@recogito/text-annotator 3.0.0-rc.53 → 3.0.0-rc.54
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/TextAnnotator.d.ts +1 -1
- package/dist/src/highlight/HighlightStyle.d.ts +1 -1
- package/dist/src/model/w3c/W3CTextFormatAdapter.d.ts +3 -3
- package/dist/text-annotator.es.js +665 -663
- 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 +6 -6
|
@@ -7,7 +7,7 @@ const re = "not-annotatable", tt = `.${re}`, it = (t) => {
|
|
|
7
7
|
}, Le = (t) => t.addEventListener("click", (e) => {
|
|
8
8
|
// Allow clicks within not-annotatable elements
|
|
9
9
|
!e.target.closest(tt) && !e.target.closest("a") && e.preventDefault();
|
|
10
|
-
}),
|
|
10
|
+
}), xt = (t) => ({
|
|
11
11
|
...t,
|
|
12
12
|
type: t.type,
|
|
13
13
|
x: t.x,
|
|
@@ -56,7 +56,7 @@ const re = "not-annotatable", tt = `.${re}`, it = (t) => {
|
|
|
56
56
|
return (...o) => {
|
|
57
57
|
clearTimeout(n), n = setTimeout(() => t.apply(void 0, o), e);
|
|
58
58
|
};
|
|
59
|
-
},
|
|
59
|
+
}, Be = function* (t) {
|
|
60
60
|
const e = document.createNodeIterator(
|
|
61
61
|
t.commonAncestorContainer,
|
|
62
62
|
NodeFilter.SHOW_ELEMENT,
|
|
@@ -65,11 +65,11 @@ const re = "not-annotatable", tt = `.${re}`, it = (t) => {
|
|
|
65
65
|
let n;
|
|
66
66
|
for (; n = e.nextNode(); )
|
|
67
67
|
n instanceof HTMLElement && (yield n);
|
|
68
|
-
},
|
|
68
|
+
}, Me = (t) => {
|
|
69
69
|
if (!Ce(t)) return [];
|
|
70
70
|
const e = [];
|
|
71
71
|
let n = null;
|
|
72
|
-
for (const o of
|
|
72
|
+
for (const o of Be(t)) {
|
|
73
73
|
let i;
|
|
74
74
|
n ? (i = document.createRange(), i.setStartAfter(n), i.setEndBefore(o)) : (i = t.cloneRange(), i.setEndBefore(o)), i.collapsed || e.push(i), n = o;
|
|
75
75
|
}
|
|
@@ -78,18 +78,18 @@ const re = "not-annotatable", tt = `.${re}`, it = (t) => {
|
|
|
78
78
|
o.setStartAfter(n), o.collapsed || e.push(o);
|
|
79
79
|
}
|
|
80
80
|
return e.length > 0 ? e : [t];
|
|
81
|
-
},
|
|
81
|
+
}, Ut = (t) => {
|
|
82
82
|
const e = t.cloneContents();
|
|
83
83
|
return e.querySelectorAll(tt).forEach((n) => n.remove()), e;
|
|
84
84
|
}, Re = (t, e, n = 10, o) => {
|
|
85
85
|
const i = o ? t.startContainer.parentElement.closest(o) : e, s = document.createRange();
|
|
86
86
|
s.setStart(i, 0), s.setEnd(t.startContainer, t.startOffset);
|
|
87
|
-
const a =
|
|
87
|
+
const a = Ut(s).textContent, r = document.createRange();
|
|
88
88
|
r.setStart(t.endContainer, t.endOffset), i === document.body ? r.setEnd(i, i.childNodes.length) : r.setEndAfter(i);
|
|
89
|
-
const
|
|
89
|
+
const d = Ut(r).textContent;
|
|
90
90
|
return {
|
|
91
91
|
prefix: a.substring(a.length - n),
|
|
92
|
-
suffix:
|
|
92
|
+
suffix: d.substring(0, n)
|
|
93
93
|
};
|
|
94
94
|
}, F = (t) => t.every((e) => e.range instanceof Range && !e.range.collapsed), ke = /^\s*$/, Ie = (t) => ke.test(t.toString()), _e = (t, e) => {
|
|
95
95
|
const n = (s) => Math.round(s * 10) / 10, o = {
|
|
@@ -149,50 +149,50 @@ const re = "not-annotatable", tt = `.${re}`, it = (t) => {
|
|
|
149
149
|
}), Ve = (t, e, n) => {
|
|
150
150
|
const o = document.createRange(), i = n ? t.startContainer.parentElement.closest(n) : e;
|
|
151
151
|
o.setStart(i, 0), o.setEnd(t.startContainer, t.startOffset);
|
|
152
|
-
const s =
|
|
153
|
-
return n ? { quote: a, start: r, end:
|
|
152
|
+
const s = Ut(o).textContent, a = t.toString(), r = s.length || 0, d = r + a.length;
|
|
153
|
+
return n ? { quote: a, start: r, end: d, range: t, offsetReference: i } : { quote: a, start: r, end: d, range: t };
|
|
154
154
|
}, ae = (t, e) => {
|
|
155
155
|
var h, u;
|
|
156
156
|
const { start: n, end: o } = t, i = t.offsetReference || e, s = document.createNodeIterator(
|
|
157
157
|
e,
|
|
158
158
|
NodeFilter.SHOW_TEXT,
|
|
159
|
-
(
|
|
160
|
-
var
|
|
161
|
-
return (
|
|
159
|
+
(g) => {
|
|
160
|
+
var v;
|
|
161
|
+
return (v = g.parentElement) != null && v.closest(tt) ? NodeFilter.FILTER_SKIP : NodeFilter.FILTER_ACCEPT;
|
|
162
162
|
}
|
|
163
163
|
);
|
|
164
164
|
let a = 0;
|
|
165
165
|
const r = document.createRange();
|
|
166
|
-
let
|
|
167
|
-
|
|
166
|
+
let d = s.nextNode();
|
|
167
|
+
d === null && console.error("Could not revive annotation target. Content missing.");
|
|
168
168
|
let f = !i;
|
|
169
|
-
for (;
|
|
170
|
-
if (f || (f = i == null ? void 0 : i.contains(
|
|
171
|
-
const
|
|
172
|
-
if (a +
|
|
173
|
-
r.setStart(
|
|
169
|
+
for (; d !== null; ) {
|
|
170
|
+
if (f || (f = i == null ? void 0 : i.contains(d)), f) {
|
|
171
|
+
const g = ((h = d.textContent) == null ? void 0 : h.length) || 0;
|
|
172
|
+
if (a + g > n) {
|
|
173
|
+
r.setStart(d, n - a);
|
|
174
174
|
break;
|
|
175
175
|
}
|
|
176
|
-
a +=
|
|
176
|
+
a += g;
|
|
177
177
|
}
|
|
178
|
-
|
|
178
|
+
d = s.nextNode();
|
|
179
179
|
}
|
|
180
|
-
for (;
|
|
181
|
-
const
|
|
182
|
-
if (a +
|
|
183
|
-
r.setEnd(
|
|
180
|
+
for (; d !== null; ) {
|
|
181
|
+
const g = ((u = d.textContent) == null ? void 0 : u.length) || 0;
|
|
182
|
+
if (a + g >= o) {
|
|
183
|
+
r.setEnd(d, o - a);
|
|
184
184
|
break;
|
|
185
185
|
}
|
|
186
|
-
a +=
|
|
186
|
+
a += g, d = s.nextNode();
|
|
187
187
|
}
|
|
188
188
|
return {
|
|
189
189
|
...t,
|
|
190
190
|
range: r
|
|
191
191
|
};
|
|
192
|
-
},
|
|
192
|
+
}, wt = (t, e) => F(t.selector) ? t : {
|
|
193
193
|
...t,
|
|
194
194
|
selector: t.selector.map((n) => n.range instanceof Range && !n.range.collapsed ? n : ae(n, e))
|
|
195
|
-
},
|
|
195
|
+
}, vt = (t, e) => F(t.target.selector) ? t : { ...t, target: wt(t.target, e) }, Ye = (t, e) => {
|
|
196
196
|
const n = t.cloneRange();
|
|
197
197
|
return e.contains(n.startContainer) || n.setStart(e, 0), e.contains(n.endContainer) || n.setEnd(e, e.childNodes.length), n;
|
|
198
198
|
}, ce = (t) => {
|
|
@@ -200,83 +200,83 @@ const re = "not-annotatable", tt = `.${re}`, it = (t) => {
|
|
|
200
200
|
return document.scrollingElement;
|
|
201
201
|
const { overflowY: e } = window.getComputedStyle(t);
|
|
202
202
|
return e !== "visible" && e !== "hidden" && t.scrollHeight > t.clientHeight ? t : ce(t.parentElement);
|
|
203
|
-
},
|
|
203
|
+
}, De = (t, e) => (n) => {
|
|
204
204
|
const o = typeof n == "string" ? n : n.id, i = (a) => {
|
|
205
|
-
const r = s.getBoundingClientRect(),
|
|
206
|
-
s.scroll({ top:
|
|
205
|
+
const r = s.getBoundingClientRect(), d = s.clientHeight, f = s.clientWidth, h = a.selector[0].range.getBoundingClientRect(), { width: u, height: g } = e.getAnnotationBounds(o), v = h.top - r.top, p = h.left - r.left, y = s.parentElement ? s.scrollTop : 0, x = s.parentElement ? s.scrollLeft : 0, l = v + y - (d - g) / 2, c = p + x - (f - u) / 2;
|
|
206
|
+
s.scroll({ top: l, left: c, behavior: "smooth" });
|
|
207
207
|
}, s = ce(t);
|
|
208
208
|
if (s) {
|
|
209
209
|
const a = e.getAnnotation(o), { range: r } = a.target.selector[0];
|
|
210
210
|
if (r && !r.collapsed)
|
|
211
211
|
return i(a.target), !0;
|
|
212
212
|
{
|
|
213
|
-
const
|
|
213
|
+
const d = wt(a.target, t), { range: f } = d.selector[0];
|
|
214
214
|
if (f && !f.collapsed)
|
|
215
|
-
return i(
|
|
215
|
+
return i(d), !0;
|
|
216
216
|
}
|
|
217
217
|
}
|
|
218
218
|
return !1;
|
|
219
219
|
}, W = {
|
|
220
220
|
fill: "rgb(0, 128, 255)",
|
|
221
221
|
fillOpacity: 0.18
|
|
222
|
-
},
|
|
222
|
+
}, At = {
|
|
223
223
|
fill: "rgb(0, 128, 255)",
|
|
224
224
|
fillOpacity: 0.45
|
|
225
|
-
},
|
|
225
|
+
}, Ke = (t, e, n, o, i) => {
|
|
226
226
|
var a, r;
|
|
227
|
-
const s = n ? typeof n == "function" ? n(t.annotation, t.state, i) || ((a = t.state) != null && a.selected ?
|
|
227
|
+
const s = n ? typeof n == "function" ? n(t.annotation, t.state, i) || ((a = t.state) != null && a.selected ? At : W) : n : (r = t.state) != null && r.selected ? At : W;
|
|
228
228
|
return o && o.paint(t, e) || s;
|
|
229
229
|
}, Xe = (t) => {
|
|
230
|
-
const { top: e, left: n } = t.getBoundingClientRect(), { innerWidth: o, innerHeight: i } = window, s = -n, a = -e, r = o - n,
|
|
231
|
-
return { top: e, left: n, minX: s, minY: a, maxX: r, maxY:
|
|
230
|
+
const { top: e, left: n } = t.getBoundingClientRect(), { innerWidth: o, innerHeight: i } = window, s = -n, a = -e, r = o - n, d = i - e;
|
|
231
|
+
return { top: e, left: n, minX: s, minY: a, maxX: r, maxY: d };
|
|
232
232
|
}, Pe = (t) => {
|
|
233
233
|
let e = /* @__PURE__ */ new Set();
|
|
234
234
|
return (o) => {
|
|
235
235
|
const i = o.map((s) => s.id);
|
|
236
236
|
(e.size !== i.length || i.some((s) => !e.has(s))) && t.set(i), e = new Set(i);
|
|
237
237
|
};
|
|
238
|
-
},
|
|
238
|
+
}, Dt = (t, e, n, o) => {
|
|
239
239
|
const { store: i, selection: s, hover: a } = e;
|
|
240
|
-
let r,
|
|
241
|
-
const h = Pe(n), u = (
|
|
242
|
-
const { x: T, y: m } = t.getBoundingClientRect(),
|
|
243
|
-
|
|
240
|
+
let r, d, f;
|
|
241
|
+
const h = Pe(n), u = (B) => {
|
|
242
|
+
const { x: T, y: m } = t.getBoundingClientRect(), A = i.getAt(B.clientX - T, B.clientY - m, !1, d);
|
|
243
|
+
A ? a.current !== A.id && (t.classList.add("hovered"), a.set(A.id)) : a.current && (t.classList.remove("hovered"), a.set(null));
|
|
244
244
|
};
|
|
245
245
|
t.addEventListener("pointermove", u);
|
|
246
|
-
const
|
|
246
|
+
const g = (B = !1) => {
|
|
247
247
|
f && f.clear();
|
|
248
|
-
const T = Xe(t), { minX: m, minY:
|
|
248
|
+
const T = Xe(t), { minX: m, minY: A, maxX: w, maxY: L } = T, M = d ? i.getIntersecting(m, A, w, L).filter(({ annotation: U }) => d(U)) : i.getIntersecting(m, A, w, L), R = s.selected.map(({ id: U }) => U), N = M.map(({ annotation: U, rects: et }) => {
|
|
249
249
|
const q = R.includes(U.id), Se = U.id === a.current;
|
|
250
250
|
return { annotation: U, rects: et, state: { selected: q, hover: Se } };
|
|
251
251
|
});
|
|
252
|
-
o.redraw(N, T, r, f,
|
|
253
|
-
},
|
|
254
|
-
f =
|
|
255
|
-
},
|
|
256
|
-
r =
|
|
257
|
-
},
|
|
258
|
-
|
|
259
|
-
},
|
|
260
|
-
i.observe(
|
|
261
|
-
const
|
|
252
|
+
o.redraw(N, T, r, f, B), setTimeout(() => h(M.map(({ annotation: U }) => U)), 1);
|
|
253
|
+
}, v = (B) => {
|
|
254
|
+
f = B, g();
|
|
255
|
+
}, p = (B) => {
|
|
256
|
+
r = B, g();
|
|
257
|
+
}, y = (B) => {
|
|
258
|
+
d = B, g(!1);
|
|
259
|
+
}, x = () => g();
|
|
260
|
+
i.observe(x);
|
|
261
|
+
const l = s.subscribe(() => g()), c = () => g(!0);
|
|
262
262
|
document.addEventListener("scroll", c, { capture: !0, passive: !0 });
|
|
263
|
-
const
|
|
264
|
-
i.recalculatePositions(), f && f.reset(),
|
|
263
|
+
const b = Yt(() => {
|
|
264
|
+
i.recalculatePositions(), f && f.reset(), g();
|
|
265
265
|
});
|
|
266
|
-
window.addEventListener("resize",
|
|
267
|
-
const S = new ResizeObserver(
|
|
266
|
+
window.addEventListener("resize", b);
|
|
267
|
+
const S = new ResizeObserver(b);
|
|
268
268
|
S.observe(t);
|
|
269
|
-
const E = { attributes: !0, childList: !0, subtree: !0 }, C = new MutationObserver((
|
|
270
|
-
|
|
269
|
+
const E = { attributes: !0, childList: !0, subtree: !0 }, C = new MutationObserver((B) => {
|
|
270
|
+
B.every((m) => m.target === t || t.contains(m.target)) || g(!0);
|
|
271
271
|
});
|
|
272
272
|
return C.observe(document.body, E), {
|
|
273
273
|
destroy: () => {
|
|
274
|
-
t.removeEventListener("pointermove", u), o.destroy(), i.unobserve(
|
|
274
|
+
t.removeEventListener("pointermove", u), o.destroy(), i.unobserve(x), l(), document.removeEventListener("scroll", c), window.removeEventListener("resize", b), S.disconnect(), C.disconnect();
|
|
275
275
|
},
|
|
276
|
-
redraw:
|
|
277
|
-
setStyle:
|
|
278
|
-
setFilter:
|
|
279
|
-
setPainter:
|
|
276
|
+
redraw: g,
|
|
277
|
+
setStyle: p,
|
|
278
|
+
setFilter: y,
|
|
279
|
+
setPainter: v,
|
|
280
280
|
setVisible: o.setVisible
|
|
281
281
|
};
|
|
282
282
|
}, $e = () => {
|
|
@@ -288,28 +288,28 @@ const re = "not-annotatable", tt = `.${re}`, it = (t) => {
|
|
|
288
288
|
t.classList.add("r6o-annotatable");
|
|
289
289
|
const e = $e(), n = e.getContext("2d");
|
|
290
290
|
document.body.appendChild(e);
|
|
291
|
-
const o = (r,
|
|
292
|
-
const { width: u, height:
|
|
293
|
-
n.clearRect(-0.5, -0.5, u + 1,
|
|
294
|
-
const { top:
|
|
295
|
-
[...r].sort((
|
|
296
|
-
const { annotation: { target: { created: c } } } =
|
|
297
|
-
return c.getTime() -
|
|
298
|
-
}).forEach((
|
|
291
|
+
const o = (r, d, f, h) => requestAnimationFrame(() => {
|
|
292
|
+
const { width: u, height: g } = e;
|
|
293
|
+
n.clearRect(-0.5, -0.5, u + 1, g + 1), h && h.clear();
|
|
294
|
+
const { top: v, left: p } = d;
|
|
295
|
+
[...r].sort((x, l) => {
|
|
296
|
+
const { annotation: { target: { created: c } } } = x, { annotation: { target: { created: b } } } = l;
|
|
297
|
+
return c.getTime() - b.getTime();
|
|
298
|
+
}).forEach((x) => {
|
|
299
299
|
var S;
|
|
300
|
-
const
|
|
301
|
-
x: E +
|
|
302
|
-
y: C +
|
|
300
|
+
const l = f ? typeof f == "function" ? f(x.annotation, x.state) : f : (S = x.state) != null && S.selected ? At : W, c = h && h.paint(x, d) || l, b = x.rects.map(({ x: E, y: C, width: O, height: B }) => ({
|
|
301
|
+
x: E + p,
|
|
302
|
+
y: C + v,
|
|
303
303
|
width: O,
|
|
304
|
-
height:
|
|
304
|
+
height: B
|
|
305
305
|
}));
|
|
306
|
-
if (n.fillStyle = c.fill, n.globalAlpha = c.fillOpacity || 1,
|
|
307
|
-
({ x: E, y: C, width: O, height:
|
|
306
|
+
if (n.fillStyle = c.fill, n.globalAlpha = c.fillOpacity || 1, b.forEach(
|
|
307
|
+
({ x: E, y: C, width: O, height: B }) => n.fillRect(E, C, O, B)
|
|
308
308
|
), c.underlineColor) {
|
|
309
309
|
n.globalAlpha = 1, n.strokeStyle = c.underlineColor, n.lineWidth = c.underlineThickness ?? 1;
|
|
310
310
|
const E = c.underlineOffset ?? 0;
|
|
311
|
-
|
|
312
|
-
n.beginPath(), n.moveTo(C, O + T + E), n.lineTo(C +
|
|
311
|
+
b.forEach(({ x: C, y: O, width: B, height: T }) => {
|
|
312
|
+
n.beginPath(), n.moveTo(C, O + T + E), n.lineTo(C + B, O + T + E), n.stroke();
|
|
313
313
|
});
|
|
314
314
|
}
|
|
315
315
|
});
|
|
@@ -325,7 +325,7 @@ const re = "not-annotatable", tt = `.${re}`, it = (t) => {
|
|
|
325
325
|
},
|
|
326
326
|
redraw: o
|
|
327
327
|
};
|
|
328
|
-
}, ze = (t, e, n) =>
|
|
328
|
+
}, ze = (t, e, n) => Dt(t, e, n, je(t));
|
|
329
329
|
var Fe = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, j = function(t) {
|
|
330
330
|
return typeof t == "string" ? t.length > 0 : typeof t == "number";
|
|
331
331
|
}, V = function(t, e, n) {
|
|
@@ -336,7 +336,7 @@ var Fe = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, j = function(t) {
|
|
|
336
336
|
return (t = isFinite(t) ? t % 360 : 0) > 0 ? t : t + 360;
|
|
337
337
|
}, Pt = function(t) {
|
|
338
338
|
return { r: X(t.r, 0, 255), g: X(t.g, 0, 255), b: X(t.b, 0, 255), a: X(t.a) };
|
|
339
|
-
},
|
|
339
|
+
}, Et = function(t) {
|
|
340
340
|
return { r: V(t.r), g: V(t.g), b: V(t.b), a: V(t.a, 3) };
|
|
341
341
|
}, We = /^#([0-9a-f]{3,8})$/i, ht = function(t) {
|
|
342
342
|
var e = t.toString(16);
|
|
@@ -347,8 +347,8 @@ var Fe = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, j = function(t) {
|
|
|
347
347
|
}, ue = function(t) {
|
|
348
348
|
var e = t.h, n = t.s, o = t.v, i = t.a;
|
|
349
349
|
e = e / 360 * 6, n /= 100, o /= 100;
|
|
350
|
-
var s = Math.floor(e), a = o * (1 - n), r = o * (1 - (e - s) * n),
|
|
351
|
-
return { r: 255 * [o, r, a, a,
|
|
350
|
+
var s = Math.floor(e), a = o * (1 - n), r = o * (1 - (e - s) * n), d = o * (1 - (1 - e + s) * n), f = s % 6;
|
|
351
|
+
return { r: 255 * [o, r, a, a, d, o][f], g: 255 * [d, o, o, r, a, a][f], b: 255 * [a, a, d, o, o, r][f], a: i };
|
|
352
352
|
}, $t = function(t) {
|
|
353
353
|
return { h: le(t.h), s: X(t.s, 0, 100), l: X(t.l, 0, 100), a: X(t.a) };
|
|
354
354
|
}, Ht = function(t) {
|
|
@@ -393,10 +393,10 @@ var Fe = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, j = function(t) {
|
|
|
393
393
|
return [null, void 0];
|
|
394
394
|
}, Ze = function(t) {
|
|
395
395
|
return typeof t == "string" ? Ft(t.trim(), zt.string) : typeof t == "object" && t !== null ? Ft(t, zt.object) : [null, void 0];
|
|
396
|
-
},
|
|
396
|
+
}, St = function(t, e) {
|
|
397
397
|
var n = at(t);
|
|
398
398
|
return { h: n.h, s: X(n.s + 100 * e, 0, 100), l: n.l, a: n.a };
|
|
399
|
-
},
|
|
399
|
+
}, Ct = function(t) {
|
|
400
400
|
return (299 * t.r + 587 * t.g + 114 * t.b) / 1e3 / 255;
|
|
401
401
|
}, Wt = function(t, e) {
|
|
402
402
|
var n = at(t);
|
|
@@ -408,18 +408,18 @@ var Fe = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, j = function(t) {
|
|
|
408
408
|
return t.prototype.isValid = function() {
|
|
409
409
|
return this.parsed !== null;
|
|
410
410
|
}, t.prototype.brightness = function() {
|
|
411
|
-
return V(
|
|
411
|
+
return V(Ct(this.rgba), 2);
|
|
412
412
|
}, t.prototype.isDark = function() {
|
|
413
|
-
return
|
|
413
|
+
return Ct(this.rgba) < 0.5;
|
|
414
414
|
}, t.prototype.isLight = function() {
|
|
415
|
-
return
|
|
415
|
+
return Ct(this.rgba) >= 0.5;
|
|
416
416
|
}, t.prototype.toHex = function() {
|
|
417
|
-
return e =
|
|
417
|
+
return e = Et(this.rgba), n = e.r, o = e.g, i = e.b, a = (s = e.a) < 1 ? ht(V(255 * s)) : "", "#" + ht(n) + ht(o) + ht(i) + a;
|
|
418
418
|
var e, n, o, i, s, a;
|
|
419
419
|
}, t.prototype.toRgb = function() {
|
|
420
|
-
return
|
|
420
|
+
return Et(this.rgba);
|
|
421
421
|
}, t.prototype.toRgbString = function() {
|
|
422
|
-
return e =
|
|
422
|
+
return e = Et(this.rgba), n = e.r, o = e.g, i = e.b, (s = e.a) < 1 ? "rgba(" + n + ", " + o + ", " + i + ", " + s + ")" : "rgb(" + n + ", " + o + ", " + i + ")";
|
|
423
423
|
var e, n, o, i, s;
|
|
424
424
|
}, t.prototype.toHsl = function() {
|
|
425
425
|
return Ht(at(this.rgba));
|
|
@@ -433,11 +433,11 @@ var Fe = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, j = function(t) {
|
|
|
433
433
|
return $({ r: 255 - (e = this.rgba).r, g: 255 - e.g, b: 255 - e.b, a: e.a });
|
|
434
434
|
var e;
|
|
435
435
|
}, t.prototype.saturate = function(e) {
|
|
436
|
-
return e === void 0 && (e = 0.1), $(
|
|
436
|
+
return e === void 0 && (e = 0.1), $(St(this.rgba, e));
|
|
437
437
|
}, t.prototype.desaturate = function(e) {
|
|
438
|
-
return e === void 0 && (e = 0.1), $(
|
|
438
|
+
return e === void 0 && (e = 0.1), $(St(this.rgba, -e));
|
|
439
439
|
}, t.prototype.grayscale = function() {
|
|
440
|
-
return $(
|
|
440
|
+
return $(St(this.rgba, -1));
|
|
441
441
|
}, t.prototype.lighten = function(e) {
|
|
442
442
|
return e === void 0 && (e = 0.1), $(Wt(this.rgba, e));
|
|
443
443
|
}, t.prototype.darken = function(e) {
|
|
@@ -473,25 +473,25 @@ const tn = (t) => [
|
|
|
473
473
|
setVisible: (s) => {
|
|
474
474
|
console.log("setVisible not implemented on CSS Custom Highlights renderer");
|
|
475
475
|
},
|
|
476
|
-
redraw: (s, a, r,
|
|
477
|
-
|
|
476
|
+
redraw: (s, a, r, d) => {
|
|
477
|
+
d && d.clear();
|
|
478
478
|
const f = new Set(s.map((u) => u.annotation.id));
|
|
479
479
|
Array.from(e).filter((u) => !f.has(u));
|
|
480
480
|
const h = s.map((u) => {
|
|
481
|
-
var
|
|
482
|
-
const
|
|
483
|
-
return `::highlight(_${u.annotation.id}) { ${tn(
|
|
481
|
+
var p;
|
|
482
|
+
const g = r ? typeof r == "function" ? r(u.annotation, u.state) : r : (p = u.state) != null && p.selected ? At : W, v = d && d.paint(u, a) || g;
|
|
483
|
+
return `::highlight(_${u.annotation.id}) { ${tn(v)} }`;
|
|
484
484
|
});
|
|
485
485
|
t.innerHTML = h.join(`
|
|
486
486
|
`), CSS.highlights.clear(), s.forEach(({ annotation: u }) => {
|
|
487
|
-
const
|
|
488
|
-
CSS.highlights.set(`_${u.id}`,
|
|
487
|
+
const g = u.target.selector.map((p) => p.range), v = new Highlight(...g);
|
|
488
|
+
CSS.highlights.set(`_${u.id}`, v);
|
|
489
489
|
}), e = f;
|
|
490
490
|
}
|
|
491
491
|
};
|
|
492
|
-
}, nn = (t, e, n) =>
|
|
492
|
+
}, nn = (t, e, n) => Dt(t, e, n, en());
|
|
493
493
|
var Gt = Object.prototype.hasOwnProperty;
|
|
494
|
-
function
|
|
494
|
+
function Vt(t, e) {
|
|
495
495
|
var n, o;
|
|
496
496
|
if (t === e) return !0;
|
|
497
497
|
if (t && e && (n = t.constructor) === e.constructor) {
|
|
@@ -499,13 +499,13 @@ function Ut(t, e) {
|
|
|
499
499
|
if (n === RegExp) return t.toString() === e.toString();
|
|
500
500
|
if (n === Array) {
|
|
501
501
|
if ((o = t.length) === e.length)
|
|
502
|
-
for (; o-- &&
|
|
502
|
+
for (; o-- && Vt(t[o], e[o]); ) ;
|
|
503
503
|
return o === -1;
|
|
504
504
|
}
|
|
505
505
|
if (!n || typeof t == "object") {
|
|
506
506
|
o = 0;
|
|
507
507
|
for (n in t)
|
|
508
|
-
if (Gt.call(t, n) && ++o && !Gt.call(e, n) || !(n in e) || !
|
|
508
|
+
if (Gt.call(t, n) && ++o && !Gt.call(e, n) || !(n in e) || !Vt(t[n], e[n])) return !1;
|
|
509
509
|
return Object.keys(e).length === o;
|
|
510
510
|
}
|
|
511
511
|
}
|
|
@@ -523,18 +523,18 @@ const on = (t, e) => {
|
|
|
523
523
|
destroy: () => {
|
|
524
524
|
e.remove();
|
|
525
525
|
},
|
|
526
|
-
redraw: (a, r,
|
|
527
|
-
const
|
|
528
|
-
if (!f && !
|
|
529
|
-
|
|
530
|
-
const { annotation: { target: { created:
|
|
531
|
-
return
|
|
532
|
-
}).forEach((
|
|
533
|
-
|
|
534
|
-
const
|
|
535
|
-
if (
|
|
526
|
+
redraw: (a, r, d, f, h) => {
|
|
527
|
+
const g = !(Vt(n, a) && h);
|
|
528
|
+
if (!f && !g) return;
|
|
529
|
+
g && (e.innerHTML = ""), [...a].sort((p, y) => {
|
|
530
|
+
const { annotation: { target: { created: x } } } = p, { annotation: { target: { created: l } } } = y;
|
|
531
|
+
return x && l ? x.getTime() - l.getTime() : 0;
|
|
532
|
+
}).forEach((p) => {
|
|
533
|
+
p.rects.map((y) => {
|
|
534
|
+
const x = on(y, a), l = Ke(p, r, d, f, x);
|
|
535
|
+
if (g) {
|
|
536
536
|
const c = document.createElement("span");
|
|
537
|
-
c.className = "r6o-annotation", c.dataset.annotation =
|
|
537
|
+
c.className = "r6o-annotation", c.dataset.annotation = p.annotation.id, c.style.left = `${y.x}px`, c.style.top = `${y.y}px`, c.style.width = `${y.width}px`, c.style.height = `${y.height}px`, c.style.backgroundColor = $((l == null ? void 0 : l.fill) || W.fill).alpha((l == null ? void 0 : l.fillOpacity) === void 0 ? W.fillOpacity : l.fillOpacity).toHex(), l.underlineStyle && (c.style.borderStyle = l.underlineStyle), l.underlineColor && (c.style.borderColor = l.underlineColor), l.underlineThickness && (c.style.borderBottomWidth = `${l.underlineThickness}px`), l.underlineOffset && (c.style.paddingBottom = `${l.underlineOffset}px`), e.appendChild(c);
|
|
538
538
|
}
|
|
539
539
|
});
|
|
540
540
|
}), n = a;
|
|
@@ -543,21 +543,21 @@ const on = (t, e) => {
|
|
|
543
543
|
a ? e.classList.remove("hidden") : e.classList.add("hidden");
|
|
544
544
|
}
|
|
545
545
|
};
|
|
546
|
-
}, rn = (t, e, n) =>
|
|
546
|
+
}, rn = (t, e, n) => Dt(t, e, n, sn(t)), Y = [];
|
|
547
547
|
for (let t = 0; t < 256; ++t)
|
|
548
548
|
Y.push((t + 256).toString(16).slice(1));
|
|
549
549
|
function an(t, e = 0) {
|
|
550
550
|
return (Y[t[e + 0]] + Y[t[e + 1]] + Y[t[e + 2]] + Y[t[e + 3]] + "-" + Y[t[e + 4]] + Y[t[e + 5]] + "-" + Y[t[e + 6]] + Y[t[e + 7]] + "-" + Y[t[e + 8]] + Y[t[e + 9]] + "-" + Y[t[e + 10]] + Y[t[e + 11]] + Y[t[e + 12]] + Y[t[e + 13]] + Y[t[e + 14]] + Y[t[e + 15]]).toLowerCase();
|
|
551
551
|
}
|
|
552
|
-
let
|
|
552
|
+
let Lt;
|
|
553
553
|
const cn = new Uint8Array(16);
|
|
554
554
|
function ln() {
|
|
555
|
-
if (!
|
|
555
|
+
if (!Lt) {
|
|
556
556
|
if (typeof crypto > "u" || !crypto.getRandomValues)
|
|
557
557
|
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
558
|
-
|
|
558
|
+
Lt = crypto.getRandomValues.bind(crypto);
|
|
559
559
|
}
|
|
560
|
-
return
|
|
560
|
+
return Lt(cn);
|
|
561
561
|
}
|
|
562
562
|
const dn = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), Qt = { randomUUID: dn };
|
|
563
563
|
function fe(t, e, n) {
|
|
@@ -588,21 +588,21 @@ function G(t, e) {
|
|
|
588
588
|
}
|
|
589
589
|
return t !== t && e !== e;
|
|
590
590
|
}
|
|
591
|
-
function
|
|
591
|
+
function Tt() {
|
|
592
592
|
}
|
|
593
593
|
function un(t, e) {
|
|
594
594
|
return t != t ? e == e : t !== e || t && typeof t == "object" || typeof t == "function";
|
|
595
595
|
}
|
|
596
596
|
const Q = [];
|
|
597
|
-
function
|
|
597
|
+
function Kt(t, e = Tt) {
|
|
598
598
|
let n;
|
|
599
599
|
const o = /* @__PURE__ */ new Set();
|
|
600
600
|
function i(r) {
|
|
601
601
|
if (un(t, r) && (t = r, n)) {
|
|
602
|
-
const
|
|
602
|
+
const d = !Q.length;
|
|
603
603
|
for (const f of o)
|
|
604
604
|
f[1](), Q.push(f, t);
|
|
605
|
-
if (
|
|
605
|
+
if (d) {
|
|
606
606
|
for (let f = 0; f < Q.length; f += 2)
|
|
607
607
|
Q[f][0](Q[f + 1]);
|
|
608
608
|
Q.length = 0;
|
|
@@ -612,16 +612,16 @@ function Dt(t, e = Lt) {
|
|
|
612
612
|
function s(r) {
|
|
613
613
|
i(r(t));
|
|
614
614
|
}
|
|
615
|
-
function a(r,
|
|
616
|
-
const f = [r,
|
|
617
|
-
return o.add(f), o.size === 1 && (n = e(i, s) ||
|
|
615
|
+
function a(r, d = Tt) {
|
|
616
|
+
const f = [r, d];
|
|
617
|
+
return o.add(f), o.size === 1 && (n = e(i, s) || Tt), r(t), () => {
|
|
618
618
|
o.delete(f), o.size === 0 && n && (n(), n = null);
|
|
619
619
|
};
|
|
620
620
|
}
|
|
621
621
|
return { set: i, update: s, subscribe: a };
|
|
622
622
|
}
|
|
623
623
|
const fn = (t) => {
|
|
624
|
-
const { subscribe: e, set: n } =
|
|
624
|
+
const { subscribe: e, set: n } = Kt();
|
|
625
625
|
let o;
|
|
626
626
|
return e((i) => o = i), t.observe(({ changes: i }) => {
|
|
627
627
|
if (o) {
|
|
@@ -638,56 +638,56 @@ const fn = (t) => {
|
|
|
638
638
|
};
|
|
639
639
|
};
|
|
640
640
|
var hn = /* @__PURE__ */ ((t) => (t.EDIT = "EDIT", t.SELECT = "SELECT", t.NONE = "NONE", t))(hn || {});
|
|
641
|
-
const
|
|
642
|
-
const { subscribe: o, set: i } =
|
|
643
|
-
let s = e, a =
|
|
644
|
-
o((
|
|
641
|
+
const gt = { selected: [] }, gn = (t, e, n) => {
|
|
642
|
+
const { subscribe: o, set: i } = Kt(gt);
|
|
643
|
+
let s = e, a = gt;
|
|
644
|
+
o((p) => a = p);
|
|
645
645
|
const r = () => {
|
|
646
|
-
G(a,
|
|
647
|
-
},
|
|
648
|
-
var
|
|
649
|
-
return ((
|
|
650
|
-
}, f = (
|
|
651
|
-
if (
|
|
646
|
+
G(a, gt) || i(gt);
|
|
647
|
+
}, d = () => {
|
|
648
|
+
var p;
|
|
649
|
+
return ((p = a.selected) == null ? void 0 : p.length) === 0;
|
|
650
|
+
}, f = (p) => {
|
|
651
|
+
if (d())
|
|
652
652
|
return !1;
|
|
653
|
-
const
|
|
654
|
-
return a.selected.some((
|
|
655
|
-
}, h = (
|
|
656
|
-
let
|
|
657
|
-
if (Array.isArray(
|
|
658
|
-
if (
|
|
659
|
-
console.warn("Invalid selection: " +
|
|
653
|
+
const y = typeof p == "string" ? p : p.id;
|
|
654
|
+
return a.selected.some((x) => x.id === y);
|
|
655
|
+
}, h = (p, y) => {
|
|
656
|
+
let x;
|
|
657
|
+
if (Array.isArray(p)) {
|
|
658
|
+
if (x = p.map((c) => t.getAnnotation(c)).filter(Boolean), x.length < p.length) {
|
|
659
|
+
console.warn("Invalid selection: " + p.filter((c) => !x.some((b) => b.id === c)));
|
|
660
660
|
return;
|
|
661
661
|
}
|
|
662
662
|
} else {
|
|
663
|
-
const c = t.getAnnotation(
|
|
663
|
+
const c = t.getAnnotation(p);
|
|
664
664
|
if (!c) {
|
|
665
|
-
console.warn("Invalid selection: " +
|
|
665
|
+
console.warn("Invalid selection: " + p);
|
|
666
666
|
return;
|
|
667
667
|
}
|
|
668
|
-
|
|
668
|
+
x = [c];
|
|
669
669
|
}
|
|
670
|
-
const
|
|
671
|
-
const S = Zt(
|
|
672
|
-
return S === "EDIT" ? [...c, { id:
|
|
670
|
+
const l = x.reduce((c, b) => {
|
|
671
|
+
const S = Zt(b, s);
|
|
672
|
+
return S === "EDIT" ? [...c, { id: b.id, editable: !0 }] : S === "SELECT" ? [...c, { id: b.id }] : c;
|
|
673
673
|
}, []);
|
|
674
|
-
i({ selected:
|
|
675
|
-
}, u = (
|
|
676
|
-
const
|
|
674
|
+
i({ selected: l, event: y });
|
|
675
|
+
}, u = (p, y) => {
|
|
676
|
+
const x = Array.isArray(p) ? p : [p], l = x.map((c) => t.getAnnotation(c)).filter((c) => !!c);
|
|
677
677
|
i({
|
|
678
|
-
selected:
|
|
679
|
-
const
|
|
680
|
-
return { id: c.id, editable:
|
|
678
|
+
selected: l.map((c) => {
|
|
679
|
+
const b = y === void 0 ? Zt(c, s) === "EDIT" : y;
|
|
680
|
+
return { id: c.id, editable: b };
|
|
681
681
|
})
|
|
682
|
-
}),
|
|
683
|
-
},
|
|
684
|
-
if (
|
|
682
|
+
}), l.length !== x.length && console.warn("Invalid selection", p);
|
|
683
|
+
}, g = (p) => {
|
|
684
|
+
if (d())
|
|
685
685
|
return !1;
|
|
686
|
-
const { selected:
|
|
687
|
-
|
|
688
|
-
},
|
|
686
|
+
const { selected: y } = a;
|
|
687
|
+
y.some(({ id: x }) => p.includes(x)) && i({ selected: y.filter(({ id: x }) => !p.includes(x)) });
|
|
688
|
+
}, v = (p) => s = p;
|
|
689
689
|
return t.observe(
|
|
690
|
-
({ changes:
|
|
690
|
+
({ changes: p }) => g((p.deleted || []).map((y) => y.id))
|
|
691
691
|
), {
|
|
692
692
|
get event() {
|
|
693
693
|
return a ? a.event : null;
|
|
@@ -699,28 +699,28 @@ const pt = { selected: [] }, pn = (t, e, n) => {
|
|
|
699
699
|
return s;
|
|
700
700
|
},
|
|
701
701
|
clear: r,
|
|
702
|
-
isEmpty:
|
|
702
|
+
isEmpty: d,
|
|
703
703
|
isSelected: f,
|
|
704
704
|
setSelected: u,
|
|
705
|
-
setUserSelectAction:
|
|
705
|
+
setUserSelectAction: v,
|
|
706
706
|
subscribe: o,
|
|
707
707
|
userSelect: h
|
|
708
708
|
};
|
|
709
|
-
}, Zt = (t, e, n) => typeof e == "function" ? e(t) : e || "EDIT",
|
|
709
|
+
}, Zt = (t, e, n) => typeof e == "function" ? e(t) : e || "EDIT", D = [];
|
|
710
710
|
for (let t = 0; t < 256; ++t)
|
|
711
|
-
|
|
712
|
-
function
|
|
713
|
-
return (
|
|
711
|
+
D.push((t + 256).toString(16).slice(1));
|
|
712
|
+
function pn(t, e = 0) {
|
|
713
|
+
return (D[t[e + 0]] + D[t[e + 1]] + D[t[e + 2]] + D[t[e + 3]] + "-" + D[t[e + 4]] + D[t[e + 5]] + "-" + D[t[e + 6]] + D[t[e + 7]] + "-" + D[t[e + 8]] + D[t[e + 9]] + "-" + D[t[e + 10]] + D[t[e + 11]] + D[t[e + 12]] + D[t[e + 13]] + D[t[e + 14]] + D[t[e + 15]]).toLowerCase();
|
|
714
714
|
}
|
|
715
|
-
let
|
|
715
|
+
let Ot;
|
|
716
716
|
const mn = new Uint8Array(16);
|
|
717
717
|
function yn() {
|
|
718
|
-
if (!
|
|
718
|
+
if (!Ot) {
|
|
719
719
|
if (typeof crypto > "u" || !crypto.getRandomValues)
|
|
720
720
|
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
721
|
-
|
|
721
|
+
Ot = crypto.getRandomValues.bind(crypto);
|
|
722
722
|
}
|
|
723
|
-
return
|
|
723
|
+
return Ot(mn);
|
|
724
724
|
}
|
|
725
725
|
const bn = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), te = { randomUUID: bn };
|
|
726
726
|
function he(t, e, n) {
|
|
@@ -728,9 +728,9 @@ function he(t, e, n) {
|
|
|
728
728
|
return te.randomUUID();
|
|
729
729
|
t = t || {};
|
|
730
730
|
const o = t.random || (t.rng || yn)();
|
|
731
|
-
return o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128,
|
|
731
|
+
return o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128, pn(o);
|
|
732
732
|
}
|
|
733
|
-
const
|
|
733
|
+
const Bt = (t) => {
|
|
734
734
|
const e = (n) => {
|
|
735
735
|
const o = { ...n };
|
|
736
736
|
return n.created && typeof n.created == "string" && (o.created = new Date(n.created)), n.updated && typeof n.updated == "string" && (o.updated = new Date(n.updated)), o;
|
|
@@ -755,7 +755,7 @@ const Ot = (t) => {
|
|
|
755
755
|
}, xn = (t, e) => e.bodies.map((n) => {
|
|
756
756
|
const o = t.bodies.find((i) => i.id === n.id);
|
|
757
757
|
return { newBody: n, oldBody: o && !G(o, n) ? o : void 0 };
|
|
758
|
-
}).filter(({ oldBody: n }) => n).map(({ oldBody: n, newBody: o }) => ({ oldBody: n, newBody: o })), vn = (t, e) => !G(t.target, e.target),
|
|
758
|
+
}).filter(({ oldBody: n }) => n).map(({ oldBody: n, newBody: o }) => ({ oldBody: n, newBody: o })), vn = (t, e) => !G(t.target, e.target), ge = (t, e) => {
|
|
759
759
|
const n = wn(t, e), o = An(t, e), i = xn(t, e);
|
|
760
760
|
return {
|
|
761
761
|
oldValue: t,
|
|
@@ -773,10 +773,10 @@ const En = (t, e) => {
|
|
|
773
773
|
if (!(t.options.origin ? t.options.origin === s : s !== "SILENT"))
|
|
774
774
|
return !1;
|
|
775
775
|
if (t.options.ignore) {
|
|
776
|
-
const { ignore: a } = t.options, r = (
|
|
776
|
+
const { ignore: a } = t.options, r = (d) => d && d.length > 0;
|
|
777
777
|
if (!(r(i.created) || r(i.deleted))) {
|
|
778
|
-
const
|
|
779
|
-
if (a === "BODY_ONLY" &&
|
|
778
|
+
const d = (n = i.updated) == null ? void 0 : n.some((h) => r(h.bodiesCreated) || r(h.bodiesDeleted) || r(h.bodiesUpdated)), f = (o = i.updated) == null ? void 0 : o.some((h) => h.targetUpdated);
|
|
779
|
+
if (a === "BODY_ONLY" && d && !f || a === "TARGET_ONLY" && f && !d)
|
|
780
780
|
return !1;
|
|
781
781
|
}
|
|
782
782
|
}
|
|
@@ -790,24 +790,24 @@ const En = (t, e) => {
|
|
|
790
790
|
} else
|
|
791
791
|
return !0;
|
|
792
792
|
}, Sn = (t, e) => {
|
|
793
|
-
const n = new Set((t.created || []).map((u) => u.id)), o = new Set((t.updated || []).map(({ newValue: u }) => u.id)), i = new Set((e.created || []).map((u) => u.id)), s = new Set((e.deleted || []).map((u) => u.id)), a = new Set((e.updated || []).map(({ oldValue: u }) => u.id)), r = new Set((e.updated || []).filter(({ oldValue: u }) => n.has(u.id) || o.has(u.id)).map(({ oldValue: u }) => u.id)),
|
|
794
|
-
...(t.created || []).filter((u) => !s.has(u.id)).map((u) => a.has(u.id) ? e.updated.find(({ oldValue:
|
|
793
|
+
const n = new Set((t.created || []).map((u) => u.id)), o = new Set((t.updated || []).map(({ newValue: u }) => u.id)), i = new Set((e.created || []).map((u) => u.id)), s = new Set((e.deleted || []).map((u) => u.id)), a = new Set((e.updated || []).map(({ oldValue: u }) => u.id)), r = new Set((e.updated || []).filter(({ oldValue: u }) => n.has(u.id) || o.has(u.id)).map(({ oldValue: u }) => u.id)), d = [
|
|
794
|
+
...(t.created || []).filter((u) => !s.has(u.id)).map((u) => a.has(u.id) ? e.updated.find(({ oldValue: g }) => g.id === u.id).newValue : u),
|
|
795
795
|
...e.created || []
|
|
796
796
|
], f = [
|
|
797
797
|
...(t.deleted || []).filter((u) => !i.has(u.id)),
|
|
798
798
|
...(e.deleted || []).filter((u) => !n.has(u.id))
|
|
799
799
|
], h = [
|
|
800
800
|
...(t.updated || []).filter(({ newValue: u }) => !s.has(u.id)).map((u) => {
|
|
801
|
-
const { oldValue:
|
|
802
|
-
if (a.has(
|
|
803
|
-
const
|
|
804
|
-
return
|
|
801
|
+
const { oldValue: g, newValue: v } = u;
|
|
802
|
+
if (a.has(v.id)) {
|
|
803
|
+
const p = e.updated.find((y) => y.oldValue.id === v.id).newValue;
|
|
804
|
+
return ge(g, p);
|
|
805
805
|
} else
|
|
806
806
|
return u;
|
|
807
807
|
}),
|
|
808
808
|
...(e.updated || []).filter(({ oldValue: u }) => !r.has(u.id))
|
|
809
809
|
];
|
|
810
|
-
return { created:
|
|
810
|
+
return { created: d, deleted: f, updated: h };
|
|
811
811
|
}, Mt = (t) => {
|
|
812
812
|
const e = t.id === void 0 ? he() : t.id;
|
|
813
813
|
return {
|
|
@@ -823,170 +823,170 @@ const En = (t, e) => {
|
|
|
823
823
|
}
|
|
824
824
|
};
|
|
825
825
|
}, Cn = (t) => t.id !== void 0, Ln = () => {
|
|
826
|
-
const t = /* @__PURE__ */ new Map(), e = /* @__PURE__ */ new Map(), n = [], o = (m,
|
|
827
|
-
n.push({ onChange: m, options:
|
|
826
|
+
const t = /* @__PURE__ */ new Map(), e = /* @__PURE__ */ new Map(), n = [], o = (m, A = {}) => {
|
|
827
|
+
n.push({ onChange: m, options: A });
|
|
828
828
|
}, i = (m) => {
|
|
829
|
-
const
|
|
830
|
-
|
|
831
|
-
}, s = (m,
|
|
832
|
-
const
|
|
829
|
+
const A = n.findIndex((w) => w.onChange == m);
|
|
830
|
+
A > -1 && n.splice(A, 1);
|
|
831
|
+
}, s = (m, A) => {
|
|
832
|
+
const w = {
|
|
833
833
|
origin: m,
|
|
834
834
|
changes: {
|
|
835
|
-
created:
|
|
836
|
-
updated:
|
|
837
|
-
deleted:
|
|
835
|
+
created: A.created || [],
|
|
836
|
+
updated: A.updated || [],
|
|
837
|
+
deleted: A.deleted || []
|
|
838
838
|
},
|
|
839
839
|
state: [...t.values()]
|
|
840
840
|
};
|
|
841
841
|
n.forEach((L) => {
|
|
842
|
-
En(L,
|
|
842
|
+
En(L, w) && L.onChange(w);
|
|
843
843
|
});
|
|
844
|
-
}, a = (m,
|
|
844
|
+
}, a = (m, A = k.LOCAL) => {
|
|
845
845
|
if (m.id && t.get(m.id))
|
|
846
846
|
throw Error(`Cannot add annotation ${m.id} - exists already`);
|
|
847
847
|
{
|
|
848
|
-
const
|
|
849
|
-
t.set(
|
|
848
|
+
const w = Mt(m);
|
|
849
|
+
t.set(w.id, w), w.bodies.forEach((L) => e.set(L.id, w.id)), s(A, { created: [w] });
|
|
850
850
|
}
|
|
851
|
-
}, r = (m,
|
|
852
|
-
const
|
|
853
|
-
if (
|
|
854
|
-
const R =
|
|
855
|
-
return L ===
|
|
851
|
+
}, r = (m, A) => {
|
|
852
|
+
const w = Mt(typeof m == "string" ? A : m), L = typeof m == "string" ? m : m.id, M = L && t.get(L);
|
|
853
|
+
if (M) {
|
|
854
|
+
const R = ge(M, w);
|
|
855
|
+
return L === w.id ? t.set(L, w) : (t.delete(L), t.set(w.id, w)), M.bodies.forEach((N) => e.delete(N.id)), w.bodies.forEach((N) => e.set(N.id, w.id)), R;
|
|
856
856
|
} else
|
|
857
857
|
console.warn(`Cannot update annotation ${L} - does not exist`);
|
|
858
|
-
},
|
|
859
|
-
const L = Cn(
|
|
860
|
-
|
|
861
|
-
}, f = (m,
|
|
862
|
-
const
|
|
863
|
-
const R = r(
|
|
858
|
+
}, d = (m, A = k.LOCAL, w = k.LOCAL) => {
|
|
859
|
+
const L = Cn(A) ? w : A, M = r(m, A);
|
|
860
|
+
M && s(L, { updated: [M] });
|
|
861
|
+
}, f = (m, A = k.LOCAL) => {
|
|
862
|
+
const w = m.reduce((L, M) => {
|
|
863
|
+
const R = r(M);
|
|
864
864
|
return R ? [...L, R] : L;
|
|
865
865
|
}, []);
|
|
866
|
-
|
|
867
|
-
}, h = (m,
|
|
868
|
-
const
|
|
869
|
-
if (
|
|
866
|
+
w.length > 0 && s(A, { updated: w });
|
|
867
|
+
}, h = (m, A = k.LOCAL) => {
|
|
868
|
+
const w = t.get(m.annotation);
|
|
869
|
+
if (w) {
|
|
870
870
|
const L = {
|
|
871
|
-
...
|
|
872
|
-
bodies: [...
|
|
871
|
+
...w,
|
|
872
|
+
bodies: [...w.bodies, m]
|
|
873
873
|
};
|
|
874
|
-
t.set(
|
|
875
|
-
oldValue:
|
|
874
|
+
t.set(w.id, L), e.set(m.id, L.id), s(A, { updated: [{
|
|
875
|
+
oldValue: w,
|
|
876
876
|
newValue: L,
|
|
877
877
|
bodiesCreated: [m]
|
|
878
878
|
}] });
|
|
879
879
|
} else
|
|
880
880
|
console.warn(`Attempt to add body to missing annotation: ${m.annotation}`);
|
|
881
|
-
}, u = () => [...t.values()],
|
|
882
|
-
const
|
|
883
|
-
t.clear(), e.clear(), s(m, { deleted:
|
|
884
|
-
},
|
|
881
|
+
}, u = () => [...t.values()], g = (m = k.LOCAL) => {
|
|
882
|
+
const A = [...t.values()];
|
|
883
|
+
t.clear(), e.clear(), s(m, { deleted: A });
|
|
884
|
+
}, v = (m, A = !0, w = k.LOCAL) => {
|
|
885
885
|
const L = m.map(Mt);
|
|
886
|
-
if (
|
|
887
|
-
const
|
|
886
|
+
if (A) {
|
|
887
|
+
const M = [...t.values()];
|
|
888
888
|
t.clear(), e.clear(), L.forEach((R) => {
|
|
889
889
|
t.set(R.id, R), R.bodies.forEach((N) => e.set(N.id, R.id));
|
|
890
|
-
}), s(
|
|
890
|
+
}), s(w, { created: L, deleted: M });
|
|
891
891
|
} else {
|
|
892
|
-
const
|
|
892
|
+
const M = m.reduce((R, N) => {
|
|
893
893
|
const U = N.id && t.get(N.id);
|
|
894
894
|
return U ? [...R, U] : R;
|
|
895
895
|
}, []);
|
|
896
|
-
if (
|
|
897
|
-
throw Error(`Bulk insert would overwrite the following annotations: ${
|
|
896
|
+
if (M.length > 0)
|
|
897
|
+
throw Error(`Bulk insert would overwrite the following annotations: ${M.map((R) => R.id).join(", ")}`);
|
|
898
898
|
L.forEach((R) => {
|
|
899
899
|
t.set(R.id, R), R.bodies.forEach((N) => e.set(N.id, R.id));
|
|
900
|
-
}), s(
|
|
900
|
+
}), s(w, { created: L });
|
|
901
901
|
}
|
|
902
|
-
},
|
|
903
|
-
const
|
|
904
|
-
if (
|
|
905
|
-
return t.delete(
|
|
906
|
-
console.warn(`Attempt to delete missing annotation: ${
|
|
907
|
-
},
|
|
908
|
-
const
|
|
909
|
-
|
|
910
|
-
},
|
|
911
|
-
const
|
|
912
|
-
const R =
|
|
902
|
+
}, p = (m) => {
|
|
903
|
+
const A = typeof m == "string" ? m : m.id, w = t.get(A);
|
|
904
|
+
if (w)
|
|
905
|
+
return t.delete(A), w.bodies.forEach((L) => e.delete(L.id)), w;
|
|
906
|
+
console.warn(`Attempt to delete missing annotation: ${A}`);
|
|
907
|
+
}, y = (m, A = k.LOCAL) => {
|
|
908
|
+
const w = p(m);
|
|
909
|
+
w && s(A, { deleted: [w] });
|
|
910
|
+
}, x = (m, A = k.LOCAL) => {
|
|
911
|
+
const w = m.reduce((L, M) => {
|
|
912
|
+
const R = p(M);
|
|
913
913
|
return R ? [...L, R] : L;
|
|
914
914
|
}, []);
|
|
915
|
-
|
|
916
|
-
},
|
|
917
|
-
const
|
|
918
|
-
if (
|
|
919
|
-
const
|
|
920
|
-
if (
|
|
921
|
-
e.delete(
|
|
915
|
+
w.length > 0 && s(A, { deleted: w });
|
|
916
|
+
}, l = (m) => {
|
|
917
|
+
const A = t.get(m.annotation);
|
|
918
|
+
if (A) {
|
|
919
|
+
const w = A.bodies.find((L) => L.id === m.id);
|
|
920
|
+
if (w) {
|
|
921
|
+
e.delete(w.id);
|
|
922
922
|
const L = {
|
|
923
|
-
...
|
|
924
|
-
bodies:
|
|
923
|
+
...A,
|
|
924
|
+
bodies: A.bodies.filter((M) => M.id !== m.id)
|
|
925
925
|
};
|
|
926
|
-
return t.set(
|
|
927
|
-
oldValue:
|
|
926
|
+
return t.set(A.id, L), {
|
|
927
|
+
oldValue: A,
|
|
928
928
|
newValue: L,
|
|
929
|
-
bodiesDeleted: [
|
|
929
|
+
bodiesDeleted: [w]
|
|
930
930
|
};
|
|
931
931
|
} else
|
|
932
932
|
console.warn(`Attempt to delete missing body ${m.id} from annotation ${m.annotation}`);
|
|
933
933
|
} else
|
|
934
934
|
console.warn(`Attempt to delete body from missing annotation ${m.annotation}`);
|
|
935
|
-
}, c = (m,
|
|
936
|
-
const
|
|
937
|
-
|
|
938
|
-
},
|
|
939
|
-
const
|
|
940
|
-
|
|
935
|
+
}, c = (m, A = k.LOCAL) => {
|
|
936
|
+
const w = l(m);
|
|
937
|
+
w && s(A, { updated: [w] });
|
|
938
|
+
}, b = (m, A = k.LOCAL) => {
|
|
939
|
+
const w = m.map((L) => l(L)).filter(Boolean);
|
|
940
|
+
w.length > 0 && s(A, { updated: w });
|
|
941
941
|
}, S = (m) => {
|
|
942
|
-
const
|
|
943
|
-
return
|
|
942
|
+
const A = t.get(m);
|
|
943
|
+
return A ? { ...A } : void 0;
|
|
944
944
|
}, E = (m) => {
|
|
945
|
-
const
|
|
946
|
-
if (
|
|
947
|
-
const
|
|
948
|
-
if (
|
|
949
|
-
return
|
|
945
|
+
const A = e.get(m);
|
|
946
|
+
if (A) {
|
|
947
|
+
const w = S(A).bodies.find((L) => L.id === m);
|
|
948
|
+
if (w)
|
|
949
|
+
return w;
|
|
950
950
|
console.error(`Store integrity error: body ${m} in index, but not in annotation`);
|
|
951
951
|
} else
|
|
952
952
|
console.warn(`Attempt to retrieve missing body: ${m}`);
|
|
953
|
-
}, C = (m,
|
|
954
|
-
if (m.annotation !==
|
|
953
|
+
}, C = (m, A) => {
|
|
954
|
+
if (m.annotation !== A.annotation)
|
|
955
955
|
throw "Annotation integrity violation: annotation ID must be the same when updating bodies";
|
|
956
|
-
const
|
|
957
|
-
if (
|
|
958
|
-
const L =
|
|
959
|
-
...
|
|
960
|
-
bodies:
|
|
956
|
+
const w = t.get(m.annotation);
|
|
957
|
+
if (w) {
|
|
958
|
+
const L = w.bodies.find((R) => R.id === m.id), M = {
|
|
959
|
+
...w,
|
|
960
|
+
bodies: w.bodies.map((R) => R.id === L.id ? A : R)
|
|
961
961
|
};
|
|
962
|
-
return t.set(
|
|
963
|
-
oldValue:
|
|
964
|
-
newValue:
|
|
965
|
-
bodiesUpdated: [{ oldBody: L, newBody:
|
|
962
|
+
return t.set(w.id, M), L.id !== A.id && (e.delete(L.id), e.set(A.id, M.id)), {
|
|
963
|
+
oldValue: w,
|
|
964
|
+
newValue: M,
|
|
965
|
+
bodiesUpdated: [{ oldBody: L, newBody: A }]
|
|
966
966
|
};
|
|
967
967
|
} else
|
|
968
968
|
console.warn(`Attempt to add body to missing annotation ${m.annotation}`);
|
|
969
|
-
}, O = (m,
|
|
970
|
-
const L = C(m,
|
|
971
|
-
L && s(
|
|
972
|
-
},
|
|
973
|
-
const
|
|
974
|
-
s(
|
|
969
|
+
}, O = (m, A, w = k.LOCAL) => {
|
|
970
|
+
const L = C(m, A);
|
|
971
|
+
L && s(w, { updated: [L] });
|
|
972
|
+
}, B = (m, A = k.LOCAL) => {
|
|
973
|
+
const w = m.map((L) => C({ id: L.id, annotation: L.annotation }, L)).filter(Boolean);
|
|
974
|
+
s(A, { updated: w });
|
|
975
975
|
}, T = (m) => {
|
|
976
|
-
const
|
|
977
|
-
if (
|
|
978
|
-
const
|
|
979
|
-
...
|
|
976
|
+
const A = t.get(m.annotation);
|
|
977
|
+
if (A) {
|
|
978
|
+
const w = {
|
|
979
|
+
...A,
|
|
980
980
|
target: {
|
|
981
|
-
...
|
|
981
|
+
...A.target,
|
|
982
982
|
...m
|
|
983
983
|
}
|
|
984
984
|
};
|
|
985
|
-
return t.set(
|
|
986
|
-
oldValue:
|
|
987
|
-
newValue:
|
|
985
|
+
return t.set(A.id, w), {
|
|
986
|
+
oldValue: A,
|
|
987
|
+
newValue: w,
|
|
988
988
|
targetUpdated: {
|
|
989
|
-
oldTarget:
|
|
989
|
+
oldTarget: A.target,
|
|
990
990
|
newTarget: m
|
|
991
991
|
}
|
|
992
992
|
};
|
|
@@ -997,27 +997,27 @@ const En = (t, e) => {
|
|
|
997
997
|
addAnnotation: a,
|
|
998
998
|
addBody: h,
|
|
999
999
|
all: u,
|
|
1000
|
-
bulkAddAnnotation:
|
|
1001
|
-
bulkDeleteAnnotation:
|
|
1002
|
-
bulkDeleteBodies:
|
|
1000
|
+
bulkAddAnnotation: v,
|
|
1001
|
+
bulkDeleteAnnotation: x,
|
|
1002
|
+
bulkDeleteBodies: b,
|
|
1003
1003
|
bulkUpdateAnnotation: f,
|
|
1004
|
-
bulkUpdateBodies:
|
|
1005
|
-
bulkUpdateTargets: (m,
|
|
1006
|
-
const
|
|
1007
|
-
|
|
1004
|
+
bulkUpdateBodies: B,
|
|
1005
|
+
bulkUpdateTargets: (m, A = k.LOCAL) => {
|
|
1006
|
+
const w = m.map((L) => T(L)).filter(Boolean);
|
|
1007
|
+
w.length > 0 && s(A, { updated: w });
|
|
1008
1008
|
},
|
|
1009
|
-
clear:
|
|
1010
|
-
deleteAnnotation:
|
|
1009
|
+
clear: g,
|
|
1010
|
+
deleteAnnotation: y,
|
|
1011
1011
|
deleteBody: c,
|
|
1012
1012
|
getAnnotation: S,
|
|
1013
1013
|
getBody: E,
|
|
1014
1014
|
observe: o,
|
|
1015
1015
|
unobserve: i,
|
|
1016
|
-
updateAnnotation:
|
|
1016
|
+
updateAnnotation: d,
|
|
1017
1017
|
updateBody: O,
|
|
1018
|
-
updateTarget: (m,
|
|
1019
|
-
const
|
|
1020
|
-
|
|
1018
|
+
updateTarget: (m, A = k.LOCAL) => {
|
|
1019
|
+
const w = T(m);
|
|
1020
|
+
w && s(A, { updated: [w] });
|
|
1021
1021
|
}
|
|
1022
1022
|
};
|
|
1023
1023
|
};
|
|
@@ -1035,118 +1035,119 @@ let Tn = () => ({
|
|
|
1035
1035
|
};
|
|
1036
1036
|
}
|
|
1037
1037
|
});
|
|
1038
|
-
const On = 250,
|
|
1039
|
-
const
|
|
1040
|
-
let
|
|
1041
|
-
const
|
|
1042
|
-
if (!
|
|
1043
|
-
const { changes: y } =
|
|
1044
|
-
if (
|
|
1045
|
-
|
|
1038
|
+
const On = 250, Bn = (t, e) => {
|
|
1039
|
+
const n = Tn(), o = [];
|
|
1040
|
+
let i = -1, s = !1, a = 0;
|
|
1041
|
+
const r = (p) => {
|
|
1042
|
+
if (!s) {
|
|
1043
|
+
const { changes: y } = p, x = performance.now();
|
|
1044
|
+
if (x - a > On)
|
|
1045
|
+
o.splice(i + 1), o.push(y), i = o.length - 1;
|
|
1046
1046
|
else {
|
|
1047
|
-
const
|
|
1048
|
-
|
|
1047
|
+
const l = o.length - 1;
|
|
1048
|
+
o[l] = Sn(o[l], y);
|
|
1049
1049
|
}
|
|
1050
|
-
|
|
1050
|
+
a = x;
|
|
1051
1051
|
}
|
|
1052
|
-
|
|
1052
|
+
s = !1;
|
|
1053
1053
|
};
|
|
1054
|
-
t.observe(
|
|
1055
|
-
const
|
|
1054
|
+
t.observe(r, { origin: k.LOCAL });
|
|
1055
|
+
const d = (p) => p && p.length > 0 && t.bulkDeleteAnnotation(p), f = (p) => p && p.length > 0 && t.bulkAddAnnotation(p, !1), h = (p) => p && p.length > 0 && t.bulkUpdateAnnotation(p.map(({ oldValue: y }) => y)), u = (p) => p && p.length > 0 && t.bulkUpdateAnnotation(p.map(({ newValue: y }) => y)), g = (p) => p && p.length > 0 && t.bulkAddAnnotation(p, !1), v = (p) => p && p.length > 0 && t.bulkDeleteAnnotation(p);
|
|
1056
1056
|
return {
|
|
1057
|
-
canRedo: () =>
|
|
1058
|
-
canUndo: () =>
|
|
1059
|
-
destroy: () => t.unobserve(
|
|
1060
|
-
|
|
1057
|
+
canRedo: () => o.length - 1 > i,
|
|
1058
|
+
canUndo: () => i > -1,
|
|
1059
|
+
destroy: () => t.unobserve(r),
|
|
1060
|
+
getHistory: () => ({ changes: [...o], pointer: i }),
|
|
1061
|
+
on: (p, y) => n.on(p, y),
|
|
1061
1062
|
redo: () => {
|
|
1062
|
-
if (
|
|
1063
|
-
|
|
1064
|
-
const { created:
|
|
1065
|
-
|
|
1063
|
+
if (o.length - 1 > i) {
|
|
1064
|
+
s = !0;
|
|
1065
|
+
const { created: p, updated: y, deleted: x } = o[i + 1];
|
|
1066
|
+
f(p), u(y), v(x), n.emit("redo", o[i + 1]), i += 1;
|
|
1066
1067
|
}
|
|
1067
1068
|
},
|
|
1068
1069
|
undo: () => {
|
|
1069
|
-
if (
|
|
1070
|
-
|
|
1071
|
-
const { created:
|
|
1072
|
-
|
|
1070
|
+
if (i > -1) {
|
|
1071
|
+
s = !0;
|
|
1072
|
+
const { created: p, updated: y, deleted: x } = o[i];
|
|
1073
|
+
d(p), h(y), g(x), n.emit("undo", o[i]), i -= 1;
|
|
1073
1074
|
}
|
|
1074
1075
|
}
|
|
1075
1076
|
};
|
|
1076
|
-
},
|
|
1077
|
-
const { subscribe: t, set: e } =
|
|
1077
|
+
}, Mn = () => {
|
|
1078
|
+
const { subscribe: t, set: e } = Kt([]);
|
|
1078
1079
|
return {
|
|
1079
1080
|
subscribe: t,
|
|
1080
1081
|
set: e
|
|
1081
1082
|
};
|
|
1082
1083
|
}, Rn = (t, e, n, o) => {
|
|
1083
|
-
const { hover: i, selection: s, store: a, viewport: r } = t,
|
|
1084
|
+
const { hover: i, selection: s, store: a, viewport: r } = t, d = /* @__PURE__ */ new Map();
|
|
1084
1085
|
let f = [], h;
|
|
1085
|
-
const u = (
|
|
1086
|
-
|
|
1087
|
-
},
|
|
1088
|
-
const
|
|
1089
|
-
if (
|
|
1090
|
-
const c =
|
|
1091
|
-
c !== -1 &&
|
|
1086
|
+
const u = (y, x) => {
|
|
1087
|
+
d.has(y) ? d.get(y).push(x) : d.set(y, [x]);
|
|
1088
|
+
}, g = (y, x) => {
|
|
1089
|
+
const l = d.get(y);
|
|
1090
|
+
if (l) {
|
|
1091
|
+
const c = l.indexOf(x);
|
|
1092
|
+
c !== -1 && l.splice(c, 1);
|
|
1092
1093
|
}
|
|
1093
|
-
},
|
|
1094
|
-
|
|
1095
|
-
|
|
1094
|
+
}, v = (y, x, l) => {
|
|
1095
|
+
d.has(y) && setTimeout(() => {
|
|
1096
|
+
d.get(y).forEach((c) => {
|
|
1096
1097
|
if (n) {
|
|
1097
|
-
const
|
|
1098
|
-
c(
|
|
1098
|
+
const b = Array.isArray(x) ? x.map((E) => n.serialize(E)) : n.serialize(x), S = l ? l instanceof PointerEvent ? l : n.serialize(l) : void 0;
|
|
1099
|
+
c(b, S);
|
|
1099
1100
|
} else
|
|
1100
|
-
c(
|
|
1101
|
+
c(x, l);
|
|
1101
1102
|
});
|
|
1102
1103
|
}, 1);
|
|
1103
1104
|
};
|
|
1104
|
-
s.subscribe(({ selected:
|
|
1105
|
-
if (!(f.length === 0 &&
|
|
1106
|
-
if (f.length === 0 &&
|
|
1107
|
-
f =
|
|
1108
|
-
else if (f.length > 0 &&
|
|
1109
|
-
f.forEach((
|
|
1110
|
-
const
|
|
1111
|
-
|
|
1105
|
+
s.subscribe(({ selected: y }) => {
|
|
1106
|
+
if (!(f.length === 0 && y.length === 0)) {
|
|
1107
|
+
if (f.length === 0 && y.length > 0)
|
|
1108
|
+
f = y.map(({ id: x }) => a.getAnnotation(x));
|
|
1109
|
+
else if (f.length > 0 && y.length === 0)
|
|
1110
|
+
f.forEach((x) => {
|
|
1111
|
+
const l = a.getAnnotation(x.id);
|
|
1112
|
+
l && !G(l, x) && v("updateAnnotation", l, x);
|
|
1112
1113
|
}), f = [];
|
|
1113
1114
|
else {
|
|
1114
|
-
const
|
|
1115
|
-
f.filter((c) => !
|
|
1116
|
-
const
|
|
1117
|
-
|
|
1115
|
+
const x = new Set(f.map((c) => c.id)), l = new Set(y.map(({ id: c }) => c));
|
|
1116
|
+
f.filter((c) => !l.has(c.id)).forEach((c) => {
|
|
1117
|
+
const b = a.getAnnotation(c.id);
|
|
1118
|
+
b && !G(b, c) && v("updateAnnotation", b, c);
|
|
1118
1119
|
}), f = [
|
|
1119
1120
|
// Remove annotations that were deselected
|
|
1120
|
-
...f.filter((c) =>
|
|
1121
|
+
...f.filter((c) => l.has(c.id)),
|
|
1121
1122
|
// Add editable annotations that were selected
|
|
1122
|
-
...
|
|
1123
|
+
...y.filter(({ id: c }) => !x.has(c)).map(({ id: c }) => a.getAnnotation(c))
|
|
1123
1124
|
];
|
|
1124
1125
|
}
|
|
1125
|
-
|
|
1126
|
+
v("selectionChanged", f);
|
|
1126
1127
|
}
|
|
1127
|
-
}), i.subscribe((
|
|
1128
|
-
!h &&
|
|
1129
|
-
}), r == null || r.subscribe((
|
|
1130
|
-
const { created:
|
|
1131
|
-
(
|
|
1128
|
+
}), i.subscribe((y) => {
|
|
1129
|
+
!h && y ? v("mouseEnterAnnotation", a.getAnnotation(y)) : h && !y ? v("mouseLeaveAnnotation", a.getAnnotation(h)) : h && y && (v("mouseLeaveAnnotation", a.getAnnotation(h)), v("mouseEnterAnnotation", a.getAnnotation(y))), h = y;
|
|
1130
|
+
}), r == null || r.subscribe((y) => v("viewportIntersect", y.map((x) => a.getAnnotation(x)))), a.observe((y) => {
|
|
1131
|
+
const { created: x, deleted: l } = y.changes;
|
|
1132
|
+
(x || []).forEach((c) => v("createAnnotation", c)), (l || []).forEach((c) => v("deleteAnnotation", c)), (y.changes.updated || []).filter((c) => [
|
|
1132
1133
|
...c.bodiesCreated || [],
|
|
1133
1134
|
...c.bodiesDeleted || [],
|
|
1134
1135
|
...c.bodiesUpdated || []
|
|
1135
|
-
].length > 0).forEach(({ oldValue: c, newValue:
|
|
1136
|
+
].length > 0).forEach(({ oldValue: c, newValue: b }) => {
|
|
1136
1137
|
const S = f.find((E) => E.id === c.id) || c;
|
|
1137
|
-
f = f.map((E) => E.id === c.id ?
|
|
1138
|
+
f = f.map((E) => E.id === c.id ? b : E), v("updateAnnotation", b, S);
|
|
1138
1139
|
});
|
|
1139
|
-
}, { origin: k.LOCAL }), a.observe((
|
|
1140
|
+
}, { origin: k.LOCAL }), a.observe((y) => {
|
|
1140
1141
|
if (f) {
|
|
1141
|
-
const
|
|
1142
|
-
|
|
1142
|
+
const x = new Set(f.map((c) => c.id)), l = (y.changes.updated || []).filter(({ newValue: c }) => x.has(c.id)).map(({ newValue: c }) => c);
|
|
1143
|
+
l.length > 0 && (f = f.map((c) => l.find((S) => S.id === c.id) || c));
|
|
1143
1144
|
}
|
|
1144
1145
|
}, { origin: k.REMOTE });
|
|
1145
|
-
const
|
|
1146
|
-
const { updated:
|
|
1147
|
-
|
|
1146
|
+
const p = (y) => (x) => {
|
|
1147
|
+
const { updated: l } = x;
|
|
1148
|
+
y ? (l || []).forEach((c) => v("updateAnnotation", c.oldValue, c.newValue)) : (l || []).forEach((c) => v("updateAnnotation", c.newValue, c.oldValue));
|
|
1148
1149
|
};
|
|
1149
|
-
return e.on("undo",
|
|
1150
|
+
return e.on("undo", p(!0)), e.on("redo", p(!1)), { on: u, off: g, emit: v };
|
|
1150
1151
|
}, kn = (t) => (e) => e.reduce((n, o) => {
|
|
1151
1152
|
const { parsed: i, error: s } = t.parse(o);
|
|
1152
1153
|
return s ? {
|
|
@@ -1159,46 +1160,46 @@ const On = 250, Mn = (t) => {
|
|
|
1159
1160
|
...n
|
|
1160
1161
|
};
|
|
1161
1162
|
}, { parsed: [], failed: [] }), In = (t, e, n) => {
|
|
1162
|
-
const { store: o, selection: i } = t, s = (
|
|
1163
|
+
const { store: o, selection: i } = t, s = (l) => {
|
|
1163
1164
|
if (n) {
|
|
1164
|
-
const { parsed: c, error:
|
|
1165
|
-
c ? o.addAnnotation(c, k.REMOTE) : console.error(
|
|
1165
|
+
const { parsed: c, error: b } = n.parse(l);
|
|
1166
|
+
c ? o.addAnnotation(c, k.REMOTE) : console.error(b);
|
|
1166
1167
|
} else
|
|
1167
|
-
o.addAnnotation(
|
|
1168
|
-
}, a = () => i.clear(), r = () => o.clear(),
|
|
1169
|
-
const c = o.getAnnotation(
|
|
1168
|
+
o.addAnnotation(Bt(l), k.REMOTE);
|
|
1169
|
+
}, a = () => i.clear(), r = () => o.clear(), d = (l) => {
|
|
1170
|
+
const c = o.getAnnotation(l);
|
|
1170
1171
|
return n && c ? n.serialize(c) : c;
|
|
1171
1172
|
}, f = () => n ? o.all().map(n.serialize) : o.all(), h = () => {
|
|
1172
|
-
var
|
|
1173
|
-
const c = (((
|
|
1173
|
+
var l;
|
|
1174
|
+
const c = (((l = i.selected) == null ? void 0 : l.map((b) => b.id)) || []).map((b) => o.getAnnotation(b)).filter(Boolean);
|
|
1174
1175
|
return n ? c.map(n.serialize) : c;
|
|
1175
|
-
}, u = (
|
|
1176
|
-
if (typeof
|
|
1177
|
-
const c = o.getAnnotation(
|
|
1178
|
-
if (o.deleteAnnotation(
|
|
1176
|
+
}, u = (l, c = !0) => fetch(l).then((b) => b.json()).then((b) => (v(b, c), b)), g = (l) => {
|
|
1177
|
+
if (typeof l == "string") {
|
|
1178
|
+
const c = o.getAnnotation(l);
|
|
1179
|
+
if (o.deleteAnnotation(l), c)
|
|
1179
1180
|
return n ? n.serialize(c) : c;
|
|
1180
1181
|
} else {
|
|
1181
|
-
const c = n ? n.parse(
|
|
1182
|
+
const c = n ? n.parse(l).parsed : l;
|
|
1182
1183
|
if (c)
|
|
1183
|
-
return o.deleteAnnotation(c),
|
|
1184
|
+
return o.deleteAnnotation(c), l;
|
|
1184
1185
|
}
|
|
1185
|
-
},
|
|
1186
|
+
}, v = (l, c = !0) => {
|
|
1186
1187
|
if (n) {
|
|
1187
|
-
const
|
|
1188
|
+
const b = n.parseAll || kn(n), { parsed: S, failed: E } = b(l);
|
|
1188
1189
|
E.length > 0 && console.warn(`Discarded ${E.length} invalid annotations`, E), o.bulkAddAnnotation(S, c, k.REMOTE);
|
|
1189
1190
|
} else
|
|
1190
|
-
o.bulkAddAnnotation(
|
|
1191
|
-
},
|
|
1192
|
-
|
|
1193
|
-
},
|
|
1194
|
-
i.clear(), i.setUserSelectAction(
|
|
1195
|
-
},
|
|
1191
|
+
o.bulkAddAnnotation(l.map(Bt), c, k.REMOTE);
|
|
1192
|
+
}, p = (l, c) => {
|
|
1193
|
+
l ? i.setSelected(l, c) : i.clear();
|
|
1194
|
+
}, y = (l) => {
|
|
1195
|
+
i.clear(), i.setUserSelectAction(l);
|
|
1196
|
+
}, x = (l) => {
|
|
1196
1197
|
if (n) {
|
|
1197
|
-
const c = n.parse(
|
|
1198
|
-
return o.updateAnnotation(c),
|
|
1198
|
+
const c = n.parse(l).parsed, b = n.serialize(o.getAnnotation(c.id));
|
|
1199
|
+
return o.updateAnnotation(c), b;
|
|
1199
1200
|
} else {
|
|
1200
|
-
const c = o.getAnnotation(
|
|
1201
|
-
return o.updateAnnotation(
|
|
1201
|
+
const c = o.getAnnotation(l.id);
|
|
1202
|
+
return o.updateAnnotation(Bt(l)), c;
|
|
1202
1203
|
}
|
|
1203
1204
|
};
|
|
1204
1205
|
return {
|
|
@@ -1207,17 +1208,18 @@ const On = 250, Mn = (t) => {
|
|
|
1207
1208
|
canRedo: e.canRedo,
|
|
1208
1209
|
canUndo: e.canUndo,
|
|
1209
1210
|
clearAnnotations: r,
|
|
1210
|
-
getAnnotationById:
|
|
1211
|
+
getAnnotationById: d,
|
|
1211
1212
|
getAnnotations: f,
|
|
1213
|
+
getHistory: e.getHistory,
|
|
1212
1214
|
getSelected: h,
|
|
1213
1215
|
loadAnnotations: u,
|
|
1214
1216
|
redo: e.redo,
|
|
1215
|
-
removeAnnotation:
|
|
1216
|
-
setAnnotations:
|
|
1217
|
-
setSelected:
|
|
1218
|
-
setUserSelectAction:
|
|
1217
|
+
removeAnnotation: g,
|
|
1218
|
+
setAnnotations: v,
|
|
1219
|
+
setSelected: p,
|
|
1220
|
+
setUserSelectAction: y,
|
|
1219
1221
|
undo: e.undo,
|
|
1220
|
-
updateAnnotation:
|
|
1222
|
+
updateAnnotation: x
|
|
1221
1223
|
};
|
|
1222
1224
|
}, _n = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
|
|
1223
1225
|
let Nn = (t) => crypto.getRandomValues(new Uint8Array(t)), Un = (t, e, n) => {
|
|
@@ -1225,18 +1227,18 @@ let Nn = (t) => crypto.getRandomValues(new Uint8Array(t)), Un = (t, e, n) => {
|
|
|
1225
1227
|
return (s = e) => {
|
|
1226
1228
|
let a = "";
|
|
1227
1229
|
for (; ; ) {
|
|
1228
|
-
let r = n(i),
|
|
1229
|
-
for (;
|
|
1230
|
-
if (a += t[r[
|
|
1230
|
+
let r = n(i), d = i | 0;
|
|
1231
|
+
for (; d--; )
|
|
1232
|
+
if (a += t[r[d] & o] || "", a.length >= s) return a;
|
|
1231
1233
|
}
|
|
1232
1234
|
};
|
|
1233
|
-
}, Vn = (t, e = 21) => Un(t, e, Nn), Yn = (t = 21) => {
|
|
1234
|
-
let e = "", n = crypto.getRandomValues(new Uint8Array(t));
|
|
1235
|
+
}, Vn = (t, e = 21) => Un(t, e | 0, Nn), Yn = (t = 21) => {
|
|
1236
|
+
let e = "", n = crypto.getRandomValues(new Uint8Array(t |= 0));
|
|
1235
1237
|
for (; t--; )
|
|
1236
1238
|
e += _n[n[t] & 63];
|
|
1237
1239
|
return e;
|
|
1238
1240
|
};
|
|
1239
|
-
const
|
|
1241
|
+
const Dn = () => ({ isGuest: !0, id: Vn("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_", 20)() }), Kn = (t) => {
|
|
1240
1242
|
const e = JSON.stringify(t);
|
|
1241
1243
|
let n = 0;
|
|
1242
1244
|
for (let o = 0, i = e.length; o < i; o++) {
|
|
@@ -1244,17 +1246,17 @@ const Kn = () => ({ isGuest: !0, id: Vn("1234567890abcdefghijklmnopqrstuvwxyzABC
|
|
|
1244
1246
|
n = (n << 5) - n + s, n |= 0;
|
|
1245
1247
|
}
|
|
1246
1248
|
return `${n}`;
|
|
1247
|
-
},
|
|
1248
|
-
const { id: o, type: i, purpose: s, value: a, created: r, modified:
|
|
1249
|
+
}, pe = (t) => t ? typeof t == "object" ? { ...t } : t : void 0, Xn = (t, e) => (Array.isArray(t) ? t : [t]).map((n) => {
|
|
1250
|
+
const { id: o, type: i, purpose: s, value: a, created: r, modified: d, creator: f, ...h } = n;
|
|
1249
1251
|
return {
|
|
1250
|
-
id: o || `temp-${
|
|
1252
|
+
id: o || `temp-${Kn(n)}`,
|
|
1251
1253
|
annotation: e,
|
|
1252
1254
|
type: i,
|
|
1253
1255
|
purpose: s,
|
|
1254
1256
|
value: a,
|
|
1255
|
-
creator:
|
|
1257
|
+
creator: pe(f),
|
|
1256
1258
|
created: r ? new Date(r) : void 0,
|
|
1257
|
-
updated:
|
|
1259
|
+
updated: d ? new Date(d) : void 0,
|
|
1258
1260
|
...h
|
|
1259
1261
|
};
|
|
1260
1262
|
}), Pn = (t) => t.map((e) => {
|
|
@@ -1281,7 +1283,7 @@ const xo = (t, e) => ({
|
|
|
1281
1283
|
if (a.length === 0)
|
|
1282
1284
|
return { error: Error(`No targets found for annotation: ${t.id}`) };
|
|
1283
1285
|
const r = {
|
|
1284
|
-
creator:
|
|
1286
|
+
creator: pe(n),
|
|
1285
1287
|
created: o ? new Date(o) : void 0,
|
|
1286
1288
|
updated: i ? new Date(i) : void 0,
|
|
1287
1289
|
annotation: e,
|
|
@@ -1289,14 +1291,14 @@ const xo = (t, e) => ({
|
|
|
1289
1291
|
// @ts-expect-error: `styleClass` is not part of the core `TextAnnotationTarget` type
|
|
1290
1292
|
styleClass: "styleClass" in a[0] ? a[0].styleClass : void 0
|
|
1291
1293
|
};
|
|
1292
|
-
for (const
|
|
1293
|
-
const h = (Array.isArray(
|
|
1294
|
-
switch (
|
|
1294
|
+
for (const d of a) {
|
|
1295
|
+
const h = (Array.isArray(d.selector) ? d.selector : [d.selector]).reduce((u, g) => {
|
|
1296
|
+
switch (g.type) {
|
|
1295
1297
|
case "TextQuoteSelector":
|
|
1296
|
-
u.quote =
|
|
1298
|
+
u.quote = g.exact;
|
|
1297
1299
|
break;
|
|
1298
1300
|
case "TextPositionSelector":
|
|
1299
|
-
u.start =
|
|
1301
|
+
u.start = g.start, u.end = g.end;
|
|
1300
1302
|
break;
|
|
1301
1303
|
}
|
|
1302
1304
|
return u;
|
|
@@ -1305,9 +1307,9 @@ const xo = (t, e) => ({
|
|
|
1305
1307
|
r.selector.push(
|
|
1306
1308
|
{
|
|
1307
1309
|
...h,
|
|
1308
|
-
id:
|
|
1310
|
+
id: d.id,
|
|
1309
1311
|
// @ts-expect-error: `scope` is not part of the core `TextSelector` type
|
|
1310
|
-
scope:
|
|
1312
|
+
scope: d.scope
|
|
1311
1313
|
}
|
|
1312
1314
|
);
|
|
1313
1315
|
else {
|
|
@@ -1326,38 +1328,38 @@ const xo = (t, e) => ({
|
|
|
1326
1328
|
modified: i,
|
|
1327
1329
|
body: s,
|
|
1328
1330
|
...a
|
|
1329
|
-
} = t, r = Xn(s, e),
|
|
1330
|
-
return "error" in
|
|
1331
|
+
} = t, r = Xn(s, e), d = Hn(t);
|
|
1332
|
+
return "error" in d ? { error: d.error } : {
|
|
1331
1333
|
parsed: {
|
|
1332
1334
|
...a,
|
|
1333
1335
|
id: e,
|
|
1334
1336
|
bodies: r,
|
|
1335
|
-
target:
|
|
1337
|
+
target: d.parsed
|
|
1336
1338
|
}
|
|
1337
1339
|
};
|
|
1338
1340
|
}, zn = (t, e, n) => {
|
|
1339
1341
|
const { bodies: o, target: i, ...s } = t, {
|
|
1340
1342
|
selector: a,
|
|
1341
1343
|
creator: r,
|
|
1342
|
-
created:
|
|
1344
|
+
created: d,
|
|
1343
1345
|
updated: f,
|
|
1344
1346
|
...h
|
|
1345
|
-
} = i, u = a.map((
|
|
1346
|
-
const { id:
|
|
1347
|
+
} = i, u = a.map((g) => {
|
|
1348
|
+
const { id: v, quote: p, start: y, end: x, range: l } = g, { prefix: c, suffix: b } = Re(l, n), S = [{
|
|
1347
1349
|
type: "TextQuoteSelector",
|
|
1348
|
-
exact:
|
|
1350
|
+
exact: p,
|
|
1349
1351
|
prefix: c,
|
|
1350
|
-
suffix:
|
|
1352
|
+
suffix: b
|
|
1351
1353
|
}, {
|
|
1352
1354
|
type: "TextPositionSelector",
|
|
1353
|
-
start:
|
|
1354
|
-
end:
|
|
1355
|
+
start: y,
|
|
1356
|
+
end: x
|
|
1355
1357
|
}];
|
|
1356
1358
|
return {
|
|
1357
1359
|
...h,
|
|
1358
|
-
id:
|
|
1360
|
+
id: v,
|
|
1359
1361
|
// @ts-expect-error: `scope` is not part of the core `TextSelector` type
|
|
1360
|
-
scope: "scope" in
|
|
1362
|
+
scope: "scope" in g ? g.scope : void 0,
|
|
1361
1363
|
source: e,
|
|
1362
1364
|
selector: S
|
|
1363
1365
|
};
|
|
@@ -1369,7 +1371,7 @@ const xo = (t, e) => ({
|
|
|
1369
1371
|
type: "Annotation",
|
|
1370
1372
|
body: Pn(t.bodies),
|
|
1371
1373
|
creator: r,
|
|
1372
|
-
created:
|
|
1374
|
+
created: d == null ? void 0 : d.toISOString(),
|
|
1373
1375
|
modified: f == null ? void 0 : f.toISOString(),
|
|
1374
1376
|
target: u
|
|
1375
1377
|
};
|
|
@@ -1377,8 +1379,8 @@ const xo = (t, e) => ({
|
|
|
1377
1379
|
function me(t, e, n = 0, o = t.length - 1, i = Fn) {
|
|
1378
1380
|
for (; o > n; ) {
|
|
1379
1381
|
if (o - n > 600) {
|
|
1380
|
-
const
|
|
1381
|
-
me(t, e,
|
|
1382
|
+
const d = o - n + 1, f = e - n + 1, h = Math.log(d), u = 0.5 * Math.exp(2 * h / 3), g = 0.5 * Math.sqrt(h * u * (d - u) / d) * (f - d / 2 < 0 ? -1 : 1), v = Math.max(n, Math.floor(e - f * u / d + g)), p = Math.min(o, Math.floor(e + (d - f) * u / d + g));
|
|
1383
|
+
me(t, e, v, p, i);
|
|
1382
1384
|
}
|
|
1383
1385
|
const s = t[e];
|
|
1384
1386
|
let a = n, r = o;
|
|
@@ -1410,8 +1412,8 @@ class Wn {
|
|
|
1410
1412
|
const i = this.toBBox, s = [];
|
|
1411
1413
|
for (; n; ) {
|
|
1412
1414
|
for (let a = 0; a < n.children.length; a++) {
|
|
1413
|
-
const r = n.children[a],
|
|
1414
|
-
mt(e,
|
|
1415
|
+
const r = n.children[a], d = n.leaf ? i(r) : r;
|
|
1416
|
+
mt(e, d) && (n.leaf ? o.push(r) : kt(e, d) ? this._all(r, o) : s.push(r));
|
|
1415
1417
|
}
|
|
1416
1418
|
n = s.pop();
|
|
1417
1419
|
}
|
|
@@ -1425,7 +1427,7 @@ class Wn {
|
|
|
1425
1427
|
for (let i = 0; i < n.children.length; i++) {
|
|
1426
1428
|
const s = n.children[i], a = n.leaf ? this.toBBox(s) : s;
|
|
1427
1429
|
if (mt(e, a)) {
|
|
1428
|
-
if (n.leaf ||
|
|
1430
|
+
if (n.leaf || kt(e, a)) return !0;
|
|
1429
1431
|
o.push(s);
|
|
1430
1432
|
}
|
|
1431
1433
|
}
|
|
@@ -1464,14 +1466,14 @@ class Wn {
|
|
|
1464
1466
|
if (!e) return this;
|
|
1465
1467
|
let o = this.data;
|
|
1466
1468
|
const i = this.toBBox(e), s = [], a = [];
|
|
1467
|
-
let r,
|
|
1469
|
+
let r, d, f;
|
|
1468
1470
|
for (; o || s.length; ) {
|
|
1469
|
-
if (o || (o = s.pop(),
|
|
1471
|
+
if (o || (o = s.pop(), d = s[s.length - 1], r = a.pop(), f = !0), o.leaf) {
|
|
1470
1472
|
const h = qn(e, o.children, n);
|
|
1471
1473
|
if (h !== -1)
|
|
1472
1474
|
return o.children.splice(h, 1), s.push(o), this._condense(s), this;
|
|
1473
1475
|
}
|
|
1474
|
-
!f && !o.leaf &&
|
|
1476
|
+
!f && !o.leaf && kt(o, i) ? (s.push(o), a.push(r), r = 0, d = o, o = o.children[0]) : d ? (r++, o = d.children[r], f = !1) : o = null;
|
|
1475
1477
|
}
|
|
1476
1478
|
return this;
|
|
1477
1479
|
}
|
|
@@ -1502,14 +1504,14 @@ class Wn {
|
|
|
1502
1504
|
if (s <= a)
|
|
1503
1505
|
return r = Z(e.slice(n, o + 1)), J(r, this.toBBox), r;
|
|
1504
1506
|
i || (i = Math.ceil(Math.log(s) / Math.log(a)), a = Math.ceil(s / Math.pow(a, i - 1))), r = Z([]), r.leaf = !1, r.height = i;
|
|
1505
|
-
const
|
|
1507
|
+
const d = Math.ceil(s / a), f = d * Math.ceil(Math.sqrt(a));
|
|
1506
1508
|
ee(e, n, o, f, this.compareMinX);
|
|
1507
1509
|
for (let h = n; h <= o; h += f) {
|
|
1508
1510
|
const u = Math.min(h + f - 1, o);
|
|
1509
|
-
ee(e, h, u,
|
|
1510
|
-
for (let
|
|
1511
|
-
const
|
|
1512
|
-
r.children.push(this._build(e,
|
|
1511
|
+
ee(e, h, u, d, this.compareMinY);
|
|
1512
|
+
for (let g = h; g <= u; g += d) {
|
|
1513
|
+
const v = Math.min(g + d - 1, u);
|
|
1514
|
+
r.children.push(this._build(e, g, v, i - 1));
|
|
1513
1515
|
}
|
|
1514
1516
|
}
|
|
1515
1517
|
return J(r, this.toBBox), r;
|
|
@@ -1517,8 +1519,8 @@ class Wn {
|
|
|
1517
1519
|
_chooseSubtree(e, n, o, i) {
|
|
1518
1520
|
for (; i.push(n), !(n.leaf || i.length - 1 === o); ) {
|
|
1519
1521
|
let s = 1 / 0, a = 1 / 0, r;
|
|
1520
|
-
for (let
|
|
1521
|
-
const f = n.children[
|
|
1522
|
+
for (let d = 0; d < n.children.length; d++) {
|
|
1523
|
+
const f = n.children[d], h = Rt(f), u = Jn(e, f) - h;
|
|
1522
1524
|
u < a ? (a = u, s = h < s ? h : s, r = f) : u === a && h < s && (s = h, r = f);
|
|
1523
1525
|
}
|
|
1524
1526
|
n = r || n.children[0];
|
|
@@ -1544,7 +1546,7 @@ class Wn {
|
|
|
1544
1546
|
_chooseSplitIndex(e, n, o) {
|
|
1545
1547
|
let i, s = 1 / 0, a = 1 / 0;
|
|
1546
1548
|
for (let r = n; r <= o - n; r++) {
|
|
1547
|
-
const
|
|
1549
|
+
const d = st(e, 0, r, this.toBBox), f = st(e, r, o, this.toBBox), h = Zn(d, f), u = Rt(d) + Rt(f);
|
|
1548
1550
|
h < s ? (s = h, i = r, a = u < a ? u : a) : h === s && u < a && (a = u, i = r);
|
|
1549
1551
|
}
|
|
1550
1552
|
return i || o - n;
|
|
@@ -1558,16 +1560,16 @@ class Wn {
|
|
|
1558
1560
|
_allDistMargin(e, n, o, i) {
|
|
1559
1561
|
e.children.sort(i);
|
|
1560
1562
|
const s = this.toBBox, a = st(e, 0, n, s), r = st(e, o - n, o, s);
|
|
1561
|
-
let
|
|
1563
|
+
let d = pt(a) + pt(r);
|
|
1562
1564
|
for (let f = n; f < o - n; f++) {
|
|
1563
1565
|
const h = e.children[f];
|
|
1564
|
-
rt(a, e.leaf ? s(h) : h),
|
|
1566
|
+
rt(a, e.leaf ? s(h) : h), d += pt(a);
|
|
1565
1567
|
}
|
|
1566
1568
|
for (let f = o - n - 1; f >= n; f--) {
|
|
1567
1569
|
const h = e.children[f];
|
|
1568
|
-
rt(r, e.leaf ? s(h) : h),
|
|
1570
|
+
rt(r, e.leaf ? s(h) : h), d += pt(r);
|
|
1569
1571
|
}
|
|
1570
|
-
return
|
|
1572
|
+
return d;
|
|
1571
1573
|
}
|
|
1572
1574
|
_adjustParentBBoxes(e, n, o) {
|
|
1573
1575
|
for (let i = o; i >= 0; i--)
|
|
@@ -1604,10 +1606,10 @@ function Gn(t, e) {
|
|
|
1604
1606
|
function Qn(t, e) {
|
|
1605
1607
|
return t.minY - e.minY;
|
|
1606
1608
|
}
|
|
1607
|
-
function
|
|
1609
|
+
function Rt(t) {
|
|
1608
1610
|
return (t.maxX - t.minX) * (t.maxY - t.minY);
|
|
1609
1611
|
}
|
|
1610
|
-
function
|
|
1612
|
+
function pt(t) {
|
|
1611
1613
|
return t.maxX - t.minX + (t.maxY - t.minY);
|
|
1612
1614
|
}
|
|
1613
1615
|
function Jn(t, e) {
|
|
@@ -1617,7 +1619,7 @@ function Zn(t, e) {
|
|
|
1617
1619
|
const n = Math.max(t.minX, e.minX), o = Math.max(t.minY, e.minY), i = Math.min(t.maxX, e.maxX), s = Math.min(t.maxY, e.maxY);
|
|
1618
1620
|
return Math.max(0, i - n) * Math.max(0, s - o);
|
|
1619
1621
|
}
|
|
1620
|
-
function
|
|
1622
|
+
function kt(t, e) {
|
|
1621
1623
|
return t.minX <= e.minX && t.minY <= e.minY && e.maxX <= t.maxX && e.maxY <= t.maxY;
|
|
1622
1624
|
}
|
|
1623
1625
|
function mt(t, e) {
|
|
@@ -1643,129 +1645,129 @@ function ee(t, e, n, o, i) {
|
|
|
1643
1645
|
}
|
|
1644
1646
|
}
|
|
1645
1647
|
const to = (t, e) => {
|
|
1646
|
-
const n = new Wn(), o = /* @__PURE__ */ new Map(), i = (
|
|
1647
|
-
const
|
|
1648
|
+
const n = new Wn(), o = /* @__PURE__ */ new Map(), i = (l, c) => {
|
|
1649
|
+
const b = l.selector.flatMap((E) => {
|
|
1648
1650
|
const C = F([E]) ? E.range : ae(E, e).range;
|
|
1649
1651
|
return Array.from(C.getClientRects());
|
|
1650
|
-
}), S = Ue(
|
|
1652
|
+
}), S = Ue(b).map(({ left: E, top: C, right: O, bottom: B }) => new DOMRect(E - c.left, C - c.top, O - E, B - C));
|
|
1651
1653
|
return S.map((E) => {
|
|
1652
|
-
const { x: C, y: O, width:
|
|
1654
|
+
const { x: C, y: O, width: B, height: T } = E;
|
|
1653
1655
|
return {
|
|
1654
1656
|
minX: C,
|
|
1655
1657
|
minY: O,
|
|
1656
|
-
maxX: C +
|
|
1658
|
+
maxX: C + B,
|
|
1657
1659
|
maxY: O + T,
|
|
1658
1660
|
annotation: {
|
|
1659
|
-
id:
|
|
1661
|
+
id: l.annotation,
|
|
1660
1662
|
rects: S
|
|
1661
1663
|
}
|
|
1662
1664
|
};
|
|
1663
1665
|
});
|
|
1664
1666
|
}, s = () => [...o.values()], a = () => {
|
|
1665
1667
|
n.clear(), o.clear();
|
|
1666
|
-
}, r = (
|
|
1667
|
-
const c = i(
|
|
1668
|
-
c.length !== 0 && (c.forEach((
|
|
1669
|
-
},
|
|
1670
|
-
const c = o.get(
|
|
1671
|
-
c && (c.forEach((
|
|
1672
|
-
}, f = (
|
|
1673
|
-
l
|
|
1674
|
-
}, h = (
|
|
1668
|
+
}, r = (l) => {
|
|
1669
|
+
const c = i(l, e.getBoundingClientRect());
|
|
1670
|
+
c.length !== 0 && (c.forEach((b) => n.insert(b)), o.set(l.annotation, c));
|
|
1671
|
+
}, d = (l) => {
|
|
1672
|
+
const c = o.get(l.annotation);
|
|
1673
|
+
c && (c.forEach((b) => n.remove(b)), o.delete(l.annotation));
|
|
1674
|
+
}, f = (l) => {
|
|
1675
|
+
d(l), r(l);
|
|
1676
|
+
}, h = (l, c = !0) => {
|
|
1675
1677
|
c && a();
|
|
1676
|
-
const
|
|
1678
|
+
const b = e.getBoundingClientRect(), S = l.map((C) => ({ target: C, rects: i(C, b) }));
|
|
1677
1679
|
S.forEach(({ target: C, rects: O }) => {
|
|
1678
1680
|
O.length > 0 && o.set(C.annotation, O);
|
|
1679
1681
|
});
|
|
1680
1682
|
const E = S.flatMap(({ rects: C }) => C);
|
|
1681
1683
|
n.load(E);
|
|
1682
|
-
}, u = (
|
|
1684
|
+
}, u = (l, c, b = !1) => {
|
|
1683
1685
|
const S = n.search({
|
|
1684
|
-
minX:
|
|
1686
|
+
minX: l,
|
|
1685
1687
|
minY: c,
|
|
1686
|
-
maxX:
|
|
1688
|
+
maxX: l,
|
|
1687
1689
|
maxY: c
|
|
1688
|
-
}), E = (C) => C.annotation.rects.reduce((O,
|
|
1689
|
-
return S.length > 0 ? (S.sort((C, O) => E(C) - E(O)),
|
|
1690
|
-
},
|
|
1691
|
-
const c =
|
|
1690
|
+
}), E = (C) => C.annotation.rects.reduce((O, B) => O + B.width * B.height, 0);
|
|
1691
|
+
return S.length > 0 ? (S.sort((C, O) => E(C) - E(O)), b ? S.map((C) => C.annotation.id) : [S[0].annotation.id]) : [];
|
|
1692
|
+
}, g = (l) => {
|
|
1693
|
+
const c = v(l);
|
|
1692
1694
|
if (c.length === 0)
|
|
1693
1695
|
return;
|
|
1694
|
-
let
|
|
1696
|
+
let b = c[0].left, S = c[0].top, E = c[0].right, C = c[0].bottom;
|
|
1695
1697
|
for (let O = 1; O < c.length; O++) {
|
|
1696
|
-
const
|
|
1697
|
-
|
|
1698
|
+
const B = c[O];
|
|
1699
|
+
b = Math.min(b, B.left), S = Math.min(S, B.top), E = Math.max(E, B.right), C = Math.max(C, B.bottom);
|
|
1698
1700
|
}
|
|
1699
|
-
return new DOMRect(
|
|
1700
|
-
},
|
|
1701
|
-
const c = o.get(
|
|
1701
|
+
return new DOMRect(b, S, E - b, C - S);
|
|
1702
|
+
}, v = (l) => {
|
|
1703
|
+
const c = o.get(l);
|
|
1702
1704
|
return c ? c[0].annotation.rects : [];
|
|
1703
1705
|
};
|
|
1704
1706
|
return {
|
|
1705
1707
|
all: s,
|
|
1706
1708
|
clear: a,
|
|
1707
1709
|
getAt: u,
|
|
1708
|
-
getAnnotationBounds:
|
|
1709
|
-
getAnnotationRects:
|
|
1710
|
-
getIntersecting: (
|
|
1711
|
-
const E = n.search({ minX:
|
|
1710
|
+
getAnnotationBounds: g,
|
|
1711
|
+
getAnnotationRects: v,
|
|
1712
|
+
getIntersecting: (l, c, b, S) => {
|
|
1713
|
+
const E = n.search({ minX: l, minY: c, maxX: b, maxY: S }), C = new Set(E.map((O) => O.annotation.id));
|
|
1712
1714
|
return Array.from(C).map((O) => ({
|
|
1713
1715
|
annotation: t.getAnnotation(O),
|
|
1714
|
-
rects:
|
|
1716
|
+
rects: v(O)
|
|
1715
1717
|
})).filter((O) => !!O.annotation);
|
|
1716
1718
|
},
|
|
1717
1719
|
insert: r,
|
|
1718
|
-
recalculate: () => h(t.all().map((
|
|
1719
|
-
remove:
|
|
1720
|
+
recalculate: () => h(t.all().map((l) => l.target), !0),
|
|
1721
|
+
remove: d,
|
|
1720
1722
|
set: h,
|
|
1721
1723
|
size: () => n.all().length,
|
|
1722
1724
|
update: f
|
|
1723
1725
|
};
|
|
1724
1726
|
}, eo = (t, e) => {
|
|
1725
|
-
const n = Ln(), o = to(n, t), i =
|
|
1727
|
+
const n = Ln(), o = to(n, t), i = gn(n);
|
|
1726
1728
|
i.setUserSelectAction(e);
|
|
1727
|
-
const s = fn(n), a =
|
|
1728
|
-
const
|
|
1729
|
-
return S && n.addAnnotation(
|
|
1730
|
-
},
|
|
1731
|
-
const S =
|
|
1732
|
-
return n.bulkAddAnnotation(S, c,
|
|
1733
|
-
}, f = (
|
|
1734
|
-
const
|
|
1735
|
-
return
|
|
1729
|
+
const s = fn(n), a = Mn(), r = (l, c = k.LOCAL) => {
|
|
1730
|
+
const b = vt(l, t), S = F(b.target.selector);
|
|
1731
|
+
return S && n.addAnnotation(b, c), S;
|
|
1732
|
+
}, d = (l, c = !0, b = k.LOCAL) => {
|
|
1733
|
+
const S = l.map((C) => vt(C, t)), E = S.filter((C) => !F(C.target.selector));
|
|
1734
|
+
return n.bulkAddAnnotation(S, c, b), E;
|
|
1735
|
+
}, f = (l, c = k.LOCAL) => {
|
|
1736
|
+
const b = l.map((E) => vt(E, t)), S = b.filter((E) => !F(E.target.selector));
|
|
1737
|
+
return b.forEach((E) => {
|
|
1736
1738
|
n.getAnnotation(E.id) ? n.updateAnnotation(E, c) : n.addAnnotation(E, c);
|
|
1737
1739
|
}), S;
|
|
1738
|
-
}, h = (
|
|
1739
|
-
const
|
|
1740
|
-
n.updateTarget(
|
|
1741
|
-
}, u = (
|
|
1742
|
-
const
|
|
1743
|
-
n.bulkUpdateTargets(
|
|
1740
|
+
}, h = (l, c = k.LOCAL) => {
|
|
1741
|
+
const b = wt(l, t);
|
|
1742
|
+
n.updateTarget(b, c);
|
|
1743
|
+
}, u = (l, c = k.LOCAL) => {
|
|
1744
|
+
const b = l.map((S) => wt(S, t));
|
|
1745
|
+
n.bulkUpdateTargets(b, c);
|
|
1744
1746
|
};
|
|
1745
|
-
function
|
|
1746
|
-
const E =
|
|
1747
|
+
function g(l, c, b, S) {
|
|
1748
|
+
const E = b || !!S, C = o.getAt(l, c, E).map((B) => n.getAnnotation(B)), O = S ? C.filter(S) : C;
|
|
1747
1749
|
if (O.length !== 0)
|
|
1748
|
-
return
|
|
1750
|
+
return b ? O : O[0];
|
|
1749
1751
|
}
|
|
1750
|
-
const
|
|
1751
|
-
if (o.getAnnotationRects(
|
|
1752
|
-
return o.getAnnotationBounds(
|
|
1753
|
-
},
|
|
1754
|
-
return n.observe(({ changes:
|
|
1755
|
-
const c = (
|
|
1756
|
-
(c == null ? void 0 : c.length) > 0 && c.forEach((E) => o.remove(E.target)),
|
|
1752
|
+
const v = (l) => {
|
|
1753
|
+
if (o.getAnnotationRects(l).length !== 0)
|
|
1754
|
+
return o.getAnnotationBounds(l);
|
|
1755
|
+
}, p = (l, c, b, S) => o.getIntersecting(l, c, b, S), y = (l) => o.getAnnotationRects(l), x = () => o.recalculate();
|
|
1756
|
+
return n.observe(({ changes: l }) => {
|
|
1757
|
+
const c = (l.deleted || []).filter((E) => F(E.target.selector)), b = (l.created || []).filter((E) => F(E.target.selector)), S = (l.updated || []).filter((E) => F(E.newValue.target.selector));
|
|
1758
|
+
(c == null ? void 0 : c.length) > 0 && c.forEach((E) => o.remove(E.target)), b.length > 0 && o.set(b.map((E) => E.target), !1), (S == null ? void 0 : S.length) > 0 && S.forEach(({ newValue: E }) => o.update(E.target));
|
|
1757
1759
|
}), {
|
|
1758
1760
|
store: {
|
|
1759
1761
|
...n,
|
|
1760
1762
|
addAnnotation: r,
|
|
1761
|
-
bulkAddAnnotation:
|
|
1763
|
+
bulkAddAnnotation: d,
|
|
1762
1764
|
bulkUpdateTargets: u,
|
|
1763
1765
|
bulkUpsertAnnotations: f,
|
|
1764
|
-
getAnnotationBounds:
|
|
1765
|
-
getAnnotationRects:
|
|
1766
|
-
getIntersecting:
|
|
1767
|
-
getAt:
|
|
1768
|
-
recalculatePositions:
|
|
1766
|
+
getAnnotationBounds: v,
|
|
1767
|
+
getAnnotationRects: y,
|
|
1768
|
+
getIntersecting: p,
|
|
1769
|
+
getAt: g,
|
|
1770
|
+
recalculatePositions: x,
|
|
1769
1771
|
updateTarget: h
|
|
1770
1772
|
},
|
|
1771
1773
|
selection: i,
|
|
@@ -1780,9 +1782,9 @@ const to = (t, e) => {
|
|
|
1780
1782
|
}, oo = (t, e = {}) => {
|
|
1781
1783
|
const n = no(), o = n.getContext("2d");
|
|
1782
1784
|
document.body.appendChild(n);
|
|
1783
|
-
const i = /* @__PURE__ */ new Map(), s = (h) => Array.from(i.entries()).filter(([u,
|
|
1785
|
+
const i = /* @__PURE__ */ new Map(), s = (h) => Array.from(i.entries()).filter(([u, g]) => g.presenceKey === h.presenceKey).map(([u, g]) => u);
|
|
1784
1786
|
return t.on("selectionChange", (h, u) => {
|
|
1785
|
-
s(h).forEach((
|
|
1787
|
+
s(h).forEach((v) => i.delete(v)), u && u.forEach((v) => i.set(v, h));
|
|
1786
1788
|
}), {
|
|
1787
1789
|
clear: () => {
|
|
1788
1790
|
const { width: h, height: u } = n;
|
|
@@ -1791,16 +1793,16 @@ const to = (t, e) => {
|
|
|
1791
1793
|
destroy: () => {
|
|
1792
1794
|
n.remove();
|
|
1793
1795
|
},
|
|
1794
|
-
paint: (h, u,
|
|
1796
|
+
paint: (h, u, g) => {
|
|
1795
1797
|
e.font && (o.font = e.font);
|
|
1796
|
-
const
|
|
1797
|
-
if (
|
|
1798
|
-
const { height:
|
|
1799
|
-
o.fillStyle =
|
|
1800
|
-
const
|
|
1801
|
-
return o.fillRect(
|
|
1802
|
-
fill:
|
|
1803
|
-
fillOpacity:
|
|
1798
|
+
const v = i.get(h.annotation.id);
|
|
1799
|
+
if (v) {
|
|
1800
|
+
const { height: p } = h.rects[0], y = h.rects[0].x + u.left, x = h.rects[0].y + u.top;
|
|
1801
|
+
o.fillStyle = v.appearance.color, o.fillRect(y - 2, x - 2.5, 2, p + 5);
|
|
1802
|
+
const l = o.measureText(v.appearance.label), c = l.width + 6, b = l.actualBoundingBoxAscent + l.actualBoundingBoxDescent + 8, S = l.fontBoundingBoxAscent ? 8 : 6.5;
|
|
1803
|
+
return o.fillRect(y - 2, x - 2.5 - b, c, b), o.fillStyle = "#fff", o.fillText(v.appearance.label, y + 1, x - S), {
|
|
1804
|
+
fill: v.appearance.color,
|
|
1805
|
+
fillOpacity: g ? 0.45 : 0.18
|
|
1804
1806
|
};
|
|
1805
1807
|
}
|
|
1806
1808
|
},
|
|
@@ -1810,8 +1812,8 @@ const to = (t, e) => {
|
|
|
1810
1812
|
h.scale(2, 2), h.translate(0.5, 0.5);
|
|
1811
1813
|
}
|
|
1812
1814
|
};
|
|
1813
|
-
},
|
|
1814
|
-
function
|
|
1815
|
+
}, It = typeof navigator < "u" ? navigator.userAgent.toLowerCase().indexOf("firefox") > 0 : !1;
|
|
1816
|
+
function _t(t, e, n, o) {
|
|
1815
1817
|
t.addEventListener ? t.addEventListener(e, n, o) : t.attachEvent && t.attachEvent("on".concat(e), n);
|
|
1816
1818
|
}
|
|
1817
1819
|
function ot(t, e, n, o) {
|
|
@@ -1882,9 +1884,9 @@ const lt = {
|
|
|
1882
1884
|
".": 190,
|
|
1883
1885
|
"/": 191,
|
|
1884
1886
|
"`": 192,
|
|
1885
|
-
"-":
|
|
1886
|
-
"=":
|
|
1887
|
-
";":
|
|
1887
|
+
"-": It ? 173 : 189,
|
|
1888
|
+
"=": It ? 61 : 187,
|
|
1889
|
+
";": It ? 59 : 186,
|
|
1888
1890
|
"'": 222,
|
|
1889
1891
|
"[": 219,
|
|
1890
1892
|
"]": 221,
|
|
@@ -1905,7 +1907,7 @@ const lt = {
|
|
|
1905
1907
|
"⌘": 91,
|
|
1906
1908
|
cmd: 91,
|
|
1907
1909
|
command: 91
|
|
1908
|
-
},
|
|
1910
|
+
}, bt = {
|
|
1909
1911
|
16: "shiftKey",
|
|
1910
1912
|
18: "altKey",
|
|
1911
1913
|
17: "ctrlKey",
|
|
@@ -1914,7 +1916,7 @@ const lt = {
|
|
|
1914
1916
|
ctrlKey: 17,
|
|
1915
1917
|
altKey: 18,
|
|
1916
1918
|
metaKey: 91
|
|
1917
|
-
},
|
|
1919
|
+
}, K = {
|
|
1918
1920
|
16: !1,
|
|
1919
1921
|
18: !1,
|
|
1920
1922
|
17: !1,
|
|
@@ -1980,11 +1982,11 @@ function ho(t, e) {
|
|
|
1980
1982
|
}) : o++;
|
|
1981
1983
|
dt() === t && Ae(e || "all");
|
|
1982
1984
|
}
|
|
1983
|
-
function
|
|
1985
|
+
function go(t) {
|
|
1984
1986
|
let e = t.keyCode || t.which || t.charCode;
|
|
1985
1987
|
const n = I.indexOf(e);
|
|
1986
|
-
if (n >= 0 && I.splice(n, 1), t.key && t.key.toLowerCase() === "meta" && I.splice(0, I.length), (e === 93 || e === 224) && (e = 91), e in
|
|
1987
|
-
|
|
1988
|
+
if (n >= 0 && I.splice(n, 1), t.key && t.key.toLowerCase() === "meta" && I.splice(0, I.length), (e === 93 || e === 224) && (e = 91), e in K) {
|
|
1989
|
+
K[e] = !1;
|
|
1988
1990
|
for (const o in H) H[o] === e && (P[o] = !1);
|
|
1989
1991
|
}
|
|
1990
1992
|
}
|
|
@@ -2019,14 +2021,14 @@ const yt = (t) => {
|
|
|
2019
2021
|
splitKey: i = "+"
|
|
2020
2022
|
} = t;
|
|
2021
2023
|
be(e).forEach((a) => {
|
|
2022
|
-
const r = a.split(i),
|
|
2024
|
+
const r = a.split(i), d = r.length, f = r[d - 1], h = f === "*" ? "*" : ut(f);
|
|
2023
2025
|
if (!_[h]) return;
|
|
2024
2026
|
n || (n = dt());
|
|
2025
|
-
const u =
|
|
2026
|
-
_[h] = _[h].filter((
|
|
2027
|
-
const
|
|
2028
|
-
return
|
|
2029
|
-
}),
|
|
2027
|
+
const u = d > 1 ? ye(H, r) : [], g = [];
|
|
2028
|
+
_[h] = _[h].filter((v) => {
|
|
2029
|
+
const y = (o ? v.method === o : !0) && v.scope === n && io(v.mods, u);
|
|
2030
|
+
return y && g.push(v.element), !y;
|
|
2031
|
+
}), g.forEach((v) => Xt(v));
|
|
2030
2032
|
});
|
|
2031
2033
|
};
|
|
2032
2034
|
function ne(t, e, n, o) {
|
|
@@ -2035,27 +2037,27 @@ function ne(t, e, n, o) {
|
|
|
2035
2037
|
let i;
|
|
2036
2038
|
if (e.scope === n || e.scope === "all") {
|
|
2037
2039
|
i = e.mods.length > 0;
|
|
2038
|
-
for (const s in
|
|
2039
|
-
Object.prototype.hasOwnProperty.call(
|
|
2040
|
-
(e.mods.length === 0 && !
|
|
2040
|
+
for (const s in K)
|
|
2041
|
+
Object.prototype.hasOwnProperty.call(K, s) && (!K[s] && e.mods.indexOf(+s) > -1 || K[s] && e.mods.indexOf(+s) === -1) && (i = !1);
|
|
2042
|
+
(e.mods.length === 0 && !K[16] && !K[18] && !K[17] && !K[91] || i || e.shortcut === "*") && (e.keys = [], e.keys = e.keys.concat(I), e.method(t, e) === !1 && (t.preventDefault ? t.preventDefault() : t.returnValue = !1, t.stopPropagation && t.stopPropagation(), t.cancelBubble && (t.cancelBubble = !0)));
|
|
2041
2043
|
}
|
|
2042
2044
|
}
|
|
2043
2045
|
function oe(t, e) {
|
|
2044
2046
|
const n = _["*"];
|
|
2045
2047
|
let o = t.keyCode || t.which || t.charCode;
|
|
2046
2048
|
if (!P.filter.call(this, t)) return;
|
|
2047
|
-
if ((o === 93 || o === 224) && (o = 91), I.indexOf(o) === -1 && o !== 229 && I.push(o), ["
|
|
2048
|
-
const
|
|
2049
|
-
t[r] && I.indexOf(
|
|
2050
|
-
}), o in
|
|
2051
|
-
|
|
2049
|
+
if ((o === 93 || o === 224) && (o = 91), I.indexOf(o) === -1 && o !== 229 && I.push(o), ["metaKey", "ctrlKey", "altKey", "shiftKey"].forEach((r) => {
|
|
2050
|
+
const d = bt[r];
|
|
2051
|
+
t[r] && I.indexOf(d) === -1 ? I.push(d) : !t[r] && I.indexOf(d) > -1 ? I.splice(I.indexOf(d), 1) : r === "metaKey" && t[r] && (I = I.filter((f) => f in bt || f === o));
|
|
2052
|
+
}), o in K) {
|
|
2053
|
+
K[o] = !0;
|
|
2052
2054
|
for (const r in H)
|
|
2053
2055
|
H[r] === o && (P[r] = !0);
|
|
2054
2056
|
if (!n) return;
|
|
2055
2057
|
}
|
|
2056
|
-
for (const r in
|
|
2057
|
-
Object.prototype.hasOwnProperty.call(
|
|
2058
|
-
t.getModifierState && !(t.altKey && !t.ctrlKey) && t.getModifierState("AltGraph") && (I.indexOf(17) === -1 && I.push(17), I.indexOf(18) === -1 && I.push(18),
|
|
2058
|
+
for (const r in K)
|
|
2059
|
+
Object.prototype.hasOwnProperty.call(K, r) && (K[r] = t[bt[r]]);
|
|
2060
|
+
t.getModifierState && !(t.altKey && !t.ctrlKey) && t.getModifierState("AltGraph") && (I.indexOf(17) === -1 && I.push(17), I.indexOf(18) === -1 && I.push(18), K[17] = !0, K[18] = !0);
|
|
2059
2061
|
const i = dt();
|
|
2060
2062
|
if (n)
|
|
2061
2063
|
for (let r = 0; r < n.length; r++)
|
|
@@ -2064,21 +2066,21 @@ function oe(t, e) {
|
|
|
2064
2066
|
const s = _[o], a = s.length;
|
|
2065
2067
|
for (let r = 0; r < a; r++)
|
|
2066
2068
|
if ((t.type === "keydown" && s[r].keydown || t.type === "keyup" && s[r].keyup) && s[r].key) {
|
|
2067
|
-
const
|
|
2069
|
+
const d = s[r], {
|
|
2068
2070
|
splitKey: f
|
|
2069
|
-
} =
|
|
2070
|
-
for (let
|
|
2071
|
-
u.push(ut(h[
|
|
2072
|
-
u.sort().join("") === I.sort().join("") && ne(t,
|
|
2071
|
+
} = d, h = d.key.split(f), u = [];
|
|
2072
|
+
for (let g = 0; g < h.length; g++)
|
|
2073
|
+
u.push(ut(h[g]));
|
|
2074
|
+
u.sort().join("") === I.sort().join("") && ne(t, d, i, e);
|
|
2073
2075
|
}
|
|
2074
2076
|
}
|
|
2075
2077
|
function P(t, e, n) {
|
|
2076
2078
|
I = [];
|
|
2077
2079
|
const o = be(t);
|
|
2078
|
-
let i = [], s = "all", a = document, r = 0,
|
|
2079
|
-
for (n === void 0 && typeof e == "function" && (n = e), Object.prototype.toString.call(e) === "[object Object]" && (e.scope && (s = e.scope), e.element && (a = e.element), e.keyup && (
|
|
2080
|
+
let i = [], s = "all", a = document, r = 0, d = !1, f = !0, h = "+", u = !1, g = !1;
|
|
2081
|
+
for (n === void 0 && typeof e == "function" && (n = e), Object.prototype.toString.call(e) === "[object Object]" && (e.scope && (s = e.scope), e.element && (a = e.element), e.keyup && (d = e.keyup), e.keydown !== void 0 && (f = e.keydown), e.capture !== void 0 && (u = e.capture), typeof e.splitKey == "string" && (h = e.splitKey), e.single === !0 && (g = !0)), typeof e == "string" && (s = e), g && xe(t, s); r < o.length; r++)
|
|
2080
2082
|
t = o[r].split(h), i = [], t.length > 1 && (i = ye(H, t)), t = t[t.length - 1], t = t === "*" ? "*" : ut(t), t in _ || (_[t] = []), _[t].push({
|
|
2081
|
-
keyup:
|
|
2083
|
+
keyup: d,
|
|
2082
2084
|
keydown: f,
|
|
2083
2085
|
scope: s,
|
|
2084
2086
|
mods: i,
|
|
@@ -2090,31 +2092,31 @@ function P(t, e, n) {
|
|
|
2090
2092
|
});
|
|
2091
2093
|
if (typeof a < "u" && window) {
|
|
2092
2094
|
if (!z.has(a)) {
|
|
2093
|
-
const
|
|
2094
|
-
let
|
|
2095
|
-
return oe(
|
|
2096
|
-
},
|
|
2097
|
-
let
|
|
2098
|
-
oe(
|
|
2095
|
+
const v = function() {
|
|
2096
|
+
let y = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : window.event;
|
|
2097
|
+
return oe(y, a);
|
|
2098
|
+
}, p = function() {
|
|
2099
|
+
let y = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : window.event;
|
|
2100
|
+
oe(y, a), go(y);
|
|
2099
2101
|
};
|
|
2100
2102
|
z.set(a, {
|
|
2101
|
-
keydownListener:
|
|
2102
|
-
keyupListenr:
|
|
2103
|
+
keydownListener: v,
|
|
2104
|
+
keyupListenr: p,
|
|
2103
2105
|
capture: u
|
|
2104
|
-
}),
|
|
2106
|
+
}), _t(a, "keydown", v, u), _t(a, "keyup", p, u);
|
|
2105
2107
|
}
|
|
2106
2108
|
if (!ct) {
|
|
2107
|
-
const
|
|
2109
|
+
const v = () => {
|
|
2108
2110
|
I = [];
|
|
2109
2111
|
};
|
|
2110
2112
|
ct = {
|
|
2111
|
-
listener:
|
|
2113
|
+
listener: v,
|
|
2112
2114
|
capture: u
|
|
2113
|
-
},
|
|
2115
|
+
}, _t(window, "focus", v, u);
|
|
2114
2116
|
}
|
|
2115
2117
|
}
|
|
2116
2118
|
}
|
|
2117
|
-
function
|
|
2119
|
+
function po(t) {
|
|
2118
2120
|
let e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "all";
|
|
2119
2121
|
Object.keys(_).forEach((n) => {
|
|
2120
2122
|
_[n].filter((i) => i.scope === e && i.shortcut === t).forEach((i) => {
|
|
@@ -2152,7 +2154,7 @@ function Xt(t) {
|
|
|
2152
2154
|
ot(window, "focus", i, s), ct = null;
|
|
2153
2155
|
}
|
|
2154
2156
|
}
|
|
2155
|
-
const
|
|
2157
|
+
const Nt = {
|
|
2156
2158
|
getPressedKeyString: co,
|
|
2157
2159
|
setScope: Ae,
|
|
2158
2160
|
getScope: dt,
|
|
@@ -2161,14 +2163,14 @@ const _t = {
|
|
|
2161
2163
|
getAllKeyCodes: lo,
|
|
2162
2164
|
isPressed: fo,
|
|
2163
2165
|
filter: uo,
|
|
2164
|
-
trigger:
|
|
2166
|
+
trigger: po,
|
|
2165
2167
|
unbind: xe,
|
|
2166
2168
|
keyMap: lt,
|
|
2167
2169
|
modifier: H,
|
|
2168
|
-
modifierMap:
|
|
2170
|
+
modifierMap: bt
|
|
2169
2171
|
};
|
|
2170
|
-
for (const t in
|
|
2171
|
-
Object.prototype.hasOwnProperty.call(
|
|
2172
|
+
for (const t in Nt)
|
|
2173
|
+
Object.prototype.hasOwnProperty.call(Nt, t) && (P[t] = Nt[t]);
|
|
2172
2174
|
if (typeof window < "u") {
|
|
2173
2175
|
const t = window.hotkeys;
|
|
2174
2176
|
P.noConflict = (e) => (e && window.hotkeys === P && (window.hotkeys = t), P), window.hotkeys = P;
|
|
@@ -2179,97 +2181,97 @@ const ie = 300, ve = ["up", "down", "left", "right"], Ee = Te ? "⌘+a" : "ctrl+
|
|
|
2179
2181
|
], yo = (t, e, n) => {
|
|
2180
2182
|
let o;
|
|
2181
2183
|
const { annotatingEnabled: i, offsetReferenceSelector: s, selectionMode: a } = n, r = (T) => o = T;
|
|
2182
|
-
let
|
|
2183
|
-
const f = (T) =>
|
|
2184
|
-
let
|
|
2185
|
-
const
|
|
2186
|
-
|
|
2184
|
+
let d;
|
|
2185
|
+
const f = (T) => d = T, { store: h, selection: u } = e;
|
|
2186
|
+
let g, v, p;
|
|
2187
|
+
const y = (T) => {
|
|
2188
|
+
v !== !1 && (g = it(T.target) ? void 0 : {
|
|
2187
2189
|
annotation: fe(),
|
|
2188
2190
|
selector: [],
|
|
2189
2191
|
creator: o,
|
|
2190
2192
|
created: /* @__PURE__ */ new Date()
|
|
2191
2193
|
});
|
|
2192
|
-
},
|
|
2194
|
+
}, x = Yt((T) => {
|
|
2193
2195
|
const m = document.getSelection();
|
|
2194
2196
|
if (!(m != null && m.anchorNode))
|
|
2195
2197
|
return;
|
|
2196
2198
|
if (it(m.anchorNode)) {
|
|
2197
|
-
|
|
2199
|
+
g = void 0;
|
|
2198
2200
|
return;
|
|
2199
2201
|
}
|
|
2200
|
-
const
|
|
2201
|
-
if ((
|
|
2202
|
+
const A = T.timeStamp - ((p == null ? void 0 : p.timeStamp) || T.timeStamp);
|
|
2203
|
+
if ((p == null ? void 0 : p.type) === "pointerdown" && (A < 1e3 && !g || m.isCollapsed && A < ie) && y(p || T), !g) return;
|
|
2202
2204
|
if (m.isCollapsed) {
|
|
2203
|
-
h.getAnnotation(
|
|
2205
|
+
h.getAnnotation(g.annotation) && (u.clear(), h.deleteAnnotation(g.annotation));
|
|
2204
2206
|
return;
|
|
2205
2207
|
}
|
|
2206
|
-
const
|
|
2208
|
+
const w = m.getRangeAt(0), L = Ye(w, t);
|
|
2207
2209
|
if (Ie(L)) return;
|
|
2208
|
-
const
|
|
2209
|
-
(
|
|
2210
|
+
const M = Me(L.cloneRange());
|
|
2211
|
+
(M.length !== g.selector.length || M.some((N, U) => {
|
|
2210
2212
|
var et;
|
|
2211
|
-
return N.toString() !== ((et =
|
|
2212
|
-
})) && (
|
|
2213
|
-
...
|
|
2214
|
-
selector:
|
|
2213
|
+
return N.toString() !== ((et = g.selector[U]) == null ? void 0 : et.quote);
|
|
2214
|
+
})) && (g = {
|
|
2215
|
+
...g,
|
|
2216
|
+
selector: M.map((N) => Ve(N, t, s)),
|
|
2215
2217
|
updated: /* @__PURE__ */ new Date()
|
|
2216
|
-
}, h.getAnnotation(
|
|
2217
|
-
}),
|
|
2218
|
-
it(T.target) || (
|
|
2218
|
+
}, h.getAnnotation(g.annotation) ? h.updateTarget(g, k.LOCAL) : u.clear());
|
|
2219
|
+
}), l = (T) => {
|
|
2220
|
+
it(T.target) || (p = xt(T), v = p.button === 0);
|
|
2219
2221
|
}, c = (T) => {
|
|
2220
|
-
if (it(T.target) || !
|
|
2222
|
+
if (it(T.target) || !v) return;
|
|
2221
2223
|
const m = () => {
|
|
2222
|
-
const { x:
|
|
2223
|
-
if (
|
|
2224
|
-
const { selected: R } = u, N = new Set(R.map((q) => q.id)), U = Array.isArray(
|
|
2224
|
+
const { x: w, y: L } = t.getBoundingClientRect(), M = T.target instanceof Node && t.contains(T.target) && h.getAt(T.clientX - w, T.clientY - L, a === "all", d);
|
|
2225
|
+
if (M) {
|
|
2226
|
+
const { selected: R } = u, N = new Set(R.map((q) => q.id)), U = Array.isArray(M) ? M.map((q) => q.id) : [M.id];
|
|
2225
2227
|
(N.size !== U.length || !U.every((q) => N.has(q))) && u.userSelect(U, T);
|
|
2226
2228
|
} else
|
|
2227
2229
|
u.clear();
|
|
2228
|
-
},
|
|
2230
|
+
}, A = T.timeStamp - p.timeStamp;
|
|
2229
2231
|
setTimeout(() => {
|
|
2230
|
-
const
|
|
2231
|
-
|
|
2232
|
+
const w = document.getSelection();
|
|
2233
|
+
w != null && w.isCollapsed && A < ie ? (g = void 0, m()) : g && g.selector.length > 0 && (O(), u.userSelect(g.annotation, xt(T)));
|
|
2232
2234
|
});
|
|
2233
|
-
},
|
|
2235
|
+
}, b = (T) => {
|
|
2234
2236
|
const m = document.getSelection();
|
|
2235
|
-
m != null && m.isCollapsed || ((!
|
|
2237
|
+
m != null && m.isCollapsed || ((!g || g.selector.length === 0) && x(T), O(), u.userSelect(g.annotation, xt(T)));
|
|
2236
2238
|
}, S = (T) => {
|
|
2237
|
-
T.key === "Shift" &&
|
|
2239
|
+
T.key === "Shift" && g && (document.getSelection().isCollapsed || (O(), u.userSelect(g.annotation, ft(T))));
|
|
2238
2240
|
}, E = (T) => {
|
|
2239
2241
|
const m = () => setTimeout(() => {
|
|
2240
|
-
(
|
|
2241
|
-
id:
|
|
2242
|
+
(g == null ? void 0 : g.selector.length) > 0 && (u.clear(), h.addAnnotation({
|
|
2243
|
+
id: g.annotation,
|
|
2242
2244
|
bodies: [],
|
|
2243
|
-
target:
|
|
2244
|
-
}), u.userSelect(
|
|
2245
|
+
target: g
|
|
2246
|
+
}), u.userSelect(g.annotation, ft(T))), document.removeEventListener("selectionchange", m);
|
|
2245
2247
|
}, 100);
|
|
2246
|
-
document.addEventListener("selectionchange", m),
|
|
2248
|
+
document.addEventListener("selectionchange", m), y(T);
|
|
2247
2249
|
};
|
|
2248
2250
|
P(mo.join(","), { element: t, keydown: !0, keyup: !1 }, (T) => {
|
|
2249
|
-
T.repeat || (
|
|
2251
|
+
T.repeat || (p = ft(T));
|
|
2250
2252
|
}), P(Ee, { keydown: !0, keyup: !1 }, (T) => {
|
|
2251
|
-
|
|
2253
|
+
p = ft(T), E(T);
|
|
2252
2254
|
});
|
|
2253
2255
|
const C = (T) => {
|
|
2254
|
-
T.repeat || T.target !== t && T.target !== document.body || (
|
|
2256
|
+
T.repeat || T.target !== t && T.target !== document.body || (g = void 0, u.clear());
|
|
2255
2257
|
};
|
|
2256
2258
|
P(ve.join(","), { keydown: !0, keyup: !1 }, C);
|
|
2257
2259
|
const O = () => {
|
|
2258
|
-
const T = h.getAnnotation(
|
|
2260
|
+
const T = h.getAnnotation(g.annotation);
|
|
2259
2261
|
if (!T) {
|
|
2260
2262
|
h.addAnnotation({
|
|
2261
|
-
id:
|
|
2263
|
+
id: g.annotation,
|
|
2262
2264
|
bodies: [],
|
|
2263
|
-
target:
|
|
2265
|
+
target: g
|
|
2264
2266
|
});
|
|
2265
2267
|
return;
|
|
2266
2268
|
}
|
|
2267
|
-
const { target: { updated: m } } = T, { updated:
|
|
2268
|
-
(!m || !
|
|
2269
|
+
const { target: { updated: m } } = T, { updated: A } = g;
|
|
2270
|
+
(!m || !A || m < A) && h.updateTarget(g);
|
|
2269
2271
|
};
|
|
2270
|
-
return t.addEventListener("pointerdown",
|
|
2272
|
+
return t.addEventListener("pointerdown", l), document.addEventListener("pointerup", c), document.addEventListener("contextmenu", b), i && (t.addEventListener("keyup", S), t.addEventListener("selectstart", y), document.addEventListener("selectionchange", x)), {
|
|
2271
2273
|
destroy: () => {
|
|
2272
|
-
t.removeEventListener("pointerdown",
|
|
2274
|
+
t.removeEventListener("pointerdown", l), document.removeEventListener("pointerup", c), document.removeEventListener("contextmenu", b), t.removeEventListener("keyup", S), t.removeEventListener("selectstart", y), document.removeEventListener("selectionchange", x), P.unbind();
|
|
2273
2275
|
},
|
|
2274
2276
|
setFilter: f,
|
|
2275
2277
|
setUser: r
|
|
@@ -2282,27 +2284,27 @@ const ie = 300, ve = ["up", "down", "left", "right"], Ee = Te ? "⌘+a" : "ctrl+
|
|
|
2282
2284
|
Le(t), Oe(t);
|
|
2283
2285
|
const n = bo(e, {
|
|
2284
2286
|
annotatingEnabled: !0,
|
|
2285
|
-
user:
|
|
2286
|
-
}), o = eo(t, n.userSelectAction), { selection: i, viewport: s } = o, a = o.store, r =
|
|
2287
|
+
user: Dn()
|
|
2288
|
+
}), o = eo(t, n.userSelectAction), { selection: i, viewport: s } = o, a = o.store, r = Bn(a), d = Rn(o, r, n.adapter);
|
|
2287
2289
|
let f = n.user;
|
|
2288
2290
|
const h = n.renderer === "CSS_HIGHLIGHTS" ? CSS.highlights ? "CSS_HIGHLIGHTS" : se : n.renderer || se, u = h === "SPANS" ? rn(t, o, s) : h === "CSS_HIGHLIGHTS" ? nn(t, o, s) : h === "CANVAS" ? ze(t, o, s) : void 0;
|
|
2289
2291
|
if (!u)
|
|
2290
2292
|
throw `Unknown renderer implementation: ${h}`;
|
|
2291
2293
|
console.debug(`Using ${h} renderer`), n.style && u.setStyle(n.style);
|
|
2292
|
-
const
|
|
2293
|
-
return
|
|
2294
|
+
const g = yo(t, o, n);
|
|
2295
|
+
return g.setUser(f), {
|
|
2294
2296
|
...In(o, r, n.adapter),
|
|
2295
2297
|
destroy: () => {
|
|
2296
|
-
u.destroy(),
|
|
2298
|
+
u.destroy(), g.destroy(), r.destroy();
|
|
2297
2299
|
},
|
|
2298
2300
|
element: t,
|
|
2299
2301
|
getUser: () => f,
|
|
2300
2302
|
setFilter: (C) => {
|
|
2301
|
-
u.setFilter(C),
|
|
2303
|
+
u.setFilter(C), g.setFilter(C);
|
|
2302
2304
|
},
|
|
2303
2305
|
setStyle: (C) => u.setStyle(C),
|
|
2304
2306
|
setUser: (C) => {
|
|
2305
|
-
f = C,
|
|
2307
|
+
f = C, g.setUser(C);
|
|
2306
2308
|
},
|
|
2307
2309
|
setSelected: (C) => {
|
|
2308
2310
|
C ? i.setSelected(C) : i.clear();
|
|
@@ -2311,14 +2313,14 @@ const ie = 300, ve = ["up", "down", "left", "right"], Ee = Te ? "⌘+a" : "ctrl+
|
|
|
2311
2313
|
C && (u.setPainter(oo(C, n.presence)), C.on("selectionChange", () => u.redraw()));
|
|
2312
2314
|
},
|
|
2313
2315
|
setVisible: (C) => u.setVisible(C),
|
|
2314
|
-
on:
|
|
2315
|
-
off:
|
|
2316
|
-
scrollIntoView:
|
|
2316
|
+
on: d.on,
|
|
2317
|
+
off: d.off,
|
|
2318
|
+
scrollIntoView: De(t, a),
|
|
2317
2319
|
state: o
|
|
2318
2320
|
};
|
|
2319
2321
|
};
|
|
2320
2322
|
export {
|
|
2321
|
-
|
|
2323
|
+
At as DEFAULT_SELECTED_STYLE,
|
|
2322
2324
|
W as DEFAULT_STYLE,
|
|
2323
2325
|
re as NOT_ANNOTATABLE_CLASS,
|
|
2324
2326
|
tt as NOT_ANNOTATABLE_SELECTOR,
|
|
@@ -2328,7 +2330,7 @@ export {
|
|
|
2328
2330
|
xo as W3CTextFormat,
|
|
2329
2331
|
Le as cancelSingleClickEvents,
|
|
2330
2332
|
ft as cloneKeyboardEvent,
|
|
2331
|
-
|
|
2333
|
+
xt as clonePointerEvent,
|
|
2332
2334
|
Ao as createBody,
|
|
2333
2335
|
ze as createCanvasRenderer,
|
|
2334
2336
|
nn as createHighlightsRenderer,
|
|
@@ -2340,23 +2342,23 @@ export {
|
|
|
2340
2342
|
Yt as debounce,
|
|
2341
2343
|
bo as fillDefaults,
|
|
2342
2344
|
Re as getQuoteContext,
|
|
2343
|
-
|
|
2345
|
+
Ut as getRangeAnnotatableContents,
|
|
2344
2346
|
Te as isMac,
|
|
2345
2347
|
it as isNotAnnotatable,
|
|
2346
2348
|
Ce as isRangeAnnotatable,
|
|
2347
2349
|
F as isRevived,
|
|
2348
2350
|
Ie as isWhitespaceOrEmpty,
|
|
2349
2351
|
Ue as mergeClientRects,
|
|
2350
|
-
|
|
2352
|
+
Ke as paint,
|
|
2351
2353
|
jn as parseW3CTextAnnotation,
|
|
2352
2354
|
Oe as programmaticallyFocusable,
|
|
2353
2355
|
Ve as rangeToSelector,
|
|
2354
|
-
|
|
2356
|
+
vt as reviveAnnotation,
|
|
2355
2357
|
ae as reviveSelector,
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
+
wt as reviveTarget,
|
|
2359
|
+
De as scrollIntoView,
|
|
2358
2360
|
zn as serializeW3CTextAnnotation,
|
|
2359
|
-
|
|
2361
|
+
Me as splitAnnotatableRanges,
|
|
2360
2362
|
wo as toDomRectList,
|
|
2361
2363
|
Ye as trimRangeToContainer,
|
|
2362
2364
|
ke as whitespaceOrEmptyRegex
|