@recogito/text-annotator 3.0.0-rc.12 → 3.0.0-rc.14
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,6 +1,6 @@
|
|
|
1
1
|
const Ot = (t) => {
|
|
2
|
-
const { top: e, left: n } = t.getBoundingClientRect(), { innerWidth: o, innerHeight: i } = window, s = -n, r = -e, a = o - n,
|
|
3
|
-
return { top: e, left: n, minX: s, minY: r, maxX: a, maxY:
|
|
2
|
+
const { top: e, left: n } = t.getBoundingClientRect(), { innerWidth: o, innerHeight: i } = window, s = -n, r = -e, a = o - n, d = i - e;
|
|
3
|
+
return { top: e, left: n, minX: s, minY: r, maxX: a, maxY: d };
|
|
4
4
|
}, It = (t) => {
|
|
5
5
|
let e = /* @__PURE__ */ new Set();
|
|
6
6
|
return (o) => {
|
|
@@ -42,7 +42,7 @@ const Ot = (t) => {
|
|
|
42
42
|
}, ht = (t) => {
|
|
43
43
|
const e = t.cloneContents();
|
|
44
44
|
return e.querySelectorAll(q).forEach((n) => n.remove()), e;
|
|
45
|
-
},
|
|
45
|
+
}, mn = (t) => {
|
|
46
46
|
const e = t.cloneContents();
|
|
47
47
|
return e.querySelectorAll(q).forEach((n) => n.remove()), e;
|
|
48
48
|
}, vt = (t, e) => {
|
|
@@ -67,30 +67,30 @@ const Ot = (t) => {
|
|
|
67
67
|
endContainer: i,
|
|
68
68
|
endOffset: s
|
|
69
69
|
} = t, r = Array.from(e.childNodes).map((c) => {
|
|
70
|
-
const
|
|
71
|
-
return c.nodeName === "CANVAS" ? c :
|
|
72
|
-
}), a = vt(n, e),
|
|
70
|
+
const b = c.cloneNode(!0);
|
|
71
|
+
return c.nodeName === "CANVAS" ? c : b;
|
|
72
|
+
}), a = vt(n, e), d = vt(i, e), u = () => {
|
|
73
73
|
const c = e;
|
|
74
74
|
c.replaceChildren(...r);
|
|
75
|
-
const
|
|
76
|
-
return t.setStart(
|
|
77
|
-
},
|
|
78
|
-
const
|
|
79
|
-
return c.surroundContents(
|
|
75
|
+
const b = yt(a, c), g = yt(d, c);
|
|
76
|
+
return t.setStart(b, o), t.setEnd(g, s), t;
|
|
77
|
+
}, y = (c) => {
|
|
78
|
+
const b = document.createElement("SPAN");
|
|
79
|
+
return c.surroundContents(b), b;
|
|
80
80
|
};
|
|
81
81
|
if (n === i)
|
|
82
82
|
throw "Not implemented";
|
|
83
83
|
{
|
|
84
84
|
const c = document.createRange();
|
|
85
85
|
c.selectNodeContents(n), c.setStart(n, o);
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
const
|
|
86
|
+
const b = y(c), g = document.createRange();
|
|
87
|
+
g.selectNode(i), g.setEnd(i, s);
|
|
88
|
+
const v = y(g), w = Zt(t).reverse().map((l) => {
|
|
89
89
|
var m;
|
|
90
|
-
const
|
|
91
|
-
return (m = l.parentNode) == null || m.insertBefore(
|
|
90
|
+
const h = document.createElement("SPAN");
|
|
91
|
+
return (m = l.parentNode) == null || m.insertBefore(h, l), h.appendChild(l), h;
|
|
92
92
|
});
|
|
93
|
-
return { unwrap:
|
|
93
|
+
return { unwrap: u, nodes: [b, ...w, v] };
|
|
94
94
|
}
|
|
95
95
|
}, Zt = (t) => {
|
|
96
96
|
const {
|
|
@@ -103,7 +103,7 @@ const Ot = (t) => {
|
|
|
103
103
|
for (; s != null; )
|
|
104
104
|
s === o && (r = !1), r && a.push(s), s === n && (r = !0), s = i.nextNode();
|
|
105
105
|
return a;
|
|
106
|
-
},
|
|
106
|
+
}, bn = (t) => {
|
|
107
107
|
const { startContainer: e, endContainer: n } = t;
|
|
108
108
|
if (e === n)
|
|
109
109
|
return Array.from(t.getClientRects());
|
|
@@ -116,10 +116,10 @@ const Ot = (t) => {
|
|
|
116
116
|
s.setStart(i, 0), s.setEnd(t.startContainer, t.startOffset);
|
|
117
117
|
const r = ht(s).textContent, a = document.createRange();
|
|
118
118
|
a.setStart(t.endContainer, t.endOffset), i === document.body ? a.setEnd(i, i.childNodes.length) : a.setEndAfter(i);
|
|
119
|
-
const
|
|
119
|
+
const d = ht(a).textContent;
|
|
120
120
|
return {
|
|
121
121
|
prefix: r.substring(r.length - n),
|
|
122
|
-
suffix:
|
|
122
|
+
suffix: d.substring(0, n)
|
|
123
123
|
};
|
|
124
124
|
}, U = (t) => t.every((e) => e.range instanceof Range && !e.range.collapsed), ee = (t, e) => {
|
|
125
125
|
const n = (s) => Math.round(s * 10) / 10, o = {
|
|
@@ -172,53 +172,50 @@ const Ot = (t) => {
|
|
|
172
172
|
}, []), ie = (t, e, n) => {
|
|
173
173
|
const o = document.createRange(), i = n ? t.startContainer.parentElement.closest(n) : e;
|
|
174
174
|
o.setStart(i, 0), o.setEnd(t.startContainer, t.startOffset);
|
|
175
|
-
const s = ht(o).textContent, r = t.toString(), a = s.length || 0,
|
|
176
|
-
return n ? { quote: r, start: a, end:
|
|
177
|
-
},
|
|
178
|
-
var
|
|
179
|
-
const o = document.createNodeIterator(
|
|
180
|
-
|
|
175
|
+
const s = ht(o).textContent, r = t.toString(), a = s.length || 0, d = a + r.length;
|
|
176
|
+
return n ? { quote: r, start: a, end: d, range: t, offsetReference: i } : { quote: r, start: a, end: d, range: t };
|
|
177
|
+
}, _t = (t, e) => {
|
|
178
|
+
var y, c;
|
|
179
|
+
const { start: n, end: o } = t, i = t.offsetReference || e, s = document.createNodeIterator(
|
|
180
|
+
e,
|
|
181
181
|
NodeFilter.SHOW_TEXT,
|
|
182
|
-
(
|
|
183
|
-
var
|
|
184
|
-
return (
|
|
182
|
+
(b) => {
|
|
183
|
+
var g;
|
|
184
|
+
return (g = b.parentElement) != null && g.closest(q) ? NodeFilter.FILTER_SKIP : NodeFilter.FILTER_ACCEPT;
|
|
185
185
|
}
|
|
186
186
|
);
|
|
187
|
-
let
|
|
188
|
-
const
|
|
189
|
-
let
|
|
190
|
-
|
|
191
|
-
let
|
|
192
|
-
for (;
|
|
193
|
-
if (
|
|
194
|
-
const
|
|
195
|
-
if (
|
|
196
|
-
|
|
187
|
+
let r = 0;
|
|
188
|
+
const a = document.createRange();
|
|
189
|
+
let d = s.nextNode();
|
|
190
|
+
d === null && console.error("Could not revive annotation target. Content missing.");
|
|
191
|
+
let u = !i;
|
|
192
|
+
for (; d !== null; ) {
|
|
193
|
+
if (u || (u = i == null ? void 0 : i.contains(d)), u) {
|
|
194
|
+
const b = ((y = d.textContent) == null ? void 0 : y.length) || 0;
|
|
195
|
+
if (r + b > n) {
|
|
196
|
+
a.setStart(d, n - r);
|
|
197
197
|
break;
|
|
198
198
|
}
|
|
199
|
-
|
|
199
|
+
r += b;
|
|
200
200
|
}
|
|
201
|
-
|
|
201
|
+
d = s.nextNode();
|
|
202
202
|
}
|
|
203
|
-
for (;
|
|
204
|
-
const
|
|
205
|
-
if (
|
|
206
|
-
|
|
203
|
+
for (; d !== null; ) {
|
|
204
|
+
const b = ((c = d.textContent) == null ? void 0 : c.length) || 0;
|
|
205
|
+
if (r + b >= o) {
|
|
206
|
+
a.setEnd(d, o - r);
|
|
207
207
|
break;
|
|
208
208
|
}
|
|
209
|
-
|
|
209
|
+
r += b, d = s.nextNode();
|
|
210
210
|
}
|
|
211
|
-
return
|
|
212
|
-
}, _t = (t, e) => {
|
|
213
|
-
const { start: n, end: o, offsetReference: i } = t, s = i || e;
|
|
214
|
-
return s ? {
|
|
211
|
+
return {
|
|
215
212
|
...t,
|
|
216
|
-
range:
|
|
217
|
-
}
|
|
213
|
+
range: a
|
|
214
|
+
};
|
|
218
215
|
}, J = (t, e) => U(t.selector) ? t : {
|
|
219
216
|
...t,
|
|
220
|
-
selector: t.selector.map((n) => n.range instanceof Range ? n : _t(n, e))
|
|
221
|
-
}, wt = (t, e) => U(t.target.selector) ? t : { ...t, target: J(t.target, e) },
|
|
217
|
+
selector: t.selector.map((n) => n.range instanceof Range && !n.range.collapsed ? n : _t(n, e))
|
|
218
|
+
}, wt = (t, e) => U(t.target.selector) ? t : { ...t, target: J(t.target, e) }, se = (t) => {
|
|
222
219
|
var i;
|
|
223
220
|
const { startContainer: e, endContainer: n } = t;
|
|
224
221
|
if (e.nodeType === Node.TEXT_NODE && n.nodeType === Node.TEXT_NODE)
|
|
@@ -238,63 +235,63 @@ const Ot = (t) => {
|
|
|
238
235
|
}, Dt = {
|
|
239
236
|
fill: "rgb(0, 128, 255)",
|
|
240
237
|
fillOpacity: 0.45
|
|
241
|
-
},
|
|
238
|
+
}, re = () => {
|
|
242
239
|
const t = document.createElement("canvas");
|
|
243
240
|
return t.width = window.innerWidth, t.height = window.innerHeight, t.className = "r6o-highlight-layer bg", t;
|
|
244
|
-
},
|
|
241
|
+
}, ae = (t, e) => {
|
|
245
242
|
if (t.width = e ? 2 * window.innerWidth : window.innerWidth, t.height = e ? 2 * window.innerHeight : window.innerHeight, e) {
|
|
246
243
|
const n = t.getContext("2d");
|
|
247
244
|
n.scale(2, 2), n.translate(0.5, 0.5);
|
|
248
245
|
}
|
|
249
|
-
},
|
|
246
|
+
}, ce = (t, e, n) => {
|
|
250
247
|
const { store: o, selection: i, hover: s } = e;
|
|
251
|
-
let r, a,
|
|
252
|
-
const
|
|
248
|
+
let r, a, d;
|
|
249
|
+
const u = It(n);
|
|
253
250
|
t.classList.add("r6o-annotatable");
|
|
254
|
-
const
|
|
255
|
-
t.insertBefore(
|
|
256
|
-
const
|
|
257
|
-
const { x: A, y: x } = t.getBoundingClientRect(), S = o.getAt(
|
|
251
|
+
const y = re(), c = y.getContext("2d");
|
|
252
|
+
t.insertBefore(y, t.firstChild);
|
|
253
|
+
const b = (p) => {
|
|
254
|
+
const { x: A, y: x } = t.getBoundingClientRect(), S = o.getAt(p.clientX - A, p.clientY - x);
|
|
258
255
|
S && (!a || a(S)) ? s.current !== S.id && (t.classList.add("hovered"), s.set(S.id)) : s.current && (t.classList.remove("hovered"), s.set(null));
|
|
259
256
|
};
|
|
260
|
-
t.addEventListener("pointermove",
|
|
261
|
-
const
|
|
262
|
-
const
|
|
263
|
-
c.clearRect(-0.5, -0.5, zt + 1, Wt + 1),
|
|
264
|
-
const tt = qt.has(_.annotation.id), mt = r ? typeof r == "function" ? r(_.annotation, tt) : r : tt ? Dt : Z, bt =
|
|
257
|
+
t.addEventListener("pointermove", b);
|
|
258
|
+
const g = () => requestAnimationFrame(() => {
|
|
259
|
+
const p = Ot(t), { top: A, left: x, minX: S, minY: B, maxX: L, maxY: I } = p, pt = a ? o.getIntersectingRects(S, B, L, I).filter(({ annotation: _ }) => a(_)) : o.getIntersectingRects(S, B, L, I), { width: zt, height: Wt } = y, qt = new Set(i.selected.map(({ id: _ }) => _));
|
|
260
|
+
c.clearRect(-0.5, -0.5, zt + 1, Wt + 1), d && d.clear(), pt.forEach((_) => {
|
|
261
|
+
const tt = qt.has(_.annotation.id), mt = r ? typeof r == "function" ? r(_.annotation, tt) : r : tt ? Dt : Z, bt = d && d.paint(_, p, tt) || mt, jt = _.rects.map(({ x: et, y: nt, width: ot, height: it }) => ({
|
|
265
262
|
x: et + x,
|
|
266
263
|
y: nt + A,
|
|
267
264
|
width: ot,
|
|
268
265
|
height: it
|
|
269
266
|
}));
|
|
270
267
|
c.fillStyle = bt.fill, c.globalAlpha = bt.fillOpacity || 1, jt.forEach(({ x: et, y: nt, width: ot, height: it }) => c.fillRect(et, nt - 2.5, ot, it + 5));
|
|
271
|
-
}), setTimeout(() =>
|
|
272
|
-
}),
|
|
273
|
-
r =
|
|
274
|
-
}, C = (
|
|
275
|
-
a =
|
|
276
|
-
}, w = () =>
|
|
268
|
+
}), setTimeout(() => u(pt.map(({ annotation: _ }) => _)), 1);
|
|
269
|
+
}), v = (p) => {
|
|
270
|
+
r = p, g();
|
|
271
|
+
}, C = (p) => {
|
|
272
|
+
a = p, g();
|
|
273
|
+
}, w = () => g();
|
|
277
274
|
o.observe(w);
|
|
278
|
-
const l = i.subscribe(() =>
|
|
279
|
-
document.addEventListener("scroll",
|
|
275
|
+
const l = i.subscribe(() => g()), h = () => g();
|
|
276
|
+
document.addEventListener("scroll", h, { capture: !0, passive: !0 });
|
|
280
277
|
const m = ft(() => {
|
|
281
|
-
|
|
278
|
+
ae(y), o.recalculatePositions(), d && d.reset(), g();
|
|
282
279
|
});
|
|
283
280
|
window.addEventListener("resize", m);
|
|
284
281
|
const f = new ResizeObserver(m);
|
|
285
282
|
f.observe(t);
|
|
286
|
-
const E = { attributes: !0, childList: !0, subtree: !0 }, T = new MutationObserver(
|
|
283
|
+
const E = { attributes: !0, childList: !0, subtree: !0 }, T = new MutationObserver(g);
|
|
287
284
|
return T.observe(document.body, E), {
|
|
288
285
|
destroy: () => {
|
|
289
|
-
t.removeEventListener("pointermove",
|
|
286
|
+
t.removeEventListener("pointermove", b), t.removeChild(y), o.unobserve(w), l(), document.removeEventListener("scroll", h), window.removeEventListener("resize", m), f.disconnect(), T.disconnect();
|
|
290
287
|
},
|
|
291
|
-
refresh:
|
|
292
|
-
setDrawingStyle:
|
|
288
|
+
refresh: g,
|
|
289
|
+
setDrawingStyle: v,
|
|
293
290
|
setFilter: C,
|
|
294
|
-
setPainter: (
|
|
291
|
+
setPainter: (p) => d = p
|
|
295
292
|
};
|
|
296
293
|
};
|
|
297
|
-
var
|
|
294
|
+
var le = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, Y = function(t) {
|
|
298
295
|
return typeof t == "string" ? t.length > 0 : typeof t == "number";
|
|
299
296
|
}, M = function(t, e, n) {
|
|
300
297
|
return e === void 0 && (e = 0), n === void 0 && (n = Math.pow(10, e)), Math.round(n * t) / n + 0;
|
|
@@ -306,7 +303,7 @@ var de = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, Y = function(t) {
|
|
|
306
303
|
return { r: X(t.r, 0, 255), g: X(t.g, 0, 255), b: X(t.b, 0, 255), a: X(t.a) };
|
|
307
304
|
}, st = function(t) {
|
|
308
305
|
return { r: M(t.r), g: M(t.g), b: M(t.b), a: M(t.a, 3) };
|
|
309
|
-
},
|
|
306
|
+
}, de = /^#([0-9a-f]{3,8})$/i, j = function(t) {
|
|
310
307
|
var e = t.toString(16);
|
|
311
308
|
return e.length < 2 ? "0" + e : e;
|
|
312
309
|
}, Ut = function(t) {
|
|
@@ -315,8 +312,8 @@ var de = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, Y = function(t) {
|
|
|
315
312
|
}, Vt = function(t) {
|
|
316
313
|
var e = t.h, n = t.s, o = t.v, i = t.a;
|
|
317
314
|
e = e / 360 * 6, n /= 100, o /= 100;
|
|
318
|
-
var s = Math.floor(e), r = o * (1 - n), a = o * (1 - (e - s) * n),
|
|
319
|
-
return { r: 255 * [o, a, r, r,
|
|
315
|
+
var s = Math.floor(e), r = o * (1 - n), a = o * (1 - (e - s) * n), d = o * (1 - (1 - e + s) * n), u = s % 6;
|
|
316
|
+
return { r: 255 * [o, a, r, r, d, o][u], g: 255 * [d, o, o, a, r, r][u], b: 255 * [r, r, d, o, o, a][u], a: i };
|
|
320
317
|
}, At = function(t) {
|
|
321
318
|
return { h: Yt(t.h), s: X(t.s, 0, 100), l: X(t.l, 0, 100), a: X(t.a) };
|
|
322
319
|
}, Et = function(t) {
|
|
@@ -327,17 +324,17 @@ var de = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, Y = function(t) {
|
|
|
327
324
|
}, W = function(t) {
|
|
328
325
|
return { h: (e = Ut(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 };
|
|
329
326
|
var e, n, o, i;
|
|
330
|
-
},
|
|
331
|
-
var e =
|
|
327
|
+
}, ue = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, he = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, fe = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, ge = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, Ct = { string: [[function(t) {
|
|
328
|
+
var e = de.exec(t);
|
|
332
329
|
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 ? M(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 ? M(parseInt(t.substr(6, 2), 16) / 255, 2) : 1 } : null : null;
|
|
333
330
|
}, "hex"], [function(t) {
|
|
334
|
-
var e =
|
|
331
|
+
var e = fe.exec(t) || ge.exec(t);
|
|
335
332
|
return e ? e[2] !== e[4] || e[4] !== e[6] ? null : xt({ 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;
|
|
336
333
|
}, "rgb"], [function(t) {
|
|
337
|
-
var e =
|
|
334
|
+
var e = ue.exec(t) || he.exec(t);
|
|
338
335
|
if (!e)
|
|
339
336
|
return null;
|
|
340
|
-
var n, o, i = At({ h: (n = e[1], o = e[2], o === void 0 && (o = "deg"), Number(n) * (
|
|
337
|
+
var n, o, i = At({ h: (n = e[1], o = e[2], o === void 0 && (o = "deg"), Number(n) * (le[o] || 1)), s: Number(e[3]), l: Number(e[4]), a: e[5] === void 0 ? 1 : Number(e[5]) / (e[6] ? 100 : 1) });
|
|
341
338
|
return St(i);
|
|
342
339
|
}, "hsl"]], object: [[function(t) {
|
|
343
340
|
var e = t.r, n = t.g, o = t.b, i = t.a, s = i === void 0 ? 1 : i;
|
|
@@ -363,7 +360,7 @@ var de = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, Y = function(t) {
|
|
|
363
360
|
return [o, e[n][1]];
|
|
364
361
|
}
|
|
365
362
|
return [null, void 0];
|
|
366
|
-
},
|
|
363
|
+
}, pe = function(t) {
|
|
367
364
|
return typeof t == "string" ? Tt(t.trim(), Ct.string) : typeof t == "object" && t !== null ? Tt(t, Ct.object) : [null, void 0];
|
|
368
365
|
}, rt = function(t, e) {
|
|
369
366
|
var n = W(t);
|
|
@@ -375,7 +372,7 @@ var de = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, Y = function(t) {
|
|
|
375
372
|
return { h: n.h, s: n.s, l: X(n.l + 100 * e, 0, 100), a: n.a };
|
|
376
373
|
}, Bt = function() {
|
|
377
374
|
function t(e) {
|
|
378
|
-
this.parsed =
|
|
375
|
+
this.parsed = pe(e)[0], this.rgba = this.parsed || { r: 0, g: 0, b: 0, a: 1 };
|
|
379
376
|
}
|
|
380
377
|
return t.prototype.isValid = function() {
|
|
381
378
|
return this.parsed !== null;
|
|
@@ -428,7 +425,7 @@ var de = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, Y = function(t) {
|
|
|
428
425
|
}(), D = function(t) {
|
|
429
426
|
return t instanceof Bt ? t : new Bt(t);
|
|
430
427
|
};
|
|
431
|
-
const
|
|
428
|
+
const me = (t) => `background-color: ${D(t.fill || Z.fill).alpha(t.fillOpacity || Z.fillOpacity).toHex()};`, be = () => {
|
|
432
429
|
const t = document.createElement("style");
|
|
433
430
|
document.getElementsByTagName("head")[0].appendChild(t);
|
|
434
431
|
let e, n = /* @__PURE__ */ new Set();
|
|
@@ -436,86 +433,86 @@ const be = (t) => `background-color: ${D(t.fill || Z.fill).alpha(t.fillOpacity |
|
|
|
436
433
|
destroy: () => {
|
|
437
434
|
CSS.highlights.clear(), t.remove();
|
|
438
435
|
},
|
|
439
|
-
refresh: (r, a,
|
|
436
|
+
refresh: (r, a, d, u) => {
|
|
440
437
|
e && e.clear();
|
|
441
|
-
const
|
|
442
|
-
const C = c.has(
|
|
443
|
-
return `::highlight(_${
|
|
438
|
+
const y = new Set(r.map((v) => v.annotation.id)), c = new Set(d), b = Array.from(n).filter((v) => !y.has(v)), g = r.map((v) => {
|
|
439
|
+
const C = c.has(v.annotation.id), w = u ? typeof u == "function" ? u(v.annotation, C) : u : C ? Dt : Z, l = e && e.paint(v, a, C) || w;
|
|
440
|
+
return `::highlight(_${v.annotation.id}) { ${me(l)} }`;
|
|
444
441
|
});
|
|
445
|
-
t.innerHTML =
|
|
446
|
-
`),
|
|
447
|
-
const C =
|
|
448
|
-
CSS.highlights.set(`_${
|
|
449
|
-
}), n =
|
|
442
|
+
t.innerHTML = g.join(`
|
|
443
|
+
`), b.forEach((v) => CSS.highlights.delete(`_${v}`)), r.forEach(({ annotation: v }) => {
|
|
444
|
+
const C = v.target.selector.map((l) => l.range), w = new Highlight(...C);
|
|
445
|
+
CSS.highlights.set(`_${v.id}`, w);
|
|
446
|
+
}), n = y;
|
|
450
447
|
},
|
|
451
448
|
setPainter: (r) => e = r
|
|
452
449
|
};
|
|
453
|
-
},
|
|
450
|
+
}, ve = (t, e, n) => {
|
|
454
451
|
const { store: o, selection: i, hover: s } = e;
|
|
455
|
-
let r, a,
|
|
456
|
-
const
|
|
457
|
-
const { x:
|
|
458
|
-
x && (!
|
|
452
|
+
let r, a, d;
|
|
453
|
+
const u = be(), y = It(n), c = (R) => {
|
|
454
|
+
const { x: p, y: A } = t.getBoundingClientRect(), x = o.getAt(R.clientX - p, R.clientY - A);
|
|
455
|
+
x && (!d || d(x)) ? s.current !== x.id && (t.classList.add("hovered"), s.set(x.id)) : s.current && (t.classList.remove("hovered"), s.set(null));
|
|
459
456
|
};
|
|
460
457
|
t.addEventListener("pointermove", c);
|
|
461
|
-
const
|
|
462
|
-
const R = Ot(t), { minX:
|
|
463
|
-
|
|
464
|
-
},
|
|
465
|
-
r = R,
|
|
466
|
-
},
|
|
467
|
-
a = R,
|
|
458
|
+
const b = () => {
|
|
459
|
+
const R = Ot(t), { minX: p, minY: A, maxX: x, maxY: S } = R, B = d ? o.getIntersectingRects(p, A, x, S).filter(({ annotation: I }) => d(I)) : o.getIntersectingRects(p, A, x, S), L = i.selected.map(({ id: I }) => I);
|
|
460
|
+
u.refresh(B, R, L, a), setTimeout(() => y(B.map(({ annotation: I }) => I)), 1);
|
|
461
|
+
}, g = (R) => {
|
|
462
|
+
r = R, u.setPainter(R);
|
|
463
|
+
}, v = (R) => {
|
|
464
|
+
a = R, b();
|
|
468
465
|
}, C = (R) => {
|
|
469
|
-
|
|
470
|
-
}, w = () =>
|
|
466
|
+
d = R, b();
|
|
467
|
+
}, w = () => b();
|
|
471
468
|
o.observe(w);
|
|
472
|
-
const l = i.subscribe(() =>
|
|
473
|
-
document.addEventListener("scroll",
|
|
474
|
-
const
|
|
475
|
-
o.recalculatePositions(), r && r.reset(),
|
|
469
|
+
const l = i.subscribe(() => b());
|
|
470
|
+
document.addEventListener("scroll", b, { capture: !0, passive: !0 });
|
|
471
|
+
const h = ft(() => {
|
|
472
|
+
o.recalculatePositions(), r && r.reset(), b();
|
|
476
473
|
});
|
|
477
|
-
window.addEventListener("resize",
|
|
478
|
-
const m = new ResizeObserver(
|
|
474
|
+
window.addEventListener("resize", h);
|
|
475
|
+
const m = new ResizeObserver(h);
|
|
479
476
|
m.observe(t);
|
|
480
|
-
const f = { attributes: !0, childList: !0, subtree: !0 }, E = new MutationObserver(
|
|
477
|
+
const f = { attributes: !0, childList: !0, subtree: !0 }, E = new MutationObserver(b);
|
|
481
478
|
return E.observe(document.body, f), {
|
|
482
479
|
destroy: () => {
|
|
483
|
-
t.removeEventListener("pointermove", c),
|
|
480
|
+
t.removeEventListener("pointermove", c), u.destroy(), o.unobserve(w), l(), document.removeEventListener("scroll", b), window.removeEventListener("resize", h), m.disconnect(), E.disconnect();
|
|
484
481
|
},
|
|
485
|
-
refresh:
|
|
486
|
-
setDrawingStyle:
|
|
482
|
+
refresh: b,
|
|
483
|
+
setDrawingStyle: v,
|
|
487
484
|
setFilter: C,
|
|
488
|
-
setPainter:
|
|
485
|
+
setPainter: g
|
|
489
486
|
};
|
|
490
|
-
},
|
|
487
|
+
}, ye = () => {
|
|
491
488
|
const t = document.createElement("canvas");
|
|
492
489
|
t.width = 2 * window.innerWidth, t.height = 2 * window.innerHeight, t.className = "r6o-highlight-layer presence";
|
|
493
490
|
const e = t.getContext("2d");
|
|
494
491
|
return e.scale(2, 2), e.translate(0.5, 0.5), t;
|
|
495
|
-
},
|
|
496
|
-
const o =
|
|
492
|
+
}, we = (t, e, n = {}) => {
|
|
493
|
+
const o = ye(), i = o.getContext("2d");
|
|
497
494
|
t.appendChild(o);
|
|
498
|
-
const s = /* @__PURE__ */ new Map(), r = (c) => Array.from(s.entries()).filter(([
|
|
499
|
-
return e.on("selectionChange", (c,
|
|
500
|
-
r(c).forEach((
|
|
495
|
+
const s = /* @__PURE__ */ new Map(), r = (c) => Array.from(s.entries()).filter(([b, g]) => g.presenceKey === c.presenceKey).map(([b, g]) => b);
|
|
496
|
+
return e.on("selectionChange", (c, b) => {
|
|
497
|
+
r(c).forEach((v) => s.delete(v)), b && b.forEach((v) => s.set(v, c));
|
|
501
498
|
}), {
|
|
502
499
|
clear: () => {
|
|
503
|
-
const { width: c, height:
|
|
504
|
-
i.clearRect(-0.5, -0.5, c + 1,
|
|
500
|
+
const { width: c, height: b } = o;
|
|
501
|
+
i.clearRect(-0.5, -0.5, c + 1, b + 1);
|
|
505
502
|
},
|
|
506
503
|
destroy: () => {
|
|
507
504
|
o.remove();
|
|
508
505
|
},
|
|
509
|
-
paint: (c,
|
|
506
|
+
paint: (c, b, g) => {
|
|
510
507
|
n.font && (i.font = n.font);
|
|
511
|
-
const
|
|
512
|
-
if (
|
|
513
|
-
const { height: C } = c.rects[0], w = c.rects[0].x +
|
|
514
|
-
i.fillStyle =
|
|
515
|
-
const
|
|
516
|
-
return i.fillRect(w - 2, l - 2.5 - f, m, f), i.fillStyle = "#fff", i.fillText(
|
|
517
|
-
fill:
|
|
518
|
-
fillOpacity:
|
|
508
|
+
const v = s.get(c.annotation.id);
|
|
509
|
+
if (v) {
|
|
510
|
+
const { height: C } = c.rects[0], w = c.rects[0].x + b.left, l = c.rects[0].y + b.top;
|
|
511
|
+
i.fillStyle = v.appearance.color, i.fillRect(w - 2, l - 2.5, 2, C + 5);
|
|
512
|
+
const h = i.measureText(v.appearance.label), m = h.width + 6, f = h.actualBoundingBoxAscent + h.actualBoundingBoxDescent + 8, E = h.fontBoundingBoxAscent ? 8 : 6.5;
|
|
513
|
+
return i.fillRect(w - 2, l - 2.5 - f, m, f), i.fillStyle = "#fff", i.fillText(v.appearance.label, w + 1, l - E), {
|
|
514
|
+
fill: v.appearance.color,
|
|
515
|
+
fillOpacity: g ? 0.45 : 0.18
|
|
519
516
|
};
|
|
520
517
|
}
|
|
521
518
|
},
|
|
@@ -527,33 +524,33 @@ const be = (t) => `background-color: ${D(t.fill || Z.fill).alpha(t.fillOpacity |
|
|
|
527
524
|
};
|
|
528
525
|
};
|
|
529
526
|
let K;
|
|
530
|
-
const
|
|
531
|
-
function
|
|
527
|
+
const xe = new Uint8Array(16);
|
|
528
|
+
function Ae() {
|
|
532
529
|
if (!K && (K = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !K))
|
|
533
530
|
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
534
|
-
return K(
|
|
531
|
+
return K(xe);
|
|
535
532
|
}
|
|
536
533
|
const O = [];
|
|
537
534
|
for (let t = 0; t < 256; ++t)
|
|
538
535
|
O.push((t + 256).toString(16).slice(1));
|
|
539
|
-
function
|
|
536
|
+
function Ee(t, e = 0) {
|
|
540
537
|
return O[t[e + 0]] + O[t[e + 1]] + O[t[e + 2]] + O[t[e + 3]] + "-" + O[t[e + 4]] + O[t[e + 5]] + "-" + O[t[e + 6]] + O[t[e + 7]] + "-" + O[t[e + 8]] + O[t[e + 9]] + "-" + O[t[e + 10]] + O[t[e + 11]] + O[t[e + 12]] + O[t[e + 13]] + O[t[e + 14]] + O[t[e + 15]];
|
|
541
538
|
}
|
|
542
|
-
const
|
|
543
|
-
randomUUID:
|
|
539
|
+
const Se = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), Nt = {
|
|
540
|
+
randomUUID: Se
|
|
544
541
|
};
|
|
545
542
|
function kt(t, e, n) {
|
|
546
543
|
if (Nt.randomUUID && !e && !t)
|
|
547
544
|
return Nt.randomUUID();
|
|
548
545
|
t = t || {};
|
|
549
|
-
const o = t.random || (t.rng ||
|
|
546
|
+
const o = t.random || (t.rng || Ae)();
|
|
550
547
|
if (o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128, e) {
|
|
551
548
|
n = n || 0;
|
|
552
549
|
for (let i = 0; i < 16; ++i)
|
|
553
550
|
e[n + i] = o[i];
|
|
554
551
|
return e;
|
|
555
552
|
}
|
|
556
|
-
return
|
|
553
|
+
return Ee(o);
|
|
557
554
|
}
|
|
558
555
|
var Lt = Object.prototype.hasOwnProperty;
|
|
559
556
|
function V(t, e) {
|
|
@@ -583,7 +580,7 @@ function V(t, e) {
|
|
|
583
580
|
}
|
|
584
581
|
function ct() {
|
|
585
582
|
}
|
|
586
|
-
function
|
|
583
|
+
function Ce(t, e) {
|
|
587
584
|
return t != t ? e == e : t !== e || t && typeof t == "object" || typeof t == "function";
|
|
588
585
|
}
|
|
589
586
|
const k = [];
|
|
@@ -591,13 +588,13 @@ function gt(t, e = ct) {
|
|
|
591
588
|
let n;
|
|
592
589
|
const o = /* @__PURE__ */ new Set();
|
|
593
590
|
function i(a) {
|
|
594
|
-
if (
|
|
595
|
-
const
|
|
596
|
-
for (const
|
|
597
|
-
|
|
598
|
-
if (
|
|
599
|
-
for (let
|
|
600
|
-
k[
|
|
591
|
+
if (Ce(t, a) && (t = a, n)) {
|
|
592
|
+
const d = !k.length;
|
|
593
|
+
for (const u of o)
|
|
594
|
+
u[1](), k.push(u, t);
|
|
595
|
+
if (d) {
|
|
596
|
+
for (let u = 0; u < k.length; u += 2)
|
|
597
|
+
k[u][0](k[u + 1]);
|
|
601
598
|
k.length = 0;
|
|
602
599
|
}
|
|
603
600
|
}
|
|
@@ -605,15 +602,15 @@ function gt(t, e = ct) {
|
|
|
605
602
|
function s(a) {
|
|
606
603
|
i(a(t));
|
|
607
604
|
}
|
|
608
|
-
function r(a,
|
|
609
|
-
const
|
|
610
|
-
return o.add(
|
|
611
|
-
o.delete(
|
|
605
|
+
function r(a, d = ct) {
|
|
606
|
+
const u = [a, d];
|
|
607
|
+
return o.add(u), o.size === 1 && (n = e(i, s) || ct), a(t), () => {
|
|
608
|
+
o.delete(u), o.size === 0 && n && (n(), n = null);
|
|
612
609
|
};
|
|
613
610
|
}
|
|
614
611
|
return { set: i, update: s, subscribe: r };
|
|
615
612
|
}
|
|
616
|
-
const
|
|
613
|
+
const Te = (t) => {
|
|
617
614
|
const { subscribe: e, set: n } = gt();
|
|
618
615
|
let o;
|
|
619
616
|
return e((i) => o = i), t.observe(({ changes: i }) => {
|
|
@@ -629,7 +626,7 @@ const Re = (t) => {
|
|
|
629
626
|
subscribe: e,
|
|
630
627
|
set: n
|
|
631
628
|
};
|
|
632
|
-
}, lt = { selected: [] },
|
|
629
|
+
}, lt = { selected: [] }, Re = (t, e = "EDIT") => {
|
|
633
630
|
const { subscribe: n, set: o } = gt(lt);
|
|
634
631
|
let i = lt;
|
|
635
632
|
n((c) => i = c);
|
|
@@ -639,27 +636,27 @@ const Re = (t) => {
|
|
|
639
636
|
}, a = (c) => {
|
|
640
637
|
if (i.selected.length === 0)
|
|
641
638
|
return !1;
|
|
642
|
-
const
|
|
643
|
-
return i.selected.some((
|
|
644
|
-
},
|
|
645
|
-
const
|
|
646
|
-
if (
|
|
647
|
-
const
|
|
648
|
-
o(
|
|
639
|
+
const b = typeof c == "string" ? c : c.id;
|
|
640
|
+
return i.selected.some((g) => g.id === b);
|
|
641
|
+
}, d = (c, b) => {
|
|
642
|
+
const g = t.getAnnotation(c);
|
|
643
|
+
if (g) {
|
|
644
|
+
const v = Be(g, e);
|
|
645
|
+
o(v === "EDIT" ? { selected: [{ id: c, editable: !0 }], pointerEvent: b } : v === "SELECT" ? { selected: [{ id: c }], pointerEvent: b } : { selected: [], pointerEvent: b });
|
|
649
646
|
} else
|
|
650
647
|
console.warn("Invalid selection: " + c);
|
|
651
|
-
},
|
|
652
|
-
const
|
|
653
|
-
o({ selected:
|
|
654
|
-
},
|
|
648
|
+
}, u = (c, b = !0) => {
|
|
649
|
+
const g = Array.isArray(c) ? c : [c], v = g.map((C) => t.getAnnotation(C)).filter(Boolean);
|
|
650
|
+
o({ selected: v.map(({ id: C }) => ({ id: C, editable: b })) }), v.length !== g.length && console.warn("Invalid selection", c);
|
|
651
|
+
}, y = (c) => {
|
|
655
652
|
if (i.selected.length === 0)
|
|
656
653
|
return !1;
|
|
657
|
-
const { selected:
|
|
658
|
-
|
|
654
|
+
const { selected: b } = i;
|
|
655
|
+
b.filter(({ id: g }) => c.includes(g)).length > 0 && o({ selected: b.filter(({ id: g }) => !c.includes(g)) });
|
|
659
656
|
};
|
|
660
|
-
return t.observe(({ changes: c }) =>
|
|
657
|
+
return t.observe(({ changes: c }) => y((c.deleted || []).map((b) => b.id))), {
|
|
661
658
|
clear: s,
|
|
662
|
-
clickSelect:
|
|
659
|
+
clickSelect: d,
|
|
663
660
|
get selected() {
|
|
664
661
|
return i ? [...i.selected] : null;
|
|
665
662
|
},
|
|
@@ -668,44 +665,44 @@ const Re = (t) => {
|
|
|
668
665
|
},
|
|
669
666
|
isEmpty: r,
|
|
670
667
|
isSelected: a,
|
|
671
|
-
setSelected:
|
|
668
|
+
setSelected: u,
|
|
672
669
|
subscribe: n
|
|
673
670
|
};
|
|
674
|
-
},
|
|
671
|
+
}, Be = (t, e) => typeof e == "function" ? e(t) || "EDIT" : e || "EDIT", Ne = [];
|
|
675
672
|
for (let t = 0; t < 256; ++t)
|
|
676
|
-
|
|
673
|
+
Ne.push((t + 256).toString(16).slice(1));
|
|
677
674
|
typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
|
|
678
|
-
const
|
|
675
|
+
const Le = (t, e) => {
|
|
679
676
|
const n = new Set(t.bodies.map((o) => o.id));
|
|
680
677
|
return e.bodies.filter((o) => !n.has(o.id));
|
|
681
|
-
},
|
|
678
|
+
}, Me = (t, e) => {
|
|
682
679
|
const n = new Set(e.bodies.map((o) => o.id));
|
|
683
680
|
return t.bodies.filter((o) => !n.has(o.id));
|
|
684
|
-
},
|
|
681
|
+
}, Oe = (t, e) => e.bodies.map((n) => {
|
|
685
682
|
const o = t.bodies.find((i) => i.id === n.id);
|
|
686
683
|
return { newBody: n, oldBody: o && !V(o, n) ? o : void 0 };
|
|
687
|
-
}).filter(({ oldBody: n }) => n).map(({ oldBody: n, newBody: o }) => ({ oldBody: n, newBody: o })),
|
|
688
|
-
const n =
|
|
684
|
+
}).filter(({ oldBody: n }) => n).map(({ oldBody: n, newBody: o }) => ({ oldBody: n, newBody: o })), Ie = (t, e) => !V(t.target, e.target), Pt = (t, e) => {
|
|
685
|
+
const n = Le(t, e), o = Me(t, e), i = Oe(t, e);
|
|
689
686
|
return {
|
|
690
687
|
oldValue: t,
|
|
691
688
|
newValue: e,
|
|
692
689
|
bodiesCreated: n.length > 0 ? n : void 0,
|
|
693
690
|
bodiesDeleted: o.length > 0 ? o : void 0,
|
|
694
691
|
bodiesUpdated: i.length > 0 ? i : void 0,
|
|
695
|
-
targetUpdated:
|
|
692
|
+
targetUpdated: Ie(t, e) ? { oldTarget: t.target, newTarget: e.target } : void 0
|
|
696
693
|
};
|
|
697
694
|
};
|
|
698
695
|
var N = /* @__PURE__ */ ((t) => (t.LOCAL = "LOCAL", t.REMOTE = "REMOTE", t))(N || {});
|
|
699
|
-
const
|
|
696
|
+
const Xe = (t, e) => {
|
|
700
697
|
var n, o;
|
|
701
698
|
const { changes: i, origin: s } = e;
|
|
702
699
|
if (!(!t.options.origin || t.options.origin === s))
|
|
703
700
|
return !1;
|
|
704
701
|
if (t.options.ignore) {
|
|
705
|
-
const { ignore: r } = t.options, a = (
|
|
702
|
+
const { ignore: r } = t.options, a = (d) => d && d.length > 0;
|
|
706
703
|
if (!(a(i.created) || a(i.deleted))) {
|
|
707
|
-
const
|
|
708
|
-
if (r === "BODY_ONLY" &&
|
|
704
|
+
const d = (n = i.updated) == null ? void 0 : n.some((y) => a(y.bodiesCreated) || a(y.bodiesDeleted) || a(y.bodiesUpdated)), u = (o = i.updated) == null ? void 0 : o.some((y) => y.targetUpdated);
|
|
705
|
+
if (r === "BODY_ONLY" && d && !u || r === "TARGET_ONLY" && u && !d)
|
|
709
706
|
return !1;
|
|
710
707
|
}
|
|
711
708
|
}
|
|
@@ -718,32 +715,32 @@ const _e = (t, e) => {
|
|
|
718
715
|
return !!(Array.isArray(t.options.annotations) ? t.options.annotations : [t.options.annotations]).find((a) => r.has(a));
|
|
719
716
|
} else
|
|
720
717
|
return !0;
|
|
721
|
-
},
|
|
722
|
-
const n = new Set((t.created || []).map((c) => c.id)), o = new Set((t.updated || []).map(({ newValue: c }) => c.id)), i = new Set((e.created || []).map((c) => c.id)), s = new Set((e.deleted || []).map((c) => c.id)), r = new Set((e.updated || []).map(({ oldValue: c }) => c.id)), a = new Set((e.updated || []).filter(({ oldValue: c }) => n.has(c.id) || o.has(c.id)).map(({ oldValue: c }) => c.id)),
|
|
723
|
-
...(t.created || []).filter((c) => !s.has(c.id)).map((c) => r.has(c.id) ? e.updated.find(({ oldValue:
|
|
718
|
+
}, _e = (t, e) => {
|
|
719
|
+
const n = new Set((t.created || []).map((c) => c.id)), o = new Set((t.updated || []).map(({ newValue: c }) => c.id)), i = new Set((e.created || []).map((c) => c.id)), s = new Set((e.deleted || []).map((c) => c.id)), r = new Set((e.updated || []).map(({ oldValue: c }) => c.id)), a = new Set((e.updated || []).filter(({ oldValue: c }) => n.has(c.id) || o.has(c.id)).map(({ oldValue: c }) => c.id)), d = [
|
|
720
|
+
...(t.created || []).filter((c) => !s.has(c.id)).map((c) => r.has(c.id) ? e.updated.find(({ oldValue: b }) => b.id === c.id).newValue : c),
|
|
724
721
|
...e.created || []
|
|
725
|
-
],
|
|
722
|
+
], u = [
|
|
726
723
|
...(t.deleted || []).filter((c) => !i.has(c.id)),
|
|
727
724
|
...(e.deleted || []).filter((c) => !n.has(c.id))
|
|
728
|
-
],
|
|
725
|
+
], y = [
|
|
729
726
|
...(t.updated || []).filter(({ newValue: c }) => !s.has(c.id)).map((c) => {
|
|
730
|
-
const { oldValue:
|
|
731
|
-
if (r.has(
|
|
732
|
-
const
|
|
733
|
-
return Pt(
|
|
727
|
+
const { oldValue: b, newValue: g } = c;
|
|
728
|
+
if (r.has(g.id)) {
|
|
729
|
+
const v = e.updated.find((C) => C.oldValue.id === g.id).newValue;
|
|
730
|
+
return Pt(b, v);
|
|
734
731
|
} else
|
|
735
732
|
return c;
|
|
736
733
|
}),
|
|
737
734
|
...(e.updated || []).filter(({ oldValue: c }) => !a.has(c.id))
|
|
738
735
|
];
|
|
739
|
-
return { created:
|
|
740
|
-
},
|
|
741
|
-
const t = /* @__PURE__ */ new Map(), e = /* @__PURE__ */ new Map(), n = [], o = (
|
|
742
|
-
const A = n.findIndex((x) => x.onChange ==
|
|
736
|
+
return { created: d, deleted: u, updated: y };
|
|
737
|
+
}, De = (t) => t.id !== void 0, Ye = () => {
|
|
738
|
+
const t = /* @__PURE__ */ new Map(), e = /* @__PURE__ */ new Map(), n = [], o = (p, A = {}) => n.push({ onChange: p, options: A }), i = (p) => {
|
|
739
|
+
const A = n.findIndex((x) => x.onChange == p);
|
|
743
740
|
A > -1 && n.splice(A, 1);
|
|
744
|
-
}, s = (
|
|
741
|
+
}, s = (p, A) => {
|
|
745
742
|
const x = {
|
|
746
|
-
origin:
|
|
743
|
+
origin: p,
|
|
747
744
|
changes: {
|
|
748
745
|
created: A.created || [],
|
|
749
746
|
updated: A.updated || [],
|
|
@@ -752,85 +749,85 @@ const _e = (t, e) => {
|
|
|
752
749
|
state: [...t.values()]
|
|
753
750
|
};
|
|
754
751
|
n.forEach((S) => {
|
|
755
|
-
|
|
752
|
+
Xe(S, x) && S.onChange(x);
|
|
756
753
|
});
|
|
757
|
-
}, r = (
|
|
758
|
-
if (t.get(
|
|
759
|
-
throw Error(`Cannot add annotation ${
|
|
760
|
-
t.set(
|
|
761
|
-
}, a = (
|
|
762
|
-
const x = typeof
|
|
754
|
+
}, r = (p, A = N.LOCAL) => {
|
|
755
|
+
if (t.get(p.id))
|
|
756
|
+
throw Error(`Cannot add annotation ${p.id} - exists already`);
|
|
757
|
+
t.set(p.id, p), p.bodies.forEach((x) => e.set(x.id, p.id)), s(A, { created: [p] });
|
|
758
|
+
}, a = (p, A) => {
|
|
759
|
+
const x = typeof p == "string" ? A : p, S = typeof p == "string" ? p : p.id, B = t.get(S);
|
|
763
760
|
if (B) {
|
|
764
761
|
const L = Pt(B, x);
|
|
765
762
|
return S === x.id ? t.set(S, x) : (t.delete(S), t.set(x.id, x)), B.bodies.forEach((I) => e.delete(I.id)), x.bodies.forEach((I) => e.set(I.id, x.id)), L;
|
|
766
763
|
} else
|
|
767
764
|
console.warn(`Cannot update annotation ${S} - does not exist`);
|
|
768
|
-
},
|
|
769
|
-
const S =
|
|
765
|
+
}, d = (p, A = N.LOCAL, x = N.LOCAL) => {
|
|
766
|
+
const S = De(A) ? x : A, B = a(p, A);
|
|
770
767
|
B && s(S, { updated: [B] });
|
|
771
|
-
},
|
|
772
|
-
const x =
|
|
768
|
+
}, u = (p, A = N.LOCAL) => {
|
|
769
|
+
const x = p.reduce((S, B) => {
|
|
773
770
|
const L = a(B);
|
|
774
771
|
return L ? [...S, L] : S;
|
|
775
772
|
}, []);
|
|
776
773
|
x.length > 0 && s(A, { updated: x });
|
|
777
|
-
},
|
|
778
|
-
const x = t.get(
|
|
774
|
+
}, y = (p, A = N.LOCAL) => {
|
|
775
|
+
const x = t.get(p.annotation);
|
|
779
776
|
if (x) {
|
|
780
777
|
const S = {
|
|
781
778
|
...x,
|
|
782
|
-
bodies: [...x.bodies,
|
|
779
|
+
bodies: [...x.bodies, p]
|
|
783
780
|
};
|
|
784
|
-
t.set(x.id, S), e.set(
|
|
781
|
+
t.set(x.id, S), e.set(p.id, S.id), s(A, { updated: [{
|
|
785
782
|
oldValue: x,
|
|
786
783
|
newValue: S,
|
|
787
|
-
bodiesCreated: [
|
|
784
|
+
bodiesCreated: [p]
|
|
788
785
|
}] });
|
|
789
786
|
} else
|
|
790
|
-
console.warn(`Attempt to add body to missing annotation: ${
|
|
791
|
-
}, c = () => [...t.values()],
|
|
787
|
+
console.warn(`Attempt to add body to missing annotation: ${p.annotation}`);
|
|
788
|
+
}, c = () => [...t.values()], b = (p = N.LOCAL) => {
|
|
792
789
|
const A = [...t.values()];
|
|
793
|
-
t.clear(), e.clear(), s(
|
|
794
|
-
},
|
|
790
|
+
t.clear(), e.clear(), s(p, { deleted: A });
|
|
791
|
+
}, g = (p, A = !0, x = N.LOCAL) => {
|
|
795
792
|
if (A) {
|
|
796
793
|
const S = [...t.values()];
|
|
797
|
-
t.clear(), e.clear(),
|
|
794
|
+
t.clear(), e.clear(), p.forEach((B) => {
|
|
798
795
|
t.set(B.id, B), B.bodies.forEach((L) => e.set(L.id, B.id));
|
|
799
|
-
}), s(x, { created:
|
|
796
|
+
}), s(x, { created: p, deleted: S });
|
|
800
797
|
} else {
|
|
801
|
-
const S =
|
|
798
|
+
const S = p.reduce((B, L) => {
|
|
802
799
|
const I = t.get(L.id);
|
|
803
800
|
return I ? [...B, I] : B;
|
|
804
801
|
}, []);
|
|
805
802
|
if (S.length > 0)
|
|
806
803
|
throw Error(`Bulk insert would overwrite the following annotations: ${S.map((B) => B.id).join(", ")}`);
|
|
807
|
-
|
|
804
|
+
p.forEach((B) => {
|
|
808
805
|
t.set(B.id, B), B.bodies.forEach((L) => e.set(L.id, B.id));
|
|
809
|
-
}), s(x, { created:
|
|
806
|
+
}), s(x, { created: p });
|
|
810
807
|
}
|
|
811
|
-
},
|
|
812
|
-
const A = typeof
|
|
808
|
+
}, v = (p) => {
|
|
809
|
+
const A = typeof p == "string" ? p : p.id, x = t.get(A);
|
|
813
810
|
if (x)
|
|
814
811
|
return t.delete(A), x.bodies.forEach((S) => e.delete(S.id)), x;
|
|
815
812
|
console.warn(`Attempt to delete missing annotation: ${A}`);
|
|
816
|
-
}, C = (
|
|
817
|
-
const x =
|
|
813
|
+
}, C = (p, A = N.LOCAL) => {
|
|
814
|
+
const x = v(p);
|
|
818
815
|
x && s(A, { deleted: [x] });
|
|
819
|
-
}, w = (
|
|
820
|
-
const x =
|
|
821
|
-
const L =
|
|
816
|
+
}, w = (p, A = N.LOCAL) => {
|
|
817
|
+
const x = p.reduce((S, B) => {
|
|
818
|
+
const L = v(B);
|
|
822
819
|
return L ? [...S, L] : S;
|
|
823
820
|
}, []);
|
|
824
821
|
x.length > 0 && s(A, { deleted: x });
|
|
825
|
-
}, l = (
|
|
826
|
-
const x = t.get(
|
|
822
|
+
}, l = (p, A = N.LOCAL) => {
|
|
823
|
+
const x = t.get(p.annotation);
|
|
827
824
|
if (x) {
|
|
828
|
-
const S = x.bodies.find((B) => B.id ===
|
|
825
|
+
const S = x.bodies.find((B) => B.id === p.id);
|
|
829
826
|
if (S) {
|
|
830
827
|
e.delete(S.id);
|
|
831
828
|
const B = {
|
|
832
829
|
...x,
|
|
833
|
-
bodies: x.bodies.filter((L) => L.id !==
|
|
830
|
+
bodies: x.bodies.filter((L) => L.id !== p.id)
|
|
834
831
|
};
|
|
835
832
|
t.set(x.id, B), s(A, { updated: [{
|
|
836
833
|
oldValue: x,
|
|
@@ -838,27 +835,27 @@ const _e = (t, e) => {
|
|
|
838
835
|
bodiesDeleted: [S]
|
|
839
836
|
}] });
|
|
840
837
|
} else
|
|
841
|
-
console.warn(`Attempt to delete missing body ${
|
|
838
|
+
console.warn(`Attempt to delete missing body ${p.id} from annotation ${p.annotation}`);
|
|
842
839
|
} else
|
|
843
|
-
console.warn(`Attempt to delete body from missing annotation ${
|
|
844
|
-
},
|
|
845
|
-
const A = t.get(
|
|
840
|
+
console.warn(`Attempt to delete body from missing annotation ${p.annotation}`);
|
|
841
|
+
}, h = (p) => {
|
|
842
|
+
const A = t.get(p);
|
|
846
843
|
return A ? { ...A } : void 0;
|
|
847
|
-
}, m = (
|
|
848
|
-
const A = e.get(
|
|
844
|
+
}, m = (p) => {
|
|
845
|
+
const A = e.get(p);
|
|
849
846
|
if (A) {
|
|
850
|
-
const x =
|
|
847
|
+
const x = h(A).bodies.find((S) => S.id === p);
|
|
851
848
|
if (x)
|
|
852
849
|
return x;
|
|
853
|
-
console.error(`Store integrity error: body ${
|
|
850
|
+
console.error(`Store integrity error: body ${p} in index, but not in annotation`);
|
|
854
851
|
} else
|
|
855
|
-
console.warn(`Attempt to retrieve missing body: ${
|
|
856
|
-
}, f = (
|
|
857
|
-
if (
|
|
852
|
+
console.warn(`Attempt to retrieve missing body: ${p}`);
|
|
853
|
+
}, f = (p, A) => {
|
|
854
|
+
if (p.annotation !== A.annotation)
|
|
858
855
|
throw "Annotation integrity violation: annotation ID must be the same when updating bodies";
|
|
859
|
-
const x = t.get(
|
|
856
|
+
const x = t.get(p.annotation);
|
|
860
857
|
if (x) {
|
|
861
|
-
const S = x.bodies.find((L) => L.id ===
|
|
858
|
+
const S = x.bodies.find((L) => L.id === p.id), B = {
|
|
862
859
|
...x,
|
|
863
860
|
bodies: x.bodies.map((L) => L.id === S.id ? A : L)
|
|
864
861
|
};
|
|
@@ -868,21 +865,21 @@ const _e = (t, e) => {
|
|
|
868
865
|
bodiesUpdated: [{ oldBody: S, newBody: A }]
|
|
869
866
|
};
|
|
870
867
|
} else
|
|
871
|
-
console.warn(`Attempt to add body to missing annotation ${
|
|
872
|
-
}, E = (
|
|
873
|
-
const S = f(
|
|
868
|
+
console.warn(`Attempt to add body to missing annotation ${p.annotation}`);
|
|
869
|
+
}, E = (p, A, x = N.LOCAL) => {
|
|
870
|
+
const S = f(p, A);
|
|
874
871
|
S && s(x, { updated: [S] });
|
|
875
|
-
}, T = (
|
|
876
|
-
const x =
|
|
872
|
+
}, T = (p, A = N.LOCAL) => {
|
|
873
|
+
const x = p.map((S) => f({ id: S.id, annotation: S.annotation }, S)).filter(Boolean);
|
|
877
874
|
s(A, { updated: x });
|
|
878
|
-
}, R = (
|
|
879
|
-
const A = t.get(
|
|
875
|
+
}, R = (p) => {
|
|
876
|
+
const A = t.get(p.annotation);
|
|
880
877
|
if (A) {
|
|
881
878
|
const x = {
|
|
882
879
|
...A,
|
|
883
880
|
target: {
|
|
884
881
|
...A.target,
|
|
885
|
-
...
|
|
882
|
+
...p
|
|
886
883
|
}
|
|
887
884
|
};
|
|
888
885
|
return t.set(A.id, x), {
|
|
@@ -890,40 +887,40 @@ const _e = (t, e) => {
|
|
|
890
887
|
newValue: x,
|
|
891
888
|
targetUpdated: {
|
|
892
889
|
oldTarget: A.target,
|
|
893
|
-
newTarget:
|
|
890
|
+
newTarget: p
|
|
894
891
|
}
|
|
895
892
|
};
|
|
896
893
|
} else
|
|
897
|
-
console.warn(`Attempt to update target on missing annotation: ${
|
|
894
|
+
console.warn(`Attempt to update target on missing annotation: ${p.annotation}`);
|
|
898
895
|
};
|
|
899
896
|
return {
|
|
900
897
|
addAnnotation: r,
|
|
901
|
-
addBody:
|
|
898
|
+
addBody: y,
|
|
902
899
|
all: c,
|
|
903
|
-
bulkAddAnnotation:
|
|
900
|
+
bulkAddAnnotation: g,
|
|
904
901
|
bulkDeleteAnnotation: w,
|
|
905
|
-
bulkUpdateAnnotation:
|
|
902
|
+
bulkUpdateAnnotation: u,
|
|
906
903
|
bulkUpdateBodies: T,
|
|
907
|
-
bulkUpdateTargets: (
|
|
908
|
-
const x =
|
|
904
|
+
bulkUpdateTargets: (p, A = N.LOCAL) => {
|
|
905
|
+
const x = p.map((S) => R(S)).filter(Boolean);
|
|
909
906
|
x.length > 0 && s(A, { updated: x });
|
|
910
907
|
},
|
|
911
|
-
clear:
|
|
908
|
+
clear: b,
|
|
912
909
|
deleteAnnotation: C,
|
|
913
910
|
deleteBody: l,
|
|
914
|
-
getAnnotation:
|
|
911
|
+
getAnnotation: h,
|
|
915
912
|
getBody: m,
|
|
916
913
|
observe: o,
|
|
917
914
|
unobserve: i,
|
|
918
|
-
updateAnnotation:
|
|
915
|
+
updateAnnotation: d,
|
|
919
916
|
updateBody: E,
|
|
920
|
-
updateTarget: (
|
|
921
|
-
const x = R(
|
|
917
|
+
updateTarget: (p, A = N.LOCAL) => {
|
|
918
|
+
const x = R(p);
|
|
922
919
|
x && s(A, { updated: [x] });
|
|
923
920
|
}
|
|
924
921
|
};
|
|
925
922
|
};
|
|
926
|
-
let
|
|
923
|
+
let Ue = () => ({
|
|
927
924
|
emit(t, ...e) {
|
|
928
925
|
for (let n = 0, o = this.events[t] || [], i = o.length; n < i; n++)
|
|
929
926
|
o[n](...e);
|
|
@@ -937,123 +934,123 @@ let Ve = () => ({
|
|
|
937
934
|
};
|
|
938
935
|
}
|
|
939
936
|
});
|
|
940
|
-
const
|
|
941
|
-
const e =
|
|
937
|
+
const Ve = 250, ke = (t) => {
|
|
938
|
+
const e = Ue(), n = [];
|
|
942
939
|
let o = -1, i = !1, s = 0;
|
|
943
|
-
const r = (
|
|
940
|
+
const r = (g) => {
|
|
944
941
|
if (!i) {
|
|
945
|
-
const { changes:
|
|
946
|
-
if (C - s >
|
|
947
|
-
n.splice(o + 1), n.push(
|
|
942
|
+
const { changes: v } = g, C = performance.now();
|
|
943
|
+
if (C - s > Ve)
|
|
944
|
+
n.splice(o + 1), n.push(v), o = n.length - 1;
|
|
948
945
|
else {
|
|
949
946
|
const w = n.length - 1;
|
|
950
|
-
n[w] =
|
|
947
|
+
n[w] = _e(n[w], v);
|
|
951
948
|
}
|
|
952
949
|
s = C;
|
|
953
950
|
}
|
|
954
951
|
i = !1;
|
|
955
952
|
};
|
|
956
953
|
t.observe(r, { origin: N.LOCAL });
|
|
957
|
-
const a = (
|
|
954
|
+
const a = (g) => g && g.length > 0 && t.bulkDeleteAnnotation(g), d = (g) => g && g.length > 0 && t.bulkAddAnnotation(g, !1), u = (g) => g && g.length > 0 && t.bulkUpdateAnnotation(g.map(({ oldValue: v }) => v)), y = (g) => g && g.length > 0 && t.bulkUpdateAnnotation(g.map(({ newValue: v }) => v)), c = (g) => g && g.length > 0 && t.bulkAddAnnotation(g, !1), b = (g) => g && g.length > 0 && t.bulkDeleteAnnotation(g);
|
|
958
955
|
return {
|
|
959
956
|
canRedo: () => n.length - 1 > o,
|
|
960
957
|
canUndo: () => o > -1,
|
|
961
958
|
destroy: () => t.unobserve(r),
|
|
962
|
-
on: (
|
|
959
|
+
on: (g, v) => e.on(g, v),
|
|
963
960
|
redo: () => {
|
|
964
961
|
if (n.length - 1 > o) {
|
|
965
962
|
i = !0;
|
|
966
|
-
const { created:
|
|
967
|
-
|
|
963
|
+
const { created: g, updated: v, deleted: C } = n[o + 1];
|
|
964
|
+
d(g), y(v), b(C), e.emit("redo", n[o + 1]), o += 1;
|
|
968
965
|
}
|
|
969
966
|
},
|
|
970
967
|
undo: () => {
|
|
971
968
|
if (o > -1) {
|
|
972
969
|
i = !0;
|
|
973
|
-
const { created:
|
|
974
|
-
a(
|
|
970
|
+
const { created: g, updated: v, deleted: C } = n[o];
|
|
971
|
+
a(g), u(v), c(C), e.emit("undo", n[o]), o -= 1;
|
|
975
972
|
}
|
|
976
973
|
}
|
|
977
974
|
};
|
|
978
|
-
},
|
|
975
|
+
}, Pe = () => {
|
|
979
976
|
const { subscribe: t, set: e } = gt([]);
|
|
980
977
|
return {
|
|
981
978
|
subscribe: t,
|
|
982
979
|
set: e
|
|
983
980
|
};
|
|
984
|
-
},
|
|
985
|
-
const { store: i, selection: s, hover: r, viewport: a } = t,
|
|
986
|
-
let
|
|
987
|
-
const
|
|
988
|
-
|
|
989
|
-
},
|
|
990
|
-
const m =
|
|
991
|
-
m && m.indexOf(
|
|
992
|
-
},
|
|
993
|
-
|
|
994
|
-
|
|
981
|
+
}, He = (t, e, n, o) => {
|
|
982
|
+
const { store: i, selection: s, hover: r, viewport: a } = t, d = /* @__PURE__ */ new Map();
|
|
983
|
+
let u = [], y, c;
|
|
984
|
+
const b = (l, h) => {
|
|
985
|
+
d.has(l) ? d.get(l).push(h) : d.set(l, [h]);
|
|
986
|
+
}, g = (l, h) => {
|
|
987
|
+
const m = d.get(l);
|
|
988
|
+
m && m.indexOf(h) > 0 && m.splice(m.indexOf(h), 1);
|
|
989
|
+
}, v = (l, h, m) => {
|
|
990
|
+
d.has(l) && setTimeout(() => {
|
|
991
|
+
d.get(l).forEach((f) => {
|
|
995
992
|
if (n) {
|
|
996
|
-
const E = Array.isArray(
|
|
993
|
+
const E = Array.isArray(h) ? h.map((R) => n.serialize(R)) : n.serialize(h), T = m ? m instanceof PointerEvent ? m : n.serialize(m) : void 0;
|
|
997
994
|
f(E, T);
|
|
998
995
|
} else
|
|
999
|
-
f(
|
|
996
|
+
f(h, m);
|
|
1000
997
|
});
|
|
1001
998
|
}, 1);
|
|
1002
999
|
}, C = () => {
|
|
1003
|
-
const { selected: l } = s,
|
|
1004
|
-
|
|
1005
|
-
const f =
|
|
1006
|
-
(!f || !V(f, m)) &&
|
|
1007
|
-
}),
|
|
1000
|
+
const { selected: l } = s, h = (l || []).map(({ id: m }) => i.getAnnotation(m));
|
|
1001
|
+
h.forEach((m) => {
|
|
1002
|
+
const f = u.find((E) => E.id === m.id);
|
|
1003
|
+
(!f || !V(f, m)) && v("updateAnnotation", m, f);
|
|
1004
|
+
}), u = u.map((m) => h.find(({ id: E }) => E === m.id) || m);
|
|
1008
1005
|
};
|
|
1009
1006
|
s.subscribe(({ selected: l }) => {
|
|
1010
|
-
if (!(
|
|
1011
|
-
if (
|
|
1012
|
-
|
|
1013
|
-
else if (
|
|
1014
|
-
|
|
1015
|
-
const m = i.getAnnotation(
|
|
1016
|
-
m && !V(m,
|
|
1017
|
-
}),
|
|
1007
|
+
if (!(u.length === 0 && l.length === 0)) {
|
|
1008
|
+
if (u.length === 0 && l.length > 0)
|
|
1009
|
+
u = l.map(({ id: h }) => i.getAnnotation(h));
|
|
1010
|
+
else if (u.length > 0 && l.length === 0)
|
|
1011
|
+
u.forEach((h) => {
|
|
1012
|
+
const m = i.getAnnotation(h.id);
|
|
1013
|
+
m && !V(m, h) && v("updateAnnotation", m, h);
|
|
1014
|
+
}), u = [];
|
|
1018
1015
|
else {
|
|
1019
|
-
const
|
|
1020
|
-
|
|
1016
|
+
const h = new Set(u.map((f) => f.id)), m = new Set(l.map(({ id: f }) => f));
|
|
1017
|
+
u.filter((f) => !m.has(f.id)).forEach((f) => {
|
|
1021
1018
|
const E = i.getAnnotation(f.id);
|
|
1022
|
-
E && !V(E, f) &&
|
|
1023
|
-
}),
|
|
1019
|
+
E && !V(E, f) && v("updateAnnotation", E, f);
|
|
1020
|
+
}), u = [
|
|
1024
1021
|
// Remove annotations that were deselected
|
|
1025
|
-
...
|
|
1022
|
+
...u.filter((f) => m.has(f.id)),
|
|
1026
1023
|
// Add editable annotations that were selected
|
|
1027
|
-
...l.filter(({ id: f }) => !
|
|
1024
|
+
...l.filter(({ id: f }) => !h.has(f)).map(({ id: f }) => i.getAnnotation(f))
|
|
1028
1025
|
];
|
|
1029
1026
|
}
|
|
1030
|
-
|
|
1027
|
+
v("selectionChanged", u);
|
|
1031
1028
|
}
|
|
1032
1029
|
}), r.subscribe((l) => {
|
|
1033
|
-
!
|
|
1034
|
-
}), a == null || a.subscribe((l) =>
|
|
1030
|
+
!y && l ? v("mouseEnterAnnotation", i.getAnnotation(l)) : y && !l ? v("mouseLeaveAnnotation", i.getAnnotation(y)) : y && l && (v("mouseLeaveAnnotation", i.getAnnotation(y)), v("mouseEnterAnnotation", i.getAnnotation(l))), y = l;
|
|
1031
|
+
}), a == null || a.subscribe((l) => v("viewportIntersect", l.map((h) => i.getAnnotation(h)))), i.observe((l) => {
|
|
1035
1032
|
o && (c && clearTimeout(c), c = setTimeout(C, 1e3));
|
|
1036
|
-
const { created:
|
|
1037
|
-
(
|
|
1033
|
+
const { created: h, deleted: m } = l.changes;
|
|
1034
|
+
(h || []).forEach((f) => v("createAnnotation", f)), (m || []).forEach((f) => v("deleteAnnotation", f)), (l.changes.updated || []).filter((f) => [
|
|
1038
1035
|
...f.bodiesCreated || [],
|
|
1039
1036
|
...f.bodiesDeleted || [],
|
|
1040
1037
|
...f.bodiesUpdated || []
|
|
1041
1038
|
].length > 0).forEach(({ oldValue: f, newValue: E }) => {
|
|
1042
|
-
const T =
|
|
1043
|
-
|
|
1039
|
+
const T = u.find((R) => R.id === f.id) || f;
|
|
1040
|
+
u = u.map((R) => R.id === f.id ? E : R), v("updateAnnotation", E, T);
|
|
1044
1041
|
});
|
|
1045
1042
|
}, { origin: N.LOCAL }), i.observe((l) => {
|
|
1046
|
-
if (
|
|
1047
|
-
const
|
|
1048
|
-
m.length > 0 && (
|
|
1043
|
+
if (u) {
|
|
1044
|
+
const h = new Set(u.map((f) => f.id)), m = (l.changes.updated || []).filter(({ newValue: f }) => h.has(f.id)).map(({ newValue: f }) => f);
|
|
1045
|
+
m.length > 0 && (u = u.map((f) => m.find((T) => T.id === f.id) || f));
|
|
1049
1046
|
}
|
|
1050
1047
|
}, { origin: N.REMOTE });
|
|
1051
|
-
const w = (l) => (
|
|
1052
|
-
const { created: m, deleted: f, updated: E } =
|
|
1053
|
-
(m || []).forEach((T) =>
|
|
1048
|
+
const w = (l) => (h) => {
|
|
1049
|
+
const { created: m, deleted: f, updated: E } = h;
|
|
1050
|
+
(m || []).forEach((T) => v("createAnnotation", T)), (f || []).forEach((T) => v("deleteAnnotation", T)), l ? (E || []).forEach((T) => v("updateAnnotation", T.oldValue, T.newValue)) : (E || []).forEach((T) => v("updateAnnotation", T.newValue, T.oldValue));
|
|
1054
1051
|
};
|
|
1055
|
-
return e.on("undo", w(!0)), e.on("redo", w(!1)), { on:
|
|
1056
|
-
},
|
|
1052
|
+
return e.on("undo", w(!0)), e.on("redo", w(!1)), { on: b, off: g, emit: v };
|
|
1053
|
+
}, $e = (t) => (e) => e.reduce((n, o) => {
|
|
1057
1054
|
const { parsed: i, error: s } = t.parse(o);
|
|
1058
1055
|
return s ? {
|
|
1059
1056
|
parsed: n.parsed,
|
|
@@ -1064,21 +1061,21 @@ const ke = 250, Pe = (t) => {
|
|
|
1064
1061
|
} : {
|
|
1065
1062
|
...n
|
|
1066
1063
|
};
|
|
1067
|
-
}, { parsed: [], failed: [] }),
|
|
1064
|
+
}, { parsed: [], failed: [] }), Fe = (t, e, n) => {
|
|
1068
1065
|
const { store: o, selection: i } = t, s = (w) => {
|
|
1069
1066
|
if (n) {
|
|
1070
|
-
const { parsed: l, error:
|
|
1071
|
-
l ? o.addAnnotation(l, N.REMOTE) : console.error(
|
|
1067
|
+
const { parsed: l, error: h } = n.parse(w);
|
|
1068
|
+
l ? o.addAnnotation(l, N.REMOTE) : console.error(h);
|
|
1072
1069
|
} else
|
|
1073
1070
|
o.addAnnotation(w, N.REMOTE);
|
|
1074
|
-
}, r = () => i.clear(), a = () => o.clear(),
|
|
1071
|
+
}, r = () => i.clear(), a = () => o.clear(), d = (w) => {
|
|
1075
1072
|
const l = o.getAnnotation(w);
|
|
1076
1073
|
return n && l ? n.serialize(l) : l;
|
|
1077
|
-
},
|
|
1074
|
+
}, u = () => n ? o.all().map(n.serialize) : o.all(), y = () => {
|
|
1078
1075
|
var w;
|
|
1079
|
-
const l = (((w = i.selected) == null ? void 0 : w.map((
|
|
1076
|
+
const l = (((w = i.selected) == null ? void 0 : w.map((h) => h.id)) || []).map((h) => o.getAnnotation(h)).filter(Boolean);
|
|
1080
1077
|
return n ? l.map(n.serialize) : l;
|
|
1081
|
-
}, c = (w) => fetch(w).then((l) => l.json()).then((l) => (
|
|
1078
|
+
}, c = (w) => fetch(w).then((l) => l.json()).then((l) => (g(l), l)), b = (w) => {
|
|
1082
1079
|
if (typeof w == "string") {
|
|
1083
1080
|
const l = o.getAnnotation(w);
|
|
1084
1081
|
if (o.deleteAnnotation(w), l)
|
|
@@ -1088,18 +1085,18 @@ const ke = 250, Pe = (t) => {
|
|
|
1088
1085
|
if (l)
|
|
1089
1086
|
return o.deleteAnnotation(l), w;
|
|
1090
1087
|
}
|
|
1091
|
-
},
|
|
1088
|
+
}, g = (w) => {
|
|
1092
1089
|
if (n) {
|
|
1093
|
-
const { parsed: l, failed:
|
|
1094
|
-
|
|
1090
|
+
const { parsed: l, failed: h } = $e(n)(w);
|
|
1091
|
+
h.length > 0 && console.warn(`Discarded ${h.length} invalid annotations`, h), o.bulkAddAnnotation(l, !0, N.REMOTE);
|
|
1095
1092
|
} else
|
|
1096
1093
|
o.bulkAddAnnotation(w, !0, N.REMOTE);
|
|
1097
|
-
},
|
|
1094
|
+
}, v = (w) => {
|
|
1098
1095
|
w ? i.setSelected(w) : i.clear();
|
|
1099
1096
|
}, C = (w) => {
|
|
1100
1097
|
if (n) {
|
|
1101
|
-
const l = n.parse(w).parsed,
|
|
1102
|
-
return o.updateAnnotation(l),
|
|
1098
|
+
const l = n.parse(w).parsed, h = n.serialize(o.getAnnotation(l.id));
|
|
1099
|
+
return o.updateAnnotation(l), h;
|
|
1103
1100
|
} else {
|
|
1104
1101
|
const l = o.getAnnotation(w.id);
|
|
1105
1102
|
return o.updateAnnotation(w), l;
|
|
@@ -1111,31 +1108,31 @@ const ke = 250, Pe = (t) => {
|
|
|
1111
1108
|
canRedo: e.canRedo,
|
|
1112
1109
|
canUndo: e.canUndo,
|
|
1113
1110
|
clearAnnotations: a,
|
|
1114
|
-
getAnnotationById:
|
|
1115
|
-
getAnnotations:
|
|
1116
|
-
getSelected:
|
|
1111
|
+
getAnnotationById: d,
|
|
1112
|
+
getAnnotations: u,
|
|
1113
|
+
getSelected: y,
|
|
1117
1114
|
loadAnnotations: c,
|
|
1118
1115
|
redo: e.redo,
|
|
1119
|
-
removeAnnotation:
|
|
1120
|
-
setAnnotations:
|
|
1121
|
-
setSelected:
|
|
1116
|
+
removeAnnotation: b,
|
|
1117
|
+
setAnnotations: g,
|
|
1118
|
+
setSelected: v,
|
|
1122
1119
|
undo: e.undo,
|
|
1123
1120
|
updateAnnotation: C
|
|
1124
1121
|
};
|
|
1125
1122
|
};
|
|
1126
|
-
let
|
|
1123
|
+
let ze = (t) => crypto.getRandomValues(new Uint8Array(t)), We = (t, e, n) => {
|
|
1127
1124
|
let o = (2 << Math.log(t.length - 1) / Math.LN2) - 1, i = -~(1.6 * o * e / t.length);
|
|
1128
1125
|
return (s = e) => {
|
|
1129
1126
|
let r = "";
|
|
1130
1127
|
for (; ; ) {
|
|
1131
|
-
let a = n(i),
|
|
1132
|
-
for (;
|
|
1133
|
-
if (r += t[a[
|
|
1128
|
+
let a = n(i), d = i;
|
|
1129
|
+
for (; d--; )
|
|
1130
|
+
if (r += t[a[d] & o] || "", r.length === s)
|
|
1134
1131
|
return r;
|
|
1135
1132
|
}
|
|
1136
1133
|
};
|
|
1137
|
-
},
|
|
1138
|
-
const
|
|
1134
|
+
}, qe = (t, e = 21) => We(t, e, ze), je = (t = 21) => crypto.getRandomValues(new Uint8Array(t)).reduce((e, n) => (n &= 63, n < 36 ? e += n.toString(36) : n < 62 ? e += (n - 26).toString(36).toUpperCase() : n > 62 ? e += "-" : e += "_", e), "");
|
|
1135
|
+
const Ke = () => ({ isGuest: !0, id: qe("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_", 20)() }), Qe = (t) => {
|
|
1139
1136
|
const e = JSON.stringify(t);
|
|
1140
1137
|
let n = 0;
|
|
1141
1138
|
for (let o = 0, i = e.length; o < i; o++) {
|
|
@@ -1143,100 +1140,100 @@ const Qe = () => ({ isGuest: !0, id: je("1234567890abcdefghijklmnopqrstuvwxyzABC
|
|
|
1143
1140
|
n = (n << 5) - n + s, n |= 0;
|
|
1144
1141
|
}
|
|
1145
1142
|
return `${n}`;
|
|
1146
|
-
}, Ht = (t) => t ? typeof t == "object" ? { ...t } : t : void 0,
|
|
1147
|
-
const { id: o, type: i, purpose: s, value: r, created: a, creator:
|
|
1143
|
+
}, Ht = (t) => t ? typeof t == "object" ? { ...t } : t : void 0, Ge = (t, e) => (Array.isArray(t) ? t : [t]).map((n) => {
|
|
1144
|
+
const { id: o, type: i, purpose: s, value: r, created: a, creator: d, ...u } = n;
|
|
1148
1145
|
return {
|
|
1149
|
-
id: o || `temp-${
|
|
1146
|
+
id: o || `temp-${Qe(n)}`,
|
|
1150
1147
|
annotation: e,
|
|
1151
1148
|
type: i,
|
|
1152
1149
|
purpose: s,
|
|
1153
1150
|
value: r,
|
|
1154
1151
|
created: a ? new Date(a) : void 0,
|
|
1155
|
-
creator: Ht(
|
|
1156
|
-
...
|
|
1152
|
+
creator: Ht(d),
|
|
1153
|
+
...u
|
|
1157
1154
|
};
|
|
1158
|
-
}),
|
|
1155
|
+
}), Je = (t) => t.map((e) => {
|
|
1159
1156
|
var n, o;
|
|
1160
1157
|
const i = { ...e };
|
|
1161
1158
|
return delete i.annotation, (n = i.id) != null && n.startsWith("temp-") && delete i.id, { ...i, created: (o = i.created) == null ? void 0 : o.toISOString() };
|
|
1162
1159
|
});
|
|
1163
|
-
|
|
1164
|
-
const
|
|
1165
|
-
parse: (n) =>
|
|
1166
|
-
serialize: (n) =>
|
|
1167
|
-
}),
|
|
1160
|
+
je();
|
|
1161
|
+
const vn = (t, e) => ({
|
|
1162
|
+
parse: (n) => en(n),
|
|
1163
|
+
serialize: (n) => nn(n, t, e)
|
|
1164
|
+
}), Ze = (t) => t.quote !== void 0 && t.start !== void 0 && t.end !== void 0, tn = (t, e) => {
|
|
1168
1165
|
const {
|
|
1169
1166
|
id: n,
|
|
1170
1167
|
creator: o,
|
|
1171
1168
|
created: i,
|
|
1172
1169
|
modified: s,
|
|
1173
1170
|
target: r
|
|
1174
|
-
} = t, a = Array.isArray(r) ? r : [r],
|
|
1171
|
+
} = t, a = Array.isArray(r) ? r : [r], d = {
|
|
1175
1172
|
creator: Ht(o),
|
|
1176
1173
|
created: i ? new Date(i) : void 0,
|
|
1177
1174
|
updated: s ? new Date(s) : void 0,
|
|
1178
1175
|
annotation: n,
|
|
1179
1176
|
selector: []
|
|
1180
1177
|
};
|
|
1181
|
-
for (const
|
|
1182
|
-
const c = (Array.isArray(
|
|
1183
|
-
switch (
|
|
1178
|
+
for (const u of a) {
|
|
1179
|
+
const c = (Array.isArray(u.selector) ? u.selector : [u.selector]).reduce((b, g) => {
|
|
1180
|
+
switch (g.type) {
|
|
1184
1181
|
case "TextQuoteSelector":
|
|
1185
|
-
|
|
1182
|
+
b.quote = g.exact;
|
|
1186
1183
|
break;
|
|
1187
1184
|
case "TextPositionSelector":
|
|
1188
|
-
|
|
1185
|
+
b.start = g.start, b.end = g.end;
|
|
1189
1186
|
break;
|
|
1190
1187
|
}
|
|
1191
|
-
return
|
|
1188
|
+
return b;
|
|
1192
1189
|
}, {});
|
|
1193
|
-
if (
|
|
1194
|
-
|
|
1190
|
+
if (Ze(c))
|
|
1191
|
+
d.selector.push(c);
|
|
1195
1192
|
else {
|
|
1196
|
-
const
|
|
1193
|
+
const b = [
|
|
1197
1194
|
c.start ? void 0 : "TextPositionSelector",
|
|
1198
1195
|
c.quote ? void 0 : "TextQuoteSelector"
|
|
1199
1196
|
].filter(Boolean);
|
|
1200
|
-
return { error: Error(`Missing selector types: ${
|
|
1197
|
+
return { error: Error(`Missing selector types: ${b.join(" and ")} for annotation: ${t.id}`) };
|
|
1201
1198
|
}
|
|
1202
1199
|
}
|
|
1203
|
-
return { parsed:
|
|
1204
|
-
},
|
|
1200
|
+
return { parsed: d };
|
|
1201
|
+
}, en = (t, e) => {
|
|
1205
1202
|
const n = t.id || kt(), {
|
|
1206
1203
|
creator: o,
|
|
1207
1204
|
created: i,
|
|
1208
1205
|
modified: s,
|
|
1209
1206
|
body: r,
|
|
1210
1207
|
...a
|
|
1211
|
-
} = t,
|
|
1212
|
-
return "error" in
|
|
1208
|
+
} = t, d = Ge(r, n), u = tn(t);
|
|
1209
|
+
return "error" in u ? { error: u.error } : {
|
|
1213
1210
|
parsed: {
|
|
1214
1211
|
...a,
|
|
1215
1212
|
id: n,
|
|
1216
|
-
bodies:
|
|
1217
|
-
target:
|
|
1213
|
+
bodies: d,
|
|
1214
|
+
target: u.parsed
|
|
1218
1215
|
}
|
|
1219
1216
|
};
|
|
1220
|
-
},
|
|
1217
|
+
}, nn = (t, e, n) => {
|
|
1221
1218
|
const { bodies: o, target: i, ...s } = t, {
|
|
1222
1219
|
selector: r,
|
|
1223
1220
|
creator: a,
|
|
1224
|
-
created:
|
|
1225
|
-
updated:
|
|
1226
|
-
...
|
|
1227
|
-
} = i, c = r.map((
|
|
1228
|
-
const { quote:
|
|
1221
|
+
created: d,
|
|
1222
|
+
updated: u,
|
|
1223
|
+
...y
|
|
1224
|
+
} = i, c = r.map((b) => {
|
|
1225
|
+
const { quote: g, start: v, end: C, range: w } = b, { prefix: l, suffix: h } = te(w, n);
|
|
1229
1226
|
return {
|
|
1230
|
-
...
|
|
1227
|
+
...y,
|
|
1231
1228
|
source: e,
|
|
1232
1229
|
selector: [{
|
|
1233
1230
|
type: "TextQuoteSelector",
|
|
1234
|
-
exact:
|
|
1231
|
+
exact: g,
|
|
1235
1232
|
prefix: l,
|
|
1236
|
-
suffix:
|
|
1233
|
+
suffix: h
|
|
1237
1234
|
}, {
|
|
1238
1235
|
type: "TextPositionSelector",
|
|
1239
|
-
start:
|
|
1236
|
+
start: v,
|
|
1240
1237
|
end: C
|
|
1241
1238
|
}]
|
|
1242
1239
|
};
|
|
@@ -1246,40 +1243,40 @@ const yn = (t, e) => ({
|
|
|
1246
1243
|
"@context": "http://www.w3.org/ns/anno.jsonld",
|
|
1247
1244
|
id: t.id,
|
|
1248
1245
|
type: "Annotation",
|
|
1249
|
-
body:
|
|
1246
|
+
body: Je(t.bodies),
|
|
1250
1247
|
creator: a,
|
|
1251
|
-
created:
|
|
1252
|
-
modified:
|
|
1248
|
+
created: d == null ? void 0 : d.toISOString(),
|
|
1249
|
+
modified: u == null ? void 0 : u.toISOString(),
|
|
1253
1250
|
target: c
|
|
1254
1251
|
};
|
|
1255
1252
|
};
|
|
1256
|
-
function
|
|
1257
|
-
$t(t, e, n || 0, o || t.length - 1, i ||
|
|
1253
|
+
function on(t, e, n, o, i) {
|
|
1254
|
+
$t(t, e, n || 0, o || t.length - 1, i || sn);
|
|
1258
1255
|
}
|
|
1259
1256
|
function $t(t, e, n, o, i) {
|
|
1260
1257
|
for (; o > n; ) {
|
|
1261
1258
|
if (o - n > 600) {
|
|
1262
|
-
var s = o - n + 1, r = e - n + 1, a = Math.log(s),
|
|
1263
|
-
$t(t, e,
|
|
1259
|
+
var s = o - n + 1, r = e - n + 1, a = Math.log(s), d = 0.5 * Math.exp(2 * a / 3), u = 0.5 * Math.sqrt(a * d * (s - d) / s) * (r - s / 2 < 0 ? -1 : 1), y = Math.max(n, Math.floor(e - r * d / s + u)), c = Math.min(o, Math.floor(e + (s - r) * d / s + u));
|
|
1260
|
+
$t(t, e, y, c, i);
|
|
1264
1261
|
}
|
|
1265
|
-
var
|
|
1266
|
-
for ($(t, n, e), i(t[o],
|
|
1267
|
-
for ($(t,
|
|
1268
|
-
|
|
1269
|
-
for (; i(t[
|
|
1270
|
-
|
|
1262
|
+
var b = t[e], g = n, v = o;
|
|
1263
|
+
for ($(t, n, e), i(t[o], b) > 0 && $(t, n, o); g < v; ) {
|
|
1264
|
+
for ($(t, g, v), g++, v--; i(t[g], b) < 0; )
|
|
1265
|
+
g++;
|
|
1266
|
+
for (; i(t[v], b) > 0; )
|
|
1267
|
+
v--;
|
|
1271
1268
|
}
|
|
1272
|
-
i(t[n],
|
|
1269
|
+
i(t[n], b) === 0 ? $(t, n, v) : (v++, $(t, v, o)), v <= e && (n = v + 1), e <= v && (o = v - 1);
|
|
1273
1270
|
}
|
|
1274
1271
|
}
|
|
1275
1272
|
function $(t, e, n) {
|
|
1276
1273
|
var o = t[e];
|
|
1277
1274
|
t[e] = t[n], t[n] = o;
|
|
1278
1275
|
}
|
|
1279
|
-
function
|
|
1276
|
+
function sn(t, e) {
|
|
1280
1277
|
return t < e ? -1 : t > e ? 1 : 0;
|
|
1281
1278
|
}
|
|
1282
|
-
class
|
|
1279
|
+
class rn {
|
|
1283
1280
|
constructor(e = 9) {
|
|
1284
1281
|
this._maxEntries = Math.max(4, e), this._minEntries = Math.max(2, Math.ceil(this._maxEntries * 0.4)), this.clear();
|
|
1285
1282
|
}
|
|
@@ -1294,8 +1291,8 @@ class an {
|
|
|
1294
1291
|
const i = this.toBBox, s = [];
|
|
1295
1292
|
for (; n; ) {
|
|
1296
1293
|
for (let r = 0; r < n.children.length; r++) {
|
|
1297
|
-
const a = n.children[r],
|
|
1298
|
-
G(e,
|
|
1294
|
+
const a = n.children[r], d = n.leaf ? i(a) : a;
|
|
1295
|
+
G(e, d) && (n.leaf ? o.push(a) : ut(e, d) ? this._all(a, o) : s.push(a));
|
|
1299
1296
|
}
|
|
1300
1297
|
n = s.pop();
|
|
1301
1298
|
}
|
|
@@ -1352,14 +1349,14 @@ class an {
|
|
|
1352
1349
|
return this;
|
|
1353
1350
|
let o = this.data;
|
|
1354
1351
|
const i = this.toBBox(e), s = [], r = [];
|
|
1355
|
-
let a,
|
|
1352
|
+
let a, d, u;
|
|
1356
1353
|
for (; o || s.length; ) {
|
|
1357
|
-
if (o || (o = s.pop(),
|
|
1358
|
-
const
|
|
1359
|
-
if (
|
|
1360
|
-
return o.children.splice(
|
|
1354
|
+
if (o || (o = s.pop(), d = s[s.length - 1], a = r.pop(), u = !0), o.leaf) {
|
|
1355
|
+
const y = an(e, o.children, n);
|
|
1356
|
+
if (y !== -1)
|
|
1357
|
+
return o.children.splice(y, 1), s.push(o), this._condense(s), this;
|
|
1361
1358
|
}
|
|
1362
|
-
!
|
|
1359
|
+
!u && !o.leaf && ut(o, i) ? (s.push(o), r.push(a), a = 0, d = o, o = o.children[0]) : d ? (a++, o = d.children[a], u = !1) : o = null;
|
|
1363
1360
|
}
|
|
1364
1361
|
return this;
|
|
1365
1362
|
}
|
|
@@ -1390,14 +1387,14 @@ class an {
|
|
|
1390
1387
|
if (s <= r)
|
|
1391
1388
|
return a = H(e.slice(n, o + 1)), P(a, this.toBBox), a;
|
|
1392
1389
|
i || (i = Math.ceil(Math.log(s) / Math.log(r)), r = Math.ceil(s / Math.pow(r, i - 1))), a = H([]), a.leaf = !1, a.height = i;
|
|
1393
|
-
const
|
|
1394
|
-
Mt(e, n, o,
|
|
1395
|
-
for (let
|
|
1396
|
-
const c = Math.min(
|
|
1397
|
-
Mt(e,
|
|
1398
|
-
for (let
|
|
1399
|
-
const
|
|
1400
|
-
a.children.push(this._build(e,
|
|
1390
|
+
const d = Math.ceil(s / r), u = d * Math.ceil(Math.sqrt(r));
|
|
1391
|
+
Mt(e, n, o, u, this.compareMinX);
|
|
1392
|
+
for (let y = n; y <= o; y += u) {
|
|
1393
|
+
const c = Math.min(y + u - 1, o);
|
|
1394
|
+
Mt(e, y, c, d, this.compareMinY);
|
|
1395
|
+
for (let b = y; b <= c; b += d) {
|
|
1396
|
+
const g = Math.min(b + d - 1, c);
|
|
1397
|
+
a.children.push(this._build(e, b, g, i - 1));
|
|
1401
1398
|
}
|
|
1402
1399
|
}
|
|
1403
1400
|
return P(a, this.toBBox), a;
|
|
@@ -1405,9 +1402,9 @@ class an {
|
|
|
1405
1402
|
_chooseSubtree(e, n, o, i) {
|
|
1406
1403
|
for (; i.push(n), !(n.leaf || i.length - 1 === o); ) {
|
|
1407
1404
|
let s = 1 / 0, r = 1 / 0, a;
|
|
1408
|
-
for (let
|
|
1409
|
-
const
|
|
1410
|
-
c < r ? (r = c, s =
|
|
1405
|
+
for (let d = 0; d < n.children.length; d++) {
|
|
1406
|
+
const u = n.children[d], y = dt(u), c = dn(e, u) - y;
|
|
1407
|
+
c < r ? (r = c, s = y < s ? y : s, a = u) : c === r && y < s && (s = y, a = u);
|
|
1411
1408
|
}
|
|
1412
1409
|
n = a || n.children[0];
|
|
1413
1410
|
}
|
|
@@ -1432,30 +1429,30 @@ class an {
|
|
|
1432
1429
|
_chooseSplitIndex(e, n, o) {
|
|
1433
1430
|
let i, s = 1 / 0, r = 1 / 0;
|
|
1434
1431
|
for (let a = n; a <= o - n; a++) {
|
|
1435
|
-
const
|
|
1436
|
-
|
|
1432
|
+
const d = F(e, 0, a, this.toBBox), u = F(e, a, o, this.toBBox), y = un(d, u), c = dt(d) + dt(u);
|
|
1433
|
+
y < s ? (s = y, i = a, r = c < r ? c : r) : y === s && c < r && (r = c, i = a);
|
|
1437
1434
|
}
|
|
1438
1435
|
return i || o - n;
|
|
1439
1436
|
}
|
|
1440
1437
|
// sorts node children by the best axis for split
|
|
1441
1438
|
_chooseSplitAxis(e, n, o) {
|
|
1442
|
-
const i = e.leaf ? this.compareMinX :
|
|
1439
|
+
const i = e.leaf ? this.compareMinX : cn, s = e.leaf ? this.compareMinY : ln, r = this._allDistMargin(e, n, o, i), a = this._allDistMargin(e, n, o, s);
|
|
1443
1440
|
r < a && e.children.sort(i);
|
|
1444
1441
|
}
|
|
1445
1442
|
// total margin of all possible split distributions where each node is at least m full
|
|
1446
1443
|
_allDistMargin(e, n, o, i) {
|
|
1447
1444
|
e.children.sort(i);
|
|
1448
1445
|
const s = this.toBBox, r = F(e, 0, n, s), a = F(e, o - n, o, s);
|
|
1449
|
-
let
|
|
1450
|
-
for (let
|
|
1451
|
-
const
|
|
1452
|
-
z(r, e.leaf ? s(
|
|
1446
|
+
let d = Q(r) + Q(a);
|
|
1447
|
+
for (let u = n; u < o - n; u++) {
|
|
1448
|
+
const y = e.children[u];
|
|
1449
|
+
z(r, e.leaf ? s(y) : y), d += Q(r);
|
|
1453
1450
|
}
|
|
1454
|
-
for (let
|
|
1455
|
-
const
|
|
1456
|
-
z(a, e.leaf ? s(
|
|
1451
|
+
for (let u = o - n - 1; u >= n; u--) {
|
|
1452
|
+
const y = e.children[u];
|
|
1453
|
+
z(a, e.leaf ? s(y) : y), d += Q(a);
|
|
1457
1454
|
}
|
|
1458
|
-
return
|
|
1455
|
+
return d;
|
|
1459
1456
|
}
|
|
1460
1457
|
_adjustParentBBoxes(e, n, o) {
|
|
1461
1458
|
for (let i = o; i >= 0; i--)
|
|
@@ -1466,7 +1463,7 @@ class an {
|
|
|
1466
1463
|
e[n].children.length === 0 ? n > 0 ? (o = e[n - 1].children, o.splice(o.indexOf(e[n]), 1)) : this.clear() : P(e[n], this.toBBox);
|
|
1467
1464
|
}
|
|
1468
1465
|
}
|
|
1469
|
-
function
|
|
1466
|
+
function an(t, e, n) {
|
|
1470
1467
|
if (!n)
|
|
1471
1468
|
return e.indexOf(t);
|
|
1472
1469
|
for (let o = 0; o < e.length; o++)
|
|
@@ -1488,10 +1485,10 @@ function F(t, e, n, o, i) {
|
|
|
1488
1485
|
function z(t, e) {
|
|
1489
1486
|
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;
|
|
1490
1487
|
}
|
|
1491
|
-
function
|
|
1488
|
+
function cn(t, e) {
|
|
1492
1489
|
return t.minX - e.minX;
|
|
1493
1490
|
}
|
|
1494
|
-
function
|
|
1491
|
+
function ln(t, e) {
|
|
1495
1492
|
return t.minY - e.minY;
|
|
1496
1493
|
}
|
|
1497
1494
|
function dt(t) {
|
|
@@ -1500,10 +1497,10 @@ function dt(t) {
|
|
|
1500
1497
|
function Q(t) {
|
|
1501
1498
|
return t.maxX - t.minX + (t.maxY - t.minY);
|
|
1502
1499
|
}
|
|
1503
|
-
function
|
|
1500
|
+
function dn(t, e) {
|
|
1504
1501
|
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));
|
|
1505
1502
|
}
|
|
1506
|
-
function
|
|
1503
|
+
function un(t, e) {
|
|
1507
1504
|
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);
|
|
1508
1505
|
return Math.max(0, i - n) * Math.max(0, s - o);
|
|
1509
1506
|
}
|
|
@@ -1530,22 +1527,22 @@ function Mt(t, e, n, o, i) {
|
|
|
1530
1527
|
if (n = s.pop(), e = s.pop(), n - e <= o)
|
|
1531
1528
|
continue;
|
|
1532
1529
|
const r = e + Math.ceil((n - e) / o / 2) * o;
|
|
1533
|
-
|
|
1530
|
+
on(t, r, e, n, i), s.push(e, r, r, n);
|
|
1534
1531
|
}
|
|
1535
1532
|
}
|
|
1536
|
-
const
|
|
1537
|
-
const n = new
|
|
1538
|
-
const
|
|
1533
|
+
const hn = (t, e) => {
|
|
1534
|
+
const n = new rn(), o = /* @__PURE__ */ new Map(), i = (l) => {
|
|
1535
|
+
const h = e.getBoundingClientRect(), m = l.selector.flatMap((E) => {
|
|
1539
1536
|
const R = E.range instanceof Range && !E.range.collapsed && E.range.startContainer.nodeType === Node.TEXT_NODE && E.range.endContainer.nodeType === Node.TEXT_NODE ? E.range : _t(E, e).range;
|
|
1540
1537
|
return Array.from(R.getClientRects());
|
|
1541
1538
|
}), f = oe(m);
|
|
1542
1539
|
return f.map((E) => {
|
|
1543
|
-
const { x: T, y: R, width:
|
|
1540
|
+
const { x: T, y: R, width: p, height: A } = E;
|
|
1544
1541
|
return {
|
|
1545
|
-
minX: T -
|
|
1546
|
-
minY: R -
|
|
1547
|
-
maxX: T -
|
|
1548
|
-
maxY: R -
|
|
1542
|
+
minX: T - h.x,
|
|
1543
|
+
minY: R - h.y,
|
|
1544
|
+
maxX: T - h.x + p,
|
|
1545
|
+
maxY: R - h.y + A,
|
|
1549
1546
|
annotation: {
|
|
1550
1547
|
id: l.annotation,
|
|
1551
1548
|
rects: f
|
|
@@ -1555,106 +1552,106 @@ const fn = (t, e) => {
|
|
|
1555
1552
|
}, s = () => [...o.values()], r = () => {
|
|
1556
1553
|
n.clear(), o.clear();
|
|
1557
1554
|
}, a = (l) => {
|
|
1558
|
-
const
|
|
1559
|
-
|
|
1560
|
-
}, h = (l) => {
|
|
1561
|
-
o.get(l.annotation).forEach((m) => n.remove(m)), o.delete(l.annotation);
|
|
1555
|
+
const h = i(l);
|
|
1556
|
+
h.forEach((m) => n.insert(m)), o.set(l.annotation, h);
|
|
1562
1557
|
}, d = (l) => {
|
|
1563
|
-
|
|
1564
|
-
},
|
|
1565
|
-
|
|
1558
|
+
o.get(l.annotation).forEach((m) => n.remove(m)), o.delete(l.annotation);
|
|
1559
|
+
}, u = (l) => {
|
|
1560
|
+
d(l), a(l);
|
|
1561
|
+
}, y = (l, h = !0) => {
|
|
1562
|
+
h && r();
|
|
1566
1563
|
const m = l.map((E) => ({ target: E, rects: i(E) }));
|
|
1567
1564
|
m.forEach(({ target: E, rects: T }) => o.set(E.annotation, T));
|
|
1568
1565
|
const f = m.reduce((E, { rects: T }) => [...E, ...T], []);
|
|
1569
1566
|
n.load(f);
|
|
1570
|
-
}, c = (l,
|
|
1567
|
+
}, c = (l, h) => {
|
|
1571
1568
|
const m = n.search({
|
|
1572
1569
|
minX: l,
|
|
1573
|
-
minY:
|
|
1570
|
+
minY: h,
|
|
1574
1571
|
maxX: l,
|
|
1575
|
-
maxY:
|
|
1572
|
+
maxY: h
|
|
1576
1573
|
}), f = (E) => E.annotation.rects.reduce((T, R) => T + R.width * R.height, 0);
|
|
1577
1574
|
if (m.length > 0)
|
|
1578
1575
|
return m.sort((E, T) => f(E) - f(T)), m[0].annotation.id;
|
|
1579
|
-
},
|
|
1580
|
-
const
|
|
1581
|
-
if (
|
|
1576
|
+
}, b = (l) => {
|
|
1577
|
+
const h = g(l);
|
|
1578
|
+
if (h.length === 0)
|
|
1582
1579
|
return;
|
|
1583
|
-
let m =
|
|
1584
|
-
for (let R = 1; R <
|
|
1585
|
-
const
|
|
1586
|
-
m = Math.min(m,
|
|
1580
|
+
let m = h[0].left, f = h[0].top, E = h[0].right, T = h[0].bottom;
|
|
1581
|
+
for (let R = 1; R < h.length; R++) {
|
|
1582
|
+
const p = h[R];
|
|
1583
|
+
m = Math.min(m, p.left), f = Math.min(f, p.top), E = Math.max(E, p.right), T = Math.max(T, p.bottom);
|
|
1587
1584
|
}
|
|
1588
1585
|
return new DOMRect(m, f, E - m, T - f);
|
|
1589
|
-
},
|
|
1590
|
-
const
|
|
1591
|
-
return
|
|
1586
|
+
}, g = (l) => {
|
|
1587
|
+
const h = o.get(l);
|
|
1588
|
+
return h ? h[0].annotation.rects : [];
|
|
1592
1589
|
};
|
|
1593
1590
|
return {
|
|
1594
1591
|
all: s,
|
|
1595
1592
|
clear: r,
|
|
1596
1593
|
getAt: c,
|
|
1597
|
-
getBoundsForAnnotation:
|
|
1598
|
-
getDOMRectsForAnnotation:
|
|
1599
|
-
getIntersectingRects: (l,
|
|
1594
|
+
getBoundsForAnnotation: b,
|
|
1595
|
+
getDOMRectsForAnnotation: g,
|
|
1596
|
+
getIntersectingRects: (l, h, m, f) => n.search({ minX: l, minY: h, maxX: m, maxY: f }),
|
|
1600
1597
|
insert: a,
|
|
1601
|
-
recalculate: () =>
|
|
1602
|
-
remove:
|
|
1603
|
-
set:
|
|
1598
|
+
recalculate: () => y(t.all().map((l) => l.target), !0),
|
|
1599
|
+
remove: d,
|
|
1600
|
+
set: y,
|
|
1604
1601
|
size: () => n.all().length,
|
|
1605
|
-
update:
|
|
1602
|
+
update: u
|
|
1606
1603
|
};
|
|
1607
|
-
},
|
|
1608
|
-
const n =
|
|
1609
|
-
const
|
|
1610
|
-
return m && n.addAnnotation(
|
|
1611
|
-
},
|
|
1604
|
+
}, fn = (t, e) => {
|
|
1605
|
+
const n = Ye(), o = hn(n, t), i = Re(n, e), s = Te(n), r = Pe(), a = (w, l = N.LOCAL) => {
|
|
1606
|
+
const h = wt(w, t), m = U(h.target.selector);
|
|
1607
|
+
return m && n.addAnnotation(h, l), m;
|
|
1608
|
+
}, d = (w, l = !0, h = N.LOCAL) => {
|
|
1612
1609
|
const m = w.map((E) => wt(E, t)), f = m.filter((E) => !U(E.target.selector));
|
|
1613
|
-
return f.length > 0 ? (console.warn("Could not revive all targets for these annotations:", f), n.bulkAddAnnotation(m, l,
|
|
1614
|
-
},
|
|
1615
|
-
const
|
|
1616
|
-
n.updateTarget(
|
|
1617
|
-
},
|
|
1618
|
-
const
|
|
1619
|
-
n.bulkUpdateTargets(
|
|
1610
|
+
return f.length > 0 ? (console.warn("Could not revive all targets for these annotations:", f), n.bulkAddAnnotation(m, l, h), f) : (n.bulkAddAnnotation(m, l, h), []);
|
|
1611
|
+
}, u = (w, l = N.LOCAL) => {
|
|
1612
|
+
const h = J(w, t);
|
|
1613
|
+
n.updateTarget(h, l);
|
|
1614
|
+
}, y = (w, l = N.LOCAL) => {
|
|
1615
|
+
const h = w.map((m) => J(m, t));
|
|
1616
|
+
n.bulkUpdateTargets(h, l);
|
|
1620
1617
|
}, c = (w, l) => {
|
|
1621
|
-
const
|
|
1622
|
-
return
|
|
1623
|
-
},
|
|
1624
|
-
const f = o.getIntersectingRects(w, l,
|
|
1618
|
+
const h = o.getAt(w, l);
|
|
1619
|
+
return h ? n.getAnnotation(h) : void 0;
|
|
1620
|
+
}, b = (w, l, h, m) => {
|
|
1621
|
+
const f = o.getIntersectingRects(w, l, h, m);
|
|
1625
1622
|
return Array.from(new Set(f.map((T) => T.annotation.id))).map((T) => n.getAnnotation(T)).filter(Boolean);
|
|
1626
|
-
},
|
|
1623
|
+
}, g = (w, l, h, m = 5) => {
|
|
1627
1624
|
const f = o.getDOMRectsForAnnotation(w);
|
|
1628
1625
|
if (f.length !== 0) {
|
|
1629
|
-
if (l &&
|
|
1630
|
-
const E = f.find(({ top: T, right: R, bottom:
|
|
1626
|
+
if (l && h) {
|
|
1627
|
+
const E = f.find(({ top: T, right: R, bottom: p, left: A }) => l >= A - m && l <= R + m && h >= T - m && h <= p + m);
|
|
1631
1628
|
if (E)
|
|
1632
1629
|
return E;
|
|
1633
1630
|
}
|
|
1634
1631
|
return o.getBoundsForAnnotation(w);
|
|
1635
1632
|
}
|
|
1636
|
-
},
|
|
1637
|
-
const E = o.getIntersectingRects(w, l,
|
|
1633
|
+
}, v = (w, l, h, m) => {
|
|
1634
|
+
const E = o.getIntersectingRects(w, l, h, m).reduce((T, R) => ((T[R.annotation.id] = T[R.annotation.id] || []).push(R), T), {});
|
|
1638
1635
|
return Object.entries(E).map(([T, R]) => ({
|
|
1639
1636
|
annotation: n.getAnnotation(T),
|
|
1640
|
-
rects: R.map(({ minX:
|
|
1637
|
+
rects: R.map(({ minX: p, minY: A, maxX: x, maxY: S }) => ({ x: p, y: A, width: x - p, height: S - A }))
|
|
1641
1638
|
}));
|
|
1642
1639
|
}, C = () => o.recalculate();
|
|
1643
1640
|
return n.observe(({ changes: w }) => {
|
|
1644
|
-
const l = (w.created || []).filter((f) => U(f.target.selector)),
|
|
1645
|
-
l.length > 0 && o.set(l.map((f) => f.target), !1), (
|
|
1641
|
+
const l = (w.created || []).filter((f) => U(f.target.selector)), h = (w.deleted || []).filter((f) => U(f.target.selector)), m = (w.updated || []).filter((f) => U(f.newValue.target.selector));
|
|
1642
|
+
l.length > 0 && o.set(l.map((f) => f.target), !1), (h == null ? void 0 : h.length) > 0 && h.forEach((f) => o.remove(f.target)), (m == null ? void 0 : m.length) > 0 && m.forEach(({ newValue: f }) => o.update(f.target));
|
|
1646
1643
|
}), {
|
|
1647
1644
|
store: {
|
|
1648
1645
|
...n,
|
|
1649
1646
|
addAnnotation: a,
|
|
1650
|
-
bulkAddAnnotation:
|
|
1651
|
-
bulkUpdateTargets:
|
|
1652
|
-
getAnnotationBounds:
|
|
1647
|
+
bulkAddAnnotation: d,
|
|
1648
|
+
bulkUpdateTargets: y,
|
|
1649
|
+
getAnnotationBounds: g,
|
|
1653
1650
|
getAt: c,
|
|
1654
|
-
getIntersecting:
|
|
1655
|
-
getIntersectingRects:
|
|
1651
|
+
getIntersecting: b,
|
|
1652
|
+
getIntersectingRects: v,
|
|
1656
1653
|
recalculatePositions: C,
|
|
1657
|
-
updateTarget:
|
|
1654
|
+
updateTarget: u
|
|
1658
1655
|
},
|
|
1659
1656
|
selection: i,
|
|
1660
1657
|
hover: s,
|
|
@@ -1665,9 +1662,9 @@ const fn = (t, e) => {
|
|
|
1665
1662
|
return document.scrollingElement;
|
|
1666
1663
|
const { overflowY: e } = window.getComputedStyle(t);
|
|
1667
1664
|
return e !== "visible" && e !== "hidden" && t.scrollHeight > t.clientHeight ? t : Ft(t.parentElement);
|
|
1668
|
-
},
|
|
1665
|
+
}, gn = (t, e) => (n) => {
|
|
1669
1666
|
const o = (s) => {
|
|
1670
|
-
const r = i.getBoundingClientRect(), a = i.clientHeight,
|
|
1667
|
+
const r = i.getBoundingClientRect(), a = i.clientHeight, d = i.clientWidth, u = s.selector[0].range.getBoundingClientRect(), { width: y, height: c } = e.getAnnotationBounds(n.id), b = u.top - r.top, g = u.left - r.left, v = i.parentElement ? i.scrollTop : 0, C = i.parentElement ? i.scrollLeft : 0, w = b + v - (a - c) / 2, l = g + C - (d - y) / 2;
|
|
1671
1668
|
i.scroll({ top: w, left: l, behavior: "smooth" });
|
|
1672
1669
|
}, i = Ft(t);
|
|
1673
1670
|
if (i) {
|
|
@@ -1675,20 +1672,20 @@ const fn = (t, e) => {
|
|
|
1675
1672
|
if (r && !r.collapsed)
|
|
1676
1673
|
return o(s.target), !0;
|
|
1677
1674
|
{
|
|
1678
|
-
const a = J(s.target, t), { range:
|
|
1679
|
-
if (
|
|
1675
|
+
const a = J(s.target, t), { range: d } = a.selector[0];
|
|
1676
|
+
if (d && !d.collapsed)
|
|
1680
1677
|
return o(a), !0;
|
|
1681
1678
|
}
|
|
1682
1679
|
}
|
|
1683
1680
|
return !1;
|
|
1684
|
-
},
|
|
1681
|
+
}, pn = (t, e, n) => {
|
|
1685
1682
|
const { store: o, selection: i } = e;
|
|
1686
1683
|
let s, r;
|
|
1687
1684
|
const a = (C) => s = C;
|
|
1688
|
-
let
|
|
1689
|
-
const
|
|
1685
|
+
let d = !1, u;
|
|
1686
|
+
const y = (C) => {
|
|
1690
1687
|
var l;
|
|
1691
|
-
if (!
|
|
1688
|
+
if (!d)
|
|
1692
1689
|
return;
|
|
1693
1690
|
!((l = C.target.parentElement) != null && l.closest(".not-annotatable")) ? r = {
|
|
1694
1691
|
annotation: kt(),
|
|
@@ -1697,12 +1694,12 @@ const fn = (t, e) => {
|
|
|
1697
1694
|
created: /* @__PURE__ */ new Date()
|
|
1698
1695
|
} : r = void 0;
|
|
1699
1696
|
};
|
|
1700
|
-
t.addEventListener("selectstart",
|
|
1697
|
+
t.addEventListener("selectstart", y);
|
|
1701
1698
|
const c = ft((C) => {
|
|
1702
1699
|
const w = document.getSelection();
|
|
1703
|
-
if (C.timeStamp -
|
|
1700
|
+
if (C.timeStamp - u.timeStamp < 1e3 && !r && y(u), w.isCollapsed || !d || !r)
|
|
1704
1701
|
return;
|
|
1705
|
-
const l = w.getRangeAt(0),
|
|
1702
|
+
const l = w.getRangeAt(0), h = se(l.cloneRange()), m = Gt(h);
|
|
1706
1703
|
(m.length !== r.selector.length || m.some((E, T) => {
|
|
1707
1704
|
var R;
|
|
1708
1705
|
return E.toString() !== ((R = r.selector[T]) == null ? void 0 : R.quote);
|
|
@@ -1713,17 +1710,17 @@ const fn = (t, e) => {
|
|
|
1713
1710
|
id: r.annotation,
|
|
1714
1711
|
bodies: [],
|
|
1715
1712
|
target: r
|
|
1716
|
-
}), i.clickSelect(r.annotation,
|
|
1713
|
+
}), i.clickSelect(r.annotation, u)));
|
|
1717
1714
|
});
|
|
1718
1715
|
document.addEventListener("selectionchange", c);
|
|
1719
|
-
const
|
|
1720
|
-
const { target: w, timeStamp: l, offsetX:
|
|
1721
|
-
|
|
1716
|
+
const b = (C) => {
|
|
1717
|
+
const { target: w, timeStamp: l, offsetX: h, offsetY: m, type: f } = C;
|
|
1718
|
+
u = { ...C, target: w, timeStamp: l, offsetX: h, offsetY: m, type: f }, d = C.button === 0;
|
|
1722
1719
|
};
|
|
1723
|
-
t.addEventListener("pointerdown",
|
|
1724
|
-
const
|
|
1720
|
+
t.addEventListener("pointerdown", b);
|
|
1721
|
+
const g = (C) => {
|
|
1725
1722
|
var m;
|
|
1726
|
-
if (!!((m = C.target.parentElement) != null && m.closest(".not-annotatable")) || !
|
|
1723
|
+
if (!!((m = C.target.parentElement) != null && m.closest(".not-annotatable")) || !d)
|
|
1727
1724
|
return;
|
|
1728
1725
|
const l = () => {
|
|
1729
1726
|
const { x: f, y: E } = t.getBoundingClientRect(), T = o.getAt(C.clientX - f, C.clientY - E);
|
|
@@ -1732,75 +1729,75 @@ const fn = (t, e) => {
|
|
|
1732
1729
|
(R.length !== 1 || R[0].id !== T.id) && i.clickSelect(T.id, C);
|
|
1733
1730
|
} else
|
|
1734
1731
|
i.isEmpty() || i.clear();
|
|
1735
|
-
},
|
|
1736
|
-
document.getSelection().isCollapsed &&
|
|
1732
|
+
}, h = C.timeStamp - u.timeStamp;
|
|
1733
|
+
document.getSelection().isCollapsed && h < 300 ? (r = void 0, l()) : r && i.clickSelect(r.annotation, C);
|
|
1737
1734
|
};
|
|
1738
|
-
return document.addEventListener("pointerup",
|
|
1735
|
+
return document.addEventListener("pointerup", g), {
|
|
1739
1736
|
destroy: () => {
|
|
1740
|
-
t.removeEventListener("selectstart",
|
|
1737
|
+
t.removeEventListener("selectstart", y), document.removeEventListener("selectionchange", c), t.removeEventListener("pointerdown", b), document.removeEventListener("pointerup", g);
|
|
1741
1738
|
},
|
|
1742
1739
|
setUser: a
|
|
1743
1740
|
};
|
|
1744
|
-
},
|
|
1741
|
+
}, yn = (t, e = {}) => {
|
|
1745
1742
|
t.addEventListener("click", (f) => f.target.nodeName !== "A" && f.preventDefault());
|
|
1746
|
-
const n =
|
|
1743
|
+
const n = fn(t, e.pointerAction), { selection: o, viewport: i } = n, s = n.store, r = ke(s), a = He(
|
|
1747
1744
|
n,
|
|
1748
1745
|
r,
|
|
1749
1746
|
e.adapter
|
|
1750
1747
|
);
|
|
1751
|
-
let
|
|
1752
|
-
const
|
|
1753
|
-
|
|
1754
|
-
const
|
|
1755
|
-
e.style &&
|
|
1756
|
-
const c =
|
|
1757
|
-
return c.setUser(
|
|
1758
|
-
...
|
|
1748
|
+
let d = Ke();
|
|
1749
|
+
const u = e.experimentalCSSRenderer && !!CSS.highlights;
|
|
1750
|
+
u && console.log("Using experimental CSS Custom Highlight API renderer");
|
|
1751
|
+
const y = u ? ve(t, n, i) : ce(t, n, i);
|
|
1752
|
+
e.style && y.setDrawingStyle(e.style);
|
|
1753
|
+
const c = pn(t, n, e.offsetReferenceSelector);
|
|
1754
|
+
return c.setUser(d), {
|
|
1755
|
+
...Fe(n, r, e.adapter),
|
|
1759
1756
|
destroy: () => {
|
|
1760
|
-
|
|
1757
|
+
y.destroy(), c.destroy(), r.destroy();
|
|
1761
1758
|
},
|
|
1762
1759
|
element: t,
|
|
1763
|
-
getUser: () =>
|
|
1764
|
-
setFilter: (f) =>
|
|
1765
|
-
setStyle: (f) =>
|
|
1760
|
+
getUser: () => d,
|
|
1761
|
+
setFilter: (f) => y.setFilter(f),
|
|
1762
|
+
setStyle: (f) => y.setDrawingStyle(f),
|
|
1766
1763
|
setUser: (f) => {
|
|
1767
|
-
|
|
1764
|
+
d = f, c.setUser(f);
|
|
1768
1765
|
},
|
|
1769
1766
|
setSelected: (f) => {
|
|
1770
1767
|
f ? o.setSelected(f) : o.clear();
|
|
1771
1768
|
},
|
|
1772
1769
|
setPresenceProvider: (f) => {
|
|
1773
|
-
f && (
|
|
1770
|
+
f && (y.setPainter(we(t, f, e.presence)), f.on("selectionChange", () => y.refresh()));
|
|
1774
1771
|
},
|
|
1775
1772
|
on: a.on,
|
|
1776
1773
|
off: a.off,
|
|
1777
|
-
scrollIntoView:
|
|
1774
|
+
scrollIntoView: gn(t, s),
|
|
1778
1775
|
state: n
|
|
1779
1776
|
};
|
|
1780
1777
|
};
|
|
1781
1778
|
export {
|
|
1782
1779
|
q as NOT_ANNTOTATABLE_SELECTOR,
|
|
1783
1780
|
N as Origin,
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1781
|
+
vn as W3CTextFormat,
|
|
1782
|
+
ve as createCSSHighlightRenderer,
|
|
1783
|
+
ce as createCanvasHighlightRenderer,
|
|
1784
|
+
we as createPresencePainter,
|
|
1785
|
+
yn as createTextAnnotator,
|
|
1786
|
+
fn as createTextAnnotatorState,
|
|
1790
1787
|
ft as debounce,
|
|
1791
|
-
|
|
1792
|
-
|
|
1788
|
+
mn as getAnnotatableFragment,
|
|
1789
|
+
bn as getClientRectsPonyfill,
|
|
1793
1790
|
te as getQuoteContext,
|
|
1794
1791
|
ht as getRangeAnnotatableContents,
|
|
1795
1792
|
U as isRevived,
|
|
1796
1793
|
oe as mergeClientRects,
|
|
1797
|
-
|
|
1794
|
+
en as parseW3CTextAnnotation,
|
|
1798
1795
|
ie as rangeToSelector,
|
|
1799
1796
|
wt as reviveAnnotation,
|
|
1800
1797
|
_t as reviveSelector,
|
|
1801
1798
|
J as reviveTarget,
|
|
1802
|
-
|
|
1799
|
+
nn as serializeW3CTextAnnotation,
|
|
1803
1800
|
Gt as splitAnnotatableRanges,
|
|
1804
|
-
|
|
1801
|
+
se as trimRange
|
|
1805
1802
|
};
|
|
1806
1803
|
//# sourceMappingURL=text-annotator.es.js.map
|