@recogito/text-annotator 3.0.0-rc.21 → 3.0.0-rc.22
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,37 +1,37 @@
|
|
|
1
|
-
const
|
|
1
|
+
const $ = {
|
|
2
2
|
fill: "rgb(0, 128, 255)",
|
|
3
3
|
fillOpacity: 0.18
|
|
4
|
-
},
|
|
4
|
+
}, ht = {
|
|
5
5
|
fill: "rgb(0, 128, 255)",
|
|
6
6
|
fillOpacity: 0.45
|
|
7
|
-
},
|
|
7
|
+
}, jt = (t, e, n, o, i) => {
|
|
8
8
|
var s;
|
|
9
|
-
const r = n ? typeof n == "function" ? n(t.annotation, t.state, i) : n : (s = t.state) != null && s.selected ?
|
|
9
|
+
const r = n ? typeof n == "function" ? n(t.annotation, t.state, i) : n : (s = t.state) != null && s.selected ? ht : $;
|
|
10
10
|
return o && o.paint(t, e) || r;
|
|
11
|
-
},
|
|
11
|
+
}, ft = (t, e = 10) => {
|
|
12
12
|
let n;
|
|
13
13
|
return (...o) => {
|
|
14
14
|
clearTimeout(n), n = setTimeout(() => t.apply(void 0, o), e);
|
|
15
15
|
};
|
|
16
|
-
},
|
|
16
|
+
}, It = "not-annotatable", Y = `.${It}`, Gt = (t) => {
|
|
17
17
|
var n;
|
|
18
18
|
const e = t.commonAncestorContainer;
|
|
19
19
|
return e instanceof HTMLElement ? !e.closest(Y) : !((n = e.parentElement) != null && n.closest(Y));
|
|
20
|
-
},
|
|
20
|
+
}, Kt = function* (t) {
|
|
21
21
|
const e = document.createNodeIterator(
|
|
22
22
|
t.commonAncestorContainer,
|
|
23
23
|
NodeFilter.SHOW_ELEMENT,
|
|
24
|
-
(o) => o instanceof HTMLElement && o.classList.contains(
|
|
24
|
+
(o) => o instanceof HTMLElement && o.classList.contains(It) && !o.parentElement.closest(Y) && t.intersectsNode(o) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP
|
|
25
25
|
);
|
|
26
26
|
let n;
|
|
27
27
|
for (; n = e.nextNode(); )
|
|
28
28
|
n instanceof HTMLElement && (yield n);
|
|
29
|
-
},
|
|
30
|
-
if (!
|
|
29
|
+
}, Qt = (t) => {
|
|
30
|
+
if (!Gt(t))
|
|
31
31
|
return [];
|
|
32
32
|
const e = [];
|
|
33
33
|
let n = null;
|
|
34
|
-
for (const o of
|
|
34
|
+
for (const o of Kt(t)) {
|
|
35
35
|
let i;
|
|
36
36
|
n ? (i = document.createRange(), i.setStartAfter(n), i.setEndBefore(o)) : (i = t.cloneRange(), i.setEndBefore(o)), i.collapsed || e.push(i), n = o;
|
|
37
37
|
}
|
|
@@ -40,13 +40,13 @@ const H = {
|
|
|
40
40
|
o.setStartAfter(n), o.collapsed || e.push(o);
|
|
41
41
|
}
|
|
42
42
|
return e.length > 0 ? e : [t];
|
|
43
|
-
},
|
|
43
|
+
}, dt = (t) => {
|
|
44
44
|
const e = t.cloneContents();
|
|
45
45
|
return e.querySelectorAll(Y).forEach((n) => n.remove()), e;
|
|
46
|
-
},
|
|
46
|
+
}, Nn = (t) => {
|
|
47
47
|
const e = t.cloneContents();
|
|
48
48
|
return e.querySelectorAll(Y).forEach((n) => n.remove()), e;
|
|
49
|
-
},
|
|
49
|
+
}, mt = (t, e) => {
|
|
50
50
|
const n = document.createNodeIterator(e);
|
|
51
51
|
let o = 0, i = n.nextNode();
|
|
52
52
|
for (; i !== null; ) {
|
|
@@ -54,46 +54,46 @@ const H = {
|
|
|
54
54
|
return o;
|
|
55
55
|
o += 1, i = n.nextNode();
|
|
56
56
|
}
|
|
57
|
-
},
|
|
57
|
+
}, bt = (t, e) => {
|
|
58
58
|
const n = document.createNodeIterator(e);
|
|
59
59
|
let o = null;
|
|
60
60
|
for (let i = 0; i < t + 1; i++)
|
|
61
61
|
o = n.nextNode();
|
|
62
62
|
return o;
|
|
63
|
-
},
|
|
63
|
+
}, Jt = (t) => {
|
|
64
64
|
const {
|
|
65
65
|
commonAncestorContainer: e,
|
|
66
66
|
startContainer: n,
|
|
67
67
|
startOffset: o,
|
|
68
68
|
endContainer: i,
|
|
69
69
|
endOffset: r
|
|
70
|
-
} = t, s = Array.from(e.childNodes).map((
|
|
71
|
-
const m =
|
|
72
|
-
return
|
|
73
|
-
}), a =
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
const m =
|
|
77
|
-
return t.setStart(m, o), t.setEnd(
|
|
78
|
-
},
|
|
70
|
+
} = t, s = Array.from(e.childNodes).map((c) => {
|
|
71
|
+
const m = c.cloneNode(!0);
|
|
72
|
+
return c.nodeName === "CANVAS" ? c : m;
|
|
73
|
+
}), a = mt(n, e), u = mt(i, e), h = () => {
|
|
74
|
+
const c = e;
|
|
75
|
+
c.replaceChildren(...s);
|
|
76
|
+
const m = bt(a, c), p = bt(u, c);
|
|
77
|
+
return t.setStart(m, o), t.setEnd(p, r), t;
|
|
78
|
+
}, v = (c) => {
|
|
79
79
|
const m = document.createElement("SPAN");
|
|
80
|
-
return
|
|
80
|
+
return c.surroundContents(m), m;
|
|
81
81
|
};
|
|
82
82
|
if (n === i)
|
|
83
83
|
throw "Not implemented";
|
|
84
84
|
{
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
const m =
|
|
88
|
-
|
|
89
|
-
const
|
|
85
|
+
const c = document.createRange();
|
|
86
|
+
c.selectNodeContents(n), c.setStart(n, o);
|
|
87
|
+
const m = v(c), p = document.createRange();
|
|
88
|
+
p.selectNode(i), p.setEnd(i, r);
|
|
89
|
+
const w = v(p), y = Zt(t).reverse().map((l) => {
|
|
90
90
|
var f;
|
|
91
91
|
const d = document.createElement("SPAN");
|
|
92
|
-
return (f =
|
|
92
|
+
return (f = l.parentNode) == null || f.insertBefore(d, l), d.appendChild(l), d;
|
|
93
93
|
});
|
|
94
|
-
return { unwrap: h, nodes: [m, ...
|
|
94
|
+
return { unwrap: h, nodes: [m, ...y, w] };
|
|
95
95
|
}
|
|
96
|
-
},
|
|
96
|
+
}, Zt = (t) => {
|
|
97
97
|
const {
|
|
98
98
|
commonAncestorContainer: e,
|
|
99
99
|
startContainer: n,
|
|
@@ -104,25 +104,25 @@ const H = {
|
|
|
104
104
|
for (; r != null; )
|
|
105
105
|
r === o && (s = !1), s && a.push(r), r === n && (s = !0), r = i.nextNode();
|
|
106
106
|
return a;
|
|
107
|
-
},
|
|
107
|
+
}, Ln = (t) => {
|
|
108
108
|
const { startContainer: e, endContainer: n } = t;
|
|
109
109
|
if (e === n)
|
|
110
110
|
return Array.from(t.getClientRects());
|
|
111
111
|
{
|
|
112
|
-
const { unwrap: o, nodes: i } =
|
|
112
|
+
const { unwrap: o, nodes: i } = Jt(t), r = i.reduce((s, a) => [...s, ...a.getClientRects()], []);
|
|
113
113
|
return o(), r;
|
|
114
114
|
}
|
|
115
|
-
},
|
|
115
|
+
}, te = (t, e, n = 10, o) => {
|
|
116
116
|
const i = o ? t.startContainer.parentElement.closest(o) : e, r = document.createRange();
|
|
117
117
|
r.setStart(i, 0), r.setEnd(t.startContainer, t.startOffset);
|
|
118
|
-
const s =
|
|
118
|
+
const s = dt(r).textContent, a = document.createRange();
|
|
119
119
|
a.setStart(t.endContainer, t.endOffset), i === document.body ? a.setEnd(i, i.childNodes.length) : a.setEndAfter(i);
|
|
120
|
-
const u =
|
|
120
|
+
const u = dt(a).textContent;
|
|
121
121
|
return {
|
|
122
122
|
prefix: s.substring(s.length - n),
|
|
123
123
|
suffix: u.substring(0, n)
|
|
124
124
|
};
|
|
125
|
-
}, k = (t) => t.every((e) => e.range instanceof Range && !e.range.collapsed),
|
|
125
|
+
}, k = (t) => t.every((e) => e.range instanceof Range && !e.range.collapsed), ee = (t, e) => {
|
|
126
126
|
const n = (r) => Math.round(r * 10) / 10, o = {
|
|
127
127
|
top: n(t.top),
|
|
128
128
|
bottom: n(t.bottom),
|
|
@@ -146,17 +146,17 @@ const H = {
|
|
|
146
146
|
return "block-contains";
|
|
147
147
|
} else if (o.top >= i.top && o.bottom <= i.bottom && o.left >= i.left && o.right <= i.right)
|
|
148
148
|
return "block-is-contained";
|
|
149
|
-
},
|
|
149
|
+
}, ne = (t, e) => {
|
|
150
150
|
const n = Math.min(t.left, e.left), o = Math.max(t.right, e.right), i = Math.min(t.top, e.top), r = Math.max(t.bottom, e.bottom);
|
|
151
151
|
return new DOMRect(n, i, o - n, r - i);
|
|
152
|
-
},
|
|
152
|
+
}, oe = (t) => t.reduce((e, n) => {
|
|
153
153
|
if (n.width === 0 || n.height === 0)
|
|
154
154
|
return e;
|
|
155
155
|
let o = [...e], i = !1;
|
|
156
156
|
for (const r of e) {
|
|
157
|
-
const s =
|
|
157
|
+
const s = ee(n, r);
|
|
158
158
|
if (s === "inline-adjacent") {
|
|
159
|
-
o = o.map((a) => a === r ?
|
|
159
|
+
o = o.map((a) => a === r ? ne(n, r) : a), i = !0;
|
|
160
160
|
break;
|
|
161
161
|
} else if (s === "inline-contains") {
|
|
162
162
|
o = o.map((a) => a === r ? n : a), i = !0;
|
|
@@ -170,19 +170,19 @@ const H = {
|
|
|
170
170
|
}
|
|
171
171
|
}
|
|
172
172
|
return i ? o : [...o, n];
|
|
173
|
-
}, []),
|
|
173
|
+
}, []), ie = (t, e, n) => {
|
|
174
174
|
const o = document.createRange(), i = n ? t.startContainer.parentElement.closest(n) : e;
|
|
175
175
|
o.setStart(i, 0), o.setEnd(t.startContainer, t.startOffset);
|
|
176
|
-
const r =
|
|
176
|
+
const r = dt(o).textContent, s = t.toString(), a = r.length || 0, u = a + s.length;
|
|
177
177
|
return n ? { quote: s, start: a, end: u, range: t, offsetReference: i } : { quote: s, start: a, end: u, range: t };
|
|
178
|
-
},
|
|
179
|
-
var
|
|
178
|
+
}, Mt = (t, e) => {
|
|
179
|
+
var v, c;
|
|
180
180
|
const { start: n, end: o } = t, i = t.offsetReference || e, r = document.createNodeIterator(
|
|
181
181
|
e,
|
|
182
182
|
NodeFilter.SHOW_TEXT,
|
|
183
183
|
(m) => {
|
|
184
|
-
var
|
|
185
|
-
return (
|
|
184
|
+
var p;
|
|
185
|
+
return (p = m.parentElement) != null && p.closest(Y) ? NodeFilter.FILTER_SKIP : NodeFilter.FILTER_ACCEPT;
|
|
186
186
|
}
|
|
187
187
|
);
|
|
188
188
|
let s = 0;
|
|
@@ -192,7 +192,7 @@ const H = {
|
|
|
192
192
|
let h = !i;
|
|
193
193
|
for (; u !== null; ) {
|
|
194
194
|
if (h || (h = i == null ? void 0 : i.contains(u)), h) {
|
|
195
|
-
const m = ((
|
|
195
|
+
const m = ((v = u.textContent) == null ? void 0 : v.length) || 0;
|
|
196
196
|
if (s + m > n) {
|
|
197
197
|
a.setStart(u, n - s);
|
|
198
198
|
break;
|
|
@@ -202,7 +202,7 @@ const H = {
|
|
|
202
202
|
u = r.nextNode();
|
|
203
203
|
}
|
|
204
204
|
for (; u !== null; ) {
|
|
205
|
-
const m = ((
|
|
205
|
+
const m = ((c = u.textContent) == null ? void 0 : c.length) || 0;
|
|
206
206
|
if (s + m >= o) {
|
|
207
207
|
a.setEnd(u, o - s);
|
|
208
208
|
break;
|
|
@@ -213,10 +213,10 @@ const H = {
|
|
|
213
213
|
...t,
|
|
214
214
|
range: a
|
|
215
215
|
};
|
|
216
|
-
},
|
|
216
|
+
}, et = (t, e) => k(t.selector) ? t : {
|
|
217
217
|
...t,
|
|
218
|
-
selector: t.selector.map((n) => n.range instanceof Range && !n.range.collapsed ? n :
|
|
219
|
-
},
|
|
218
|
+
selector: t.selector.map((n) => n.range instanceof Range && !n.range.collapsed ? n : Mt(n, e))
|
|
219
|
+
}, nt = (t, e) => k(t.target.selector) ? t : { ...t, target: et(t.target, e) }, re = (t) => {
|
|
220
220
|
var i;
|
|
221
221
|
const { startContainer: e, endContainer: n } = t;
|
|
222
222
|
if (e.nodeType === Node.TEXT_NODE && n.nodeType === Node.TEXT_NODE)
|
|
@@ -230,89 +230,89 @@ const H = {
|
|
|
230
230
|
t.setEnd(s, ((i = s == null ? void 0 : s.textContent) == null ? void 0 : i.length) || 0);
|
|
231
231
|
}
|
|
232
232
|
return t;
|
|
233
|
-
},
|
|
233
|
+
}, se = (t) => {
|
|
234
234
|
const { top: e, left: n } = t.getBoundingClientRect(), { innerWidth: o, innerHeight: i } = window, r = -n, s = -e, a = o - n, u = i - e;
|
|
235
235
|
return { top: e, left: n, minX: r, minY: s, maxX: a, maxY: u };
|
|
236
|
-
},
|
|
236
|
+
}, ae = (t) => {
|
|
237
237
|
let e = /* @__PURE__ */ new Set();
|
|
238
238
|
return (o) => {
|
|
239
239
|
const i = o.map((r) => r.id);
|
|
240
240
|
(e.size !== i.length || i.some((r) => !e.has(r))) && t.set(i), e = new Set(i);
|
|
241
241
|
};
|
|
242
|
-
},
|
|
242
|
+
}, pt = (t, e, n, o) => {
|
|
243
243
|
const { store: i, selection: r, hover: s } = e;
|
|
244
244
|
let a, u, h;
|
|
245
|
-
const
|
|
246
|
-
const { x: S, y: E } = t.getBoundingClientRect(), C = i.getAt(
|
|
245
|
+
const v = ae(n), c = (g) => {
|
|
246
|
+
const { x: S, y: E } = t.getBoundingClientRect(), C = i.getAt(g.clientX - S, g.clientY - E);
|
|
247
247
|
C && (!u || u(C)) ? s.current !== C.id && (t.classList.add("hovered"), s.set(C.id)) : s.current && (t.classList.remove("hovered"), s.set(null));
|
|
248
248
|
};
|
|
249
|
-
t.addEventListener("pointermove",
|
|
250
|
-
const m = (
|
|
249
|
+
t.addEventListener("pointermove", c);
|
|
250
|
+
const m = (g = !1) => {
|
|
251
251
|
h && h.clear();
|
|
252
|
-
const S =
|
|
253
|
-
const
|
|
254
|
-
return { annotation:
|
|
252
|
+
const S = se(t), { minX: E, minY: C, maxX: N, maxY: B } = S, _ = u ? i.getIntersecting(E, C, N, B).filter(({ annotation: X }) => u(X)) : i.getIntersecting(E, C, N, B), Pt = r.selected.map(({ id: X }) => X), zt = _.map(({ annotation: X, rects: Ft }) => {
|
|
253
|
+
const Wt = Pt.includes(X.id), qt = X.id === s.current;
|
|
254
|
+
return { annotation: X, rects: Ft, state: { selected: Wt, hover: qt, custom: {} } };
|
|
255
255
|
});
|
|
256
|
-
o.redraw(
|
|
257
|
-
},
|
|
258
|
-
h =
|
|
259
|
-
},
|
|
260
|
-
a =
|
|
261
|
-
}, x = (
|
|
262
|
-
u =
|
|
263
|
-
},
|
|
264
|
-
i.observe(
|
|
265
|
-
const
|
|
256
|
+
o.redraw(zt, S, a, h, g), setTimeout(() => v(_.map(({ annotation: X }) => X)), 1);
|
|
257
|
+
}, p = (g) => {
|
|
258
|
+
h = g, m();
|
|
259
|
+
}, w = (g) => {
|
|
260
|
+
a = g, m();
|
|
261
|
+
}, x = (g) => {
|
|
262
|
+
u = g, m(!1);
|
|
263
|
+
}, y = () => m();
|
|
264
|
+
i.observe(y);
|
|
265
|
+
const l = r.subscribe(() => m()), d = () => m(!0);
|
|
266
266
|
document.addEventListener("scroll", d, { capture: !0, passive: !0 });
|
|
267
|
-
const f =
|
|
267
|
+
const f = ft(() => {
|
|
268
268
|
i.recalculatePositions(), h && h.reset(), m();
|
|
269
269
|
});
|
|
270
270
|
window.addEventListener("resize", f);
|
|
271
|
-
const
|
|
272
|
-
|
|
273
|
-
const A = { attributes: !0, childList: !0, subtree: !0 }, R = new MutationObserver((
|
|
274
|
-
|
|
271
|
+
const b = new ResizeObserver(f);
|
|
272
|
+
b.observe(t);
|
|
273
|
+
const A = { attributes: !0, childList: !0, subtree: !0 }, R = new MutationObserver((g) => {
|
|
274
|
+
g.every((E) => E.target === t || t.contains(E.target)) || m(!0);
|
|
275
275
|
});
|
|
276
276
|
return R.observe(document.body, A), {
|
|
277
277
|
destroy: () => {
|
|
278
|
-
t.removeEventListener("pointermove",
|
|
278
|
+
t.removeEventListener("pointermove", c), o.destroy(), i.unobserve(y), l(), document.removeEventListener("scroll", d), window.removeEventListener("resize", f), b.disconnect(), R.disconnect();
|
|
279
279
|
},
|
|
280
280
|
redraw: m,
|
|
281
|
-
setStyle:
|
|
281
|
+
setStyle: w,
|
|
282
282
|
setFilter: x,
|
|
283
|
-
setPainter:
|
|
283
|
+
setPainter: p,
|
|
284
284
|
setVisible: o.setVisible
|
|
285
285
|
};
|
|
286
|
-
},
|
|
286
|
+
}, ce = () => {
|
|
287
287
|
const t = document.createElement("canvas");
|
|
288
288
|
return t.width = window.innerWidth, t.height = window.innerHeight, t.className = "r6o-highlight-layer bg", t;
|
|
289
|
-
},
|
|
289
|
+
}, le = (t, e) => {
|
|
290
290
|
if (t.width = e ? 2 * window.innerWidth : window.innerWidth, t.height = e ? 2 * window.innerHeight : window.innerHeight, e) {
|
|
291
291
|
const n = t.getContext("2d");
|
|
292
292
|
n.scale(2, 2), n.translate(0.5, 0.5);
|
|
293
293
|
}
|
|
294
|
-
},
|
|
294
|
+
}, de = (t) => {
|
|
295
295
|
t.classList.add("r6o-annotatable");
|
|
296
|
-
const e =
|
|
296
|
+
const e = ce(), n = e.getContext("2d");
|
|
297
297
|
t.insertBefore(e, t.firstChild);
|
|
298
|
-
const o = (a, u, h,
|
|
299
|
-
const { width:
|
|
300
|
-
n.clearRect(-0.5, -0.5,
|
|
301
|
-
const { top:
|
|
298
|
+
const o = (a, u, h, v) => requestAnimationFrame(() => {
|
|
299
|
+
const { width: c, height: m } = e;
|
|
300
|
+
n.clearRect(-0.5, -0.5, c + 1, m + 1), v && v.clear();
|
|
301
|
+
const { top: p, left: w } = u;
|
|
302
302
|
a.forEach((x) => {
|
|
303
303
|
var f;
|
|
304
|
-
const
|
|
305
|
-
x:
|
|
306
|
-
y: A +
|
|
304
|
+
const y = h ? typeof h == "function" ? h(x.annotation, x.state) : h : (f = x.state) != null && f.selected ? ht : $, l = v && v.paint(x, u) || y, d = x.rects.map(({ x: b, y: A, width: R, height: T }) => ({
|
|
305
|
+
x: b + w,
|
|
306
|
+
y: A + p,
|
|
307
307
|
width: R,
|
|
308
308
|
height: T
|
|
309
309
|
}));
|
|
310
|
-
n.fillStyle =
|
|
311
|
-
n.beginPath(), n.moveTo(
|
|
310
|
+
n.fillStyle = l.fill, n.globalAlpha = l.fillOpacity || 1, d.forEach(({ x: b, y: A, width: R, height: T }) => n.fillRect(b, A - 2.5, R, T + 5)), l.underlineColor && (n.globalAlpha = 1, n.strokeStyle = l.underlineColor, d.forEach(({ x: b, y: A, width: R, height: T }) => {
|
|
311
|
+
n.beginPath(), n.moveTo(b, A + T + 4), n.lineTo(b + R, A + T + 4), n.stroke();
|
|
312
312
|
}));
|
|
313
313
|
});
|
|
314
|
-
}), i =
|
|
315
|
-
|
|
314
|
+
}), i = ft(() => {
|
|
315
|
+
le(e);
|
|
316
316
|
});
|
|
317
317
|
return window.addEventListener("resize", i), {
|
|
318
318
|
destroy: () => {
|
|
@@ -323,148 +323,148 @@ const H = {
|
|
|
323
323
|
},
|
|
324
324
|
redraw: o
|
|
325
325
|
};
|
|
326
|
-
},
|
|
327
|
-
var
|
|
326
|
+
}, ue = (t, e, n) => pt(t, e, n, de(t));
|
|
327
|
+
var he = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, D = function(t) {
|
|
328
328
|
return typeof t == "string" ? t.length > 0 : typeof t == "number";
|
|
329
329
|
}, O = function(t, e, n) {
|
|
330
330
|
return e === void 0 && (e = 0), n === void 0 && (n = Math.pow(10, e)), Math.round(n * t) / n + 0;
|
|
331
|
-
},
|
|
331
|
+
}, U = function(t, e, n) {
|
|
332
332
|
return e === void 0 && (e = 0), n === void 0 && (n = 1), t > n ? n : t > e ? t : e;
|
|
333
|
-
},
|
|
333
|
+
}, Ut = function(t) {
|
|
334
334
|
return (t = isFinite(t) ? t % 360 : 0) > 0 ? t : t + 360;
|
|
335
|
-
},
|
|
336
|
-
return { r:
|
|
337
|
-
},
|
|
335
|
+
}, vt = function(t) {
|
|
336
|
+
return { r: U(t.r, 0, 255), g: U(t.g, 0, 255), b: U(t.b, 0, 255), a: U(t.a) };
|
|
337
|
+
}, ot = function(t) {
|
|
338
338
|
return { r: O(t.r), g: O(t.g), b: O(t.b), a: O(t.a, 3) };
|
|
339
|
-
},
|
|
339
|
+
}, fe = /^#([0-9a-f]{3,8})$/i, K = function(t) {
|
|
340
340
|
var e = t.toString(16);
|
|
341
341
|
return e.length < 2 ? "0" + e : e;
|
|
342
|
-
},
|
|
342
|
+
}, Vt = function(t) {
|
|
343
343
|
var e = t.r, n = t.g, o = t.b, i = t.a, r = Math.max(e, n, o), s = r - Math.min(e, n, o), a = s ? r === e ? (n - o) / s : r === n ? 2 + (o - e) / s : 4 + (e - n) / s : 0;
|
|
344
344
|
return { h: 60 * (a < 0 ? a + 6 : a), s: r ? s / r * 100 : 0, v: r / 255 * 100, a: i };
|
|
345
|
-
},
|
|
345
|
+
}, _t = function(t) {
|
|
346
346
|
var e = t.h, n = t.s, o = t.v, i = t.a;
|
|
347
347
|
e = e / 360 * 6, n /= 100, o /= 100;
|
|
348
348
|
var r = Math.floor(e), s = o * (1 - n), a = o * (1 - (e - r) * n), u = o * (1 - (1 - e + r) * n), h = r % 6;
|
|
349
349
|
return { r: 255 * [o, a, s, s, u, o][h], g: 255 * [u, o, o, a, s, s][h], b: 255 * [s, s, u, o, o, a][h], a: i };
|
|
350
|
-
},
|
|
351
|
-
return { h:
|
|
352
|
-
}, vt = function(t) {
|
|
353
|
-
return { h: O(t.h), s: O(t.s), l: O(t.l), a: O(t.a, 3) };
|
|
350
|
+
}, yt = function(t) {
|
|
351
|
+
return { h: Ut(t.h), s: U(t.s, 0, 100), l: U(t.l, 0, 100), a: U(t.a) };
|
|
354
352
|
}, wt = function(t) {
|
|
355
|
-
return
|
|
353
|
+
return { h: O(t.h), s: O(t.s), l: O(t.l), a: O(t.a, 3) };
|
|
354
|
+
}, xt = function(t) {
|
|
355
|
+
return _t((n = (e = t).s, { h: e.h, s: (n *= ((o = e.l) < 50 ? o : 100 - o) / 100) > 0 ? 2 * n / (o + n) * 100 : 0, v: o + n, a: e.a }));
|
|
356
356
|
var e, n, o;
|
|
357
|
-
},
|
|
358
|
-
return { h: (e =
|
|
357
|
+
}, G = function(t) {
|
|
358
|
+
return { h: (e = Vt(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 };
|
|
359
359
|
var e, n, o, i;
|
|
360
|
-
},
|
|
361
|
-
var e =
|
|
360
|
+
}, pe = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, ge = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, me = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, be = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, At = { string: [[function(t) {
|
|
361
|
+
var e = fe.exec(t);
|
|
362
362
|
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 ? O(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 ? O(parseInt(t.substr(6, 2), 16) / 255, 2) : 1 } : null : null;
|
|
363
363
|
}, "hex"], [function(t) {
|
|
364
|
-
var e =
|
|
365
|
-
return e ? e[2] !== e[4] || e[4] !== e[6] ? null :
|
|
364
|
+
var e = me.exec(t) || be.exec(t);
|
|
365
|
+
return e ? e[2] !== e[4] || e[4] !== e[6] ? null : vt({ 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;
|
|
366
366
|
}, "rgb"], [function(t) {
|
|
367
|
-
var e =
|
|
367
|
+
var e = pe.exec(t) || ge.exec(t);
|
|
368
368
|
if (!e)
|
|
369
369
|
return null;
|
|
370
|
-
var n, o, i =
|
|
371
|
-
return
|
|
370
|
+
var n, o, i = yt({ h: (n = e[1], o = e[2], o === void 0 && (o = "deg"), Number(n) * (he[o] || 1)), s: Number(e[3]), l: Number(e[4]), a: e[5] === void 0 ? 1 : Number(e[5]) / (e[6] ? 100 : 1) });
|
|
371
|
+
return xt(i);
|
|
372
372
|
}, "hsl"]], object: [[function(t) {
|
|
373
373
|
var e = t.r, n = t.g, o = t.b, i = t.a, r = i === void 0 ? 1 : i;
|
|
374
|
-
return
|
|
374
|
+
return D(e) && D(n) && D(o) ? vt({ r: Number(e), g: Number(n), b: Number(o), a: Number(r) }) : null;
|
|
375
375
|
}, "rgb"], [function(t) {
|
|
376
376
|
var e = t.h, n = t.s, o = t.l, i = t.a, r = i === void 0 ? 1 : i;
|
|
377
|
-
if (!
|
|
377
|
+
if (!D(e) || !D(n) || !D(o))
|
|
378
378
|
return null;
|
|
379
|
-
var s =
|
|
380
|
-
return
|
|
379
|
+
var s = yt({ h: Number(e), s: Number(n), l: Number(o), a: Number(r) });
|
|
380
|
+
return xt(s);
|
|
381
381
|
}, "hsl"], [function(t) {
|
|
382
382
|
var e = t.h, n = t.s, o = t.v, i = t.a, r = i === void 0 ? 1 : i;
|
|
383
|
-
if (!
|
|
383
|
+
if (!D(e) || !D(n) || !D(o))
|
|
384
384
|
return null;
|
|
385
385
|
var s = function(a) {
|
|
386
|
-
return { h:
|
|
386
|
+
return { h: Ut(a.h), s: U(a.s, 0, 100), v: U(a.v, 0, 100), a: U(a.a) };
|
|
387
387
|
}({ h: Number(e), s: Number(n), v: Number(o), a: Number(r) });
|
|
388
|
-
return
|
|
389
|
-
}, "hsv"]] },
|
|
388
|
+
return _t(s);
|
|
389
|
+
}, "hsv"]] }, Et = function(t, e) {
|
|
390
390
|
for (var n = 0; n < e.length; n++) {
|
|
391
391
|
var o = e[n][0](t);
|
|
392
392
|
if (o)
|
|
393
393
|
return [o, e[n][1]];
|
|
394
394
|
}
|
|
395
395
|
return [null, void 0];
|
|
396
|
-
},
|
|
397
|
-
return typeof t == "string" ?
|
|
398
|
-
},
|
|
399
|
-
var n =
|
|
400
|
-
return { h: n.h, s:
|
|
401
|
-
},
|
|
396
|
+
}, ve = function(t) {
|
|
397
|
+
return typeof t == "string" ? Et(t.trim(), At.string) : typeof t == "object" && t !== null ? Et(t, At.object) : [null, void 0];
|
|
398
|
+
}, it = function(t, e) {
|
|
399
|
+
var n = G(t);
|
|
400
|
+
return { h: n.h, s: U(n.s + 100 * e, 0, 100), l: n.l, a: n.a };
|
|
401
|
+
}, rt = function(t) {
|
|
402
402
|
return (299 * t.r + 587 * t.g + 114 * t.b) / 1e3 / 255;
|
|
403
|
-
},
|
|
404
|
-
var n =
|
|
405
|
-
return { h: n.h, s: n.s, l:
|
|
406
|
-
},
|
|
403
|
+
}, St = function(t, e) {
|
|
404
|
+
var n = G(t);
|
|
405
|
+
return { h: n.h, s: n.s, l: U(n.l + 100 * e, 0, 100), a: n.a };
|
|
406
|
+
}, Ct = function() {
|
|
407
407
|
function t(e) {
|
|
408
|
-
this.parsed =
|
|
408
|
+
this.parsed = ve(e)[0], this.rgba = this.parsed || { r: 0, g: 0, b: 0, a: 1 };
|
|
409
409
|
}
|
|
410
410
|
return t.prototype.isValid = function() {
|
|
411
411
|
return this.parsed !== null;
|
|
412
412
|
}, t.prototype.brightness = function() {
|
|
413
|
-
return O(
|
|
413
|
+
return O(rt(this.rgba), 2);
|
|
414
414
|
}, t.prototype.isDark = function() {
|
|
415
|
-
return
|
|
415
|
+
return rt(this.rgba) < 0.5;
|
|
416
416
|
}, t.prototype.isLight = function() {
|
|
417
|
-
return
|
|
417
|
+
return rt(this.rgba) >= 0.5;
|
|
418
418
|
}, t.prototype.toHex = function() {
|
|
419
|
-
return e =
|
|
419
|
+
return e = ot(this.rgba), n = e.r, o = e.g, i = e.b, s = (r = e.a) < 1 ? K(O(255 * r)) : "", "#" + K(n) + K(o) + K(i) + s;
|
|
420
420
|
var e, n, o, i, r, s;
|
|
421
421
|
}, t.prototype.toRgb = function() {
|
|
422
|
-
return
|
|
422
|
+
return ot(this.rgba);
|
|
423
423
|
}, t.prototype.toRgbString = function() {
|
|
424
|
-
return e =
|
|
424
|
+
return e = ot(this.rgba), n = e.r, o = e.g, i = e.b, (r = e.a) < 1 ? "rgba(" + n + ", " + o + ", " + i + ", " + r + ")" : "rgb(" + n + ", " + o + ", " + i + ")";
|
|
425
425
|
var e, n, o, i, r;
|
|
426
426
|
}, t.prototype.toHsl = function() {
|
|
427
|
-
return
|
|
427
|
+
return wt(G(this.rgba));
|
|
428
428
|
}, t.prototype.toHslString = function() {
|
|
429
|
-
return e =
|
|
429
|
+
return e = wt(G(this.rgba)), n = e.h, o = e.s, i = e.l, (r = e.a) < 1 ? "hsla(" + n + ", " + o + "%, " + i + "%, " + r + ")" : "hsl(" + n + ", " + o + "%, " + i + "%)";
|
|
430
430
|
var e, n, o, i, r;
|
|
431
431
|
}, t.prototype.toHsv = function() {
|
|
432
|
-
return e =
|
|
432
|
+
return e = Vt(this.rgba), { h: O(e.h), s: O(e.s), v: O(e.v), a: O(e.a, 3) };
|
|
433
433
|
var e;
|
|
434
434
|
}, t.prototype.invert = function() {
|
|
435
435
|
return V({ r: 255 - (e = this.rgba).r, g: 255 - e.g, b: 255 - e.b, a: e.a });
|
|
436
436
|
var e;
|
|
437
437
|
}, t.prototype.saturate = function(e) {
|
|
438
|
-
return e === void 0 && (e = 0.1), V(
|
|
438
|
+
return e === void 0 && (e = 0.1), V(it(this.rgba, e));
|
|
439
439
|
}, t.prototype.desaturate = function(e) {
|
|
440
|
-
return e === void 0 && (e = 0.1), V(
|
|
440
|
+
return e === void 0 && (e = 0.1), V(it(this.rgba, -e));
|
|
441
441
|
}, t.prototype.grayscale = function() {
|
|
442
|
-
return V(
|
|
442
|
+
return V(it(this.rgba, -1));
|
|
443
443
|
}, t.prototype.lighten = function(e) {
|
|
444
|
-
return e === void 0 && (e = 0.1), V(
|
|
444
|
+
return e === void 0 && (e = 0.1), V(St(this.rgba, e));
|
|
445
445
|
}, t.prototype.darken = function(e) {
|
|
446
|
-
return e === void 0 && (e = 0.1), V(
|
|
446
|
+
return e === void 0 && (e = 0.1), V(St(this.rgba, -e));
|
|
447
447
|
}, t.prototype.rotate = function(e) {
|
|
448
448
|
return e === void 0 && (e = 15), this.hue(this.hue() + e);
|
|
449
449
|
}, t.prototype.alpha = function(e) {
|
|
450
450
|
return typeof e == "number" ? V({ r: (n = this.rgba).r, g: n.g, b: n.b, a: e }) : O(this.rgba.a, 3);
|
|
451
451
|
var n;
|
|
452
452
|
}, t.prototype.hue = function(e) {
|
|
453
|
-
var n =
|
|
453
|
+
var n = G(this.rgba);
|
|
454
454
|
return typeof e == "number" ? V({ h: e, s: n.s, l: n.l, a: n.a }) : O(n.h);
|
|
455
455
|
}, t.prototype.isEqual = function(e) {
|
|
456
456
|
return this.toHex() === V(e).toHex();
|
|
457
457
|
}, t;
|
|
458
458
|
}(), V = function(t) {
|
|
459
|
-
return t instanceof
|
|
459
|
+
return t instanceof Ct ? t : new Ct(t);
|
|
460
460
|
};
|
|
461
|
-
const
|
|
462
|
-
`background-color:${V((t == null ? void 0 : t.fill) ||
|
|
461
|
+
const ye = (t) => [
|
|
462
|
+
`background-color:${V((t == null ? void 0 : t.fill) || $.fill).alpha((t == null ? void 0 : t.fillOpacity) === void 0 ? $.fillOpacity : t.fillOpacity).toHex()}`,
|
|
463
463
|
t != null && t.underlineThickness ? "text-decoration:underline" : void 0,
|
|
464
464
|
t != null && t.underlineColor ? `text-decoration-color:${t.underlineColor}` : void 0,
|
|
465
465
|
t != null && t.underlineOffset ? `text-underline-offset:${t.underlineOffset}px` : void 0,
|
|
466
466
|
t != null && t.underlineThickness ? `text-decoration-thickness:${t.underlineThickness}px` : void 0
|
|
467
|
-
].filter(Boolean).join(";"),
|
|
467
|
+
].filter(Boolean).join(";"), we = () => {
|
|
468
468
|
const t = document.createElement("style");
|
|
469
469
|
document.getElementsByTagName("head")[0].appendChild(t);
|
|
470
470
|
let e = /* @__PURE__ */ new Set();
|
|
@@ -477,23 +477,23 @@ const pe = (t) => [
|
|
|
477
477
|
},
|
|
478
478
|
redraw: (r, s, a, u) => {
|
|
479
479
|
u && u.clear();
|
|
480
|
-
const h = new Set(r.map((
|
|
481
|
-
Array.from(e).filter((
|
|
482
|
-
const
|
|
483
|
-
var
|
|
484
|
-
const m = a ? typeof a == "function" ? a(
|
|
485
|
-
return `::highlight(_${
|
|
480
|
+
const h = new Set(r.map((c) => c.annotation.id));
|
|
481
|
+
Array.from(e).filter((c) => !h.has(c));
|
|
482
|
+
const v = r.map((c) => {
|
|
483
|
+
var w;
|
|
484
|
+
const m = a ? typeof a == "function" ? a(c.annotation, c.state) : a : (w = c.state) != null && w.selected ? ht : $, p = u && u.paint(c, s) || m;
|
|
485
|
+
return `::highlight(_${c.annotation.id}) { ${ye(p)} }`;
|
|
486
486
|
});
|
|
487
|
-
t.innerHTML =
|
|
488
|
-
`), CSS.highlights.clear(), r.forEach(({ annotation:
|
|
489
|
-
const m =
|
|
490
|
-
CSS.highlights.set(`_${
|
|
487
|
+
t.innerHTML = v.join(`
|
|
488
|
+
`), CSS.highlights.clear(), r.forEach(({ annotation: c }) => {
|
|
489
|
+
const m = c.target.selector.map((w) => w.range), p = new Highlight(...m);
|
|
490
|
+
CSS.highlights.set(`_${c.id}`, p);
|
|
491
491
|
}), e = h;
|
|
492
492
|
}
|
|
493
493
|
};
|
|
494
|
-
},
|
|
495
|
-
var
|
|
496
|
-
function
|
|
494
|
+
}, xe = (t, e, n) => pt(t, e, n, we());
|
|
495
|
+
var Tt = Object.prototype.hasOwnProperty;
|
|
496
|
+
function ut(t, e) {
|
|
497
497
|
var n, o;
|
|
498
498
|
if (t === e)
|
|
499
499
|
return !0;
|
|
@@ -504,24 +504,24 @@ function ct(t, e) {
|
|
|
504
504
|
return t.toString() === e.toString();
|
|
505
505
|
if (n === Array) {
|
|
506
506
|
if ((o = t.length) === e.length)
|
|
507
|
-
for (; o-- &&
|
|
507
|
+
for (; o-- && ut(t[o], e[o]); )
|
|
508
508
|
;
|
|
509
509
|
return o === -1;
|
|
510
510
|
}
|
|
511
511
|
if (!n || typeof t == "object") {
|
|
512
512
|
o = 0;
|
|
513
513
|
for (n in t)
|
|
514
|
-
if (
|
|
514
|
+
if (Tt.call(t, n) && ++o && !Tt.call(e, n) || !(n in e) || !ut(t[n], e[n]))
|
|
515
515
|
return !1;
|
|
516
516
|
return Object.keys(e).length === o;
|
|
517
517
|
}
|
|
518
518
|
}
|
|
519
519
|
return t !== t && e !== e;
|
|
520
520
|
}
|
|
521
|
-
const
|
|
521
|
+
const Ae = (t, e) => {
|
|
522
522
|
const n = (o, i) => o.x <= i.x + i.width && o.x + o.width >= i.x && o.y <= i.y + i.height && o.y + o.height >= i.y;
|
|
523
523
|
return e.filter((o) => t !== o && n(t, o) && o.width > t.width).length;
|
|
524
|
-
},
|
|
524
|
+
}, Ee = (t) => {
|
|
525
525
|
t.classList.add("r6o-annotatable");
|
|
526
526
|
const e = document.createElement("div");
|
|
527
527
|
e.className = "r6o-span-highlight-layer", t.insertBefore(e, t.firstChild);
|
|
@@ -530,57 +530,57 @@ const ve = (t, e) => {
|
|
|
530
530
|
destroy: () => {
|
|
531
531
|
e.remove();
|
|
532
532
|
},
|
|
533
|
-
redraw: (s, a, u, h,
|
|
534
|
-
if (
|
|
533
|
+
redraw: (s, a, u, h, v) => {
|
|
534
|
+
if (ut(n, s) && v)
|
|
535
535
|
return;
|
|
536
536
|
e.innerHTML = "";
|
|
537
|
-
const m = s.reduce((
|
|
538
|
-
s.forEach((
|
|
539
|
-
const
|
|
540
|
-
const
|
|
541
|
-
|
|
542
|
-
const
|
|
543
|
-
return
|
|
537
|
+
const m = s.reduce((p, { rects: w }) => [...p, ...w], []);
|
|
538
|
+
s.forEach((p) => {
|
|
539
|
+
const w = p.rects.map((x) => {
|
|
540
|
+
const y = document.createElement("span");
|
|
541
|
+
y.className = "r6o-annotation", y.dataset.annotation = p.annotation.id, y.style.left = `${x.x}px`, y.style.top = `${x.y}px`, y.style.width = `${x.width}px`, y.style.height = `${x.height}px`;
|
|
542
|
+
const l = Ae(x, m), d = jt(p, a, u, h, l), f = V((d == null ? void 0 : d.fill) || $.fill).alpha((d == null ? void 0 : d.fillOpacity) === void 0 ? $.fillOpacity : d.fillOpacity).toHex();
|
|
543
|
+
return y.style.backgroundColor = f, d.underlineStyle && (y.style.borderStyle = d.underlineStyle), d.underlineColor && (y.style.borderColor = d.underlineColor), d.underlineThickness && (y.style.borderBottomWidth = `${d.underlineThickness}px`), d.underlineOffset && (y.style.paddingBottom = `${d.underlineOffset}px`), e.appendChild(y), y;
|
|
544
544
|
});
|
|
545
|
-
return { id:
|
|
545
|
+
return { id: p.annotation.id, spans: w };
|
|
546
546
|
}), n = s;
|
|
547
547
|
},
|
|
548
548
|
setVisible: (s) => {
|
|
549
549
|
s ? e.classList.remove("hidden") : e.classList.add("hidden");
|
|
550
550
|
}
|
|
551
551
|
};
|
|
552
|
-
},
|
|
553
|
-
let
|
|
554
|
-
const
|
|
555
|
-
function
|
|
556
|
-
if (!
|
|
552
|
+
}, Se = (t, e, n) => pt(t, e, n, Ee(t));
|
|
553
|
+
let Q;
|
|
554
|
+
const Ce = new Uint8Array(16);
|
|
555
|
+
function Te() {
|
|
556
|
+
if (!Q && (Q = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !Q))
|
|
557
557
|
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
558
|
-
return
|
|
558
|
+
return Q(Ce);
|
|
559
559
|
}
|
|
560
|
-
const
|
|
560
|
+
const I = [];
|
|
561
561
|
for (let t = 0; t < 256; ++t)
|
|
562
|
-
|
|
563
|
-
function
|
|
564
|
-
return
|
|
562
|
+
I.push((t + 256).toString(16).slice(1));
|
|
563
|
+
function Re(t, e = 0) {
|
|
564
|
+
return I[t[e + 0]] + I[t[e + 1]] + I[t[e + 2]] + I[t[e + 3]] + "-" + I[t[e + 4]] + I[t[e + 5]] + "-" + I[t[e + 6]] + I[t[e + 7]] + "-" + I[t[e + 8]] + I[t[e + 9]] + "-" + I[t[e + 10]] + I[t[e + 11]] + I[t[e + 12]] + I[t[e + 13]] + I[t[e + 14]] + I[t[e + 15]];
|
|
565
565
|
}
|
|
566
|
-
const
|
|
567
|
-
randomUUID:
|
|
566
|
+
const Ne = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), Rt = {
|
|
567
|
+
randomUUID: Ne
|
|
568
568
|
};
|
|
569
|
-
function
|
|
570
|
-
if (
|
|
571
|
-
return
|
|
569
|
+
function Xt(t, e, n) {
|
|
570
|
+
if (Rt.randomUUID && !e && !t)
|
|
571
|
+
return Rt.randomUUID();
|
|
572
572
|
t = t || {};
|
|
573
|
-
const o = t.random || (t.rng ||
|
|
573
|
+
const o = t.random || (t.rng || Te)();
|
|
574
574
|
if (o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128, e) {
|
|
575
575
|
n = n || 0;
|
|
576
576
|
for (let i = 0; i < 16; ++i)
|
|
577
577
|
e[n + i] = o[i];
|
|
578
578
|
return e;
|
|
579
579
|
}
|
|
580
|
-
return
|
|
580
|
+
return Re(o);
|
|
581
581
|
}
|
|
582
|
-
var
|
|
583
|
-
function
|
|
582
|
+
var Nt = Object.prototype.hasOwnProperty;
|
|
583
|
+
function H(t, e) {
|
|
584
584
|
var n, o;
|
|
585
585
|
if (t === e)
|
|
586
586
|
return !0;
|
|
@@ -591,54 +591,54 @@ function D(t, e) {
|
|
|
591
591
|
return t.toString() === e.toString();
|
|
592
592
|
if (n === Array) {
|
|
593
593
|
if ((o = t.length) === e.length)
|
|
594
|
-
for (; o-- &&
|
|
594
|
+
for (; o-- && H(t[o], e[o]); )
|
|
595
595
|
;
|
|
596
596
|
return o === -1;
|
|
597
597
|
}
|
|
598
598
|
if (!n || typeof t == "object") {
|
|
599
599
|
o = 0;
|
|
600
600
|
for (n in t)
|
|
601
|
-
if (
|
|
601
|
+
if (Nt.call(t, n) && ++o && !Nt.call(e, n) || !(n in e) || !H(t[n], e[n]))
|
|
602
602
|
return !1;
|
|
603
603
|
return Object.keys(e).length === o;
|
|
604
604
|
}
|
|
605
605
|
}
|
|
606
606
|
return t !== t && e !== e;
|
|
607
607
|
}
|
|
608
|
-
function
|
|
608
|
+
function st() {
|
|
609
609
|
}
|
|
610
|
-
function
|
|
610
|
+
function Le(t, e) {
|
|
611
611
|
return t != t ? e == e : t !== e || t && typeof t == "object" || typeof t == "function";
|
|
612
612
|
}
|
|
613
|
-
const
|
|
614
|
-
function
|
|
613
|
+
const P = [];
|
|
614
|
+
function gt(t, e = st) {
|
|
615
615
|
let n;
|
|
616
616
|
const o = /* @__PURE__ */ new Set();
|
|
617
617
|
function i(a) {
|
|
618
|
-
if (
|
|
619
|
-
const u =
|
|
618
|
+
if (Le(t, a) && (t = a, n)) {
|
|
619
|
+
const u = !P.length;
|
|
620
620
|
for (const h of o)
|
|
621
|
-
h[1](),
|
|
621
|
+
h[1](), P.push(h, t);
|
|
622
622
|
if (u) {
|
|
623
|
-
for (let h = 0; h <
|
|
624
|
-
|
|
625
|
-
|
|
623
|
+
for (let h = 0; h < P.length; h += 2)
|
|
624
|
+
P[h][0](P[h + 1]);
|
|
625
|
+
P.length = 0;
|
|
626
626
|
}
|
|
627
627
|
}
|
|
628
628
|
}
|
|
629
629
|
function r(a) {
|
|
630
630
|
i(a(t));
|
|
631
631
|
}
|
|
632
|
-
function s(a, u =
|
|
632
|
+
function s(a, u = st) {
|
|
633
633
|
const h = [a, u];
|
|
634
|
-
return o.add(h), o.size === 1 && (n = e(i, r) ||
|
|
634
|
+
return o.add(h), o.size === 1 && (n = e(i, r) || st), a(t), () => {
|
|
635
635
|
o.delete(h), o.size === 0 && n && (n(), n = null);
|
|
636
636
|
};
|
|
637
637
|
}
|
|
638
638
|
return { set: i, update: r, subscribe: s };
|
|
639
639
|
}
|
|
640
|
-
const
|
|
641
|
-
const { subscribe: e, set: n } =
|
|
640
|
+
const Be = (t) => {
|
|
641
|
+
const { subscribe: e, set: n } = gt();
|
|
642
642
|
let o;
|
|
643
643
|
return e((i) => o = i), t.observe(({ changes: i }) => {
|
|
644
644
|
if (o) {
|
|
@@ -653,35 +653,37 @@ const Te = (t) => {
|
|
|
653
653
|
subscribe: e,
|
|
654
654
|
set: n
|
|
655
655
|
};
|
|
656
|
-
}
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
n
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
656
|
+
};
|
|
657
|
+
var Dt = /* @__PURE__ */ ((t) => (t.EDIT = "EDIT", t.SELECT = "SELECT", t.NONE = "NONE", t))(Dt || {});
|
|
658
|
+
const at = { selected: [] }, Oe = (t, e = "EDIT") => {
|
|
659
|
+
const { subscribe: n, set: o } = gt(at);
|
|
660
|
+
let i = at;
|
|
661
|
+
n((c) => i = c);
|
|
662
|
+
const r = () => o(at), s = () => {
|
|
663
|
+
var c;
|
|
664
|
+
return ((c = i.selected) == null ? void 0 : c.length) === 0;
|
|
665
|
+
}, a = (c) => {
|
|
664
666
|
if (i.selected.length === 0)
|
|
665
667
|
return !1;
|
|
666
|
-
const m = typeof
|
|
667
|
-
return i.selected.some((
|
|
668
|
-
}, u = (
|
|
669
|
-
const
|
|
670
|
-
if (
|
|
671
|
-
const
|
|
672
|
-
o(
|
|
668
|
+
const m = typeof c == "string" ? c : c.id;
|
|
669
|
+
return i.selected.some((p) => p.id === m);
|
|
670
|
+
}, u = (c, m) => {
|
|
671
|
+
const p = t.getAnnotation(c);
|
|
672
|
+
if (p) {
|
|
673
|
+
const w = Ie(p, e);
|
|
674
|
+
o(w === "EDIT" ? { selected: [{ id: c, editable: !0 }], pointerEvent: m } : w === "SELECT" ? { selected: [{ id: c }], pointerEvent: m } : { selected: [], pointerEvent: m });
|
|
673
675
|
} else
|
|
674
|
-
console.warn("Invalid selection: " +
|
|
675
|
-
}, h = (
|
|
676
|
-
const
|
|
677
|
-
o({ selected:
|
|
678
|
-
},
|
|
676
|
+
console.warn("Invalid selection: " + c);
|
|
677
|
+
}, h = (c, m = !0) => {
|
|
678
|
+
const p = Array.isArray(c) ? c : [c], w = p.map((x) => t.getAnnotation(x)).filter(Boolean);
|
|
679
|
+
o({ selected: w.map(({ id: x }) => ({ id: x, editable: m })) }), w.length !== p.length && console.warn("Invalid selection", c);
|
|
680
|
+
}, v = (c) => {
|
|
679
681
|
if (i.selected.length === 0)
|
|
680
682
|
return !1;
|
|
681
683
|
const { selected: m } = i;
|
|
682
|
-
m.filter(({ id:
|
|
684
|
+
m.filter(({ id: p }) => c.includes(p)).length > 0 && o({ selected: m.filter(({ id: p }) => !c.includes(p)) });
|
|
683
685
|
};
|
|
684
|
-
return t.observe(({ changes:
|
|
686
|
+
return t.observe(({ changes: c }) => v((c.deleted || []).map((m) => m.id))), {
|
|
685
687
|
clear: r,
|
|
686
688
|
clickSelect: u,
|
|
687
689
|
get selected() {
|
|
@@ -695,32 +697,64 @@ const Te = (t) => {
|
|
|
695
697
|
setSelected: h,
|
|
696
698
|
subscribe: n
|
|
697
699
|
};
|
|
698
|
-
},
|
|
700
|
+
}, Ie = (t, e) => typeof e == "function" ? e(t) || "EDIT" : e || "EDIT";
|
|
701
|
+
let J;
|
|
702
|
+
const Me = new Uint8Array(16);
|
|
703
|
+
function Ue() {
|
|
704
|
+
if (!J && (J = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !J))
|
|
705
|
+
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
706
|
+
return J(Me);
|
|
707
|
+
}
|
|
708
|
+
const M = [];
|
|
699
709
|
for (let t = 0; t < 256; ++t)
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
710
|
+
M.push((t + 256).toString(16).slice(1));
|
|
711
|
+
function Ve(t, e = 0) {
|
|
712
|
+
return M[t[e + 0]] + M[t[e + 1]] + M[t[e + 2]] + M[t[e + 3]] + "-" + M[t[e + 4]] + M[t[e + 5]] + "-" + M[t[e + 6]] + M[t[e + 7]] + "-" + M[t[e + 8]] + M[t[e + 9]] + "-" + M[t[e + 10]] + M[t[e + 11]] + M[t[e + 12]] + M[t[e + 13]] + M[t[e + 14]] + M[t[e + 15]];
|
|
713
|
+
}
|
|
714
|
+
const _e = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), Lt = {
|
|
715
|
+
randomUUID: _e
|
|
716
|
+
};
|
|
717
|
+
function Xe(t, e, n) {
|
|
718
|
+
if (Lt.randomUUID && !e && !t)
|
|
719
|
+
return Lt.randomUUID();
|
|
720
|
+
t = t || {};
|
|
721
|
+
const o = t.random || (t.rng || Ue)();
|
|
722
|
+
if (o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128, e) {
|
|
723
|
+
n = n || 0;
|
|
724
|
+
for (let i = 0; i < 16; ++i)
|
|
725
|
+
e[n + i] = o[i];
|
|
726
|
+
return e;
|
|
727
|
+
}
|
|
728
|
+
return Ve(o);
|
|
729
|
+
}
|
|
730
|
+
const De = (t, e, n, o) => ({
|
|
731
|
+
id: Xe(),
|
|
732
|
+
annotation: t.id,
|
|
733
|
+
created: n || /* @__PURE__ */ new Date(),
|
|
734
|
+
creator: o,
|
|
735
|
+
...e
|
|
736
|
+
}), ke = (t, e) => {
|
|
703
737
|
const n = new Set(t.bodies.map((o) => o.id));
|
|
704
738
|
return e.bodies.filter((o) => !n.has(o.id));
|
|
705
|
-
},
|
|
739
|
+
}, Ye = (t, e) => {
|
|
706
740
|
const n = new Set(e.bodies.map((o) => o.id));
|
|
707
741
|
return t.bodies.filter((o) => !n.has(o.id));
|
|
708
|
-
},
|
|
742
|
+
}, He = (t, e) => e.bodies.map((n) => {
|
|
709
743
|
const o = t.bodies.find((i) => i.id === n.id);
|
|
710
|
-
return { newBody: n, oldBody: o && !
|
|
711
|
-
}).filter(({ oldBody: n }) => n).map(({ oldBody: n, newBody: o }) => ({ oldBody: n, newBody: o })),
|
|
712
|
-
const n =
|
|
744
|
+
return { newBody: n, oldBody: o && !H(o, n) ? o : void 0 };
|
|
745
|
+
}).filter(({ oldBody: n }) => n).map(({ oldBody: n, newBody: o }) => ({ oldBody: n, newBody: o })), $e = (t, e) => !H(t.target, e.target), kt = (t, e) => {
|
|
746
|
+
const n = ke(t, e), o = Ye(t, e), i = He(t, e);
|
|
713
747
|
return {
|
|
714
748
|
oldValue: t,
|
|
715
749
|
newValue: e,
|
|
716
750
|
bodiesCreated: n.length > 0 ? n : void 0,
|
|
717
751
|
bodiesDeleted: o.length > 0 ? o : void 0,
|
|
718
752
|
bodiesUpdated: i.length > 0 ? i : void 0,
|
|
719
|
-
targetUpdated:
|
|
753
|
+
targetUpdated: $e(t, e) ? { oldTarget: t.target, newTarget: e.target } : void 0
|
|
720
754
|
};
|
|
721
755
|
};
|
|
722
|
-
var
|
|
723
|
-
const
|
|
756
|
+
var L = /* @__PURE__ */ ((t) => (t.LOCAL = "LOCAL", t.REMOTE = "REMOTE", t))(L || {});
|
|
757
|
+
const Pe = (t, e) => {
|
|
724
758
|
var n, o;
|
|
725
759
|
const { changes: i, origin: r } = e;
|
|
726
760
|
if (!(!t.options.origin || t.options.origin === r))
|
|
@@ -728,7 +762,7 @@ const Ve = (t, e) => {
|
|
|
728
762
|
if (t.options.ignore) {
|
|
729
763
|
const { ignore: s } = t.options, a = (u) => u && u.length > 0;
|
|
730
764
|
if (!(a(i.created) || a(i.deleted))) {
|
|
731
|
-
const u = (n = i.updated) == null ? void 0 : n.some((
|
|
765
|
+
const u = (n = i.updated) == null ? void 0 : n.some((v) => a(v.bodiesCreated) || a(v.bodiesDeleted) || a(v.bodiesUpdated)), h = (o = i.updated) == null ? void 0 : o.some((v) => v.targetUpdated);
|
|
732
766
|
if (s === "BODY_ONLY" && u && !h || s === "TARGET_ONLY" && h && !u)
|
|
733
767
|
return !1;
|
|
734
768
|
}
|
|
@@ -742,32 +776,32 @@ const Ve = (t, e) => {
|
|
|
742
776
|
return !!(Array.isArray(t.options.annotations) ? t.options.annotations : [t.options.annotations]).find((a) => s.has(a));
|
|
743
777
|
} else
|
|
744
778
|
return !0;
|
|
745
|
-
},
|
|
746
|
-
const n = new Set((t.created || []).map((
|
|
747
|
-
...(t.created || []).filter((
|
|
779
|
+
}, ze = (t, e) => {
|
|
780
|
+
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)), r = new Set((e.deleted || []).map((c) => c.id)), s = 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)), u = [
|
|
781
|
+
...(t.created || []).filter((c) => !r.has(c.id)).map((c) => s.has(c.id) ? e.updated.find(({ oldValue: m }) => m.id === c.id).newValue : c),
|
|
748
782
|
...e.created || []
|
|
749
783
|
], h = [
|
|
750
|
-
...(t.deleted || []).filter((
|
|
751
|
-
...(e.deleted || []).filter((
|
|
752
|
-
],
|
|
753
|
-
...(t.updated || []).filter(({ newValue:
|
|
754
|
-
const { oldValue: m, newValue:
|
|
755
|
-
if (s.has(
|
|
756
|
-
const
|
|
757
|
-
return
|
|
784
|
+
...(t.deleted || []).filter((c) => !i.has(c.id)),
|
|
785
|
+
...(e.deleted || []).filter((c) => !n.has(c.id))
|
|
786
|
+
], v = [
|
|
787
|
+
...(t.updated || []).filter(({ newValue: c }) => !r.has(c.id)).map((c) => {
|
|
788
|
+
const { oldValue: m, newValue: p } = c;
|
|
789
|
+
if (s.has(p.id)) {
|
|
790
|
+
const w = e.updated.find((x) => x.oldValue.id === p.id).newValue;
|
|
791
|
+
return kt(m, w);
|
|
758
792
|
} else
|
|
759
|
-
return
|
|
793
|
+
return c;
|
|
760
794
|
}),
|
|
761
|
-
...(e.updated || []).filter(({ oldValue:
|
|
795
|
+
...(e.updated || []).filter(({ oldValue: c }) => !a.has(c.id))
|
|
762
796
|
];
|
|
763
|
-
return { created: u, deleted: h, updated:
|
|
764
|
-
},
|
|
765
|
-
const t = /* @__PURE__ */ new Map(), e = /* @__PURE__ */ new Map(), n = [], o = (
|
|
766
|
-
const S = n.findIndex((E) => E.onChange ==
|
|
797
|
+
return { created: u, deleted: h, updated: v };
|
|
798
|
+
}, Fe = (t) => t.id !== void 0, We = () => {
|
|
799
|
+
const t = /* @__PURE__ */ new Map(), e = /* @__PURE__ */ new Map(), n = [], o = (g, S = {}) => n.push({ onChange: g, options: S }), i = (g) => {
|
|
800
|
+
const S = n.findIndex((E) => E.onChange == g);
|
|
767
801
|
S > -1 && n.splice(S, 1);
|
|
768
|
-
}, r = (
|
|
802
|
+
}, r = (g, S) => {
|
|
769
803
|
const E = {
|
|
770
|
-
origin:
|
|
804
|
+
origin: g,
|
|
771
805
|
changes: {
|
|
772
806
|
created: S.created || [],
|
|
773
807
|
updated: S.updated || [],
|
|
@@ -776,137 +810,137 @@ const Ve = (t, e) => {
|
|
|
776
810
|
state: [...t.values()]
|
|
777
811
|
};
|
|
778
812
|
n.forEach((C) => {
|
|
779
|
-
|
|
813
|
+
Pe(C, E) && C.onChange(E);
|
|
780
814
|
});
|
|
781
|
-
}, s = (
|
|
782
|
-
if (t.get(
|
|
783
|
-
throw Error(`Cannot add annotation ${
|
|
784
|
-
t.set(
|
|
785
|
-
}, a = (
|
|
786
|
-
const E = typeof
|
|
787
|
-
if (
|
|
788
|
-
const B =
|
|
789
|
-
return C === E.id ? t.set(C, E) : (t.delete(C), t.set(E.id, E)),
|
|
815
|
+
}, s = (g, S = L.LOCAL) => {
|
|
816
|
+
if (t.get(g.id))
|
|
817
|
+
throw Error(`Cannot add annotation ${g.id} - exists already`);
|
|
818
|
+
t.set(g.id, g), g.bodies.forEach((E) => e.set(E.id, g.id)), r(S, { created: [g] });
|
|
819
|
+
}, a = (g, S) => {
|
|
820
|
+
const E = typeof g == "string" ? S : g, C = typeof g == "string" ? g : g.id, N = t.get(C);
|
|
821
|
+
if (N) {
|
|
822
|
+
const B = kt(N, E);
|
|
823
|
+
return C === E.id ? t.set(C, E) : (t.delete(C), t.set(E.id, E)), N.bodies.forEach((_) => e.delete(_.id)), E.bodies.forEach((_) => e.set(_.id, E.id)), B;
|
|
790
824
|
} else
|
|
791
825
|
console.warn(`Cannot update annotation ${C} - does not exist`);
|
|
792
|
-
}, u = (
|
|
793
|
-
const C =
|
|
794
|
-
|
|
795
|
-
}, h = (
|
|
796
|
-
const E =
|
|
797
|
-
const B = a(
|
|
826
|
+
}, u = (g, S = L.LOCAL, E = L.LOCAL) => {
|
|
827
|
+
const C = Fe(S) ? E : S, N = a(g, S);
|
|
828
|
+
N && r(C, { updated: [N] });
|
|
829
|
+
}, h = (g, S = L.LOCAL) => {
|
|
830
|
+
const E = g.reduce((C, N) => {
|
|
831
|
+
const B = a(N);
|
|
798
832
|
return B ? [...C, B] : C;
|
|
799
833
|
}, []);
|
|
800
834
|
E.length > 0 && r(S, { updated: E });
|
|
801
|
-
},
|
|
802
|
-
const E = t.get(
|
|
835
|
+
}, v = (g, S = L.LOCAL) => {
|
|
836
|
+
const E = t.get(g.annotation);
|
|
803
837
|
if (E) {
|
|
804
838
|
const C = {
|
|
805
839
|
...E,
|
|
806
|
-
bodies: [...E.bodies,
|
|
840
|
+
bodies: [...E.bodies, g]
|
|
807
841
|
};
|
|
808
|
-
t.set(E.id, C), e.set(
|
|
842
|
+
t.set(E.id, C), e.set(g.id, C.id), r(S, { updated: [{
|
|
809
843
|
oldValue: E,
|
|
810
844
|
newValue: C,
|
|
811
|
-
bodiesCreated: [
|
|
845
|
+
bodiesCreated: [g]
|
|
812
846
|
}] });
|
|
813
847
|
} else
|
|
814
|
-
console.warn(`Attempt to add body to missing annotation: ${
|
|
815
|
-
},
|
|
848
|
+
console.warn(`Attempt to add body to missing annotation: ${g.annotation}`);
|
|
849
|
+
}, c = () => [...t.values()], m = (g = L.LOCAL) => {
|
|
816
850
|
const S = [...t.values()];
|
|
817
|
-
t.clear(), e.clear(), r(
|
|
818
|
-
},
|
|
851
|
+
t.clear(), e.clear(), r(g, { deleted: S });
|
|
852
|
+
}, p = (g, S = !0, E = L.LOCAL) => {
|
|
819
853
|
if (S) {
|
|
820
854
|
const C = [...t.values()];
|
|
821
|
-
t.clear(), e.clear(),
|
|
822
|
-
t.set(
|
|
823
|
-
}), r(E, { created:
|
|
855
|
+
t.clear(), e.clear(), g.forEach((N) => {
|
|
856
|
+
t.set(N.id, N), N.bodies.forEach((B) => e.set(B.id, N.id));
|
|
857
|
+
}), r(E, { created: g, deleted: C });
|
|
824
858
|
} else {
|
|
825
|
-
const C =
|
|
859
|
+
const C = g.reduce((N, B) => {
|
|
826
860
|
const _ = t.get(B.id);
|
|
827
|
-
return _ ? [...
|
|
861
|
+
return _ ? [...N, _] : N;
|
|
828
862
|
}, []);
|
|
829
863
|
if (C.length > 0)
|
|
830
|
-
throw Error(`Bulk insert would overwrite the following annotations: ${C.map((
|
|
831
|
-
|
|
832
|
-
t.set(
|
|
833
|
-
}), r(E, { created:
|
|
864
|
+
throw Error(`Bulk insert would overwrite the following annotations: ${C.map((N) => N.id).join(", ")}`);
|
|
865
|
+
g.forEach((N) => {
|
|
866
|
+
t.set(N.id, N), N.bodies.forEach((B) => e.set(B.id, N.id));
|
|
867
|
+
}), r(E, { created: g });
|
|
834
868
|
}
|
|
835
|
-
},
|
|
836
|
-
const S = typeof
|
|
869
|
+
}, w = (g) => {
|
|
870
|
+
const S = typeof g == "string" ? g : g.id, E = t.get(S);
|
|
837
871
|
if (E)
|
|
838
872
|
return t.delete(S), E.bodies.forEach((C) => e.delete(C.id)), E;
|
|
839
873
|
console.warn(`Attempt to delete missing annotation: ${S}`);
|
|
840
|
-
}, x = (
|
|
841
|
-
const E =
|
|
874
|
+
}, x = (g, S = L.LOCAL) => {
|
|
875
|
+
const E = w(g);
|
|
842
876
|
E && r(S, { deleted: [E] });
|
|
843
|
-
},
|
|
844
|
-
const E =
|
|
845
|
-
const B =
|
|
877
|
+
}, y = (g, S = L.LOCAL) => {
|
|
878
|
+
const E = g.reduce((C, N) => {
|
|
879
|
+
const B = w(N);
|
|
846
880
|
return B ? [...C, B] : C;
|
|
847
881
|
}, []);
|
|
848
882
|
E.length > 0 && r(S, { deleted: E });
|
|
849
|
-
},
|
|
850
|
-
const E = t.get(
|
|
883
|
+
}, l = (g, S = L.LOCAL) => {
|
|
884
|
+
const E = t.get(g.annotation);
|
|
851
885
|
if (E) {
|
|
852
|
-
const C = E.bodies.find((
|
|
886
|
+
const C = E.bodies.find((N) => N.id === g.id);
|
|
853
887
|
if (C) {
|
|
854
888
|
e.delete(C.id);
|
|
855
|
-
const
|
|
889
|
+
const N = {
|
|
856
890
|
...E,
|
|
857
|
-
bodies: E.bodies.filter((B) => B.id !==
|
|
891
|
+
bodies: E.bodies.filter((B) => B.id !== g.id)
|
|
858
892
|
};
|
|
859
|
-
t.set(E.id,
|
|
893
|
+
t.set(E.id, N), r(S, { updated: [{
|
|
860
894
|
oldValue: E,
|
|
861
|
-
newValue:
|
|
895
|
+
newValue: N,
|
|
862
896
|
bodiesDeleted: [C]
|
|
863
897
|
}] });
|
|
864
898
|
} else
|
|
865
|
-
console.warn(`Attempt to delete missing body ${
|
|
899
|
+
console.warn(`Attempt to delete missing body ${g.id} from annotation ${g.annotation}`);
|
|
866
900
|
} else
|
|
867
|
-
console.warn(`Attempt to delete body from missing annotation ${
|
|
868
|
-
}, d = (
|
|
869
|
-
const S = t.get(
|
|
901
|
+
console.warn(`Attempt to delete body from missing annotation ${g.annotation}`);
|
|
902
|
+
}, d = (g) => {
|
|
903
|
+
const S = t.get(g);
|
|
870
904
|
return S ? { ...S } : void 0;
|
|
871
|
-
}, f = (
|
|
872
|
-
const S = e.get(
|
|
905
|
+
}, f = (g) => {
|
|
906
|
+
const S = e.get(g);
|
|
873
907
|
if (S) {
|
|
874
|
-
const E = d(S).bodies.find((C) => C.id ===
|
|
908
|
+
const E = d(S).bodies.find((C) => C.id === g);
|
|
875
909
|
if (E)
|
|
876
910
|
return E;
|
|
877
|
-
console.error(`Store integrity error: body ${
|
|
911
|
+
console.error(`Store integrity error: body ${g} in index, but not in annotation`);
|
|
878
912
|
} else
|
|
879
|
-
console.warn(`Attempt to retrieve missing body: ${
|
|
880
|
-
},
|
|
881
|
-
if (
|
|
913
|
+
console.warn(`Attempt to retrieve missing body: ${g}`);
|
|
914
|
+
}, b = (g, S) => {
|
|
915
|
+
if (g.annotation !== S.annotation)
|
|
882
916
|
throw "Annotation integrity violation: annotation ID must be the same when updating bodies";
|
|
883
|
-
const E = t.get(
|
|
917
|
+
const E = t.get(g.annotation);
|
|
884
918
|
if (E) {
|
|
885
|
-
const C = E.bodies.find((B) => B.id ===
|
|
919
|
+
const C = E.bodies.find((B) => B.id === g.id), N = {
|
|
886
920
|
...E,
|
|
887
921
|
bodies: E.bodies.map((B) => B.id === C.id ? S : B)
|
|
888
922
|
};
|
|
889
|
-
return t.set(E.id,
|
|
923
|
+
return t.set(E.id, N), C.id !== S.id && (e.delete(C.id), e.set(S.id, N.id)), {
|
|
890
924
|
oldValue: E,
|
|
891
|
-
newValue:
|
|
925
|
+
newValue: N,
|
|
892
926
|
bodiesUpdated: [{ oldBody: C, newBody: S }]
|
|
893
927
|
};
|
|
894
928
|
} else
|
|
895
|
-
console.warn(`Attempt to add body to missing annotation ${
|
|
896
|
-
}, A = (
|
|
897
|
-
const C =
|
|
929
|
+
console.warn(`Attempt to add body to missing annotation ${g.annotation}`);
|
|
930
|
+
}, A = (g, S, E = L.LOCAL) => {
|
|
931
|
+
const C = b(g, S);
|
|
898
932
|
C && r(E, { updated: [C] });
|
|
899
|
-
}, R = (
|
|
900
|
-
const E =
|
|
933
|
+
}, R = (g, S = L.LOCAL) => {
|
|
934
|
+
const E = g.map((C) => b({ id: C.id, annotation: C.annotation }, C)).filter(Boolean);
|
|
901
935
|
r(S, { updated: E });
|
|
902
|
-
}, T = (
|
|
903
|
-
const S = t.get(
|
|
936
|
+
}, T = (g) => {
|
|
937
|
+
const S = t.get(g.annotation);
|
|
904
938
|
if (S) {
|
|
905
939
|
const E = {
|
|
906
940
|
...S,
|
|
907
941
|
target: {
|
|
908
942
|
...S.target,
|
|
909
|
-
...
|
|
943
|
+
...g
|
|
910
944
|
}
|
|
911
945
|
};
|
|
912
946
|
return t.set(S.id, E), {
|
|
@@ -914,40 +948,40 @@ const Ve = (t, e) => {
|
|
|
914
948
|
newValue: E,
|
|
915
949
|
targetUpdated: {
|
|
916
950
|
oldTarget: S.target,
|
|
917
|
-
newTarget:
|
|
951
|
+
newTarget: g
|
|
918
952
|
}
|
|
919
953
|
};
|
|
920
954
|
} else
|
|
921
|
-
console.warn(`Attempt to update target on missing annotation: ${
|
|
955
|
+
console.warn(`Attempt to update target on missing annotation: ${g.annotation}`);
|
|
922
956
|
};
|
|
923
957
|
return {
|
|
924
958
|
addAnnotation: s,
|
|
925
|
-
addBody:
|
|
926
|
-
all:
|
|
927
|
-
bulkAddAnnotation:
|
|
928
|
-
bulkDeleteAnnotation:
|
|
959
|
+
addBody: v,
|
|
960
|
+
all: c,
|
|
961
|
+
bulkAddAnnotation: p,
|
|
962
|
+
bulkDeleteAnnotation: y,
|
|
929
963
|
bulkUpdateAnnotation: h,
|
|
930
964
|
bulkUpdateBodies: R,
|
|
931
|
-
bulkUpdateTargets: (
|
|
932
|
-
const E =
|
|
965
|
+
bulkUpdateTargets: (g, S = L.LOCAL) => {
|
|
966
|
+
const E = g.map((C) => T(C)).filter(Boolean);
|
|
933
967
|
E.length > 0 && r(S, { updated: E });
|
|
934
968
|
},
|
|
935
969
|
clear: m,
|
|
936
970
|
deleteAnnotation: x,
|
|
937
|
-
deleteBody:
|
|
971
|
+
deleteBody: l,
|
|
938
972
|
getAnnotation: d,
|
|
939
973
|
getBody: f,
|
|
940
974
|
observe: o,
|
|
941
975
|
unobserve: i,
|
|
942
976
|
updateAnnotation: u,
|
|
943
977
|
updateBody: A,
|
|
944
|
-
updateTarget: (
|
|
945
|
-
const E = T(
|
|
978
|
+
updateTarget: (g, S = L.LOCAL) => {
|
|
979
|
+
const E = T(g);
|
|
946
980
|
E && r(S, { updated: [E] });
|
|
947
981
|
}
|
|
948
982
|
};
|
|
949
983
|
};
|
|
950
|
-
let
|
|
984
|
+
let qe = () => ({
|
|
951
985
|
emit(t, ...e) {
|
|
952
986
|
for (let n = 0, o = this.events[t] || [], i = o.length; n < i; n++)
|
|
953
987
|
o[n](...e);
|
|
@@ -961,123 +995,123 @@ let ke = () => ({
|
|
|
961
995
|
};
|
|
962
996
|
}
|
|
963
997
|
});
|
|
964
|
-
const
|
|
965
|
-
const e =
|
|
998
|
+
const je = 250, Ge = (t) => {
|
|
999
|
+
const e = qe(), n = [];
|
|
966
1000
|
let o = -1, i = !1, r = 0;
|
|
967
|
-
const s = (
|
|
1001
|
+
const s = (p) => {
|
|
968
1002
|
if (!i) {
|
|
969
|
-
const { changes:
|
|
970
|
-
if (x - r >
|
|
971
|
-
n.splice(o + 1), n.push(
|
|
1003
|
+
const { changes: w } = p, x = performance.now();
|
|
1004
|
+
if (x - r > je)
|
|
1005
|
+
n.splice(o + 1), n.push(w), o = n.length - 1;
|
|
972
1006
|
else {
|
|
973
|
-
const
|
|
974
|
-
n[
|
|
1007
|
+
const y = n.length - 1;
|
|
1008
|
+
n[y] = ze(n[y], w);
|
|
975
1009
|
}
|
|
976
1010
|
r = x;
|
|
977
1011
|
}
|
|
978
1012
|
i = !1;
|
|
979
1013
|
};
|
|
980
|
-
t.observe(s, { origin:
|
|
981
|
-
const a = (
|
|
1014
|
+
t.observe(s, { origin: L.LOCAL });
|
|
1015
|
+
const a = (p) => p && p.length > 0 && t.bulkDeleteAnnotation(p), u = (p) => p && p.length > 0 && t.bulkAddAnnotation(p, !1), h = (p) => p && p.length > 0 && t.bulkUpdateAnnotation(p.map(({ oldValue: w }) => w)), v = (p) => p && p.length > 0 && t.bulkUpdateAnnotation(p.map(({ newValue: w }) => w)), c = (p) => p && p.length > 0 && t.bulkAddAnnotation(p, !1), m = (p) => p && p.length > 0 && t.bulkDeleteAnnotation(p);
|
|
982
1016
|
return {
|
|
983
1017
|
canRedo: () => n.length - 1 > o,
|
|
984
1018
|
canUndo: () => o > -1,
|
|
985
1019
|
destroy: () => t.unobserve(s),
|
|
986
|
-
on: (
|
|
1020
|
+
on: (p, w) => e.on(p, w),
|
|
987
1021
|
redo: () => {
|
|
988
1022
|
if (n.length - 1 > o) {
|
|
989
1023
|
i = !0;
|
|
990
|
-
const { created:
|
|
991
|
-
u(
|
|
1024
|
+
const { created: p, updated: w, deleted: x } = n[o + 1];
|
|
1025
|
+
u(p), v(w), m(x), e.emit("redo", n[o + 1]), o += 1;
|
|
992
1026
|
}
|
|
993
1027
|
},
|
|
994
1028
|
undo: () => {
|
|
995
1029
|
if (o > -1) {
|
|
996
1030
|
i = !0;
|
|
997
|
-
const { created:
|
|
998
|
-
a(
|
|
1031
|
+
const { created: p, updated: w, deleted: x } = n[o];
|
|
1032
|
+
a(p), h(w), c(x), e.emit("undo", n[o]), o -= 1;
|
|
999
1033
|
}
|
|
1000
1034
|
}
|
|
1001
1035
|
};
|
|
1002
|
-
},
|
|
1003
|
-
const { subscribe: t, set: e } =
|
|
1036
|
+
}, Ke = () => {
|
|
1037
|
+
const { subscribe: t, set: e } = gt([]);
|
|
1004
1038
|
return {
|
|
1005
1039
|
subscribe: t,
|
|
1006
1040
|
set: e
|
|
1007
1041
|
};
|
|
1008
|
-
},
|
|
1042
|
+
}, Qe = (t, e, n, o) => {
|
|
1009
1043
|
const { store: i, selection: r, hover: s, viewport: a } = t, u = /* @__PURE__ */ new Map();
|
|
1010
|
-
let h = [],
|
|
1011
|
-
const m = (
|
|
1012
|
-
u.has(
|
|
1013
|
-
},
|
|
1014
|
-
const f = u.get(
|
|
1044
|
+
let h = [], v, c;
|
|
1045
|
+
const m = (l, d) => {
|
|
1046
|
+
u.has(l) ? u.get(l).push(d) : u.set(l, [d]);
|
|
1047
|
+
}, p = (l, d) => {
|
|
1048
|
+
const f = u.get(l);
|
|
1015
1049
|
f && f.indexOf(d) > 0 && f.splice(f.indexOf(d), 1);
|
|
1016
|
-
},
|
|
1017
|
-
u.has(
|
|
1018
|
-
u.get(
|
|
1050
|
+
}, w = (l, d, f) => {
|
|
1051
|
+
u.has(l) && setTimeout(() => {
|
|
1052
|
+
u.get(l).forEach((b) => {
|
|
1019
1053
|
if (n) {
|
|
1020
1054
|
const A = Array.isArray(d) ? d.map((T) => n.serialize(T)) : n.serialize(d), R = f ? f instanceof PointerEvent ? f : n.serialize(f) : void 0;
|
|
1021
|
-
|
|
1055
|
+
b(A, R);
|
|
1022
1056
|
} else
|
|
1023
|
-
|
|
1057
|
+
b(d, f);
|
|
1024
1058
|
});
|
|
1025
1059
|
}, 1);
|
|
1026
1060
|
}, x = () => {
|
|
1027
|
-
const { selected:
|
|
1061
|
+
const { selected: l } = r, d = (l || []).map(({ id: f }) => i.getAnnotation(f));
|
|
1028
1062
|
d.forEach((f) => {
|
|
1029
|
-
const
|
|
1030
|
-
(!
|
|
1063
|
+
const b = h.find((A) => A.id === f.id);
|
|
1064
|
+
(!b || !H(b, f)) && w("updateAnnotation", f, b);
|
|
1031
1065
|
}), h = h.map((f) => d.find(({ id: A }) => A === f.id) || f);
|
|
1032
1066
|
};
|
|
1033
|
-
r.subscribe(({ selected:
|
|
1034
|
-
if (!(h.length === 0 &&
|
|
1035
|
-
if (h.length === 0 &&
|
|
1036
|
-
h =
|
|
1037
|
-
else if (h.length > 0 &&
|
|
1067
|
+
r.subscribe(({ selected: l }) => {
|
|
1068
|
+
if (!(h.length === 0 && l.length === 0)) {
|
|
1069
|
+
if (h.length === 0 && l.length > 0)
|
|
1070
|
+
h = l.map(({ id: d }) => i.getAnnotation(d));
|
|
1071
|
+
else if (h.length > 0 && l.length === 0)
|
|
1038
1072
|
h.forEach((d) => {
|
|
1039
1073
|
const f = i.getAnnotation(d.id);
|
|
1040
|
-
f && !
|
|
1074
|
+
f && !H(f, d) && w("updateAnnotation", f, d);
|
|
1041
1075
|
}), h = [];
|
|
1042
1076
|
else {
|
|
1043
|
-
const d = new Set(h.map((
|
|
1044
|
-
h.filter((
|
|
1045
|
-
const A = i.getAnnotation(
|
|
1046
|
-
A && !
|
|
1077
|
+
const d = new Set(h.map((b) => b.id)), f = new Set(l.map(({ id: b }) => b));
|
|
1078
|
+
h.filter((b) => !f.has(b.id)).forEach((b) => {
|
|
1079
|
+
const A = i.getAnnotation(b.id);
|
|
1080
|
+
A && !H(A, b) && w("updateAnnotation", A, b);
|
|
1047
1081
|
}), h = [
|
|
1048
1082
|
// Remove annotations that were deselected
|
|
1049
|
-
...h.filter((
|
|
1083
|
+
...h.filter((b) => f.has(b.id)),
|
|
1050
1084
|
// Add editable annotations that were selected
|
|
1051
|
-
...
|
|
1085
|
+
...l.filter(({ id: b }) => !d.has(b)).map(({ id: b }) => i.getAnnotation(b))
|
|
1052
1086
|
];
|
|
1053
1087
|
}
|
|
1054
|
-
|
|
1088
|
+
w("selectionChanged", h);
|
|
1055
1089
|
}
|
|
1056
|
-
}), s.subscribe((
|
|
1057
|
-
!
|
|
1058
|
-
}), a == null || a.subscribe((
|
|
1059
|
-
o && (
|
|
1060
|
-
const { created: d, deleted: f } =
|
|
1061
|
-
(d || []).forEach((
|
|
1062
|
-
...
|
|
1063
|
-
...
|
|
1064
|
-
...
|
|
1065
|
-
].length > 0).forEach(({ oldValue:
|
|
1066
|
-
const R = h.find((T) => T.id ===
|
|
1067
|
-
h = h.map((T) => T.id ===
|
|
1090
|
+
}), s.subscribe((l) => {
|
|
1091
|
+
!v && l ? w("mouseEnterAnnotation", i.getAnnotation(l)) : v && !l ? w("mouseLeaveAnnotation", i.getAnnotation(v)) : v && l && (w("mouseLeaveAnnotation", i.getAnnotation(v)), w("mouseEnterAnnotation", i.getAnnotation(l))), v = l;
|
|
1092
|
+
}), a == null || a.subscribe((l) => w("viewportIntersect", l.map((d) => i.getAnnotation(d)))), i.observe((l) => {
|
|
1093
|
+
o && (c && clearTimeout(c), c = setTimeout(x, 1e3));
|
|
1094
|
+
const { created: d, deleted: f } = l.changes;
|
|
1095
|
+
(d || []).forEach((b) => w("createAnnotation", b)), (f || []).forEach((b) => w("deleteAnnotation", b)), (l.changes.updated || []).filter((b) => [
|
|
1096
|
+
...b.bodiesCreated || [],
|
|
1097
|
+
...b.bodiesDeleted || [],
|
|
1098
|
+
...b.bodiesUpdated || []
|
|
1099
|
+
].length > 0).forEach(({ oldValue: b, newValue: A }) => {
|
|
1100
|
+
const R = h.find((T) => T.id === b.id) || b;
|
|
1101
|
+
h = h.map((T) => T.id === b.id ? A : T), w("updateAnnotation", A, R);
|
|
1068
1102
|
});
|
|
1069
|
-
}, { origin:
|
|
1103
|
+
}, { origin: L.LOCAL }), i.observe((l) => {
|
|
1070
1104
|
if (h) {
|
|
1071
|
-
const d = new Set(h.map((
|
|
1072
|
-
f.length > 0 && (h = h.map((
|
|
1105
|
+
const d = new Set(h.map((b) => b.id)), f = (l.changes.updated || []).filter(({ newValue: b }) => d.has(b.id)).map(({ newValue: b }) => b);
|
|
1106
|
+
f.length > 0 && (h = h.map((b) => f.find((R) => R.id === b.id) || b));
|
|
1073
1107
|
}
|
|
1074
|
-
}, { origin:
|
|
1075
|
-
const
|
|
1108
|
+
}, { origin: L.REMOTE });
|
|
1109
|
+
const y = (l) => (d) => {
|
|
1076
1110
|
const { updated: f } = d;
|
|
1077
|
-
|
|
1111
|
+
l ? (f || []).forEach((b) => w("updateAnnotation", b.oldValue, b.newValue)) : (f || []).forEach((b) => w("updateAnnotation", b.newValue, b.oldValue));
|
|
1078
1112
|
};
|
|
1079
|
-
return e.on("undo",
|
|
1080
|
-
},
|
|
1113
|
+
return e.on("undo", y(!0)), e.on("redo", y(!1)), { on: m, off: p, emit: w };
|
|
1114
|
+
}, Je = (t) => (e) => e.reduce((n, o) => {
|
|
1081
1115
|
const { parsed: i, error: r } = t.parse(o);
|
|
1082
1116
|
return r ? {
|
|
1083
1117
|
parsed: n.parsed,
|
|
@@ -1088,45 +1122,45 @@ const Ye = 250, De = (t) => {
|
|
|
1088
1122
|
} : {
|
|
1089
1123
|
...n
|
|
1090
1124
|
};
|
|
1091
|
-
}, { parsed: [], failed: [] }),
|
|
1092
|
-
const { store: o, selection: i } = t, r = (
|
|
1125
|
+
}, { parsed: [], failed: [] }), Ze = (t, e, n) => {
|
|
1126
|
+
const { store: o, selection: i } = t, r = (y) => {
|
|
1093
1127
|
if (n) {
|
|
1094
|
-
const { parsed:
|
|
1095
|
-
|
|
1128
|
+
const { parsed: l, error: d } = n.parse(y);
|
|
1129
|
+
l ? o.addAnnotation(l, L.REMOTE) : console.error(d);
|
|
1096
1130
|
} else
|
|
1097
|
-
o.addAnnotation(
|
|
1098
|
-
}, s = () => i.clear(), a = () => o.clear(), u = (
|
|
1099
|
-
const
|
|
1100
|
-
return n &&
|
|
1101
|
-
}, h = () => n ? o.all().map(n.serialize) : o.all(),
|
|
1102
|
-
var
|
|
1103
|
-
const
|
|
1104
|
-
return n ?
|
|
1105
|
-
},
|
|
1106
|
-
if (typeof
|
|
1107
|
-
const
|
|
1108
|
-
if (o.deleteAnnotation(
|
|
1109
|
-
return n ? n.serialize(
|
|
1131
|
+
o.addAnnotation(y, L.REMOTE);
|
|
1132
|
+
}, s = () => i.clear(), a = () => o.clear(), u = (y) => {
|
|
1133
|
+
const l = o.getAnnotation(y);
|
|
1134
|
+
return n && l ? n.serialize(l) : l;
|
|
1135
|
+
}, h = () => n ? o.all().map(n.serialize) : o.all(), v = () => {
|
|
1136
|
+
var y;
|
|
1137
|
+
const l = (((y = i.selected) == null ? void 0 : y.map((d) => d.id)) || []).map((d) => o.getAnnotation(d)).filter(Boolean);
|
|
1138
|
+
return n ? l.map(n.serialize) : l;
|
|
1139
|
+
}, c = (y, l = !0) => fetch(y).then((d) => d.json()).then((d) => (p(d, l), d)), m = (y) => {
|
|
1140
|
+
if (typeof y == "string") {
|
|
1141
|
+
const l = o.getAnnotation(y);
|
|
1142
|
+
if (o.deleteAnnotation(y), l)
|
|
1143
|
+
return n ? n.serialize(l) : l;
|
|
1110
1144
|
} else {
|
|
1111
|
-
const
|
|
1112
|
-
if (
|
|
1113
|
-
return o.deleteAnnotation(
|
|
1145
|
+
const l = n ? n.parse(y).parsed : y;
|
|
1146
|
+
if (l)
|
|
1147
|
+
return o.deleteAnnotation(l), y;
|
|
1114
1148
|
}
|
|
1115
|
-
},
|
|
1149
|
+
}, p = (y, l = !0) => {
|
|
1116
1150
|
if (n) {
|
|
1117
|
-
const { parsed: d, failed: f } =
|
|
1118
|
-
f.length > 0 && console.warn(`Discarded ${f.length} invalid annotations`, f), o.bulkAddAnnotation(d,
|
|
1151
|
+
const { parsed: d, failed: f } = Je(n)(y);
|
|
1152
|
+
f.length > 0 && console.warn(`Discarded ${f.length} invalid annotations`, f), o.bulkAddAnnotation(d, l, L.REMOTE);
|
|
1119
1153
|
} else
|
|
1120
|
-
o.bulkAddAnnotation(
|
|
1121
|
-
},
|
|
1122
|
-
|
|
1123
|
-
}, x = (
|
|
1154
|
+
o.bulkAddAnnotation(y, l, L.REMOTE);
|
|
1155
|
+
}, w = (y) => {
|
|
1156
|
+
y ? i.setSelected(y) : i.clear();
|
|
1157
|
+
}, x = (y) => {
|
|
1124
1158
|
if (n) {
|
|
1125
|
-
const
|
|
1126
|
-
return o.updateAnnotation(
|
|
1159
|
+
const l = n.parse(y).parsed, d = n.serialize(o.getAnnotation(l.id));
|
|
1160
|
+
return o.updateAnnotation(l), d;
|
|
1127
1161
|
} else {
|
|
1128
|
-
const
|
|
1129
|
-
return o.updateAnnotation(
|
|
1162
|
+
const l = o.getAnnotation(y.id);
|
|
1163
|
+
return o.updateAnnotation(y), l;
|
|
1130
1164
|
}
|
|
1131
1165
|
};
|
|
1132
1166
|
return {
|
|
@@ -1137,17 +1171,17 @@ const Ye = 250, De = (t) => {
|
|
|
1137
1171
|
clearAnnotations: a,
|
|
1138
1172
|
getAnnotationById: u,
|
|
1139
1173
|
getAnnotations: h,
|
|
1140
|
-
getSelected:
|
|
1141
|
-
loadAnnotations:
|
|
1174
|
+
getSelected: v,
|
|
1175
|
+
loadAnnotations: c,
|
|
1142
1176
|
redo: e.redo,
|
|
1143
1177
|
removeAnnotation: m,
|
|
1144
|
-
setAnnotations:
|
|
1145
|
-
setSelected:
|
|
1178
|
+
setAnnotations: p,
|
|
1179
|
+
setSelected: w,
|
|
1146
1180
|
undo: e.undo,
|
|
1147
1181
|
updateAnnotation: x
|
|
1148
1182
|
};
|
|
1149
|
-
},
|
|
1150
|
-
let
|
|
1183
|
+
}, tn = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
|
|
1184
|
+
let en = (t) => crypto.getRandomValues(new Uint8Array(t)), nn = (t, e, n) => {
|
|
1151
1185
|
let o = (2 << Math.log(t.length - 1) / Math.LN2) - 1, i = -~(1.6 * o * e / t.length);
|
|
1152
1186
|
return (r = e) => {
|
|
1153
1187
|
let s = "";
|
|
@@ -1158,13 +1192,13 @@ let We = (t) => crypto.getRandomValues(new Uint8Array(t)), qe = (t, e, n) => {
|
|
|
1158
1192
|
return s;
|
|
1159
1193
|
}
|
|
1160
1194
|
};
|
|
1161
|
-
},
|
|
1195
|
+
}, on = (t, e = 21) => nn(t, e, en), rn = (t = 21) => {
|
|
1162
1196
|
let e = "", n = crypto.getRandomValues(new Uint8Array(t));
|
|
1163
1197
|
for (; t--; )
|
|
1164
|
-
e +=
|
|
1198
|
+
e += tn[n[t] & 63];
|
|
1165
1199
|
return e;
|
|
1166
1200
|
};
|
|
1167
|
-
const
|
|
1201
|
+
const sn = () => ({ isGuest: !0, id: on("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_", 20)() }), an = (t) => {
|
|
1168
1202
|
const e = JSON.stringify(t);
|
|
1169
1203
|
let n = 0;
|
|
1170
1204
|
for (let o = 0, i = e.length; o < i; o++) {
|
|
@@ -1172,28 +1206,28 @@ const Ke = () => ({ isGuest: !0, id: je("1234567890abcdefghijklmnopqrstuvwxyzABC
|
|
|
1172
1206
|
n = (n << 5) - n + r, n |= 0;
|
|
1173
1207
|
}
|
|
1174
1208
|
return `${n}`;
|
|
1175
|
-
},
|
|
1209
|
+
}, Yt = (t) => t ? typeof t == "object" ? { ...t } : t : void 0, cn = (t, e) => (Array.isArray(t) ? t : [t]).map((n) => {
|
|
1176
1210
|
const { id: o, type: i, purpose: r, value: s, created: a, creator: u, ...h } = n;
|
|
1177
1211
|
return {
|
|
1178
|
-
id: o || `temp-${
|
|
1212
|
+
id: o || `temp-${an(n)}`,
|
|
1179
1213
|
annotation: e,
|
|
1180
1214
|
type: i,
|
|
1181
1215
|
purpose: r,
|
|
1182
1216
|
value: s,
|
|
1183
1217
|
created: a ? new Date(a) : void 0,
|
|
1184
|
-
creator:
|
|
1218
|
+
creator: Yt(u),
|
|
1185
1219
|
...h
|
|
1186
1220
|
};
|
|
1187
|
-
}),
|
|
1221
|
+
}), ln = (t) => t.map((e) => {
|
|
1188
1222
|
var n, o;
|
|
1189
1223
|
const i = { ...e };
|
|
1190
1224
|
return delete i.annotation, (n = i.id) != null && n.startsWith("temp-") && delete i.id, { ...i, created: (o = i.created) == null ? void 0 : o.toISOString() };
|
|
1191
1225
|
});
|
|
1192
|
-
|
|
1193
|
-
const
|
|
1194
|
-
parse: (n) =>
|
|
1195
|
-
serialize: (n) =>
|
|
1196
|
-
}),
|
|
1226
|
+
rn();
|
|
1227
|
+
const Bn = (t, e) => ({
|
|
1228
|
+
parse: (n) => hn(n),
|
|
1229
|
+
serialize: (n) => fn(n, t, e)
|
|
1230
|
+
}), dn = (t) => t.quote !== void 0 && t.start !== void 0 && t.end !== void 0, un = (t) => {
|
|
1197
1231
|
const {
|
|
1198
1232
|
id: e,
|
|
1199
1233
|
creator: n,
|
|
@@ -1201,43 +1235,43 @@ const xn = (t, e) => ({
|
|
|
1201
1235
|
modified: i,
|
|
1202
1236
|
target: r
|
|
1203
1237
|
} = t, s = Array.isArray(r) ? r : [r], a = {
|
|
1204
|
-
creator:
|
|
1238
|
+
creator: Yt(n),
|
|
1205
1239
|
created: o ? new Date(o) : void 0,
|
|
1206
1240
|
updated: i ? new Date(i) : void 0,
|
|
1207
1241
|
annotation: e,
|
|
1208
1242
|
selector: []
|
|
1209
1243
|
};
|
|
1210
1244
|
for (const u of s) {
|
|
1211
|
-
const
|
|
1245
|
+
const v = (Array.isArray(u.selector) ? u.selector : [u.selector]).reduce((c, m) => {
|
|
1212
1246
|
switch (m.type) {
|
|
1213
1247
|
case "TextQuoteSelector":
|
|
1214
|
-
|
|
1248
|
+
c.quote = m.exact;
|
|
1215
1249
|
break;
|
|
1216
1250
|
case "TextPositionSelector":
|
|
1217
|
-
|
|
1251
|
+
c.start = m.start, c.end = m.end;
|
|
1218
1252
|
break;
|
|
1219
1253
|
}
|
|
1220
|
-
return
|
|
1254
|
+
return c;
|
|
1221
1255
|
}, {});
|
|
1222
|
-
if (
|
|
1223
|
-
a.selector.push({ id: u.id, ...
|
|
1256
|
+
if (dn(v))
|
|
1257
|
+
a.selector.push({ id: u.id, ...v });
|
|
1224
1258
|
else {
|
|
1225
|
-
const
|
|
1226
|
-
|
|
1227
|
-
|
|
1259
|
+
const c = [
|
|
1260
|
+
v.start ? void 0 : "TextPositionSelector",
|
|
1261
|
+
v.quote ? void 0 : "TextQuoteSelector"
|
|
1228
1262
|
].filter(Boolean);
|
|
1229
|
-
return { error: Error(`Missing selector types: ${
|
|
1263
|
+
return { error: Error(`Missing selector types: ${c.join(" and ")} for annotation: ${t.id}`) };
|
|
1230
1264
|
}
|
|
1231
1265
|
}
|
|
1232
1266
|
return { parsed: a };
|
|
1233
|
-
},
|
|
1234
|
-
const e = t.id ||
|
|
1267
|
+
}, hn = (t) => {
|
|
1268
|
+
const e = t.id || Xt(), {
|
|
1235
1269
|
creator: n,
|
|
1236
1270
|
created: o,
|
|
1237
1271
|
modified: i,
|
|
1238
1272
|
body: r,
|
|
1239
1273
|
...s
|
|
1240
|
-
} = t, a =
|
|
1274
|
+
} = t, a = cn(r, e), u = un(t);
|
|
1241
1275
|
return "error" in u ? { error: u.error } : {
|
|
1242
1276
|
parsed: {
|
|
1243
1277
|
...s,
|
|
@@ -1246,26 +1280,26 @@ const xn = (t, e) => ({
|
|
|
1246
1280
|
target: u.parsed
|
|
1247
1281
|
}
|
|
1248
1282
|
};
|
|
1249
|
-
},
|
|
1283
|
+
}, fn = (t, e, n) => {
|
|
1250
1284
|
const { bodies: o, target: i, ...r } = t, {
|
|
1251
1285
|
selector: s,
|
|
1252
1286
|
creator: a,
|
|
1253
1287
|
created: u,
|
|
1254
1288
|
updated: h,
|
|
1255
|
-
...
|
|
1256
|
-
} = i,
|
|
1257
|
-
const { quote:
|
|
1289
|
+
...v
|
|
1290
|
+
} = i, c = s.map((m) => {
|
|
1291
|
+
const { quote: p, start: w, end: x, range: y } = m, { prefix: l, suffix: d } = te(y, n), f = [{
|
|
1258
1292
|
type: "TextQuoteSelector",
|
|
1259
|
-
exact:
|
|
1260
|
-
prefix:
|
|
1293
|
+
exact: p,
|
|
1294
|
+
prefix: l,
|
|
1261
1295
|
suffix: d
|
|
1262
1296
|
}, {
|
|
1263
1297
|
type: "TextPositionSelector",
|
|
1264
|
-
start:
|
|
1298
|
+
start: w,
|
|
1265
1299
|
end: x
|
|
1266
1300
|
}];
|
|
1267
1301
|
return {
|
|
1268
|
-
...
|
|
1302
|
+
...v,
|
|
1269
1303
|
id: m.id,
|
|
1270
1304
|
source: e,
|
|
1271
1305
|
selector: f
|
|
@@ -1276,40 +1310,40 @@ const xn = (t, e) => ({
|
|
|
1276
1310
|
"@context": "http://www.w3.org/ns/anno.jsonld",
|
|
1277
1311
|
id: t.id,
|
|
1278
1312
|
type: "Annotation",
|
|
1279
|
-
body:
|
|
1313
|
+
body: ln(t.bodies),
|
|
1280
1314
|
creator: a,
|
|
1281
1315
|
created: u == null ? void 0 : u.toISOString(),
|
|
1282
1316
|
modified: h == null ? void 0 : h.toISOString(),
|
|
1283
|
-
target:
|
|
1317
|
+
target: c
|
|
1284
1318
|
};
|
|
1285
1319
|
};
|
|
1286
|
-
function
|
|
1287
|
-
|
|
1320
|
+
function pn(t, e, n, o, i) {
|
|
1321
|
+
Ht(t, e, n || 0, o || t.length - 1, i || gn);
|
|
1288
1322
|
}
|
|
1289
|
-
function
|
|
1323
|
+
function Ht(t, e, n, o, i) {
|
|
1290
1324
|
for (; o > n; ) {
|
|
1291
1325
|
if (o - n > 600) {
|
|
1292
|
-
var r = o - n + 1, s = e - n + 1, a = Math.log(r), u = 0.5 * Math.exp(2 * a / 3), h = 0.5 * Math.sqrt(a * u * (r - u) / r) * (s - r / 2 < 0 ? -1 : 1),
|
|
1293
|
-
|
|
1326
|
+
var r = o - n + 1, s = e - n + 1, a = Math.log(r), u = 0.5 * Math.exp(2 * a / 3), h = 0.5 * Math.sqrt(a * u * (r - u) / r) * (s - r / 2 < 0 ? -1 : 1), v = Math.max(n, Math.floor(e - s * u / r + h)), c = Math.min(o, Math.floor(e + (r - s) * u / r + h));
|
|
1327
|
+
Ht(t, e, v, c, i);
|
|
1294
1328
|
}
|
|
1295
|
-
var m = t[e],
|
|
1296
|
-
for (
|
|
1297
|
-
for (
|
|
1298
|
-
|
|
1299
|
-
for (; i(t[
|
|
1300
|
-
|
|
1329
|
+
var m = t[e], p = n, w = o;
|
|
1330
|
+
for (W(t, n, e), i(t[o], m) > 0 && W(t, n, o); p < w; ) {
|
|
1331
|
+
for (W(t, p, w), p++, w--; i(t[p], m) < 0; )
|
|
1332
|
+
p++;
|
|
1333
|
+
for (; i(t[w], m) > 0; )
|
|
1334
|
+
w--;
|
|
1301
1335
|
}
|
|
1302
|
-
i(t[n], m) === 0 ?
|
|
1336
|
+
i(t[n], m) === 0 ? W(t, n, w) : (w++, W(t, w, o)), w <= e && (n = w + 1), e <= w && (o = w - 1);
|
|
1303
1337
|
}
|
|
1304
1338
|
}
|
|
1305
|
-
function
|
|
1339
|
+
function W(t, e, n) {
|
|
1306
1340
|
var o = t[e];
|
|
1307
1341
|
t[e] = t[n], t[n] = o;
|
|
1308
1342
|
}
|
|
1309
|
-
function
|
|
1343
|
+
function gn(t, e) {
|
|
1310
1344
|
return t < e ? -1 : t > e ? 1 : 0;
|
|
1311
1345
|
}
|
|
1312
|
-
class
|
|
1346
|
+
class mn {
|
|
1313
1347
|
constructor(e = 9) {
|
|
1314
1348
|
this._maxEntries = Math.max(4, e), this._minEntries = Math.max(2, Math.ceil(this._maxEntries * 0.4)), this.clear();
|
|
1315
1349
|
}
|
|
@@ -1319,13 +1353,13 @@ class an {
|
|
|
1319
1353
|
search(e) {
|
|
1320
1354
|
let n = this.data;
|
|
1321
1355
|
const o = [];
|
|
1322
|
-
if (!
|
|
1356
|
+
if (!tt(e, n))
|
|
1323
1357
|
return o;
|
|
1324
1358
|
const i = this.toBBox, r = [];
|
|
1325
1359
|
for (; n; ) {
|
|
1326
1360
|
for (let s = 0; s < n.children.length; s++) {
|
|
1327
1361
|
const a = n.children[s], u = n.leaf ? i(a) : a;
|
|
1328
|
-
|
|
1362
|
+
tt(e, u) && (n.leaf ? o.push(a) : lt(e, u) ? this._all(a, o) : r.push(a));
|
|
1329
1363
|
}
|
|
1330
1364
|
n = r.pop();
|
|
1331
1365
|
}
|
|
@@ -1333,14 +1367,14 @@ class an {
|
|
|
1333
1367
|
}
|
|
1334
1368
|
collides(e) {
|
|
1335
1369
|
let n = this.data;
|
|
1336
|
-
if (!
|
|
1370
|
+
if (!tt(e, n))
|
|
1337
1371
|
return !1;
|
|
1338
1372
|
const o = [];
|
|
1339
1373
|
for (; n; ) {
|
|
1340
1374
|
for (let i = 0; i < n.children.length; i++) {
|
|
1341
1375
|
const r = n.children[i], s = n.leaf ? this.toBBox(r) : r;
|
|
1342
|
-
if (
|
|
1343
|
-
if (n.leaf ||
|
|
1376
|
+
if (tt(e, s)) {
|
|
1377
|
+
if (n.leaf || lt(e, s))
|
|
1344
1378
|
return !0;
|
|
1345
1379
|
o.push(r);
|
|
1346
1380
|
}
|
|
@@ -1375,7 +1409,7 @@ class an {
|
|
|
1375
1409
|
return e && this._insert(e, this.data.height - 1), this;
|
|
1376
1410
|
}
|
|
1377
1411
|
clear() {
|
|
1378
|
-
return this.data =
|
|
1412
|
+
return this.data = F([]), this;
|
|
1379
1413
|
}
|
|
1380
1414
|
remove(e, n) {
|
|
1381
1415
|
if (!e)
|
|
@@ -1385,11 +1419,11 @@ class an {
|
|
|
1385
1419
|
let a, u, h;
|
|
1386
1420
|
for (; o || r.length; ) {
|
|
1387
1421
|
if (o || (o = r.pop(), u = r[r.length - 1], a = s.pop(), h = !0), o.leaf) {
|
|
1388
|
-
const
|
|
1389
|
-
if (
|
|
1390
|
-
return o.children.splice(
|
|
1422
|
+
const v = bn(e, o.children, n);
|
|
1423
|
+
if (v !== -1)
|
|
1424
|
+
return o.children.splice(v, 1), r.push(o), this._condense(r), this;
|
|
1391
1425
|
}
|
|
1392
|
-
!h && !o.leaf &&
|
|
1426
|
+
!h && !o.leaf && lt(o, i) ? (r.push(o), s.push(a), a = 0, u = o, o = o.children[0]) : u ? (a++, o = u.children[a], h = !1) : o = null;
|
|
1393
1427
|
}
|
|
1394
1428
|
return this;
|
|
1395
1429
|
}
|
|
@@ -1418,26 +1452,26 @@ class an {
|
|
|
1418
1452
|
const r = o - n + 1;
|
|
1419
1453
|
let s = this._maxEntries, a;
|
|
1420
1454
|
if (r <= s)
|
|
1421
|
-
return a =
|
|
1422
|
-
i || (i = Math.ceil(Math.log(r) / Math.log(s)), s = Math.ceil(r / Math.pow(s, i - 1))), a =
|
|
1455
|
+
return a = F(e.slice(n, o + 1)), z(a, this.toBBox), a;
|
|
1456
|
+
i || (i = Math.ceil(Math.log(r) / Math.log(s)), s = Math.ceil(r / Math.pow(s, i - 1))), a = F([]), a.leaf = !1, a.height = i;
|
|
1423
1457
|
const u = Math.ceil(r / s), h = u * Math.ceil(Math.sqrt(s));
|
|
1424
|
-
|
|
1425
|
-
for (let
|
|
1426
|
-
const
|
|
1427
|
-
|
|
1428
|
-
for (let m =
|
|
1429
|
-
const
|
|
1430
|
-
a.children.push(this._build(e, m,
|
|
1458
|
+
Bt(e, n, o, h, this.compareMinX);
|
|
1459
|
+
for (let v = n; v <= o; v += h) {
|
|
1460
|
+
const c = Math.min(v + h - 1, o);
|
|
1461
|
+
Bt(e, v, c, u, this.compareMinY);
|
|
1462
|
+
for (let m = v; m <= c; m += u) {
|
|
1463
|
+
const p = Math.min(m + u - 1, c);
|
|
1464
|
+
a.children.push(this._build(e, m, p, i - 1));
|
|
1431
1465
|
}
|
|
1432
1466
|
}
|
|
1433
|
-
return
|
|
1467
|
+
return z(a, this.toBBox), a;
|
|
1434
1468
|
}
|
|
1435
1469
|
_chooseSubtree(e, n, o, i) {
|
|
1436
1470
|
for (; i.push(n), !(n.leaf || i.length - 1 === o); ) {
|
|
1437
1471
|
let r = 1 / 0, s = 1 / 0, a;
|
|
1438
1472
|
for (let u = 0; u < n.children.length; u++) {
|
|
1439
|
-
const h = n.children[u],
|
|
1440
|
-
|
|
1473
|
+
const h = n.children[u], v = ct(h), c = wn(e, h) - v;
|
|
1474
|
+
c < s ? (s = c, r = v < r ? v : r, a = h) : c === s && v < r && (r = v, a = h);
|
|
1441
1475
|
}
|
|
1442
1476
|
n = a || n.children[0];
|
|
1443
1477
|
}
|
|
@@ -1445,7 +1479,7 @@ class an {
|
|
|
1445
1479
|
}
|
|
1446
1480
|
_insert(e, n, o) {
|
|
1447
1481
|
const i = o ? e : this.toBBox(e), r = [], s = this._chooseSubtree(i, this.data, n, r);
|
|
1448
|
-
for (s.children.push(e),
|
|
1482
|
+
for (s.children.push(e), j(s, i); n >= 0 && r[n].children.length > this._maxEntries; )
|
|
1449
1483
|
this._split(r, n), n--;
|
|
1450
1484
|
this._adjustParentBBoxes(i, r, n);
|
|
1451
1485
|
}
|
|
@@ -1453,50 +1487,50 @@ class an {
|
|
|
1453
1487
|
_split(e, n) {
|
|
1454
1488
|
const o = e[n], i = o.children.length, r = this._minEntries;
|
|
1455
1489
|
this._chooseSplitAxis(o, r, i);
|
|
1456
|
-
const s = this._chooseSplitIndex(o, r, i), a =
|
|
1457
|
-
a.height = o.height, a.leaf = o.leaf,
|
|
1490
|
+
const s = this._chooseSplitIndex(o, r, i), a = F(o.children.splice(s, o.children.length - s));
|
|
1491
|
+
a.height = o.height, a.leaf = o.leaf, z(o, this.toBBox), z(a, this.toBBox), n ? e[n - 1].children.push(a) : this._splitRoot(o, a);
|
|
1458
1492
|
}
|
|
1459
1493
|
_splitRoot(e, n) {
|
|
1460
|
-
this.data =
|
|
1494
|
+
this.data = F([e, n]), this.data.height = e.height + 1, this.data.leaf = !1, z(this.data, this.toBBox);
|
|
1461
1495
|
}
|
|
1462
1496
|
_chooseSplitIndex(e, n, o) {
|
|
1463
1497
|
let i, r = 1 / 0, s = 1 / 0;
|
|
1464
1498
|
for (let a = n; a <= o - n; a++) {
|
|
1465
|
-
const u =
|
|
1466
|
-
|
|
1499
|
+
const u = q(e, 0, a, this.toBBox), h = q(e, a, o, this.toBBox), v = xn(u, h), c = ct(u) + ct(h);
|
|
1500
|
+
v < r ? (r = v, i = a, s = c < s ? c : s) : v === r && c < s && (s = c, i = a);
|
|
1467
1501
|
}
|
|
1468
1502
|
return i || o - n;
|
|
1469
1503
|
}
|
|
1470
1504
|
// sorts node children by the best axis for split
|
|
1471
1505
|
_chooseSplitAxis(e, n, o) {
|
|
1472
|
-
const i = e.leaf ? this.compareMinX :
|
|
1506
|
+
const i = e.leaf ? this.compareMinX : vn, r = e.leaf ? this.compareMinY : yn, s = this._allDistMargin(e, n, o, i), a = this._allDistMargin(e, n, o, r);
|
|
1473
1507
|
s < a && e.children.sort(i);
|
|
1474
1508
|
}
|
|
1475
1509
|
// total margin of all possible split distributions where each node is at least m full
|
|
1476
1510
|
_allDistMargin(e, n, o, i) {
|
|
1477
1511
|
e.children.sort(i);
|
|
1478
|
-
const r = this.toBBox, s =
|
|
1479
|
-
let u =
|
|
1512
|
+
const r = this.toBBox, s = q(e, 0, n, r), a = q(e, o - n, o, r);
|
|
1513
|
+
let u = Z(s) + Z(a);
|
|
1480
1514
|
for (let h = n; h < o - n; h++) {
|
|
1481
|
-
const
|
|
1482
|
-
|
|
1515
|
+
const v = e.children[h];
|
|
1516
|
+
j(s, e.leaf ? r(v) : v), u += Z(s);
|
|
1483
1517
|
}
|
|
1484
1518
|
for (let h = o - n - 1; h >= n; h--) {
|
|
1485
|
-
const
|
|
1486
|
-
|
|
1519
|
+
const v = e.children[h];
|
|
1520
|
+
j(a, e.leaf ? r(v) : v), u += Z(a);
|
|
1487
1521
|
}
|
|
1488
1522
|
return u;
|
|
1489
1523
|
}
|
|
1490
1524
|
_adjustParentBBoxes(e, n, o) {
|
|
1491
1525
|
for (let i = o; i >= 0; i--)
|
|
1492
|
-
|
|
1526
|
+
j(n[i], e);
|
|
1493
1527
|
}
|
|
1494
1528
|
_condense(e) {
|
|
1495
1529
|
for (let n = e.length - 1, o; n >= 0; n--)
|
|
1496
|
-
e[n].children.length === 0 ? n > 0 ? (o = e[n - 1].children, o.splice(o.indexOf(e[n]), 1)) : this.clear() :
|
|
1530
|
+
e[n].children.length === 0 ? n > 0 ? (o = e[n - 1].children, o.splice(o.indexOf(e[n]), 1)) : this.clear() : z(e[n], this.toBBox);
|
|
1497
1531
|
}
|
|
1498
1532
|
}
|
|
1499
|
-
function
|
|
1533
|
+
function bn(t, e, n) {
|
|
1500
1534
|
if (!n)
|
|
1501
1535
|
return e.indexOf(t);
|
|
1502
1536
|
for (let o = 0; o < e.length; o++)
|
|
@@ -1504,46 +1538,46 @@ function ln(t, e, n) {
|
|
|
1504
1538
|
return o;
|
|
1505
1539
|
return -1;
|
|
1506
1540
|
}
|
|
1507
|
-
function
|
|
1508
|
-
|
|
1541
|
+
function z(t, e) {
|
|
1542
|
+
q(t, 0, t.children.length, e, t);
|
|
1509
1543
|
}
|
|
1510
|
-
function
|
|
1511
|
-
i || (i =
|
|
1544
|
+
function q(t, e, n, o, i) {
|
|
1545
|
+
i || (i = F(null)), i.minX = 1 / 0, i.minY = 1 / 0, i.maxX = -1 / 0, i.maxY = -1 / 0;
|
|
1512
1546
|
for (let r = e; r < n; r++) {
|
|
1513
1547
|
const s = t.children[r];
|
|
1514
|
-
|
|
1548
|
+
j(i, t.leaf ? o(s) : s);
|
|
1515
1549
|
}
|
|
1516
1550
|
return i;
|
|
1517
1551
|
}
|
|
1518
|
-
function
|
|
1552
|
+
function j(t, e) {
|
|
1519
1553
|
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;
|
|
1520
1554
|
}
|
|
1521
|
-
function
|
|
1555
|
+
function vn(t, e) {
|
|
1522
1556
|
return t.minX - e.minX;
|
|
1523
1557
|
}
|
|
1524
|
-
function
|
|
1558
|
+
function yn(t, e) {
|
|
1525
1559
|
return t.minY - e.minY;
|
|
1526
1560
|
}
|
|
1527
|
-
function
|
|
1561
|
+
function ct(t) {
|
|
1528
1562
|
return (t.maxX - t.minX) * (t.maxY - t.minY);
|
|
1529
1563
|
}
|
|
1530
|
-
function
|
|
1564
|
+
function Z(t) {
|
|
1531
1565
|
return t.maxX - t.minX + (t.maxY - t.minY);
|
|
1532
1566
|
}
|
|
1533
|
-
function
|
|
1567
|
+
function wn(t, e) {
|
|
1534
1568
|
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));
|
|
1535
1569
|
}
|
|
1536
|
-
function
|
|
1570
|
+
function xn(t, e) {
|
|
1537
1571
|
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);
|
|
1538
1572
|
return Math.max(0, i - n) * Math.max(0, r - o);
|
|
1539
1573
|
}
|
|
1540
|
-
function
|
|
1574
|
+
function lt(t, e) {
|
|
1541
1575
|
return t.minX <= e.minX && t.minY <= e.minY && e.maxX <= t.maxX && e.maxY <= t.maxY;
|
|
1542
1576
|
}
|
|
1543
|
-
function
|
|
1577
|
+
function tt(t, e) {
|
|
1544
1578
|
return e.minX <= t.maxX && e.minY <= t.maxY && e.maxX >= t.minX && e.maxY >= t.minY;
|
|
1545
1579
|
}
|
|
1546
|
-
function
|
|
1580
|
+
function F(t) {
|
|
1547
1581
|
return {
|
|
1548
1582
|
children: t,
|
|
1549
1583
|
height: 1,
|
|
@@ -1554,330 +1588,328 @@ function z(t) {
|
|
|
1554
1588
|
maxY: -1 / 0
|
|
1555
1589
|
};
|
|
1556
1590
|
}
|
|
1557
|
-
function
|
|
1591
|
+
function Bt(t, e, n, o, i) {
|
|
1558
1592
|
const r = [e, n];
|
|
1559
1593
|
for (; r.length; ) {
|
|
1560
1594
|
if (n = r.pop(), e = r.pop(), n - e <= o)
|
|
1561
1595
|
continue;
|
|
1562
1596
|
const s = e + Math.ceil((n - e) / o / 2) * o;
|
|
1563
|
-
|
|
1597
|
+
pn(t, s, e, n, i), r.push(e, s, s, n);
|
|
1564
1598
|
}
|
|
1565
1599
|
}
|
|
1566
|
-
const
|
|
1567
|
-
const n = new
|
|
1568
|
-
const f =
|
|
1569
|
-
const T = A.range instanceof Range && !A.range.collapsed && A.range.startContainer.nodeType === Node.TEXT_NODE && A.range.endContainer.nodeType === Node.TEXT_NODE ? A.range :
|
|
1600
|
+
const An = (t, e) => {
|
|
1601
|
+
const n = new mn(), o = /* @__PURE__ */ new Map(), i = (l, d) => {
|
|
1602
|
+
const f = l.selector.flatMap((A) => {
|
|
1603
|
+
const T = A.range instanceof Range && !A.range.collapsed && A.range.startContainer.nodeType === Node.TEXT_NODE && A.range.endContainer.nodeType === Node.TEXT_NODE ? A.range : Mt(A, e).range;
|
|
1570
1604
|
return Array.from(T.getClientRects());
|
|
1571
|
-
}),
|
|
1572
|
-
return
|
|
1573
|
-
const { x: R, y: T, width:
|
|
1605
|
+
}), b = oe(f).map(({ left: A, top: R, right: T, bottom: g }) => new DOMRect(A - d.left, R - d.top, T - A, g - R));
|
|
1606
|
+
return b.map((A) => {
|
|
1607
|
+
const { x: R, y: T, width: g, height: S } = A;
|
|
1574
1608
|
return {
|
|
1575
1609
|
minX: R,
|
|
1576
1610
|
minY: T,
|
|
1577
|
-
maxX: R +
|
|
1611
|
+
maxX: R + g,
|
|
1578
1612
|
maxY: T + S,
|
|
1579
1613
|
annotation: {
|
|
1580
|
-
id:
|
|
1581
|
-
rects:
|
|
1614
|
+
id: l.annotation,
|
|
1615
|
+
rects: b
|
|
1582
1616
|
}
|
|
1583
1617
|
};
|
|
1584
1618
|
});
|
|
1585
1619
|
}, r = () => [...o.values()], s = () => {
|
|
1586
1620
|
n.clear(), o.clear();
|
|
1587
|
-
}, a = (
|
|
1588
|
-
const d = i(
|
|
1589
|
-
d.forEach((f) => n.insert(f)), o.set(
|
|
1590
|
-
}, u = (
|
|
1591
|
-
const d = o.get(
|
|
1592
|
-
d && (d.forEach((f) => n.remove(f)), o.delete(
|
|
1593
|
-
}, h = (
|
|
1594
|
-
u(
|
|
1595
|
-
},
|
|
1621
|
+
}, a = (l) => {
|
|
1622
|
+
const d = i(l, e.getBoundingClientRect());
|
|
1623
|
+
d.forEach((f) => n.insert(f)), o.set(l.annotation, d);
|
|
1624
|
+
}, u = (l) => {
|
|
1625
|
+
const d = o.get(l.annotation);
|
|
1626
|
+
d && (d.forEach((f) => n.remove(f)), o.delete(l.annotation));
|
|
1627
|
+
}, h = (l) => {
|
|
1628
|
+
u(l), a(l);
|
|
1629
|
+
}, v = (l, d = !0) => {
|
|
1596
1630
|
d && s();
|
|
1597
|
-
const f = e.getBoundingClientRect(),
|
|
1598
|
-
|
|
1599
|
-
const A =
|
|
1631
|
+
const f = e.getBoundingClientRect(), b = l.map((R) => ({ target: R, rects: i(R, f) }));
|
|
1632
|
+
b.forEach(({ target: R, rects: T }) => o.set(R.annotation, T));
|
|
1633
|
+
const A = b.reduce((R, { rects: T }) => [...R, ...T], []);
|
|
1600
1634
|
n.load(A);
|
|
1601
|
-
},
|
|
1635
|
+
}, c = (l, d) => {
|
|
1602
1636
|
const f = n.search({
|
|
1603
|
-
minX:
|
|
1637
|
+
minX: l,
|
|
1604
1638
|
minY: d,
|
|
1605
|
-
maxX:
|
|
1639
|
+
maxX: l,
|
|
1606
1640
|
maxY: d
|
|
1607
|
-
}),
|
|
1641
|
+
}), b = (A) => A.annotation.rects.reduce((R, T) => R + T.width * T.height, 0);
|
|
1608
1642
|
if (f.length > 0)
|
|
1609
|
-
return f.sort((A, R) =>
|
|
1610
|
-
}, m = (
|
|
1611
|
-
const d =
|
|
1643
|
+
return f.sort((A, R) => b(A) - b(R)), f[0].annotation.id;
|
|
1644
|
+
}, m = (l) => {
|
|
1645
|
+
const d = p(l);
|
|
1612
1646
|
if (d.length === 0)
|
|
1613
1647
|
return;
|
|
1614
|
-
let f = d[0].left,
|
|
1648
|
+
let f = d[0].left, b = d[0].top, A = d[0].right, R = d[0].bottom;
|
|
1615
1649
|
for (let T = 1; T < d.length; T++) {
|
|
1616
|
-
const
|
|
1617
|
-
f = Math.min(f,
|
|
1650
|
+
const g = d[T];
|
|
1651
|
+
f = Math.min(f, g.left), b = Math.min(b, g.top), A = Math.max(A, g.right), R = Math.max(R, g.bottom);
|
|
1618
1652
|
}
|
|
1619
|
-
return new DOMRect(f,
|
|
1620
|
-
},
|
|
1621
|
-
const d = o.get(
|
|
1653
|
+
return new DOMRect(f, b, A - f, R - b);
|
|
1654
|
+
}, p = (l) => {
|
|
1655
|
+
const d = o.get(l);
|
|
1622
1656
|
return d ? d[0].annotation.rects : [];
|
|
1623
1657
|
};
|
|
1624
1658
|
return {
|
|
1625
1659
|
all: r,
|
|
1626
1660
|
clear: s,
|
|
1627
|
-
getAt:
|
|
1661
|
+
getAt: c,
|
|
1628
1662
|
getAnnotationBounds: m,
|
|
1629
|
-
getAnnotationRects:
|
|
1630
|
-
getIntersecting: (
|
|
1631
|
-
const A = n.search({ minX:
|
|
1663
|
+
getAnnotationRects: p,
|
|
1664
|
+
getIntersecting: (l, d, f, b) => {
|
|
1665
|
+
const A = n.search({ minX: l, minY: d, maxX: f, maxY: b }), R = new Set(A.reduce((T, g) => [...T, g.annotation.id], []));
|
|
1632
1666
|
return Array.from(R).map((T) => ({
|
|
1633
1667
|
annotation: t.getAnnotation(T),
|
|
1634
|
-
rects:
|
|
1668
|
+
rects: p(T)
|
|
1635
1669
|
})).filter((T) => !!T.annotation);
|
|
1636
1670
|
},
|
|
1637
1671
|
insert: a,
|
|
1638
|
-
recalculate: () =>
|
|
1672
|
+
recalculate: () => v(t.all().map((l) => l.target), !0),
|
|
1639
1673
|
remove: u,
|
|
1640
|
-
set:
|
|
1674
|
+
set: v,
|
|
1641
1675
|
size: () => n.all().length,
|
|
1642
1676
|
update: h
|
|
1643
1677
|
};
|
|
1644
|
-
},
|
|
1645
|
-
const n =
|
|
1646
|
-
const
|
|
1647
|
-
return d && n.addAnnotation(
|
|
1648
|
-
}, u = (x,
|
|
1649
|
-
const d = x.map((
|
|
1650
|
-
return f.length > 0 ? (console.warn("Could not revive all targets for these annotations:", f), n.bulkAddAnnotation(d,
|
|
1651
|
-
}, h = (x,
|
|
1652
|
-
const
|
|
1653
|
-
return d.length > 0 && console.warn("Could not revive all targets for these annotations:", d),
|
|
1654
|
-
n.getAnnotation(f.id) ? n.updateAnnotation(f,
|
|
1678
|
+
}, En = (t, e) => {
|
|
1679
|
+
const n = We(), o = An(n, t), i = Oe(n, e), r = Be(n), s = Ke(), a = (x, y = L.LOCAL) => {
|
|
1680
|
+
const l = nt(x, t), d = k(l.target.selector);
|
|
1681
|
+
return d && n.addAnnotation(l, y), d;
|
|
1682
|
+
}, u = (x, y = !0, l = L.LOCAL) => {
|
|
1683
|
+
const d = x.map((b) => nt(b, t)), f = d.filter((b) => !k(b.target.selector));
|
|
1684
|
+
return f.length > 0 ? (console.warn("Could not revive all targets for these annotations:", f), n.bulkAddAnnotation(d, y, l), f) : (n.bulkAddAnnotation(d, y, l), []);
|
|
1685
|
+
}, h = (x, y = L.LOCAL) => {
|
|
1686
|
+
const l = x.map((f) => nt(f, t)), d = l.filter((f) => !k(f.target.selector));
|
|
1687
|
+
return d.length > 0 && console.warn("Could not revive all targets for these annotations:", d), l.forEach((f) => {
|
|
1688
|
+
n.getAnnotation(f.id) ? n.updateAnnotation(f, y) : n.addAnnotation(f, y);
|
|
1655
1689
|
}), d;
|
|
1656
|
-
},
|
|
1657
|
-
const
|
|
1658
|
-
n.updateTarget(
|
|
1659
|
-
},
|
|
1660
|
-
const
|
|
1661
|
-
n.bulkUpdateTargets(
|
|
1662
|
-
}, m = (x,
|
|
1663
|
-
const
|
|
1664
|
-
return
|
|
1665
|
-
},
|
|
1690
|
+
}, v = (x, y = L.LOCAL) => {
|
|
1691
|
+
const l = et(x, t);
|
|
1692
|
+
n.updateTarget(l, y);
|
|
1693
|
+
}, c = (x, y = L.LOCAL) => {
|
|
1694
|
+
const l = x.map((d) => et(d, t));
|
|
1695
|
+
n.bulkUpdateTargets(l, y);
|
|
1696
|
+
}, m = (x, y) => {
|
|
1697
|
+
const l = o.getAt(x, y);
|
|
1698
|
+
return l ? n.getAnnotation(l) : void 0;
|
|
1699
|
+
}, p = (x, y, l, d = 5) => {
|
|
1666
1700
|
const f = o.getAnnotationRects(x);
|
|
1667
1701
|
if (f.length !== 0) {
|
|
1668
|
-
if (
|
|
1669
|
-
const
|
|
1670
|
-
if (
|
|
1671
|
-
return
|
|
1702
|
+
if (y && l) {
|
|
1703
|
+
const b = f.find(({ top: A, right: R, bottom: T, left: g }) => y >= g - d && y <= R + d && l >= A - d && l <= T + d);
|
|
1704
|
+
if (b)
|
|
1705
|
+
return b;
|
|
1672
1706
|
}
|
|
1673
1707
|
return o.getAnnotationBounds(x);
|
|
1674
1708
|
}
|
|
1675
|
-
},
|
|
1709
|
+
}, w = () => o.recalculate();
|
|
1676
1710
|
return n.observe(({ changes: x }) => {
|
|
1677
|
-
const
|
|
1678
|
-
|
|
1711
|
+
const y = (x.created || []).filter((f) => k(f.target.selector)), l = (x.deleted || []).filter((f) => k(f.target.selector)), d = (x.updated || []).filter((f) => k(f.newValue.target.selector));
|
|
1712
|
+
y.length > 0 && o.set(y.map((f) => f.target), !1), (l == null ? void 0 : l.length) > 0 && l.forEach((f) => o.remove(f.target)), (d == null ? void 0 : d.length) > 0 && d.forEach(({ newValue: f }) => o.update(f.target));
|
|
1679
1713
|
}), {
|
|
1680
1714
|
store: {
|
|
1681
1715
|
...n,
|
|
1682
1716
|
addAnnotation: a,
|
|
1683
1717
|
bulkAddAnnotation: u,
|
|
1684
|
-
bulkUpdateTargets:
|
|
1718
|
+
bulkUpdateTargets: c,
|
|
1685
1719
|
bulkUpsertAnnotations: h,
|
|
1686
|
-
getAnnotationBounds:
|
|
1720
|
+
getAnnotationBounds: p,
|
|
1687
1721
|
getAt: m,
|
|
1688
1722
|
getIntersecting: o.getIntersecting,
|
|
1689
|
-
recalculatePositions:
|
|
1690
|
-
updateTarget:
|
|
1723
|
+
recalculatePositions: w,
|
|
1724
|
+
updateTarget: v
|
|
1691
1725
|
},
|
|
1692
1726
|
selection: i,
|
|
1693
1727
|
hover: r,
|
|
1694
1728
|
viewport: s
|
|
1695
1729
|
};
|
|
1696
|
-
},
|
|
1730
|
+
}, Sn = () => {
|
|
1697
1731
|
const t = document.createElement("canvas");
|
|
1698
1732
|
t.width = 2 * window.innerWidth, t.height = 2 * window.innerHeight, t.className = "r6o-highlight-layer presence";
|
|
1699
1733
|
const e = t.getContext("2d");
|
|
1700
1734
|
return e.scale(2, 2), e.translate(0.5, 0.5), t;
|
|
1701
|
-
},
|
|
1702
|
-
const o =
|
|
1735
|
+
}, Cn = (t, e, n = {}) => {
|
|
1736
|
+
const o = Sn(), i = o.getContext("2d");
|
|
1703
1737
|
t.appendChild(o);
|
|
1704
|
-
const r = /* @__PURE__ */ new Map(), s = (
|
|
1705
|
-
return e.on("selectionChange", (
|
|
1706
|
-
s(
|
|
1738
|
+
const r = /* @__PURE__ */ new Map(), s = (c) => Array.from(r.entries()).filter(([m, p]) => p.presenceKey === c.presenceKey).map(([m, p]) => m);
|
|
1739
|
+
return e.on("selectionChange", (c, m) => {
|
|
1740
|
+
s(c).forEach((w) => r.delete(w)), m && m.forEach((w) => r.set(w, c));
|
|
1707
1741
|
}), {
|
|
1708
1742
|
clear: () => {
|
|
1709
|
-
const { width:
|
|
1710
|
-
i.clearRect(-0.5, -0.5,
|
|
1743
|
+
const { width: c, height: m } = o;
|
|
1744
|
+
i.clearRect(-0.5, -0.5, c + 1, m + 1);
|
|
1711
1745
|
},
|
|
1712
1746
|
destroy: () => {
|
|
1713
1747
|
o.remove();
|
|
1714
1748
|
},
|
|
1715
|
-
paint: (
|
|
1749
|
+
paint: (c, m, p) => {
|
|
1716
1750
|
n.font && (i.font = n.font);
|
|
1717
|
-
const
|
|
1718
|
-
if (
|
|
1719
|
-
const { height: x } =
|
|
1720
|
-
i.fillStyle =
|
|
1721
|
-
const d = i.measureText(
|
|
1722
|
-
return i.fillRect(
|
|
1723
|
-
fill:
|
|
1724
|
-
fillOpacity:
|
|
1751
|
+
const w = r.get(c.annotation.id);
|
|
1752
|
+
if (w) {
|
|
1753
|
+
const { height: x } = c.rects[0], y = c.rects[0].x + m.left, l = c.rects[0].y + m.top;
|
|
1754
|
+
i.fillStyle = w.appearance.color, i.fillRect(y - 2, l - 2.5, 2, x + 5);
|
|
1755
|
+
const d = i.measureText(w.appearance.label), f = d.width + 6, b = d.actualBoundingBoxAscent + d.actualBoundingBoxDescent + 8, A = d.fontBoundingBoxAscent ? 8 : 6.5;
|
|
1756
|
+
return i.fillRect(y - 2, l - 2.5 - b, f, b), i.fillStyle = "#fff", i.fillText(w.appearance.label, y + 1, l - A), {
|
|
1757
|
+
fill: w.appearance.color,
|
|
1758
|
+
fillOpacity: p ? 0.45 : 0.18
|
|
1725
1759
|
};
|
|
1726
1760
|
}
|
|
1727
1761
|
},
|
|
1728
1762
|
reset: () => {
|
|
1729
1763
|
o.width = 2 * window.innerWidth, o.height = 2 * window.innerHeight;
|
|
1730
|
-
const
|
|
1731
|
-
|
|
1764
|
+
const c = o.getContext("2d");
|
|
1765
|
+
c.scale(2, 2), c.translate(0.5, 0.5);
|
|
1732
1766
|
}
|
|
1733
1767
|
};
|
|
1734
|
-
},
|
|
1768
|
+
}, $t = (t) => {
|
|
1735
1769
|
if (t === null)
|
|
1736
1770
|
return document.scrollingElement;
|
|
1737
1771
|
const { overflowY: e } = window.getComputedStyle(t);
|
|
1738
|
-
return e !== "visible" && e !== "hidden" && t.scrollHeight > t.clientHeight ? t :
|
|
1739
|
-
},
|
|
1772
|
+
return e !== "visible" && e !== "hidden" && t.scrollHeight > t.clientHeight ? t : $t(t.parentElement);
|
|
1773
|
+
}, Tn = (t, e) => (n) => {
|
|
1740
1774
|
const o = (r) => {
|
|
1741
|
-
const s = i.getBoundingClientRect(), a = i.clientHeight, u = i.clientWidth, h = r.selector[0].range.getBoundingClientRect(), { width:
|
|
1742
|
-
i.scroll({ top:
|
|
1743
|
-
}, i =
|
|
1775
|
+
const s = i.getBoundingClientRect(), a = i.clientHeight, u = i.clientWidth, h = r.selector[0].range.getBoundingClientRect(), { width: v, height: c } = e.getAnnotationBounds(n.id), m = h.top - s.top, p = h.left - s.left, w = i.parentElement ? i.scrollTop : 0, x = i.parentElement ? i.scrollLeft : 0, y = m + w - (a - c) / 2, l = p + x - (u - v) / 2;
|
|
1776
|
+
i.scroll({ top: y, left: l, behavior: "smooth" });
|
|
1777
|
+
}, i = $t(t);
|
|
1744
1778
|
if (i) {
|
|
1745
1779
|
const r = e.getAnnotation(n.id), { range: s } = r.target.selector[0];
|
|
1746
1780
|
if (s && !s.collapsed)
|
|
1747
1781
|
return o(r.target), !0;
|
|
1748
1782
|
{
|
|
1749
|
-
const a =
|
|
1783
|
+
const a = et(r.target, t), { range: u } = a.selector[0];
|
|
1750
1784
|
if (u && !u.collapsed)
|
|
1751
1785
|
return o(a), !0;
|
|
1752
1786
|
}
|
|
1753
1787
|
}
|
|
1754
1788
|
return !1;
|
|
1755
|
-
},
|
|
1789
|
+
}, Rn = (t, e, n) => {
|
|
1756
1790
|
const { store: o, selection: i } = e;
|
|
1757
1791
|
let r, s;
|
|
1758
1792
|
const a = (x) => r = x;
|
|
1759
1793
|
let u = !1, h;
|
|
1760
|
-
const
|
|
1761
|
-
var
|
|
1794
|
+
const v = (x) => {
|
|
1795
|
+
var l;
|
|
1762
1796
|
if (!u)
|
|
1763
1797
|
return;
|
|
1764
|
-
!((
|
|
1765
|
-
annotation:
|
|
1798
|
+
!((l = x.target.parentElement) != null && l.closest(Y)) ? s = {
|
|
1799
|
+
annotation: Xt(),
|
|
1766
1800
|
selector: [],
|
|
1767
1801
|
creator: r,
|
|
1768
1802
|
created: /* @__PURE__ */ new Date()
|
|
1769
1803
|
} : s = void 0;
|
|
1770
1804
|
};
|
|
1771
|
-
t.addEventListener("selectstart",
|
|
1772
|
-
const
|
|
1773
|
-
const
|
|
1774
|
-
if (x.timeStamp - ((h == null ? void 0 : h.timeStamp) || x.timeStamp) < 1e3 && !s &&
|
|
1805
|
+
t.addEventListener("selectstart", v);
|
|
1806
|
+
const c = ft((x) => {
|
|
1807
|
+
const y = document.getSelection();
|
|
1808
|
+
if (x.timeStamp - ((h == null ? void 0 : h.timeStamp) || x.timeStamp) < 1e3 && !s && v(h), y.isCollapsed || !u || !s)
|
|
1775
1809
|
return;
|
|
1776
|
-
const
|
|
1810
|
+
const l = y.getRangeAt(0), d = re(l.cloneRange()), f = Qt(d);
|
|
1777
1811
|
(f.length !== s.selector.length || f.some((A, R) => {
|
|
1778
1812
|
var T;
|
|
1779
1813
|
return A.toString() !== ((T = s.selector[R]) == null ? void 0 : T.quote);
|
|
1780
1814
|
})) && (s = {
|
|
1781
1815
|
...s,
|
|
1782
|
-
selector: f.map((A) =>
|
|
1783
|
-
}, o.getAnnotation(s.annotation) ? o.updateTarget(s,
|
|
1816
|
+
selector: f.map((A) => ie(A, t, n))
|
|
1817
|
+
}, o.getAnnotation(s.annotation) ? o.updateTarget(s, L.LOCAL) : (o.addAnnotation({
|
|
1784
1818
|
id: s.annotation,
|
|
1785
1819
|
bodies: [],
|
|
1786
1820
|
target: s
|
|
1787
1821
|
}), i.clickSelect(s.annotation, h)));
|
|
1788
1822
|
});
|
|
1789
|
-
document.addEventListener("selectionchange",
|
|
1823
|
+
document.addEventListener("selectionchange", c);
|
|
1790
1824
|
const m = (x) => {
|
|
1791
|
-
const { target:
|
|
1792
|
-
h = { ...x, target:
|
|
1825
|
+
const { target: y, timeStamp: l, offsetX: d, offsetY: f, type: b } = x;
|
|
1826
|
+
h = { ...x, target: y, timeStamp: l, offsetX: d, offsetY: f, type: b }, u = x.button === 0;
|
|
1793
1827
|
};
|
|
1794
1828
|
t.addEventListener("pointerdown", m);
|
|
1795
|
-
const
|
|
1829
|
+
const p = (x) => {
|
|
1796
1830
|
var f;
|
|
1797
1831
|
if (!!((f = x.target.parentElement) != null && f.closest(Y)) || !u)
|
|
1798
1832
|
return;
|
|
1799
|
-
const
|
|
1800
|
-
const { x:
|
|
1833
|
+
const l = () => {
|
|
1834
|
+
const { x: b, y: A } = t.getBoundingClientRect(), R = o.getAt(x.clientX - b, x.clientY - A);
|
|
1801
1835
|
if (R) {
|
|
1802
1836
|
const { selected: T } = i;
|
|
1803
1837
|
(T.length !== 1 || T[0].id !== R.id) && i.clickSelect(R.id, x);
|
|
1804
1838
|
} else
|
|
1805
1839
|
i.isEmpty() || i.clear();
|
|
1806
1840
|
}, d = x.timeStamp - h.timeStamp;
|
|
1807
|
-
document.getSelection().isCollapsed && d < 300 ? (s = void 0,
|
|
1841
|
+
document.getSelection().isCollapsed && d < 300 ? (s = void 0, l()) : s && i.clickSelect(s.annotation, x);
|
|
1808
1842
|
};
|
|
1809
|
-
return document.addEventListener("pointerup",
|
|
1843
|
+
return document.addEventListener("pointerup", p), {
|
|
1810
1844
|
destroy: () => {
|
|
1811
|
-
t.removeEventListener("selectstart",
|
|
1845
|
+
t.removeEventListener("selectstart", v), document.removeEventListener("selectionchange", c), t.removeEventListener("pointerdown", m), document.removeEventListener("pointerup", p);
|
|
1812
1846
|
},
|
|
1813
1847
|
setUser: a
|
|
1814
1848
|
};
|
|
1815
|
-
},
|
|
1849
|
+
}, Ot = "SPANS", On = (t, e = {}) => {
|
|
1816
1850
|
t.addEventListener("click", (A) => !A.target.closest("a") && A.preventDefault());
|
|
1817
|
-
const n =
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
);
|
|
1822
|
-
let u = Ke();
|
|
1823
|
-
const h = e.renderer === "CSS_HIGHLIGHTS" ? CSS.highlights ? "CSS_HIGHLIGHTS" : Lt : e.renderer || Lt, b = h === "SPANS" ? ye(t, n, i) : h === "CSS_HIGHLIGHTS" ? be(t, n, i) : h === "CANVAS" ? ae(t, n, i) : void 0;
|
|
1824
|
-
if (!b)
|
|
1851
|
+
const n = En(t, e.pointerAction), { selection: o, viewport: i } = n, r = n.store, s = Ge(r), a = Qe(n, s, e.adapter);
|
|
1852
|
+
let u = sn();
|
|
1853
|
+
const h = e.renderer === "CSS_HIGHLIGHTS" ? CSS.highlights ? "CSS_HIGHLIGHTS" : Ot : e.renderer || Ot, v = h === "SPANS" ? Se(t, n, i) : h === "CSS_HIGHLIGHTS" ? xe(t, n, i) : h === "CANVAS" ? ue(t, n, i) : void 0;
|
|
1854
|
+
if (!v)
|
|
1825
1855
|
throw `Unknown renderer implementation: ${h}`;
|
|
1826
|
-
console.debug(`Using ${h} renderer`), e.style &&
|
|
1827
|
-
const
|
|
1828
|
-
return
|
|
1829
|
-
...
|
|
1856
|
+
console.debug(`Using ${h} renderer`), e.style && v.setStyle(e.style);
|
|
1857
|
+
const c = Rn(t, n, e.offsetReferenceSelector);
|
|
1858
|
+
return c.setUser(u), {
|
|
1859
|
+
...Ze(n, s, e.adapter),
|
|
1830
1860
|
destroy: () => {
|
|
1831
|
-
|
|
1861
|
+
v.destroy(), c.destroy(), s.destroy();
|
|
1832
1862
|
},
|
|
1833
1863
|
element: t,
|
|
1834
1864
|
getUser: () => u,
|
|
1835
|
-
setFilter: (A) =>
|
|
1836
|
-
setStyle: (A) =>
|
|
1865
|
+
setFilter: (A) => v.setFilter(A),
|
|
1866
|
+
setStyle: (A) => v.setStyle(A),
|
|
1837
1867
|
setUser: (A) => {
|
|
1838
|
-
u = A,
|
|
1868
|
+
u = A, c.setUser(A);
|
|
1839
1869
|
},
|
|
1840
1870
|
setSelected: (A) => {
|
|
1841
1871
|
A ? o.setSelected(A) : o.clear();
|
|
1842
1872
|
},
|
|
1843
1873
|
setPresenceProvider: (A) => {
|
|
1844
|
-
A && (
|
|
1874
|
+
A && (v.setPainter(Cn(t, A, e.presence)), A.on("selectionChange", () => v.redraw()));
|
|
1845
1875
|
},
|
|
1846
|
-
setVisible: (A) =>
|
|
1876
|
+
setVisible: (A) => v.setVisible(A),
|
|
1847
1877
|
on: a.on,
|
|
1848
1878
|
off: a.off,
|
|
1849
|
-
scrollIntoView:
|
|
1879
|
+
scrollIntoView: Tn(t, r),
|
|
1850
1880
|
state: n
|
|
1851
1881
|
};
|
|
1852
|
-
};
|
|
1882
|
+
}, In = Dt, Mn = De, Un = L;
|
|
1853
1883
|
export {
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1884
|
+
ht as DEFAULT_SELECTED_STYLE,
|
|
1885
|
+
$ as DEFAULT_STYLE,
|
|
1886
|
+
It as NOT_ANNOTATABLE_CLASS,
|
|
1857
1887
|
Y as NOT_ANNOTATABLE_SELECTOR,
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1888
|
+
Un as Origin,
|
|
1889
|
+
In as PointerSelectAction,
|
|
1890
|
+
Bn as W3CTextFormat,
|
|
1891
|
+
Mn as createBody,
|
|
1892
|
+
ue as createCanvasRenderer,
|
|
1893
|
+
xe as createHighlightsRenderer,
|
|
1894
|
+
we as createRenderer,
|
|
1895
|
+
Se as createSpansRenderer,
|
|
1896
|
+
On as createTextAnnotator,
|
|
1897
|
+
En as createTextAnnotatorState,
|
|
1898
|
+
ft as debounce,
|
|
1899
|
+
Nn as getAnnotatableFragment,
|
|
1900
|
+
Ln as getClientRectsPonyfill,
|
|
1901
|
+
te as getQuoteContext,
|
|
1902
|
+
dt as getRangeAnnotatableContents,
|
|
1871
1903
|
k as isRevived,
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1904
|
+
oe as mergeClientRects,
|
|
1905
|
+
jt as paint,
|
|
1906
|
+
hn as parseW3CTextAnnotation,
|
|
1907
|
+
ie as rangeToSelector,
|
|
1908
|
+
nt as reviveAnnotation,
|
|
1909
|
+
Mt as reviveSelector,
|
|
1910
|
+
et as reviveTarget,
|
|
1911
|
+
fn as serializeW3CTextAnnotation,
|
|
1912
|
+
Qt as splitAnnotatableRanges,
|
|
1913
|
+
re as trimRange
|
|
1882
1914
|
};
|
|
1883
1915
|
//# sourceMappingURL=text-annotator.es.js.map
|