@recogito/text-annotator 3.0.0-rc.40 → 3.0.0-rc.41
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.
|
@@ -47,7 +47,7 @@ const P = {
|
|
|
47
47
|
return (...o) => {
|
|
48
48
|
clearTimeout(n), n = setTimeout(() => t.apply(void 0, o), e);
|
|
49
49
|
};
|
|
50
|
-
},
|
|
50
|
+
}, In = (t) => {
|
|
51
51
|
const e = t.cloneContents();
|
|
52
52
|
return e.querySelectorAll(X).forEach((n) => n.remove()), e;
|
|
53
53
|
}, xt = (t, e) => {
|
|
@@ -108,7 +108,7 @@ const P = {
|
|
|
108
108
|
for (; r != null; )
|
|
109
109
|
r === o && (s = !1), s && a.push(r), r === n && (s = !0), r = i.nextNode();
|
|
110
110
|
return a;
|
|
111
|
-
},
|
|
111
|
+
}, Vn = (t) => {
|
|
112
112
|
const { startContainer: e, endContainer: n } = t;
|
|
113
113
|
if (e === n)
|
|
114
114
|
return Array.from(t.getClientRects());
|
|
@@ -220,10 +220,13 @@ const P = {
|
|
|
220
220
|
}, rt = (t, e) => H(t.selector) ? t : {
|
|
221
221
|
...t,
|
|
222
222
|
selector: t.selector.map((n) => n.range instanceof Range && !n.range.collapsed ? n : Yt(n, e))
|
|
223
|
-
}, st = (t, e) => H(t.target.selector) ? t : { ...t, target: rt(t.target, e) }, he = (t) => {
|
|
223
|
+
}, st = (t, e) => H(t.target.selector) ? t : { ...t, target: rt(t.target, e) }, he = (t, e) => {
|
|
224
|
+
const n = t.cloneRange();
|
|
225
|
+
return e.contains(n.startContainer) || n.setStart(e, 0), e.contains(n.endContainer) || n.setEnd(e, e.childNodes.length), n;
|
|
226
|
+
}, fe = (t) => {
|
|
224
227
|
const { top: e, left: n } = t.getBoundingClientRect(), { innerWidth: o, innerHeight: i } = window, r = -n, s = -e, a = o - n, u = i - e;
|
|
225
228
|
return { top: e, left: n, minX: r, minY: s, maxX: a, maxY: u };
|
|
226
|
-
},
|
|
229
|
+
}, ge = (t) => {
|
|
227
230
|
let e = /* @__PURE__ */ new Set();
|
|
228
231
|
return (o) => {
|
|
229
232
|
const i = o.map((r) => r.id);
|
|
@@ -232,15 +235,15 @@ const P = {
|
|
|
232
235
|
}, yt = (t, e, n, o) => {
|
|
233
236
|
const { store: i, selection: r, hover: s } = e;
|
|
234
237
|
let a, u, h;
|
|
235
|
-
const p =
|
|
238
|
+
const p = ge(n), d = (T) => {
|
|
236
239
|
const { x: O, y: v } = t.getBoundingClientRect(), x = i.getAt(T.clientX - O, T.clientY - v, u);
|
|
237
240
|
x ? s.current !== x.id && (t.classList.add("hovered"), s.set(x.id)) : s.current && (t.classList.remove("hovered"), s.set(null));
|
|
238
241
|
};
|
|
239
242
|
t.addEventListener("pointermove", d);
|
|
240
243
|
const f = (T = !1) => {
|
|
241
244
|
h && h.clear();
|
|
242
|
-
const O =
|
|
243
|
-
const Kt =
|
|
245
|
+
const O = fe(t), { minX: v, minY: x, maxX: w, maxY: S } = O, M = u ? i.getIntersecting(v, x, w, S).filter(({ annotation: _ }) => u(_)) : i.getIntersecting(v, x, w, S), B = r.selected.map(({ id: _ }) => _), k = M.map(({ annotation: _, rects: Gt }) => {
|
|
246
|
+
const Kt = B.includes(_.id), Qt = _.id === s.current;
|
|
244
247
|
return { annotation: _, rects: Gt, state: { selected: Kt, hover: Qt } };
|
|
245
248
|
});
|
|
246
249
|
o.redraw(k, O, a, h, T), setTimeout(() => p(M.map(({ annotation: _ }) => _)), 1);
|
|
@@ -258,14 +261,14 @@ const P = {
|
|
|
258
261
|
i.recalculatePositions(), h && h.reset(), f();
|
|
259
262
|
});
|
|
260
263
|
window.addEventListener("resize", b);
|
|
261
|
-
const
|
|
262
|
-
|
|
264
|
+
const C = new ResizeObserver(b);
|
|
265
|
+
C.observe(t);
|
|
263
266
|
const L = { attributes: !0, childList: !0, subtree: !0 }, E = new MutationObserver((T) => {
|
|
264
267
|
T.every((v) => v.target === t || t.contains(v.target)) || f(!0);
|
|
265
268
|
});
|
|
266
269
|
return E.observe(document.body, L), {
|
|
267
270
|
destroy: () => {
|
|
268
|
-
t.removeEventListener("pointermove", d), o.destroy(), i.unobserve(m), l(), document.removeEventListener("scroll", c), window.removeEventListener("resize", b),
|
|
271
|
+
t.removeEventListener("pointermove", d), o.destroy(), i.unobserve(m), l(), document.removeEventListener("scroll", c), window.removeEventListener("resize", b), C.disconnect(), E.disconnect();
|
|
269
272
|
},
|
|
270
273
|
redraw: f,
|
|
271
274
|
setStyle: A,
|
|
@@ -273,14 +276,14 @@ const P = {
|
|
|
273
276
|
setPainter: g,
|
|
274
277
|
setVisible: o.setVisible
|
|
275
278
|
};
|
|
276
|
-
},
|
|
279
|
+
}, pe = () => {
|
|
277
280
|
const t = document.createElement("canvas");
|
|
278
281
|
return t.width = window.innerWidth, t.height = window.innerHeight, t.className = "r6o-canvas-highlight-layer bg", t;
|
|
279
|
-
},
|
|
282
|
+
}, me = (t, e) => {
|
|
280
283
|
t.width = window.innerWidth, t.height = window.innerHeight;
|
|
281
|
-
},
|
|
284
|
+
}, be = (t) => {
|
|
282
285
|
t.classList.add("r6o-annotatable");
|
|
283
|
-
const e =
|
|
286
|
+
const e = pe(), n = e.getContext("2d");
|
|
284
287
|
document.body.appendChild(e);
|
|
285
288
|
const o = (a, u, h, p) => requestAnimationFrame(() => {
|
|
286
289
|
const { width: d, height: f } = e;
|
|
@@ -290,25 +293,25 @@ const P = {
|
|
|
290
293
|
const { annotation: { target: { created: c } } } = m, { annotation: { target: { created: b } } } = l;
|
|
291
294
|
return c.getTime() - b.getTime();
|
|
292
295
|
}).forEach((m) => {
|
|
293
|
-
var
|
|
294
|
-
const l = h ? typeof h == "function" ? h(m.annotation, m.state) : h : (
|
|
296
|
+
var C;
|
|
297
|
+
const l = h ? typeof h == "function" ? h(m.annotation, m.state) : h : (C = m.state) != null && C.selected ? it : P, c = p && p.paint(m, u) || l, b = m.rects.map(({ x: L, y: E, width: R, height: T }) => ({
|
|
295
298
|
x: L + A,
|
|
296
299
|
y: E + g,
|
|
297
|
-
width:
|
|
300
|
+
width: R,
|
|
298
301
|
height: T
|
|
299
302
|
}));
|
|
300
303
|
if (n.fillStyle = c.fill, n.globalAlpha = c.fillOpacity || 1, b.forEach(
|
|
301
|
-
({ x: L, y: E, width:
|
|
304
|
+
({ x: L, y: E, width: R, height: T }) => n.fillRect(L, E, R, T)
|
|
302
305
|
), c.underlineColor) {
|
|
303
306
|
n.globalAlpha = 1, n.strokeStyle = c.underlineColor, n.lineWidth = c.underlineThickness ?? 1;
|
|
304
307
|
const L = c.underlineOffset ?? 0;
|
|
305
|
-
b.forEach(({ x: E, y:
|
|
306
|
-
n.beginPath(), n.moveTo(E,
|
|
308
|
+
b.forEach(({ x: E, y: R, width: T, height: O }) => {
|
|
309
|
+
n.beginPath(), n.moveTo(E, R + O + L), n.lineTo(E + T, R + O + L), n.stroke();
|
|
307
310
|
});
|
|
308
311
|
}
|
|
309
312
|
});
|
|
310
313
|
}), i = vt(() => {
|
|
311
|
-
|
|
314
|
+
me(e);
|
|
312
315
|
});
|
|
313
316
|
return window.addEventListener("resize", i), {
|
|
314
317
|
destroy: () => {
|
|
@@ -319,8 +322,8 @@ const P = {
|
|
|
319
322
|
},
|
|
320
323
|
redraw: o
|
|
321
324
|
};
|
|
322
|
-
},
|
|
323
|
-
var
|
|
325
|
+
}, ve = (t, e, n) => yt(t, e, n, be(t));
|
|
326
|
+
var ye = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, $ = function(t) {
|
|
324
327
|
return typeof t == "string" ? t.length > 0 : typeof t == "number";
|
|
325
328
|
}, I = function(t, e, n) {
|
|
326
329
|
return e === void 0 && (e = 0), n === void 0 && (n = Math.pow(10, e)), Math.round(n * t) / n + 0;
|
|
@@ -332,7 +335,7 @@ var ve = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, $ = function(t) {
|
|
|
332
335
|
return { r: D(t.r, 0, 255), g: D(t.g, 0, 255), b: D(t.b, 0, 255), a: D(t.a) };
|
|
333
336
|
}, at = function(t) {
|
|
334
337
|
return { r: I(t.r), g: I(t.g), b: I(t.b), a: I(t.a, 3) };
|
|
335
|
-
},
|
|
338
|
+
}, we = /^#([0-9a-f]{3,8})$/i, J = function(t) {
|
|
336
339
|
var e = t.toString(16);
|
|
337
340
|
return e.length < 2 ? "0" + e : e;
|
|
338
341
|
}, $t = function(t) {
|
|
@@ -353,16 +356,16 @@ var ve = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, $ = function(t) {
|
|
|
353
356
|
}, Q = function(t) {
|
|
354
357
|
return { h: (e = $t(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 };
|
|
355
358
|
var e, n, o, i;
|
|
356
|
-
},
|
|
357
|
-
var e =
|
|
359
|
+
}, xe = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, Ae = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, Ee = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, Se = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, Rt = { string: [[function(t) {
|
|
360
|
+
var e = we.exec(t);
|
|
358
361
|
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 ? I(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 ? I(parseInt(t.substr(6, 2), 16) / 255, 2) : 1 } : null : null;
|
|
359
362
|
}, "hex"], [function(t) {
|
|
360
|
-
var e =
|
|
363
|
+
var e = Ee.exec(t) || Se.exec(t);
|
|
361
364
|
return e ? e[2] !== e[4] || e[4] !== e[6] ? null : Et({ 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;
|
|
362
365
|
}, "rgb"], [function(t) {
|
|
363
|
-
var e =
|
|
366
|
+
var e = xe.exec(t) || Ae.exec(t);
|
|
364
367
|
if (!e) return null;
|
|
365
|
-
var n, o, i = St({ h: (n = e[1], o = e[2], o === void 0 && (o = "deg"), Number(n) * (
|
|
368
|
+
var n, o, i = St({ h: (n = e[1], o = e[2], o === void 0 && (o = "deg"), Number(n) * (ye[o] || 1)), s: Number(e[3]), l: Number(e[4]), a: e[5] === void 0 ? 1 : Number(e[5]) / (e[6] ? 100 : 1) });
|
|
366
369
|
return Lt(i);
|
|
367
370
|
}, "hsl"]], object: [[function(t) {
|
|
368
371
|
var e = t.r, n = t.g, o = t.b, i = t.a, r = i === void 0 ? 1 : i;
|
|
@@ -379,25 +382,25 @@ var ve = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, $ = function(t) {
|
|
|
379
382
|
return { h: Xt(a.h), s: D(a.s, 0, 100), v: D(a.v, 0, 100), a: D(a.a) };
|
|
380
383
|
}({ h: Number(e), s: Number(n), v: Number(o), a: Number(r) });
|
|
381
384
|
return Ht(s);
|
|
382
|
-
}, "hsv"]] },
|
|
385
|
+
}, "hsv"]] }, Tt = function(t, e) {
|
|
383
386
|
for (var n = 0; n < e.length; n++) {
|
|
384
387
|
var o = e[n][0](t);
|
|
385
388
|
if (o) return [o, e[n][1]];
|
|
386
389
|
}
|
|
387
390
|
return [null, void 0];
|
|
388
|
-
},
|
|
389
|
-
return typeof t == "string" ?
|
|
391
|
+
}, Ce = function(t) {
|
|
392
|
+
return typeof t == "string" ? Tt(t.trim(), Rt.string) : typeof t == "object" && t !== null ? Tt(t, Rt.object) : [null, void 0];
|
|
390
393
|
}, ct = function(t, e) {
|
|
391
394
|
var n = Q(t);
|
|
392
395
|
return { h: n.h, s: D(n.s + 100 * e, 0, 100), l: n.l, a: n.a };
|
|
393
396
|
}, lt = function(t) {
|
|
394
397
|
return (299 * t.r + 587 * t.g + 114 * t.b) / 1e3 / 255;
|
|
395
|
-
},
|
|
398
|
+
}, Bt = function(t, e) {
|
|
396
399
|
var n = Q(t);
|
|
397
400
|
return { h: n.h, s: n.s, l: D(n.l + 100 * e, 0, 100), a: n.a };
|
|
398
401
|
}, Nt = function() {
|
|
399
402
|
function t(e) {
|
|
400
|
-
this.parsed =
|
|
403
|
+
this.parsed = Ce(e)[0], this.rgba = this.parsed || { r: 0, g: 0, b: 0, a: 1 };
|
|
401
404
|
}
|
|
402
405
|
return t.prototype.isValid = function() {
|
|
403
406
|
return this.parsed !== null;
|
|
@@ -433,9 +436,9 @@ var ve = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, $ = function(t) {
|
|
|
433
436
|
}, t.prototype.grayscale = function() {
|
|
434
437
|
return Y(ct(this.rgba, -1));
|
|
435
438
|
}, t.prototype.lighten = function(e) {
|
|
436
|
-
return e === void 0 && (e = 0.1), Y(
|
|
439
|
+
return e === void 0 && (e = 0.1), Y(Bt(this.rgba, e));
|
|
437
440
|
}, t.prototype.darken = function(e) {
|
|
438
|
-
return e === void 0 && (e = 0.1), Y(
|
|
441
|
+
return e === void 0 && (e = 0.1), Y(Bt(this.rgba, -e));
|
|
439
442
|
}, t.prototype.rotate = function(e) {
|
|
440
443
|
return e === void 0 && (e = 15), this.hue(this.hue() + e);
|
|
441
444
|
}, t.prototype.alpha = function(e) {
|
|
@@ -450,13 +453,13 @@ var ve = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, $ = function(t) {
|
|
|
450
453
|
}(), Y = function(t) {
|
|
451
454
|
return t instanceof Nt ? t : new Nt(t);
|
|
452
455
|
};
|
|
453
|
-
const
|
|
456
|
+
const Le = (t) => [
|
|
454
457
|
`background-color:${Y((t == null ? void 0 : t.fill) || P.fill).alpha((t == null ? void 0 : t.fillOpacity) === void 0 ? P.fillOpacity : t.fillOpacity).toHex()}`,
|
|
455
458
|
t != null && t.underlineThickness ? "text-decoration:underline" : void 0,
|
|
456
459
|
t != null && t.underlineColor ? `text-decoration-color:${t.underlineColor}` : void 0,
|
|
457
460
|
t != null && t.underlineOffset ? `text-underline-offset:${t.underlineOffset}px` : void 0,
|
|
458
461
|
t != null && t.underlineThickness ? `text-decoration-thickness:${t.underlineThickness}px` : void 0
|
|
459
|
-
].filter(Boolean).join(";"),
|
|
462
|
+
].filter(Boolean).join(";"), Re = () => {
|
|
460
463
|
const t = document.createElement("style");
|
|
461
464
|
document.getElementsByTagName("head")[0].appendChild(t);
|
|
462
465
|
let e = /* @__PURE__ */ new Set();
|
|
@@ -474,7 +477,7 @@ const Ce = (t) => [
|
|
|
474
477
|
const p = r.map((d) => {
|
|
475
478
|
var A;
|
|
476
479
|
const f = a ? typeof a == "function" ? a(d.annotation, d.state) : a : (A = d.state) != null && A.selected ? it : P, g = u && u.paint(d, s) || f;
|
|
477
|
-
return `::highlight(_${d.annotation.id}) { ${
|
|
480
|
+
return `::highlight(_${d.annotation.id}) { ${Le(g)} }`;
|
|
478
481
|
});
|
|
479
482
|
t.innerHTML = p.join(`
|
|
480
483
|
`), CSS.highlights.clear(), r.forEach(({ annotation: d }) => {
|
|
@@ -483,7 +486,7 @@ const Ce = (t) => [
|
|
|
483
486
|
}), e = h;
|
|
484
487
|
}
|
|
485
488
|
};
|
|
486
|
-
}, Te = (t, e, n) => yt(t, e, n,
|
|
489
|
+
}, Te = (t, e, n) => yt(t, e, n, Re());
|
|
487
490
|
var Mt = Object.prototype.hasOwnProperty;
|
|
488
491
|
function bt(t, e) {
|
|
489
492
|
var n, o;
|
|
@@ -508,7 +511,7 @@ function bt(t, e) {
|
|
|
508
511
|
const Be = (t, e) => {
|
|
509
512
|
const n = (r, s) => r.x <= s.x + s.width && r.x + r.width >= s.x && r.y <= s.y + s.height && r.y + r.height >= s.y, o = (r) => r.rects.reduce((s, a) => s + a.width, 0), i = e.filter(({ rects: r }) => r.some((s) => n(t, s)));
|
|
510
513
|
return i.sort((r, s) => o(s) - o(r)), i.findIndex((r) => r.rects.includes(t));
|
|
511
|
-
},
|
|
514
|
+
}, Ne = (t) => {
|
|
512
515
|
t.classList.add("r6o-annotatable");
|
|
513
516
|
const e = document.createElement("div");
|
|
514
517
|
e.className = "r6o-span-highlight-layer", t.insertBefore(e, t.firstChild);
|
|
@@ -533,29 +536,29 @@ const Be = (t, e) => {
|
|
|
533
536
|
s ? e.classList.remove("hidden") : e.classList.add("hidden");
|
|
534
537
|
}
|
|
535
538
|
};
|
|
536
|
-
},
|
|
539
|
+
}, Me = (t, e, n) => yt(t, e, n, Ne(t));
|
|
537
540
|
var V = [];
|
|
538
541
|
for (var dt = 0; dt < 256; ++dt)
|
|
539
542
|
V.push((dt + 256).toString(16).slice(1));
|
|
540
|
-
function
|
|
543
|
+
function Oe(t, e = 0) {
|
|
541
544
|
return (V[t[e + 0]] + V[t[e + 1]] + V[t[e + 2]] + V[t[e + 3]] + "-" + V[t[e + 4]] + V[t[e + 5]] + "-" + V[t[e + 6]] + V[t[e + 7]] + "-" + V[t[e + 8]] + V[t[e + 9]] + "-" + V[t[e + 10]] + V[t[e + 11]] + V[t[e + 12]] + V[t[e + 13]] + V[t[e + 14]] + V[t[e + 15]]).toLowerCase();
|
|
542
545
|
}
|
|
543
|
-
var Z,
|
|
544
|
-
function
|
|
546
|
+
var Z, Ie = new Uint8Array(16);
|
|
547
|
+
function Ve() {
|
|
545
548
|
if (!Z && (Z = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !Z))
|
|
546
549
|
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
547
|
-
return Z(
|
|
550
|
+
return Z(Ie);
|
|
548
551
|
}
|
|
549
|
-
var
|
|
552
|
+
var Ue = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
|
|
550
553
|
const Ot = {
|
|
551
|
-
randomUUID:
|
|
554
|
+
randomUUID: Ue
|
|
552
555
|
};
|
|
553
556
|
function Pt(t, e, n) {
|
|
554
557
|
if (Ot.randomUUID && !e && !t)
|
|
555
558
|
return Ot.randomUUID();
|
|
556
559
|
t = t || {};
|
|
557
|
-
var o = t.random || (t.rng ||
|
|
558
|
-
return o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128,
|
|
560
|
+
var o = t.random || (t.rng || Ve)();
|
|
561
|
+
return o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128, Oe(o);
|
|
559
562
|
}
|
|
560
563
|
var It = Object.prototype.hasOwnProperty;
|
|
561
564
|
function z(t, e) {
|
|
@@ -580,7 +583,7 @@ function z(t, e) {
|
|
|
580
583
|
}
|
|
581
584
|
function ut() {
|
|
582
585
|
}
|
|
583
|
-
function
|
|
586
|
+
function ke(t, e) {
|
|
584
587
|
return t != t ? e == e : t !== e || t && typeof t == "object" || typeof t == "function";
|
|
585
588
|
}
|
|
586
589
|
const F = [];
|
|
@@ -588,7 +591,7 @@ function wt(t, e = ut) {
|
|
|
588
591
|
let n;
|
|
589
592
|
const o = /* @__PURE__ */ new Set();
|
|
590
593
|
function i(a) {
|
|
591
|
-
if (
|
|
594
|
+
if (ke(t, a) && (t = a, n)) {
|
|
592
595
|
const u = !F.length;
|
|
593
596
|
for (const h of o)
|
|
594
597
|
h[1](), F.push(h, t);
|
|
@@ -610,7 +613,7 @@ function wt(t, e = ut) {
|
|
|
610
613
|
}
|
|
611
614
|
return { set: i, update: r, subscribe: s };
|
|
612
615
|
}
|
|
613
|
-
const
|
|
616
|
+
const _e = (t) => {
|
|
614
617
|
const { subscribe: e, set: n } = wt();
|
|
615
618
|
let o;
|
|
616
619
|
return e((i) => o = i), t.observe(({ changes: i }) => {
|
|
@@ -627,8 +630,8 @@ const ke = (t) => {
|
|
|
627
630
|
set: n
|
|
628
631
|
};
|
|
629
632
|
};
|
|
630
|
-
var
|
|
631
|
-
const tt = { selected: [] },
|
|
633
|
+
var De = /* @__PURE__ */ ((t) => (t.EDIT = "EDIT", t.SELECT = "SELECT", t.NONE = "NONE", t))(De || {});
|
|
634
|
+
const tt = { selected: [] }, Ye = (t) => {
|
|
632
635
|
const { subscribe: e, set: n } = wt(tt);
|
|
633
636
|
let o, i = tt;
|
|
634
637
|
e((f) => i = f);
|
|
@@ -696,54 +699,54 @@ const tt = { selected: [] }, De = (t) => {
|
|
|
696
699
|
var U = [];
|
|
697
700
|
for (var ht = 0; ht < 256; ++ht)
|
|
698
701
|
U.push((ht + 256).toString(16).slice(1));
|
|
699
|
-
function
|
|
702
|
+
function Xe(t, e = 0) {
|
|
700
703
|
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();
|
|
701
704
|
}
|
|
702
|
-
var et,
|
|
703
|
-
function
|
|
705
|
+
var et, $e = new Uint8Array(16);
|
|
706
|
+
function He() {
|
|
704
707
|
if (!et && (et = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !et))
|
|
705
708
|
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
706
|
-
return et(
|
|
709
|
+
return et($e);
|
|
707
710
|
}
|
|
708
|
-
var
|
|
711
|
+
var Pe = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
|
|
709
712
|
const Ut = {
|
|
710
|
-
randomUUID:
|
|
713
|
+
randomUUID: Pe
|
|
711
714
|
};
|
|
712
715
|
function zt(t, e, n) {
|
|
713
716
|
if (Ut.randomUUID && !e && !t)
|
|
714
717
|
return Ut.randomUUID();
|
|
715
718
|
t = t || {};
|
|
716
|
-
var o = t.random || (t.rng ||
|
|
717
|
-
return o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128,
|
|
719
|
+
var o = t.random || (t.rng || He)();
|
|
720
|
+
return o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128, Xe(o);
|
|
718
721
|
}
|
|
719
|
-
const
|
|
722
|
+
const Un = (t, e, n, o) => ({
|
|
720
723
|
id: zt(),
|
|
721
724
|
annotation: typeof t == "string" ? t : t.id,
|
|
722
725
|
created: n || /* @__PURE__ */ new Date(),
|
|
723
726
|
creator: o,
|
|
724
727
|
...e
|
|
725
|
-
}),
|
|
728
|
+
}), ze = (t, e) => {
|
|
726
729
|
const n = new Set(t.bodies.map((o) => o.id));
|
|
727
730
|
return e.bodies.filter((o) => !n.has(o.id));
|
|
728
|
-
},
|
|
731
|
+
}, Fe = (t, e) => {
|
|
729
732
|
const n = new Set(e.bodies.map((o) => o.id));
|
|
730
733
|
return t.bodies.filter((o) => !n.has(o.id));
|
|
731
|
-
},
|
|
734
|
+
}, je = (t, e) => e.bodies.map((n) => {
|
|
732
735
|
const o = t.bodies.find((i) => i.id === n.id);
|
|
733
736
|
return { newBody: n, oldBody: o && !z(o, n) ? o : void 0 };
|
|
734
|
-
}).filter(({ oldBody: n }) => n).map(({ oldBody: n, newBody: o }) => ({ oldBody: n, newBody: o })),
|
|
735
|
-
const n =
|
|
737
|
+
}).filter(({ oldBody: n }) => n).map(({ oldBody: n, newBody: o }) => ({ oldBody: n, newBody: o })), We = (t, e) => !z(t.target, e.target), Ft = (t, e) => {
|
|
738
|
+
const n = ze(t, e), o = Fe(t, e), i = je(t, e);
|
|
736
739
|
return {
|
|
737
740
|
oldValue: t,
|
|
738
741
|
newValue: e,
|
|
739
742
|
bodiesCreated: n.length > 0 ? n : void 0,
|
|
740
743
|
bodiesDeleted: o.length > 0 ? o : void 0,
|
|
741
744
|
bodiesUpdated: i.length > 0 ? i : void 0,
|
|
742
|
-
targetUpdated:
|
|
745
|
+
targetUpdated: We(t, e) ? { oldTarget: t.target, newTarget: e.target } : void 0
|
|
743
746
|
};
|
|
744
747
|
};
|
|
745
748
|
var N = /* @__PURE__ */ ((t) => (t.LOCAL = "LOCAL", t.REMOTE = "REMOTE", t))(N || {});
|
|
746
|
-
const
|
|
749
|
+
const qe = (t, e) => {
|
|
747
750
|
var n, o;
|
|
748
751
|
const { changes: i, origin: r } = e;
|
|
749
752
|
if (!(!t.options.origin || t.options.origin === r))
|
|
@@ -765,7 +768,7 @@ const We = (t, e) => {
|
|
|
765
768
|
return !!(Array.isArray(t.options.annotations) ? t.options.annotations : [t.options.annotations]).find((a) => s.has(a));
|
|
766
769
|
} else
|
|
767
770
|
return !0;
|
|
768
|
-
},
|
|
771
|
+
}, Ge = (t, e) => {
|
|
769
772
|
const n = new Set((t.created || []).map((d) => d.id)), o = new Set((t.updated || []).map(({ newValue: d }) => d.id)), i = new Set((e.created || []).map((d) => d.id)), r = new Set((e.deleted || []).map((d) => d.id)), s = new Set((e.updated || []).map(({ oldValue: d }) => d.id)), a = new Set((e.updated || []).filter(({ oldValue: d }) => n.has(d.id) || o.has(d.id)).map(({ oldValue: d }) => d.id)), u = [
|
|
770
773
|
...(t.created || []).filter((d) => !r.has(d.id)).map((d) => s.has(d.id) ? e.updated.find(({ oldValue: f }) => f.id === d.id).newValue : d),
|
|
771
774
|
...e.created || []
|
|
@@ -798,7 +801,7 @@ const We = (t, e) => {
|
|
|
798
801
|
annotation: e
|
|
799
802
|
}
|
|
800
803
|
};
|
|
801
|
-
},
|
|
804
|
+
}, Ke = (t) => t.id !== void 0, Qe = () => {
|
|
802
805
|
const t = /* @__PURE__ */ new Map(), e = /* @__PURE__ */ new Map(), n = [], o = (v, x = {}) => n.push({ onChange: v, options: x }), i = (v) => {
|
|
803
806
|
const x = n.findIndex((w) => w.onChange == v);
|
|
804
807
|
x > -1 && n.splice(x, 1);
|
|
@@ -812,42 +815,42 @@ const We = (t, e) => {
|
|
|
812
815
|
},
|
|
813
816
|
state: [...t.values()]
|
|
814
817
|
};
|
|
815
|
-
n.forEach((
|
|
816
|
-
|
|
818
|
+
n.forEach((S) => {
|
|
819
|
+
qe(S, w) && S.onChange(w);
|
|
817
820
|
});
|
|
818
821
|
}, s = (v, x = N.LOCAL) => {
|
|
819
822
|
if (v.id && t.get(v.id))
|
|
820
823
|
throw Error(`Cannot add annotation ${v.id} - exists already`);
|
|
821
824
|
{
|
|
822
825
|
const w = ft(v);
|
|
823
|
-
t.set(w.id, w), w.bodies.forEach((
|
|
826
|
+
t.set(w.id, w), w.bodies.forEach((S) => e.set(S.id, w.id)), r(x, { created: [w] });
|
|
824
827
|
}
|
|
825
828
|
}, a = (v, x) => {
|
|
826
|
-
const w = ft(typeof v == "string" ? x : v),
|
|
829
|
+
const w = ft(typeof v == "string" ? x : v), S = typeof v == "string" ? v : v.id, M = S && t.get(S);
|
|
827
830
|
if (M) {
|
|
828
|
-
const
|
|
829
|
-
return
|
|
831
|
+
const B = Ft(M, w);
|
|
832
|
+
return S === w.id ? t.set(S, w) : (t.delete(S), t.set(w.id, w)), M.bodies.forEach((k) => e.delete(k.id)), w.bodies.forEach((k) => e.set(k.id, w.id)), B;
|
|
830
833
|
} else
|
|
831
|
-
console.warn(`Cannot update annotation ${
|
|
834
|
+
console.warn(`Cannot update annotation ${S} - does not exist`);
|
|
832
835
|
}, u = (v, x = N.LOCAL, w = N.LOCAL) => {
|
|
833
|
-
const
|
|
834
|
-
M && r(
|
|
836
|
+
const S = Ke(x) ? w : x, M = a(v, x);
|
|
837
|
+
M && r(S, { updated: [M] });
|
|
835
838
|
}, h = (v, x = N.LOCAL) => {
|
|
836
|
-
const w = v.reduce((
|
|
837
|
-
const
|
|
838
|
-
return
|
|
839
|
+
const w = v.reduce((S, M) => {
|
|
840
|
+
const B = a(M);
|
|
841
|
+
return B ? [...S, B] : S;
|
|
839
842
|
}, []);
|
|
840
843
|
w.length > 0 && r(x, { updated: w });
|
|
841
844
|
}, p = (v, x = N.LOCAL) => {
|
|
842
845
|
const w = t.get(v.annotation);
|
|
843
846
|
if (w) {
|
|
844
|
-
const
|
|
847
|
+
const S = {
|
|
845
848
|
...w,
|
|
846
849
|
bodies: [...w.bodies, v]
|
|
847
850
|
};
|
|
848
|
-
t.set(w.id,
|
|
851
|
+
t.set(w.id, S), e.set(v.id, S.id), r(x, { updated: [{
|
|
849
852
|
oldValue: w,
|
|
850
|
-
newValue:
|
|
853
|
+
newValue: S,
|
|
851
854
|
bodiesCreated: [v]
|
|
852
855
|
}] });
|
|
853
856
|
} else
|
|
@@ -856,50 +859,50 @@ const We = (t, e) => {
|
|
|
856
859
|
const x = [...t.values()];
|
|
857
860
|
t.clear(), e.clear(), r(v, { deleted: x });
|
|
858
861
|
}, g = (v, x = !0, w = N.LOCAL) => {
|
|
859
|
-
const
|
|
862
|
+
const S = v.map(ft);
|
|
860
863
|
if (x) {
|
|
861
864
|
const M = [...t.values()];
|
|
862
|
-
t.clear(), e.clear(),
|
|
863
|
-
t.set(
|
|
864
|
-
}), r(w, { created:
|
|
865
|
+
t.clear(), e.clear(), S.forEach((B) => {
|
|
866
|
+
t.set(B.id, B), B.bodies.forEach((k) => e.set(k.id, B.id));
|
|
867
|
+
}), r(w, { created: S, deleted: M });
|
|
865
868
|
} else {
|
|
866
|
-
const M = v.reduce((
|
|
869
|
+
const M = v.reduce((B, k) => {
|
|
867
870
|
const _ = k.id && t.get(k.id);
|
|
868
|
-
return _ ? [...
|
|
871
|
+
return _ ? [...B, _] : B;
|
|
869
872
|
}, []);
|
|
870
873
|
if (M.length > 0)
|
|
871
|
-
throw Error(`Bulk insert would overwrite the following annotations: ${M.map((
|
|
872
|
-
|
|
873
|
-
t.set(
|
|
874
|
-
}), r(w, { created:
|
|
874
|
+
throw Error(`Bulk insert would overwrite the following annotations: ${M.map((B) => B.id).join(", ")}`);
|
|
875
|
+
S.forEach((B) => {
|
|
876
|
+
t.set(B.id, B), B.bodies.forEach((k) => e.set(k.id, B.id));
|
|
877
|
+
}), r(w, { created: S });
|
|
875
878
|
}
|
|
876
879
|
}, A = (v) => {
|
|
877
880
|
const x = typeof v == "string" ? v : v.id, w = t.get(x);
|
|
878
881
|
if (w)
|
|
879
|
-
return t.delete(x), w.bodies.forEach((
|
|
882
|
+
return t.delete(x), w.bodies.forEach((S) => e.delete(S.id)), w;
|
|
880
883
|
console.warn(`Attempt to delete missing annotation: ${x}`);
|
|
881
884
|
}, y = (v, x = N.LOCAL) => {
|
|
882
885
|
const w = A(v);
|
|
883
886
|
w && r(x, { deleted: [w] });
|
|
884
887
|
}, m = (v, x = N.LOCAL) => {
|
|
885
|
-
const w = v.reduce((
|
|
886
|
-
const
|
|
887
|
-
return
|
|
888
|
+
const w = v.reduce((S, M) => {
|
|
889
|
+
const B = A(M);
|
|
890
|
+
return B ? [...S, B] : S;
|
|
888
891
|
}, []);
|
|
889
892
|
w.length > 0 && r(x, { deleted: w });
|
|
890
893
|
}, l = (v) => {
|
|
891
894
|
const x = t.get(v.annotation);
|
|
892
895
|
if (x) {
|
|
893
|
-
const w = x.bodies.find((
|
|
896
|
+
const w = x.bodies.find((S) => S.id === v.id);
|
|
894
897
|
if (w) {
|
|
895
898
|
e.delete(w.id);
|
|
896
|
-
const
|
|
899
|
+
const S = {
|
|
897
900
|
...x,
|
|
898
901
|
bodies: x.bodies.filter((M) => M.id !== v.id)
|
|
899
902
|
};
|
|
900
|
-
return t.set(x.id,
|
|
903
|
+
return t.set(x.id, S), {
|
|
901
904
|
oldValue: x,
|
|
902
|
-
newValue:
|
|
905
|
+
newValue: S,
|
|
903
906
|
bodiesDeleted: [w]
|
|
904
907
|
};
|
|
905
908
|
} else
|
|
@@ -910,15 +913,15 @@ const We = (t, e) => {
|
|
|
910
913
|
const w = l(v);
|
|
911
914
|
w && r(x, { updated: [w] });
|
|
912
915
|
}, b = (v, x = N.LOCAL) => {
|
|
913
|
-
const w = v.map((
|
|
916
|
+
const w = v.map((S) => l(S)).filter(Boolean);
|
|
914
917
|
w.length > 0 && r(x, { updated: w });
|
|
915
|
-
},
|
|
918
|
+
}, C = (v) => {
|
|
916
919
|
const x = t.get(v);
|
|
917
920
|
return x ? { ...x } : void 0;
|
|
918
921
|
}, L = (v) => {
|
|
919
922
|
const x = e.get(v);
|
|
920
923
|
if (x) {
|
|
921
|
-
const w =
|
|
924
|
+
const w = C(x).bodies.find((S) => S.id === v);
|
|
922
925
|
if (w)
|
|
923
926
|
return w;
|
|
924
927
|
console.error(`Store integrity error: body ${v} in index, but not in annotation`);
|
|
@@ -929,22 +932,22 @@ const We = (t, e) => {
|
|
|
929
932
|
throw "Annotation integrity violation: annotation ID must be the same when updating bodies";
|
|
930
933
|
const w = t.get(v.annotation);
|
|
931
934
|
if (w) {
|
|
932
|
-
const
|
|
935
|
+
const S = w.bodies.find((B) => B.id === v.id), M = {
|
|
933
936
|
...w,
|
|
934
|
-
bodies: w.bodies.map((
|
|
937
|
+
bodies: w.bodies.map((B) => B.id === S.id ? x : B)
|
|
935
938
|
};
|
|
936
|
-
return t.set(w.id, M),
|
|
939
|
+
return t.set(w.id, M), S.id !== x.id && (e.delete(S.id), e.set(x.id, M.id)), {
|
|
937
940
|
oldValue: w,
|
|
938
941
|
newValue: M,
|
|
939
|
-
bodiesUpdated: [{ oldBody:
|
|
942
|
+
bodiesUpdated: [{ oldBody: S, newBody: x }]
|
|
940
943
|
};
|
|
941
944
|
} else
|
|
942
945
|
console.warn(`Attempt to add body to missing annotation ${v.annotation}`);
|
|
943
|
-
},
|
|
944
|
-
const
|
|
945
|
-
|
|
946
|
+
}, R = (v, x, w = N.LOCAL) => {
|
|
947
|
+
const S = E(v, x);
|
|
948
|
+
S && r(w, { updated: [S] });
|
|
946
949
|
}, T = (v, x = N.LOCAL) => {
|
|
947
|
-
const w = v.map((
|
|
950
|
+
const w = v.map((S) => E({ id: S.id, annotation: S.annotation }, S)).filter(Boolean);
|
|
948
951
|
r(x, { updated: w });
|
|
949
952
|
}, O = (v) => {
|
|
950
953
|
const x = t.get(v.annotation);
|
|
@@ -977,25 +980,25 @@ const We = (t, e) => {
|
|
|
977
980
|
bulkUpdateAnnotation: h,
|
|
978
981
|
bulkUpdateBodies: T,
|
|
979
982
|
bulkUpdateTargets: (v, x = N.LOCAL) => {
|
|
980
|
-
const w = v.map((
|
|
983
|
+
const w = v.map((S) => O(S)).filter(Boolean);
|
|
981
984
|
w.length > 0 && r(x, { updated: w });
|
|
982
985
|
},
|
|
983
986
|
clear: f,
|
|
984
987
|
deleteAnnotation: y,
|
|
985
988
|
deleteBody: c,
|
|
986
|
-
getAnnotation:
|
|
989
|
+
getAnnotation: C,
|
|
987
990
|
getBody: L,
|
|
988
991
|
observe: o,
|
|
989
992
|
unobserve: i,
|
|
990
993
|
updateAnnotation: u,
|
|
991
|
-
updateBody:
|
|
994
|
+
updateBody: R,
|
|
992
995
|
updateTarget: (v, x = N.LOCAL) => {
|
|
993
996
|
const w = O(v);
|
|
994
997
|
w && r(x, { updated: [w] });
|
|
995
998
|
}
|
|
996
999
|
};
|
|
997
1000
|
};
|
|
998
|
-
let
|
|
1001
|
+
let Je = () => ({
|
|
999
1002
|
emit(t, ...e) {
|
|
1000
1003
|
for (let n = 0, o = this.events[t] || [], i = o.length; n < i; n++)
|
|
1001
1004
|
o[n](...e);
|
|
@@ -1009,17 +1012,17 @@ let Qe = () => ({
|
|
|
1009
1012
|
};
|
|
1010
1013
|
}
|
|
1011
1014
|
});
|
|
1012
|
-
const
|
|
1013
|
-
const e =
|
|
1015
|
+
const Ze = 250, tn = (t) => {
|
|
1016
|
+
const e = Je(), n = [];
|
|
1014
1017
|
let o = -1, i = !1, r = 0;
|
|
1015
1018
|
const s = (g) => {
|
|
1016
1019
|
if (!i) {
|
|
1017
1020
|
const { changes: A } = g, y = performance.now();
|
|
1018
|
-
if (y - r >
|
|
1021
|
+
if (y - r > Ze)
|
|
1019
1022
|
n.splice(o + 1), n.push(A), o = n.length - 1;
|
|
1020
1023
|
else {
|
|
1021
1024
|
const m = n.length - 1;
|
|
1022
|
-
n[m] =
|
|
1025
|
+
n[m] = Ge(n[m], A);
|
|
1023
1026
|
}
|
|
1024
1027
|
r = y;
|
|
1025
1028
|
}
|
|
@@ -1047,13 +1050,13 @@ const Je = 250, Ze = (t) => {
|
|
|
1047
1050
|
}
|
|
1048
1051
|
}
|
|
1049
1052
|
};
|
|
1050
|
-
},
|
|
1053
|
+
}, en = () => {
|
|
1051
1054
|
const { subscribe: t, set: e } = wt([]);
|
|
1052
1055
|
return {
|
|
1053
1056
|
subscribe: t,
|
|
1054
1057
|
set: e
|
|
1055
1058
|
};
|
|
1056
|
-
},
|
|
1059
|
+
}, nn = (t, e, n, o) => {
|
|
1057
1060
|
const { store: i, selection: r, hover: s, viewport: a } = t, u = /* @__PURE__ */ new Map();
|
|
1058
1061
|
let h = [], p;
|
|
1059
1062
|
const d = (y, m) => {
|
|
@@ -1068,8 +1071,8 @@ const Je = 250, Ze = (t) => {
|
|
|
1068
1071
|
u.has(y) && setTimeout(() => {
|
|
1069
1072
|
u.get(y).forEach((c) => {
|
|
1070
1073
|
if (n) {
|
|
1071
|
-
const b = Array.isArray(m) ? m.map((L) => n.serialize(L)) : n.serialize(m),
|
|
1072
|
-
c(b,
|
|
1074
|
+
const b = Array.isArray(m) ? m.map((L) => n.serialize(L)) : n.serialize(m), C = l ? l instanceof PointerEvent ? l : n.serialize(l) : void 0;
|
|
1075
|
+
c(b, C);
|
|
1073
1076
|
} else
|
|
1074
1077
|
c(m, l);
|
|
1075
1078
|
});
|
|
@@ -1107,13 +1110,13 @@ const Je = 250, Ze = (t) => {
|
|
|
1107
1110
|
...c.bodiesDeleted || [],
|
|
1108
1111
|
...c.bodiesUpdated || []
|
|
1109
1112
|
].length > 0).forEach(({ oldValue: c, newValue: b }) => {
|
|
1110
|
-
const
|
|
1111
|
-
h = h.map((L) => L.id === c.id ? b : L), g("updateAnnotation", b,
|
|
1113
|
+
const C = h.find((L) => L.id === c.id) || c;
|
|
1114
|
+
h = h.map((L) => L.id === c.id ? b : L), g("updateAnnotation", b, C);
|
|
1112
1115
|
});
|
|
1113
1116
|
}, { origin: N.LOCAL }), i.observe((y) => {
|
|
1114
1117
|
if (h) {
|
|
1115
1118
|
const m = new Set(h.map((c) => c.id)), l = (y.changes.updated || []).filter(({ newValue: c }) => m.has(c.id)).map(({ newValue: c }) => c);
|
|
1116
|
-
l.length > 0 && (h = h.map((c) => l.find((
|
|
1119
|
+
l.length > 0 && (h = h.map((c) => l.find((C) => C.id === c.id) || c));
|
|
1117
1120
|
}
|
|
1118
1121
|
}, { origin: N.REMOTE });
|
|
1119
1122
|
const A = (y) => (m) => {
|
|
@@ -1121,7 +1124,7 @@ const Je = 250, Ze = (t) => {
|
|
|
1121
1124
|
y ? (l || []).forEach((c) => g("updateAnnotation", c.oldValue, c.newValue)) : (l || []).forEach((c) => g("updateAnnotation", c.newValue, c.oldValue));
|
|
1122
1125
|
};
|
|
1123
1126
|
return e.on("undo", A(!0)), e.on("redo", A(!1)), { on: d, off: f, emit: g };
|
|
1124
|
-
},
|
|
1127
|
+
}, on = (t) => (e) => e.reduce((n, o) => {
|
|
1125
1128
|
const { parsed: i, error: r } = t.parse(o);
|
|
1126
1129
|
return r ? {
|
|
1127
1130
|
parsed: n.parsed,
|
|
@@ -1132,7 +1135,7 @@ const Je = 250, Ze = (t) => {
|
|
|
1132
1135
|
} : {
|
|
1133
1136
|
...n
|
|
1134
1137
|
};
|
|
1135
|
-
}, { parsed: [], failed: [] }),
|
|
1138
|
+
}, { parsed: [], failed: [] }), rn = (t, e, n) => {
|
|
1136
1139
|
const { store: o, selection: i } = t, r = (l) => {
|
|
1137
1140
|
if (n) {
|
|
1138
1141
|
const { parsed: c, error: b } = n.parse(l);
|
|
@@ -1158,8 +1161,8 @@ const Je = 250, Ze = (t) => {
|
|
|
1158
1161
|
}
|
|
1159
1162
|
}, g = (l, c = !0) => {
|
|
1160
1163
|
if (n) {
|
|
1161
|
-
const { parsed: b, failed:
|
|
1162
|
-
|
|
1164
|
+
const { parsed: b, failed: C } = on(n)(l);
|
|
1165
|
+
C.length > 0 && console.warn(`Discarded ${C.length} invalid annotations`, C), o.bulkAddAnnotation(b, c, N.REMOTE);
|
|
1163
1166
|
} else
|
|
1164
1167
|
o.bulkAddAnnotation(l, c, N.REMOTE);
|
|
1165
1168
|
}, A = (l, c) => {
|
|
@@ -1193,8 +1196,8 @@ const Je = 250, Ze = (t) => {
|
|
|
1193
1196
|
undo: e.undo,
|
|
1194
1197
|
updateAnnotation: m
|
|
1195
1198
|
};
|
|
1196
|
-
},
|
|
1197
|
-
let
|
|
1199
|
+
}, sn = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
|
|
1200
|
+
let an = (t) => crypto.getRandomValues(new Uint8Array(t)), cn = (t, e, n) => {
|
|
1198
1201
|
let o = (2 << Math.log(t.length - 1) / Math.LN2) - 1, i = -~(1.6 * o * e / t.length);
|
|
1199
1202
|
return (r = e) => {
|
|
1200
1203
|
let s = "";
|
|
@@ -1204,13 +1207,13 @@ let sn = (t) => crypto.getRandomValues(new Uint8Array(t)), an = (t, e, n) => {
|
|
|
1204
1207
|
if (s += t[a[u] & o] || "", s.length === r) return s;
|
|
1205
1208
|
}
|
|
1206
1209
|
};
|
|
1207
|
-
},
|
|
1210
|
+
}, ln = (t, e = 21) => cn(t, e, an), dn = (t = 21) => {
|
|
1208
1211
|
let e = "", n = crypto.getRandomValues(new Uint8Array(t));
|
|
1209
1212
|
for (; t--; )
|
|
1210
|
-
e +=
|
|
1213
|
+
e += sn[n[t] & 63];
|
|
1211
1214
|
return e;
|
|
1212
1215
|
};
|
|
1213
|
-
const
|
|
1216
|
+
const un = () => ({ isGuest: !0, id: ln("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_", 20)() }), hn = (t) => {
|
|
1214
1217
|
const e = JSON.stringify(t);
|
|
1215
1218
|
let n = 0;
|
|
1216
1219
|
for (let o = 0, i = e.length; o < i; o++) {
|
|
@@ -1218,10 +1221,10 @@ const dn = () => ({ isGuest: !0, id: cn("1234567890abcdefghijklmnopqrstuvwxyzABC
|
|
|
1218
1221
|
n = (n << 5) - n + r, n |= 0;
|
|
1219
1222
|
}
|
|
1220
1223
|
return `${n}`;
|
|
1221
|
-
}, jt = (t) => t ? typeof t == "object" ? { ...t } : t : void 0,
|
|
1224
|
+
}, jt = (t) => t ? typeof t == "object" ? { ...t } : t : void 0, fn = (t, e) => (Array.isArray(t) ? t : [t]).map((n) => {
|
|
1222
1225
|
const { id: o, type: i, purpose: r, value: s, created: a, modified: u, creator: h, ...p } = n;
|
|
1223
1226
|
return {
|
|
1224
|
-
id: o || `temp-${
|
|
1227
|
+
id: o || `temp-${hn(n)}`,
|
|
1225
1228
|
annotation: e,
|
|
1226
1229
|
type: i,
|
|
1227
1230
|
purpose: r,
|
|
@@ -1231,7 +1234,7 @@ const dn = () => ({ isGuest: !0, id: cn("1234567890abcdefghijklmnopqrstuvwxyzABC
|
|
|
1231
1234
|
updated: u ? new Date(u) : void 0,
|
|
1232
1235
|
...p
|
|
1233
1236
|
};
|
|
1234
|
-
}),
|
|
1237
|
+
}), gn = (t) => t.map((e) => {
|
|
1235
1238
|
var n;
|
|
1236
1239
|
const { annotation: o, created: i, updated: r, ...s } = e, a = {
|
|
1237
1240
|
...s,
|
|
@@ -1240,11 +1243,11 @@ const dn = () => ({ isGuest: !0, id: cn("1234567890abcdefghijklmnopqrstuvwxyzABC
|
|
|
1240
1243
|
};
|
|
1241
1244
|
return (n = a.id) != null && n.startsWith("temp-") && delete a.id, a;
|
|
1242
1245
|
});
|
|
1243
|
-
|
|
1244
|
-
const
|
|
1245
|
-
parse: (n) =>
|
|
1246
|
-
serialize: (n) =>
|
|
1247
|
-
}),
|
|
1246
|
+
dn();
|
|
1247
|
+
const kn = (t, e) => ({
|
|
1248
|
+
parse: (n) => bn(n),
|
|
1249
|
+
serialize: (n) => vn(n, t, e)
|
|
1250
|
+
}), pn = (t) => t.quote !== void 0 && t.start !== void 0 && t.end !== void 0, mn = (t) => {
|
|
1248
1251
|
const {
|
|
1249
1252
|
id: e,
|
|
1250
1253
|
creator: n,
|
|
@@ -1270,7 +1273,7 @@ const Un = (t, e) => ({
|
|
|
1270
1273
|
}
|
|
1271
1274
|
return d;
|
|
1272
1275
|
}, {});
|
|
1273
|
-
if (
|
|
1276
|
+
if (pn(p))
|
|
1274
1277
|
a.selector.push({ id: u.id, ...p });
|
|
1275
1278
|
else {
|
|
1276
1279
|
const d = [
|
|
@@ -1281,14 +1284,14 @@ const Un = (t, e) => ({
|
|
|
1281
1284
|
}
|
|
1282
1285
|
}
|
|
1283
1286
|
return { parsed: a };
|
|
1284
|
-
},
|
|
1287
|
+
}, bn = (t) => {
|
|
1285
1288
|
const e = t.id || Pt(), {
|
|
1286
1289
|
creator: n,
|
|
1287
1290
|
created: o,
|
|
1288
1291
|
modified: i,
|
|
1289
1292
|
body: r,
|
|
1290
1293
|
...s
|
|
1291
|
-
} = t, a =
|
|
1294
|
+
} = t, a = fn(r, e), u = mn(t);
|
|
1292
1295
|
return "error" in u ? { error: u.error } : {
|
|
1293
1296
|
parsed: {
|
|
1294
1297
|
...s,
|
|
@@ -1297,7 +1300,7 @@ const Un = (t, e) => ({
|
|
|
1297
1300
|
target: u.parsed
|
|
1298
1301
|
}
|
|
1299
1302
|
};
|
|
1300
|
-
},
|
|
1303
|
+
}, vn = (t, e, n) => {
|
|
1301
1304
|
const { bodies: o, target: i, ...r } = t, {
|
|
1302
1305
|
selector: s,
|
|
1303
1306
|
creator: a,
|
|
@@ -1327,14 +1330,14 @@ const Un = (t, e) => ({
|
|
|
1327
1330
|
"@context": "http://www.w3.org/ns/anno.jsonld",
|
|
1328
1331
|
id: t.id,
|
|
1329
1332
|
type: "Annotation",
|
|
1330
|
-
body:
|
|
1333
|
+
body: gn(t.bodies),
|
|
1331
1334
|
creator: a,
|
|
1332
1335
|
created: u == null ? void 0 : u.toISOString(),
|
|
1333
1336
|
modified: h == null ? void 0 : h.toISOString(),
|
|
1334
1337
|
target: d
|
|
1335
1338
|
};
|
|
1336
1339
|
};
|
|
1337
|
-
function Wt(t, e, n = 0, o = t.length - 1, i =
|
|
1340
|
+
function Wt(t, e, n = 0, o = t.length - 1, i = yn) {
|
|
1338
1341
|
for (; o > n; ) {
|
|
1339
1342
|
if (o - n > 600) {
|
|
1340
1343
|
const u = o - n + 1, h = e - n + 1, p = Math.log(u), d = 0.5 * Math.exp(2 * p / 3), f = 0.5 * Math.sqrt(p * d * (u - d) / u) * (h - u / 2 < 0 ? -1 : 1), g = Math.max(n, Math.floor(e - h * d / u + f)), A = Math.min(o, Math.floor(e + (u - h) * d / u + f));
|
|
@@ -1353,10 +1356,10 @@ function q(t, e, n) {
|
|
|
1353
1356
|
const o = t[e];
|
|
1354
1357
|
t[e] = t[n], t[n] = o;
|
|
1355
1358
|
}
|
|
1356
|
-
function
|
|
1359
|
+
function yn(t, e) {
|
|
1357
1360
|
return t < e ? -1 : t > e ? 1 : 0;
|
|
1358
1361
|
}
|
|
1359
|
-
class
|
|
1362
|
+
class wn {
|
|
1360
1363
|
constructor(e = 9) {
|
|
1361
1364
|
this._maxEntries = Math.max(4, e), this._minEntries = Math.max(2, Math.ceil(this._maxEntries * 0.4)), this.clear();
|
|
1362
1365
|
}
|
|
@@ -1427,7 +1430,7 @@ class yn {
|
|
|
1427
1430
|
let a, u, h;
|
|
1428
1431
|
for (; o || r.length; ) {
|
|
1429
1432
|
if (o || (o = r.pop(), u = r[r.length - 1], a = s.pop(), h = !0), o.leaf) {
|
|
1430
|
-
const p =
|
|
1433
|
+
const p = xn(e, o.children, n);
|
|
1431
1434
|
if (p !== -1)
|
|
1432
1435
|
return o.children.splice(p, 1), r.push(o), this._condense(r), this;
|
|
1433
1436
|
}
|
|
@@ -1478,7 +1481,7 @@ class yn {
|
|
|
1478
1481
|
for (; i.push(n), !(n.leaf || i.length - 1 === o); ) {
|
|
1479
1482
|
let r = 1 / 0, s = 1 / 0, a;
|
|
1480
1483
|
for (let u = 0; u < n.children.length; u++) {
|
|
1481
|
-
const h = n.children[u], p = gt(h), d =
|
|
1484
|
+
const h = n.children[u], p = gt(h), d = Sn(e, h) - p;
|
|
1482
1485
|
d < s ? (s = d, r = p < r ? p : r, a = h) : d === s && p < r && (r = p, a = h);
|
|
1483
1486
|
}
|
|
1484
1487
|
n = a || n.children[0];
|
|
@@ -1504,14 +1507,14 @@ class yn {
|
|
|
1504
1507
|
_chooseSplitIndex(e, n, o) {
|
|
1505
1508
|
let i, r = 1 / 0, s = 1 / 0;
|
|
1506
1509
|
for (let a = n; a <= o - n; a++) {
|
|
1507
|
-
const u = G(e, 0, a, this.toBBox), h = G(e, a, o, this.toBBox), p =
|
|
1510
|
+
const u = G(e, 0, a, this.toBBox), h = G(e, a, o, this.toBBox), p = Cn(u, h), d = gt(u) + gt(h);
|
|
1508
1511
|
p < r ? (r = p, i = a, s = d < s ? d : s) : p === r && d < s && (s = d, i = a);
|
|
1509
1512
|
}
|
|
1510
1513
|
return i || o - n;
|
|
1511
1514
|
}
|
|
1512
1515
|
// sorts node children by the best axis for split
|
|
1513
1516
|
_chooseSplitAxis(e, n, o) {
|
|
1514
|
-
const i = e.leaf ? this.compareMinX :
|
|
1517
|
+
const i = e.leaf ? this.compareMinX : An, r = e.leaf ? this.compareMinY : En, s = this._allDistMargin(e, n, o, i), a = this._allDistMargin(e, n, o, r);
|
|
1515
1518
|
s < a && e.children.sort(i);
|
|
1516
1519
|
}
|
|
1517
1520
|
// total margin of all possible split distributions where each node is at least m full
|
|
@@ -1538,7 +1541,7 @@ class yn {
|
|
|
1538
1541
|
e[n].children.length === 0 ? n > 0 ? (o = e[n - 1].children, o.splice(o.indexOf(e[n]), 1)) : this.clear() : j(e[n], this.toBBox);
|
|
1539
1542
|
}
|
|
1540
1543
|
}
|
|
1541
|
-
function
|
|
1544
|
+
function xn(t, e, n) {
|
|
1542
1545
|
if (!n) return e.indexOf(t);
|
|
1543
1546
|
for (let o = 0; o < e.length; o++)
|
|
1544
1547
|
if (n(t, e[o])) return o;
|
|
@@ -1558,10 +1561,10 @@ function G(t, e, n, o, i) {
|
|
|
1558
1561
|
function K(t, e) {
|
|
1559
1562
|
return t.minX = Math.min(t.minX, e.minX), t.minY = Math.min(t.minY, e.minY), t.maxX = Math.max(t.maxX, e.maxX), t.maxY = Math.max(t.maxY, e.maxY), t;
|
|
1560
1563
|
}
|
|
1561
|
-
function
|
|
1564
|
+
function An(t, e) {
|
|
1562
1565
|
return t.minX - e.minX;
|
|
1563
1566
|
}
|
|
1564
|
-
function
|
|
1567
|
+
function En(t, e) {
|
|
1565
1568
|
return t.minY - e.minY;
|
|
1566
1569
|
}
|
|
1567
1570
|
function gt(t) {
|
|
@@ -1570,10 +1573,10 @@ function gt(t) {
|
|
|
1570
1573
|
function nt(t) {
|
|
1571
1574
|
return t.maxX - t.minX + (t.maxY - t.minY);
|
|
1572
1575
|
}
|
|
1573
|
-
function
|
|
1576
|
+
function Sn(t, e) {
|
|
1574
1577
|
return (Math.max(e.maxX, t.maxX) - Math.min(e.minX, t.minX)) * (Math.max(e.maxY, t.maxY) - Math.min(e.minY, t.minY));
|
|
1575
1578
|
}
|
|
1576
|
-
function
|
|
1579
|
+
function Cn(t, e) {
|
|
1577
1580
|
const n = Math.max(t.minX, e.minX), o = Math.max(t.minY, e.minY), i = Math.min(t.maxX, e.maxX), r = Math.min(t.maxY, e.maxY);
|
|
1578
1581
|
return Math.max(0, i - n) * Math.max(0, r - o);
|
|
1579
1582
|
}
|
|
@@ -1602,22 +1605,22 @@ function kt(t, e, n, o, i) {
|
|
|
1602
1605
|
Wt(t, s, e, n, i), r.push(e, s, s, n);
|
|
1603
1606
|
}
|
|
1604
1607
|
}
|
|
1605
|
-
const
|
|
1606
|
-
const n = new
|
|
1608
|
+
const Ln = (t, e) => {
|
|
1609
|
+
const n = new wn(), o = /* @__PURE__ */ new Map(), i = (l, c) => {
|
|
1607
1610
|
const b = l.selector.flatMap((L) => {
|
|
1608
1611
|
const E = H([L]) ? L.range : Yt(L, e).range;
|
|
1609
1612
|
return Array.from(E.getClientRects());
|
|
1610
|
-
}),
|
|
1611
|
-
return
|
|
1612
|
-
const { x: E, y:
|
|
1613
|
+
}), C = de(b).map(({ left: L, top: E, right: R, bottom: T }) => new DOMRect(L - c.left, E - c.top, R - L, T - E));
|
|
1614
|
+
return C.map((L) => {
|
|
1615
|
+
const { x: E, y: R, width: T, height: O } = L;
|
|
1613
1616
|
return {
|
|
1614
1617
|
minX: E,
|
|
1615
|
-
minY:
|
|
1618
|
+
minY: R,
|
|
1616
1619
|
maxX: E + T,
|
|
1617
|
-
maxY:
|
|
1620
|
+
maxY: R + O,
|
|
1618
1621
|
annotation: {
|
|
1619
1622
|
id: l.annotation,
|
|
1620
|
-
rects:
|
|
1623
|
+
rects: C
|
|
1621
1624
|
}
|
|
1622
1625
|
};
|
|
1623
1626
|
});
|
|
@@ -1633,28 +1636,28 @@ const Cn = (t, e) => {
|
|
|
1633
1636
|
u(l), a(l);
|
|
1634
1637
|
}, p = (l, c = !0) => {
|
|
1635
1638
|
c && s();
|
|
1636
|
-
const b = e.getBoundingClientRect(),
|
|
1637
|
-
|
|
1638
|
-
const L =
|
|
1639
|
+
const b = e.getBoundingClientRect(), C = l.map((E) => ({ target: E, rects: i(E, b) }));
|
|
1640
|
+
C.forEach(({ target: E, rects: R }) => o.set(E.annotation, R));
|
|
1641
|
+
const L = C.flatMap(({ rects: E }) => E);
|
|
1639
1642
|
n.load(L);
|
|
1640
1643
|
}, d = (l, c, b = !1) => {
|
|
1641
|
-
const
|
|
1644
|
+
const C = n.search({
|
|
1642
1645
|
minX: l,
|
|
1643
1646
|
minY: c,
|
|
1644
1647
|
maxX: l,
|
|
1645
1648
|
maxY: c
|
|
1646
|
-
}), L = (E) => E.annotation.rects.reduce((
|
|
1647
|
-
return
|
|
1649
|
+
}), L = (E) => E.annotation.rects.reduce((R, T) => R + T.width * T.height, 0);
|
|
1650
|
+
return C.length > 0 ? (C.sort((E, R) => L(E) - L(R)), b ? C.map((E) => E.annotation.id) : [C[0].annotation.id]) : [];
|
|
1648
1651
|
}, f = (l) => {
|
|
1649
1652
|
const c = g(l);
|
|
1650
1653
|
if (c.length === 0)
|
|
1651
1654
|
return;
|
|
1652
|
-
let b = c[0].left,
|
|
1653
|
-
for (let
|
|
1654
|
-
const T = c[
|
|
1655
|
-
b = Math.min(b, T.left),
|
|
1655
|
+
let b = c[0].left, C = c[0].top, L = c[0].right, E = c[0].bottom;
|
|
1656
|
+
for (let R = 1; R < c.length; R++) {
|
|
1657
|
+
const T = c[R];
|
|
1658
|
+
b = Math.min(b, T.left), C = Math.min(C, T.top), L = Math.max(L, T.right), E = Math.max(E, T.bottom);
|
|
1656
1659
|
}
|
|
1657
|
-
return new DOMRect(b,
|
|
1660
|
+
return new DOMRect(b, C, L - b, E - C);
|
|
1658
1661
|
}, g = (l) => {
|
|
1659
1662
|
const c = o.get(l);
|
|
1660
1663
|
return c ? c[0].annotation.rects : [];
|
|
@@ -1665,12 +1668,12 @@ const Cn = (t, e) => {
|
|
|
1665
1668
|
getAt: d,
|
|
1666
1669
|
getAnnotationBounds: f,
|
|
1667
1670
|
getAnnotationRects: g,
|
|
1668
|
-
getIntersecting: (l, c, b,
|
|
1669
|
-
const L = n.search({ minX: l, minY: c, maxX: b, maxY:
|
|
1670
|
-
return Array.from(E).map((
|
|
1671
|
-
annotation: t.getAnnotation(
|
|
1672
|
-
rects: g(
|
|
1673
|
-
})).filter((
|
|
1671
|
+
getIntersecting: (l, c, b, C) => {
|
|
1672
|
+
const L = n.search({ minX: l, minY: c, maxX: b, maxY: C }), E = new Set(L.map((R) => R.annotation.id));
|
|
1673
|
+
return Array.from(E).map((R) => ({
|
|
1674
|
+
annotation: t.getAnnotation(R),
|
|
1675
|
+
rects: g(R)
|
|
1676
|
+
})).filter((R) => !!R.annotation);
|
|
1674
1677
|
},
|
|
1675
1678
|
insert: a,
|
|
1676
1679
|
recalculate: () => p(t.all().map((l) => l.target), !0),
|
|
@@ -1679,14 +1682,14 @@ const Cn = (t, e) => {
|
|
|
1679
1682
|
size: () => n.all().length,
|
|
1680
1683
|
update: h
|
|
1681
1684
|
};
|
|
1682
|
-
},
|
|
1683
|
-
const n =
|
|
1685
|
+
}, Rn = (t, e) => {
|
|
1686
|
+
const n = Qe(), o = Ln(n, t), i = Ye(n);
|
|
1684
1687
|
i.setUserSelectAction(e);
|
|
1685
|
-
const r =
|
|
1688
|
+
const r = _e(n), s = en(), a = (y, m = N.LOCAL) => {
|
|
1686
1689
|
const l = st(y, t), c = H(l.target.selector);
|
|
1687
1690
|
return c && n.addAnnotation(l, m), c;
|
|
1688
1691
|
}, u = (y, m = !0, l = N.LOCAL) => {
|
|
1689
|
-
const c = y.map((
|
|
1692
|
+
const c = y.map((C) => st(C, t)), b = c.filter((C) => !H(C.target.selector));
|
|
1690
1693
|
return b.length > 0 ? (console.warn("Could not revive all targets for these annotations:", b), n.bulkAddAnnotation(c, m, l), b) : (n.bulkAddAnnotation(c, m, l), []);
|
|
1691
1694
|
}, h = (y, m = N.LOCAL) => {
|
|
1692
1695
|
const l = y.map((b) => st(b, t)), c = l.filter((b) => !H(b.target.selector));
|
|
@@ -1700,14 +1703,14 @@ const Cn = (t, e) => {
|
|
|
1700
1703
|
const l = y.map((c) => rt(c, t));
|
|
1701
1704
|
n.bulkUpdateTargets(l, m);
|
|
1702
1705
|
}, f = (y, m, l) => {
|
|
1703
|
-
const c = o.getAt(y, m, !!l).map((
|
|
1706
|
+
const c = o.getAt(y, m, !!l).map((C) => n.getAnnotation(C)), b = l ? c.filter(l) : c;
|
|
1704
1707
|
return b.length > 0 ? b[0] : void 0;
|
|
1705
1708
|
}, g = (y, m, l, c = 5) => {
|
|
1706
1709
|
const b = o.getAnnotationRects(y);
|
|
1707
1710
|
if (b.length !== 0) {
|
|
1708
1711
|
if (m && l) {
|
|
1709
|
-
const
|
|
1710
|
-
if (
|
|
1712
|
+
const C = b.find(({ top: L, right: E, bottom: R, left: T }) => m >= T - c && m <= E + c && l >= L - c && l <= R + c);
|
|
1713
|
+
if (C) return C;
|
|
1711
1714
|
}
|
|
1712
1715
|
return o.getAnnotationBounds(y);
|
|
1713
1716
|
}
|
|
@@ -1757,8 +1760,8 @@ const Cn = (t, e) => {
|
|
|
1757
1760
|
if (A) {
|
|
1758
1761
|
const { height: y } = d.rects[0], m = d.rects[0].x + f.left, l = d.rects[0].y + f.top;
|
|
1759
1762
|
i.fillStyle = A.appearance.color, i.fillRect(m - 2, l - 2.5, 2, y + 5);
|
|
1760
|
-
const c = i.measureText(A.appearance.label), b = c.width + 6,
|
|
1761
|
-
return i.fillRect(m - 2, l - 2.5 -
|
|
1763
|
+
const c = i.measureText(A.appearance.label), b = c.width + 6, C = c.actualBoundingBoxAscent + c.actualBoundingBoxDescent + 8, L = c.fontBoundingBoxAscent ? 8 : 6.5;
|
|
1764
|
+
return i.fillRect(m - 2, l - 2.5 - C, b, C), i.fillStyle = "#fff", i.fillText(A.appearance.label, m + 1, l - L), {
|
|
1762
1765
|
fill: A.appearance.color,
|
|
1763
1766
|
fillOpacity: g ? 0.45 : 0.18
|
|
1764
1767
|
};
|
|
@@ -1775,7 +1778,7 @@ const Cn = (t, e) => {
|
|
|
1775
1778
|
return document.scrollingElement;
|
|
1776
1779
|
const { overflowY: e } = window.getComputedStyle(t);
|
|
1777
1780
|
return e !== "visible" && e !== "hidden" && t.scrollHeight > t.clientHeight ? t : qt(t.parentElement);
|
|
1778
|
-
},
|
|
1781
|
+
}, Nn = (t, e) => (n) => {
|
|
1779
1782
|
const o = typeof n == "string" ? n : n.id, i = (s) => {
|
|
1780
1783
|
const a = r.getBoundingClientRect(), u = r.clientHeight, h = r.clientWidth, p = s.selector[0].range.getBoundingClientRect(), { width: d, height: f } = e.getAnnotationBounds(o), g = p.top - a.top, A = p.left - a.left, y = r.parentElement ? r.scrollTop : 0, m = r.parentElement ? r.scrollLeft : 0, l = g + y - (u - f) / 2, c = A + m - (h - d) / 2;
|
|
1781
1784
|
r.scroll({ top: l, left: c, behavior: "smooth" });
|
|
@@ -1791,20 +1794,20 @@ const Cn = (t, e) => {
|
|
|
1791
1794
|
}
|
|
1792
1795
|
}
|
|
1793
1796
|
return !1;
|
|
1794
|
-
},
|
|
1797
|
+
}, Mn = (t, e) => ({
|
|
1795
1798
|
...t,
|
|
1796
1799
|
annotatingEnabled: t.annotatingEnabled ?? e.annotatingEnabled,
|
|
1797
1800
|
user: t.user || e.user
|
|
1798
|
-
}),
|
|
1801
|
+
}), On = (t, e, n, o) => {
|
|
1799
1802
|
let i;
|
|
1800
1803
|
const r = (c) => i = c;
|
|
1801
1804
|
let s;
|
|
1802
1805
|
const a = (c) => s = c, { store: u, selection: h } = e;
|
|
1803
1806
|
let p, d = !1, f;
|
|
1804
1807
|
const g = (c) => {
|
|
1805
|
-
var
|
|
1808
|
+
var C;
|
|
1806
1809
|
if (!d) return;
|
|
1807
|
-
!((
|
|
1810
|
+
!((C = c.target.parentElement) != null && C.closest(X)) ? p = {
|
|
1808
1811
|
annotation: Pt(),
|
|
1809
1812
|
selector: [],
|
|
1810
1813
|
creator: i,
|
|
@@ -1813,22 +1816,22 @@ const Cn = (t, e) => {
|
|
|
1813
1816
|
};
|
|
1814
1817
|
n && t.addEventListener("selectstart", g);
|
|
1815
1818
|
const A = vt((c) => {
|
|
1816
|
-
var
|
|
1819
|
+
var v, x;
|
|
1817
1820
|
const b = document.getSelection();
|
|
1818
|
-
if (!!((
|
|
1821
|
+
if (!!((x = (v = b.anchorNode) == null ? void 0 : v.parentElement) != null && x.closest(X))) {
|
|
1819
1822
|
p = void 0;
|
|
1820
1823
|
return;
|
|
1821
1824
|
}
|
|
1822
1825
|
if (c.timeStamp - ((f == null ? void 0 : f.timeStamp) || c.timeStamp) < 1e3 && !p && g(f), b.isCollapsed || !d || !p) return;
|
|
1823
|
-
const
|
|
1824
|
-
if (ae(
|
|
1825
|
-
const
|
|
1826
|
-
(
|
|
1827
|
-
var
|
|
1828
|
-
return
|
|
1826
|
+
const E = b.getRangeAt(0), R = he(E, t);
|
|
1827
|
+
if (ae(R)) return;
|
|
1828
|
+
const T = ee(R.cloneRange());
|
|
1829
|
+
(T.length !== p.selector.length || T.some((w, S) => {
|
|
1830
|
+
var M;
|
|
1831
|
+
return w.toString() !== ((M = p.selector[S]) == null ? void 0 : M.quote);
|
|
1829
1832
|
})) && (p = {
|
|
1830
1833
|
...p,
|
|
1831
|
-
selector:
|
|
1834
|
+
selector: T.map((w) => ue(w, t, o)),
|
|
1832
1835
|
updated: /* @__PURE__ */ new Date()
|
|
1833
1836
|
}, u.getAnnotation(p.annotation) ? u.updateTarget(p, N.LOCAL) : (h.clear(), u.addAnnotation({
|
|
1834
1837
|
id: p.annotation,
|
|
@@ -1838,44 +1841,44 @@ const Cn = (t, e) => {
|
|
|
1838
1841
|
});
|
|
1839
1842
|
n && document.addEventListener("selectionchange", A);
|
|
1840
1843
|
const y = (c) => {
|
|
1841
|
-
const { target: b, timeStamp:
|
|
1842
|
-
f = { ...c, target: b, timeStamp:
|
|
1844
|
+
const { target: b, timeStamp: C, offsetX: L, offsetY: E, type: R } = c;
|
|
1845
|
+
f = { ...c, target: b, timeStamp: C, offsetX: L, offsetY: E, type: R }, d = c.button === 0;
|
|
1843
1846
|
};
|
|
1844
|
-
|
|
1847
|
+
document.addEventListener("pointerdown", y);
|
|
1845
1848
|
const m = (c) => {
|
|
1846
1849
|
var E;
|
|
1847
1850
|
if (!!((E = c.target.parentElement) != null && E.closest(X)) || !d)
|
|
1848
1851
|
return;
|
|
1849
|
-
const
|
|
1850
|
-
const { x:
|
|
1852
|
+
const C = () => {
|
|
1853
|
+
const { x: R, y: T } = t.getBoundingClientRect(), O = c.target instanceof Node && t.contains(c.target) && u.getAt(c.clientX - R, c.clientY - T, s);
|
|
1851
1854
|
if (O) {
|
|
1852
1855
|
const { selected: v } = h;
|
|
1853
1856
|
(v.length !== 1 || v[0].id !== O.id) && h.userSelect(O.id, c);
|
|
1854
1857
|
} else h.isEmpty() || h.clear();
|
|
1855
1858
|
}, L = c.timeStamp - f.timeStamp;
|
|
1856
|
-
document.getSelection().isCollapsed && L < 300 ? (p = void 0,
|
|
1859
|
+
document.getSelection().isCollapsed && L < 300 ? (p = void 0, C()) : p && h.userSelect(p.annotation, c);
|
|
1857
1860
|
};
|
|
1858
1861
|
return document.addEventListener("pointerup", m), {
|
|
1859
1862
|
destroy: () => {
|
|
1860
|
-
t.removeEventListener("selectstart", g), document.removeEventListener("selectionchange", A),
|
|
1863
|
+
t.removeEventListener("selectstart", g), document.removeEventListener("selectionchange", A), document.removeEventListener("pointerdown", y), document.removeEventListener("pointerup", m);
|
|
1861
1864
|
},
|
|
1862
1865
|
setFilter: a,
|
|
1863
1866
|
setUser: r
|
|
1864
1867
|
};
|
|
1865
|
-
}, _t = "SPANS",
|
|
1868
|
+
}, _t = "SPANS", _n = (t, e = {}) => {
|
|
1866
1869
|
ne(t);
|
|
1867
|
-
const n =
|
|
1870
|
+
const n = Mn(e, {
|
|
1868
1871
|
annotatingEnabled: !0,
|
|
1869
|
-
user:
|
|
1870
|
-
}), o =
|
|
1872
|
+
user: un()
|
|
1873
|
+
}), o = Rn(t, n.userSelectAction), { selection: i, viewport: r } = o, s = o.store, a = tn(s), u = nn(o, a, n.adapter);
|
|
1871
1874
|
let h = n.user;
|
|
1872
|
-
const p = n.renderer === "CSS_HIGHLIGHTS" ? CSS.highlights ? "CSS_HIGHLIGHTS" : _t : n.renderer || _t, d = p === "SPANS" ?
|
|
1875
|
+
const p = n.renderer === "CSS_HIGHLIGHTS" ? CSS.highlights ? "CSS_HIGHLIGHTS" : _t : n.renderer || _t, d = p === "SPANS" ? Me(t, o, r) : p === "CSS_HIGHLIGHTS" ? Te(t, o, r) : p === "CANVAS" ? ve(t, o, r) : void 0;
|
|
1873
1876
|
if (!d)
|
|
1874
1877
|
throw `Unknown renderer implementation: ${p}`;
|
|
1875
1878
|
console.debug(`Using ${p} renderer`), n.style && d.setStyle(n.style);
|
|
1876
|
-
const f =
|
|
1879
|
+
const f = On(t, o, n.annotatingEnabled, n.offsetReferenceSelector);
|
|
1877
1880
|
return f.setUser(h), {
|
|
1878
|
-
...
|
|
1881
|
+
...rn(o, a, n.adapter),
|
|
1879
1882
|
destroy: () => {
|
|
1880
1883
|
d.destroy(), f.destroy(), a.destroy();
|
|
1881
1884
|
},
|
|
@@ -1897,7 +1900,7 @@ const Cn = (t, e) => {
|
|
|
1897
1900
|
setVisible: (E) => d.setVisible(E),
|
|
1898
1901
|
on: u.on,
|
|
1899
1902
|
off: u.off,
|
|
1900
|
-
scrollIntoView:
|
|
1903
|
+
scrollIntoView: Nn(t, s),
|
|
1901
1904
|
state: o
|
|
1902
1905
|
};
|
|
1903
1906
|
};
|
|
@@ -1907,33 +1910,34 @@ export {
|
|
|
1907
1910
|
Dt as NOT_ANNOTATABLE_CLASS,
|
|
1908
1911
|
X as NOT_ANNOTATABLE_SELECTOR,
|
|
1909
1912
|
N as Origin,
|
|
1910
|
-
|
|
1911
|
-
|
|
1913
|
+
De as UserSelectAction,
|
|
1914
|
+
kn as W3CTextFormat,
|
|
1912
1915
|
ne as cancelSingleClickEvents,
|
|
1913
|
-
|
|
1914
|
-
|
|
1916
|
+
Un as createBody,
|
|
1917
|
+
ve as createCanvasRenderer,
|
|
1915
1918
|
Te as createHighlightsRenderer,
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1919
|
+
Re as createRenderer,
|
|
1920
|
+
Me as createSpansRenderer,
|
|
1921
|
+
_n as createTextAnnotator,
|
|
1922
|
+
Rn as createTextAnnotatorState,
|
|
1920
1923
|
vt as debounce,
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
+
Mn as fillDefaults,
|
|
1925
|
+
In as getAnnotatableFragment,
|
|
1926
|
+
Vn as getClientRectsPonyfill,
|
|
1924
1927
|
re as getQuoteContext,
|
|
1925
1928
|
mt as getRangeAnnotatableContents,
|
|
1926
1929
|
H as isRevived,
|
|
1927
1930
|
ae as isWhitespaceOrEmpty,
|
|
1928
1931
|
de as mergeClientRects,
|
|
1929
1932
|
Jt as paint,
|
|
1930
|
-
|
|
1933
|
+
bn as parseW3CTextAnnotation,
|
|
1931
1934
|
ue as rangeToSelector,
|
|
1932
1935
|
st as reviveAnnotation,
|
|
1933
1936
|
Yt as reviveSelector,
|
|
1934
1937
|
rt as reviveTarget,
|
|
1935
|
-
|
|
1938
|
+
vn as serializeW3CTextAnnotation,
|
|
1936
1939
|
ee as splitAnnotatableRanges,
|
|
1940
|
+
he as trimRangeToContainer,
|
|
1937
1941
|
se as whitespaceOrEmptyRegex
|
|
1938
1942
|
};
|
|
1939
1943
|
//# sourceMappingURL=text-annotator.es.js.map
|