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