@soomo/text-annotator 3.1.0-staging.10 → 3.1.0-staging.12
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 ce = "not-annotatable", Z = `.${ce}`, 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) => {
|
|
@@ -13,7 +13,7 @@ const le = "not-annotatable", Z = `.${le}`, nt = (t) => {
|
|
|
13
13
|
const e = document.createNodeIterator(
|
|
14
14
|
t.commonAncestorContainer,
|
|
15
15
|
NodeFilter.SHOW_ELEMENT,
|
|
16
|
-
(o) => o instanceof HTMLElement && o.classList.contains(
|
|
16
|
+
(o) => o instanceof HTMLElement && o.classList.contains(ce) && !o.parentElement.closest(Z) && t.intersectsNode(o) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP
|
|
17
17
|
);
|
|
18
18
|
let n;
|
|
19
19
|
for (; n = e.nextNode(); )
|
|
@@ -31,15 +31,15 @@ const le = "not-annotatable", Z = `.${le}`, nt = (t) => {
|
|
|
31
31
|
o.setStartAfter(n), o.collapsed || e.push(o);
|
|
32
32
|
}
|
|
33
33
|
return e.length > 0 ? e : [t];
|
|
34
|
-
},
|
|
34
|
+
}, Ut = (t) => {
|
|
35
35
|
const e = t.cloneContents();
|
|
36
36
|
return e.querySelectorAll(Z).forEach((n) => n.remove()), e;
|
|
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 = Ut(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 = Ut(a).textContent;
|
|
43
43
|
return {
|
|
44
44
|
prefix: r.substring(r.length - n),
|
|
45
45
|
suffix: d.substring(0, n)
|
|
@@ -102,16 +102,16 @@ const le = "not-annotatable", Z = `.${le}`, nt = (t) => {
|
|
|
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 = Ut(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
|
+
}, le = (t, e) => {
|
|
108
|
+
var f, 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
|
-
(
|
|
112
|
+
(m) => {
|
|
113
113
|
var p;
|
|
114
|
-
return (p =
|
|
114
|
+
return (p = m.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 le = "not-annotatable", Z = `.${le}`, 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 m = ((f = d.textContent) == null ? void 0 : f.length) || 0;
|
|
125
|
+
if (r + m > n) {
|
|
126
126
|
a.setStart(d, n - r);
|
|
127
127
|
break;
|
|
128
128
|
}
|
|
129
|
-
r +=
|
|
129
|
+
r += m;
|
|
130
130
|
}
|
|
131
131
|
d = s.nextNode();
|
|
132
132
|
}
|
|
133
133
|
for (; d !== null; ) {
|
|
134
|
-
const
|
|
135
|
-
if (r +
|
|
134
|
+
const m = ((l = d.textContent) == null ? void 0 : l.length) || 0;
|
|
135
|
+
if (r + m >= o) {
|
|
136
136
|
a.setEnd(d, o - r);
|
|
137
137
|
break;
|
|
138
138
|
}
|
|
139
|
-
r +=
|
|
139
|
+
r += m, d = s.nextNode();
|
|
140
140
|
}
|
|
141
141
|
return {
|
|
142
142
|
...t,
|
|
@@ -144,21 +144,21 @@ const le = "not-annotatable", Z = `.${le}`, 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 : le(n, e))
|
|
148
|
+
}, At = (t, e) => F(t.target.selector) ? t : { ...t, target: wt(t.target, e) }, de = (t, e) => {
|
|
149
149
|
if (t.isEqualNode(e))
|
|
150
150
|
return !0;
|
|
151
151
|
for (let n of t.childNodes)
|
|
152
|
-
if (
|
|
152
|
+
if (de(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 de(n, e);
|
|
158
158
|
}, je = (t, e) => {
|
|
159
159
|
const n = t.cloneRange(), o = e.contains(n.startContainer), i = e.contains(n.endContainer);
|
|
160
160
|
return !o && !i && !$e(n, e) ? (n.collapse(), n) : (o || n.setStart(e, 0), i || n.setEnd(e, e.childNodes.length), n);
|
|
161
|
-
},
|
|
161
|
+
}, xt = (t) => ({
|
|
162
162
|
...t,
|
|
163
163
|
type: t.type,
|
|
164
164
|
x: t.x,
|
|
@@ -206,16 +206,16 @@ const le = "not-annotatable", Z = `.${le}`, nt = (t) => {
|
|
|
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
|
+
}, ue = (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 : ue(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,
|
|
217
|
-
s.scroll({ top:
|
|
218
|
-
}, s =
|
|
216
|
+
const a = s.getBoundingClientRect(), d = s.clientHeight, c = s.clientWidth, f = r.selector[0].range.getBoundingClientRect(), { width: l, height: m } = e.getAnnotationBounds(o), p = f.top - a.top, w = f.left - a.left, b = s.parentElement ? s.scrollTop : 0, S = s.parentElement ? s.scrollLeft : 0, g = p + b - (d - m) / 2, u = w + S - (c - l) / 2;
|
|
217
|
+
s.scroll({ top: g, left: u, behavior: "smooth" });
|
|
218
|
+
}, s = ue(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 le = "not-annotatable", Z = `.${le}`, 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 Kt = { exports: {} };
|
|
245
|
+
function fe(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 he(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 m = i, p = s;
|
|
254
|
+
return i = void 0, s = void 0, d = t.apply(m, p), d;
|
|
255
255
|
}
|
|
256
|
-
function
|
|
257
|
-
const
|
|
258
|
-
|
|
256
|
+
function f() {
|
|
257
|
+
const m = Date.now() - a;
|
|
258
|
+
m < e && m >= 0 ? r = setTimeout(f, e - m) : (r = void 0, o || (d = c()));
|
|
259
259
|
}
|
|
260
|
-
const l = function(...
|
|
260
|
+
const l = function(...m) {
|
|
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 =
|
|
263
|
+
i = this, s = m, a = Date.now();
|
|
264
264
|
const p = o && !r;
|
|
265
|
-
return r || (r = setTimeout(
|
|
265
|
+
return r || (r = setTimeout(f, 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 he(t, e = 100, n = {}) {
|
|
|
272
272
|
d = c(), l.clear();
|
|
273
273
|
}, l;
|
|
274
274
|
}
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
var qe =
|
|
278
|
-
const
|
|
275
|
+
Kt.exports.debounce = fe;
|
|
276
|
+
Kt.exports = fe;
|
|
277
|
+
var qe = Kt.exports;
|
|
278
|
+
const Yt = /* @__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,47 +284,47 @@ const Xt = /* @__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
|
+
}, Xt = (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 f = Qe(n), l = (T) => {
|
|
291
|
+
const { x, y: h } = t.getBoundingClientRect(), v = i.getAt(T.clientX - x, T.clientY - h, d);
|
|
292
|
+
v ? r.current !== v.id && (t.classList.add("hovered"), r.set(v.id)) : r.current && (t.classList.remove("hovered"), r.set(null));
|
|
293
293
|
};
|
|
294
294
|
t.addEventListener("pointermove", l);
|
|
295
|
-
const
|
|
295
|
+
const m = (T = !1) => {
|
|
296
296
|
c && c.clear();
|
|
297
|
-
const
|
|
298
|
-
const
|
|
299
|
-
return { annotation: Y, rects:
|
|
297
|
+
const x = Ge(t), { minX: h, minY: v, maxX: A, maxY: L } = x, M = d ? i.getIntersecting(h, v, A, L).filter(({ annotation: Y }) => d(Y)) : i.getIntersecting(h, v, A, L), B = s.selected.map(({ id: Y }) => Y), K = M.map(({ annotation: Y, rects: dt }) => {
|
|
298
|
+
const Te = B.includes(Y.id), Re = Y.id === r.current;
|
|
299
|
+
return { annotation: Y, rects: dt, state: { selected: Te, hover: Re } };
|
|
300
300
|
});
|
|
301
|
-
o.redraw(K,
|
|
302
|
-
}, p = (
|
|
303
|
-
c =
|
|
304
|
-
},
|
|
305
|
-
a =
|
|
306
|
-
},
|
|
307
|
-
d =
|
|
308
|
-
},
|
|
309
|
-
i.observe(
|
|
310
|
-
const
|
|
301
|
+
o.redraw(K, x, a, c, T), setTimeout(() => f(M.map(({ annotation: Y }) => Y)), 1);
|
|
302
|
+
}, p = (T) => {
|
|
303
|
+
c = T, m();
|
|
304
|
+
}, w = (T) => {
|
|
305
|
+
a = T, m();
|
|
306
|
+
}, b = (T) => {
|
|
307
|
+
d = T, m(!1);
|
|
308
|
+
}, S = () => m();
|
|
309
|
+
i.observe(S);
|
|
310
|
+
const g = s.subscribe(() => m()), u = () => m(!0);
|
|
311
311
|
document.addEventListener("scroll", u, { capture: !0, passive: !0 });
|
|
312
|
-
const
|
|
313
|
-
i.recalculatePositions(), c == null || c.reset(),
|
|
312
|
+
const y = Yt(() => {
|
|
313
|
+
i.recalculatePositions(), c == null || c.reset(), m();
|
|
314
314
|
}, 10);
|
|
315
|
-
window.addEventListener("resize",
|
|
316
|
-
const
|
|
317
|
-
|
|
318
|
-
const
|
|
319
|
-
|
|
315
|
+
window.addEventListener("resize", y);
|
|
316
|
+
const C = new ResizeObserver(y);
|
|
317
|
+
C.observe(t);
|
|
318
|
+
const E = { attributes: !0, childList: !0, subtree: !0 }, O = new MutationObserver((T) => {
|
|
319
|
+
T.every((h) => h.target === t || t.contains(h.target)) || m(!0);
|
|
320
320
|
});
|
|
321
|
-
return
|
|
321
|
+
return O.observe(document.body, E), {
|
|
322
322
|
destroy: () => {
|
|
323
|
-
t.removeEventListener("pointermove", l), o.destroy(), i.unobserve(
|
|
323
|
+
t.removeEventListener("pointermove", l), o.destroy(), i.unobserve(S), g(), document.removeEventListener("scroll", u), y.clear(), window.removeEventListener("resize", y), C.disconnect(), O.disconnect();
|
|
324
324
|
},
|
|
325
|
-
redraw:
|
|
326
|
-
setStyle:
|
|
327
|
-
setFilter:
|
|
325
|
+
redraw: m,
|
|
326
|
+
setStyle: w,
|
|
327
|
+
setFilter: b,
|
|
328
328
|
setPainter: p,
|
|
329
329
|
setVisible: o.setVisible
|
|
330
330
|
};
|
|
@@ -337,32 +337,32 @@ const Xt = /* @__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: p, left:
|
|
344
|
-
[...a].sort((
|
|
345
|
-
const { annotation: { target: { created: u } } } =
|
|
346
|
-
return u.getTime() -
|
|
347
|
-
}).forEach((
|
|
348
|
-
var
|
|
349
|
-
const
|
|
350
|
-
x:
|
|
351
|
-
y:
|
|
352
|
-
width:
|
|
353
|
-
height:
|
|
340
|
+
const o = (a, d, c, f) => requestAnimationFrame(() => {
|
|
341
|
+
const { width: l, height: m } = e;
|
|
342
|
+
n.clearRect(-0.5, -0.5, l + 1, m + 1), f && f.clear();
|
|
343
|
+
const { top: p, left: w } = d;
|
|
344
|
+
[...a].sort((S, g) => {
|
|
345
|
+
const { annotation: { target: { created: u } } } = S, { annotation: { target: { created: y } } } = g;
|
|
346
|
+
return u.getTime() - y.getTime();
|
|
347
|
+
}).forEach((S) => {
|
|
348
|
+
var C;
|
|
349
|
+
const g = c ? typeof c == "function" ? c(S.annotation, S.state) : c : (C = S.state) != null && C.selected ? vt : W, u = f && f.paint(S, d) || g, y = S.rects.map(({ x: E, y: O, width: R, height: T }) => ({
|
|
350
|
+
x: E + w,
|
|
351
|
+
y: O + p,
|
|
352
|
+
width: R,
|
|
353
|
+
height: T
|
|
354
354
|
}));
|
|
355
|
-
if (n.fillStyle = u.fill, n.globalAlpha = u.fillOpacity || 1,
|
|
356
|
-
({ x:
|
|
355
|
+
if (n.fillStyle = u.fill, n.globalAlpha = u.fillOpacity || 1, y.forEach(
|
|
356
|
+
({ x: E, y: O, width: R, height: T }) => n.fillRect(E, O, R, T)
|
|
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(
|
|
359
|
+
const E = u.underlineOffset ?? 0;
|
|
360
|
+
y.forEach(({ x: O, y: R, width: T, height: x }) => {
|
|
361
|
+
n.beginPath(), n.moveTo(O, R + x + E), n.lineTo(O + T, R + x + E), n.stroke();
|
|
362
362
|
});
|
|
363
363
|
}
|
|
364
364
|
});
|
|
365
|
-
}), i =
|
|
365
|
+
}), i = Yt(() => Ze(e), 10);
|
|
366
366
|
return window.addEventListener("resize", i), {
|
|
367
367
|
destroy: () => {
|
|
368
368
|
e.remove(), i.clear(), window.removeEventListener("resize", i);
|
|
@@ -372,123 +372,123 @@ const Xt = /* @__PURE__ */ We(qe), Ge = (t) => {
|
|
|
372
372
|
},
|
|
373
373
|
redraw: o
|
|
374
374
|
};
|
|
375
|
-
}, en = (t, e, n) =>
|
|
375
|
+
}, en = (t, e, n) => Xt(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
|
+
}, he = function(t) {
|
|
383
383
|
return (t = isFinite(t) ? t % 360 : 0) > 0 ? t : t + 360;
|
|
384
|
-
},
|
|
384
|
+
}, jt = 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
|
+
}, Et = 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);
|
|
390
390
|
return e.length < 2 ? "0" + e : e;
|
|
391
|
-
},
|
|
391
|
+
}, pe = 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
|
+
}, ge = 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) };
|
|
399
401
|
}, zt = function(t) {
|
|
400
|
-
return { h: pe(t.h), s: X(t.s, 0, 100), l: X(t.l, 0, 100), a: X(t.a) };
|
|
401
|
-
}, Ft = function(t) {
|
|
402
402
|
return { h: _(t.h), s: _(t.s), l: _(t.l), a: _(t.a, 3) };
|
|
403
|
-
},
|
|
404
|
-
return
|
|
403
|
+
}, Ft = function(t) {
|
|
404
|
+
return ge((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
|
-
return { h: (e =
|
|
407
|
+
return { h: (e = pe(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, Wt = { 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 : jt({ 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 = Ht({ 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 Ft(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) ? jt({ 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 = Ht({ h: Number(e), s: Number(n), l: Number(o), a: Number(s) });
|
|
427
|
+
return Ft(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: he(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 ge(r);
|
|
435
|
+
}, "hsv"]] }, qt = 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" ? qt(t.trim(), Wt.string) : typeof t == "object" && t !== null ? qt(t, Wt.object) : [null, void 0];
|
|
443
|
+
}, St = 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
|
+
}, Ct = function(t) {
|
|
447
447
|
return (299 * t.r + 587 * t.g + 114 * t.b) / 1e3 / 255;
|
|
448
|
-
},
|
|
448
|
+
}, Gt = 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
|
+
}, Qt = 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 _(Ct(this.rgba), 2);
|
|
459
459
|
}, t.prototype.isDark = function() {
|
|
460
|
-
return
|
|
460
|
+
return Ct(this.rgba) < 0.5;
|
|
461
461
|
}, t.prototype.isLight = function() {
|
|
462
|
-
return
|
|
462
|
+
return Ct(this.rgba) >= 0.5;
|
|
463
463
|
}, t.prototype.toHex = function() {
|
|
464
|
-
return e =
|
|
464
|
+
return e = Et(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 Et(this.rgba);
|
|
468
468
|
}, t.prototype.toRgbString = function() {
|
|
469
|
-
return e =
|
|
469
|
+
return e = Et(this.rgba), n = e.r, o = e.g, i = e.b, (s = e.a) < 1 ? "rgba(" + n + ", " + o + ", " + i + ", " + s + ")" : "rgb(" + n + ", " + o + ", " + i + ")";
|
|
470
470
|
var e, n, o, i, s;
|
|
471
471
|
}, t.prototype.toHsl = function() {
|
|
472
|
-
return
|
|
472
|
+
return zt(st(this.rgba));
|
|
473
473
|
}, t.prototype.toHslString = function() {
|
|
474
|
-
return e =
|
|
474
|
+
return e = zt(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
|
-
return e =
|
|
477
|
+
return e = pe(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
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), $(St(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), $(St(this.rgba, -e));
|
|
486
486
|
}, t.prototype.grayscale = function() {
|
|
487
|
-
return $(
|
|
487
|
+
return $(St(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), $(Gt(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), $(Gt(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) {
|
|
@@ -501,7 +501,7 @@ var nn = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, H = function(t) {
|
|
|
501
501
|
return this.toHex() === $(e).toHex();
|
|
502
502
|
}, t;
|
|
503
503
|
}(), $ = function(t) {
|
|
504
|
-
return t instanceof
|
|
504
|
+
return t instanceof Qt ? t : new Qt(t);
|
|
505
505
|
};
|
|
506
506
|
const dn = (t) => [
|
|
507
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()}`,
|
|
@@ -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
|
|
527
|
+
const f = s.map((l) => {
|
|
528
|
+
var w;
|
|
529
|
+
const m = a ? typeof a == "function" ? a(l.annotation, l.state) : a : (w = l.state) != null && w.selected ? vt : W, p = d && d.paint(l, r) || m;
|
|
530
530
|
return `::highlight(_${l.annotation.id}) { ${dn(p)} }`;
|
|
531
531
|
});
|
|
532
|
-
t.innerHTML =
|
|
532
|
+
t.innerHTML = f.join(`
|
|
533
533
|
`), CSS.highlights.clear(), s.forEach(({ annotation: l }) => {
|
|
534
|
-
const
|
|
534
|
+
const m = l.target.selector.map((w) => w.range), p = new Highlight(...m);
|
|
535
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) => Xt(t, e, n, un());
|
|
540
|
+
var Jt = Object.prototype.hasOwnProperty;
|
|
541
|
+
function Dt(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 Vt(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-- && Dt(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 (Jt.call(t, n) && ++o && !Jt.call(e, n) || !(n in e) || !Dt(t[n], e[n])) return !1;
|
|
556
556
|
return Object.keys(e).length === o;
|
|
557
557
|
}
|
|
558
558
|
}
|
|
@@ -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:
|
|
578
|
-
return
|
|
579
|
-
}).forEach((
|
|
580
|
-
|
|
581
|
-
const
|
|
582
|
-
if (
|
|
573
|
+
redraw: (r, a, d, c, f) => {
|
|
574
|
+
const m = !(Dt(n, r) && f);
|
|
575
|
+
if (!c && !m) return;
|
|
576
|
+
m && (e.innerHTML = ""), [...r].sort((w, b) => {
|
|
577
|
+
const { annotation: { target: { created: S } } } = w, { annotation: { target: { created: g } } } = b;
|
|
578
|
+
return S && g ? S.getTime() - g.getTime() : 0;
|
|
579
|
+
}).forEach((w) => {
|
|
580
|
+
w.rects.map((b) => {
|
|
581
|
+
const S = hn(b, r), g = Fe(w, a, d, c, S);
|
|
582
|
+
if (m) {
|
|
583
583
|
const u = document.createElement("span");
|
|
584
|
-
u.className = "r6o-annotation", u.dataset.annotation =
|
|
584
|
+
u.className = "r6o-annotation", u.dataset.annotation = w.annotation.id, u.style.left = `${b.x}px`, u.style.top = `${b.y}px`, u.style.width = `${b.width}px`, u.style.height = `${b.height}px`, u.style.backgroundColor = $((g == null ? void 0 : g.fill) || W.fill).alpha((g == null ? void 0 : g.fillOpacity) === void 0 ? W.fillOpacity : g.fillOpacity).toHex(), g.underlineStyle && (u.style.borderStyle = g.underlineStyle), g.underlineColor && (u.style.borderColor = g.underlineColor), g.underlineThickness && (u.style.borderBottomWidth = `${g.underlineThickness}px`), g.underlineOffset && (u.style.paddingBottom = `${g.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
|
-
}, gn = (t, e, n) =>
|
|
593
|
+
}, gn = (t, e, n) => Xt(t, e, n, pn(t));
|
|
594
594
|
var U = [];
|
|
595
|
-
for (var
|
|
596
|
-
U.push((
|
|
595
|
+
for (var Lt = 0; Lt < 256; ++Lt)
|
|
596
|
+
U.push((Lt + 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 Zt = {
|
|
608
608
|
randomUUID: wn
|
|
609
609
|
};
|
|
610
|
-
function
|
|
611
|
-
if (
|
|
612
|
-
return
|
|
610
|
+
function me(t, e, n) {
|
|
611
|
+
if (Zt.randomUUID && !e && !t)
|
|
612
|
+
return Zt.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 te = 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 (te.call(t, n) && ++o && !te.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 Ot() {
|
|
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
|
|
644
|
+
function Pt(t, e = Ot) {
|
|
645
645
|
let n;
|
|
646
646
|
const o = /* @__PURE__ */ new Set();
|
|
647
647
|
function i(a) {
|
|
@@ -659,16 +659,16 @@ function $t(t, e = Tt) {
|
|
|
659
659
|
function s(a) {
|
|
660
660
|
i(a(t));
|
|
661
661
|
}
|
|
662
|
-
function r(a, d =
|
|
662
|
+
function r(a, d = Ot) {
|
|
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) || Ot), a(t), () => {
|
|
665
665
|
o.delete(c), o.size === 0 && n && (n(), n = null);
|
|
666
666
|
};
|
|
667
667
|
}
|
|
668
668
|
return { set: i, update: s, subscribe: r };
|
|
669
669
|
}
|
|
670
670
|
const An = (t) => {
|
|
671
|
-
const { subscribe: e, set: n } =
|
|
671
|
+
const { subscribe: e, set: n } = Pt();
|
|
672
672
|
let o;
|
|
673
673
|
return e((i) => o = i), t.observe(({ changes: i }) => {
|
|
674
674
|
if (o) {
|
|
@@ -686,51 +686,51 @@ const An = (t) => {
|
|
|
686
686
|
};
|
|
687
687
|
var xn = /* @__PURE__ */ ((t) => (t.EDIT = "EDIT", t.SELECT = "SELECT", t.NONE = "NONE", t))(xn || {});
|
|
688
688
|
const pt = { selected: [] }, En = (t, e, n) => {
|
|
689
|
-
const { subscribe: o, set: i } =
|
|
689
|
+
const { subscribe: o, set: i } = Pt(pt);
|
|
690
690
|
let s = e, r = pt;
|
|
691
|
-
o((
|
|
691
|
+
o((w) => r = w);
|
|
692
692
|
const a = () => {
|
|
693
693
|
q(r, pt) || i(pt);
|
|
694
694
|
}, d = () => {
|
|
695
|
-
var
|
|
696
|
-
return ((
|
|
697
|
-
}, c = (
|
|
695
|
+
var w;
|
|
696
|
+
return ((w = r.selected) == null ? void 0 : w.length) === 0;
|
|
697
|
+
}, c = (w) => {
|
|
698
698
|
if (d())
|
|
699
699
|
return !1;
|
|
700
|
-
const
|
|
701
|
-
return r.selected.some((
|
|
702
|
-
},
|
|
703
|
-
const
|
|
704
|
-
if (!
|
|
705
|
-
console.warn("Invalid selection: " +
|
|
700
|
+
const b = typeof w == "string" ? w : w.id;
|
|
701
|
+
return r.selected.some((S) => S.id === b);
|
|
702
|
+
}, f = (w, b) => {
|
|
703
|
+
const S = t.getAnnotation(w);
|
|
704
|
+
if (!S) {
|
|
705
|
+
console.warn("Invalid selection: " + w);
|
|
706
706
|
return;
|
|
707
707
|
}
|
|
708
|
-
switch (
|
|
708
|
+
switch (ee(S, s)) {
|
|
709
709
|
case "EDIT":
|
|
710
|
-
i({ selected: [{ id:
|
|
710
|
+
i({ selected: [{ id: w, editable: !0 }], event: b });
|
|
711
711
|
break;
|
|
712
712
|
case "SELECT":
|
|
713
|
-
i({ selected: [{ id:
|
|
713
|
+
i({ selected: [{ id: w }], event: b });
|
|
714
714
|
break;
|
|
715
715
|
default:
|
|
716
|
-
i({ selected: [], event:
|
|
716
|
+
i({ selected: [], event: b });
|
|
717
717
|
}
|
|
718
|
-
}, l = (
|
|
719
|
-
const
|
|
718
|
+
}, l = (w, b) => {
|
|
719
|
+
const S = Array.isArray(w) ? w : [w], g = S.map((u) => t.getAnnotation(u)).filter((u) => !!u);
|
|
720
720
|
i({
|
|
721
|
-
selected:
|
|
722
|
-
const
|
|
723
|
-
return { id: u.id, editable:
|
|
721
|
+
selected: g.map((u) => {
|
|
722
|
+
const y = b === void 0 ? ee(u, s) === "EDIT" : b;
|
|
723
|
+
return { id: u.id, editable: y };
|
|
724
724
|
})
|
|
725
|
-
}),
|
|
726
|
-
},
|
|
725
|
+
}), g.length !== S.length && console.warn("Invalid selection", w);
|
|
726
|
+
}, m = (w) => {
|
|
727
727
|
if (d())
|
|
728
728
|
return !1;
|
|
729
|
-
const { selected:
|
|
730
|
-
|
|
731
|
-
}, p = (
|
|
729
|
+
const { selected: b } = r;
|
|
730
|
+
b.some(({ id: S }) => w.includes(S)) && i({ selected: b.filter(({ id: S }) => !w.includes(S)) });
|
|
731
|
+
}, p = (w) => s = w;
|
|
732
732
|
return t.observe(
|
|
733
|
-
({ changes:
|
|
733
|
+
({ changes: w }) => m((w.deleted || []).map((b) => b.id))
|
|
734
734
|
), {
|
|
735
735
|
get event() {
|
|
736
736
|
return r ? r.event : null;
|
|
@@ -747,12 +747,12 @@ const pt = { selected: [] }, En = (t, e, n) => {
|
|
|
747
747
|
setSelected: l,
|
|
748
748
|
setUserSelectAction: p,
|
|
749
749
|
subscribe: o,
|
|
750
|
-
userSelect:
|
|
750
|
+
userSelect: f
|
|
751
751
|
};
|
|
752
|
-
},
|
|
752
|
+
}, ee = (t, e, n) => typeof e == "function" ? e(t) : e || "EDIT";
|
|
753
753
|
var D = [];
|
|
754
|
-
for (var
|
|
755
|
-
D.push((
|
|
754
|
+
for (var Tt = 0; Tt < 256; ++Tt)
|
|
755
|
+
D.push((Tt + 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
|
}
|
|
@@ -763,17 +763,17 @@ function Ln() {
|
|
|
763
763
|
return gt(Cn);
|
|
764
764
|
}
|
|
765
765
|
var On = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
|
|
766
|
-
const
|
|
766
|
+
const ne = {
|
|
767
767
|
randomUUID: On
|
|
768
768
|
};
|
|
769
|
-
function
|
|
770
|
-
if (
|
|
771
|
-
return
|
|
769
|
+
function ye(t, e, n) {
|
|
770
|
+
if (ne.randomUUID && !e && !t)
|
|
771
|
+
return ne.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 Rt = (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;
|
|
@@ -784,7 +784,7 @@ const Mt = (t) => {
|
|
|
784
784
|
target: e(t.target)
|
|
785
785
|
};
|
|
786
786
|
}, ko = (t, e, n, o) => ({
|
|
787
|
-
id:
|
|
787
|
+
id: ye(),
|
|
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 Mt = (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), be = (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((f) => a(f.bodiesCreated) || a(f.bodiesDeleted) || a(f.bodiesUpdated)), c = (o = i.updated) == null ? void 0 : o.some((f) => f.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: m }) => m.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
|
+
], f = [
|
|
843
843
|
...(t.updated || []).filter(({ newValue: l }) => !s.has(l.id)).map((l) => {
|
|
844
|
-
const { oldValue:
|
|
844
|
+
const { oldValue: m, newValue: p } = l;
|
|
845
845
|
if (r.has(p.id)) {
|
|
846
|
-
const
|
|
847
|
-
return
|
|
846
|
+
const w = e.updated.find((b) => b.oldValue.id === p.id).newValue;
|
|
847
|
+
return be(m, w);
|
|
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: f };
|
|
854
|
+
}, Mt = (t) => {
|
|
855
|
+
const e = t.id === void 0 ? ye() : 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 = (h, v = {}) => {
|
|
870
|
+
n.push({ onChange: h, options: v });
|
|
871
|
+
}, i = (h) => {
|
|
872
|
+
const v = n.findIndex((A) => A.onChange == h);
|
|
873
|
+
v > -1 && n.splice(v, 1);
|
|
874
|
+
}, s = (h, v) => {
|
|
875
|
+
const A = {
|
|
876
|
+
origin: h,
|
|
877
877
|
changes: {
|
|
878
|
-
created:
|
|
879
|
-
updated:
|
|
880
|
-
deleted:
|
|
878
|
+
created: v.created || [],
|
|
879
|
+
updated: v.updated || [],
|
|
880
|
+
deleted: v.deleted || []
|
|
881
881
|
},
|
|
882
882
|
state: [...t.values()]
|
|
883
883
|
};
|
|
884
|
-
n.forEach((
|
|
885
|
-
kn(
|
|
884
|
+
n.forEach((L) => {
|
|
885
|
+
kn(L, A) && L.onChange(A);
|
|
886
886
|
});
|
|
887
|
-
}, r = (
|
|
888
|
-
if (
|
|
889
|
-
throw Error(`Cannot add annotation ${
|
|
887
|
+
}, r = (h, v = k.LOCAL) => {
|
|
888
|
+
if (h.id && t.get(h.id))
|
|
889
|
+
throw Error(`Cannot add annotation ${h.id} - exists already`);
|
|
890
890
|
{
|
|
891
|
-
const
|
|
892
|
-
t.set(
|
|
891
|
+
const A = Mt(h);
|
|
892
|
+
t.set(A.id, A), A.bodies.forEach((L) => e.set(L.id, A.id)), s(v, { created: [A] });
|
|
893
893
|
}
|
|
894
|
-
}, a = (
|
|
895
|
-
const
|
|
896
|
-
if (
|
|
897
|
-
const
|
|
898
|
-
return
|
|
894
|
+
}, a = (h, v) => {
|
|
895
|
+
const A = Mt(typeof h == "string" ? v : h), L = typeof h == "string" ? h : h.id, M = L && t.get(L);
|
|
896
|
+
if (M) {
|
|
897
|
+
const B = be(M, A);
|
|
898
|
+
return L === A.id ? t.set(L, A) : (t.delete(L), t.set(A.id, A)), M.bodies.forEach((K) => e.delete(K.id)), A.bodies.forEach((K) => e.set(K.id, A.id)), B;
|
|
899
899
|
} else
|
|
900
|
-
console.warn(`Cannot update annotation ${
|
|
901
|
-
}, d = (
|
|
902
|
-
const
|
|
903
|
-
|
|
904
|
-
}, c = (
|
|
905
|
-
const
|
|
906
|
-
const
|
|
907
|
-
return
|
|
900
|
+
console.warn(`Cannot update annotation ${L} - does not exist`);
|
|
901
|
+
}, d = (h, v = k.LOCAL, A = k.LOCAL) => {
|
|
902
|
+
const L = Nn(v) ? A : v, M = a(h, v);
|
|
903
|
+
M && s(L, { updated: [M] });
|
|
904
|
+
}, c = (h, v = k.LOCAL) => {
|
|
905
|
+
const A = h.reduce((L, M) => {
|
|
906
|
+
const B = a(M);
|
|
907
|
+
return B ? [...L, B] : L;
|
|
908
908
|
}, []);
|
|
909
|
-
|
|
910
|
-
},
|
|
911
|
-
const
|
|
912
|
-
if (
|
|
913
|
-
const
|
|
914
|
-
...
|
|
915
|
-
bodies: [...
|
|
909
|
+
A.length > 0 && s(v, { updated: A });
|
|
910
|
+
}, f = (h, v = k.LOCAL) => {
|
|
911
|
+
const A = t.get(h.annotation);
|
|
912
|
+
if (A) {
|
|
913
|
+
const L = {
|
|
914
|
+
...A,
|
|
915
|
+
bodies: [...A.bodies, h]
|
|
916
916
|
};
|
|
917
|
-
t.set(
|
|
918
|
-
oldValue:
|
|
919
|
-
newValue:
|
|
920
|
-
bodiesCreated: [
|
|
917
|
+
t.set(A.id, L), e.set(h.id, L.id), s(v, { updated: [{
|
|
918
|
+
oldValue: A,
|
|
919
|
+
newValue: L,
|
|
920
|
+
bodiesCreated: [h]
|
|
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
|
-
}, p = (
|
|
928
|
-
const
|
|
929
|
-
if (
|
|
930
|
-
const
|
|
931
|
-
t.clear(), e.clear(),
|
|
932
|
-
t.set(
|
|
933
|
-
}), s(
|
|
923
|
+
console.warn(`Attempt to add body to missing annotation: ${h.annotation}`);
|
|
924
|
+
}, l = () => [...t.values()], m = (h = k.LOCAL) => {
|
|
925
|
+
const v = [...t.values()];
|
|
926
|
+
t.clear(), e.clear(), s(h, { deleted: v });
|
|
927
|
+
}, p = (h, v = !0, A = k.LOCAL) => {
|
|
928
|
+
const L = h.map(Mt);
|
|
929
|
+
if (v) {
|
|
930
|
+
const M = [...t.values()];
|
|
931
|
+
t.clear(), e.clear(), L.forEach((B) => {
|
|
932
|
+
t.set(B.id, B), B.bodies.forEach((K) => e.set(K.id, B.id));
|
|
933
|
+
}), s(A, { created: L, deleted: M });
|
|
934
934
|
} else {
|
|
935
|
-
const
|
|
935
|
+
const M = h.reduce((B, K) => {
|
|
936
936
|
const Y = K.id && t.get(K.id);
|
|
937
|
-
return Y ? [...
|
|
937
|
+
return Y ? [...B, Y] : B;
|
|
938
938
|
}, []);
|
|
939
|
-
if (
|
|
940
|
-
throw Error(`Bulk insert would overwrite the following annotations: ${
|
|
941
|
-
|
|
942
|
-
t.set(
|
|
943
|
-
}), s(
|
|
939
|
+
if (M.length > 0)
|
|
940
|
+
throw Error(`Bulk insert would overwrite the following annotations: ${M.map((B) => B.id).join(", ")}`);
|
|
941
|
+
L.forEach((B) => {
|
|
942
|
+
t.set(B.id, B), B.bodies.forEach((K) => e.set(K.id, B.id));
|
|
943
|
+
}), s(A, { created: L });
|
|
944
944
|
}
|
|
945
|
-
},
|
|
946
|
-
const
|
|
947
|
-
if (
|
|
948
|
-
return t.delete(
|
|
949
|
-
console.warn(`Attempt to delete missing annotation: ${
|
|
950
|
-
},
|
|
951
|
-
const
|
|
952
|
-
|
|
953
|
-
},
|
|
954
|
-
const
|
|
955
|
-
const
|
|
956
|
-
return
|
|
945
|
+
}, w = (h) => {
|
|
946
|
+
const v = typeof h == "string" ? h : h.id, A = t.get(v);
|
|
947
|
+
if (A)
|
|
948
|
+
return t.delete(v), A.bodies.forEach((L) => e.delete(L.id)), A;
|
|
949
|
+
console.warn(`Attempt to delete missing annotation: ${v}`);
|
|
950
|
+
}, b = (h, v = k.LOCAL) => {
|
|
951
|
+
const A = w(h);
|
|
952
|
+
A && s(v, { deleted: [A] });
|
|
953
|
+
}, S = (h, v = k.LOCAL) => {
|
|
954
|
+
const A = h.reduce((L, M) => {
|
|
955
|
+
const B = w(M);
|
|
956
|
+
return B ? [...L, B] : L;
|
|
957
957
|
}, []);
|
|
958
|
-
|
|
959
|
-
},
|
|
960
|
-
const
|
|
961
|
-
if (
|
|
962
|
-
const
|
|
963
|
-
if (
|
|
964
|
-
e.delete(
|
|
965
|
-
const
|
|
966
|
-
...
|
|
967
|
-
bodies:
|
|
958
|
+
A.length > 0 && s(v, { deleted: A });
|
|
959
|
+
}, g = (h) => {
|
|
960
|
+
const v = t.get(h.annotation);
|
|
961
|
+
if (v) {
|
|
962
|
+
const A = v.bodies.find((L) => L.id === h.id);
|
|
963
|
+
if (A) {
|
|
964
|
+
e.delete(A.id);
|
|
965
|
+
const L = {
|
|
966
|
+
...v,
|
|
967
|
+
bodies: v.bodies.filter((M) => M.id !== h.id)
|
|
968
968
|
};
|
|
969
|
-
return t.set(
|
|
970
|
-
oldValue:
|
|
971
|
-
newValue:
|
|
972
|
-
bodiesDeleted: [
|
|
969
|
+
return t.set(v.id, L), {
|
|
970
|
+
oldValue: v,
|
|
971
|
+
newValue: L,
|
|
972
|
+
bodiesDeleted: [A]
|
|
973
973
|
};
|
|
974
974
|
} else
|
|
975
|
-
console.warn(`Attempt to delete missing body ${
|
|
975
|
+
console.warn(`Attempt to delete missing body ${h.id} from annotation ${h.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 ${h.annotation}`);
|
|
978
|
+
}, u = (h, v = k.LOCAL) => {
|
|
979
|
+
const A = g(h);
|
|
980
|
+
A && s(v, { updated: [A] });
|
|
981
|
+
}, y = (h, v = k.LOCAL) => {
|
|
982
|
+
const A = h.map((L) => g(L)).filter(Boolean);
|
|
983
|
+
A.length > 0 && s(v, { updated: A });
|
|
984
|
+
}, C = (h) => {
|
|
985
|
+
const v = t.get(h);
|
|
986
|
+
return v ? { ...v } : void 0;
|
|
987
|
+
}, E = (h) => {
|
|
988
|
+
const v = e.get(h);
|
|
989
|
+
if (v) {
|
|
990
|
+
const A = C(v).bodies.find((L) => L.id === h);
|
|
991
|
+
if (A)
|
|
992
|
+
return A;
|
|
993
|
+
console.error(`Store integrity error: body ${h} in index, but not in annotation`);
|
|
994
994
|
} else
|
|
995
|
-
console.warn(`Attempt to retrieve missing body: ${
|
|
996
|
-
},
|
|
997
|
-
if (
|
|
995
|
+
console.warn(`Attempt to retrieve missing body: ${h}`);
|
|
996
|
+
}, O = (h, v) => {
|
|
997
|
+
if (h.annotation !== v.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 A = t.get(h.annotation);
|
|
1000
|
+
if (A) {
|
|
1001
|
+
const L = A.bodies.find((B) => B.id === h.id), M = {
|
|
1002
|
+
...A,
|
|
1003
|
+
bodies: A.bodies.map((B) => B.id === L.id ? v : B)
|
|
1004
1004
|
};
|
|
1005
|
-
return t.set(
|
|
1006
|
-
oldValue:
|
|
1007
|
-
newValue:
|
|
1008
|
-
bodiesUpdated: [{ oldBody:
|
|
1005
|
+
return t.set(A.id, M), L.id !== v.id && (e.delete(L.id), e.set(v.id, M.id)), {
|
|
1006
|
+
oldValue: A,
|
|
1007
|
+
newValue: M,
|
|
1008
|
+
bodiesUpdated: [{ oldBody: L, newBody: v }]
|
|
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 ${h.annotation}`);
|
|
1012
|
+
}, R = (h, v, A = k.LOCAL) => {
|
|
1013
|
+
const L = O(h, v);
|
|
1014
|
+
L && s(A, { updated: [L] });
|
|
1015
|
+
}, T = (h, v = k.LOCAL) => {
|
|
1016
|
+
const A = h.map((L) => O({ id: L.id, annotation: L.annotation }, L)).filter(Boolean);
|
|
1017
|
+
s(v, { updated: A });
|
|
1018
|
+
}, x = (h) => {
|
|
1019
|
+
const v = t.get(h.annotation);
|
|
1020
|
+
if (v) {
|
|
1021
|
+
const A = {
|
|
1022
|
+
...v,
|
|
1023
1023
|
target: {
|
|
1024
|
-
...
|
|
1025
|
-
...
|
|
1024
|
+
...v.target,
|
|
1025
|
+
...h
|
|
1026
1026
|
}
|
|
1027
1027
|
};
|
|
1028
|
-
return t.set(
|
|
1029
|
-
oldValue:
|
|
1030
|
-
newValue:
|
|
1028
|
+
return t.set(v.id, A), {
|
|
1029
|
+
oldValue: v,
|
|
1030
|
+
newValue: A,
|
|
1031
1031
|
targetUpdated: {
|
|
1032
|
-
oldTarget:
|
|
1033
|
-
newTarget:
|
|
1032
|
+
oldTarget: v.target,
|
|
1033
|
+
newTarget: h
|
|
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: ${h.annotation}`);
|
|
1038
1038
|
};
|
|
1039
1039
|
return {
|
|
1040
1040
|
addAnnotation: r,
|
|
1041
|
-
addBody:
|
|
1041
|
+
addBody: f,
|
|
1042
1042
|
all: l,
|
|
1043
1043
|
bulkAddAnnotation: p,
|
|
1044
|
-
bulkDeleteAnnotation:
|
|
1045
|
-
bulkDeleteBodies:
|
|
1044
|
+
bulkDeleteAnnotation: S,
|
|
1045
|
+
bulkDeleteBodies: y,
|
|
1046
1046
|
bulkUpdateAnnotation: c,
|
|
1047
|
-
bulkUpdateBodies:
|
|
1048
|
-
bulkUpdateTargets: (
|
|
1049
|
-
const
|
|
1050
|
-
|
|
1047
|
+
bulkUpdateBodies: T,
|
|
1048
|
+
bulkUpdateTargets: (h, v = k.LOCAL) => {
|
|
1049
|
+
const A = h.map((L) => x(L)).filter(Boolean);
|
|
1050
|
+
A.length > 0 && s(v, { updated: A });
|
|
1051
1051
|
},
|
|
1052
|
-
clear:
|
|
1053
|
-
deleteAnnotation:
|
|
1052
|
+
clear: m,
|
|
1053
|
+
deleteAnnotation: b,
|
|
1054
1054
|
deleteBody: u,
|
|
1055
|
-
getAnnotation:
|
|
1056
|
-
getBody:
|
|
1055
|
+
getAnnotation: C,
|
|
1056
|
+
getBody: E,
|
|
1057
1057
|
observe: o,
|
|
1058
1058
|
unobserve: i,
|
|
1059
1059
|
updateAnnotation: d,
|
|
1060
|
-
updateBody:
|
|
1061
|
-
updateTarget: (
|
|
1062
|
-
const
|
|
1063
|
-
|
|
1060
|
+
updateBody: R,
|
|
1061
|
+
updateTarget: (h, v = k.LOCAL) => {
|
|
1062
|
+
const A = x(h);
|
|
1063
|
+
A && s(v, { updated: [A] });
|
|
1064
1064
|
}
|
|
1065
1065
|
};
|
|
1066
1066
|
};
|
|
@@ -1083,113 +1083,113 @@ const Dn = 250, Vn = (t) => {
|
|
|
1083
1083
|
let o = -1, i = !1, s = 0;
|
|
1084
1084
|
const r = (p) => {
|
|
1085
1085
|
if (!i) {
|
|
1086
|
-
const { changes:
|
|
1087
|
-
if (
|
|
1088
|
-
n.splice(o + 1), n.push(
|
|
1086
|
+
const { changes: w } = p, b = performance.now();
|
|
1087
|
+
if (b - s > Dn)
|
|
1088
|
+
n.splice(o + 1), n.push(w), o = n.length - 1;
|
|
1089
1089
|
else {
|
|
1090
|
-
const
|
|
1091
|
-
n[
|
|
1090
|
+
const S = n.length - 1;
|
|
1091
|
+
n[S] = In(n[S], w);
|
|
1092
1092
|
}
|
|
1093
|
-
s =
|
|
1093
|
+
s = b;
|
|
1094
1094
|
}
|
|
1095
1095
|
i = !1;
|
|
1096
1096
|
};
|
|
1097
1097
|
t.observe(r, { origin: k.LOCAL });
|
|
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:
|
|
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: w }) => w)), f = (p) => p && p.length > 0 && t.bulkUpdateAnnotation(p.map(({ newValue: w }) => w)), l = (p) => p && p.length > 0 && t.bulkAddAnnotation(p, !1), m = (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: (p,
|
|
1103
|
+
on: (p, w) => e.on(p, w),
|
|
1104
1104
|
redo: () => {
|
|
1105
1105
|
if (n.length - 1 > o) {
|
|
1106
1106
|
i = !0;
|
|
1107
|
-
const { created: p, updated:
|
|
1108
|
-
d(p),
|
|
1107
|
+
const { created: p, updated: w, deleted: b } = n[o + 1];
|
|
1108
|
+
d(p), f(w), m(b), 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: p, updated:
|
|
1115
|
-
a(p), c(
|
|
1114
|
+
const { created: p, updated: w, deleted: b } = n[o];
|
|
1115
|
+
a(p), c(w), l(b), e.emit("undo", n[o]), o -= 1;
|
|
1116
1116
|
}
|
|
1117
1117
|
}
|
|
1118
1118
|
};
|
|
1119
1119
|
}, Kn = () => {
|
|
1120
|
-
const { subscribe: t, set: e } =
|
|
1120
|
+
const { subscribe: t, set: e } = Pt([]);
|
|
1121
1121
|
return {
|
|
1122
1122
|
subscribe: t,
|
|
1123
1123
|
set: e
|
|
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
|
|
1132
|
-
if (
|
|
1133
|
-
const u =
|
|
1134
|
-
u !== -1 &&
|
|
1127
|
+
let c = [], f;
|
|
1128
|
+
const l = (b, S) => {
|
|
1129
|
+
d.has(b) ? d.get(b).push(S) : d.set(b, [S]);
|
|
1130
|
+
}, m = (b, S) => {
|
|
1131
|
+
const g = d.get(b);
|
|
1132
|
+
if (g) {
|
|
1133
|
+
const u = g.indexOf(S);
|
|
1134
|
+
u !== -1 && g.splice(u, 1);
|
|
1135
1135
|
}
|
|
1136
|
-
}, p = (
|
|
1137
|
-
d.has(
|
|
1138
|
-
d.get(
|
|
1136
|
+
}, p = (b, S, g) => {
|
|
1137
|
+
d.has(b) && setTimeout(() => {
|
|
1138
|
+
d.get(b).forEach((u) => {
|
|
1139
1139
|
if (n) {
|
|
1140
|
-
const
|
|
1141
|
-
u(
|
|
1140
|
+
const y = Array.isArray(S) ? S.map((E) => n.serialize(E)) : n.serialize(S), C = g ? g instanceof PointerEvent ? g : n.serialize(g) : void 0;
|
|
1141
|
+
u(y, C);
|
|
1142
1142
|
} else
|
|
1143
|
-
u(
|
|
1143
|
+
u(S, g);
|
|
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 &&
|
|
1152
|
-
c.forEach((
|
|
1153
|
-
const
|
|
1154
|
-
|
|
1147
|
+
s.subscribe(({ selected: b }) => {
|
|
1148
|
+
if (!(c.length === 0 && b.length === 0)) {
|
|
1149
|
+
if (c.length === 0 && b.length > 0)
|
|
1150
|
+
c = b.map(({ id: S }) => r.getAnnotation(S));
|
|
1151
|
+
else if (c.length > 0 && b.length === 0)
|
|
1152
|
+
c.forEach((S) => {
|
|
1153
|
+
const g = r.getAnnotation(S.id);
|
|
1154
|
+
g && !q(g, S) && p("updateAnnotation", g, S);
|
|
1155
1155
|
}), c = [];
|
|
1156
1156
|
else {
|
|
1157
|
-
const
|
|
1158
|
-
c.filter((u) => !
|
|
1159
|
-
const
|
|
1160
|
-
|
|
1157
|
+
const S = new Set(c.map((u) => u.id)), g = new Set(b.map(({ id: u }) => u));
|
|
1158
|
+
c.filter((u) => !g.has(u.id)).forEach((u) => {
|
|
1159
|
+
const y = r.getAnnotation(u.id);
|
|
1160
|
+
y && !q(y, u) && p("updateAnnotation", y, u);
|
|
1161
1161
|
}), c = [
|
|
1162
1162
|
// Remove annotations that were deselected
|
|
1163
|
-
...c.filter((u) =>
|
|
1163
|
+
...c.filter((u) => g.has(u.id)),
|
|
1164
1164
|
// Add editable annotations that were selected
|
|
1165
|
-
...
|
|
1165
|
+
...b.filter(({ id: u }) => !S.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:
|
|
1174
|
-
(
|
|
1170
|
+
}), i.subscribe((b) => {
|
|
1171
|
+
!f && b ? p("mouseEnterAnnotation", r.getAnnotation(b)) : f && !b ? p("mouseLeaveAnnotation", r.getAnnotation(f)) : f && b && (p("mouseLeaveAnnotation", r.getAnnotation(f)), p("mouseEnterAnnotation", r.getAnnotation(b))), f = b;
|
|
1172
|
+
}), a == null || a.subscribe((b) => p("viewportIntersect", b.map((S) => r.getAnnotation(S)))), r.observe((b) => {
|
|
1173
|
+
const { created: S, deleted: g } = b.changes;
|
|
1174
|
+
(S || []).forEach((u) => p("createAnnotation", u)), (g || []).forEach((u) => p("deleteAnnotation", u)), (b.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: y }) => {
|
|
1179
|
+
const C = c.find((E) => E.id === u.id) || u;
|
|
1180
|
+
c = c.map((E) => E.id === u.id ? y : E), p("updateAnnotation", y, C);
|
|
1181
1181
|
});
|
|
1182
|
-
}, { origin: k.LOCAL }), r.observe((
|
|
1182
|
+
}, { origin: k.LOCAL }), r.observe((b) => {
|
|
1183
1183
|
if (c) {
|
|
1184
|
-
const
|
|
1185
|
-
|
|
1184
|
+
const S = new Set(c.map((u) => u.id)), g = (b.changes.updated || []).filter(({ newValue: u }) => S.has(u.id)).map(({ newValue: u }) => u);
|
|
1185
|
+
g.length > 0 && (c = c.map((u) => g.find((C) => C.id === u.id) || u));
|
|
1186
1186
|
}
|
|
1187
1187
|
}, { origin: k.REMOTE });
|
|
1188
|
-
const
|
|
1189
|
-
const { updated:
|
|
1190
|
-
|
|
1188
|
+
const w = (b) => (S) => {
|
|
1189
|
+
const { updated: g } = S;
|
|
1190
|
+
b ? (g || []).forEach((u) => p("updateAnnotation", u.oldValue, u.newValue)) : (g || []).forEach((u) => p("updateAnnotation", u.newValue, u.oldValue));
|
|
1191
1191
|
};
|
|
1192
|
-
return e.on("undo",
|
|
1192
|
+
return e.on("undo", w(!0)), e.on("redo", w(!1)), { on: l, off: m, 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 ? {
|
|
@@ -1202,46 +1202,46 @@ const Dn = 250, Vn = (t) => {
|
|
|
1202
1202
|
...n
|
|
1203
1203
|
};
|
|
1204
1204
|
}, { parsed: [], failed: [] }), Pn = (t, e, n) => {
|
|
1205
|
-
const { store: o, selection: i } = t, s = (
|
|
1205
|
+
const { store: o, selection: i } = t, s = (g) => {
|
|
1206
1206
|
if (n) {
|
|
1207
|
-
const { parsed: u, error:
|
|
1208
|
-
u ? o.addAnnotation(u, k.REMOTE) : console.error(
|
|
1207
|
+
const { parsed: u, error: y } = n.parse(g);
|
|
1208
|
+
u ? o.addAnnotation(u, k.REMOTE) : console.error(y);
|
|
1209
1209
|
} else
|
|
1210
|
-
o.addAnnotation(
|
|
1211
|
-
}, r = () => i.clear(), a = () => o.clear(), d = (
|
|
1212
|
-
const u = o.getAnnotation(
|
|
1210
|
+
o.addAnnotation(Rt(g), k.REMOTE);
|
|
1211
|
+
}, r = () => i.clear(), a = () => o.clear(), d = (g) => {
|
|
1212
|
+
const u = o.getAnnotation(g);
|
|
1213
1213
|
return n && u ? n.serialize(u) : u;
|
|
1214
|
-
}, c = () => n ? o.all().map(n.serialize) : o.all(),
|
|
1215
|
-
var
|
|
1216
|
-
const u = (((
|
|
1214
|
+
}, c = () => n ? o.all().map(n.serialize) : o.all(), f = () => {
|
|
1215
|
+
var g;
|
|
1216
|
+
const u = (((g = i.selected) == null ? void 0 : g.map((y) => y.id)) || []).map((y) => o.getAnnotation(y)).filter(Boolean);
|
|
1217
1217
|
return n ? u.map(n.serialize) : u;
|
|
1218
|
-
}, l = (
|
|
1219
|
-
if (typeof
|
|
1220
|
-
const u = o.getAnnotation(
|
|
1221
|
-
if (o.deleteAnnotation(
|
|
1218
|
+
}, l = (g, u = !0) => fetch(g).then((y) => y.json()).then((y) => (p(y, u), y)), m = (g) => {
|
|
1219
|
+
if (typeof g == "string") {
|
|
1220
|
+
const u = o.getAnnotation(g);
|
|
1221
|
+
if (o.deleteAnnotation(g), u)
|
|
1222
1222
|
return n ? n.serialize(u) : u;
|
|
1223
1223
|
} else {
|
|
1224
|
-
const u = n ? n.parse(
|
|
1224
|
+
const u = n ? n.parse(g).parsed : g;
|
|
1225
1225
|
if (u)
|
|
1226
|
-
return o.deleteAnnotation(u),
|
|
1226
|
+
return o.deleteAnnotation(u), g;
|
|
1227
1227
|
}
|
|
1228
|
-
}, p = (
|
|
1228
|
+
}, p = (g, u = !0) => {
|
|
1229
1229
|
if (n) {
|
|
1230
|
-
const
|
|
1231
|
-
|
|
1230
|
+
const y = n.parseAll || Xn(n), { parsed: C, failed: E } = y(g);
|
|
1231
|
+
E.length > 0 && console.warn(`Discarded ${E.length} invalid annotations`, E), o.bulkAddAnnotation(C, u, k.REMOTE);
|
|
1232
1232
|
} else
|
|
1233
|
-
o.bulkAddAnnotation(
|
|
1234
|
-
},
|
|
1235
|
-
|
|
1236
|
-
},
|
|
1237
|
-
i.clear(), i.setUserSelectAction(
|
|
1238
|
-
},
|
|
1233
|
+
o.bulkAddAnnotation(g.map(Rt), u, k.REMOTE);
|
|
1234
|
+
}, w = (g, u) => {
|
|
1235
|
+
g ? i.setSelected(g, u) : i.clear();
|
|
1236
|
+
}, b = (g) => {
|
|
1237
|
+
i.clear(), i.setUserSelectAction(g);
|
|
1238
|
+
}, S = (g) => {
|
|
1239
1239
|
if (n) {
|
|
1240
|
-
const u = n.parse(
|
|
1241
|
-
return o.updateAnnotation(u),
|
|
1240
|
+
const u = n.parse(g).parsed, y = n.serialize(o.getAnnotation(u.id));
|
|
1241
|
+
return o.updateAnnotation(u), y;
|
|
1242
1242
|
} else {
|
|
1243
|
-
const u = o.getAnnotation(
|
|
1244
|
-
return o.updateAnnotation(
|
|
1243
|
+
const u = o.getAnnotation(g.id);
|
|
1244
|
+
return o.updateAnnotation(Rt(g)), u;
|
|
1245
1245
|
}
|
|
1246
1246
|
};
|
|
1247
1247
|
return {
|
|
@@ -1252,15 +1252,15 @@ const Dn = 250, Vn = (t) => {
|
|
|
1252
1252
|
clearAnnotations: a,
|
|
1253
1253
|
getAnnotationById: d,
|
|
1254
1254
|
getAnnotations: c,
|
|
1255
|
-
getSelected:
|
|
1255
|
+
getSelected: f,
|
|
1256
1256
|
loadAnnotations: l,
|
|
1257
1257
|
redo: e.redo,
|
|
1258
|
-
removeAnnotation:
|
|
1258
|
+
removeAnnotation: m,
|
|
1259
1259
|
setAnnotations: p,
|
|
1260
|
-
setSelected:
|
|
1261
|
-
setUserSelectAction:
|
|
1260
|
+
setSelected: w,
|
|
1261
|
+
setUserSelectAction: b,
|
|
1262
1262
|
undo: e.undo,
|
|
1263
|
-
updateAnnotation:
|
|
1263
|
+
updateAnnotation: S
|
|
1264
1264
|
};
|
|
1265
1265
|
}, $n = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
|
|
1266
1266
|
let jn = (t) => crypto.getRandomValues(new Uint8Array(t)), Hn = (t, e, n) => {
|
|
@@ -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
|
+
}, we = (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, ...f } = 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: we(c),
|
|
1299
1299
|
created: a ? new Date(a) : void 0,
|
|
1300
1300
|
updated: d ? new Date(d) : void 0,
|
|
1301
|
-
...
|
|
1301
|
+
...f
|
|
1302
1302
|
};
|
|
1303
1303
|
}), Qn = (t) => t.map((e) => {
|
|
1304
1304
|
var n;
|
|
@@ -1324,7 +1324,7 @@ const Io = (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: we(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 Io = (t, e) => ({
|
|
|
1332
1332
|
styleClass: r[0].styleClass
|
|
1333
1333
|
};
|
|
1334
1334
|
for (const d of r) {
|
|
1335
|
-
const
|
|
1336
|
-
switch (
|
|
1335
|
+
const f = (Array.isArray(d.selector) ? d.selector : [d.selector]).reduce((l, m) => {
|
|
1336
|
+
switch (m.type) {
|
|
1337
1337
|
case "TextQuoteSelector":
|
|
1338
|
-
l.quote =
|
|
1338
|
+
l.quote = m.exact;
|
|
1339
1339
|
break;
|
|
1340
1340
|
case "TextPositionSelector":
|
|
1341
|
-
l.start =
|
|
1341
|
+
l.start = m.start, l.end = m.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(f))
|
|
1347
|
+
a.selector.push({ id: d.id, ...f });
|
|
1348
1348
|
else {
|
|
1349
1349
|
const l = [
|
|
1350
|
-
|
|
1351
|
-
|
|
1350
|
+
f.start ? void 0 : "TextPositionSelector",
|
|
1351
|
+
f.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 || me(), {
|
|
1359
1359
|
creator: n,
|
|
1360
1360
|
created: o,
|
|
1361
1361
|
modified: i,
|
|
@@ -1376,23 +1376,23 @@ const Io = (t, e) => ({
|
|
|
1376
1376
|
creator: a,
|
|
1377
1377
|
created: d,
|
|
1378
1378
|
updated: c,
|
|
1379
|
-
...
|
|
1380
|
-
} = i, l = r.map((
|
|
1381
|
-
const { quote: p, start:
|
|
1379
|
+
...f
|
|
1380
|
+
} = i, l = r.map((m) => {
|
|
1381
|
+
const { quote: p, start: w, end: b, range: S } = m, { prefix: g, suffix: u } = Ue(S, n), y = [{
|
|
1382
1382
|
type: "TextQuoteSelector",
|
|
1383
1383
|
exact: p,
|
|
1384
|
-
prefix:
|
|
1384
|
+
prefix: g,
|
|
1385
1385
|
suffix: u
|
|
1386
1386
|
}, {
|
|
1387
1387
|
type: "TextPositionSelector",
|
|
1388
|
-
start:
|
|
1389
|
-
end:
|
|
1388
|
+
start: w,
|
|
1389
|
+
end: b
|
|
1390
1390
|
}];
|
|
1391
1391
|
return {
|
|
1392
|
-
...
|
|
1393
|
-
id:
|
|
1392
|
+
...f,
|
|
1393
|
+
id: m.id,
|
|
1394
1394
|
source: e,
|
|
1395
|
-
selector:
|
|
1395
|
+
selector: y
|
|
1396
1396
|
};
|
|
1397
1397
|
});
|
|
1398
1398
|
return {
|
|
@@ -1407,11 +1407,11 @@ const Io = (t, e) => ({
|
|
|
1407
1407
|
target: l
|
|
1408
1408
|
};
|
|
1409
1409
|
};
|
|
1410
|
-
function
|
|
1410
|
+
function ve(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, f = Math.log(d), l = 0.5 * Math.exp(2 * f / 3), m = 0.5 * Math.sqrt(f * l * (d - l) / d) * (c - d / 2 < 0 ? -1 : 1), p = Math.max(n, Math.floor(e - c * l / d + m)), w = Math.min(o, Math.floor(e + (d - c) * l / d + m));
|
|
1414
|
+
ve(t, e, p, w, 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) : kt(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 || kt(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 f = io(e, o.children, n);
|
|
1504
|
+
if (f !== -1)
|
|
1505
|
+
return o.children.splice(f, 1), s.push(o), this._condense(s), this;
|
|
1506
1506
|
}
|
|
1507
|
-
!c && !o.leaf &&
|
|
1507
|
+
!c && !o.leaf && kt(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 p = Math.min(
|
|
1545
|
-
a.children.push(this._build(e,
|
|
1539
|
+
oe(e, n, o, c, this.compareMinX);
|
|
1540
|
+
for (let f = n; f <= o; f += c) {
|
|
1541
|
+
const l = Math.min(f + c - 1, o);
|
|
1542
|
+
oe(e, f, l, d, this.compareMinY);
|
|
1543
|
+
for (let m = f; m <= l; m += d) {
|
|
1544
|
+
const p = Math.min(m + d - 1, l);
|
|
1545
|
+
a.children.push(this._build(e, m, 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], f = Bt(c), l = ao(e, c) - f;
|
|
1555
|
+
l < r ? (r = l, s = f < s ? f : s, a = c) : l === r && f < s && (s = f, 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), f = co(d, c), l = Bt(d) + Bt(c);
|
|
1581
|
+
f < s ? (s = f, i = a, r = l < r ? l : r) : f === 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 f = e.children[c];
|
|
1597
|
+
it(r, e.leaf ? s(f) : f), 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 f = e.children[c];
|
|
1601
|
+
it(a, e.leaf ? s(f) : f), 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 Bt(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 kt(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 oe(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
|
+
ve(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
|
-
}),
|
|
1698
|
-
return
|
|
1699
|
-
const { x:
|
|
1693
|
+
const n = new oo(), o = /* @__PURE__ */ new Map(), i = lo(), s = (y, C) => {
|
|
1694
|
+
const E = y.selector.flatMap((R) => {
|
|
1695
|
+
const T = F([R]) ? R.range : le(R, e).range;
|
|
1696
|
+
return Array.from(T.getClientRects());
|
|
1697
|
+
}), O = Xe(E).map((R) => He(R, C));
|
|
1698
|
+
return O.map((R) => {
|
|
1699
|
+
const { x: T, y: x, width: h, height: v } = R;
|
|
1700
1700
|
return {
|
|
1701
|
-
minX:
|
|
1702
|
-
minY:
|
|
1703
|
-
maxX:
|
|
1704
|
-
maxY:
|
|
1701
|
+
minX: T,
|
|
1702
|
+
minY: x,
|
|
1703
|
+
maxX: T + h,
|
|
1704
|
+
maxY: x + v,
|
|
1705
1705
|
annotation: {
|
|
1706
|
-
id:
|
|
1707
|
-
rects:
|
|
1706
|
+
id: y.annotation,
|
|
1707
|
+
rects: O
|
|
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
|
-
|
|
1725
|
-
const
|
|
1726
|
-
n.load(
|
|
1727
|
-
},
|
|
1728
|
-
const
|
|
1729
|
-
minX:
|
|
1730
|
-
minY:
|
|
1731
|
-
maxX:
|
|
1732
|
-
maxY:
|
|
1733
|
-
}),
|
|
1734
|
-
return
|
|
1735
|
-
}, p = (
|
|
1736
|
-
const
|
|
1737
|
-
if (
|
|
1713
|
+
}, d = (y) => {
|
|
1714
|
+
const C = s(y, e.getBoundingClientRect());
|
|
1715
|
+
C.forEach((E) => n.insert(E)), o.set(y.annotation, C);
|
|
1716
|
+
}, c = (y) => {
|
|
1717
|
+
const C = o.get(y.annotation);
|
|
1718
|
+
C && (C.forEach((E) => n.remove(E)), o.delete(y.annotation));
|
|
1719
|
+
}, f = (y) => {
|
|
1720
|
+
c(y), d(y);
|
|
1721
|
+
}, l = (y, C = !0) => {
|
|
1722
|
+
C && a();
|
|
1723
|
+
const E = e.getBoundingClientRect(), O = y.map((T) => ({ target: T, rects: s(T, E) }));
|
|
1724
|
+
O.forEach(({ target: T, rects: x }) => o.set(T.annotation, x));
|
|
1725
|
+
const R = O.flatMap(({ rects: T }) => T);
|
|
1726
|
+
n.load(R);
|
|
1727
|
+
}, m = (y, C, E = !1) => {
|
|
1728
|
+
const O = n.search({
|
|
1729
|
+
minX: y,
|
|
1730
|
+
minY: C,
|
|
1731
|
+
maxX: y,
|
|
1732
|
+
maxY: C
|
|
1733
|
+
}), R = (T) => T.annotation.rects.reduce((x, h) => x + h.width * h.height, 0);
|
|
1734
|
+
return O.length > 0 ? (O.sort((T, x) => R(T) - R(x)), E ? O.map((T) => T.annotation.id) : [O[0].annotation.id]) : [];
|
|
1735
|
+
}, p = (y) => {
|
|
1736
|
+
const C = w(y);
|
|
1737
|
+
if (C.length === 0)
|
|
1738
1738
|
return;
|
|
1739
|
-
let
|
|
1740
|
-
for (let
|
|
1741
|
-
const
|
|
1742
|
-
|
|
1739
|
+
let E = C[0].left, O = C[0].top, R = C[0].right, T = C[0].bottom;
|
|
1740
|
+
for (let x = 1; x < C.length; x++) {
|
|
1741
|
+
const h = C[x];
|
|
1742
|
+
E = Math.min(E, h.left), O = Math.min(O, h.top), R = Math.max(R, h.right), T = Math.max(T, h.bottom);
|
|
1743
1743
|
}
|
|
1744
|
-
return new DOMRect(
|
|
1745
|
-
},
|
|
1746
|
-
const
|
|
1747
|
-
return
|
|
1744
|
+
return new DOMRect(E, O, R - E, T - O);
|
|
1745
|
+
}, w = (y) => {
|
|
1746
|
+
const C = o.get(y);
|
|
1747
|
+
return C[0] ? C[0].annotation.rects : [];
|
|
1748
1748
|
};
|
|
1749
1749
|
return {
|
|
1750
1750
|
all: r,
|
|
1751
1751
|
clear: a,
|
|
1752
|
-
getAt:
|
|
1752
|
+
getAt: m,
|
|
1753
1753
|
getAnnotationBounds: p,
|
|
1754
|
-
getAnnotationRects:
|
|
1755
|
-
getIntersecting: (
|
|
1756
|
-
const
|
|
1757
|
-
return Array.from(
|
|
1758
|
-
annotation: t.getAnnotation(
|
|
1759
|
-
rects:
|
|
1760
|
-
})).filter((
|
|
1754
|
+
getAnnotationRects: w,
|
|
1755
|
+
getIntersecting: (y, C, E, O) => {
|
|
1756
|
+
const R = n.search({ minX: y, minY: C, maxX: E, maxY: O }), T = new Set(R.map((x) => x.annotation.id));
|
|
1757
|
+
return Array.from(T).map((x) => ({
|
|
1758
|
+
annotation: t.getAnnotation(x),
|
|
1759
|
+
rects: w(x)
|
|
1760
|
+
})).filter((x) => !!x.annotation);
|
|
1761
1761
|
},
|
|
1762
1762
|
insert: d,
|
|
1763
1763
|
recalculate: () => {
|
|
1764
|
-
l(t.all().map((
|
|
1764
|
+
l(t.all().map((y) => y.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: f,
|
|
1770
|
+
on: (y, C) => i.on(y, C)
|
|
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
|
|
1781
|
-
}, c = (u,
|
|
1782
|
-
const
|
|
1783
|
-
return
|
|
1784
|
-
n.getAnnotation(
|
|
1785
|
-
}),
|
|
1786
|
-
},
|
|
1787
|
-
const
|
|
1788
|
-
n.updateTarget(
|
|
1789
|
-
}, l = (u,
|
|
1790
|
-
const
|
|
1791
|
-
n.bulkUpdateTargets(
|
|
1792
|
-
},
|
|
1793
|
-
const
|
|
1794
|
-
return
|
|
1795
|
-
}, p = (u,
|
|
1796
|
-
const
|
|
1797
|
-
if (
|
|
1798
|
-
if (
|
|
1799
|
-
const
|
|
1800
|
-
if (
|
|
1775
|
+
const s = An(n), r = Kn(), a = (u, y = k.LOCAL) => {
|
|
1776
|
+
const C = At(u, t), E = F(C.target.selector);
|
|
1777
|
+
return E && n.addAnnotation(C, y), E;
|
|
1778
|
+
}, d = (u, y = !0, C = k.LOCAL) => {
|
|
1779
|
+
const E = u.map((R) => At(R, t)), O = E.filter((R) => !F(R.target.selector));
|
|
1780
|
+
return O.length > 0 ? (console.warn("Could not revive all targets for these annotations:", O), n.bulkAddAnnotation(E, y, C), O) : (n.bulkAddAnnotation(E, y, C), []);
|
|
1781
|
+
}, c = (u, y = k.LOCAL) => {
|
|
1782
|
+
const C = u.map((O) => At(O, t)), E = C.filter((O) => !F(O.target.selector));
|
|
1783
|
+
return E.length > 0 && console.warn("Could not revive all targets for these annotations:", E), C.forEach((O) => {
|
|
1784
|
+
n.getAnnotation(O.id) ? n.updateAnnotation(O, y) : n.addAnnotation(O, y);
|
|
1785
|
+
}), E;
|
|
1786
|
+
}, f = (u, y = k.LOCAL) => {
|
|
1787
|
+
const C = wt(u, t);
|
|
1788
|
+
n.updateTarget(C, y);
|
|
1789
|
+
}, l = (u, y = k.LOCAL) => {
|
|
1790
|
+
const C = u.map((E) => wt(E, t));
|
|
1791
|
+
n.bulkUpdateTargets(C, y);
|
|
1792
|
+
}, m = (u, y, C) => {
|
|
1793
|
+
const E = o.getAt(u, y, !!C).map((R) => n.getAnnotation(R)), O = C ? E.filter(C) : E;
|
|
1794
|
+
return O.length > 0 ? O[0] : void 0;
|
|
1795
|
+
}, p = (u, y, C, E = 5) => {
|
|
1796
|
+
const O = o.getAnnotationRects(u);
|
|
1797
|
+
if (O.length !== 0) {
|
|
1798
|
+
if (y && C) {
|
|
1799
|
+
const R = O.find(({ top: T, right: x, bottom: h, left: v }) => y >= v - E && y <= x + E && C >= T - E && C <= h + E);
|
|
1800
|
+
if (R) return R;
|
|
1801
1801
|
}
|
|
1802
1802
|
return o.getAnnotationBounds(u);
|
|
1803
1803
|
}
|
|
1804
|
-
},
|
|
1804
|
+
}, w = (u, y, C, E) => o.getIntersecting(u, y, C, E), b = (u) => o.getAnnotationRects(u), S = () => o.recalculate(), g = (u) => o.on("recalculate", u);
|
|
1805
1805
|
return n.observe(({ changes: u }) => {
|
|
1806
|
-
const
|
|
1807
|
-
(
|
|
1806
|
+
const y = (u.deleted || []).filter((O) => F(O.target.selector)), C = (u.created || []).filter((O) => F(O.target.selector)), E = (u.updated || []).filter((O) => F(O.newValue.target.selector));
|
|
1807
|
+
(y == null ? void 0 : y.length) > 0 && y.forEach((O) => o.remove(O.target)), C.length > 0 && o.set(C.map((O) => O.target), !1), (E == null ? void 0 : E.length) > 0 && E.forEach(({ newValue: O }) => o.update(O.target));
|
|
1808
1808
|
}), {
|
|
1809
1809
|
store: {
|
|
1810
1810
|
...n,
|
|
@@ -1813,12 +1813,12 @@ const uo = (t, e) => {
|
|
|
1813
1813
|
bulkUpdateTargets: l,
|
|
1814
1814
|
bulkUpsertAnnotations: c,
|
|
1815
1815
|
getAnnotationBounds: p,
|
|
1816
|
-
getAnnotationRects:
|
|
1817
|
-
getIntersecting:
|
|
1818
|
-
getAt:
|
|
1819
|
-
recalculatePositions:
|
|
1820
|
-
onRecalculatePositions:
|
|
1821
|
-
updateTarget:
|
|
1816
|
+
getAnnotationRects: b,
|
|
1817
|
+
getIntersecting: w,
|
|
1818
|
+
getAt: m,
|
|
1819
|
+
recalculatePositions: S,
|
|
1820
|
+
onRecalculatePositions: g,
|
|
1821
|
+
updateTarget: f
|
|
1822
1822
|
},
|
|
1823
1823
|
selection: i,
|
|
1824
1824
|
hover: s,
|
|
@@ -1832,49 +1832,49 @@ const uo = (t, e) => {
|
|
|
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 = (f) => Array.from(i.entries()).filter(([l, m]) => m.presenceKey === f.presenceKey).map(([l, m]) => l);
|
|
1836
|
+
return t.on("selectionChange", (f, l) => {
|
|
1837
|
+
s(f).forEach((p) => i.delete(p)), l && l.forEach((p) => i.set(p, f));
|
|
1838
1838
|
}), {
|
|
1839
1839
|
clear: () => {
|
|
1840
|
-
const { width:
|
|
1841
|
-
o.clearRect(-0.5, -0.5,
|
|
1840
|
+
const { width: f, height: l } = n;
|
|
1841
|
+
o.clearRect(-0.5, -0.5, f + 1, l + 1);
|
|
1842
1842
|
},
|
|
1843
1843
|
destroy: () => {
|
|
1844
1844
|
n.remove();
|
|
1845
1845
|
},
|
|
1846
|
-
paint: (
|
|
1846
|
+
paint: (f, l, m) => {
|
|
1847
1847
|
e.font && (o.font = e.font);
|
|
1848
|
-
const p = i.get(
|
|
1848
|
+
const p = i.get(f.annotation.id);
|
|
1849
1849
|
if (p) {
|
|
1850
|
-
const { height:
|
|
1851
|
-
o.fillStyle = p.appearance.color, o.fillRect(
|
|
1852
|
-
const
|
|
1853
|
-
return o.fillRect(
|
|
1850
|
+
const { height: w } = f.rects[0], b = f.rects[0].x + l.left, S = f.rects[0].y + l.top;
|
|
1851
|
+
o.fillStyle = p.appearance.color, o.fillRect(b - 2, S - 2.5, 2, w + 5);
|
|
1852
|
+
const g = o.measureText(p.appearance.label), u = g.width + 6, y = g.actualBoundingBoxAscent + g.actualBoundingBoxDescent + 8, C = g.fontBoundingBoxAscent ? 8 : 6.5;
|
|
1853
|
+
return o.fillRect(b - 2, S - 2.5 - y, u, y), o.fillStyle = "#fff", o.fillText(p.appearance.label, b + 1, S - C), {
|
|
1854
1854
|
fill: p.appearance.color,
|
|
1855
|
-
fillOpacity:
|
|
1855
|
+
fillOpacity: m ? 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 f = n.getContext("2d");
|
|
1862
|
+
f.scale(2, 2), f.translate(0.5, 0.5);
|
|
1863
1863
|
}
|
|
1864
1864
|
};
|
|
1865
|
-
},
|
|
1866
|
-
function
|
|
1865
|
+
}, It = typeof navigator < "u" ? navigator.userAgent.toLowerCase().indexOf("firefox") > 0 : !1;
|
|
1866
|
+
function Nt(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 Ae(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 xe(t) {
|
|
1878
1878
|
typeof t != "string" && (t = ""), t = t.replace(/\s/g, "");
|
|
1879
1879
|
const e = t.split(",");
|
|
1880
1880
|
let n = e.lastIndexOf("");
|
|
@@ -1934,9 +1934,9 @@ const at = {
|
|
|
1934
1934
|
".": 190,
|
|
1935
1935
|
"/": 191,
|
|
1936
1936
|
"`": 192,
|
|
1937
|
-
"-":
|
|
1938
|
-
"=":
|
|
1939
|
-
";":
|
|
1937
|
+
"-": It ? 173 : 189,
|
|
1938
|
+
"=": It ? 61 : 187,
|
|
1939
|
+
";": It ? 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
|
+
}, Vt = {
|
|
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, Ee = "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 Se(t) {
|
|
1980
|
+
Ee = t || "all";
|
|
1981
1981
|
}
|
|
1982
1982
|
function ct() {
|
|
1983
|
-
return
|
|
1983
|
+
return Ee || "all";
|
|
1984
1984
|
}
|
|
1985
1985
|
function bo() {
|
|
1986
1986
|
return I.slice(0);
|
|
@@ -2028,9 +2028,9 @@ function Eo(t, e) {
|
|
|
2028
2028
|
let {
|
|
2029
2029
|
element: a
|
|
2030
2030
|
} = r;
|
|
2031
|
-
return
|
|
2031
|
+
return $t(a);
|
|
2032
2032
|
}) : o++;
|
|
2033
|
-
ct() === t &&
|
|
2033
|
+
ct() === t && Se(e || "all");
|
|
2034
2034
|
}
|
|
2035
2035
|
function So(t) {
|
|
2036
2036
|
let e = t.keyCode || t.which || t.charCode;
|
|
@@ -2040,11 +2040,11 @@ function So(t) {
|
|
|
2040
2040
|
for (const o in j) j[o] === e && (P[o] = !1);
|
|
2041
2041
|
}
|
|
2042
2042
|
}
|
|
2043
|
-
function
|
|
2043
|
+
function Ce(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
|
+
}), $t(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
|
+
xe(e).forEach((r) => {
|
|
2074
|
+
const a = r.split(i), d = a.length, c = a[d - 1], f = c === "*" ? "*" : lt(c);
|
|
2075
|
+
if (!N[f]) return;
|
|
2076
2076
|
n || (n = ct());
|
|
2077
|
-
const l = d > 1 ?
|
|
2078
|
-
N[
|
|
2079
|
-
const
|
|
2080
|
-
return
|
|
2081
|
-
}),
|
|
2077
|
+
const l = d > 1 ? Ae(j, a) : [], m = [];
|
|
2078
|
+
N[f] = N[f].filter((p) => {
|
|
2079
|
+
const b = (o ? p.method === o : !0) && p.scope === n && go(p.mods, l);
|
|
2080
|
+
return b && m.push(p.element), !b;
|
|
2081
|
+
}), m.forEach((p) => $t(p));
|
|
2082
2082
|
});
|
|
2083
2083
|
};
|
|
2084
|
-
function
|
|
2084
|
+
function ie(t, e, n, o) {
|
|
2085
2085
|
if (e.element !== o)
|
|
2086
2086
|
return;
|
|
2087
2087
|
let i;
|
|
@@ -2092,12 +2092,12 @@ function se(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 se(t, e) {
|
|
2096
2096
|
const n = N["*"];
|
|
2097
2097
|
let o = t.keyCode || t.which || t.charCode;
|
|
2098
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 = Vt[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;
|
|
@@ -2106,30 +2106,30 @@ function re(t, e) {
|
|
|
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[Vt[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) && ie(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, f = d.key.split(c), l = [];
|
|
2122
|
+
for (let m = 0; m < f.length; m++)
|
|
2123
|
+
l.push(lt(f[m]));
|
|
2124
|
+
l.sort().join("") === I.sort().join("") && ie(t, d, i, e);
|
|
2125
2125
|
}
|
|
2126
2126
|
}
|
|
2127
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 = xe(t);
|
|
2130
|
+
let i = [], s = "all", r = document, a = 0, d = !1, c = !0, f = "+", l = !1, m = !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" && (f = e.splitKey), e.single === !0 && (m = !0)), typeof e == "string" && (s = e), m && Ce(t, s); a < o.length; a++)
|
|
2132
|
+
t = o[a].split(f), i = [], t.length > 1 && (i = Ae(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,23 +2137,23 @@ function P(t, e, n) {
|
|
|
2137
2137
|
shortcut: o[a],
|
|
2138
2138
|
method: n,
|
|
2139
2139
|
key: o[a],
|
|
2140
|
-
splitKey:
|
|
2140
|
+
splitKey: f,
|
|
2141
2141
|
element: r
|
|
2142
2142
|
});
|
|
2143
2143
|
if (typeof r < "u" && window) {
|
|
2144
2144
|
if (!z.has(r)) {
|
|
2145
2145
|
const p = function() {
|
|
2146
|
-
let
|
|
2147
|
-
return
|
|
2148
|
-
},
|
|
2149
|
-
let
|
|
2150
|
-
|
|
2146
|
+
let b = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : window.event;
|
|
2147
|
+
return se(b, r);
|
|
2148
|
+
}, w = function() {
|
|
2149
|
+
let b = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : window.event;
|
|
2150
|
+
se(b, r), So(b);
|
|
2151
2151
|
};
|
|
2152
2152
|
z.set(r, {
|
|
2153
2153
|
keydownListener: p,
|
|
2154
|
-
keyupListenr:
|
|
2154
|
+
keyupListenr: w,
|
|
2155
2155
|
capture: l
|
|
2156
|
-
}),
|
|
2156
|
+
}), Nt(r, "keydown", p, l), Nt(r, "keyup", w, l);
|
|
2157
2157
|
}
|
|
2158
2158
|
if (!rt) {
|
|
2159
2159
|
const p = () => {
|
|
@@ -2162,7 +2162,7 @@ function P(t, e, n) {
|
|
|
2162
2162
|
rt = {
|
|
2163
2163
|
listener: p,
|
|
2164
2164
|
capture: l
|
|
2165
|
-
},
|
|
2165
|
+
}, Nt(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 $t(t) {
|
|
2178
2178
|
const e = Object.values(N).flat();
|
|
2179
2179
|
if (e.findIndex((o) => {
|
|
2180
2180
|
let {
|
|
@@ -2204,9 +2204,9 @@ function jt(t) {
|
|
|
2204
2204
|
et(window, "focus", i, s), rt = null;
|
|
2205
2205
|
}
|
|
2206
2206
|
}
|
|
2207
|
-
const
|
|
2207
|
+
const _t = {
|
|
2208
2208
|
getPressedKeyString: wo,
|
|
2209
|
-
setScope:
|
|
2209
|
+
setScope: Se,
|
|
2210
2210
|
getScope: ct,
|
|
2211
2211
|
deleteScope: Eo,
|
|
2212
2212
|
getPressedKeyCodes: bo,
|
|
@@ -2214,13 +2214,13 @@ const Ut = {
|
|
|
2214
2214
|
isPressed: xo,
|
|
2215
2215
|
filter: Ao,
|
|
2216
2216
|
trigger: Co,
|
|
2217
|
-
unbind:
|
|
2217
|
+
unbind: Ce,
|
|
2218
2218
|
keyMap: at,
|
|
2219
2219
|
modifier: j,
|
|
2220
|
-
modifierMap:
|
|
2220
|
+
modifierMap: Vt
|
|
2221
2221
|
};
|
|
2222
|
-
for (const t in
|
|
2223
|
-
Object.prototype.hasOwnProperty.call(
|
|
2222
|
+
for (const t in _t)
|
|
2223
|
+
Object.prototype.hasOwnProperty.call(_t, t) && (P[t] = _t[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;
|
|
@@ -2232,158 +2232,157 @@ async function Lo(t, e, n = () => !1) {
|
|
|
2232
2232
|
await new Promise((i) => setTimeout(i, Math.max(0, o)));
|
|
2233
2233
|
} while (!await n());
|
|
2234
2234
|
}
|
|
2235
|
-
const
|
|
2236
|
-
...
|
|
2237
|
-
|
|
2235
|
+
const re = 300, Le = ["up", "down", "left", "right"], Oe = ke ? "⌘+a" : "ctrl+a", Oo = [
|
|
2236
|
+
...Le.map((t) => `shift+${t}`),
|
|
2237
|
+
Oe
|
|
2238
2238
|
], To = (t, e, n) => {
|
|
2239
2239
|
const { store: o, selection: i } = e;
|
|
2240
2240
|
let s;
|
|
2241
|
-
const r = (
|
|
2241
|
+
const r = (x) => s = x;
|
|
2242
2242
|
let a;
|
|
2243
|
-
const d = (
|
|
2244
|
-
let c,
|
|
2245
|
-
const
|
|
2246
|
-
|
|
2247
|
-
}, w = (
|
|
2248
|
-
|
|
2249
|
-
annotation:
|
|
2243
|
+
const d = (x) => a = x;
|
|
2244
|
+
let c, f, l, m = !0;
|
|
2245
|
+
const p = (x) => {
|
|
2246
|
+
m = x, b.clear(), x || (c = void 0, l = void 0);
|
|
2247
|
+
}, w = (x) => {
|
|
2248
|
+
f !== !1 && (c = nt(x.target) ? void 0 : {
|
|
2249
|
+
annotation: me(),
|
|
2250
2250
|
selector: [],
|
|
2251
2251
|
creator: s,
|
|
2252
2252
|
created: /* @__PURE__ */ new Date()
|
|
2253
|
-
})
|
|
2254
|
-
},
|
|
2255
|
-
if (!
|
|
2256
|
-
const
|
|
2257
|
-
if (!(
|
|
2253
|
+
});
|
|
2254
|
+
}, b = Yt((x) => {
|
|
2255
|
+
if (!m) return;
|
|
2256
|
+
const h = document.getSelection();
|
|
2257
|
+
if (!(h != null && h.anchorNode))
|
|
2258
2258
|
return;
|
|
2259
|
-
if (nt(
|
|
2259
|
+
if (nt(h.anchorNode)) {
|
|
2260
2260
|
c = void 0;
|
|
2261
2261
|
return;
|
|
2262
2262
|
}
|
|
2263
|
-
const
|
|
2264
|
-
if ((l == null ? void 0 : l.type) === "pointerdown" && (
|
|
2265
|
-
if (
|
|
2263
|
+
const v = x.timeStamp - ((l == null ? void 0 : l.timeStamp) || x.timeStamp);
|
|
2264
|
+
if ((l == null ? void 0 : l.type) === "pointerdown" && (v < 1e3 && !c || h.isCollapsed && v < re) && w(l || x), !c) return;
|
|
2265
|
+
if (h.isCollapsed) {
|
|
2266
2266
|
o.getAnnotation(c.annotation) && (i.clear(), o.deleteAnnotation(c.annotation));
|
|
2267
2267
|
return;
|
|
2268
2268
|
}
|
|
2269
|
-
const
|
|
2270
|
-
if (Ve(
|
|
2271
|
-
const
|
|
2272
|
-
(
|
|
2269
|
+
const A = h.getRangeAt(0), L = je(A, t);
|
|
2270
|
+
if (Ve(L)) return;
|
|
2271
|
+
const M = _e(L.cloneRange());
|
|
2272
|
+
(M.length !== c.selector.length || M.some((K, Y) => {
|
|
2273
2273
|
var dt;
|
|
2274
|
-
return
|
|
2274
|
+
return K.toString() !== ((dt = c.selector[Y]) == null ? void 0 : dt.quote);
|
|
2275
2275
|
})) && (c = {
|
|
2276
2276
|
...c,
|
|
2277
|
-
selector:
|
|
2277
|
+
selector: M.map((K) => Pe(K, t, n)),
|
|
2278
2278
|
updated: /* @__PURE__ */ new Date()
|
|
2279
2279
|
}, o.getAnnotation(c.annotation) ? o.updateTarget(c, k.LOCAL) : i.clear());
|
|
2280
|
-
}, 10),
|
|
2281
|
-
|
|
2282
|
-
},
|
|
2280
|
+
}, 10), S = (x) => {
|
|
2281
|
+
nt(x.target) || (l = xt(x), f = l.button === 0);
|
|
2282
|
+
}, g = () => {
|
|
2283
2283
|
o.getAnnotation(c.annotation) ? o.updateTarget(c) : o.addAnnotation({
|
|
2284
2284
|
id: c.annotation,
|
|
2285
2285
|
bodies: [],
|
|
2286
2286
|
target: c
|
|
2287
2287
|
});
|
|
2288
|
-
},
|
|
2289
|
-
if (
|
|
2290
|
-
const
|
|
2291
|
-
const { x:
|
|
2292
|
-
if (
|
|
2293
|
-
const { selected:
|
|
2294
|
-
(
|
|
2288
|
+
}, u = async (x) => {
|
|
2289
|
+
if (nt(x.target) || !f) return;
|
|
2290
|
+
const h = () => {
|
|
2291
|
+
const { x: A, y: L } = t.getBoundingClientRect(), M = x.target instanceof Node && t.contains(x.target) && o.getAt(x.clientX - A, x.clientY - L, a);
|
|
2292
|
+
if (M) {
|
|
2293
|
+
const { selected: B } = i;
|
|
2294
|
+
(B.length !== 1 || B[0].id !== M.id) && i.userSelect(M.id, x);
|
|
2295
2295
|
} else
|
|
2296
2296
|
i.clear();
|
|
2297
2297
|
};
|
|
2298
|
-
if (
|
|
2299
|
-
await
|
|
2300
|
-
const
|
|
2301
|
-
if (
|
|
2302
|
-
c = void 0,
|
|
2298
|
+
if (x.timeStamp - l.timeStamp < re) {
|
|
2299
|
+
await y();
|
|
2300
|
+
const A = document.getSelection();
|
|
2301
|
+
if (A != null && A.isCollapsed) {
|
|
2302
|
+
c = void 0, h();
|
|
2303
2303
|
return;
|
|
2304
2304
|
}
|
|
2305
2305
|
}
|
|
2306
|
-
c && c.selector.length > 0 && (i.clear(),
|
|
2307
|
-
},
|
|
2308
|
-
const
|
|
2309
|
-
let
|
|
2310
|
-
const
|
|
2311
|
-
return setTimeout(() =>
|
|
2312
|
-
},
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
const y = () => setTimeout(() => {
|
|
2306
|
+
c && c.selector.length > 0 && (i.clear(), g(), i.userSelect(c.annotation, xt(x)));
|
|
2307
|
+
}, y = async () => {
|
|
2308
|
+
const x = document.getSelection();
|
|
2309
|
+
let h = !1, v = x == null ? void 0 : x.isCollapsed;
|
|
2310
|
+
const A = () => v || h, L = 1;
|
|
2311
|
+
return setTimeout(() => h = !0, 50), Lo(() => v = x == null ? void 0 : x.isCollapsed, L, A);
|
|
2312
|
+
}, C = (x) => {
|
|
2313
|
+
const h = document.getSelection();
|
|
2314
|
+
h != null && h.isCollapsed || ((!c || c.selector.length === 0) && b(x), g(), i.userSelect(c.annotation, xt(x)));
|
|
2315
|
+
}, E = (x) => {
|
|
2316
|
+
m && x.key === "Shift" && c && (document.getSelection().isCollapsed || (i.clear(), g(), i.userSelect(c.annotation, ut(x))));
|
|
2317
|
+
}, O = (x) => {
|
|
2318
|
+
const h = () => setTimeout(() => {
|
|
2320
2319
|
(c == null ? void 0 : c.selector.length) > 0 && (i.clear(), o.addAnnotation({
|
|
2321
2320
|
id: c.annotation,
|
|
2322
2321
|
bodies: [],
|
|
2323
2322
|
target: c
|
|
2324
|
-
}), i.userSelect(c.annotation, ut(
|
|
2323
|
+
}), i.userSelect(c.annotation, ut(x))), document.removeEventListener("selectionchange", h);
|
|
2325
2324
|
}, 100);
|
|
2326
|
-
document.addEventListener("selectionchange",
|
|
2325
|
+
document.addEventListener("selectionchange", h), w(x);
|
|
2327
2326
|
};
|
|
2328
|
-
P(Oo.join(","), { element: t, keydown: !0, keyup: !1 }, (
|
|
2329
|
-
|
|
2330
|
-
}), P(
|
|
2331
|
-
l = ut(
|
|
2327
|
+
P(Oo.join(","), { element: t, keydown: !0, keyup: !1 }, (x) => {
|
|
2328
|
+
x.repeat || (l = ut(x));
|
|
2329
|
+
}), P(Oe, { keydown: !0, keyup: !1 }, (x) => {
|
|
2330
|
+
l = ut(x), O(x);
|
|
2332
2331
|
});
|
|
2333
|
-
const
|
|
2334
|
-
|
|
2332
|
+
const R = (x) => {
|
|
2333
|
+
x.repeat || x.target !== t && x.target !== document.body || (c = void 0, i.clear());
|
|
2335
2334
|
};
|
|
2336
|
-
return P(
|
|
2335
|
+
return P(Le.join(","), { keydown: !0, keyup: !1 }, R), document.addEventListener("pointerdown", S), document.addEventListener("pointerup", u), document.addEventListener("contextmenu", C), t.addEventListener("keyup", E), t.addEventListener("selectstart", w), document.addEventListener("selectionchange", b), {
|
|
2337
2336
|
destroy: () => {
|
|
2338
|
-
c = void 0,
|
|
2337
|
+
c = void 0, f = void 0, l = void 0, b.clear(), document.removeEventListener("pointerdown", S), document.removeEventListener("pointerup", u), document.removeEventListener("contextmenu", C), t.removeEventListener("keyup", E), t.removeEventListener("selectstart", w), document.removeEventListener("selectionchange", b), P.unbind();
|
|
2339
2338
|
},
|
|
2340
2339
|
setFilter: d,
|
|
2341
2340
|
setUser: r,
|
|
2342
|
-
setAnnotatingEnabled:
|
|
2341
|
+
setAnnotatingEnabled: p
|
|
2343
2342
|
};
|
|
2344
2343
|
}, Ro = (t, e) => ({
|
|
2345
2344
|
...t,
|
|
2346
2345
|
annotatingEnabled: t.annotatingEnabled ?? e.annotatingEnabled,
|
|
2347
2346
|
user: t.user || e.user
|
|
2348
|
-
}),
|
|
2347
|
+
}), ae = "SPANS", No = (t, e = {}) => {
|
|
2349
2348
|
Be(t), Ie(t);
|
|
2350
2349
|
const n = Ro(e, {
|
|
2351
2350
|
annotatingEnabled: !0,
|
|
2352
2351
|
user: Wn()
|
|
2353
2352
|
}), o = fo(t, n.userSelectAction), { selection: i, viewport: s } = o, r = o.store, a = Vn(r), d = Yn(o, a, n.adapter);
|
|
2354
2353
|
let c = n.user;
|
|
2355
|
-
const
|
|
2354
|
+
const f = n.renderer === "CSS_HIGHLIGHTS" ? CSS.highlights ? "CSS_HIGHLIGHTS" : ae : n.renderer || ae, l = f === "SPANS" ? gn(t, o, s) : f === "CSS_HIGHLIGHTS" ? fn(t, o, s) : f === "CANVAS" ? en(t, o, s) : void 0;
|
|
2356
2355
|
if (!l)
|
|
2357
|
-
throw `Unknown renderer implementation: ${
|
|
2358
|
-
console.debug(`Using ${
|
|
2359
|
-
const
|
|
2360
|
-
|
|
2361
|
-
const p = Pn(o, a, n.adapter),
|
|
2362
|
-
|
|
2363
|
-
|
|
2356
|
+
throw `Unknown renderer implementation: ${f}`;
|
|
2357
|
+
console.debug(`Using ${f} renderer`), n.style && l.setStyle(n.style);
|
|
2358
|
+
const m = To(t, o, n.offsetReferenceSelector);
|
|
2359
|
+
m.setUser(c), m.setAnnotatingEnabled(n.annotatingEnabled);
|
|
2360
|
+
const p = Pn(o, a, n.adapter), w = () => c, b = (E) => {
|
|
2361
|
+
m.setAnnotatingEnabled(
|
|
2362
|
+
E === void 0 ? !0 : E
|
|
2364
2363
|
);
|
|
2365
|
-
},
|
|
2366
|
-
l.setFilter(
|
|
2367
|
-
},
|
|
2368
|
-
c =
|
|
2369
|
-
}, u = (
|
|
2370
|
-
|
|
2371
|
-
},
|
|
2372
|
-
|
|
2364
|
+
}, S = (E) => {
|
|
2365
|
+
l.setFilter(E), m.setFilter(E);
|
|
2366
|
+
}, g = (E) => {
|
|
2367
|
+
c = E, m.setUser(E);
|
|
2368
|
+
}, u = (E) => {
|
|
2369
|
+
E && (l.setPainter(po(E, n.presence)), E.on("selectionChange", () => l.redraw()));
|
|
2370
|
+
}, y = (E) => {
|
|
2371
|
+
E ? i.setSelected(E) : i.clear();
|
|
2373
2372
|
};
|
|
2374
2373
|
return {
|
|
2375
2374
|
...p,
|
|
2376
2375
|
destroy: () => {
|
|
2377
|
-
l.destroy(),
|
|
2376
|
+
l.destroy(), m.destroy(), a.destroy();
|
|
2378
2377
|
},
|
|
2379
2378
|
element: t,
|
|
2380
|
-
getUser:
|
|
2381
|
-
setAnnotatingEnabled:
|
|
2382
|
-
setFilter:
|
|
2379
|
+
getUser: w,
|
|
2380
|
+
setAnnotatingEnabled: b,
|
|
2381
|
+
setFilter: S,
|
|
2383
2382
|
setStyle: l.setStyle.bind(l),
|
|
2384
2383
|
redraw: l.redraw.bind(l),
|
|
2385
|
-
setUser:
|
|
2386
|
-
setSelected:
|
|
2384
|
+
setUser: g,
|
|
2385
|
+
setSelected: y,
|
|
2387
2386
|
setPresenceProvider: u,
|
|
2388
2387
|
setVisible: l.setVisible.bind(l),
|
|
2389
2388
|
on: d.on,
|
|
@@ -2395,14 +2394,14 @@ const ae = 300, Oe = ["up", "down", "left", "right"], Te = ke ? "⌘+a" : "ctrl+
|
|
|
2395
2394
|
export {
|
|
2396
2395
|
vt as DEFAULT_SELECTED_STYLE,
|
|
2397
2396
|
W as DEFAULT_STYLE,
|
|
2398
|
-
|
|
2397
|
+
ce as NOT_ANNOTATABLE_CLASS,
|
|
2399
2398
|
Z as NOT_ANNOTATABLE_SELECTOR,
|
|
2400
2399
|
k as Origin,
|
|
2401
2400
|
xn as UserSelectAction,
|
|
2402
2401
|
Io as W3CTextFormat,
|
|
2403
2402
|
Be as cancelSingleClickEvents,
|
|
2404
2403
|
ut as cloneKeyboardEvent,
|
|
2405
|
-
|
|
2404
|
+
xt as clonePointerEvent,
|
|
2406
2405
|
ko as createBody,
|
|
2407
2406
|
en as createCanvasRenderer,
|
|
2408
2407
|
fn as createHighlightsRenderer,
|
|
@@ -2415,7 +2414,7 @@ export {
|
|
|
2415
2414
|
Bo as denormalizeRectWithOffset,
|
|
2416
2415
|
Ro as fillDefaults,
|
|
2417
2416
|
Ue as getQuoteContext,
|
|
2418
|
-
|
|
2417
|
+
Ut as getRangeAnnotatableContents,
|
|
2419
2418
|
ke as isMac,
|
|
2420
2419
|
nt as isNotAnnotatable,
|
|
2421
2420
|
Me as isRangeAnnotatable,
|
|
@@ -2428,8 +2427,8 @@ export {
|
|
|
2428
2427
|
Ie as programmaticallyFocusable,
|
|
2429
2428
|
$e as rangeContains,
|
|
2430
2429
|
Pe as rangeToSelector,
|
|
2431
|
-
|
|
2432
|
-
|
|
2430
|
+
At as reviveAnnotation,
|
|
2431
|
+
le as reviveSelector,
|
|
2433
2432
|
wt as reviveTarget,
|
|
2434
2433
|
ze as scrollIntoView,
|
|
2435
2434
|
eo as serializeW3CTextAnnotation,
|