@soomo/text-annotator 3.1.0-staging.4 → 3.1.0-staging.6
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const le = "not-annotatable", Z = `.${le}`, nt = (t) => {
|
|
2
2
|
var n;
|
|
3
3
|
return !!(t instanceof HTMLElement ? t.closest(Z) : (n = t.parentElement) == null ? void 0 : n.closest(Z));
|
|
4
4
|
}, Me = (t) => {
|
|
@@ -8,7 +8,7 @@ const ce = "not-annotatable", Z = `.${ce}`, nt = (t) => {
|
|
|
8
8
|
const e = document.createNodeIterator(
|
|
9
9
|
t.commonAncestorContainer,
|
|
10
10
|
NodeFilter.SHOW_ELEMENT,
|
|
11
|
-
(o) => o instanceof HTMLElement && o.classList.contains(
|
|
11
|
+
(o) => o instanceof HTMLElement && o.classList.contains(le) && !o.parentElement.closest(Z) && t.intersectsNode(o) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP
|
|
12
12
|
);
|
|
13
13
|
let n;
|
|
14
14
|
for (; n = e.nextNode(); )
|
|
@@ -26,7 +26,7 @@ const ce = "not-annotatable", Z = `.${ce}`, nt = (t) => {
|
|
|
26
26
|
o.setStartAfter(n), o.collapsed || e.push(o);
|
|
27
27
|
}
|
|
28
28
|
return e.length > 0 ? e : [t];
|
|
29
|
-
},
|
|
29
|
+
}, Dt = (t) => {
|
|
30
30
|
const e = t.cloneContents();
|
|
31
31
|
return e.querySelectorAll(Z).forEach((n) => n.remove()), e;
|
|
32
32
|
}, Ie = (t) => t.addEventListener("click", (e) => {
|
|
@@ -37,9 +37,9 @@ const ce = "not-annotatable", Z = `.${ce}`, nt = (t) => {
|
|
|
37
37
|
}, Ue = (t, e, n = 10, o) => {
|
|
38
38
|
const i = o ? t.startContainer.parentElement.closest(o) : e, s = document.createRange();
|
|
39
39
|
s.setStart(i, 0), s.setEnd(t.startContainer, t.startOffset);
|
|
40
|
-
const r =
|
|
40
|
+
const r = Dt(s).textContent, a = document.createRange();
|
|
41
41
|
a.setStart(t.endContainer, t.endOffset), i === document.body ? a.setEnd(i, i.childNodes.length) : a.setEndAfter(i);
|
|
42
|
-
const d =
|
|
42
|
+
const d = Dt(a).textContent;
|
|
43
43
|
return {
|
|
44
44
|
prefix: r.substring(r.length - n),
|
|
45
45
|
suffix: d.substring(0, n)
|
|
@@ -92,26 +92,26 @@ const ce = "not-annotatable", Z = `.${ce}`, nt = (t) => {
|
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
94
|
return i ? o : [...o, n];
|
|
95
|
-
}, []),
|
|
95
|
+
}, []), Mo = (t) => ({
|
|
96
96
|
length: t.length,
|
|
97
97
|
item: (e) => t[e],
|
|
98
98
|
[Symbol.iterator]: function* () {
|
|
99
99
|
for (let e = 0; e < this.length; e++)
|
|
100
100
|
yield this.item(e);
|
|
101
101
|
}
|
|
102
|
-
}),
|
|
102
|
+
}), Pe = (t, e, n) => {
|
|
103
103
|
const o = document.createRange(), i = n ? t.startContainer.parentElement.closest(n) : e;
|
|
104
104
|
o.setStart(i, 0), o.setEnd(t.startContainer, t.startOffset);
|
|
105
|
-
const s =
|
|
105
|
+
const s = Dt(o).textContent, r = t.toString(), a = s.length || 0, d = a + r.length;
|
|
106
106
|
return n ? { quote: r, start: a, end: d, range: t, offsetReference: i } : { quote: r, start: a, end: d, range: t };
|
|
107
|
-
},
|
|
108
|
-
var
|
|
107
|
+
}, de = (t, e) => {
|
|
108
|
+
var h, l;
|
|
109
109
|
const { start: n, end: o } = t, i = t.offsetReference || e, s = document.createNodeIterator(
|
|
110
110
|
e,
|
|
111
111
|
NodeFilter.SHOW_TEXT,
|
|
112
|
-
(
|
|
113
|
-
var
|
|
114
|
-
return (
|
|
112
|
+
(g) => {
|
|
113
|
+
var p;
|
|
114
|
+
return (p = g.parentElement) != null && p.closest(Z) ? NodeFilter.FILTER_SKIP : NodeFilter.FILTER_ACCEPT;
|
|
115
115
|
}
|
|
116
116
|
);
|
|
117
117
|
let r = 0;
|
|
@@ -121,22 +121,22 @@ const ce = "not-annotatable", Z = `.${ce}`, nt = (t) => {
|
|
|
121
121
|
let c = !i;
|
|
122
122
|
for (; d !== null; ) {
|
|
123
123
|
if (c || (c = i == null ? void 0 : i.contains(d)), c) {
|
|
124
|
-
const
|
|
125
|
-
if (r +
|
|
124
|
+
const g = ((h = d.textContent) == null ? void 0 : h.length) || 0;
|
|
125
|
+
if (r + g > n) {
|
|
126
126
|
a.setStart(d, n - r);
|
|
127
127
|
break;
|
|
128
128
|
}
|
|
129
|
-
r +=
|
|
129
|
+
r += g;
|
|
130
130
|
}
|
|
131
131
|
d = s.nextNode();
|
|
132
132
|
}
|
|
133
133
|
for (; d !== null; ) {
|
|
134
|
-
const
|
|
135
|
-
if (r +
|
|
134
|
+
const g = ((l = d.textContent) == null ? void 0 : l.length) || 0;
|
|
135
|
+
if (r + g >= o) {
|
|
136
136
|
a.setEnd(d, o - r);
|
|
137
137
|
break;
|
|
138
138
|
}
|
|
139
|
-
r +=
|
|
139
|
+
r += g, d = s.nextNode();
|
|
140
140
|
}
|
|
141
141
|
return {
|
|
142
142
|
...t,
|
|
@@ -144,21 +144,21 @@ const ce = "not-annotatable", Z = `.${ce}`, nt = (t) => {
|
|
|
144
144
|
};
|
|
145
145
|
}, wt = (t, e) => F(t.selector) ? t : {
|
|
146
146
|
...t,
|
|
147
|
-
selector: t.selector.map((n) => n.range instanceof Range && !n.range.collapsed ? n :
|
|
148
|
-
},
|
|
147
|
+
selector: t.selector.map((n) => n.range instanceof Range && !n.range.collapsed ? n : de(n, e))
|
|
148
|
+
}, xt = (t, e) => F(t.target.selector) ? t : { ...t, target: wt(t.target, e) }, ue = (t, e) => {
|
|
149
149
|
if (t.isEqualNode(e))
|
|
150
150
|
return !0;
|
|
151
151
|
for (let n of t.childNodes)
|
|
152
|
-
if (
|
|
152
|
+
if (ue(n, e))
|
|
153
153
|
return !0;
|
|
154
154
|
return !1;
|
|
155
|
-
},
|
|
155
|
+
}, $e = (t, e) => {
|
|
156
156
|
const n = t.cloneContents();
|
|
157
|
-
return
|
|
157
|
+
return ue(n, e);
|
|
158
158
|
}, je = (t, e) => {
|
|
159
159
|
const n = t.cloneRange(), o = e.contains(n.startContainer), i = e.contains(n.endContainer);
|
|
160
|
-
return !o && !i &&
|
|
161
|
-
},
|
|
160
|
+
return !o && !i && !$e(n, e) ? (n.collapse(), n) : (o || n.setStart(e, 0), i || n.setEnd(e, e.childNodes.length), n);
|
|
161
|
+
}, Et = (t) => ({
|
|
162
162
|
...t,
|
|
163
163
|
type: t.type,
|
|
164
164
|
x: t.x,
|
|
@@ -203,19 +203,19 @@ const ce = "not-annotatable", Z = `.${ce}`, nt = (t) => {
|
|
|
203
203
|
}), He = (t, e) => {
|
|
204
204
|
const { left: n, top: o, right: i, bottom: s } = t;
|
|
205
205
|
return new DOMRect(n - e.left, o - e.top, i - n, s - o);
|
|
206
|
-
},
|
|
206
|
+
}, Bo = (t, e) => {
|
|
207
207
|
const { left: n, top: o, right: i, bottom: s } = t;
|
|
208
208
|
return new DOMRect(n + e.left, o + e.top, i - n, s - o);
|
|
209
|
-
},
|
|
209
|
+
}, fe = (t) => {
|
|
210
210
|
if (t === null)
|
|
211
211
|
return document.scrollingElement;
|
|
212
212
|
const { overflowY: e } = window.getComputedStyle(t);
|
|
213
|
-
return e !== "visible" && e !== "hidden" && t.scrollHeight > t.clientHeight ? t :
|
|
213
|
+
return e !== "visible" && e !== "hidden" && t.scrollHeight > t.clientHeight ? t : fe(t.parentElement);
|
|
214
214
|
}, ze = (t, e) => (n) => {
|
|
215
215
|
const o = typeof n == "string" ? n : n.id, i = (r) => {
|
|
216
|
-
const a = s.getBoundingClientRect(), d = s.clientHeight, c = s.clientWidth,
|
|
216
|
+
const a = s.getBoundingClientRect(), d = s.clientHeight, c = s.clientWidth, h = r.selector[0].range.getBoundingClientRect(), { width: l, height: g } = e.getAnnotationBounds(o), p = h.top - a.top, v = h.left - a.left, w = s.parentElement ? s.scrollTop : 0, E = s.parentElement ? s.scrollLeft : 0, m = p + w - (d - g) / 2, u = v + E - (c - l) / 2;
|
|
217
217
|
s.scroll({ top: m, left: u, behavior: "smooth" });
|
|
218
|
-
}, s =
|
|
218
|
+
}, s = fe(t);
|
|
219
219
|
if (s) {
|
|
220
220
|
const r = e.getAnnotation(o), { range: a } = r.target.selector[0];
|
|
221
221
|
if (a && !a.collapsed)
|
|
@@ -241,8 +241,8 @@ const ce = "not-annotatable", Z = `.${ce}`, nt = (t) => {
|
|
|
241
241
|
function We(t) {
|
|
242
242
|
return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
|
|
243
243
|
}
|
|
244
|
-
var
|
|
245
|
-
function
|
|
244
|
+
var Yt = { exports: {} };
|
|
245
|
+
function he(t, e = 100, n = {}) {
|
|
246
246
|
if (typeof t != "function")
|
|
247
247
|
throw new TypeError(`Expected the first parameter to be a function, got \`${typeof t}\`.`);
|
|
248
248
|
if (e < 0)
|
|
@@ -250,19 +250,19 @@ function fe(t, e = 100, n = {}) {
|
|
|
250
250
|
const { immediate: o } = typeof n == "boolean" ? { immediate: n } : n;
|
|
251
251
|
let i, s, r, a, d;
|
|
252
252
|
function c() {
|
|
253
|
-
const
|
|
254
|
-
return i = void 0, s = void 0, d = t.apply(
|
|
253
|
+
const g = i, p = s;
|
|
254
|
+
return i = void 0, s = void 0, d = t.apply(g, p), d;
|
|
255
255
|
}
|
|
256
|
-
function
|
|
257
|
-
const
|
|
258
|
-
|
|
256
|
+
function h() {
|
|
257
|
+
const g = Date.now() - a;
|
|
258
|
+
g < e && g >= 0 ? r = setTimeout(h, e - g) : (r = void 0, o || (d = c()));
|
|
259
259
|
}
|
|
260
|
-
const l = function(...
|
|
260
|
+
const l = function(...g) {
|
|
261
261
|
if (i && this !== i && Object.getPrototypeOf(this) === Object.getPrototypeOf(i))
|
|
262
262
|
throw new Error("Debounced method called with different contexts of the same prototype.");
|
|
263
|
-
i = this, s =
|
|
264
|
-
const
|
|
265
|
-
return r || (r = setTimeout(
|
|
263
|
+
i = this, s = g, a = Date.now();
|
|
264
|
+
const p = o && !r;
|
|
265
|
+
return r || (r = setTimeout(h, e)), p && (d = c()), d;
|
|
266
266
|
};
|
|
267
267
|
return l.clear = () => {
|
|
268
268
|
r && (clearTimeout(r), r = void 0);
|
|
@@ -272,10 +272,10 @@ function fe(t, e = 100, n = {}) {
|
|
|
272
272
|
d = c(), l.clear();
|
|
273
273
|
}, l;
|
|
274
274
|
}
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
var qe =
|
|
278
|
-
const
|
|
275
|
+
Yt.exports.debounce = he;
|
|
276
|
+
Yt.exports = he;
|
|
277
|
+
var qe = Yt.exports;
|
|
278
|
+
const Xt = /* @__PURE__ */ We(qe), Ge = (t) => {
|
|
279
279
|
const { top: e, left: n } = t.getBoundingClientRect(), { innerWidth: o, innerHeight: i } = window, s = -n, r = -e, a = o - n, d = i - e;
|
|
280
280
|
return { top: e, left: n, minX: s, minY: r, maxX: a, maxY: d };
|
|
281
281
|
}, Qe = (t) => {
|
|
@@ -284,48 +284,48 @@ const Yt = /* @__PURE__ */ We(qe), Ge = (t) => {
|
|
|
284
284
|
const i = o.map((s) => s.id);
|
|
285
285
|
(e.size !== i.length || i.some((s) => !e.has(s))) && t.set(i), e = new Set(i);
|
|
286
286
|
};
|
|
287
|
-
},
|
|
287
|
+
}, Pt = (t, e, n, o) => {
|
|
288
288
|
const { store: i, selection: s, hover: r } = e;
|
|
289
289
|
let a, d, c;
|
|
290
|
-
const
|
|
291
|
-
const { x:
|
|
292
|
-
|
|
290
|
+
const h = Qe(n), l = (O) => {
|
|
291
|
+
const { x: M, y: f } = t.getBoundingClientRect(), y = i.getAt(O.clientX - M, O.clientY - f, d);
|
|
292
|
+
y ? r.current !== y.id && (t.classList.add("hovered"), r.set(y.id)) : r.current && (t.classList.remove("hovered"), r.set(null));
|
|
293
293
|
};
|
|
294
294
|
t.addEventListener("pointermove", l);
|
|
295
|
-
const
|
|
295
|
+
const g = (O = !1) => {
|
|
296
296
|
c && c.clear();
|
|
297
|
-
const
|
|
298
|
-
const
|
|
299
|
-
return { annotation: Y, rects:
|
|
297
|
+
const M = Ge(t), { minX: f, minY: y, maxX: x, maxY: C } = M, B = d ? i.getIntersecting(f, y, x, C).filter(({ annotation: Y }) => d(Y)) : i.getIntersecting(f, y, x, C), R = s.selected.map(({ id: Y }) => Y), K = B.map(({ annotation: Y, rects: At }) => {
|
|
298
|
+
const dt = R.includes(Y.id), Re = Y.id === r.current;
|
|
299
|
+
return { annotation: Y, rects: At, state: { selected: dt, hover: Re } };
|
|
300
300
|
});
|
|
301
|
-
o.redraw(K,
|
|
302
|
-
},
|
|
303
|
-
c =
|
|
304
|
-
},
|
|
305
|
-
a =
|
|
306
|
-
},
|
|
307
|
-
d =
|
|
308
|
-
}, E = () =>
|
|
301
|
+
o.redraw(K, M, a, c, O), setTimeout(() => h(B.map(({ annotation: Y }) => Y)), 1);
|
|
302
|
+
}, p = (O) => {
|
|
303
|
+
c = O, g();
|
|
304
|
+
}, v = (O) => {
|
|
305
|
+
a = O, g();
|
|
306
|
+
}, w = (O) => {
|
|
307
|
+
d = O, g(!1);
|
|
308
|
+
}, E = () => g();
|
|
309
309
|
i.observe(E);
|
|
310
|
-
const m = s.subscribe(() =>
|
|
310
|
+
const m = s.subscribe(() => g()), u = () => g(!0);
|
|
311
311
|
document.addEventListener("scroll", u, { capture: !0, passive: !0 });
|
|
312
|
-
const
|
|
313
|
-
i.recalculatePositions(), c == null || c.reset(),
|
|
312
|
+
const b = Xt(() => {
|
|
313
|
+
i.recalculatePositions(), c == null || c.reset(), g();
|
|
314
314
|
}, 10);
|
|
315
|
-
window.addEventListener("resize",
|
|
316
|
-
const
|
|
317
|
-
|
|
318
|
-
const
|
|
319
|
-
|
|
315
|
+
window.addEventListener("resize", b);
|
|
316
|
+
const S = new ResizeObserver(b);
|
|
317
|
+
S.observe(t);
|
|
318
|
+
const A = { attributes: !0, childList: !0, subtree: !0 }, L = new MutationObserver((O) => {
|
|
319
|
+
O.every((f) => f.target === t || t.contains(f.target)) || g(!0);
|
|
320
320
|
});
|
|
321
|
-
return L.observe(document.body,
|
|
321
|
+
return L.observe(document.body, A), {
|
|
322
322
|
destroy: () => {
|
|
323
|
-
t.removeEventListener("pointermove", l), o.destroy(), i.unobserve(E), m(), document.removeEventListener("scroll", u),
|
|
323
|
+
t.removeEventListener("pointermove", l), o.destroy(), i.unobserve(E), m(), document.removeEventListener("scroll", u), b.clear(), window.removeEventListener("resize", b), S.disconnect(), L.disconnect();
|
|
324
324
|
},
|
|
325
|
-
redraw:
|
|
326
|
-
setStyle:
|
|
327
|
-
setFilter:
|
|
328
|
-
setPainter:
|
|
325
|
+
redraw: g,
|
|
326
|
+
setStyle: v,
|
|
327
|
+
setFilter: w,
|
|
328
|
+
setPainter: p,
|
|
329
329
|
setVisible: o.setVisible
|
|
330
330
|
};
|
|
331
331
|
}, Je = () => {
|
|
@@ -337,32 +337,32 @@ const Yt = /* @__PURE__ */ We(qe), Ge = (t) => {
|
|
|
337
337
|
t.classList.add("r6o-annotatable");
|
|
338
338
|
const e = Je(), n = e.getContext("2d");
|
|
339
339
|
document.body.appendChild(e);
|
|
340
|
-
const o = (a, d, c,
|
|
341
|
-
const { width: l, height:
|
|
342
|
-
n.clearRect(-0.5, -0.5, l + 1,
|
|
343
|
-
const { top:
|
|
340
|
+
const o = (a, d, c, h) => requestAnimationFrame(() => {
|
|
341
|
+
const { width: l, height: g } = e;
|
|
342
|
+
n.clearRect(-0.5, -0.5, l + 1, g + 1), h && h.clear();
|
|
343
|
+
const { top: p, left: v } = d;
|
|
344
344
|
[...a].sort((E, m) => {
|
|
345
|
-
const { annotation: { target: { created: u } } } = E, { annotation: { target: { created:
|
|
346
|
-
return u.getTime() -
|
|
345
|
+
const { annotation: { target: { created: u } } } = E, { annotation: { target: { created: b } } } = m;
|
|
346
|
+
return u.getTime() - b.getTime();
|
|
347
347
|
}).forEach((E) => {
|
|
348
|
-
var
|
|
349
|
-
const m = c ? typeof c == "function" ? c(E.annotation, E.state) : c : (
|
|
350
|
-
x:
|
|
351
|
-
y: L +
|
|
352
|
-
width:
|
|
353
|
-
height:
|
|
348
|
+
var S;
|
|
349
|
+
const m = c ? typeof c == "function" ? c(E.annotation, E.state) : c : (S = E.state) != null && S.selected ? vt : W, u = h && h.paint(E, d) || m, b = E.rects.map(({ x: A, y: L, width: T, height: O }) => ({
|
|
350
|
+
x: A + v,
|
|
351
|
+
y: L + p,
|
|
352
|
+
width: T,
|
|
353
|
+
height: O
|
|
354
354
|
}));
|
|
355
|
-
if (n.fillStyle = u.fill, n.globalAlpha = u.fillOpacity || 1,
|
|
356
|
-
({ x, y: L, width:
|
|
355
|
+
if (n.fillStyle = u.fill, n.globalAlpha = u.fillOpacity || 1, b.forEach(
|
|
356
|
+
({ x: A, y: L, width: T, height: O }) => n.fillRect(A, L, T, O)
|
|
357
357
|
), u.underlineColor) {
|
|
358
358
|
n.globalAlpha = 1, n.strokeStyle = u.underlineColor, n.lineWidth = u.underlineThickness ?? 1;
|
|
359
|
-
const
|
|
360
|
-
|
|
361
|
-
n.beginPath(), n.moveTo(L,
|
|
359
|
+
const A = u.underlineOffset ?? 0;
|
|
360
|
+
b.forEach(({ x: L, y: T, width: O, height: M }) => {
|
|
361
|
+
n.beginPath(), n.moveTo(L, T + M + A), n.lineTo(L + O, T + M + A), n.stroke();
|
|
362
362
|
});
|
|
363
363
|
}
|
|
364
364
|
});
|
|
365
|
-
}), i =
|
|
365
|
+
}), i = Xt(() => Ze(e), 10);
|
|
366
366
|
return window.addEventListener("resize", i), {
|
|
367
367
|
destroy: () => {
|
|
368
368
|
e.remove(), i.clear(), window.removeEventListener("resize", i);
|
|
@@ -372,18 +372,18 @@ const Yt = /* @__PURE__ */ We(qe), Ge = (t) => {
|
|
|
372
372
|
},
|
|
373
373
|
redraw: o
|
|
374
374
|
};
|
|
375
|
-
}, en = (t, e, n) =>
|
|
375
|
+
}, en = (t, e, n) => Pt(t, e, n, tn(t));
|
|
376
376
|
var nn = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, H = function(t) {
|
|
377
377
|
return typeof t == "string" ? t.length > 0 : typeof t == "number";
|
|
378
378
|
}, _ = function(t, e, n) {
|
|
379
379
|
return e === void 0 && (e = 0), n === void 0 && (n = Math.pow(10, e)), Math.round(n * t) / n + 0;
|
|
380
380
|
}, X = function(t, e, n) {
|
|
381
381
|
return e === void 0 && (e = 0), n === void 0 && (n = 1), t > n ? n : t > e ? t : e;
|
|
382
|
-
},
|
|
382
|
+
}, pe = function(t) {
|
|
383
383
|
return (t = isFinite(t) ? t % 360 : 0) > 0 ? t : t + 360;
|
|
384
|
-
},
|
|
384
|
+
}, Ht = function(t) {
|
|
385
385
|
return { r: X(t.r, 0, 255), g: X(t.g, 0, 255), b: X(t.b, 0, 255), a: X(t.a) };
|
|
386
|
-
},
|
|
386
|
+
}, St = function(t) {
|
|
387
387
|
return { r: _(t.r), g: _(t.g), b: _(t.b), a: _(t.a, 3) };
|
|
388
388
|
}, on = /^#([0-9a-f]{3,8})$/i, ft = function(t) {
|
|
389
389
|
var e = t.toString(16);
|
|
@@ -391,120 +391,120 @@ var nn = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, H = function(t) {
|
|
|
391
391
|
}, ge = function(t) {
|
|
392
392
|
var e = t.r, n = t.g, o = t.b, i = t.a, s = Math.max(e, n, o), r = s - Math.min(e, n, o), a = r ? s === e ? (n - o) / r : s === n ? 2 + (o - e) / r : 4 + (e - n) / r : 0;
|
|
393
393
|
return { h: 60 * (a < 0 ? a + 6 : a), s: s ? r / s * 100 : 0, v: s / 255 * 100, a: i };
|
|
394
|
-
},
|
|
394
|
+
}, me = function(t) {
|
|
395
395
|
var e = t.h, n = t.s, o = t.v, i = t.a;
|
|
396
396
|
e = e / 360 * 6, n /= 100, o /= 100;
|
|
397
397
|
var s = Math.floor(e), r = o * (1 - n), a = o * (1 - (e - s) * n), d = o * (1 - (1 - e + s) * n), c = s % 6;
|
|
398
398
|
return { r: 255 * [o, a, r, r, d, o][c], g: 255 * [d, o, o, a, r, r][c], b: 255 * [r, r, d, o, o, a][c], a: i };
|
|
399
|
-
}, Ht = function(t) {
|
|
400
|
-
return { h: he(t.h), s: X(t.s, 0, 100), l: X(t.l, 0, 100), a: X(t.a) };
|
|
401
399
|
}, zt = function(t) {
|
|
402
|
-
return { h:
|
|
400
|
+
return { h: pe(t.h), s: X(t.s, 0, 100), l: X(t.l, 0, 100), a: X(t.a) };
|
|
403
401
|
}, Ft = function(t) {
|
|
404
|
-
return
|
|
402
|
+
return { h: _(t.h), s: _(t.s), l: _(t.l), a: _(t.a, 3) };
|
|
403
|
+
}, Wt = function(t) {
|
|
404
|
+
return me((n = (e = t).s, { h: e.h, s: (n *= ((o = e.l) < 50 ? o : 100 - o) / 100) > 0 ? 2 * n / (o + n) * 100 : 0, v: o + n, a: e.a }));
|
|
405
405
|
var e, n, o;
|
|
406
406
|
}, st = function(t) {
|
|
407
407
|
return { h: (e = ge(t)).h, s: (i = (200 - (n = e.s)) * (o = e.v) / 100) > 0 && i < 200 ? n * o / 100 / (i <= 100 ? i : 200 - i) * 100 : 0, l: i / 2, a: e.a };
|
|
408
408
|
var e, n, o, i;
|
|
409
|
-
}, sn = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, rn = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, an = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, cn = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,
|
|
409
|
+
}, sn = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, rn = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, an = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, cn = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, qt = { string: [[function(t) {
|
|
410
410
|
var e = on.exec(t);
|
|
411
411
|
return e ? (t = e[1]).length <= 4 ? { r: parseInt(t[0] + t[0], 16), g: parseInt(t[1] + t[1], 16), b: parseInt(t[2] + t[2], 16), a: t.length === 4 ? _(parseInt(t[3] + t[3], 16) / 255, 2) : 1 } : t.length === 6 || t.length === 8 ? { r: parseInt(t.substr(0, 2), 16), g: parseInt(t.substr(2, 2), 16), b: parseInt(t.substr(4, 2), 16), a: t.length === 8 ? _(parseInt(t.substr(6, 2), 16) / 255, 2) : 1 } : null : null;
|
|
412
412
|
}, "hex"], [function(t) {
|
|
413
413
|
var e = an.exec(t) || cn.exec(t);
|
|
414
|
-
return e ? e[2] !== e[4] || e[4] !== e[6] ? null :
|
|
414
|
+
return e ? e[2] !== e[4] || e[4] !== e[6] ? null : Ht({ r: Number(e[1]) / (e[2] ? 100 / 255 : 1), g: Number(e[3]) / (e[4] ? 100 / 255 : 1), b: Number(e[5]) / (e[6] ? 100 / 255 : 1), a: e[7] === void 0 ? 1 : Number(e[7]) / (e[8] ? 100 : 1) }) : null;
|
|
415
415
|
}, "rgb"], [function(t) {
|
|
416
416
|
var e = sn.exec(t) || rn.exec(t);
|
|
417
417
|
if (!e) return null;
|
|
418
|
-
var n, o, i =
|
|
419
|
-
return
|
|
418
|
+
var n, o, i = zt({ h: (n = e[1], o = e[2], o === void 0 && (o = "deg"), Number(n) * (nn[o] || 1)), s: Number(e[3]), l: Number(e[4]), a: e[5] === void 0 ? 1 : Number(e[5]) / (e[6] ? 100 : 1) });
|
|
419
|
+
return Wt(i);
|
|
420
420
|
}, "hsl"]], object: [[function(t) {
|
|
421
421
|
var e = t.r, n = t.g, o = t.b, i = t.a, s = i === void 0 ? 1 : i;
|
|
422
|
-
return H(e) && H(n) && H(o) ?
|
|
422
|
+
return H(e) && H(n) && H(o) ? Ht({ r: Number(e), g: Number(n), b: Number(o), a: Number(s) }) : null;
|
|
423
423
|
}, "rgb"], [function(t) {
|
|
424
424
|
var e = t.h, n = t.s, o = t.l, i = t.a, s = i === void 0 ? 1 : i;
|
|
425
425
|
if (!H(e) || !H(n) || !H(o)) return null;
|
|
426
|
-
var r =
|
|
427
|
-
return
|
|
426
|
+
var r = zt({ h: Number(e), s: Number(n), l: Number(o), a: Number(s) });
|
|
427
|
+
return Wt(r);
|
|
428
428
|
}, "hsl"], [function(t) {
|
|
429
429
|
var e = t.h, n = t.s, o = t.v, i = t.a, s = i === void 0 ? 1 : i;
|
|
430
430
|
if (!H(e) || !H(n) || !H(o)) return null;
|
|
431
431
|
var r = function(a) {
|
|
432
|
-
return { h:
|
|
432
|
+
return { h: pe(a.h), s: X(a.s, 0, 100), v: X(a.v, 0, 100), a: X(a.a) };
|
|
433
433
|
}({ h: Number(e), s: Number(n), v: Number(o), a: Number(s) });
|
|
434
|
-
return
|
|
435
|
-
}, "hsv"]] },
|
|
434
|
+
return me(r);
|
|
435
|
+
}, "hsv"]] }, Gt = function(t, e) {
|
|
436
436
|
for (var n = 0; n < e.length; n++) {
|
|
437
437
|
var o = e[n][0](t);
|
|
438
438
|
if (o) return [o, e[n][1]];
|
|
439
439
|
}
|
|
440
440
|
return [null, void 0];
|
|
441
441
|
}, ln = function(t) {
|
|
442
|
-
return typeof t == "string" ?
|
|
443
|
-
},
|
|
442
|
+
return typeof t == "string" ? Gt(t.trim(), qt.string) : typeof t == "object" && t !== null ? Gt(t, qt.object) : [null, void 0];
|
|
443
|
+
}, Ct = function(t, e) {
|
|
444
444
|
var n = st(t);
|
|
445
445
|
return { h: n.h, s: X(n.s + 100 * e, 0, 100), l: n.l, a: n.a };
|
|
446
|
-
},
|
|
446
|
+
}, Lt = function(t) {
|
|
447
447
|
return (299 * t.r + 587 * t.g + 114 * t.b) / 1e3 / 255;
|
|
448
|
-
},
|
|
448
|
+
}, Qt = function(t, e) {
|
|
449
449
|
var n = st(t);
|
|
450
450
|
return { h: n.h, s: n.s, l: X(n.l + 100 * e, 0, 100), a: n.a };
|
|
451
|
-
},
|
|
451
|
+
}, Jt = function() {
|
|
452
452
|
function t(e) {
|
|
453
453
|
this.parsed = ln(e)[0], this.rgba = this.parsed || { r: 0, g: 0, b: 0, a: 1 };
|
|
454
454
|
}
|
|
455
455
|
return t.prototype.isValid = function() {
|
|
456
456
|
return this.parsed !== null;
|
|
457
457
|
}, t.prototype.brightness = function() {
|
|
458
|
-
return _(
|
|
458
|
+
return _(Lt(this.rgba), 2);
|
|
459
459
|
}, t.prototype.isDark = function() {
|
|
460
|
-
return
|
|
460
|
+
return Lt(this.rgba) < 0.5;
|
|
461
461
|
}, t.prototype.isLight = function() {
|
|
462
|
-
return
|
|
462
|
+
return Lt(this.rgba) >= 0.5;
|
|
463
463
|
}, t.prototype.toHex = function() {
|
|
464
|
-
return e =
|
|
464
|
+
return e = St(this.rgba), n = e.r, o = e.g, i = e.b, r = (s = e.a) < 1 ? ft(_(255 * s)) : "", "#" + ft(n) + ft(o) + ft(i) + r;
|
|
465
465
|
var e, n, o, i, s, r;
|
|
466
466
|
}, t.prototype.toRgb = function() {
|
|
467
|
-
return
|
|
467
|
+
return St(this.rgba);
|
|
468
468
|
}, t.prototype.toRgbString = function() {
|
|
469
|
-
return e =
|
|
469
|
+
return e = St(this.rgba), n = e.r, o = e.g, i = e.b, (s = e.a) < 1 ? "rgba(" + n + ", " + o + ", " + i + ", " + s + ")" : "rgb(" + n + ", " + o + ", " + i + ")";
|
|
470
470
|
var e, n, o, i, s;
|
|
471
471
|
}, t.prototype.toHsl = function() {
|
|
472
|
-
return
|
|
472
|
+
return Ft(st(this.rgba));
|
|
473
473
|
}, t.prototype.toHslString = function() {
|
|
474
|
-
return e =
|
|
474
|
+
return e = Ft(st(this.rgba)), n = e.h, o = e.s, i = e.l, (s = e.a) < 1 ? "hsla(" + n + ", " + o + "%, " + i + "%, " + s + ")" : "hsl(" + n + ", " + o + "%, " + i + "%)";
|
|
475
475
|
var e, n, o, i, s;
|
|
476
476
|
}, t.prototype.toHsv = function() {
|
|
477
477
|
return e = ge(this.rgba), { h: _(e.h), s: _(e.s), v: _(e.v), a: _(e.a, 3) };
|
|
478
478
|
var e;
|
|
479
479
|
}, t.prototype.invert = function() {
|
|
480
|
-
return
|
|
480
|
+
return $({ r: 255 - (e = this.rgba).r, g: 255 - e.g, b: 255 - e.b, a: e.a });
|
|
481
481
|
var e;
|
|
482
482
|
}, t.prototype.saturate = function(e) {
|
|
483
|
-
return e === void 0 && (e = 0.1),
|
|
483
|
+
return e === void 0 && (e = 0.1), $(Ct(this.rgba, e));
|
|
484
484
|
}, t.prototype.desaturate = function(e) {
|
|
485
|
-
return e === void 0 && (e = 0.1),
|
|
485
|
+
return e === void 0 && (e = 0.1), $(Ct(this.rgba, -e));
|
|
486
486
|
}, t.prototype.grayscale = function() {
|
|
487
|
-
return
|
|
487
|
+
return $(Ct(this.rgba, -1));
|
|
488
488
|
}, t.prototype.lighten = function(e) {
|
|
489
|
-
return e === void 0 && (e = 0.1),
|
|
489
|
+
return e === void 0 && (e = 0.1), $(Qt(this.rgba, e));
|
|
490
490
|
}, t.prototype.darken = function(e) {
|
|
491
|
-
return e === void 0 && (e = 0.1),
|
|
491
|
+
return e === void 0 && (e = 0.1), $(Qt(this.rgba, -e));
|
|
492
492
|
}, t.prototype.rotate = function(e) {
|
|
493
493
|
return e === void 0 && (e = 15), this.hue(this.hue() + e);
|
|
494
494
|
}, t.prototype.alpha = function(e) {
|
|
495
|
-
return typeof e == "number" ?
|
|
495
|
+
return typeof e == "number" ? $({ r: (n = this.rgba).r, g: n.g, b: n.b, a: e }) : _(this.rgba.a, 3);
|
|
496
496
|
var n;
|
|
497
497
|
}, t.prototype.hue = function(e) {
|
|
498
498
|
var n = st(this.rgba);
|
|
499
|
-
return typeof e == "number" ?
|
|
499
|
+
return typeof e == "number" ? $({ h: e, s: n.s, l: n.l, a: n.a }) : _(n.h);
|
|
500
500
|
}, t.prototype.isEqual = function(e) {
|
|
501
|
-
return this.toHex() ===
|
|
501
|
+
return this.toHex() === $(e).toHex();
|
|
502
502
|
}, t;
|
|
503
|
-
}(),
|
|
504
|
-
return t instanceof
|
|
503
|
+
}(), $ = function(t) {
|
|
504
|
+
return t instanceof Jt ? t : new Jt(t);
|
|
505
505
|
};
|
|
506
506
|
const dn = (t) => [
|
|
507
|
-
`background-color:${
|
|
507
|
+
`background-color:${$((t == null ? void 0 : t.fill) || W.fill).alpha((t == null ? void 0 : t.fillOpacity) === void 0 ? W.fillOpacity : t.fillOpacity).toHex()}`,
|
|
508
508
|
t != null && t.underlineThickness ? "text-decoration:underline" : void 0,
|
|
509
509
|
t != null && t.underlineColor ? `text-decoration-color:${t.underlineColor}` : void 0,
|
|
510
510
|
t != null && t.underlineOffset ? `text-underline-offset:${t.underlineOffset}px` : void 0,
|
|
@@ -524,21 +524,21 @@ const dn = (t) => [
|
|
|
524
524
|
d && d.clear();
|
|
525
525
|
const c = new Set(s.map((l) => l.annotation.id));
|
|
526
526
|
Array.from(e).filter((l) => !c.has(l));
|
|
527
|
-
const
|
|
528
|
-
var
|
|
529
|
-
const
|
|
530
|
-
return `::highlight(_${l.annotation.id}) { ${dn(
|
|
527
|
+
const h = s.map((l) => {
|
|
528
|
+
var v;
|
|
529
|
+
const g = a ? typeof a == "function" ? a(l.annotation, l.state) : a : (v = l.state) != null && v.selected ? vt : W, p = d && d.paint(l, r) || g;
|
|
530
|
+
return `::highlight(_${l.annotation.id}) { ${dn(p)} }`;
|
|
531
531
|
});
|
|
532
|
-
t.innerHTML =
|
|
532
|
+
t.innerHTML = h.join(`
|
|
533
533
|
`), CSS.highlights.clear(), s.forEach(({ annotation: l }) => {
|
|
534
|
-
const
|
|
535
|
-
CSS.highlights.set(`_${l.id}`,
|
|
534
|
+
const g = l.target.selector.map((v) => v.range), p = new Highlight(...g);
|
|
535
|
+
CSS.highlights.set(`_${l.id}`, p);
|
|
536
536
|
}), e = c;
|
|
537
537
|
}
|
|
538
538
|
};
|
|
539
|
-
}, fn = (t, e, n) =>
|
|
540
|
-
var
|
|
541
|
-
function
|
|
539
|
+
}, fn = (t, e, n) => Pt(t, e, n, un());
|
|
540
|
+
var Zt = Object.prototype.hasOwnProperty;
|
|
541
|
+
function Vt(t, e) {
|
|
542
542
|
var n, o;
|
|
543
543
|
if (t === e) return !0;
|
|
544
544
|
if (t && e && (n = t.constructor) === e.constructor) {
|
|
@@ -546,13 +546,13 @@ function Dt(t, e) {
|
|
|
546
546
|
if (n === RegExp) return t.toString() === e.toString();
|
|
547
547
|
if (n === Array) {
|
|
548
548
|
if ((o = t.length) === e.length)
|
|
549
|
-
for (; o-- &&
|
|
549
|
+
for (; o-- && Vt(t[o], e[o]); ) ;
|
|
550
550
|
return o === -1;
|
|
551
551
|
}
|
|
552
552
|
if (!n || typeof t == "object") {
|
|
553
553
|
o = 0;
|
|
554
554
|
for (n in t)
|
|
555
|
-
if (
|
|
555
|
+
if (Zt.call(t, n) && ++o && !Zt.call(e, n) || !(n in e) || !Vt(t[n], e[n])) return !1;
|
|
556
556
|
return Object.keys(e).length === o;
|
|
557
557
|
}
|
|
558
558
|
}
|
|
@@ -561,7 +561,7 @@ function Dt(t, e) {
|
|
|
561
561
|
const hn = (t, e) => {
|
|
562
562
|
const n = (s, r) => s.x <= r.x + r.width && s.x + s.width >= r.x && s.y <= r.y + r.height && s.y + s.height >= r.y, o = (s) => s.rects.reduce((r, a) => r + a.width, 0), i = e.filter(({ rects: s }) => s.some((r) => n(t, r)));
|
|
563
563
|
return i.sort((s, r) => o(r) - o(s)), i.findIndex((s) => s.rects.includes(t));
|
|
564
|
-
},
|
|
564
|
+
}, pn = (t) => {
|
|
565
565
|
t.classList.add("r6o-annotatable");
|
|
566
566
|
const e = document.createElement("div");
|
|
567
567
|
e.className = "r6o-span-highlight-layer", t.insertBefore(e, t.firstChild);
|
|
@@ -570,18 +570,18 @@ const hn = (t, e) => {
|
|
|
570
570
|
destroy: () => {
|
|
571
571
|
e.remove();
|
|
572
572
|
},
|
|
573
|
-
redraw: (r, a, d, c,
|
|
574
|
-
const
|
|
575
|
-
if (!c && !
|
|
576
|
-
|
|
577
|
-
const { annotation: { target: { created: E } } } =
|
|
573
|
+
redraw: (r, a, d, c, h) => {
|
|
574
|
+
const g = !(Vt(n, r) && h);
|
|
575
|
+
if (!c && !g) return;
|
|
576
|
+
g && (e.innerHTML = ""), [...r].sort((v, w) => {
|
|
577
|
+
const { annotation: { target: { created: E } } } = v, { annotation: { target: { created: m } } } = w;
|
|
578
578
|
return E && m ? E.getTime() - m.getTime() : 0;
|
|
579
|
-
}).forEach((
|
|
580
|
-
|
|
581
|
-
const E = hn(
|
|
582
|
-
if (
|
|
579
|
+
}).forEach((v) => {
|
|
580
|
+
v.rects.map((w) => {
|
|
581
|
+
const E = hn(w, r), m = Fe(v, a, d, c, E);
|
|
582
|
+
if (g) {
|
|
583
583
|
const u = document.createElement("span");
|
|
584
|
-
u.className = "r6o-annotation", u.dataset.annotation =
|
|
584
|
+
u.className = "r6o-annotation", u.dataset.annotation = v.annotation.id, u.style.left = `${w.x}px`, u.style.top = `${w.y}px`, u.style.width = `${w.width}px`, u.style.height = `${w.height}px`, u.style.backgroundColor = $((m == null ? void 0 : m.fill) || W.fill).alpha((m == null ? void 0 : m.fillOpacity) === void 0 ? W.fillOpacity : m.fillOpacity).toHex(), m.underlineStyle && (u.style.borderStyle = m.underlineStyle), m.underlineColor && (u.style.borderColor = m.underlineColor), m.underlineThickness && (u.style.borderBottomWidth = `${m.underlineThickness}px`), m.underlineOffset && (u.style.paddingBottom = `${m.underlineOffset}px`), e.appendChild(u);
|
|
585
585
|
}
|
|
586
586
|
});
|
|
587
587
|
}), n = r;
|
|
@@ -590,10 +590,10 @@ const hn = (t, e) => {
|
|
|
590
590
|
r ? e.classList.remove("hidden") : e.classList.add("hidden");
|
|
591
591
|
}
|
|
592
592
|
};
|
|
593
|
-
},
|
|
593
|
+
}, gn = (t, e, n) => Pt(t, e, n, pn(t));
|
|
594
594
|
var U = [];
|
|
595
|
-
for (var
|
|
596
|
-
U.push((
|
|
595
|
+
for (var Ot = 0; Ot < 256; ++Ot)
|
|
596
|
+
U.push((Ot + 256).toString(16).slice(1));
|
|
597
597
|
function mn(t, e = 0) {
|
|
598
598
|
return (U[t[e + 0]] + U[t[e + 1]] + U[t[e + 2]] + U[t[e + 3]] + "-" + U[t[e + 4]] + U[t[e + 5]] + "-" + U[t[e + 6]] + U[t[e + 7]] + "-" + U[t[e + 8]] + U[t[e + 9]] + "-" + U[t[e + 10]] + U[t[e + 11]] + U[t[e + 12]] + U[t[e + 13]] + U[t[e + 14]] + U[t[e + 15]]).toLowerCase();
|
|
599
599
|
}
|
|
@@ -604,17 +604,17 @@ function bn() {
|
|
|
604
604
|
return ht(yn);
|
|
605
605
|
}
|
|
606
606
|
var wn = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
|
|
607
|
-
const
|
|
607
|
+
const te = {
|
|
608
608
|
randomUUID: wn
|
|
609
609
|
};
|
|
610
|
-
function
|
|
611
|
-
if (
|
|
612
|
-
return
|
|
610
|
+
function ye(t, e, n) {
|
|
611
|
+
if (te.randomUUID && !e && !t)
|
|
612
|
+
return te.randomUUID();
|
|
613
613
|
t = t || {};
|
|
614
614
|
var o = t.random || (t.rng || bn)();
|
|
615
615
|
return o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128, mn(o);
|
|
616
616
|
}
|
|
617
|
-
var
|
|
617
|
+
var ee = Object.prototype.hasOwnProperty;
|
|
618
618
|
function q(t, e) {
|
|
619
619
|
var n, o;
|
|
620
620
|
if (t === e) return !0;
|
|
@@ -629,19 +629,19 @@ function q(t, e) {
|
|
|
629
629
|
if (!n || typeof t == "object") {
|
|
630
630
|
o = 0;
|
|
631
631
|
for (n in t)
|
|
632
|
-
if (
|
|
632
|
+
if (ee.call(t, n) && ++o && !ee.call(e, n) || !(n in e) || !q(t[n], e[n])) return !1;
|
|
633
633
|
return Object.keys(e).length === o;
|
|
634
634
|
}
|
|
635
635
|
}
|
|
636
636
|
return t !== t && e !== e;
|
|
637
637
|
}
|
|
638
|
-
function
|
|
638
|
+
function Tt() {
|
|
639
639
|
}
|
|
640
640
|
function vn(t, e) {
|
|
641
641
|
return t != t ? e == e : t !== e || t && typeof t == "object" || typeof t == "function";
|
|
642
642
|
}
|
|
643
643
|
const G = [];
|
|
644
|
-
function $t(t, e =
|
|
644
|
+
function $t(t, e = Tt) {
|
|
645
645
|
let n;
|
|
646
646
|
const o = /* @__PURE__ */ new Set();
|
|
647
647
|
function i(a) {
|
|
@@ -659,9 +659,9 @@ function $t(t, e = Ot) {
|
|
|
659
659
|
function s(a) {
|
|
660
660
|
i(a(t));
|
|
661
661
|
}
|
|
662
|
-
function r(a, d =
|
|
662
|
+
function r(a, d = Tt) {
|
|
663
663
|
const c = [a, d];
|
|
664
|
-
return o.add(c), o.size === 1 && (n = e(i, s) ||
|
|
664
|
+
return o.add(c), o.size === 1 && (n = e(i, s) || Tt), a(t), () => {
|
|
665
665
|
o.delete(c), o.size === 0 && n && (n(), n = null);
|
|
666
666
|
};
|
|
667
667
|
}
|
|
@@ -685,52 +685,52 @@ const An = (t) => {
|
|
|
685
685
|
};
|
|
686
686
|
};
|
|
687
687
|
var xn = /* @__PURE__ */ ((t) => (t.EDIT = "EDIT", t.SELECT = "SELECT", t.NONE = "NONE", t))(xn || {});
|
|
688
|
-
const
|
|
689
|
-
const { subscribe: o, set: i } = $t(
|
|
690
|
-
let s = e, r =
|
|
691
|
-
o((
|
|
688
|
+
const pt = { selected: [] }, En = (t, e, n) => {
|
|
689
|
+
const { subscribe: o, set: i } = $t(pt);
|
|
690
|
+
let s = e, r = pt;
|
|
691
|
+
o((v) => r = v);
|
|
692
692
|
const a = () => {
|
|
693
|
-
q(r,
|
|
693
|
+
q(r, pt) || i(pt);
|
|
694
694
|
}, d = () => {
|
|
695
|
-
var
|
|
696
|
-
return ((
|
|
697
|
-
}, c = (
|
|
695
|
+
var v;
|
|
696
|
+
return ((v = r.selected) == null ? void 0 : v.length) === 0;
|
|
697
|
+
}, c = (v) => {
|
|
698
698
|
if (d())
|
|
699
699
|
return !1;
|
|
700
|
-
const
|
|
701
|
-
return r.selected.some((E) => E.id ===
|
|
702
|
-
},
|
|
703
|
-
const E = t.getAnnotation(
|
|
700
|
+
const w = typeof v == "string" ? v : v.id;
|
|
701
|
+
return r.selected.some((E) => E.id === w);
|
|
702
|
+
}, h = (v, w) => {
|
|
703
|
+
const E = t.getAnnotation(v);
|
|
704
704
|
if (!E) {
|
|
705
|
-
console.warn("Invalid selection: " +
|
|
705
|
+
console.warn("Invalid selection: " + v);
|
|
706
706
|
return;
|
|
707
707
|
}
|
|
708
|
-
switch (
|
|
708
|
+
switch (ne(E, s)) {
|
|
709
709
|
case "EDIT":
|
|
710
|
-
i({ selected: [{ id:
|
|
710
|
+
i({ selected: [{ id: v, editable: !0 }], event: w });
|
|
711
711
|
break;
|
|
712
712
|
case "SELECT":
|
|
713
|
-
i({ selected: [{ id:
|
|
713
|
+
i({ selected: [{ id: v }], event: w });
|
|
714
714
|
break;
|
|
715
715
|
default:
|
|
716
|
-
i({ selected: [], event:
|
|
716
|
+
i({ selected: [], event: w });
|
|
717
717
|
}
|
|
718
|
-
}, l = (
|
|
719
|
-
const E = Array.isArray(
|
|
718
|
+
}, l = (v, w) => {
|
|
719
|
+
const E = Array.isArray(v) ? v : [v], m = E.map((u) => t.getAnnotation(u)).filter((u) => !!u);
|
|
720
720
|
i({
|
|
721
721
|
selected: m.map((u) => {
|
|
722
|
-
const
|
|
723
|
-
return { id: u.id, editable:
|
|
722
|
+
const b = w === void 0 ? ne(u, s) === "EDIT" : w;
|
|
723
|
+
return { id: u.id, editable: b };
|
|
724
724
|
})
|
|
725
|
-
}), m.length !== E.length && console.warn("Invalid selection",
|
|
726
|
-
},
|
|
725
|
+
}), m.length !== E.length && console.warn("Invalid selection", v);
|
|
726
|
+
}, g = (v) => {
|
|
727
727
|
if (d())
|
|
728
728
|
return !1;
|
|
729
|
-
const { selected:
|
|
730
|
-
|
|
731
|
-
},
|
|
729
|
+
const { selected: w } = r;
|
|
730
|
+
w.some(({ id: E }) => v.includes(E)) && i({ selected: w.filter(({ id: E }) => !v.includes(E)) });
|
|
731
|
+
}, p = (v) => s = v;
|
|
732
732
|
return t.observe(
|
|
733
|
-
({ changes:
|
|
733
|
+
({ changes: v }) => g((v.deleted || []).map((w) => w.id))
|
|
734
734
|
), {
|
|
735
735
|
get event() {
|
|
736
736
|
return r ? r.event : null;
|
|
@@ -745,35 +745,35 @@ const gt = { selected: [] }, En = (t, e, n) => {
|
|
|
745
745
|
isEmpty: d,
|
|
746
746
|
isSelected: c,
|
|
747
747
|
setSelected: l,
|
|
748
|
-
setUserSelectAction:
|
|
748
|
+
setUserSelectAction: p,
|
|
749
749
|
subscribe: o,
|
|
750
|
-
userSelect:
|
|
750
|
+
userSelect: h
|
|
751
751
|
};
|
|
752
|
-
},
|
|
752
|
+
}, ne = (t, e, n) => typeof e == "function" ? e(t) : e || "EDIT";
|
|
753
753
|
var D = [];
|
|
754
|
-
for (var
|
|
755
|
-
D.push((
|
|
754
|
+
for (var Rt = 0; Rt < 256; ++Rt)
|
|
755
|
+
D.push((Rt + 256).toString(16).slice(1));
|
|
756
756
|
function Sn(t, e = 0) {
|
|
757
757
|
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();
|
|
758
758
|
}
|
|
759
|
-
var
|
|
759
|
+
var gt, Cn = new Uint8Array(16);
|
|
760
760
|
function Ln() {
|
|
761
|
-
if (!
|
|
761
|
+
if (!gt && (gt = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !gt))
|
|
762
762
|
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
763
|
-
return
|
|
763
|
+
return gt(Cn);
|
|
764
764
|
}
|
|
765
765
|
var On = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
|
|
766
|
-
const
|
|
766
|
+
const oe = {
|
|
767
767
|
randomUUID: On
|
|
768
768
|
};
|
|
769
|
-
function
|
|
770
|
-
if (
|
|
771
|
-
return
|
|
769
|
+
function be(t, e, n) {
|
|
770
|
+
if (oe.randomUUID && !e && !t)
|
|
771
|
+
return oe.randomUUID();
|
|
772
772
|
t = t || {};
|
|
773
773
|
var o = t.random || (t.rng || Ln)();
|
|
774
774
|
return o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128, Sn(o);
|
|
775
775
|
}
|
|
776
|
-
const
|
|
776
|
+
const Mt = (t) => {
|
|
777
777
|
const e = (n) => {
|
|
778
778
|
const o = { ...n };
|
|
779
779
|
return n.created && typeof n.created == "string" && (o.created = new Date(n.created)), n.updated && typeof n.updated == "string" && (o.updated = new Date(n.updated)), o;
|
|
@@ -783,8 +783,8 @@ const Rt = (t) => {
|
|
|
783
783
|
bodies: (t.bodies || []).map(e),
|
|
784
784
|
target: e(t.target)
|
|
785
785
|
};
|
|
786
|
-
},
|
|
787
|
-
id:
|
|
786
|
+
}, ko = (t, e, n, o) => ({
|
|
787
|
+
id: be(),
|
|
788
788
|
annotation: typeof t == "string" ? t : t.id,
|
|
789
789
|
created: n || /* @__PURE__ */ new Date(),
|
|
790
790
|
creator: o,
|
|
@@ -798,7 +798,7 @@ const Rt = (t) => {
|
|
|
798
798
|
}, Mn = (t, e) => e.bodies.map((n) => {
|
|
799
799
|
const o = t.bodies.find((i) => i.id === n.id);
|
|
800
800
|
return { newBody: n, oldBody: o && !q(o, n) ? o : void 0 };
|
|
801
|
-
}).filter(({ oldBody: n }) => n).map(({ oldBody: n, newBody: o }) => ({ oldBody: n, newBody: o })), Bn = (t, e) => !q(t.target, e.target),
|
|
801
|
+
}).filter(({ oldBody: n }) => n).map(({ oldBody: n, newBody: o }) => ({ oldBody: n, newBody: o })), Bn = (t, e) => !q(t.target, e.target), we = (t, e) => {
|
|
802
802
|
const n = Tn(t, e), o = Rn(t, e), i = Mn(t, e);
|
|
803
803
|
return {
|
|
804
804
|
oldValue: t,
|
|
@@ -818,7 +818,7 @@ const kn = (t, e) => {
|
|
|
818
818
|
if (t.options.ignore) {
|
|
819
819
|
const { ignore: r } = t.options, a = (d) => d && d.length > 0;
|
|
820
820
|
if (!(a(i.created) || a(i.deleted))) {
|
|
821
|
-
const d = (n = i.updated) == null ? void 0 : n.some((
|
|
821
|
+
const d = (n = i.updated) == null ? void 0 : n.some((h) => a(h.bodiesCreated) || a(h.bodiesDeleted) || a(h.bodiesUpdated)), c = (o = i.updated) == null ? void 0 : o.some((h) => h.targetUpdated);
|
|
822
822
|
if (r === "BODY_ONLY" && d && !c || r === "TARGET_ONLY" && c && !d)
|
|
823
823
|
return !1;
|
|
824
824
|
}
|
|
@@ -834,25 +834,25 @@ const kn = (t, e) => {
|
|
|
834
834
|
return !0;
|
|
835
835
|
}, In = (t, e) => {
|
|
836
836
|
const n = new Set((t.created || []).map((l) => l.id)), o = new Set((t.updated || []).map(({ newValue: l }) => l.id)), i = new Set((e.created || []).map((l) => l.id)), s = new Set((e.deleted || []).map((l) => l.id)), r = new Set((e.updated || []).map(({ oldValue: l }) => l.id)), a = new Set((e.updated || []).filter(({ oldValue: l }) => n.has(l.id) || o.has(l.id)).map(({ oldValue: l }) => l.id)), d = [
|
|
837
|
-
...(t.created || []).filter((l) => !s.has(l.id)).map((l) => r.has(l.id) ? e.updated.find(({ oldValue:
|
|
837
|
+
...(t.created || []).filter((l) => !s.has(l.id)).map((l) => r.has(l.id) ? e.updated.find(({ oldValue: g }) => g.id === l.id).newValue : l),
|
|
838
838
|
...e.created || []
|
|
839
839
|
], c = [
|
|
840
840
|
...(t.deleted || []).filter((l) => !i.has(l.id)),
|
|
841
841
|
...(e.deleted || []).filter((l) => !n.has(l.id))
|
|
842
|
-
],
|
|
842
|
+
], h = [
|
|
843
843
|
...(t.updated || []).filter(({ newValue: l }) => !s.has(l.id)).map((l) => {
|
|
844
|
-
const { oldValue:
|
|
845
|
-
if (r.has(
|
|
846
|
-
const
|
|
847
|
-
return
|
|
844
|
+
const { oldValue: g, newValue: p } = l;
|
|
845
|
+
if (r.has(p.id)) {
|
|
846
|
+
const v = e.updated.find((w) => w.oldValue.id === p.id).newValue;
|
|
847
|
+
return we(g, v);
|
|
848
848
|
} else
|
|
849
849
|
return l;
|
|
850
850
|
}),
|
|
851
851
|
...(e.updated || []).filter(({ oldValue: l }) => !a.has(l.id))
|
|
852
852
|
];
|
|
853
|
-
return { created: d, deleted: c, updated:
|
|
854
|
-
},
|
|
855
|
-
const e = t.id === void 0 ?
|
|
853
|
+
return { created: d, deleted: c, updated: h };
|
|
854
|
+
}, Bt = (t) => {
|
|
855
|
+
const e = t.id === void 0 ? be() : t.id;
|
|
856
856
|
return {
|
|
857
857
|
...t,
|
|
858
858
|
id: e,
|
|
@@ -866,201 +866,201 @@ const kn = (t, e) => {
|
|
|
866
866
|
}
|
|
867
867
|
};
|
|
868
868
|
}, Nn = (t) => t.id !== void 0, _n = () => {
|
|
869
|
-
const t = /* @__PURE__ */ new Map(), e = /* @__PURE__ */ new Map(), n = [], o = (
|
|
870
|
-
n.push({ onChange:
|
|
871
|
-
}, i = (
|
|
872
|
-
const
|
|
873
|
-
|
|
874
|
-
}, s = (
|
|
875
|
-
const
|
|
876
|
-
origin:
|
|
869
|
+
const t = /* @__PURE__ */ new Map(), e = /* @__PURE__ */ new Map(), n = [], o = (f, y = {}) => {
|
|
870
|
+
n.push({ onChange: f, options: y });
|
|
871
|
+
}, i = (f) => {
|
|
872
|
+
const y = n.findIndex((x) => x.onChange == f);
|
|
873
|
+
y > -1 && n.splice(y, 1);
|
|
874
|
+
}, s = (f, y) => {
|
|
875
|
+
const x = {
|
|
876
|
+
origin: f,
|
|
877
877
|
changes: {
|
|
878
|
-
created:
|
|
879
|
-
updated:
|
|
880
|
-
deleted:
|
|
878
|
+
created: y.created || [],
|
|
879
|
+
updated: y.updated || [],
|
|
880
|
+
deleted: y.deleted || []
|
|
881
881
|
},
|
|
882
882
|
state: [...t.values()]
|
|
883
883
|
};
|
|
884
|
-
n.forEach((
|
|
885
|
-
kn(
|
|
884
|
+
n.forEach((C) => {
|
|
885
|
+
kn(C, x) && C.onChange(x);
|
|
886
886
|
});
|
|
887
|
-
}, r = (
|
|
888
|
-
if (
|
|
889
|
-
throw Error(`Cannot add annotation ${
|
|
887
|
+
}, r = (f, y = k.LOCAL) => {
|
|
888
|
+
if (f.id && t.get(f.id))
|
|
889
|
+
throw Error(`Cannot add annotation ${f.id} - exists already`);
|
|
890
890
|
{
|
|
891
|
-
const
|
|
892
|
-
t.set(
|
|
891
|
+
const x = Bt(f);
|
|
892
|
+
t.set(x.id, x), x.bodies.forEach((C) => e.set(C.id, x.id)), s(y, { created: [x] });
|
|
893
893
|
}
|
|
894
|
-
}, a = (
|
|
895
|
-
const
|
|
894
|
+
}, a = (f, y) => {
|
|
895
|
+
const x = Bt(typeof f == "string" ? y : f), C = typeof f == "string" ? f : f.id, B = C && t.get(C);
|
|
896
896
|
if (B) {
|
|
897
|
-
const
|
|
898
|
-
return
|
|
897
|
+
const R = we(B, x);
|
|
898
|
+
return C === x.id ? t.set(C, x) : (t.delete(C), t.set(x.id, x)), B.bodies.forEach((K) => e.delete(K.id)), x.bodies.forEach((K) => e.set(K.id, x.id)), R;
|
|
899
899
|
} else
|
|
900
|
-
console.warn(`Cannot update annotation ${
|
|
901
|
-
}, d = (
|
|
902
|
-
const
|
|
903
|
-
B && s(
|
|
904
|
-
}, c = (
|
|
905
|
-
const
|
|
906
|
-
const
|
|
907
|
-
return
|
|
900
|
+
console.warn(`Cannot update annotation ${C} - does not exist`);
|
|
901
|
+
}, d = (f, y = k.LOCAL, x = k.LOCAL) => {
|
|
902
|
+
const C = Nn(y) ? x : y, B = a(f, y);
|
|
903
|
+
B && s(C, { updated: [B] });
|
|
904
|
+
}, c = (f, y = k.LOCAL) => {
|
|
905
|
+
const x = f.reduce((C, B) => {
|
|
906
|
+
const R = a(B);
|
|
907
|
+
return R ? [...C, R] : C;
|
|
908
908
|
}, []);
|
|
909
|
-
|
|
910
|
-
},
|
|
911
|
-
const
|
|
912
|
-
if (
|
|
913
|
-
const
|
|
914
|
-
...
|
|
915
|
-
bodies: [...
|
|
909
|
+
x.length > 0 && s(y, { updated: x });
|
|
910
|
+
}, h = (f, y = k.LOCAL) => {
|
|
911
|
+
const x = t.get(f.annotation);
|
|
912
|
+
if (x) {
|
|
913
|
+
const C = {
|
|
914
|
+
...x,
|
|
915
|
+
bodies: [...x.bodies, f]
|
|
916
916
|
};
|
|
917
|
-
t.set(
|
|
918
|
-
oldValue:
|
|
919
|
-
newValue:
|
|
920
|
-
bodiesCreated: [
|
|
917
|
+
t.set(x.id, C), e.set(f.id, C.id), s(y, { updated: [{
|
|
918
|
+
oldValue: x,
|
|
919
|
+
newValue: C,
|
|
920
|
+
bodiesCreated: [f]
|
|
921
921
|
}] });
|
|
922
922
|
} else
|
|
923
|
-
console.warn(`Attempt to add body to missing annotation: ${
|
|
924
|
-
}, l = () => [...t.values()],
|
|
925
|
-
const
|
|
926
|
-
t.clear(), e.clear(), s(
|
|
927
|
-
},
|
|
928
|
-
const
|
|
929
|
-
if (
|
|
923
|
+
console.warn(`Attempt to add body to missing annotation: ${f.annotation}`);
|
|
924
|
+
}, l = () => [...t.values()], g = (f = k.LOCAL) => {
|
|
925
|
+
const y = [...t.values()];
|
|
926
|
+
t.clear(), e.clear(), s(f, { deleted: y });
|
|
927
|
+
}, p = (f, y = !0, x = k.LOCAL) => {
|
|
928
|
+
const C = f.map(Bt);
|
|
929
|
+
if (y) {
|
|
930
930
|
const B = [...t.values()];
|
|
931
|
-
t.clear(), e.clear(),
|
|
932
|
-
t.set(
|
|
933
|
-
}), s(
|
|
931
|
+
t.clear(), e.clear(), C.forEach((R) => {
|
|
932
|
+
t.set(R.id, R), R.bodies.forEach((K) => e.set(K.id, R.id));
|
|
933
|
+
}), s(x, { created: C, deleted: B });
|
|
934
934
|
} else {
|
|
935
|
-
const B =
|
|
935
|
+
const B = f.reduce((R, K) => {
|
|
936
936
|
const Y = K.id && t.get(K.id);
|
|
937
|
-
return Y ? [...
|
|
937
|
+
return Y ? [...R, Y] : R;
|
|
938
938
|
}, []);
|
|
939
939
|
if (B.length > 0)
|
|
940
|
-
throw Error(`Bulk insert would overwrite the following annotations: ${B.map((
|
|
941
|
-
|
|
942
|
-
t.set(
|
|
943
|
-
}), s(
|
|
940
|
+
throw Error(`Bulk insert would overwrite the following annotations: ${B.map((R) => R.id).join(", ")}`);
|
|
941
|
+
C.forEach((R) => {
|
|
942
|
+
t.set(R.id, R), R.bodies.forEach((K) => e.set(K.id, R.id));
|
|
943
|
+
}), s(x, { created: C });
|
|
944
944
|
}
|
|
945
|
-
},
|
|
946
|
-
const
|
|
947
|
-
if (
|
|
948
|
-
return t.delete(
|
|
949
|
-
console.warn(`Attempt to delete missing annotation: ${
|
|
950
|
-
},
|
|
951
|
-
const
|
|
952
|
-
|
|
953
|
-
}, E = (
|
|
954
|
-
const
|
|
955
|
-
const
|
|
956
|
-
return
|
|
945
|
+
}, v = (f) => {
|
|
946
|
+
const y = typeof f == "string" ? f : f.id, x = t.get(y);
|
|
947
|
+
if (x)
|
|
948
|
+
return t.delete(y), x.bodies.forEach((C) => e.delete(C.id)), x;
|
|
949
|
+
console.warn(`Attempt to delete missing annotation: ${y}`);
|
|
950
|
+
}, w = (f, y = k.LOCAL) => {
|
|
951
|
+
const x = v(f);
|
|
952
|
+
x && s(y, { deleted: [x] });
|
|
953
|
+
}, E = (f, y = k.LOCAL) => {
|
|
954
|
+
const x = f.reduce((C, B) => {
|
|
955
|
+
const R = v(B);
|
|
956
|
+
return R ? [...C, R] : C;
|
|
957
957
|
}, []);
|
|
958
|
-
|
|
959
|
-
}, m = (
|
|
960
|
-
const
|
|
961
|
-
if (
|
|
962
|
-
const
|
|
963
|
-
if (
|
|
964
|
-
e.delete(
|
|
965
|
-
const
|
|
966
|
-
...
|
|
967
|
-
bodies:
|
|
958
|
+
x.length > 0 && s(y, { deleted: x });
|
|
959
|
+
}, m = (f) => {
|
|
960
|
+
const y = t.get(f.annotation);
|
|
961
|
+
if (y) {
|
|
962
|
+
const x = y.bodies.find((C) => C.id === f.id);
|
|
963
|
+
if (x) {
|
|
964
|
+
e.delete(x.id);
|
|
965
|
+
const C = {
|
|
966
|
+
...y,
|
|
967
|
+
bodies: y.bodies.filter((B) => B.id !== f.id)
|
|
968
968
|
};
|
|
969
|
-
return t.set(
|
|
970
|
-
oldValue:
|
|
971
|
-
newValue:
|
|
972
|
-
bodiesDeleted: [
|
|
969
|
+
return t.set(y.id, C), {
|
|
970
|
+
oldValue: y,
|
|
971
|
+
newValue: C,
|
|
972
|
+
bodiesDeleted: [x]
|
|
973
973
|
};
|
|
974
974
|
} else
|
|
975
|
-
console.warn(`Attempt to delete missing body ${
|
|
975
|
+
console.warn(`Attempt to delete missing body ${f.id} from annotation ${f.annotation}`);
|
|
976
976
|
} else
|
|
977
|
-
console.warn(`Attempt to delete body from missing annotation ${
|
|
978
|
-
}, u = (
|
|
979
|
-
const
|
|
980
|
-
|
|
981
|
-
},
|
|
982
|
-
const
|
|
983
|
-
|
|
984
|
-
},
|
|
985
|
-
const
|
|
986
|
-
return
|
|
987
|
-
},
|
|
988
|
-
const
|
|
989
|
-
if (
|
|
990
|
-
const
|
|
991
|
-
if (
|
|
992
|
-
return
|
|
993
|
-
console.error(`Store integrity error: body ${
|
|
977
|
+
console.warn(`Attempt to delete body from missing annotation ${f.annotation}`);
|
|
978
|
+
}, u = (f, y = k.LOCAL) => {
|
|
979
|
+
const x = m(f);
|
|
980
|
+
x && s(y, { updated: [x] });
|
|
981
|
+
}, b = (f, y = k.LOCAL) => {
|
|
982
|
+
const x = f.map((C) => m(C)).filter(Boolean);
|
|
983
|
+
x.length > 0 && s(y, { updated: x });
|
|
984
|
+
}, S = (f) => {
|
|
985
|
+
const y = t.get(f);
|
|
986
|
+
return y ? { ...y } : void 0;
|
|
987
|
+
}, A = (f) => {
|
|
988
|
+
const y = e.get(f);
|
|
989
|
+
if (y) {
|
|
990
|
+
const x = S(y).bodies.find((C) => C.id === f);
|
|
991
|
+
if (x)
|
|
992
|
+
return x;
|
|
993
|
+
console.error(`Store integrity error: body ${f} in index, but not in annotation`);
|
|
994
994
|
} else
|
|
995
|
-
console.warn(`Attempt to retrieve missing body: ${
|
|
996
|
-
}, L = (
|
|
997
|
-
if (
|
|
995
|
+
console.warn(`Attempt to retrieve missing body: ${f}`);
|
|
996
|
+
}, L = (f, y) => {
|
|
997
|
+
if (f.annotation !== y.annotation)
|
|
998
998
|
throw "Annotation integrity violation: annotation ID must be the same when updating bodies";
|
|
999
|
-
const
|
|
1000
|
-
if (
|
|
1001
|
-
const
|
|
1002
|
-
...
|
|
1003
|
-
bodies:
|
|
999
|
+
const x = t.get(f.annotation);
|
|
1000
|
+
if (x) {
|
|
1001
|
+
const C = x.bodies.find((R) => R.id === f.id), B = {
|
|
1002
|
+
...x,
|
|
1003
|
+
bodies: x.bodies.map((R) => R.id === C.id ? y : R)
|
|
1004
1004
|
};
|
|
1005
|
-
return t.set(
|
|
1006
|
-
oldValue:
|
|
1005
|
+
return t.set(x.id, B), C.id !== y.id && (e.delete(C.id), e.set(y.id, B.id)), {
|
|
1006
|
+
oldValue: x,
|
|
1007
1007
|
newValue: B,
|
|
1008
|
-
bodiesUpdated: [{ oldBody:
|
|
1008
|
+
bodiesUpdated: [{ oldBody: C, newBody: y }]
|
|
1009
1009
|
};
|
|
1010
1010
|
} else
|
|
1011
|
-
console.warn(`Attempt to add body to missing annotation ${
|
|
1012
|
-
},
|
|
1013
|
-
const
|
|
1014
|
-
|
|
1015
|
-
},
|
|
1016
|
-
const
|
|
1017
|
-
s(
|
|
1018
|
-
},
|
|
1019
|
-
const
|
|
1020
|
-
if (
|
|
1021
|
-
const
|
|
1022
|
-
...
|
|
1011
|
+
console.warn(`Attempt to add body to missing annotation ${f.annotation}`);
|
|
1012
|
+
}, T = (f, y, x = k.LOCAL) => {
|
|
1013
|
+
const C = L(f, y);
|
|
1014
|
+
C && s(x, { updated: [C] });
|
|
1015
|
+
}, O = (f, y = k.LOCAL) => {
|
|
1016
|
+
const x = f.map((C) => L({ id: C.id, annotation: C.annotation }, C)).filter(Boolean);
|
|
1017
|
+
s(y, { updated: x });
|
|
1018
|
+
}, M = (f) => {
|
|
1019
|
+
const y = t.get(f.annotation);
|
|
1020
|
+
if (y) {
|
|
1021
|
+
const x = {
|
|
1022
|
+
...y,
|
|
1023
1023
|
target: {
|
|
1024
|
-
...
|
|
1025
|
-
...
|
|
1024
|
+
...y.target,
|
|
1025
|
+
...f
|
|
1026
1026
|
}
|
|
1027
1027
|
};
|
|
1028
|
-
return t.set(
|
|
1029
|
-
oldValue:
|
|
1030
|
-
newValue:
|
|
1028
|
+
return t.set(y.id, x), {
|
|
1029
|
+
oldValue: y,
|
|
1030
|
+
newValue: x,
|
|
1031
1031
|
targetUpdated: {
|
|
1032
|
-
oldTarget:
|
|
1033
|
-
newTarget:
|
|
1032
|
+
oldTarget: y.target,
|
|
1033
|
+
newTarget: f
|
|
1034
1034
|
}
|
|
1035
1035
|
};
|
|
1036
1036
|
} else
|
|
1037
|
-
console.warn(`Attempt to update target on missing annotation: ${
|
|
1037
|
+
console.warn(`Attempt to update target on missing annotation: ${f.annotation}`);
|
|
1038
1038
|
};
|
|
1039
1039
|
return {
|
|
1040
1040
|
addAnnotation: r,
|
|
1041
|
-
addBody:
|
|
1041
|
+
addBody: h,
|
|
1042
1042
|
all: l,
|
|
1043
|
-
bulkAddAnnotation:
|
|
1043
|
+
bulkAddAnnotation: p,
|
|
1044
1044
|
bulkDeleteAnnotation: E,
|
|
1045
|
-
bulkDeleteBodies:
|
|
1045
|
+
bulkDeleteBodies: b,
|
|
1046
1046
|
bulkUpdateAnnotation: c,
|
|
1047
|
-
bulkUpdateBodies:
|
|
1048
|
-
bulkUpdateTargets: (
|
|
1049
|
-
const
|
|
1050
|
-
|
|
1047
|
+
bulkUpdateBodies: O,
|
|
1048
|
+
bulkUpdateTargets: (f, y = k.LOCAL) => {
|
|
1049
|
+
const x = f.map((C) => M(C)).filter(Boolean);
|
|
1050
|
+
x.length > 0 && s(y, { updated: x });
|
|
1051
1051
|
},
|
|
1052
|
-
clear:
|
|
1053
|
-
deleteAnnotation:
|
|
1052
|
+
clear: g,
|
|
1053
|
+
deleteAnnotation: w,
|
|
1054
1054
|
deleteBody: u,
|
|
1055
|
-
getAnnotation:
|
|
1056
|
-
getBody:
|
|
1055
|
+
getAnnotation: S,
|
|
1056
|
+
getBody: A,
|
|
1057
1057
|
observe: o,
|
|
1058
1058
|
unobserve: i,
|
|
1059
1059
|
updateAnnotation: d,
|
|
1060
|
-
updateBody:
|
|
1061
|
-
updateTarget: (
|
|
1062
|
-
const
|
|
1063
|
-
|
|
1060
|
+
updateBody: T,
|
|
1061
|
+
updateTarget: (f, y = k.LOCAL) => {
|
|
1062
|
+
const x = M(f);
|
|
1063
|
+
x && s(y, { updated: [x] });
|
|
1064
1064
|
}
|
|
1065
1065
|
};
|
|
1066
1066
|
};
|
|
@@ -1081,38 +1081,38 @@ let Un = () => ({
|
|
|
1081
1081
|
const Dn = 250, Vn = (t) => {
|
|
1082
1082
|
const e = Un(), n = [];
|
|
1083
1083
|
let o = -1, i = !1, s = 0;
|
|
1084
|
-
const r = (
|
|
1084
|
+
const r = (p) => {
|
|
1085
1085
|
if (!i) {
|
|
1086
|
-
const { changes:
|
|
1087
|
-
if (
|
|
1088
|
-
n.splice(o + 1), n.push(
|
|
1086
|
+
const { changes: v } = p, w = performance.now();
|
|
1087
|
+
if (w - s > Dn)
|
|
1088
|
+
n.splice(o + 1), n.push(v), o = n.length - 1;
|
|
1089
1089
|
else {
|
|
1090
1090
|
const E = n.length - 1;
|
|
1091
|
-
n[E] = In(n[E],
|
|
1091
|
+
n[E] = In(n[E], v);
|
|
1092
1092
|
}
|
|
1093
|
-
s =
|
|
1093
|
+
s = w;
|
|
1094
1094
|
}
|
|
1095
1095
|
i = !1;
|
|
1096
1096
|
};
|
|
1097
1097
|
t.observe(r, { origin: k.LOCAL });
|
|
1098
|
-
const a = (
|
|
1098
|
+
const a = (p) => p && p.length > 0 && t.bulkDeleteAnnotation(p), d = (p) => p && p.length > 0 && t.bulkAddAnnotation(p, !1), c = (p) => p && p.length > 0 && t.bulkUpdateAnnotation(p.map(({ oldValue: v }) => v)), h = (p) => p && p.length > 0 && t.bulkUpdateAnnotation(p.map(({ newValue: v }) => v)), l = (p) => p && p.length > 0 && t.bulkAddAnnotation(p, !1), g = (p) => p && p.length > 0 && t.bulkDeleteAnnotation(p);
|
|
1099
1099
|
return {
|
|
1100
1100
|
canRedo: () => n.length - 1 > o,
|
|
1101
1101
|
canUndo: () => o > -1,
|
|
1102
1102
|
destroy: () => t.unobserve(r),
|
|
1103
|
-
on: (
|
|
1103
|
+
on: (p, v) => e.on(p, v),
|
|
1104
1104
|
redo: () => {
|
|
1105
1105
|
if (n.length - 1 > o) {
|
|
1106
1106
|
i = !0;
|
|
1107
|
-
const { created:
|
|
1108
|
-
d(
|
|
1107
|
+
const { created: p, updated: v, deleted: w } = n[o + 1];
|
|
1108
|
+
d(p), h(v), g(w), e.emit("redo", n[o + 1]), o += 1;
|
|
1109
1109
|
}
|
|
1110
1110
|
},
|
|
1111
1111
|
undo: () => {
|
|
1112
1112
|
if (o > -1) {
|
|
1113
1113
|
i = !0;
|
|
1114
|
-
const { created:
|
|
1115
|
-
a(
|
|
1114
|
+
const { created: p, updated: v, deleted: w } = n[o];
|
|
1115
|
+
a(p), c(v), l(w), e.emit("undo", n[o]), o -= 1;
|
|
1116
1116
|
}
|
|
1117
1117
|
}
|
|
1118
1118
|
};
|
|
@@ -1124,72 +1124,72 @@ const Dn = 250, Vn = (t) => {
|
|
|
1124
1124
|
};
|
|
1125
1125
|
}, Yn = (t, e, n, o) => {
|
|
1126
1126
|
const { hover: i, selection: s, store: r, viewport: a } = t, d = /* @__PURE__ */ new Map();
|
|
1127
|
-
let c = [],
|
|
1128
|
-
const l = (
|
|
1129
|
-
d.has(
|
|
1130
|
-
},
|
|
1131
|
-
const m = d.get(
|
|
1127
|
+
let c = [], h;
|
|
1128
|
+
const l = (w, E) => {
|
|
1129
|
+
d.has(w) ? d.get(w).push(E) : d.set(w, [E]);
|
|
1130
|
+
}, g = (w, E) => {
|
|
1131
|
+
const m = d.get(w);
|
|
1132
1132
|
if (m) {
|
|
1133
1133
|
const u = m.indexOf(E);
|
|
1134
1134
|
u !== -1 && m.splice(u, 1);
|
|
1135
1135
|
}
|
|
1136
|
-
},
|
|
1137
|
-
d.has(
|
|
1138
|
-
d.get(
|
|
1136
|
+
}, p = (w, E, m) => {
|
|
1137
|
+
d.has(w) && setTimeout(() => {
|
|
1138
|
+
d.get(w).forEach((u) => {
|
|
1139
1139
|
if (n) {
|
|
1140
|
-
const
|
|
1141
|
-
u(
|
|
1140
|
+
const b = Array.isArray(E) ? E.map((A) => n.serialize(A)) : n.serialize(E), S = m ? m instanceof PointerEvent ? m : n.serialize(m) : void 0;
|
|
1141
|
+
u(b, S);
|
|
1142
1142
|
} else
|
|
1143
1143
|
u(E, m);
|
|
1144
1144
|
});
|
|
1145
1145
|
}, 1);
|
|
1146
1146
|
};
|
|
1147
|
-
s.subscribe(({ selected:
|
|
1148
|
-
if (!(c.length === 0 &&
|
|
1149
|
-
if (c.length === 0 &&
|
|
1150
|
-
c =
|
|
1151
|
-
else if (c.length > 0 &&
|
|
1147
|
+
s.subscribe(({ selected: w }) => {
|
|
1148
|
+
if (!(c.length === 0 && w.length === 0)) {
|
|
1149
|
+
if (c.length === 0 && w.length > 0)
|
|
1150
|
+
c = w.map(({ id: E }) => r.getAnnotation(E));
|
|
1151
|
+
else if (c.length > 0 && w.length === 0)
|
|
1152
1152
|
c.forEach((E) => {
|
|
1153
1153
|
const m = r.getAnnotation(E.id);
|
|
1154
|
-
m && !q(m, E) &&
|
|
1154
|
+
m && !q(m, E) && p("updateAnnotation", m, E);
|
|
1155
1155
|
}), c = [];
|
|
1156
1156
|
else {
|
|
1157
|
-
const E = new Set(c.map((u) => u.id)), m = new Set(
|
|
1157
|
+
const E = new Set(c.map((u) => u.id)), m = new Set(w.map(({ id: u }) => u));
|
|
1158
1158
|
c.filter((u) => !m.has(u.id)).forEach((u) => {
|
|
1159
|
-
const
|
|
1160
|
-
|
|
1159
|
+
const b = r.getAnnotation(u.id);
|
|
1160
|
+
b && !q(b, u) && p("updateAnnotation", b, u);
|
|
1161
1161
|
}), c = [
|
|
1162
1162
|
// Remove annotations that were deselected
|
|
1163
1163
|
...c.filter((u) => m.has(u.id)),
|
|
1164
1164
|
// Add editable annotations that were selected
|
|
1165
|
-
...
|
|
1165
|
+
...w.filter(({ id: u }) => !E.has(u)).map(({ id: u }) => r.getAnnotation(u))
|
|
1166
1166
|
];
|
|
1167
1167
|
}
|
|
1168
|
-
|
|
1168
|
+
p("selectionChanged", c);
|
|
1169
1169
|
}
|
|
1170
|
-
}), i.subscribe((
|
|
1171
|
-
!
|
|
1172
|
-
}), a == null || a.subscribe((
|
|
1173
|
-
const { created: E, deleted: m } =
|
|
1174
|
-
(E || []).forEach((u) =>
|
|
1170
|
+
}), i.subscribe((w) => {
|
|
1171
|
+
!h && w ? p("mouseEnterAnnotation", r.getAnnotation(w)) : h && !w ? p("mouseLeaveAnnotation", r.getAnnotation(h)) : h && w && (p("mouseLeaveAnnotation", r.getAnnotation(h)), p("mouseEnterAnnotation", r.getAnnotation(w))), h = w;
|
|
1172
|
+
}), a == null || a.subscribe((w) => p("viewportIntersect", w.map((E) => r.getAnnotation(E)))), r.observe((w) => {
|
|
1173
|
+
const { created: E, deleted: m } = w.changes;
|
|
1174
|
+
(E || []).forEach((u) => p("createAnnotation", u)), (m || []).forEach((u) => p("deleteAnnotation", u)), (w.changes.updated || []).filter((u) => [
|
|
1175
1175
|
...u.bodiesCreated || [],
|
|
1176
1176
|
...u.bodiesDeleted || [],
|
|
1177
1177
|
...u.bodiesUpdated || []
|
|
1178
|
-
].length > 0).forEach(({ oldValue: u, newValue:
|
|
1179
|
-
const
|
|
1180
|
-
c = c.map((
|
|
1178
|
+
].length > 0).forEach(({ oldValue: u, newValue: b }) => {
|
|
1179
|
+
const S = c.find((A) => A.id === u.id) || u;
|
|
1180
|
+
c = c.map((A) => A.id === u.id ? b : A), p("updateAnnotation", b, S);
|
|
1181
1181
|
});
|
|
1182
|
-
}, { origin: k.LOCAL }), r.observe((
|
|
1182
|
+
}, { origin: k.LOCAL }), r.observe((w) => {
|
|
1183
1183
|
if (c) {
|
|
1184
|
-
const E = new Set(c.map((u) => u.id)), m = (
|
|
1185
|
-
m.length > 0 && (c = c.map((u) => m.find((
|
|
1184
|
+
const E = new Set(c.map((u) => u.id)), m = (w.changes.updated || []).filter(({ newValue: u }) => E.has(u.id)).map(({ newValue: u }) => u);
|
|
1185
|
+
m.length > 0 && (c = c.map((u) => m.find((S) => S.id === u.id) || u));
|
|
1186
1186
|
}
|
|
1187
1187
|
}, { origin: k.REMOTE });
|
|
1188
|
-
const
|
|
1188
|
+
const v = (w) => (E) => {
|
|
1189
1189
|
const { updated: m } = E;
|
|
1190
|
-
|
|
1190
|
+
w ? (m || []).forEach((u) => p("updateAnnotation", u.oldValue, u.newValue)) : (m || []).forEach((u) => p("updateAnnotation", u.newValue, u.oldValue));
|
|
1191
1191
|
};
|
|
1192
|
-
return e.on("undo",
|
|
1192
|
+
return e.on("undo", v(!0)), e.on("redo", v(!1)), { on: l, off: g, emit: p };
|
|
1193
1193
|
}, Xn = (t) => (e) => e.reduce((n, o) => {
|
|
1194
1194
|
const { parsed: i, error: s } = t.parse(o);
|
|
1195
1195
|
return s ? {
|
|
@@ -1201,21 +1201,21 @@ const Dn = 250, Vn = (t) => {
|
|
|
1201
1201
|
} : {
|
|
1202
1202
|
...n
|
|
1203
1203
|
};
|
|
1204
|
-
}, { parsed: [], failed: [] }),
|
|
1204
|
+
}, { parsed: [], failed: [] }), Pn = (t, e, n) => {
|
|
1205
1205
|
const { store: o, selection: i } = t, s = (m) => {
|
|
1206
1206
|
if (n) {
|
|
1207
|
-
const { parsed: u, error:
|
|
1208
|
-
u ? o.addAnnotation(u, k.REMOTE) : console.error(
|
|
1207
|
+
const { parsed: u, error: b } = n.parse(m);
|
|
1208
|
+
u ? o.addAnnotation(u, k.REMOTE) : console.error(b);
|
|
1209
1209
|
} else
|
|
1210
|
-
o.addAnnotation(
|
|
1210
|
+
o.addAnnotation(Mt(m), k.REMOTE);
|
|
1211
1211
|
}, r = () => i.clear(), a = () => o.clear(), d = (m) => {
|
|
1212
1212
|
const u = o.getAnnotation(m);
|
|
1213
1213
|
return n && u ? n.serialize(u) : u;
|
|
1214
|
-
}, c = () => n ? o.all().map(n.serialize) : o.all(),
|
|
1214
|
+
}, c = () => n ? o.all().map(n.serialize) : o.all(), h = () => {
|
|
1215
1215
|
var m;
|
|
1216
|
-
const u = (((m = i.selected) == null ? void 0 : m.map((
|
|
1216
|
+
const u = (((m = i.selected) == null ? void 0 : m.map((b) => b.id)) || []).map((b) => o.getAnnotation(b)).filter(Boolean);
|
|
1217
1217
|
return n ? u.map(n.serialize) : u;
|
|
1218
|
-
}, l = (m, u = !0) => fetch(m).then((
|
|
1218
|
+
}, l = (m, u = !0) => fetch(m).then((b) => b.json()).then((b) => (p(b, u), b)), g = (m) => {
|
|
1219
1219
|
if (typeof m == "string") {
|
|
1220
1220
|
const u = o.getAnnotation(m);
|
|
1221
1221
|
if (o.deleteAnnotation(m), u)
|
|
@@ -1225,23 +1225,23 @@ const Dn = 250, Vn = (t) => {
|
|
|
1225
1225
|
if (u)
|
|
1226
1226
|
return o.deleteAnnotation(u), m;
|
|
1227
1227
|
}
|
|
1228
|
-
},
|
|
1228
|
+
}, p = (m, u = !0) => {
|
|
1229
1229
|
if (n) {
|
|
1230
|
-
const
|
|
1231
|
-
|
|
1230
|
+
const b = n.parseAll || Xn(n), { parsed: S, failed: A } = b(m);
|
|
1231
|
+
A.length > 0 && console.warn(`Discarded ${A.length} invalid annotations`, A), o.bulkAddAnnotation(S, u, k.REMOTE);
|
|
1232
1232
|
} else
|
|
1233
|
-
o.bulkAddAnnotation(m.map(
|
|
1234
|
-
},
|
|
1233
|
+
o.bulkAddAnnotation(m.map(Mt), u, k.REMOTE);
|
|
1234
|
+
}, v = (m, u) => {
|
|
1235
1235
|
m ? i.setSelected(m, u) : i.clear();
|
|
1236
|
-
},
|
|
1236
|
+
}, w = (m) => {
|
|
1237
1237
|
i.clear(), i.setUserSelectAction(m);
|
|
1238
1238
|
}, E = (m) => {
|
|
1239
1239
|
if (n) {
|
|
1240
|
-
const u = n.parse(m).parsed,
|
|
1241
|
-
return o.updateAnnotation(u),
|
|
1240
|
+
const u = n.parse(m).parsed, b = n.serialize(o.getAnnotation(u.id));
|
|
1241
|
+
return o.updateAnnotation(u), b;
|
|
1242
1242
|
} else {
|
|
1243
1243
|
const u = o.getAnnotation(m.id);
|
|
1244
|
-
return o.updateAnnotation(
|
|
1244
|
+
return o.updateAnnotation(Mt(m)), u;
|
|
1245
1245
|
}
|
|
1246
1246
|
};
|
|
1247
1247
|
return {
|
|
@@ -1252,17 +1252,17 @@ const Dn = 250, Vn = (t) => {
|
|
|
1252
1252
|
clearAnnotations: a,
|
|
1253
1253
|
getAnnotationById: d,
|
|
1254
1254
|
getAnnotations: c,
|
|
1255
|
-
getSelected:
|
|
1255
|
+
getSelected: h,
|
|
1256
1256
|
loadAnnotations: l,
|
|
1257
1257
|
redo: e.redo,
|
|
1258
|
-
removeAnnotation:
|
|
1259
|
-
setAnnotations:
|
|
1260
|
-
setSelected:
|
|
1261
|
-
setUserSelectAction:
|
|
1258
|
+
removeAnnotation: g,
|
|
1259
|
+
setAnnotations: p,
|
|
1260
|
+
setSelected: v,
|
|
1261
|
+
setUserSelectAction: w,
|
|
1262
1262
|
undo: e.undo,
|
|
1263
1263
|
updateAnnotation: E
|
|
1264
1264
|
};
|
|
1265
|
-
},
|
|
1265
|
+
}, $n = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
|
|
1266
1266
|
let jn = (t) => crypto.getRandomValues(new Uint8Array(t)), Hn = (t, e, n) => {
|
|
1267
1267
|
let o = (2 << Math.log(t.length - 1) / Math.LN2) - 1, i = -~(1.6 * o * e / t.length);
|
|
1268
1268
|
return (s = e) => {
|
|
@@ -1276,7 +1276,7 @@ let jn = (t) => crypto.getRandomValues(new Uint8Array(t)), Hn = (t, e, n) => {
|
|
|
1276
1276
|
}, zn = (t, e = 21) => Hn(t, e, jn), Fn = (t = 21) => {
|
|
1277
1277
|
let e = "", n = crypto.getRandomValues(new Uint8Array(t));
|
|
1278
1278
|
for (; t--; )
|
|
1279
|
-
e +=
|
|
1279
|
+
e += $n[n[t] & 63];
|
|
1280
1280
|
return e;
|
|
1281
1281
|
};
|
|
1282
1282
|
const Wn = () => ({ isGuest: !0, id: zn("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_", 20)() }), qn = (t) => {
|
|
@@ -1287,18 +1287,18 @@ const Wn = () => ({ isGuest: !0, id: zn("1234567890abcdefghijklmnopqrstuvwxyzABC
|
|
|
1287
1287
|
n = (n << 5) - n + s, n |= 0;
|
|
1288
1288
|
}
|
|
1289
1289
|
return `${n}`;
|
|
1290
|
-
},
|
|
1291
|
-
const { id: o, type: i, purpose: s, value: r, created: a, modified: d, creator: c, ...
|
|
1290
|
+
}, ve = (t) => t ? typeof t == "object" ? { ...t } : t : void 0, Gn = (t, e) => (Array.isArray(t) ? t : [t]).map((n) => {
|
|
1291
|
+
const { id: o, type: i, purpose: s, value: r, created: a, modified: d, creator: c, ...h } = n;
|
|
1292
1292
|
return {
|
|
1293
1293
|
id: o || `temp-${qn(n)}`,
|
|
1294
1294
|
annotation: e,
|
|
1295
1295
|
type: i,
|
|
1296
1296
|
purpose: s,
|
|
1297
1297
|
value: r,
|
|
1298
|
-
creator:
|
|
1298
|
+
creator: ve(c),
|
|
1299
1299
|
created: a ? new Date(a) : void 0,
|
|
1300
1300
|
updated: d ? new Date(d) : void 0,
|
|
1301
|
-
...
|
|
1301
|
+
...h
|
|
1302
1302
|
};
|
|
1303
1303
|
}), Qn = (t) => t.map((e) => {
|
|
1304
1304
|
var n;
|
|
@@ -1310,7 +1310,7 @@ const Wn = () => ({ isGuest: !0, id: zn("1234567890abcdefghijklmnopqrstuvwxyzABC
|
|
|
1310
1310
|
return (n = a.id) != null && n.startsWith("temp-") && delete a.id, a;
|
|
1311
1311
|
});
|
|
1312
1312
|
Fn();
|
|
1313
|
-
const
|
|
1313
|
+
const Io = (t, e) => ({
|
|
1314
1314
|
parse: (n) => to(n),
|
|
1315
1315
|
serialize: (n) => eo(n, t, e)
|
|
1316
1316
|
}), Jn = (t) => t.quote !== void 0 && t.start !== void 0 && t.end !== void 0, Zn = (t) => {
|
|
@@ -1324,7 +1324,7 @@ const ko = (t, e) => ({
|
|
|
1324
1324
|
if (r.length === 0)
|
|
1325
1325
|
return { error: Error(`No targets found for annotation: ${t.id}`) };
|
|
1326
1326
|
const a = {
|
|
1327
|
-
creator:
|
|
1327
|
+
creator: ve(n),
|
|
1328
1328
|
created: o ? new Date(o) : void 0,
|
|
1329
1329
|
updated: i ? new Date(i) : void 0,
|
|
1330
1330
|
annotation: e,
|
|
@@ -1332,30 +1332,30 @@ const ko = (t, e) => ({
|
|
|
1332
1332
|
styleClass: r[0].styleClass
|
|
1333
1333
|
};
|
|
1334
1334
|
for (const d of r) {
|
|
1335
|
-
const
|
|
1336
|
-
switch (
|
|
1335
|
+
const h = (Array.isArray(d.selector) ? d.selector : [d.selector]).reduce((l, g) => {
|
|
1336
|
+
switch (g.type) {
|
|
1337
1337
|
case "TextQuoteSelector":
|
|
1338
|
-
l.quote =
|
|
1338
|
+
l.quote = g.exact;
|
|
1339
1339
|
break;
|
|
1340
1340
|
case "TextPositionSelector":
|
|
1341
|
-
l.start =
|
|
1341
|
+
l.start = g.start, l.end = g.end;
|
|
1342
1342
|
break;
|
|
1343
1343
|
}
|
|
1344
1344
|
return l;
|
|
1345
1345
|
}, {});
|
|
1346
|
-
if (Jn(
|
|
1347
|
-
a.selector.push({ id: d.id, ...
|
|
1346
|
+
if (Jn(h))
|
|
1347
|
+
a.selector.push({ id: d.id, ...h });
|
|
1348
1348
|
else {
|
|
1349
1349
|
const l = [
|
|
1350
|
-
|
|
1351
|
-
|
|
1350
|
+
h.start ? void 0 : "TextPositionSelector",
|
|
1351
|
+
h.quote ? void 0 : "TextQuoteSelector"
|
|
1352
1352
|
].filter(Boolean);
|
|
1353
1353
|
return { error: Error(`Missing selector types: ${l.join(" and ")} for annotation: ${t.id}`) };
|
|
1354
1354
|
}
|
|
1355
1355
|
}
|
|
1356
1356
|
return { parsed: a };
|
|
1357
1357
|
}, to = (t) => {
|
|
1358
|
-
const e = t.id ||
|
|
1358
|
+
const e = t.id || ye(), {
|
|
1359
1359
|
creator: n,
|
|
1360
1360
|
created: o,
|
|
1361
1361
|
modified: i,
|
|
@@ -1376,23 +1376,23 @@ const ko = (t, e) => ({
|
|
|
1376
1376
|
creator: a,
|
|
1377
1377
|
created: d,
|
|
1378
1378
|
updated: c,
|
|
1379
|
-
...
|
|
1380
|
-
} = i, l = r.map((
|
|
1381
|
-
const { quote:
|
|
1379
|
+
...h
|
|
1380
|
+
} = i, l = r.map((g) => {
|
|
1381
|
+
const { quote: p, start: v, end: w, range: E } = g, { prefix: m, suffix: u } = Ue(E, n), b = [{
|
|
1382
1382
|
type: "TextQuoteSelector",
|
|
1383
|
-
exact:
|
|
1383
|
+
exact: p,
|
|
1384
1384
|
prefix: m,
|
|
1385
1385
|
suffix: u
|
|
1386
1386
|
}, {
|
|
1387
1387
|
type: "TextPositionSelector",
|
|
1388
|
-
start:
|
|
1389
|
-
end:
|
|
1388
|
+
start: v,
|
|
1389
|
+
end: w
|
|
1390
1390
|
}];
|
|
1391
1391
|
return {
|
|
1392
|
-
...
|
|
1393
|
-
id:
|
|
1392
|
+
...h,
|
|
1393
|
+
id: g.id,
|
|
1394
1394
|
source: e,
|
|
1395
|
-
selector:
|
|
1395
|
+
selector: b
|
|
1396
1396
|
};
|
|
1397
1397
|
});
|
|
1398
1398
|
return {
|
|
@@ -1407,11 +1407,11 @@ const ko = (t, e) => ({
|
|
|
1407
1407
|
target: l
|
|
1408
1408
|
};
|
|
1409
1409
|
};
|
|
1410
|
-
function
|
|
1410
|
+
function Ae(t, e, n = 0, o = t.length - 1, i = no) {
|
|
1411
1411
|
for (; o > n; ) {
|
|
1412
1412
|
if (o - n > 600) {
|
|
1413
|
-
const d = o - n + 1, c = e - n + 1,
|
|
1414
|
-
|
|
1413
|
+
const d = o - n + 1, c = e - n + 1, h = Math.log(d), l = 0.5 * Math.exp(2 * h / 3), g = 0.5 * Math.sqrt(h * l * (d - l) / d) * (c - d / 2 < 0 ? -1 : 1), p = Math.max(n, Math.floor(e - c * l / d + g)), v = Math.min(o, Math.floor(e + (d - c) * l / d + g));
|
|
1414
|
+
Ae(t, e, p, v, i);
|
|
1415
1415
|
}
|
|
1416
1416
|
const s = t[e];
|
|
1417
1417
|
let r = n, a = o;
|
|
@@ -1444,7 +1444,7 @@ class oo {
|
|
|
1444
1444
|
for (; n; ) {
|
|
1445
1445
|
for (let r = 0; r < n.children.length; r++) {
|
|
1446
1446
|
const a = n.children[r], d = n.leaf ? i(a) : a;
|
|
1447
|
-
yt(e, d) && (n.leaf ? o.push(a) :
|
|
1447
|
+
yt(e, d) && (n.leaf ? o.push(a) : It(e, d) ? this._all(a, o) : s.push(a));
|
|
1448
1448
|
}
|
|
1449
1449
|
n = s.pop();
|
|
1450
1450
|
}
|
|
@@ -1458,7 +1458,7 @@ class oo {
|
|
|
1458
1458
|
for (let i = 0; i < n.children.length; i++) {
|
|
1459
1459
|
const s = n.children[i], r = n.leaf ? this.toBBox(s) : s;
|
|
1460
1460
|
if (yt(e, r)) {
|
|
1461
|
-
if (n.leaf ||
|
|
1461
|
+
if (n.leaf || It(e, r)) return !0;
|
|
1462
1462
|
o.push(s);
|
|
1463
1463
|
}
|
|
1464
1464
|
}
|
|
@@ -1500,11 +1500,11 @@ class oo {
|
|
|
1500
1500
|
let a, d, c;
|
|
1501
1501
|
for (; o || s.length; ) {
|
|
1502
1502
|
if (o || (o = s.pop(), d = s[s.length - 1], a = r.pop(), c = !0), o.leaf) {
|
|
1503
|
-
const
|
|
1504
|
-
if (
|
|
1505
|
-
return o.children.splice(
|
|
1503
|
+
const h = io(e, o.children, n);
|
|
1504
|
+
if (h !== -1)
|
|
1505
|
+
return o.children.splice(h, 1), s.push(o), this._condense(s), this;
|
|
1506
1506
|
}
|
|
1507
|
-
!c && !o.leaf &&
|
|
1507
|
+
!c && !o.leaf && It(o, i) ? (s.push(o), r.push(a), a = 0, d = o, o = o.children[0]) : d ? (a++, o = d.children[a], c = !1) : o = null;
|
|
1508
1508
|
}
|
|
1509
1509
|
return this;
|
|
1510
1510
|
}
|
|
@@ -1536,13 +1536,13 @@ class oo {
|
|
|
1536
1536
|
return a = J(e.slice(n, o + 1)), Q(a, this.toBBox), a;
|
|
1537
1537
|
i || (i = Math.ceil(Math.log(s) / Math.log(r)), r = Math.ceil(s / Math.pow(r, i - 1))), a = J([]), a.leaf = !1, a.height = i;
|
|
1538
1538
|
const d = Math.ceil(s / r), c = d * Math.ceil(Math.sqrt(r));
|
|
1539
|
-
|
|
1540
|
-
for (let
|
|
1541
|
-
const l = Math.min(
|
|
1542
|
-
|
|
1543
|
-
for (let
|
|
1544
|
-
const
|
|
1545
|
-
a.children.push(this._build(e,
|
|
1539
|
+
ie(e, n, o, c, this.compareMinX);
|
|
1540
|
+
for (let h = n; h <= o; h += c) {
|
|
1541
|
+
const l = Math.min(h + c - 1, o);
|
|
1542
|
+
ie(e, h, l, d, this.compareMinY);
|
|
1543
|
+
for (let g = h; g <= l; g += d) {
|
|
1544
|
+
const p = Math.min(g + d - 1, l);
|
|
1545
|
+
a.children.push(this._build(e, g, p, i - 1));
|
|
1546
1546
|
}
|
|
1547
1547
|
}
|
|
1548
1548
|
return Q(a, this.toBBox), a;
|
|
@@ -1551,8 +1551,8 @@ class oo {
|
|
|
1551
1551
|
for (; i.push(n), !(n.leaf || i.length - 1 === o); ) {
|
|
1552
1552
|
let s = 1 / 0, r = 1 / 0, a;
|
|
1553
1553
|
for (let d = 0; d < n.children.length; d++) {
|
|
1554
|
-
const c = n.children[d],
|
|
1555
|
-
l < r ? (r = l, s =
|
|
1554
|
+
const c = n.children[d], h = kt(c), l = ao(e, c) - h;
|
|
1555
|
+
l < r ? (r = l, s = h < s ? h : s, a = c) : l === r && h < s && (s = h, a = c);
|
|
1556
1556
|
}
|
|
1557
1557
|
n = a || n.children[0];
|
|
1558
1558
|
}
|
|
@@ -1577,8 +1577,8 @@ class oo {
|
|
|
1577
1577
|
_chooseSplitIndex(e, n, o) {
|
|
1578
1578
|
let i, s = 1 / 0, r = 1 / 0;
|
|
1579
1579
|
for (let a = n; a <= o - n; a++) {
|
|
1580
|
-
const d = ot(e, 0, a, this.toBBox), c = ot(e, a, o, this.toBBox),
|
|
1581
|
-
|
|
1580
|
+
const d = ot(e, 0, a, this.toBBox), c = ot(e, a, o, this.toBBox), h = co(d, c), l = kt(d) + kt(c);
|
|
1581
|
+
h < s ? (s = h, i = a, r = l < r ? l : r) : h === s && l < r && (r = l, i = a);
|
|
1582
1582
|
}
|
|
1583
1583
|
return i || o - n;
|
|
1584
1584
|
}
|
|
@@ -1593,12 +1593,12 @@ class oo {
|
|
|
1593
1593
|
const s = this.toBBox, r = ot(e, 0, n, s), a = ot(e, o - n, o, s);
|
|
1594
1594
|
let d = mt(r) + mt(a);
|
|
1595
1595
|
for (let c = n; c < o - n; c++) {
|
|
1596
|
-
const
|
|
1597
|
-
it(r, e.leaf ? s(
|
|
1596
|
+
const h = e.children[c];
|
|
1597
|
+
it(r, e.leaf ? s(h) : h), d += mt(r);
|
|
1598
1598
|
}
|
|
1599
1599
|
for (let c = o - n - 1; c >= n; c--) {
|
|
1600
|
-
const
|
|
1601
|
-
it(a, e.leaf ? s(
|
|
1600
|
+
const h = e.children[c];
|
|
1601
|
+
it(a, e.leaf ? s(h) : h), d += mt(a);
|
|
1602
1602
|
}
|
|
1603
1603
|
return d;
|
|
1604
1604
|
}
|
|
@@ -1637,7 +1637,7 @@ function so(t, e) {
|
|
|
1637
1637
|
function ro(t, e) {
|
|
1638
1638
|
return t.minY - e.minY;
|
|
1639
1639
|
}
|
|
1640
|
-
function
|
|
1640
|
+
function kt(t) {
|
|
1641
1641
|
return (t.maxX - t.minX) * (t.maxY - t.minY);
|
|
1642
1642
|
}
|
|
1643
1643
|
function mt(t) {
|
|
@@ -1650,7 +1650,7 @@ function co(t, e) {
|
|
|
1650
1650
|
const n = Math.max(t.minX, e.minX), o = Math.max(t.minY, e.minY), i = Math.min(t.maxX, e.maxX), s = Math.min(t.maxY, e.maxY);
|
|
1651
1651
|
return Math.max(0, i - n) * Math.max(0, s - o);
|
|
1652
1652
|
}
|
|
1653
|
-
function
|
|
1653
|
+
function It(t, e) {
|
|
1654
1654
|
return t.minX <= e.minX && t.minY <= e.minY && e.maxX <= t.maxX && e.maxY <= t.maxY;
|
|
1655
1655
|
}
|
|
1656
1656
|
function yt(t, e) {
|
|
@@ -1667,12 +1667,12 @@ function J(t) {
|
|
|
1667
1667
|
maxY: -1 / 0
|
|
1668
1668
|
};
|
|
1669
1669
|
}
|
|
1670
|
-
function
|
|
1670
|
+
function ie(t, e, n, o, i) {
|
|
1671
1671
|
const s = [e, n];
|
|
1672
1672
|
for (; s.length; ) {
|
|
1673
1673
|
if (n = s.pop(), e = s.pop(), n - e <= o) continue;
|
|
1674
1674
|
const r = e + Math.ceil((n - e) / o / 2) * o;
|
|
1675
|
-
|
|
1675
|
+
Ae(t, r, e, n, i), s.push(e, r, r, n);
|
|
1676
1676
|
}
|
|
1677
1677
|
}
|
|
1678
1678
|
let lo = () => ({
|
|
@@ -1690,121 +1690,121 @@ let lo = () => ({
|
|
|
1690
1690
|
}
|
|
1691
1691
|
});
|
|
1692
1692
|
const uo = (t, e) => {
|
|
1693
|
-
const n = new oo(), o = /* @__PURE__ */ new Map(), i = lo(), s = (
|
|
1694
|
-
const
|
|
1695
|
-
const
|
|
1696
|
-
return Array.from(
|
|
1697
|
-
}), L = Xe(
|
|
1698
|
-
return L.map((
|
|
1699
|
-
const { x:
|
|
1693
|
+
const n = new oo(), o = /* @__PURE__ */ new Map(), i = lo(), s = (b, S) => {
|
|
1694
|
+
const A = b.selector.flatMap((T) => {
|
|
1695
|
+
const O = F([T]) ? T.range : de(T, e).range;
|
|
1696
|
+
return Array.from(O.getClientRects());
|
|
1697
|
+
}), L = Xe(A).map((T) => He(T, S));
|
|
1698
|
+
return L.map((T) => {
|
|
1699
|
+
const { x: O, y: M, width: f, height: y } = T;
|
|
1700
1700
|
return {
|
|
1701
|
-
minX:
|
|
1702
|
-
minY:
|
|
1703
|
-
maxX:
|
|
1704
|
-
maxY:
|
|
1701
|
+
minX: O,
|
|
1702
|
+
minY: M,
|
|
1703
|
+
maxX: O + f,
|
|
1704
|
+
maxY: M + y,
|
|
1705
1705
|
annotation: {
|
|
1706
|
-
id:
|
|
1706
|
+
id: b.annotation,
|
|
1707
1707
|
rects: L
|
|
1708
1708
|
}
|
|
1709
1709
|
};
|
|
1710
1710
|
});
|
|
1711
1711
|
}, r = () => [...o.values()], a = () => {
|
|
1712
1712
|
n.clear(), o.clear();
|
|
1713
|
-
}, d = (
|
|
1714
|
-
const
|
|
1715
|
-
|
|
1716
|
-
}, c = (
|
|
1717
|
-
const
|
|
1718
|
-
|
|
1719
|
-
},
|
|
1720
|
-
c(
|
|
1721
|
-
}, l = (
|
|
1722
|
-
|
|
1723
|
-
const
|
|
1724
|
-
L.forEach(({ target:
|
|
1725
|
-
const
|
|
1726
|
-
n.load(
|
|
1727
|
-
},
|
|
1713
|
+
}, d = (b) => {
|
|
1714
|
+
const S = s(b, e.getBoundingClientRect());
|
|
1715
|
+
S.forEach((A) => n.insert(A)), o.set(b.annotation, S);
|
|
1716
|
+
}, c = (b) => {
|
|
1717
|
+
const S = o.get(b.annotation);
|
|
1718
|
+
S && (S.forEach((A) => n.remove(A)), o.delete(b.annotation));
|
|
1719
|
+
}, h = (b) => {
|
|
1720
|
+
c(b), d(b);
|
|
1721
|
+
}, l = (b, S = !0) => {
|
|
1722
|
+
S && a();
|
|
1723
|
+
const A = e.getBoundingClientRect(), L = b.map((O) => ({ target: O, rects: s(O, A) }));
|
|
1724
|
+
L.forEach(({ target: O, rects: M }) => o.set(O.annotation, M));
|
|
1725
|
+
const T = L.flatMap(({ rects: O }) => O);
|
|
1726
|
+
n.load(T);
|
|
1727
|
+
}, g = (b, S, A = !1) => {
|
|
1728
1728
|
const L = n.search({
|
|
1729
|
-
minX:
|
|
1730
|
-
minY:
|
|
1731
|
-
maxX:
|
|
1732
|
-
maxY:
|
|
1733
|
-
}),
|
|
1734
|
-
return L.length > 0 ? (L.sort((
|
|
1735
|
-
},
|
|
1736
|
-
const
|
|
1737
|
-
if (
|
|
1729
|
+
minX: b,
|
|
1730
|
+
minY: S,
|
|
1731
|
+
maxX: b,
|
|
1732
|
+
maxY: S
|
|
1733
|
+
}), T = (O) => O.annotation.rects.reduce((M, f) => M + f.width * f.height, 0);
|
|
1734
|
+
return L.length > 0 ? (L.sort((O, M) => T(O) - T(M)), A ? L.map((O) => O.annotation.id) : [L[0].annotation.id]) : [];
|
|
1735
|
+
}, p = (b) => {
|
|
1736
|
+
const S = v(b);
|
|
1737
|
+
if (S.length === 0)
|
|
1738
1738
|
return;
|
|
1739
|
-
let
|
|
1740
|
-
for (let
|
|
1741
|
-
const
|
|
1742
|
-
|
|
1739
|
+
let A = S[0].left, L = S[0].top, T = S[0].right, O = S[0].bottom;
|
|
1740
|
+
for (let M = 1; M < S.length; M++) {
|
|
1741
|
+
const f = S[M];
|
|
1742
|
+
A = Math.min(A, f.left), L = Math.min(L, f.top), T = Math.max(T, f.right), O = Math.max(O, f.bottom);
|
|
1743
1743
|
}
|
|
1744
|
-
return new DOMRect(
|
|
1745
|
-
},
|
|
1746
|
-
const
|
|
1747
|
-
return
|
|
1744
|
+
return new DOMRect(A, L, T - A, O - L);
|
|
1745
|
+
}, v = (b) => {
|
|
1746
|
+
const S = o.get(b);
|
|
1747
|
+
return S ? S[0].annotation.rects : [];
|
|
1748
1748
|
};
|
|
1749
1749
|
return {
|
|
1750
1750
|
all: r,
|
|
1751
1751
|
clear: a,
|
|
1752
|
-
getAt:
|
|
1753
|
-
getAnnotationBounds:
|
|
1754
|
-
getAnnotationRects:
|
|
1755
|
-
getIntersecting: (
|
|
1756
|
-
const
|
|
1757
|
-
return Array.from(
|
|
1758
|
-
annotation: t.getAnnotation(
|
|
1759
|
-
rects:
|
|
1760
|
-
})).filter((
|
|
1752
|
+
getAt: g,
|
|
1753
|
+
getAnnotationBounds: p,
|
|
1754
|
+
getAnnotationRects: v,
|
|
1755
|
+
getIntersecting: (b, S, A, L) => {
|
|
1756
|
+
const T = n.search({ minX: b, minY: S, maxX: A, maxY: L }), O = new Set(T.map((M) => M.annotation.id));
|
|
1757
|
+
return Array.from(O).map((M) => ({
|
|
1758
|
+
annotation: t.getAnnotation(M),
|
|
1759
|
+
rects: v(M)
|
|
1760
|
+
})).filter((M) => !!M.annotation);
|
|
1761
1761
|
},
|
|
1762
1762
|
insert: d,
|
|
1763
1763
|
recalculate: () => {
|
|
1764
|
-
l(t.all().map((
|
|
1764
|
+
l(t.all().map((b) => b.target), !0), i.emit("recalculate");
|
|
1765
1765
|
},
|
|
1766
1766
|
remove: c,
|
|
1767
1767
|
set: l,
|
|
1768
1768
|
size: () => n.all().length,
|
|
1769
|
-
update:
|
|
1770
|
-
on: (
|
|
1769
|
+
update: h,
|
|
1770
|
+
on: (b, S) => i.on(b, S)
|
|
1771
1771
|
};
|
|
1772
1772
|
}, fo = (t, e) => {
|
|
1773
1773
|
const n = _n(), o = uo(n, t), i = En(n);
|
|
1774
1774
|
i.setUserSelectAction(e);
|
|
1775
|
-
const s = An(n), r = Kn(), a = (u,
|
|
1776
|
-
const
|
|
1777
|
-
return
|
|
1778
|
-
}, d = (u,
|
|
1779
|
-
const
|
|
1780
|
-
return L.length > 0 ? (console.warn("Could not revive all targets for these annotations:", L), n.bulkAddAnnotation(
|
|
1781
|
-
}, c = (u,
|
|
1782
|
-
const
|
|
1783
|
-
return
|
|
1784
|
-
n.getAnnotation(L.id) ? n.updateAnnotation(L,
|
|
1785
|
-
}),
|
|
1786
|
-
},
|
|
1787
|
-
const
|
|
1788
|
-
n.updateTarget(
|
|
1789
|
-
}, l = (u,
|
|
1790
|
-
const
|
|
1791
|
-
n.bulkUpdateTargets(
|
|
1792
|
-
},
|
|
1793
|
-
const
|
|
1775
|
+
const s = An(n), r = Kn(), a = (u, b = k.LOCAL) => {
|
|
1776
|
+
const S = xt(u, t), A = F(S.target.selector);
|
|
1777
|
+
return A && n.addAnnotation(S, b), A;
|
|
1778
|
+
}, d = (u, b = !0, S = k.LOCAL) => {
|
|
1779
|
+
const A = u.map((T) => xt(T, t)), L = A.filter((T) => !F(T.target.selector));
|
|
1780
|
+
return L.length > 0 ? (console.warn("Could not revive all targets for these annotations:", L), n.bulkAddAnnotation(A, b, S), L) : (n.bulkAddAnnotation(A, b, S), []);
|
|
1781
|
+
}, c = (u, b = k.LOCAL) => {
|
|
1782
|
+
const S = u.map((L) => xt(L, t)), A = S.filter((L) => !F(L.target.selector));
|
|
1783
|
+
return A.length > 0 && console.warn("Could not revive all targets for these annotations:", A), S.forEach((L) => {
|
|
1784
|
+
n.getAnnotation(L.id) ? n.updateAnnotation(L, b) : n.addAnnotation(L, b);
|
|
1785
|
+
}), A;
|
|
1786
|
+
}, h = (u, b = k.LOCAL) => {
|
|
1787
|
+
const S = wt(u, t);
|
|
1788
|
+
n.updateTarget(S, b);
|
|
1789
|
+
}, l = (u, b = k.LOCAL) => {
|
|
1790
|
+
const S = u.map((A) => wt(A, t));
|
|
1791
|
+
n.bulkUpdateTargets(S, b);
|
|
1792
|
+
}, g = (u, b, S) => {
|
|
1793
|
+
const A = o.getAt(u, b, !!S).map((T) => n.getAnnotation(T)), L = S ? A.filter(S) : A;
|
|
1794
1794
|
return L.length > 0 ? L[0] : void 0;
|
|
1795
|
-
},
|
|
1795
|
+
}, p = (u, b, S, A = 5) => {
|
|
1796
1796
|
const L = o.getAnnotationRects(u);
|
|
1797
1797
|
if (L.length !== 0) {
|
|
1798
|
-
if (
|
|
1799
|
-
const
|
|
1800
|
-
if (
|
|
1798
|
+
if (b && S) {
|
|
1799
|
+
const T = L.find(({ top: O, right: M, bottom: f, left: y }) => b >= y - A && b <= M + A && S >= O - A && S <= f + A);
|
|
1800
|
+
if (T) return T;
|
|
1801
1801
|
}
|
|
1802
1802
|
return o.getAnnotationBounds(u);
|
|
1803
1803
|
}
|
|
1804
|
-
},
|
|
1804
|
+
}, v = (u, b, S, A) => o.getIntersecting(u, b, S, A), w = (u) => o.getAnnotationRects(u), E = () => o.recalculate(), m = (u) => o.on("recalculate", u);
|
|
1805
1805
|
return n.observe(({ changes: u }) => {
|
|
1806
|
-
const
|
|
1807
|
-
(
|
|
1806
|
+
const b = (u.deleted || []).filter((L) => F(L.target.selector)), S = (u.created || []).filter((L) => F(L.target.selector)), A = (u.updated || []).filter((L) => F(L.newValue.target.selector));
|
|
1807
|
+
(b == null ? void 0 : b.length) > 0 && b.forEach((L) => o.remove(L.target)), S.length > 0 && o.set(S.map((L) => L.target), !1), (A == null ? void 0 : A.length) > 0 && A.forEach(({ newValue: L }) => o.update(L.target));
|
|
1808
1808
|
}), {
|
|
1809
1809
|
store: {
|
|
1810
1810
|
...n,
|
|
@@ -1812,13 +1812,13 @@ const uo = (t, e) => {
|
|
|
1812
1812
|
bulkAddAnnotation: d,
|
|
1813
1813
|
bulkUpdateTargets: l,
|
|
1814
1814
|
bulkUpsertAnnotations: c,
|
|
1815
|
-
getAnnotationBounds:
|
|
1816
|
-
getAnnotationRects:
|
|
1817
|
-
getIntersecting:
|
|
1818
|
-
getAt:
|
|
1815
|
+
getAnnotationBounds: p,
|
|
1816
|
+
getAnnotationRects: w,
|
|
1817
|
+
getIntersecting: v,
|
|
1818
|
+
getAt: g,
|
|
1819
1819
|
recalculatePositions: E,
|
|
1820
1820
|
onRecalculatePositions: m,
|
|
1821
|
-
updateTarget:
|
|
1821
|
+
updateTarget: h
|
|
1822
1822
|
},
|
|
1823
1823
|
selection: i,
|
|
1824
1824
|
hover: s,
|
|
@@ -1829,52 +1829,52 @@ const uo = (t, e) => {
|
|
|
1829
1829
|
t.width = 2 * window.innerWidth, t.height = 2 * window.innerHeight, t.className = "r6o-presence-layer";
|
|
1830
1830
|
const e = t.getContext("2d");
|
|
1831
1831
|
return e.scale(2, 2), e.translate(0.5, 0.5), t;
|
|
1832
|
-
},
|
|
1832
|
+
}, po = (t, e = {}) => {
|
|
1833
1833
|
const n = ho(), o = n.getContext("2d");
|
|
1834
1834
|
document.body.appendChild(n);
|
|
1835
|
-
const i = /* @__PURE__ */ new Map(), s = (
|
|
1836
|
-
return t.on("selectionChange", (
|
|
1837
|
-
s(
|
|
1835
|
+
const i = /* @__PURE__ */ new Map(), s = (h) => Array.from(i.entries()).filter(([l, g]) => g.presenceKey === h.presenceKey).map(([l, g]) => l);
|
|
1836
|
+
return t.on("selectionChange", (h, l) => {
|
|
1837
|
+
s(h).forEach((p) => i.delete(p)), l && l.forEach((p) => i.set(p, h));
|
|
1838
1838
|
}), {
|
|
1839
1839
|
clear: () => {
|
|
1840
|
-
const { width:
|
|
1841
|
-
o.clearRect(-0.5, -0.5,
|
|
1840
|
+
const { width: h, height: l } = n;
|
|
1841
|
+
o.clearRect(-0.5, -0.5, h + 1, l + 1);
|
|
1842
1842
|
},
|
|
1843
1843
|
destroy: () => {
|
|
1844
1844
|
n.remove();
|
|
1845
1845
|
},
|
|
1846
|
-
paint: (
|
|
1846
|
+
paint: (h, l, g) => {
|
|
1847
1847
|
e.font && (o.font = e.font);
|
|
1848
|
-
const
|
|
1849
|
-
if (
|
|
1850
|
-
const { height:
|
|
1851
|
-
o.fillStyle =
|
|
1852
|
-
const m = o.measureText(
|
|
1853
|
-
return o.fillRect(
|
|
1854
|
-
fill:
|
|
1855
|
-
fillOpacity:
|
|
1848
|
+
const p = i.get(h.annotation.id);
|
|
1849
|
+
if (p) {
|
|
1850
|
+
const { height: v } = h.rects[0], w = h.rects[0].x + l.left, E = h.rects[0].y + l.top;
|
|
1851
|
+
o.fillStyle = p.appearance.color, o.fillRect(w - 2, E - 2.5, 2, v + 5);
|
|
1852
|
+
const m = o.measureText(p.appearance.label), u = m.width + 6, b = m.actualBoundingBoxAscent + m.actualBoundingBoxDescent + 8, S = m.fontBoundingBoxAscent ? 8 : 6.5;
|
|
1853
|
+
return o.fillRect(w - 2, E - 2.5 - b, u, b), o.fillStyle = "#fff", o.fillText(p.appearance.label, w + 1, E - S), {
|
|
1854
|
+
fill: p.appearance.color,
|
|
1855
|
+
fillOpacity: g ? 0.45 : 0.18
|
|
1856
1856
|
};
|
|
1857
1857
|
}
|
|
1858
1858
|
},
|
|
1859
1859
|
reset: () => {
|
|
1860
1860
|
n.width = 2 * window.innerWidth, n.height = 2 * window.innerHeight;
|
|
1861
|
-
const
|
|
1862
|
-
|
|
1861
|
+
const h = n.getContext("2d");
|
|
1862
|
+
h.scale(2, 2), h.translate(0.5, 0.5);
|
|
1863
1863
|
}
|
|
1864
1864
|
};
|
|
1865
|
-
},
|
|
1866
|
-
function
|
|
1865
|
+
}, Nt = typeof navigator < "u" ? navigator.userAgent.toLowerCase().indexOf("firefox") > 0 : !1;
|
|
1866
|
+
function _t(t, e, n, o) {
|
|
1867
1867
|
t.addEventListener ? t.addEventListener(e, n, o) : t.attachEvent && t.attachEvent("on".concat(e), n);
|
|
1868
1868
|
}
|
|
1869
1869
|
function et(t, e, n, o) {
|
|
1870
1870
|
t.removeEventListener ? t.removeEventListener(e, n, o) : t.detachEvent && t.detachEvent("on".concat(e), n);
|
|
1871
1871
|
}
|
|
1872
|
-
function
|
|
1872
|
+
function xe(t, e) {
|
|
1873
1873
|
const n = e.slice(0, e.length - 1);
|
|
1874
1874
|
for (let o = 0; o < n.length; o++) n[o] = t[n[o].toLowerCase()];
|
|
1875
1875
|
return n;
|
|
1876
1876
|
}
|
|
1877
|
-
function
|
|
1877
|
+
function Ee(t) {
|
|
1878
1878
|
typeof t != "string" && (t = ""), t = t.replace(/\s/g, "");
|
|
1879
1879
|
const e = t.split(",");
|
|
1880
1880
|
let n = e.lastIndexOf("");
|
|
@@ -1882,7 +1882,7 @@ function xe(t) {
|
|
|
1882
1882
|
e[n - 1] += ",", e.splice(n, 1), n = e.lastIndexOf("");
|
|
1883
1883
|
return e;
|
|
1884
1884
|
}
|
|
1885
|
-
function
|
|
1885
|
+
function go(t, e) {
|
|
1886
1886
|
const n = t.length >= e.length ? t : e, o = t.length >= e.length ? e : t;
|
|
1887
1887
|
let i = !0;
|
|
1888
1888
|
for (let s = 0; s < n.length; s++)
|
|
@@ -1934,9 +1934,9 @@ const at = {
|
|
|
1934
1934
|
".": 190,
|
|
1935
1935
|
"/": 191,
|
|
1936
1936
|
"`": 192,
|
|
1937
|
-
"-":
|
|
1938
|
-
"=":
|
|
1939
|
-
";":
|
|
1937
|
+
"-": Nt ? 173 : 189,
|
|
1938
|
+
"=": Nt ? 61 : 187,
|
|
1939
|
+
";": Nt ? 59 : 186,
|
|
1940
1940
|
"'": 222,
|
|
1941
1941
|
"[": 219,
|
|
1942
1942
|
"]": 221,
|
|
@@ -1957,7 +1957,7 @@ const at = {
|
|
|
1957
1957
|
"⌘": 91,
|
|
1958
1958
|
cmd: 91,
|
|
1959
1959
|
command: 91
|
|
1960
|
-
},
|
|
1960
|
+
}, Kt = {
|
|
1961
1961
|
16: "shiftKey",
|
|
1962
1962
|
18: "altKey",
|
|
1963
1963
|
17: "ctrlKey",
|
|
@@ -1974,13 +1974,13 @@ const at = {
|
|
|
1974
1974
|
}, N = {};
|
|
1975
1975
|
for (let t = 1; t < 20; t++)
|
|
1976
1976
|
at["f".concat(t)] = 111 + t;
|
|
1977
|
-
let I = [], rt = null,
|
|
1977
|
+
let I = [], rt = null, Se = "all";
|
|
1978
1978
|
const z = /* @__PURE__ */ new Map(), lt = (t) => at[t.toLowerCase()] || j[t.toLowerCase()] || t.toUpperCase().charCodeAt(0), mo = (t) => Object.keys(at).find((e) => at[e] === t), yo = (t) => Object.keys(j).find((e) => j[e] === t);
|
|
1979
|
-
function
|
|
1980
|
-
|
|
1979
|
+
function Ce(t) {
|
|
1980
|
+
Se = t || "all";
|
|
1981
1981
|
}
|
|
1982
1982
|
function ct() {
|
|
1983
|
-
return
|
|
1983
|
+
return Se || "all";
|
|
1984
1984
|
}
|
|
1985
1985
|
function bo() {
|
|
1986
1986
|
return I.slice(0);
|
|
@@ -2028,23 +2028,23 @@ function Eo(t, e) {
|
|
|
2028
2028
|
let {
|
|
2029
2029
|
element: a
|
|
2030
2030
|
} = r;
|
|
2031
|
-
return
|
|
2031
|
+
return jt(a);
|
|
2032
2032
|
}) : o++;
|
|
2033
|
-
ct() === t &&
|
|
2033
|
+
ct() === t && Ce(e || "all");
|
|
2034
2034
|
}
|
|
2035
2035
|
function So(t) {
|
|
2036
2036
|
let e = t.keyCode || t.which || t.charCode;
|
|
2037
2037
|
const n = I.indexOf(e);
|
|
2038
2038
|
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 V) {
|
|
2039
2039
|
V[e] = !1;
|
|
2040
|
-
for (const o in j) j[o] === e && (
|
|
2040
|
+
for (const o in j) j[o] === e && (P[o] = !1);
|
|
2041
2041
|
}
|
|
2042
2042
|
}
|
|
2043
|
-
function
|
|
2043
|
+
function Le(t) {
|
|
2044
2044
|
if (typeof t > "u")
|
|
2045
2045
|
Object.keys(N).forEach((i) => {
|
|
2046
2046
|
Array.isArray(N[i]) && N[i].forEach((s) => bt(s)), delete N[i];
|
|
2047
|
-
}),
|
|
2047
|
+
}), jt(null);
|
|
2048
2048
|
else if (Array.isArray(t))
|
|
2049
2049
|
t.forEach((i) => {
|
|
2050
2050
|
i.key && bt(i);
|
|
@@ -2070,18 +2070,18 @@ const bt = (t) => {
|
|
|
2070
2070
|
method: o,
|
|
2071
2071
|
splitKey: i = "+"
|
|
2072
2072
|
} = t;
|
|
2073
|
-
|
|
2074
|
-
const a = r.split(i), d = a.length, c = a[d - 1],
|
|
2075
|
-
if (!N[
|
|
2073
|
+
Ee(e).forEach((r) => {
|
|
2074
|
+
const a = r.split(i), d = a.length, c = a[d - 1], h = c === "*" ? "*" : lt(c);
|
|
2075
|
+
if (!N[h]) return;
|
|
2076
2076
|
n || (n = ct());
|
|
2077
|
-
const l = d > 1 ?
|
|
2078
|
-
N[
|
|
2079
|
-
const
|
|
2080
|
-
return
|
|
2081
|
-
}),
|
|
2077
|
+
const l = d > 1 ? xe(j, a) : [], g = [];
|
|
2078
|
+
N[h] = N[h].filter((p) => {
|
|
2079
|
+
const w = (o ? p.method === o : !0) && p.scope === n && go(p.mods, l);
|
|
2080
|
+
return w && g.push(p.element), !w;
|
|
2081
|
+
}), g.forEach((p) => jt(p));
|
|
2082
2082
|
});
|
|
2083
2083
|
};
|
|
2084
|
-
function
|
|
2084
|
+
function se(t, e, n, o) {
|
|
2085
2085
|
if (e.element !== o)
|
|
2086
2086
|
return;
|
|
2087
2087
|
let i;
|
|
@@ -2092,44 +2092,44 @@ function ie(t, e, n, o) {
|
|
|
2092
2092
|
(e.mods.length === 0 && !V[16] && !V[18] && !V[17] && !V[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)));
|
|
2093
2093
|
}
|
|
2094
2094
|
}
|
|
2095
|
-
function
|
|
2095
|
+
function re(t, e) {
|
|
2096
2096
|
const n = N["*"];
|
|
2097
2097
|
let o = t.keyCode || t.which || t.charCode;
|
|
2098
|
-
if (
|
|
2098
|
+
if (!P.filter.call(this, t)) return;
|
|
2099
2099
|
if ((o === 93 || o === 224) && (o = 91), I.indexOf(o) === -1 && o !== 229 && I.push(o), ["ctrlKey", "altKey", "shiftKey", "metaKey"].forEach((a) => {
|
|
2100
|
-
const d =
|
|
2100
|
+
const d = Kt[a];
|
|
2101
2101
|
t[a] && I.indexOf(d) === -1 ? I.push(d) : !t[a] && I.indexOf(d) > -1 ? I.splice(I.indexOf(d), 1) : a === "metaKey" && t[a] && I.length === 3 && (t.ctrlKey || t.shiftKey || t.altKey || (I = I.slice(I.indexOf(d))));
|
|
2102
2102
|
}), o in V) {
|
|
2103
2103
|
V[o] = !0;
|
|
2104
2104
|
for (const a in j)
|
|
2105
|
-
j[a] === o && (
|
|
2105
|
+
j[a] === o && (P[a] = !0);
|
|
2106
2106
|
if (!n) return;
|
|
2107
2107
|
}
|
|
2108
2108
|
for (const a in V)
|
|
2109
|
-
Object.prototype.hasOwnProperty.call(V, a) && (V[a] = t[
|
|
2109
|
+
Object.prototype.hasOwnProperty.call(V, a) && (V[a] = t[Kt[a]]);
|
|
2110
2110
|
t.getModifierState && !(t.altKey && !t.ctrlKey) && t.getModifierState("AltGraph") && (I.indexOf(17) === -1 && I.push(17), I.indexOf(18) === -1 && I.push(18), V[17] = !0, V[18] = !0);
|
|
2111
2111
|
const i = ct();
|
|
2112
2112
|
if (n)
|
|
2113
2113
|
for (let a = 0; a < n.length; a++)
|
|
2114
|
-
n[a].scope === i && (t.type === "keydown" && n[a].keydown || t.type === "keyup" && n[a].keyup) &&
|
|
2114
|
+
n[a].scope === i && (t.type === "keydown" && n[a].keydown || t.type === "keyup" && n[a].keyup) && se(t, n[a], i, e);
|
|
2115
2115
|
if (!(o in N)) return;
|
|
2116
2116
|
const s = N[o], r = s.length;
|
|
2117
2117
|
for (let a = 0; a < r; a++)
|
|
2118
2118
|
if ((t.type === "keydown" && s[a].keydown || t.type === "keyup" && s[a].keyup) && s[a].key) {
|
|
2119
2119
|
const d = s[a], {
|
|
2120
2120
|
splitKey: c
|
|
2121
|
-
} = d,
|
|
2122
|
-
for (let
|
|
2123
|
-
l.push(lt(
|
|
2124
|
-
l.sort().join("") === I.sort().join("") &&
|
|
2121
|
+
} = d, h = d.key.split(c), l = [];
|
|
2122
|
+
for (let g = 0; g < h.length; g++)
|
|
2123
|
+
l.push(lt(h[g]));
|
|
2124
|
+
l.sort().join("") === I.sort().join("") && se(t, d, i, e);
|
|
2125
2125
|
}
|
|
2126
2126
|
}
|
|
2127
|
-
function
|
|
2127
|
+
function P(t, e, n) {
|
|
2128
2128
|
I = [];
|
|
2129
|
-
const o =
|
|
2130
|
-
let i = [], s = "all", r = document, a = 0, d = !1, c = !0,
|
|
2131
|
-
for (n === void 0 && typeof e == "function" && (n = e), Object.prototype.toString.call(e) === "[object Object]" && (e.scope && (s = e.scope), e.element && (r = e.element), e.keyup && (d = e.keyup), e.keydown !== void 0 && (c = e.keydown), e.capture !== void 0 && (l = e.capture), typeof e.splitKey == "string" && (
|
|
2132
|
-
t = o[a].split(
|
|
2129
|
+
const o = Ee(t);
|
|
2130
|
+
let i = [], s = "all", r = document, a = 0, d = !1, c = !0, h = "+", l = !1, g = !1;
|
|
2131
|
+
for (n === void 0 && typeof e == "function" && (n = e), Object.prototype.toString.call(e) === "[object Object]" && (e.scope && (s = e.scope), e.element && (r = e.element), e.keyup && (d = e.keyup), e.keydown !== void 0 && (c = e.keydown), e.capture !== void 0 && (l = e.capture), typeof e.splitKey == "string" && (h = e.splitKey), e.single === !0 && (g = !0)), typeof e == "string" && (s = e), g && Le(t, s); a < o.length; a++)
|
|
2132
|
+
t = o[a].split(h), i = [], t.length > 1 && (i = xe(j, t)), t = t[t.length - 1], t = t === "*" ? "*" : lt(t), t in N || (N[t] = []), N[t].push({
|
|
2133
2133
|
keyup: d,
|
|
2134
2134
|
keydown: c,
|
|
2135
2135
|
scope: s,
|
|
@@ -2137,32 +2137,32 @@ function $(t, e, n) {
|
|
|
2137
2137
|
shortcut: o[a],
|
|
2138
2138
|
method: n,
|
|
2139
2139
|
key: o[a],
|
|
2140
|
-
splitKey:
|
|
2140
|
+
splitKey: h,
|
|
2141
2141
|
element: r
|
|
2142
2142
|
});
|
|
2143
2143
|
if (typeof r < "u" && window) {
|
|
2144
2144
|
if (!z.has(r)) {
|
|
2145
|
-
const
|
|
2146
|
-
let
|
|
2147
|
-
return
|
|
2148
|
-
},
|
|
2149
|
-
let
|
|
2150
|
-
|
|
2145
|
+
const p = function() {
|
|
2146
|
+
let w = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : window.event;
|
|
2147
|
+
return re(w, r);
|
|
2148
|
+
}, v = function() {
|
|
2149
|
+
let w = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : window.event;
|
|
2150
|
+
re(w, r), So(w);
|
|
2151
2151
|
};
|
|
2152
2152
|
z.set(r, {
|
|
2153
|
-
keydownListener:
|
|
2154
|
-
keyupListenr:
|
|
2153
|
+
keydownListener: p,
|
|
2154
|
+
keyupListenr: v,
|
|
2155
2155
|
capture: l
|
|
2156
|
-
}),
|
|
2156
|
+
}), _t(r, "keydown", p, l), _t(r, "keyup", v, l);
|
|
2157
2157
|
}
|
|
2158
2158
|
if (!rt) {
|
|
2159
|
-
const
|
|
2159
|
+
const p = () => {
|
|
2160
2160
|
I = [];
|
|
2161
2161
|
};
|
|
2162
2162
|
rt = {
|
|
2163
|
-
listener:
|
|
2163
|
+
listener: p,
|
|
2164
2164
|
capture: l
|
|
2165
|
-
},
|
|
2165
|
+
}, _t(window, "focus", p, l);
|
|
2166
2166
|
}
|
|
2167
2167
|
}
|
|
2168
2168
|
}
|
|
@@ -2174,7 +2174,7 @@ function Co(t) {
|
|
|
2174
2174
|
});
|
|
2175
2175
|
});
|
|
2176
2176
|
}
|
|
2177
|
-
function
|
|
2177
|
+
function jt(t) {
|
|
2178
2178
|
const e = Object.values(N).flat();
|
|
2179
2179
|
if (e.findIndex((o) => {
|
|
2180
2180
|
let {
|
|
@@ -2204,9 +2204,9 @@ function Pt(t) {
|
|
|
2204
2204
|
et(window, "focus", i, s), rt = null;
|
|
2205
2205
|
}
|
|
2206
2206
|
}
|
|
2207
|
-
const
|
|
2207
|
+
const Ut = {
|
|
2208
2208
|
getPressedKeyString: wo,
|
|
2209
|
-
setScope:
|
|
2209
|
+
setScope: Ce,
|
|
2210
2210
|
getScope: ct,
|
|
2211
2211
|
deleteScope: Eo,
|
|
2212
2212
|
getPressedKeyCodes: bo,
|
|
@@ -2214,157 +2214,174 @@ const _t = {
|
|
|
2214
2214
|
isPressed: xo,
|
|
2215
2215
|
filter: Ao,
|
|
2216
2216
|
trigger: Co,
|
|
2217
|
-
unbind:
|
|
2217
|
+
unbind: Le,
|
|
2218
2218
|
keyMap: at,
|
|
2219
2219
|
modifier: j,
|
|
2220
|
-
modifierMap:
|
|
2220
|
+
modifierMap: Kt
|
|
2221
2221
|
};
|
|
2222
|
-
for (const t in
|
|
2223
|
-
Object.prototype.hasOwnProperty.call(
|
|
2222
|
+
for (const t in Ut)
|
|
2223
|
+
Object.prototype.hasOwnProperty.call(Ut, t) && (P[t] = Ut[t]);
|
|
2224
2224
|
if (typeof window < "u") {
|
|
2225
2225
|
const t = window.hotkeys;
|
|
2226
|
-
|
|
2226
|
+
P.noConflict = (e) => (e && window.hotkeys === P && (window.hotkeys = t), P), window.hotkeys = P;
|
|
2227
2227
|
}
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2228
|
+
async function Lo(t, e, n = () => !1) {
|
|
2229
|
+
do {
|
|
2230
|
+
if (await t(), await n()) break;
|
|
2231
|
+
const o = e;
|
|
2232
|
+
await new Promise((i) => setTimeout(i, Math.max(0, o)));
|
|
2233
|
+
} while (!await n());
|
|
2234
|
+
}
|
|
2235
|
+
const ae = 300, Oe = ["up", "down", "left", "right"], Te = Ne ? "⌘+a" : "ctrl+a", Oo = [
|
|
2236
|
+
...Oe.map((t) => `shift+${t}`),
|
|
2237
|
+
Te
|
|
2238
|
+
], To = (t, e, n) => {
|
|
2232
2239
|
const { store: o, selection: i } = e;
|
|
2233
2240
|
let s;
|
|
2234
|
-
const r = (
|
|
2241
|
+
const r = (f) => s = f;
|
|
2235
2242
|
let a;
|
|
2236
|
-
const d = (
|
|
2237
|
-
let c,
|
|
2238
|
-
const
|
|
2239
|
-
|
|
2240
|
-
},
|
|
2241
|
-
|
|
2242
|
-
annotation:
|
|
2243
|
+
const d = (f) => a = f;
|
|
2244
|
+
let c, h, l, g = !1, p = !0;
|
|
2245
|
+
const v = (f) => {
|
|
2246
|
+
p = f, E.clear(), f || (c = void 0, l = void 0, g = !1);
|
|
2247
|
+
}, w = (f) => {
|
|
2248
|
+
p && (g = !1, h !== !1 && (c = nt(f.target) ? void 0 : {
|
|
2249
|
+
annotation: ye(),
|
|
2243
2250
|
selector: [],
|
|
2244
2251
|
creator: s,
|
|
2245
2252
|
created: /* @__PURE__ */ new Date()
|
|
2246
2253
|
}));
|
|
2247
|
-
}, E =
|
|
2248
|
-
if (!
|
|
2249
|
-
const
|
|
2250
|
-
if (nt(
|
|
2254
|
+
}, E = Xt((f) => {
|
|
2255
|
+
if (!p) return;
|
|
2256
|
+
const y = document.getSelection();
|
|
2257
|
+
if (y != null && y.anchorNode && nt(y.anchorNode)) {
|
|
2251
2258
|
c = void 0;
|
|
2252
2259
|
return;
|
|
2253
2260
|
}
|
|
2254
|
-
const
|
|
2255
|
-
if ((l == null ? void 0 : l.type) === "pointerdown" && (
|
|
2256
|
-
if (
|
|
2261
|
+
const x = f.timeStamp - ((l == null ? void 0 : l.timeStamp) || f.timeStamp);
|
|
2262
|
+
if ((l == null ? void 0 : l.type) === "pointerdown" && (x < 1e3 && !c || y.isCollapsed && x < ae) && w(l || f), !c) return;
|
|
2263
|
+
if (y.isCollapsed) {
|
|
2257
2264
|
o.getAnnotation(c.annotation) && (i.clear(), o.deleteAnnotation(c.annotation));
|
|
2258
2265
|
return;
|
|
2259
2266
|
}
|
|
2260
|
-
const
|
|
2261
|
-
if (Ve(
|
|
2262
|
-
const
|
|
2263
|
-
(
|
|
2267
|
+
const C = y.getRangeAt(0), B = je(C, t);
|
|
2268
|
+
if (Ve(B)) return;
|
|
2269
|
+
const R = ke(B.cloneRange());
|
|
2270
|
+
(R.length !== c.selector.length || R.some((Y, At) => {
|
|
2264
2271
|
var dt;
|
|
2265
|
-
return
|
|
2272
|
+
return Y.toString() !== ((dt = c.selector[At]) == null ? void 0 : dt.quote);
|
|
2266
2273
|
})) && (c = {
|
|
2267
2274
|
...c,
|
|
2268
|
-
selector:
|
|
2275
|
+
selector: R.map((Y) => Pe(Y, t, n)),
|
|
2269
2276
|
updated: /* @__PURE__ */ new Date()
|
|
2270
2277
|
}, o.getAnnotation(c.annotation) ? o.updateTarget(c, k.LOCAL) : i.clear());
|
|
2271
|
-
}, 10), m = (
|
|
2272
|
-
|
|
2278
|
+
}, 10), m = (f) => {
|
|
2279
|
+
g || nt(f.target) || (l = Et(f), h = l.button === 0);
|
|
2273
2280
|
}, u = () => {
|
|
2274
2281
|
o.getAnnotation(c.annotation) ? o.updateTarget(c) : o.addAnnotation({
|
|
2275
2282
|
id: c.annotation,
|
|
2276
2283
|
bodies: [],
|
|
2277
2284
|
target: c
|
|
2278
2285
|
});
|
|
2279
|
-
},
|
|
2280
|
-
if (
|
|
2281
|
-
const
|
|
2282
|
-
const { x:
|
|
2283
|
-
if (
|
|
2284
|
-
const { selected:
|
|
2285
|
-
(
|
|
2286
|
+
}, b = async (f) => {
|
|
2287
|
+
if (g || nt(f.target) || !h) return;
|
|
2288
|
+
const y = () => {
|
|
2289
|
+
const { x: C, y: B } = t.getBoundingClientRect(), R = f.target instanceof Node && t.contains(f.target) && o.getAt(f.clientX - C, f.clientY - B, a);
|
|
2290
|
+
if (R) {
|
|
2291
|
+
const { selected: K } = i;
|
|
2292
|
+
(K.length !== 1 || K[0].id !== R.id) && i.userSelect(R.id, f);
|
|
2286
2293
|
} else
|
|
2287
2294
|
i.clear();
|
|
2288
|
-
}
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2295
|
+
};
|
|
2296
|
+
if (f.timeStamp - l.timeStamp < ae) {
|
|
2297
|
+
await S();
|
|
2298
|
+
const C = document.getSelection();
|
|
2299
|
+
if (C != null && C.isCollapsed) {
|
|
2300
|
+
c = void 0, y();
|
|
2301
|
+
return;
|
|
2302
|
+
}
|
|
2303
|
+
}
|
|
2304
|
+
c && c.selector.length > 0 && (i.clear(), u(), i.userSelect(c.annotation, Et(f)));
|
|
2305
|
+
}, S = async () => {
|
|
2306
|
+
const f = document.getSelection();
|
|
2307
|
+
let y = !1, x = f == null ? void 0 : f.isCollapsed;
|
|
2308
|
+
const C = () => x || y, B = 2;
|
|
2309
|
+
return setTimeout(() => y = !0, 50), Lo(() => x = f == null ? void 0 : f.isCollapsed, B, C);
|
|
2310
|
+
}, A = (f) => {
|
|
2311
|
+
g = !0;
|
|
2312
|
+
const y = document.getSelection();
|
|
2313
|
+
y != null && y.isCollapsed || ((!c || c.selector.length === 0) && E(f), u(), i.userSelect(c.annotation, Et(f)));
|
|
2314
|
+
}, L = (f) => {
|
|
2315
|
+
p && f.key === "Shift" && c && (document.getSelection().isCollapsed || (i.clear(), u(), i.userSelect(c.annotation, ut(f))));
|
|
2316
|
+
}, T = (f) => {
|
|
2317
|
+
const y = () => setTimeout(() => {
|
|
2301
2318
|
(c == null ? void 0 : c.selector.length) > 0 && (i.clear(), o.addAnnotation({
|
|
2302
2319
|
id: c.annotation,
|
|
2303
2320
|
bodies: [],
|
|
2304
2321
|
target: c
|
|
2305
|
-
}), i.userSelect(c.annotation, ut(
|
|
2322
|
+
}), i.userSelect(c.annotation, ut(f))), document.removeEventListener("selectionchange", y);
|
|
2306
2323
|
}, 100);
|
|
2307
|
-
document.addEventListener("selectionchange",
|
|
2324
|
+
document.addEventListener("selectionchange", y), w(f);
|
|
2308
2325
|
};
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
}),
|
|
2312
|
-
l = ut(
|
|
2326
|
+
P(Oo.join(","), { element: t, keydown: !0, keyup: !1 }, (f) => {
|
|
2327
|
+
f.repeat || (l = ut(f));
|
|
2328
|
+
}), P(Te, { keydown: !0, keyup: !1 }, (f) => {
|
|
2329
|
+
l = ut(f), T(f);
|
|
2313
2330
|
});
|
|
2314
|
-
const
|
|
2315
|
-
|
|
2331
|
+
const O = (f) => {
|
|
2332
|
+
f.repeat || f.target !== t && f.target !== document.body || (c = void 0, i.clear());
|
|
2316
2333
|
};
|
|
2317
|
-
return
|
|
2334
|
+
return P(Oe.join(","), { keydown: !0, keyup: !1 }, O), document.addEventListener("pointerdown", m), document.addEventListener("pointerup", b), document.addEventListener("contextmenu", A), t.addEventListener("keyup", L), t.addEventListener("selectstart", w), document.addEventListener("selectionchange", E), {
|
|
2318
2335
|
destroy: () => {
|
|
2319
|
-
c = void 0,
|
|
2336
|
+
c = void 0, h = void 0, l = void 0, g = !1, E.clear(), document.removeEventListener("pointerdown", m), document.removeEventListener("pointerup", b), document.removeEventListener("contextmenu", A), t.removeEventListener("keyup", L), t.removeEventListener("selectstart", w), document.removeEventListener("selectionchange", E), P.unbind();
|
|
2320
2337
|
},
|
|
2321
2338
|
setFilter: d,
|
|
2322
2339
|
setUser: r,
|
|
2323
|
-
setAnnotatingEnabled:
|
|
2340
|
+
setAnnotatingEnabled: v
|
|
2324
2341
|
};
|
|
2325
|
-
},
|
|
2342
|
+
}, Ro = (t, e) => ({
|
|
2326
2343
|
...t,
|
|
2327
2344
|
annotatingEnabled: t.annotatingEnabled ?? e.annotatingEnabled,
|
|
2328
2345
|
user: t.user || e.user
|
|
2329
|
-
}),
|
|
2346
|
+
}), ce = "SPANS", No = (t, e = {}) => {
|
|
2330
2347
|
Ie(t), _e(t);
|
|
2331
|
-
const n =
|
|
2348
|
+
const n = Ro(e, {
|
|
2332
2349
|
annotatingEnabled: !0,
|
|
2333
2350
|
user: Wn()
|
|
2334
2351
|
}), o = fo(t, n.userSelectAction), { selection: i, viewport: s } = o, r = o.store, a = Vn(r), d = Yn(o, a, n.adapter);
|
|
2335
2352
|
let c = n.user;
|
|
2336
|
-
const
|
|
2353
|
+
const h = n.renderer === "CSS_HIGHLIGHTS" ? CSS.highlights ? "CSS_HIGHLIGHTS" : ce : n.renderer || ce, l = h === "SPANS" ? gn(t, o, s) : h === "CSS_HIGHLIGHTS" ? fn(t, o, s) : h === "CANVAS" ? en(t, o, s) : void 0;
|
|
2337
2354
|
if (!l)
|
|
2338
|
-
throw `Unknown renderer implementation: ${
|
|
2339
|
-
console.debug(`Using ${
|
|
2340
|
-
const
|
|
2341
|
-
|
|
2342
|
-
const
|
|
2343
|
-
|
|
2344
|
-
|
|
2355
|
+
throw `Unknown renderer implementation: ${h}`;
|
|
2356
|
+
console.debug(`Using ${h} renderer`), n.style && l.setStyle(n.style);
|
|
2357
|
+
const g = To(t, o, n.offsetReferenceSelector);
|
|
2358
|
+
g.setUser(c), g.setAnnotatingEnabled(n.annotatingEnabled);
|
|
2359
|
+
const p = Pn(o, a, n.adapter), v = () => c, w = (A) => {
|
|
2360
|
+
g.setAnnotatingEnabled(
|
|
2361
|
+
A === void 0 ? !0 : A
|
|
2345
2362
|
);
|
|
2346
|
-
}, E = (
|
|
2347
|
-
l.setFilter(
|
|
2348
|
-
}, m = (
|
|
2349
|
-
c =
|
|
2350
|
-
}, u = (
|
|
2351
|
-
|
|
2352
|
-
},
|
|
2353
|
-
|
|
2363
|
+
}, E = (A) => {
|
|
2364
|
+
l.setFilter(A), g.setFilter(A);
|
|
2365
|
+
}, m = (A) => {
|
|
2366
|
+
c = A, g.setUser(A);
|
|
2367
|
+
}, u = (A) => {
|
|
2368
|
+
A && (l.setPainter(po(A, n.presence)), A.on("selectionChange", () => l.redraw()));
|
|
2369
|
+
}, b = (A) => {
|
|
2370
|
+
A ? i.setSelected(A) : i.clear();
|
|
2354
2371
|
};
|
|
2355
2372
|
return {
|
|
2356
|
-
...
|
|
2373
|
+
...p,
|
|
2357
2374
|
destroy: () => {
|
|
2358
|
-
l.destroy(),
|
|
2375
|
+
l.destroy(), g.destroy(), a.destroy();
|
|
2359
2376
|
},
|
|
2360
2377
|
element: t,
|
|
2361
|
-
getUser:
|
|
2362
|
-
setAnnotatingEnabled:
|
|
2378
|
+
getUser: v,
|
|
2379
|
+
setAnnotatingEnabled: w,
|
|
2363
2380
|
setFilter: E,
|
|
2364
2381
|
setStyle: l.setStyle.bind(l),
|
|
2365
2382
|
redraw: l.redraw.bind(l),
|
|
2366
2383
|
setUser: m,
|
|
2367
|
-
setSelected:
|
|
2384
|
+
setSelected: b,
|
|
2368
2385
|
setPresenceProvider: u,
|
|
2369
2386
|
setVisible: l.setVisible.bind(l),
|
|
2370
2387
|
on: d.on,
|
|
@@ -2376,27 +2393,27 @@ const re = 300, Le = ["up", "down", "left", "right"], Oe = Ne ? "⌘+a" : "ctrl+
|
|
|
2376
2393
|
export {
|
|
2377
2394
|
vt as DEFAULT_SELECTED_STYLE,
|
|
2378
2395
|
W as DEFAULT_STYLE,
|
|
2379
|
-
|
|
2396
|
+
le as NOT_ANNOTATABLE_CLASS,
|
|
2380
2397
|
Z as NOT_ANNOTATABLE_SELECTOR,
|
|
2381
2398
|
k as Origin,
|
|
2382
2399
|
xn as UserSelectAction,
|
|
2383
|
-
|
|
2400
|
+
Io as W3CTextFormat,
|
|
2384
2401
|
Ie as cancelSingleClickEvents,
|
|
2385
2402
|
ut as cloneKeyboardEvent,
|
|
2386
|
-
|
|
2387
|
-
|
|
2403
|
+
Et as clonePointerEvent,
|
|
2404
|
+
ko as createBody,
|
|
2388
2405
|
en as createCanvasRenderer,
|
|
2389
2406
|
fn as createHighlightsRenderer,
|
|
2390
|
-
|
|
2407
|
+
po as createPresencePainter,
|
|
2391
2408
|
un as createRenderer,
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2409
|
+
To as createSelectionHandler,
|
|
2410
|
+
gn as createSpansRenderer,
|
|
2411
|
+
No as createTextAnnotator,
|
|
2395
2412
|
fo as createTextAnnotatorState,
|
|
2396
|
-
|
|
2397
|
-
|
|
2413
|
+
Bo as denormalizeRectWithOffset,
|
|
2414
|
+
Ro as fillDefaults,
|
|
2398
2415
|
Ue as getQuoteContext,
|
|
2399
|
-
|
|
2416
|
+
Dt as getRangeAnnotatableContents,
|
|
2400
2417
|
Ne as isMac,
|
|
2401
2418
|
nt as isNotAnnotatable,
|
|
2402
2419
|
Me as isRangeAnnotatable,
|
|
@@ -2407,15 +2424,15 @@ export {
|
|
|
2407
2424
|
Fe as paint,
|
|
2408
2425
|
to as parseW3CTextAnnotation,
|
|
2409
2426
|
_e as programmaticallyFocusable,
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2427
|
+
$e as rangeContains,
|
|
2428
|
+
Pe as rangeToSelector,
|
|
2429
|
+
xt as reviveAnnotation,
|
|
2430
|
+
de as reviveSelector,
|
|
2414
2431
|
wt as reviveTarget,
|
|
2415
2432
|
ze as scrollIntoView,
|
|
2416
2433
|
eo as serializeW3CTextAnnotation,
|
|
2417
2434
|
ke as splitAnnotatableRanges,
|
|
2418
|
-
|
|
2435
|
+
Mo as toDomRectList,
|
|
2419
2436
|
je as trimRangeToContainer,
|
|
2420
2437
|
De as whitespaceOrEmptyRegex
|
|
2421
2438
|
};
|