@recogito/text-annotator 3.0.0-rc.50 → 3.0.0-rc.52
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 +2 -1
- package/dist/src/TextAnnotatorOptions.d.ts +1 -0
- package/dist/src/model/w3c/W3CTextAnnotation.d.ts +1 -0
- package/dist/src/state/TextAnnotationStore.d.ts +3 -1
- package/dist/text-annotator.es.js +998 -970
- 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 +4 -5
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
const
|
|
1
|
+
const re = "not-annotatable", tt = `.${re}`, it = (t) => {
|
|
2
2
|
var n;
|
|
3
|
-
return !!(t instanceof HTMLElement ? t.closest(
|
|
4
|
-
},
|
|
3
|
+
return !!(t instanceof HTMLElement ? t.closest(tt) : (n = t.parentElement) == null ? void 0 : n.closest(tt));
|
|
4
|
+
}, Ce = (t) => {
|
|
5
5
|
const e = t.commonAncestorContainer;
|
|
6
|
-
return !
|
|
7
|
-
},
|
|
6
|
+
return !it(e);
|
|
7
|
+
}, Le = (t) => t.addEventListener("click", (e) => {
|
|
8
8
|
// Allow clicks within not-annotatable elements
|
|
9
|
-
!e.target.closest(
|
|
10
|
-
}),
|
|
9
|
+
!e.target.closest(tt) && !e.target.closest("a") && e.preventDefault();
|
|
10
|
+
}), At = (t) => ({
|
|
11
11
|
...t,
|
|
12
12
|
type: t.type,
|
|
13
13
|
x: t.x,
|
|
@@ -33,7 +33,7 @@ const se = "not-annotatable", Z = `.${se}`, nt = (t) => {
|
|
|
33
33
|
pointerId: t.pointerId,
|
|
34
34
|
pointerType: t.pointerType,
|
|
35
35
|
timeStamp: t.timeStamp
|
|
36
|
-
}),
|
|
36
|
+
}), ft = (t) => ({
|
|
37
37
|
...t,
|
|
38
38
|
type: t.type,
|
|
39
39
|
key: t.key,
|
|
@@ -49,27 +49,27 @@ const se = "not-annotatable", Z = `.${se}`, nt = (t) => {
|
|
|
49
49
|
defaultPrevented: t.defaultPrevented,
|
|
50
50
|
detail: t.detail,
|
|
51
51
|
timeStamp: t.timeStamp
|
|
52
|
-
}),
|
|
52
|
+
}), Te = /mac/i.test(navigator.userAgentData ? navigator.userAgentData.platform : navigator.platform), Oe = (t) => {
|
|
53
53
|
!t.hasAttribute("tabindex") && t.tabIndex < 0 && t.setAttribute("tabindex", "-1"), t.classList.add("no-focus-outline");
|
|
54
|
-
},
|
|
54
|
+
}, Yt = (t, e = 10) => {
|
|
55
55
|
let n;
|
|
56
56
|
return (...o) => {
|
|
57
57
|
clearTimeout(n), n = setTimeout(() => t.apply(void 0, o), e);
|
|
58
58
|
};
|
|
59
|
-
},
|
|
59
|
+
}, Me = function* (t) {
|
|
60
60
|
const e = document.createNodeIterator(
|
|
61
61
|
t.commonAncestorContainer,
|
|
62
62
|
NodeFilter.SHOW_ELEMENT,
|
|
63
|
-
(o) => o instanceof HTMLElement && o.classList.contains(
|
|
63
|
+
(o) => o instanceof HTMLElement && o.classList.contains(re) && !o.parentElement.closest(tt) && t.intersectsNode(o) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP
|
|
64
64
|
);
|
|
65
65
|
let n;
|
|
66
66
|
for (; n = e.nextNode(); )
|
|
67
67
|
n instanceof HTMLElement && (yield n);
|
|
68
68
|
}, Be = (t) => {
|
|
69
|
-
if (!
|
|
69
|
+
if (!Ce(t)) return [];
|
|
70
70
|
const e = [];
|
|
71
71
|
let n = null;
|
|
72
|
-
for (const o of
|
|
72
|
+
for (const o of Me(t)) {
|
|
73
73
|
let i;
|
|
74
74
|
n ? (i = document.createRange(), i.setStartAfter(n), i.setEndBefore(o)) : (i = t.cloneRange(), i.setEndBefore(o)), i.collapsed || e.push(i), n = o;
|
|
75
75
|
}
|
|
@@ -78,20 +78,20 @@ const se = "not-annotatable", Z = `.${se}`, nt = (t) => {
|
|
|
78
78
|
o.setStartAfter(n), o.collapsed || e.push(o);
|
|
79
79
|
}
|
|
80
80
|
return e.length > 0 ? e : [t];
|
|
81
|
-
},
|
|
81
|
+
}, Nt = (t) => {
|
|
82
82
|
const e = t.cloneContents();
|
|
83
|
-
return e.querySelectorAll(
|
|
84
|
-
},
|
|
83
|
+
return e.querySelectorAll(tt).forEach((n) => n.remove()), e;
|
|
84
|
+
}, Re = (t, e, n = 10, o) => {
|
|
85
85
|
const i = o ? t.startContainer.parentElement.closest(o) : e, s = document.createRange();
|
|
86
86
|
s.setStart(i, 0), s.setEnd(t.startContainer, t.startOffset);
|
|
87
|
-
const a =
|
|
87
|
+
const a = Nt(s).textContent, r = document.createRange();
|
|
88
88
|
r.setStart(t.endContainer, t.endOffset), i === document.body ? r.setEnd(i, i.childNodes.length) : r.setEndAfter(i);
|
|
89
|
-
const l =
|
|
89
|
+
const l = Nt(r).textContent;
|
|
90
90
|
return {
|
|
91
91
|
prefix: a.substring(a.length - n),
|
|
92
92
|
suffix: l.substring(0, n)
|
|
93
93
|
};
|
|
94
|
-
}, F = (t) => t.every((e) => e.range instanceof Range && !e.range.collapsed),
|
|
94
|
+
}, F = (t) => t.every((e) => e.range instanceof Range && !e.range.collapsed), ke = /^\s*$/, Ie = (t) => ke.test(t.toString()), _e = (t, e) => {
|
|
95
95
|
const n = (s) => Math.round(s * 10) / 10, o = {
|
|
96
96
|
top: n(t.top),
|
|
97
97
|
bottom: n(t.bottom),
|
|
@@ -115,17 +115,17 @@ const se = "not-annotatable", Z = `.${se}`, nt = (t) => {
|
|
|
115
115
|
return "block-contains";
|
|
116
116
|
} else if (o.top >= i.top && o.bottom <= i.bottom && o.left >= i.left && o.right <= i.right)
|
|
117
117
|
return "block-is-contained";
|
|
118
|
-
},
|
|
118
|
+
}, Ne = (t, e) => {
|
|
119
119
|
const n = Math.min(t.left, e.left), o = Math.max(t.right, e.right), i = Math.min(t.top, e.top), s = Math.max(t.bottom, e.bottom);
|
|
120
120
|
return new DOMRect(n, i, o - n, s - i);
|
|
121
|
-
},
|
|
121
|
+
}, Ue = (t) => t.reduce((e, n) => {
|
|
122
122
|
if (n.width === 0 || n.height === 0)
|
|
123
123
|
return e;
|
|
124
124
|
let o = [...e], i = !1;
|
|
125
125
|
for (const s of e) {
|
|
126
|
-
const a =
|
|
126
|
+
const a = _e(n, s);
|
|
127
127
|
if (a === "inline-adjacent") {
|
|
128
|
-
o = o.map((r) => r === s ?
|
|
128
|
+
o = o.map((r) => r === s ? Ne(n, s) : r), i = !0;
|
|
129
129
|
break;
|
|
130
130
|
} else if (a === "inline-contains") {
|
|
131
131
|
o = o.map((r) => r === s ? n : r), i = !0;
|
|
@@ -139,19 +139,19 @@ const se = "not-annotatable", Z = `.${se}`, nt = (t) => {
|
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
141
|
return i ? o : [...o, n];
|
|
142
|
-
}, []),
|
|
142
|
+
}, []), Ve = (t, e, n) => {
|
|
143
143
|
const o = document.createRange(), i = n ? t.startContainer.parentElement.closest(n) : e;
|
|
144
144
|
o.setStart(i, 0), o.setEnd(t.startContainer, t.startOffset);
|
|
145
|
-
const s =
|
|
145
|
+
const s = Nt(o).textContent, a = t.toString(), r = s.length || 0, l = r + a.length;
|
|
146
146
|
return n ? { quote: a, start: r, end: l, range: t, offsetReference: i } : { quote: a, start: r, end: l, range: t };
|
|
147
|
-
},
|
|
148
|
-
var
|
|
147
|
+
}, ae = (t, e) => {
|
|
148
|
+
var h, u;
|
|
149
149
|
const { start: n, end: o } = t, i = t.offsetReference || e, s = document.createNodeIterator(
|
|
150
150
|
e,
|
|
151
151
|
NodeFilter.SHOW_TEXT,
|
|
152
|
-
(
|
|
153
|
-
var
|
|
154
|
-
return (
|
|
152
|
+
(p) => {
|
|
153
|
+
var g;
|
|
154
|
+
return (g = p.parentElement) != null && g.closest(tt) ? NodeFilter.FILTER_SKIP : NodeFilter.FILTER_ACCEPT;
|
|
155
155
|
}
|
|
156
156
|
);
|
|
157
157
|
let a = 0;
|
|
@@ -161,49 +161,49 @@ const se = "not-annotatable", Z = `.${se}`, nt = (t) => {
|
|
|
161
161
|
let f = !i;
|
|
162
162
|
for (; l !== null; ) {
|
|
163
163
|
if (f || (f = i == null ? void 0 : i.contains(l)), f) {
|
|
164
|
-
const
|
|
165
|
-
if (a +
|
|
164
|
+
const p = ((h = l.textContent) == null ? void 0 : h.length) || 0;
|
|
165
|
+
if (a + p > n) {
|
|
166
166
|
r.setStart(l, n - a);
|
|
167
167
|
break;
|
|
168
168
|
}
|
|
169
|
-
a +=
|
|
169
|
+
a += p;
|
|
170
170
|
}
|
|
171
171
|
l = s.nextNode();
|
|
172
172
|
}
|
|
173
173
|
for (; l !== null; ) {
|
|
174
|
-
const
|
|
175
|
-
if (a +
|
|
174
|
+
const p = ((u = l.textContent) == null ? void 0 : u.length) || 0;
|
|
175
|
+
if (a + p >= o) {
|
|
176
176
|
r.setEnd(l, o - a);
|
|
177
177
|
break;
|
|
178
178
|
}
|
|
179
|
-
a +=
|
|
179
|
+
a += p, l = s.nextNode();
|
|
180
180
|
}
|
|
181
181
|
return {
|
|
182
182
|
...t,
|
|
183
183
|
range: r
|
|
184
184
|
};
|
|
185
|
-
},
|
|
185
|
+
}, bt = (t, e) => F(t.selector) ? t : {
|
|
186
186
|
...t,
|
|
187
|
-
selector: t.selector.map((n) => n.range instanceof Range && !n.range.collapsed ? n :
|
|
188
|
-
},
|
|
187
|
+
selector: t.selector.map((n) => n.range instanceof Range && !n.range.collapsed ? n : ae(n, e))
|
|
188
|
+
}, xt = (t, e) => F(t.target.selector) ? t : { ...t, target: bt(t.target, e) }, Ye = (t, e) => {
|
|
189
189
|
const n = t.cloneRange();
|
|
190
190
|
return e.contains(n.startContainer) || n.setStart(e, 0), e.contains(n.endContainer) || n.setEnd(e, e.childNodes.length), n;
|
|
191
|
-
},
|
|
191
|
+
}, ce = (t) => {
|
|
192
192
|
if (t === null)
|
|
193
193
|
return document.scrollingElement;
|
|
194
194
|
const { overflowY: e } = window.getComputedStyle(t);
|
|
195
|
-
return e !== "visible" && e !== "hidden" && t.scrollHeight > t.clientHeight ? t :
|
|
196
|
-
},
|
|
195
|
+
return e !== "visible" && e !== "hidden" && t.scrollHeight > t.clientHeight ? t : ce(t.parentElement);
|
|
196
|
+
}, Ke = (t, e) => (n) => {
|
|
197
197
|
const o = typeof n == "string" ? n : n.id, i = (a) => {
|
|
198
|
-
const r = s.getBoundingClientRect(), l = s.clientHeight, f = s.clientWidth,
|
|
198
|
+
const r = s.getBoundingClientRect(), l = s.clientHeight, f = s.clientWidth, h = a.selector[0].range.getBoundingClientRect(), { width: u, height: p } = e.getAnnotationBounds(o), g = h.top - r.top, b = h.left - r.left, w = s.parentElement ? s.scrollTop : 0, y = s.parentElement ? s.scrollLeft : 0, d = g + w - (l - p) / 2, c = b + y - (f - u) / 2;
|
|
199
199
|
s.scroll({ top: d, left: c, behavior: "smooth" });
|
|
200
|
-
}, s =
|
|
200
|
+
}, s = ce(t);
|
|
201
201
|
if (s) {
|
|
202
202
|
const a = e.getAnnotation(o), { range: r } = a.target.selector[0];
|
|
203
203
|
if (r && !r.collapsed)
|
|
204
204
|
return i(a.target), !0;
|
|
205
205
|
{
|
|
206
|
-
const l =
|
|
206
|
+
const l = bt(a.target, t), { range: f } = l.selector[0];
|
|
207
207
|
if (f && !f.collapsed)
|
|
208
208
|
return i(l), !0;
|
|
209
209
|
}
|
|
@@ -212,17 +212,17 @@ const se = "not-annotatable", Z = `.${se}`, nt = (t) => {
|
|
|
212
212
|
}, W = {
|
|
213
213
|
fill: "rgb(0, 128, 255)",
|
|
214
214
|
fillOpacity: 0.18
|
|
215
|
-
},
|
|
215
|
+
}, wt = {
|
|
216
216
|
fill: "rgb(0, 128, 255)",
|
|
217
217
|
fillOpacity: 0.45
|
|
218
|
-
},
|
|
218
|
+
}, De = (t, e, n, o, i) => {
|
|
219
219
|
var a, r;
|
|
220
|
-
const s = n ? typeof n == "function" ? n(t.annotation, t.state, i) || ((a = t.state) != null && a.selected ?
|
|
220
|
+
const s = n ? typeof n == "function" ? n(t.annotation, t.state, i) || ((a = t.state) != null && a.selected ? wt : W) : n : (r = t.state) != null && r.selected ? wt : W;
|
|
221
221
|
return o && o.paint(t, e) || s;
|
|
222
|
-
},
|
|
222
|
+
}, Xe = (t) => {
|
|
223
223
|
const { top: e, left: n } = t.getBoundingClientRect(), { innerWidth: o, innerHeight: i } = window, s = -n, a = -e, r = o - n, l = i - e;
|
|
224
224
|
return { top: e, left: n, minX: s, minY: a, maxX: r, maxY: l };
|
|
225
|
-
},
|
|
225
|
+
}, Pe = (t) => {
|
|
226
226
|
let e = /* @__PURE__ */ new Set();
|
|
227
227
|
return (o) => {
|
|
228
228
|
const i = o.map((s) => s.id);
|
|
@@ -231,83 +231,83 @@ const se = "not-annotatable", Z = `.${se}`, nt = (t) => {
|
|
|
231
231
|
}, Kt = (t, e, n, o) => {
|
|
232
232
|
const { store: i, selection: s, hover: a } = e;
|
|
233
233
|
let r, l, f;
|
|
234
|
-
const
|
|
235
|
-
const { x:
|
|
236
|
-
|
|
234
|
+
const h = Pe(n), u = (M) => {
|
|
235
|
+
const { x: L, y: m } = t.getBoundingClientRect(), v = i.getAt(M.clientX - L, M.clientY - m, !1, l);
|
|
236
|
+
v ? a.current !== v.id && (t.classList.add("hovered"), a.set(v.id)) : a.current && (t.classList.remove("hovered"), a.set(null));
|
|
237
237
|
};
|
|
238
|
-
t.addEventListener("pointermove",
|
|
239
|
-
const
|
|
238
|
+
t.addEventListener("pointermove", u);
|
|
239
|
+
const p = (M = !1) => {
|
|
240
240
|
f && f.clear();
|
|
241
|
-
const
|
|
242
|
-
const
|
|
243
|
-
return { annotation:
|
|
241
|
+
const L = Xe(t), { minX: m, minY: v, maxX: x, maxY: C } = L, B = l ? i.getIntersecting(m, v, x, C).filter(({ annotation: U }) => l(U)) : i.getIntersecting(m, v, x, C), R = s.selected.map(({ id: U }) => U), N = B.map(({ annotation: U, rects: et }) => {
|
|
242
|
+
const q = R.includes(U.id), Se = U.id === a.current;
|
|
243
|
+
return { annotation: U, rects: et, state: { selected: q, hover: Se } };
|
|
244
244
|
});
|
|
245
|
-
o.redraw(
|
|
246
|
-
},
|
|
247
|
-
f =
|
|
248
|
-
},
|
|
249
|
-
r =
|
|
250
|
-
},
|
|
251
|
-
l =
|
|
252
|
-
},
|
|
253
|
-
i.observe(
|
|
254
|
-
const d = s.subscribe(() =>
|
|
245
|
+
o.redraw(N, L, r, f, M), setTimeout(() => h(B.map(({ annotation: U }) => U)), 1);
|
|
246
|
+
}, g = (M) => {
|
|
247
|
+
f = M, p();
|
|
248
|
+
}, b = (M) => {
|
|
249
|
+
r = M, p();
|
|
250
|
+
}, w = (M) => {
|
|
251
|
+
l = M, p(!1);
|
|
252
|
+
}, y = () => p();
|
|
253
|
+
i.observe(y);
|
|
254
|
+
const d = s.subscribe(() => p()), c = () => p(!0);
|
|
255
255
|
document.addEventListener("scroll", c, { capture: !0, passive: !0 });
|
|
256
|
-
const
|
|
257
|
-
i.recalculatePositions(), f && f.reset(),
|
|
256
|
+
const A = Yt(() => {
|
|
257
|
+
i.recalculatePositions(), f && f.reset(), p();
|
|
258
258
|
});
|
|
259
|
-
window.addEventListener("resize",
|
|
260
|
-
const
|
|
261
|
-
|
|
262
|
-
const T = { attributes: !0, childList: !0, subtree: !0 },
|
|
263
|
-
|
|
259
|
+
window.addEventListener("resize", A);
|
|
260
|
+
const E = new ResizeObserver(A);
|
|
261
|
+
E.observe(t);
|
|
262
|
+
const T = { attributes: !0, childList: !0, subtree: !0 }, S = new MutationObserver((M) => {
|
|
263
|
+
M.every((m) => m.target === t || t.contains(m.target)) || p(!0);
|
|
264
264
|
});
|
|
265
|
-
return
|
|
265
|
+
return S.observe(document.body, T), {
|
|
266
266
|
destroy: () => {
|
|
267
|
-
t.removeEventListener("pointermove",
|
|
267
|
+
t.removeEventListener("pointermove", u), o.destroy(), i.unobserve(y), d(), document.removeEventListener("scroll", c), window.removeEventListener("resize", A), E.disconnect(), S.disconnect();
|
|
268
268
|
},
|
|
269
|
-
redraw:
|
|
270
|
-
setStyle:
|
|
271
|
-
setFilter:
|
|
272
|
-
setPainter:
|
|
269
|
+
redraw: p,
|
|
270
|
+
setStyle: b,
|
|
271
|
+
setFilter: w,
|
|
272
|
+
setPainter: g,
|
|
273
273
|
setVisible: o.setVisible
|
|
274
274
|
};
|
|
275
|
-
},
|
|
275
|
+
}, $e = () => {
|
|
276
276
|
const t = document.createElement("canvas");
|
|
277
277
|
return t.width = window.innerWidth, t.height = window.innerHeight, t.className = "r6o-canvas-highlight-layer bg", t;
|
|
278
|
-
},
|
|
278
|
+
}, He = (t, e) => {
|
|
279
279
|
t.width = window.innerWidth, t.height = window.innerHeight;
|
|
280
|
-
},
|
|
280
|
+
}, je = (t) => {
|
|
281
281
|
t.classList.add("r6o-annotatable");
|
|
282
|
-
const e =
|
|
282
|
+
const e = $e(), n = e.getContext("2d");
|
|
283
283
|
document.body.appendChild(e);
|
|
284
|
-
const o = (r, l, f,
|
|
285
|
-
const { width:
|
|
286
|
-
n.clearRect(-0.5, -0.5,
|
|
287
|
-
const { top:
|
|
288
|
-
[...r].sort((
|
|
289
|
-
const { annotation: { target: { created: c } } } =
|
|
290
|
-
return c.getTime() -
|
|
291
|
-
}).forEach((
|
|
292
|
-
var
|
|
293
|
-
const d = f ? typeof f == "function" ? f(
|
|
294
|
-
x: T +
|
|
295
|
-
y:
|
|
284
|
+
const o = (r, l, f, h) => requestAnimationFrame(() => {
|
|
285
|
+
const { width: u, height: p } = e;
|
|
286
|
+
n.clearRect(-0.5, -0.5, u + 1, p + 1), h && h.clear();
|
|
287
|
+
const { top: g, left: b } = l;
|
|
288
|
+
[...r].sort((y, d) => {
|
|
289
|
+
const { annotation: { target: { created: c } } } = y, { annotation: { target: { created: A } } } = d;
|
|
290
|
+
return c.getTime() - A.getTime();
|
|
291
|
+
}).forEach((y) => {
|
|
292
|
+
var E;
|
|
293
|
+
const d = f ? typeof f == "function" ? f(y.annotation, y.state) : f : (E = y.state) != null && E.selected ? wt : W, c = h && h.paint(y, l) || d, A = y.rects.map(({ x: T, y: S, width: O, height: M }) => ({
|
|
294
|
+
x: T + b,
|
|
295
|
+
y: S + g,
|
|
296
296
|
width: O,
|
|
297
|
-
height:
|
|
297
|
+
height: M
|
|
298
298
|
}));
|
|
299
|
-
if (n.fillStyle = c.fill, n.globalAlpha = c.fillOpacity || 1,
|
|
300
|
-
({ x: T, y:
|
|
299
|
+
if (n.fillStyle = c.fill, n.globalAlpha = c.fillOpacity || 1, A.forEach(
|
|
300
|
+
({ x: T, y: S, width: O, height: M }) => n.fillRect(T, S, O, M)
|
|
301
301
|
), c.underlineColor) {
|
|
302
302
|
n.globalAlpha = 1, n.strokeStyle = c.underlineColor, n.lineWidth = c.underlineThickness ?? 1;
|
|
303
303
|
const T = c.underlineOffset ?? 0;
|
|
304
|
-
|
|
305
|
-
n.beginPath(), n.moveTo(
|
|
304
|
+
A.forEach(({ x: S, y: O, width: M, height: L }) => {
|
|
305
|
+
n.beginPath(), n.moveTo(S, O + L + T), n.lineTo(S + M, O + L + T), n.stroke();
|
|
306
306
|
});
|
|
307
307
|
}
|
|
308
308
|
});
|
|
309
|
-
}), i =
|
|
310
|
-
|
|
309
|
+
}), i = Yt(() => {
|
|
310
|
+
He(e);
|
|
311
311
|
});
|
|
312
312
|
return window.addEventListener("resize", i), {
|
|
313
313
|
destroy: () => {
|
|
@@ -318,144 +318,144 @@ const se = "not-annotatable", Z = `.${se}`, nt = (t) => {
|
|
|
318
318
|
},
|
|
319
319
|
redraw: o
|
|
320
320
|
};
|
|
321
|
-
},
|
|
322
|
-
var
|
|
321
|
+
}, ze = (t, e, n) => Kt(t, e, n, je(t));
|
|
322
|
+
var Fe = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, j = function(t) {
|
|
323
323
|
return typeof t == "string" ? t.length > 0 : typeof t == "number";
|
|
324
|
-
},
|
|
324
|
+
}, V = function(t, e, n) {
|
|
325
325
|
return e === void 0 && (e = 0), n === void 0 && (n = Math.pow(10, e)), Math.round(n * t) / n + 0;
|
|
326
326
|
}, X = function(t, e, n) {
|
|
327
327
|
return e === void 0 && (e = 0), n === void 0 && (n = 1), t > n ? n : t > e ? t : e;
|
|
328
|
-
},
|
|
328
|
+
}, le = function(t) {
|
|
329
329
|
return (t = isFinite(t) ? t % 360 : 0) > 0 ? t : t + 360;
|
|
330
|
-
},
|
|
330
|
+
}, Pt = function(t) {
|
|
331
331
|
return { r: X(t.r, 0, 255), g: X(t.g, 0, 255), b: X(t.b, 0, 255), a: X(t.a) };
|
|
332
|
-
},
|
|
333
|
-
return { r:
|
|
334
|
-
},
|
|
332
|
+
}, vt = function(t) {
|
|
333
|
+
return { r: V(t.r), g: V(t.g), b: V(t.b), a: V(t.a, 3) };
|
|
334
|
+
}, We = /^#([0-9a-f]{3,8})$/i, ht = function(t) {
|
|
335
335
|
var e = t.toString(16);
|
|
336
336
|
return e.length < 2 ? "0" + e : e;
|
|
337
|
-
},
|
|
337
|
+
}, de = function(t) {
|
|
338
338
|
var e = t.r, n = t.g, o = t.b, i = t.a, s = Math.max(e, n, o), a = s - Math.min(e, n, o), r = a ? s === e ? (n - o) / a : s === n ? 2 + (o - e) / a : 4 + (e - n) / a : 0;
|
|
339
339
|
return { h: 60 * (r < 0 ? r + 6 : r), s: s ? a / s * 100 : 0, v: s / 255 * 100, a: i };
|
|
340
|
-
},
|
|
340
|
+
}, ue = function(t) {
|
|
341
341
|
var e = t.h, n = t.s, o = t.v, i = t.a;
|
|
342
342
|
e = e / 360 * 6, n /= 100, o /= 100;
|
|
343
343
|
var s = Math.floor(e), a = o * (1 - n), r = o * (1 - (e - s) * n), l = o * (1 - (1 - e + s) * n), f = s % 6;
|
|
344
344
|
return { r: 255 * [o, r, a, a, l, o][f], g: 255 * [l, o, o, r, a, a][f], b: 255 * [a, a, l, o, o, r][f], a: i };
|
|
345
|
-
}, Pt = function(t) {
|
|
346
|
-
return { h: ce(t.h), s: X(t.s, 0, 100), l: X(t.l, 0, 100), a: X(t.a) };
|
|
347
345
|
}, $t = function(t) {
|
|
348
|
-
return { h:
|
|
346
|
+
return { h: le(t.h), s: X(t.s, 0, 100), l: X(t.l, 0, 100), a: X(t.a) };
|
|
349
347
|
}, Ht = function(t) {
|
|
350
|
-
return
|
|
348
|
+
return { h: V(t.h), s: V(t.s), l: V(t.l), a: V(t.a, 3) };
|
|
349
|
+
}, jt = function(t) {
|
|
350
|
+
return ue((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 }));
|
|
351
351
|
var e, n, o;
|
|
352
|
-
},
|
|
353
|
-
return { h: (e =
|
|
352
|
+
}, at = function(t) {
|
|
353
|
+
return { h: (e = de(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 };
|
|
354
354
|
var e, n, o, i;
|
|
355
|
-
},
|
|
356
|
-
var e =
|
|
357
|
-
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 ?
|
|
355
|
+
}, qe = /^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, Qe = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, Je = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, zt = { string: [[function(t) {
|
|
356
|
+
var e = We.exec(t);
|
|
357
|
+
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 ? V(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 ? V(parseInt(t.substr(6, 2), 16) / 255, 2) : 1 } : null : null;
|
|
358
358
|
}, "hex"], [function(t) {
|
|
359
|
-
var e =
|
|
360
|
-
return e ? e[2] !== e[4] || e[4] !== e[6] ? null :
|
|
359
|
+
var e = Qe.exec(t) || Je.exec(t);
|
|
360
|
+
return e ? e[2] !== e[4] || e[4] !== e[6] ? null : Pt({ 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;
|
|
361
361
|
}, "rgb"], [function(t) {
|
|
362
|
-
var e =
|
|
362
|
+
var e = qe.exec(t) || Ge.exec(t);
|
|
363
363
|
if (!e) return null;
|
|
364
|
-
var n, o, i =
|
|
365
|
-
return
|
|
364
|
+
var n, o, i = $t({ h: (n = e[1], o = e[2], o === void 0 && (o = "deg"), Number(n) * (Fe[o] || 1)), s: Number(e[3]), l: Number(e[4]), a: e[5] === void 0 ? 1 : Number(e[5]) / (e[6] ? 100 : 1) });
|
|
365
|
+
return jt(i);
|
|
366
366
|
}, "hsl"]], object: [[function(t) {
|
|
367
367
|
var e = t.r, n = t.g, o = t.b, i = t.a, s = i === void 0 ? 1 : i;
|
|
368
|
-
return j(e) && j(n) && j(o) ?
|
|
368
|
+
return j(e) && j(n) && j(o) ? Pt({ r: Number(e), g: Number(n), b: Number(o), a: Number(s) }) : null;
|
|
369
369
|
}, "rgb"], [function(t) {
|
|
370
370
|
var e = t.h, n = t.s, o = t.l, i = t.a, s = i === void 0 ? 1 : i;
|
|
371
371
|
if (!j(e) || !j(n) || !j(o)) return null;
|
|
372
|
-
var a =
|
|
373
|
-
return
|
|
372
|
+
var a = $t({ h: Number(e), s: Number(n), l: Number(o), a: Number(s) });
|
|
373
|
+
return jt(a);
|
|
374
374
|
}, "hsl"], [function(t) {
|
|
375
375
|
var e = t.h, n = t.s, o = t.v, i = t.a, s = i === void 0 ? 1 : i;
|
|
376
376
|
if (!j(e) || !j(n) || !j(o)) return null;
|
|
377
377
|
var a = function(r) {
|
|
378
|
-
return { h:
|
|
378
|
+
return { h: le(r.h), s: X(r.s, 0, 100), v: X(r.v, 0, 100), a: X(r.a) };
|
|
379
379
|
}({ h: Number(e), s: Number(n), v: Number(o), a: Number(s) });
|
|
380
|
-
return
|
|
381
|
-
}, "hsv"]] },
|
|
380
|
+
return ue(a);
|
|
381
|
+
}, "hsv"]] }, Ft = function(t, e) {
|
|
382
382
|
for (var n = 0; n < e.length; n++) {
|
|
383
383
|
var o = e[n][0](t);
|
|
384
384
|
if (o) return [o, e[n][1]];
|
|
385
385
|
}
|
|
386
386
|
return [null, void 0];
|
|
387
|
-
},
|
|
388
|
-
return typeof t == "string" ?
|
|
389
|
-
},
|
|
390
|
-
var n =
|
|
387
|
+
}, Ze = function(t) {
|
|
388
|
+
return typeof t == "string" ? Ft(t.trim(), zt.string) : typeof t == "object" && t !== null ? Ft(t, zt.object) : [null, void 0];
|
|
389
|
+
}, Et = function(t, e) {
|
|
390
|
+
var n = at(t);
|
|
391
391
|
return { h: n.h, s: X(n.s + 100 * e, 0, 100), l: n.l, a: n.a };
|
|
392
|
-
},
|
|
392
|
+
}, St = function(t) {
|
|
393
393
|
return (299 * t.r + 587 * t.g + 114 * t.b) / 1e3 / 255;
|
|
394
|
-
},
|
|
395
|
-
var n =
|
|
394
|
+
}, Wt = function(t, e) {
|
|
395
|
+
var n = at(t);
|
|
396
396
|
return { h: n.h, s: n.s, l: X(n.l + 100 * e, 0, 100), a: n.a };
|
|
397
|
-
},
|
|
397
|
+
}, qt = function() {
|
|
398
398
|
function t(e) {
|
|
399
|
-
this.parsed =
|
|
399
|
+
this.parsed = Ze(e)[0], this.rgba = this.parsed || { r: 0, g: 0, b: 0, a: 1 };
|
|
400
400
|
}
|
|
401
401
|
return t.prototype.isValid = function() {
|
|
402
402
|
return this.parsed !== null;
|
|
403
403
|
}, t.prototype.brightness = function() {
|
|
404
|
-
return
|
|
404
|
+
return V(St(this.rgba), 2);
|
|
405
405
|
}, t.prototype.isDark = function() {
|
|
406
|
-
return
|
|
406
|
+
return St(this.rgba) < 0.5;
|
|
407
407
|
}, t.prototype.isLight = function() {
|
|
408
|
-
return
|
|
408
|
+
return St(this.rgba) >= 0.5;
|
|
409
409
|
}, t.prototype.toHex = function() {
|
|
410
|
-
return e =
|
|
410
|
+
return e = vt(this.rgba), n = e.r, o = e.g, i = e.b, a = (s = e.a) < 1 ? ht(V(255 * s)) : "", "#" + ht(n) + ht(o) + ht(i) + a;
|
|
411
411
|
var e, n, o, i, s, a;
|
|
412
412
|
}, t.prototype.toRgb = function() {
|
|
413
|
-
return
|
|
413
|
+
return vt(this.rgba);
|
|
414
414
|
}, t.prototype.toRgbString = function() {
|
|
415
|
-
return e =
|
|
415
|
+
return e = vt(this.rgba), n = e.r, o = e.g, i = e.b, (s = e.a) < 1 ? "rgba(" + n + ", " + o + ", " + i + ", " + s + ")" : "rgb(" + n + ", " + o + ", " + i + ")";
|
|
416
416
|
var e, n, o, i, s;
|
|
417
417
|
}, t.prototype.toHsl = function() {
|
|
418
|
-
return
|
|
418
|
+
return Ht(at(this.rgba));
|
|
419
419
|
}, t.prototype.toHslString = function() {
|
|
420
|
-
return e =
|
|
420
|
+
return e = Ht(at(this.rgba)), n = e.h, o = e.s, i = e.l, (s = e.a) < 1 ? "hsla(" + n + ", " + o + "%, " + i + "%, " + s + ")" : "hsl(" + n + ", " + o + "%, " + i + "%)";
|
|
421
421
|
var e, n, o, i, s;
|
|
422
422
|
}, t.prototype.toHsv = function() {
|
|
423
|
-
return e =
|
|
423
|
+
return e = de(this.rgba), { h: V(e.h), s: V(e.s), v: V(e.v), a: V(e.a, 3) };
|
|
424
424
|
var e;
|
|
425
425
|
}, t.prototype.invert = function() {
|
|
426
426
|
return $({ r: 255 - (e = this.rgba).r, g: 255 - e.g, b: 255 - e.b, a: e.a });
|
|
427
427
|
var e;
|
|
428
428
|
}, t.prototype.saturate = function(e) {
|
|
429
|
-
return e === void 0 && (e = 0.1), $(
|
|
429
|
+
return e === void 0 && (e = 0.1), $(Et(this.rgba, e));
|
|
430
430
|
}, t.prototype.desaturate = function(e) {
|
|
431
|
-
return e === void 0 && (e = 0.1), $(
|
|
431
|
+
return e === void 0 && (e = 0.1), $(Et(this.rgba, -e));
|
|
432
432
|
}, t.prototype.grayscale = function() {
|
|
433
|
-
return $(
|
|
433
|
+
return $(Et(this.rgba, -1));
|
|
434
434
|
}, t.prototype.lighten = function(e) {
|
|
435
|
-
return e === void 0 && (e = 0.1), $(
|
|
435
|
+
return e === void 0 && (e = 0.1), $(Wt(this.rgba, e));
|
|
436
436
|
}, t.prototype.darken = function(e) {
|
|
437
|
-
return e === void 0 && (e = 0.1), $(
|
|
437
|
+
return e === void 0 && (e = 0.1), $(Wt(this.rgba, -e));
|
|
438
438
|
}, t.prototype.rotate = function(e) {
|
|
439
439
|
return e === void 0 && (e = 15), this.hue(this.hue() + e);
|
|
440
440
|
}, t.prototype.alpha = function(e) {
|
|
441
|
-
return typeof e == "number" ? $({ r: (n = this.rgba).r, g: n.g, b: n.b, a: e }) :
|
|
441
|
+
return typeof e == "number" ? $({ r: (n = this.rgba).r, g: n.g, b: n.b, a: e }) : V(this.rgba.a, 3);
|
|
442
442
|
var n;
|
|
443
443
|
}, t.prototype.hue = function(e) {
|
|
444
|
-
var n =
|
|
445
|
-
return typeof e == "number" ? $({ h: e, s: n.s, l: n.l, a: n.a }) :
|
|
444
|
+
var n = at(this.rgba);
|
|
445
|
+
return typeof e == "number" ? $({ h: e, s: n.s, l: n.l, a: n.a }) : V(n.h);
|
|
446
446
|
}, t.prototype.isEqual = function(e) {
|
|
447
447
|
return this.toHex() === $(e).toHex();
|
|
448
448
|
}, t;
|
|
449
449
|
}(), $ = function(t) {
|
|
450
|
-
return t instanceof
|
|
450
|
+
return t instanceof qt ? t : new qt(t);
|
|
451
451
|
};
|
|
452
|
-
const
|
|
452
|
+
const tn = (t) => [
|
|
453
453
|
`background-color:${$((t == null ? void 0 : t.fill) || W.fill).alpha((t == null ? void 0 : t.fillOpacity) === void 0 ? W.fillOpacity : t.fillOpacity).toHex()}`,
|
|
454
454
|
t != null && t.underlineThickness ? "text-decoration:underline" : void 0,
|
|
455
455
|
t != null && t.underlineColor ? `text-decoration-color:${t.underlineColor}` : void 0,
|
|
456
456
|
t != null && t.underlineOffset ? `text-underline-offset:${t.underlineOffset}px` : void 0,
|
|
457
457
|
t != null && t.underlineThickness ? `text-decoration-thickness:${t.underlineThickness}px` : void 0
|
|
458
|
-
].filter(Boolean).join(";"),
|
|
458
|
+
].filter(Boolean).join(";"), en = () => {
|
|
459
459
|
const t = document.createElement("style");
|
|
460
460
|
document.getElementsByTagName("head")[0].appendChild(t);
|
|
461
461
|
let e = /* @__PURE__ */ new Set();
|
|
@@ -468,23 +468,23 @@ const en = (t) => [
|
|
|
468
468
|
},
|
|
469
469
|
redraw: (s, a, r, l) => {
|
|
470
470
|
l && l.clear();
|
|
471
|
-
const f = new Set(s.map((
|
|
472
|
-
Array.from(e).filter((
|
|
473
|
-
const
|
|
474
|
-
var
|
|
475
|
-
const
|
|
476
|
-
return `::highlight(_${
|
|
471
|
+
const f = new Set(s.map((u) => u.annotation.id));
|
|
472
|
+
Array.from(e).filter((u) => !f.has(u));
|
|
473
|
+
const h = s.map((u) => {
|
|
474
|
+
var b;
|
|
475
|
+
const p = r ? typeof r == "function" ? r(u.annotation, u.state) : r : (b = u.state) != null && b.selected ? wt : W, g = l && l.paint(u, a) || p;
|
|
476
|
+
return `::highlight(_${u.annotation.id}) { ${tn(g)} }`;
|
|
477
477
|
});
|
|
478
|
-
t.innerHTML =
|
|
479
|
-
`), CSS.highlights.clear(), s.forEach(({ annotation:
|
|
480
|
-
const
|
|
481
|
-
CSS.highlights.set(`_${
|
|
478
|
+
t.innerHTML = h.join(`
|
|
479
|
+
`), CSS.highlights.clear(), s.forEach(({ annotation: u }) => {
|
|
480
|
+
const p = u.target.selector.map((b) => b.range), g = new Highlight(...p);
|
|
481
|
+
CSS.highlights.set(`_${u.id}`, g);
|
|
482
482
|
}), e = f;
|
|
483
483
|
}
|
|
484
484
|
};
|
|
485
|
-
},
|
|
486
|
-
var
|
|
487
|
-
function
|
|
485
|
+
}, nn = (t, e, n) => Kt(t, e, n, en());
|
|
486
|
+
var Gt = Object.prototype.hasOwnProperty;
|
|
487
|
+
function Ut(t, e) {
|
|
488
488
|
var n, o;
|
|
489
489
|
if (t === e) return !0;
|
|
490
490
|
if (t && e && (n = t.constructor) === e.constructor) {
|
|
@@ -492,22 +492,22 @@ function Nt(t, e) {
|
|
|
492
492
|
if (n === RegExp) return t.toString() === e.toString();
|
|
493
493
|
if (n === Array) {
|
|
494
494
|
if ((o = t.length) === e.length)
|
|
495
|
-
for (; o-- &&
|
|
495
|
+
for (; o-- && Ut(t[o], e[o]); ) ;
|
|
496
496
|
return o === -1;
|
|
497
497
|
}
|
|
498
498
|
if (!n || typeof t == "object") {
|
|
499
499
|
o = 0;
|
|
500
500
|
for (n in t)
|
|
501
|
-
if (
|
|
501
|
+
if (Gt.call(t, n) && ++o && !Gt.call(e, n) || !(n in e) || !Ut(t[n], e[n])) return !1;
|
|
502
502
|
return Object.keys(e).length === o;
|
|
503
503
|
}
|
|
504
504
|
}
|
|
505
505
|
return t !== t && e !== e;
|
|
506
506
|
}
|
|
507
|
-
const
|
|
507
|
+
const on = (t, e) => {
|
|
508
508
|
const n = (s, a) => s.x <= a.x + a.width && s.x + s.width >= a.x && s.y <= a.y + a.height && s.y + s.height >= a.y, o = (s) => s.rects.reduce((a, r) => a + r.width, 0), i = e.filter(({ rects: s }) => s.some((a) => n(t, a)));
|
|
509
509
|
return i.sort((s, a) => o(a) - o(s)), i.findIndex((s) => s.rects.includes(t));
|
|
510
|
-
},
|
|
510
|
+
}, sn = (t) => {
|
|
511
511
|
t.classList.add("r6o-annotatable");
|
|
512
512
|
const e = document.createElement("div");
|
|
513
513
|
e.className = "r6o-span-highlight-layer", t.insertBefore(e, t.firstChild);
|
|
@@ -516,18 +516,18 @@ const sn = (t, e) => {
|
|
|
516
516
|
destroy: () => {
|
|
517
517
|
e.remove();
|
|
518
518
|
},
|
|
519
|
-
redraw: (a, r, l, f,
|
|
520
|
-
const
|
|
521
|
-
if (!f && !
|
|
522
|
-
|
|
523
|
-
const { annotation: { target: { created:
|
|
524
|
-
return
|
|
525
|
-
}).forEach((
|
|
526
|
-
|
|
527
|
-
const
|
|
528
|
-
if (
|
|
519
|
+
redraw: (a, r, l, f, h) => {
|
|
520
|
+
const p = !(Ut(n, a) && h);
|
|
521
|
+
if (!f && !p) return;
|
|
522
|
+
p && (e.innerHTML = ""), [...a].sort((b, w) => {
|
|
523
|
+
const { annotation: { target: { created: y } } } = b, { annotation: { target: { created: d } } } = w;
|
|
524
|
+
return y && d ? y.getTime() - d.getTime() : 0;
|
|
525
|
+
}).forEach((b) => {
|
|
526
|
+
b.rects.map((w) => {
|
|
527
|
+
const y = on(w, a), d = De(b, r, l, f, y);
|
|
528
|
+
if (p) {
|
|
529
529
|
const c = document.createElement("span");
|
|
530
|
-
c.className = "r6o-annotation", c.dataset.annotation =
|
|
530
|
+
c.className = "r6o-annotation", c.dataset.annotation = b.annotation.id, c.style.left = `${w.x}px`, c.style.top = `${w.y}px`, c.style.width = `${w.width}px`, c.style.height = `${w.height}px`, c.style.backgroundColor = $((d == null ? void 0 : d.fill) || W.fill).alpha((d == null ? void 0 : d.fillOpacity) === void 0 ? W.fillOpacity : d.fillOpacity).toHex(), d.underlineStyle && (c.style.borderStyle = d.underlineStyle), d.underlineColor && (c.style.borderColor = d.underlineColor), d.underlineThickness && (c.style.borderBottomWidth = `${d.underlineThickness}px`), d.underlineOffset && (c.style.paddingBottom = `${d.underlineOffset}px`), e.appendChild(c);
|
|
531
531
|
}
|
|
532
532
|
});
|
|
533
533
|
}), n = a;
|
|
@@ -536,32 +536,32 @@ const sn = (t, e) => {
|
|
|
536
536
|
a ? e.classList.remove("hidden") : e.classList.add("hidden");
|
|
537
537
|
}
|
|
538
538
|
};
|
|
539
|
-
},
|
|
539
|
+
}, rn = (t, e, n) => Kt(t, e, n, sn(t)), Y = [];
|
|
540
540
|
for (let t = 0; t < 256; ++t)
|
|
541
|
-
|
|
542
|
-
function
|
|
543
|
-
return (
|
|
541
|
+
Y.push((t + 256).toString(16).slice(1));
|
|
542
|
+
function an(t, e = 0) {
|
|
543
|
+
return (Y[t[e + 0]] + Y[t[e + 1]] + Y[t[e + 2]] + Y[t[e + 3]] + "-" + Y[t[e + 4]] + Y[t[e + 5]] + "-" + Y[t[e + 6]] + Y[t[e + 7]] + "-" + Y[t[e + 8]] + Y[t[e + 9]] + "-" + Y[t[e + 10]] + Y[t[e + 11]] + Y[t[e + 12]] + Y[t[e + 13]] + Y[t[e + 14]] + Y[t[e + 15]]).toLowerCase();
|
|
544
544
|
}
|
|
545
|
-
let
|
|
546
|
-
const
|
|
547
|
-
function
|
|
548
|
-
if (!
|
|
545
|
+
let Ct;
|
|
546
|
+
const cn = new Uint8Array(16);
|
|
547
|
+
function ln() {
|
|
548
|
+
if (!Ct) {
|
|
549
549
|
if (typeof crypto > "u" || !crypto.getRandomValues)
|
|
550
550
|
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
551
|
-
|
|
551
|
+
Ct = crypto.getRandomValues.bind(crypto);
|
|
552
552
|
}
|
|
553
|
-
return
|
|
553
|
+
return Ct(cn);
|
|
554
554
|
}
|
|
555
|
-
const
|
|
556
|
-
function
|
|
557
|
-
if (
|
|
558
|
-
return
|
|
555
|
+
const dn = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), Qt = { randomUUID: dn };
|
|
556
|
+
function fe(t, e, n) {
|
|
557
|
+
if (Qt.randomUUID && !e && !t)
|
|
558
|
+
return Qt.randomUUID();
|
|
559
559
|
t = t || {};
|
|
560
|
-
const o = t.random || (t.rng ||
|
|
561
|
-
return o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128,
|
|
560
|
+
const o = t.random || (t.rng || ln)();
|
|
561
|
+
return o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128, an(o);
|
|
562
562
|
}
|
|
563
|
-
var
|
|
564
|
-
function
|
|
563
|
+
var Jt = Object.prototype.hasOwnProperty;
|
|
564
|
+
function G(t, e) {
|
|
565
565
|
var n, o;
|
|
566
566
|
if (t === e) return !0;
|
|
567
567
|
if (t && e && (n = t.constructor) === e.constructor) {
|
|
@@ -569,52 +569,52 @@ function q(t, e) {
|
|
|
569
569
|
if (n === RegExp) return t.toString() === e.toString();
|
|
570
570
|
if (n === Array) {
|
|
571
571
|
if ((o = t.length) === e.length)
|
|
572
|
-
for (; o-- &&
|
|
572
|
+
for (; o-- && G(t[o], e[o]); ) ;
|
|
573
573
|
return o === -1;
|
|
574
574
|
}
|
|
575
575
|
if (!n || typeof t == "object") {
|
|
576
576
|
o = 0;
|
|
577
577
|
for (n in t)
|
|
578
|
-
if (
|
|
578
|
+
if (Jt.call(t, n) && ++o && !Jt.call(e, n) || !(n in e) || !G(t[n], e[n])) return !1;
|
|
579
579
|
return Object.keys(e).length === o;
|
|
580
580
|
}
|
|
581
581
|
}
|
|
582
582
|
return t !== t && e !== e;
|
|
583
583
|
}
|
|
584
|
-
function
|
|
584
|
+
function Lt() {
|
|
585
585
|
}
|
|
586
|
-
function
|
|
586
|
+
function un(t, e) {
|
|
587
587
|
return t != t ? e == e : t !== e || t && typeof t == "object" || typeof t == "function";
|
|
588
588
|
}
|
|
589
|
-
const
|
|
590
|
-
function
|
|
589
|
+
const Q = [];
|
|
590
|
+
function Dt(t, e = Lt) {
|
|
591
591
|
let n;
|
|
592
592
|
const o = /* @__PURE__ */ new Set();
|
|
593
593
|
function i(r) {
|
|
594
|
-
if (
|
|
595
|
-
const l = !
|
|
594
|
+
if (un(t, r) && (t = r, n)) {
|
|
595
|
+
const l = !Q.length;
|
|
596
596
|
for (const f of o)
|
|
597
|
-
f[1](),
|
|
597
|
+
f[1](), Q.push(f, t);
|
|
598
598
|
if (l) {
|
|
599
|
-
for (let f = 0; f <
|
|
600
|
-
|
|
601
|
-
|
|
599
|
+
for (let f = 0; f < Q.length; f += 2)
|
|
600
|
+
Q[f][0](Q[f + 1]);
|
|
601
|
+
Q.length = 0;
|
|
602
602
|
}
|
|
603
603
|
}
|
|
604
604
|
}
|
|
605
605
|
function s(r) {
|
|
606
606
|
i(r(t));
|
|
607
607
|
}
|
|
608
|
-
function a(r, l =
|
|
608
|
+
function a(r, l = Lt) {
|
|
609
609
|
const f = [r, l];
|
|
610
|
-
return o.add(f), o.size === 1 && (n = e(i, s) ||
|
|
610
|
+
return o.add(f), o.size === 1 && (n = e(i, s) || Lt), r(t), () => {
|
|
611
611
|
o.delete(f), o.size === 0 && n && (n(), n = null);
|
|
612
612
|
};
|
|
613
613
|
}
|
|
614
614
|
return { set: i, update: s, subscribe: a };
|
|
615
615
|
}
|
|
616
|
-
const
|
|
617
|
-
const { subscribe: e, set: n } =
|
|
616
|
+
const fn = (t) => {
|
|
617
|
+
const { subscribe: e, set: n } = Dt();
|
|
618
618
|
let o;
|
|
619
619
|
return e((i) => o = i), t.observe(({ changes: i }) => {
|
|
620
620
|
if (o) {
|
|
@@ -630,53 +630,57 @@ const hn = (t) => {
|
|
|
630
630
|
set: n
|
|
631
631
|
};
|
|
632
632
|
};
|
|
633
|
-
var
|
|
634
|
-
const
|
|
635
|
-
const { subscribe: o, set: i } =
|
|
636
|
-
let s = e, a =
|
|
637
|
-
o((
|
|
633
|
+
var hn = /* @__PURE__ */ ((t) => (t.EDIT = "EDIT", t.SELECT = "SELECT", t.NONE = "NONE", t))(hn || {});
|
|
634
|
+
const pt = { selected: [] }, pn = (t, e, n) => {
|
|
635
|
+
const { subscribe: o, set: i } = Dt(pt);
|
|
636
|
+
let s = e, a = pt;
|
|
637
|
+
o((b) => a = b);
|
|
638
638
|
const r = () => {
|
|
639
|
-
|
|
639
|
+
G(a, pt) || i(pt);
|
|
640
640
|
}, l = () => {
|
|
641
|
-
var
|
|
642
|
-
return ((
|
|
643
|
-
}, f = (
|
|
641
|
+
var b;
|
|
642
|
+
return ((b = a.selected) == null ? void 0 : b.length) === 0;
|
|
643
|
+
}, f = (b) => {
|
|
644
644
|
if (l())
|
|
645
645
|
return !1;
|
|
646
|
-
const
|
|
647
|
-
return a.selected.some((
|
|
648
|
-
},
|
|
649
|
-
|
|
650
|
-
if (
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
i({ selected: [], event: y });
|
|
646
|
+
const w = typeof b == "string" ? b : b.id;
|
|
647
|
+
return a.selected.some((y) => y.id === w);
|
|
648
|
+
}, h = (b, w) => {
|
|
649
|
+
let y;
|
|
650
|
+
if (Array.isArray(b)) {
|
|
651
|
+
if (y = b.map((c) => t.getAnnotation(c)).filter(Boolean), y.length < b.length) {
|
|
652
|
+
console.warn("Invalid selection: " + b.filter((c) => !y.some((A) => A.id === c)));
|
|
653
|
+
return;
|
|
654
|
+
}
|
|
655
|
+
} else {
|
|
656
|
+
const c = t.getAnnotation(b);
|
|
657
|
+
if (!c) {
|
|
658
|
+
console.warn("Invalid selection: " + b);
|
|
659
|
+
return;
|
|
660
|
+
}
|
|
661
|
+
y = [c];
|
|
663
662
|
}
|
|
664
|
-
|
|
665
|
-
|
|
663
|
+
const d = y.reduce((c, A) => {
|
|
664
|
+
const E = Zt(A, s);
|
|
665
|
+
return E === "EDIT" ? [...c, { id: A.id, editable: !0 }] : E === "SELECT" ? [...c, { id: A.id }] : c;
|
|
666
|
+
}, []);
|
|
667
|
+
i({ selected: d, event: w });
|
|
668
|
+
}, u = (b, w) => {
|
|
669
|
+
const y = Array.isArray(b) ? b : [b], d = y.map((c) => t.getAnnotation(c)).filter((c) => !!c);
|
|
666
670
|
i({
|
|
667
671
|
selected: d.map((c) => {
|
|
668
|
-
const
|
|
669
|
-
return { id: c.id, editable:
|
|
672
|
+
const A = w === void 0 ? Zt(c, s) === "EDIT" : w;
|
|
673
|
+
return { id: c.id, editable: A };
|
|
670
674
|
})
|
|
671
|
-
}), d.length !==
|
|
672
|
-
},
|
|
675
|
+
}), d.length !== y.length && console.warn("Invalid selection", b);
|
|
676
|
+
}, p = (b) => {
|
|
673
677
|
if (l())
|
|
674
678
|
return !1;
|
|
675
|
-
const { selected:
|
|
676
|
-
|
|
677
|
-
},
|
|
679
|
+
const { selected: w } = a;
|
|
680
|
+
w.some(({ id: y }) => b.includes(y)) && i({ selected: w.filter(({ id: y }) => !b.includes(y)) });
|
|
681
|
+
}, g = (b) => s = b;
|
|
678
682
|
return t.observe(
|
|
679
|
-
({ changes:
|
|
683
|
+
({ changes: b }) => p((b.deleted || []).map((w) => w.id))
|
|
680
684
|
), {
|
|
681
685
|
get event() {
|
|
682
686
|
return a ? a.event : null;
|
|
@@ -690,36 +694,36 @@ const ft = { selected: [] }, gn = (t, e, n) => {
|
|
|
690
694
|
clear: r,
|
|
691
695
|
isEmpty: l,
|
|
692
696
|
isSelected: f,
|
|
693
|
-
setSelected:
|
|
694
|
-
setUserSelectAction:
|
|
697
|
+
setSelected: u,
|
|
698
|
+
setUserSelectAction: g,
|
|
695
699
|
subscribe: o,
|
|
696
|
-
userSelect:
|
|
700
|
+
userSelect: h
|
|
697
701
|
};
|
|
698
|
-
},
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
return (V[t[e + 0]] + V[t[e + 1]] + V[t[e + 2]] + V[t[e + 3]] + "-" + V[t[e + 4]] + V[t[e + 5]] + "-" + V[t[e + 6]] + V[t[e + 7]] + "-" + V[t[e + 8]] + V[t[e + 9]] + "-" + V[t[e + 10]] + V[t[e + 11]] + V[t[e + 12]] + V[t[e + 13]] + V[t[e + 14]] + V[t[e + 15]]).toLowerCase();
|
|
702
|
+
}, Zt = (t, e, n) => typeof e == "function" ? e(t) : e || "EDIT", K = [];
|
|
703
|
+
for (let t = 0; t < 256; ++t)
|
|
704
|
+
K.push((t + 256).toString(16).slice(1));
|
|
705
|
+
function gn(t, e = 0) {
|
|
706
|
+
return (K[t[e + 0]] + K[t[e + 1]] + K[t[e + 2]] + K[t[e + 3]] + "-" + K[t[e + 4]] + K[t[e + 5]] + "-" + K[t[e + 6]] + K[t[e + 7]] + "-" + K[t[e + 8]] + K[t[e + 9]] + "-" + K[t[e + 10]] + K[t[e + 11]] + K[t[e + 12]] + K[t[e + 13]] + K[t[e + 14]] + K[t[e + 15]]).toLowerCase();
|
|
704
707
|
}
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
708
|
+
let Tt;
|
|
709
|
+
const mn = new Uint8Array(16);
|
|
710
|
+
function yn() {
|
|
711
|
+
if (!Tt) {
|
|
712
|
+
if (typeof crypto > "u" || !crypto.getRandomValues)
|
|
713
|
+
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
714
|
+
Tt = crypto.getRandomValues.bind(crypto);
|
|
715
|
+
}
|
|
716
|
+
return Tt(mn);
|
|
710
717
|
}
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
randomUUID
|
|
714
|
-
|
|
715
|
-
function fe(t, e, n) {
|
|
716
|
-
if (Zt.randomUUID && !e && !t)
|
|
717
|
-
return Zt.randomUUID();
|
|
718
|
+
const bn = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), te = { randomUUID: bn };
|
|
719
|
+
function he(t, e, n) {
|
|
720
|
+
if (te.randomUUID && !e && !t)
|
|
721
|
+
return te.randomUUID();
|
|
718
722
|
t = t || {};
|
|
719
|
-
|
|
720
|
-
return o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128,
|
|
723
|
+
const o = t.random || (t.rng || yn)();
|
|
724
|
+
return o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128, gn(o);
|
|
721
725
|
}
|
|
722
|
-
const
|
|
726
|
+
const Ot = (t) => {
|
|
723
727
|
const e = (n) => {
|
|
724
728
|
const o = { ...n };
|
|
725
729
|
return n.created && typeof n.created == "string" && (o.created = new Date(n.created)), n.updated && typeof n.updated == "string" && (o.updated = new Date(n.updated)), o;
|
|
@@ -729,13 +733,13 @@ const Tt = (t) => {
|
|
|
729
733
|
bodies: (t.bodies || []).map(e),
|
|
730
734
|
target: e(t.target)
|
|
731
735
|
};
|
|
732
|
-
},
|
|
733
|
-
id:
|
|
736
|
+
}, wo = (t, e, n, o) => ({
|
|
737
|
+
id: he(),
|
|
734
738
|
annotation: typeof t == "string" ? t : t.id,
|
|
735
739
|
created: n || /* @__PURE__ */ new Date(),
|
|
736
740
|
creator: o,
|
|
737
741
|
...e
|
|
738
|
-
}),
|
|
742
|
+
}), wn = (t, e) => {
|
|
739
743
|
const n = new Set(t.bodies.map((o) => o.id));
|
|
740
744
|
return e.bodies.filter((o) => !n.has(o.id));
|
|
741
745
|
}, An = (t, e) => {
|
|
@@ -743,20 +747,20 @@ const Tt = (t) => {
|
|
|
743
747
|
return t.bodies.filter((o) => !n.has(o.id));
|
|
744
748
|
}, xn = (t, e) => e.bodies.map((n) => {
|
|
745
749
|
const o = t.bodies.find((i) => i.id === n.id);
|
|
746
|
-
return { newBody: n, oldBody: o && !
|
|
747
|
-
}).filter(({ oldBody: n }) => n).map(({ oldBody: n, newBody: o }) => ({ oldBody: n, newBody: o })),
|
|
748
|
-
const n =
|
|
750
|
+
return { newBody: n, oldBody: o && !G(o, n) ? o : void 0 };
|
|
751
|
+
}).filter(({ oldBody: n }) => n).map(({ oldBody: n, newBody: o }) => ({ oldBody: n, newBody: o })), vn = (t, e) => !G(t.target, e.target), pe = (t, e) => {
|
|
752
|
+
const n = wn(t, e), o = An(t, e), i = xn(t, e);
|
|
749
753
|
return {
|
|
750
754
|
oldValue: t,
|
|
751
755
|
newValue: e,
|
|
752
756
|
bodiesCreated: n.length > 0 ? n : void 0,
|
|
753
757
|
bodiesDeleted: o.length > 0 ? o : void 0,
|
|
754
758
|
bodiesUpdated: i.length > 0 ? i : void 0,
|
|
755
|
-
targetUpdated:
|
|
759
|
+
targetUpdated: vn(t, e) ? { oldTarget: t.target, newTarget: e.target } : void 0
|
|
756
760
|
};
|
|
757
761
|
};
|
|
758
|
-
var
|
|
759
|
-
const
|
|
762
|
+
var k = /* @__PURE__ */ ((t) => (t.LOCAL = "LOCAL", t.REMOTE = "REMOTE", t.SILENT = "SILENT", t))(k || {});
|
|
763
|
+
const En = (t, e) => {
|
|
760
764
|
var n, o;
|
|
761
765
|
const { changes: i, origin: s } = e;
|
|
762
766
|
if (!(t.options.origin ? t.options.origin === s : s !== "SILENT"))
|
|
@@ -764,7 +768,7 @@ const Sn = (t, e) => {
|
|
|
764
768
|
if (t.options.ignore) {
|
|
765
769
|
const { ignore: a } = t.options, r = (l) => l && l.length > 0;
|
|
766
770
|
if (!(r(i.created) || r(i.deleted))) {
|
|
767
|
-
const l = (n = i.updated) == null ? void 0 : n.some((
|
|
771
|
+
const l = (n = i.updated) == null ? void 0 : n.some((h) => r(h.bodiesCreated) || r(h.bodiesDeleted) || r(h.bodiesUpdated)), f = (o = i.updated) == null ? void 0 : o.some((h) => h.targetUpdated);
|
|
768
772
|
if (a === "BODY_ONLY" && l && !f || a === "TARGET_ONLY" && f && !l)
|
|
769
773
|
return !1;
|
|
770
774
|
}
|
|
@@ -778,27 +782,27 @@ const Sn = (t, e) => {
|
|
|
778
782
|
return !!(Array.isArray(t.options.annotations) ? t.options.annotations : [t.options.annotations]).find((r) => a.has(r));
|
|
779
783
|
} else
|
|
780
784
|
return !0;
|
|
781
|
-
},
|
|
782
|
-
const n = new Set((t.created || []).map((
|
|
783
|
-
...(t.created || []).filter((
|
|
785
|
+
}, Sn = (t, e) => {
|
|
786
|
+
const n = new Set((t.created || []).map((u) => u.id)), o = new Set((t.updated || []).map(({ newValue: u }) => u.id)), i = new Set((e.created || []).map((u) => u.id)), s = new Set((e.deleted || []).map((u) => u.id)), a = new Set((e.updated || []).map(({ oldValue: u }) => u.id)), r = new Set((e.updated || []).filter(({ oldValue: u }) => n.has(u.id) || o.has(u.id)).map(({ oldValue: u }) => u.id)), l = [
|
|
787
|
+
...(t.created || []).filter((u) => !s.has(u.id)).map((u) => a.has(u.id) ? e.updated.find(({ oldValue: p }) => p.id === u.id).newValue : u),
|
|
784
788
|
...e.created || []
|
|
785
789
|
], f = [
|
|
786
|
-
...(t.deleted || []).filter((
|
|
787
|
-
...(e.deleted || []).filter((
|
|
788
|
-
],
|
|
789
|
-
...(t.updated || []).filter(({ newValue:
|
|
790
|
-
const { oldValue:
|
|
791
|
-
if (a.has(
|
|
792
|
-
const
|
|
793
|
-
return
|
|
790
|
+
...(t.deleted || []).filter((u) => !i.has(u.id)),
|
|
791
|
+
...(e.deleted || []).filter((u) => !n.has(u.id))
|
|
792
|
+
], h = [
|
|
793
|
+
...(t.updated || []).filter(({ newValue: u }) => !s.has(u.id)).map((u) => {
|
|
794
|
+
const { oldValue: p, newValue: g } = u;
|
|
795
|
+
if (a.has(g.id)) {
|
|
796
|
+
const b = e.updated.find((w) => w.oldValue.id === g.id).newValue;
|
|
797
|
+
return pe(p, b);
|
|
794
798
|
} else
|
|
795
|
-
return
|
|
799
|
+
return u;
|
|
796
800
|
}),
|
|
797
|
-
...(e.updated || []).filter(({ oldValue:
|
|
801
|
+
...(e.updated || []).filter(({ oldValue: u }) => !r.has(u.id))
|
|
798
802
|
];
|
|
799
|
-
return { created: l, deleted: f, updated:
|
|
800
|
-
},
|
|
801
|
-
const e = t.id === void 0 ?
|
|
803
|
+
return { created: l, deleted: f, updated: h };
|
|
804
|
+
}, Mt = (t) => {
|
|
805
|
+
const e = t.id === void 0 ? he() : t.id;
|
|
802
806
|
return {
|
|
803
807
|
...t,
|
|
804
808
|
id: e,
|
|
@@ -811,209 +815,209 @@ const Sn = (t, e) => {
|
|
|
811
815
|
annotation: e
|
|
812
816
|
}
|
|
813
817
|
};
|
|
814
|
-
},
|
|
815
|
-
const t = /* @__PURE__ */ new Map(), e = /* @__PURE__ */ new Map(), n = [], o = (
|
|
816
|
-
n.push({ onChange:
|
|
817
|
-
}, i = (
|
|
818
|
-
const
|
|
819
|
-
|
|
820
|
-
}, s = (
|
|
818
|
+
}, Cn = (t) => t.id !== void 0, Ln = () => {
|
|
819
|
+
const t = /* @__PURE__ */ new Map(), e = /* @__PURE__ */ new Map(), n = [], o = (m, v = {}) => {
|
|
820
|
+
n.push({ onChange: m, options: v });
|
|
821
|
+
}, i = (m) => {
|
|
822
|
+
const v = n.findIndex((x) => x.onChange == m);
|
|
823
|
+
v > -1 && n.splice(v, 1);
|
|
824
|
+
}, s = (m, v) => {
|
|
821
825
|
const x = {
|
|
822
|
-
origin:
|
|
826
|
+
origin: m,
|
|
823
827
|
changes: {
|
|
824
|
-
created:
|
|
825
|
-
updated:
|
|
826
|
-
deleted:
|
|
828
|
+
created: v.created || [],
|
|
829
|
+
updated: v.updated || [],
|
|
830
|
+
deleted: v.deleted || []
|
|
827
831
|
},
|
|
828
832
|
state: [...t.values()]
|
|
829
833
|
};
|
|
830
834
|
n.forEach((C) => {
|
|
831
|
-
|
|
835
|
+
En(C, x) && C.onChange(x);
|
|
832
836
|
});
|
|
833
|
-
}, a = (
|
|
834
|
-
if (
|
|
835
|
-
throw Error(`Cannot add annotation ${
|
|
837
|
+
}, a = (m, v = k.LOCAL) => {
|
|
838
|
+
if (m.id && t.get(m.id))
|
|
839
|
+
throw Error(`Cannot add annotation ${m.id} - exists already`);
|
|
836
840
|
{
|
|
837
|
-
const x =
|
|
838
|
-
t.set(x.id, x), x.bodies.forEach((C) => e.set(C.id, x.id)), s(
|
|
841
|
+
const x = Mt(m);
|
|
842
|
+
t.set(x.id, x), x.bodies.forEach((C) => e.set(C.id, x.id)), s(v, { created: [x] });
|
|
839
843
|
}
|
|
840
|
-
}, r = (
|
|
841
|
-
const x =
|
|
842
|
-
if (
|
|
843
|
-
const
|
|
844
|
-
return C === x.id ? t.set(C, x) : (t.delete(C), t.set(x.id, x)),
|
|
844
|
+
}, r = (m, v) => {
|
|
845
|
+
const x = Mt(typeof m == "string" ? v : m), C = typeof m == "string" ? m : m.id, B = C && t.get(C);
|
|
846
|
+
if (B) {
|
|
847
|
+
const R = pe(B, x);
|
|
848
|
+
return C === x.id ? t.set(C, x) : (t.delete(C), t.set(x.id, x)), B.bodies.forEach((N) => e.delete(N.id)), x.bodies.forEach((N) => e.set(N.id, x.id)), R;
|
|
845
849
|
} else
|
|
846
850
|
console.warn(`Cannot update annotation ${C} - does not exist`);
|
|
847
|
-
}, l = (
|
|
848
|
-
const C =
|
|
849
|
-
|
|
850
|
-
}, f = (
|
|
851
|
-
const x =
|
|
852
|
-
const
|
|
853
|
-
return
|
|
851
|
+
}, l = (m, v = k.LOCAL, x = k.LOCAL) => {
|
|
852
|
+
const C = Cn(v) ? x : v, B = r(m, v);
|
|
853
|
+
B && s(C, { updated: [B] });
|
|
854
|
+
}, f = (m, v = k.LOCAL) => {
|
|
855
|
+
const x = m.reduce((C, B) => {
|
|
856
|
+
const R = r(B);
|
|
857
|
+
return R ? [...C, R] : C;
|
|
854
858
|
}, []);
|
|
855
|
-
x.length > 0 && s(
|
|
856
|
-
},
|
|
857
|
-
const x = t.get(
|
|
859
|
+
x.length > 0 && s(v, { updated: x });
|
|
860
|
+
}, h = (m, v = k.LOCAL) => {
|
|
861
|
+
const x = t.get(m.annotation);
|
|
858
862
|
if (x) {
|
|
859
863
|
const C = {
|
|
860
864
|
...x,
|
|
861
|
-
bodies: [...x.bodies,
|
|
865
|
+
bodies: [...x.bodies, m]
|
|
862
866
|
};
|
|
863
|
-
t.set(x.id, C), e.set(
|
|
867
|
+
t.set(x.id, C), e.set(m.id, C.id), s(v, { updated: [{
|
|
864
868
|
oldValue: x,
|
|
865
869
|
newValue: C,
|
|
866
|
-
bodiesCreated: [
|
|
870
|
+
bodiesCreated: [m]
|
|
867
871
|
}] });
|
|
868
872
|
} else
|
|
869
|
-
console.warn(`Attempt to add body to missing annotation: ${
|
|
870
|
-
},
|
|
871
|
-
const
|
|
872
|
-
t.clear(), e.clear(), s(
|
|
873
|
-
},
|
|
874
|
-
const C =
|
|
875
|
-
if (
|
|
876
|
-
const
|
|
877
|
-
t.clear(), e.clear(), C.forEach((
|
|
878
|
-
t.set(
|
|
879
|
-
}), s(x, { created: C, deleted:
|
|
873
|
+
console.warn(`Attempt to add body to missing annotation: ${m.annotation}`);
|
|
874
|
+
}, u = () => [...t.values()], p = (m = k.LOCAL) => {
|
|
875
|
+
const v = [...t.values()];
|
|
876
|
+
t.clear(), e.clear(), s(m, { deleted: v });
|
|
877
|
+
}, g = (m, v = !0, x = k.LOCAL) => {
|
|
878
|
+
const C = m.map(Mt);
|
|
879
|
+
if (v) {
|
|
880
|
+
const B = [...t.values()];
|
|
881
|
+
t.clear(), e.clear(), C.forEach((R) => {
|
|
882
|
+
t.set(R.id, R), R.bodies.forEach((N) => e.set(N.id, R.id));
|
|
883
|
+
}), s(x, { created: C, deleted: B });
|
|
880
884
|
} else {
|
|
881
|
-
const
|
|
882
|
-
const
|
|
883
|
-
return
|
|
885
|
+
const B = m.reduce((R, N) => {
|
|
886
|
+
const U = N.id && t.get(N.id);
|
|
887
|
+
return U ? [...R, U] : R;
|
|
884
888
|
}, []);
|
|
885
|
-
if (
|
|
886
|
-
throw Error(`Bulk insert would overwrite the following annotations: ${
|
|
887
|
-
C.forEach((
|
|
888
|
-
t.set(
|
|
889
|
+
if (B.length > 0)
|
|
890
|
+
throw Error(`Bulk insert would overwrite the following annotations: ${B.map((R) => R.id).join(", ")}`);
|
|
891
|
+
C.forEach((R) => {
|
|
892
|
+
t.set(R.id, R), R.bodies.forEach((N) => e.set(N.id, R.id));
|
|
889
893
|
}), s(x, { created: C });
|
|
890
894
|
}
|
|
891
|
-
},
|
|
892
|
-
const
|
|
895
|
+
}, b = (m) => {
|
|
896
|
+
const v = typeof m == "string" ? m : m.id, x = t.get(v);
|
|
893
897
|
if (x)
|
|
894
|
-
return t.delete(
|
|
895
|
-
console.warn(`Attempt to delete missing annotation: ${
|
|
896
|
-
},
|
|
897
|
-
const x =
|
|
898
|
-
x && s(
|
|
899
|
-
},
|
|
900
|
-
const x =
|
|
901
|
-
const
|
|
902
|
-
return
|
|
898
|
+
return t.delete(v), x.bodies.forEach((C) => e.delete(C.id)), x;
|
|
899
|
+
console.warn(`Attempt to delete missing annotation: ${v}`);
|
|
900
|
+
}, w = (m, v = k.LOCAL) => {
|
|
901
|
+
const x = b(m);
|
|
902
|
+
x && s(v, { deleted: [x] });
|
|
903
|
+
}, y = (m, v = k.LOCAL) => {
|
|
904
|
+
const x = m.reduce((C, B) => {
|
|
905
|
+
const R = b(B);
|
|
906
|
+
return R ? [...C, R] : C;
|
|
903
907
|
}, []);
|
|
904
|
-
x.length > 0 && s(
|
|
905
|
-
}, d = (
|
|
906
|
-
const
|
|
907
|
-
if (
|
|
908
|
-
const x =
|
|
908
|
+
x.length > 0 && s(v, { deleted: x });
|
|
909
|
+
}, d = (m) => {
|
|
910
|
+
const v = t.get(m.annotation);
|
|
911
|
+
if (v) {
|
|
912
|
+
const x = v.bodies.find((C) => C.id === m.id);
|
|
909
913
|
if (x) {
|
|
910
914
|
e.delete(x.id);
|
|
911
915
|
const C = {
|
|
912
|
-
...
|
|
913
|
-
bodies:
|
|
916
|
+
...v,
|
|
917
|
+
bodies: v.bodies.filter((B) => B.id !== m.id)
|
|
914
918
|
};
|
|
915
|
-
return t.set(
|
|
916
|
-
oldValue:
|
|
919
|
+
return t.set(v.id, C), {
|
|
920
|
+
oldValue: v,
|
|
917
921
|
newValue: C,
|
|
918
922
|
bodiesDeleted: [x]
|
|
919
923
|
};
|
|
920
924
|
} else
|
|
921
|
-
console.warn(`Attempt to delete missing body ${
|
|
925
|
+
console.warn(`Attempt to delete missing body ${m.id} from annotation ${m.annotation}`);
|
|
922
926
|
} else
|
|
923
|
-
console.warn(`Attempt to delete body from missing annotation ${
|
|
924
|
-
}, c = (
|
|
925
|
-
const x = d(
|
|
926
|
-
x && s(
|
|
927
|
-
},
|
|
928
|
-
const x =
|
|
929
|
-
x.length > 0 && s(
|
|
930
|
-
},
|
|
931
|
-
const
|
|
932
|
-
return
|
|
933
|
-
}, T = (
|
|
934
|
-
const
|
|
935
|
-
if (
|
|
936
|
-
const x =
|
|
927
|
+
console.warn(`Attempt to delete body from missing annotation ${m.annotation}`);
|
|
928
|
+
}, c = (m, v = k.LOCAL) => {
|
|
929
|
+
const x = d(m);
|
|
930
|
+
x && s(v, { updated: [x] });
|
|
931
|
+
}, A = (m, v = k.LOCAL) => {
|
|
932
|
+
const x = m.map((C) => d(C)).filter(Boolean);
|
|
933
|
+
x.length > 0 && s(v, { updated: x });
|
|
934
|
+
}, E = (m) => {
|
|
935
|
+
const v = t.get(m);
|
|
936
|
+
return v ? { ...v } : void 0;
|
|
937
|
+
}, T = (m) => {
|
|
938
|
+
const v = e.get(m);
|
|
939
|
+
if (v) {
|
|
940
|
+
const x = E(v).bodies.find((C) => C.id === m);
|
|
937
941
|
if (x)
|
|
938
942
|
return x;
|
|
939
|
-
console.error(`Store integrity error: body ${
|
|
943
|
+
console.error(`Store integrity error: body ${m} in index, but not in annotation`);
|
|
940
944
|
} else
|
|
941
|
-
console.warn(`Attempt to retrieve missing body: ${
|
|
942
|
-
},
|
|
943
|
-
if (
|
|
945
|
+
console.warn(`Attempt to retrieve missing body: ${m}`);
|
|
946
|
+
}, S = (m, v) => {
|
|
947
|
+
if (m.annotation !== v.annotation)
|
|
944
948
|
throw "Annotation integrity violation: annotation ID must be the same when updating bodies";
|
|
945
|
-
const x = t.get(
|
|
949
|
+
const x = t.get(m.annotation);
|
|
946
950
|
if (x) {
|
|
947
|
-
const C = x.bodies.find((
|
|
951
|
+
const C = x.bodies.find((R) => R.id === m.id), B = {
|
|
948
952
|
...x,
|
|
949
|
-
bodies: x.bodies.map((
|
|
953
|
+
bodies: x.bodies.map((R) => R.id === C.id ? v : R)
|
|
950
954
|
};
|
|
951
|
-
return t.set(x.id,
|
|
955
|
+
return t.set(x.id, B), C.id !== v.id && (e.delete(C.id), e.set(v.id, B.id)), {
|
|
952
956
|
oldValue: x,
|
|
953
|
-
newValue:
|
|
954
|
-
bodiesUpdated: [{ oldBody: C, newBody:
|
|
957
|
+
newValue: B,
|
|
958
|
+
bodiesUpdated: [{ oldBody: C, newBody: v }]
|
|
955
959
|
};
|
|
956
960
|
} else
|
|
957
|
-
console.warn(`Attempt to add body to missing annotation ${
|
|
958
|
-
}, O = (
|
|
959
|
-
const C =
|
|
961
|
+
console.warn(`Attempt to add body to missing annotation ${m.annotation}`);
|
|
962
|
+
}, O = (m, v, x = k.LOCAL) => {
|
|
963
|
+
const C = S(m, v);
|
|
960
964
|
C && s(x, { updated: [C] });
|
|
961
|
-
},
|
|
962
|
-
const x =
|
|
963
|
-
s(
|
|
964
|
-
},
|
|
965
|
-
const
|
|
966
|
-
if (
|
|
965
|
+
}, M = (m, v = k.LOCAL) => {
|
|
966
|
+
const x = m.map((C) => S({ id: C.id, annotation: C.annotation }, C)).filter(Boolean);
|
|
967
|
+
s(v, { updated: x });
|
|
968
|
+
}, L = (m) => {
|
|
969
|
+
const v = t.get(m.annotation);
|
|
970
|
+
if (v) {
|
|
967
971
|
const x = {
|
|
968
|
-
...
|
|
972
|
+
...v,
|
|
969
973
|
target: {
|
|
970
|
-
...
|
|
971
|
-
...
|
|
974
|
+
...v.target,
|
|
975
|
+
...m
|
|
972
976
|
}
|
|
973
977
|
};
|
|
974
|
-
return t.set(
|
|
975
|
-
oldValue:
|
|
978
|
+
return t.set(v.id, x), {
|
|
979
|
+
oldValue: v,
|
|
976
980
|
newValue: x,
|
|
977
981
|
targetUpdated: {
|
|
978
|
-
oldTarget:
|
|
979
|
-
newTarget:
|
|
982
|
+
oldTarget: v.target,
|
|
983
|
+
newTarget: m
|
|
980
984
|
}
|
|
981
985
|
};
|
|
982
986
|
} else
|
|
983
|
-
console.warn(`Attempt to update target on missing annotation: ${
|
|
987
|
+
console.warn(`Attempt to update target on missing annotation: ${m.annotation}`);
|
|
984
988
|
};
|
|
985
989
|
return {
|
|
986
990
|
addAnnotation: a,
|
|
987
|
-
addBody:
|
|
988
|
-
all:
|
|
989
|
-
bulkAddAnnotation:
|
|
990
|
-
bulkDeleteAnnotation:
|
|
991
|
-
bulkDeleteBodies:
|
|
991
|
+
addBody: h,
|
|
992
|
+
all: u,
|
|
993
|
+
bulkAddAnnotation: g,
|
|
994
|
+
bulkDeleteAnnotation: y,
|
|
995
|
+
bulkDeleteBodies: A,
|
|
992
996
|
bulkUpdateAnnotation: f,
|
|
993
|
-
bulkUpdateBodies:
|
|
994
|
-
bulkUpdateTargets: (
|
|
995
|
-
const x =
|
|
996
|
-
x.length > 0 && s(
|
|
997
|
+
bulkUpdateBodies: M,
|
|
998
|
+
bulkUpdateTargets: (m, v = k.LOCAL) => {
|
|
999
|
+
const x = m.map((C) => L(C)).filter(Boolean);
|
|
1000
|
+
x.length > 0 && s(v, { updated: x });
|
|
997
1001
|
},
|
|
998
|
-
clear:
|
|
999
|
-
deleteAnnotation:
|
|
1002
|
+
clear: p,
|
|
1003
|
+
deleteAnnotation: w,
|
|
1000
1004
|
deleteBody: c,
|
|
1001
|
-
getAnnotation:
|
|
1005
|
+
getAnnotation: E,
|
|
1002
1006
|
getBody: T,
|
|
1003
1007
|
observe: o,
|
|
1004
1008
|
unobserve: i,
|
|
1005
1009
|
updateAnnotation: l,
|
|
1006
1010
|
updateBody: O,
|
|
1007
|
-
updateTarget: (
|
|
1008
|
-
const x =
|
|
1009
|
-
x && s(
|
|
1011
|
+
updateTarget: (m, v = k.LOCAL) => {
|
|
1012
|
+
const x = L(m);
|
|
1013
|
+
x && s(v, { updated: [x] });
|
|
1010
1014
|
}
|
|
1011
1015
|
};
|
|
1012
1016
|
};
|
|
1013
|
-
let
|
|
1017
|
+
let Tn = () => ({
|
|
1014
1018
|
emit(t, ...e) {
|
|
1015
|
-
for (let n =
|
|
1016
|
-
o
|
|
1019
|
+
for (let n = this.events[t] || [], o = 0, i = n.length; o < i; o++)
|
|
1020
|
+
n[o](...e);
|
|
1017
1021
|
},
|
|
1018
1022
|
events: {},
|
|
1019
1023
|
on(t, e) {
|
|
@@ -1024,119 +1028,119 @@ let On = () => ({
|
|
|
1024
1028
|
};
|
|
1025
1029
|
}
|
|
1026
1030
|
});
|
|
1027
|
-
const
|
|
1028
|
-
const e =
|
|
1031
|
+
const On = 250, Mn = (t) => {
|
|
1032
|
+
const e = Tn(), n = [];
|
|
1029
1033
|
let o = -1, i = !1, s = 0;
|
|
1030
|
-
const a = (
|
|
1034
|
+
const a = (g) => {
|
|
1031
1035
|
if (!i) {
|
|
1032
|
-
const { changes:
|
|
1033
|
-
if (
|
|
1034
|
-
n.splice(o + 1), n.push(
|
|
1036
|
+
const { changes: b } = g, w = performance.now();
|
|
1037
|
+
if (w - s > On)
|
|
1038
|
+
n.splice(o + 1), n.push(b), o = n.length - 1;
|
|
1035
1039
|
else {
|
|
1036
|
-
const
|
|
1037
|
-
n[
|
|
1040
|
+
const y = n.length - 1;
|
|
1041
|
+
n[y] = Sn(n[y], b);
|
|
1038
1042
|
}
|
|
1039
|
-
s =
|
|
1043
|
+
s = w;
|
|
1040
1044
|
}
|
|
1041
1045
|
i = !1;
|
|
1042
1046
|
};
|
|
1043
|
-
t.observe(a, { origin:
|
|
1044
|
-
const r = (
|
|
1047
|
+
t.observe(a, { origin: k.LOCAL });
|
|
1048
|
+
const r = (g) => g && g.length > 0 && t.bulkDeleteAnnotation(g), l = (g) => g && g.length > 0 && t.bulkAddAnnotation(g, !1), f = (g) => g && g.length > 0 && t.bulkUpdateAnnotation(g.map(({ oldValue: b }) => b)), h = (g) => g && g.length > 0 && t.bulkUpdateAnnotation(g.map(({ newValue: b }) => b)), u = (g) => g && g.length > 0 && t.bulkAddAnnotation(g, !1), p = (g) => g && g.length > 0 && t.bulkDeleteAnnotation(g);
|
|
1045
1049
|
return {
|
|
1046
1050
|
canRedo: () => n.length - 1 > o,
|
|
1047
1051
|
canUndo: () => o > -1,
|
|
1048
1052
|
destroy: () => t.unobserve(a),
|
|
1049
|
-
on: (
|
|
1053
|
+
on: (g, b) => e.on(g, b),
|
|
1050
1054
|
redo: () => {
|
|
1051
1055
|
if (n.length - 1 > o) {
|
|
1052
1056
|
i = !0;
|
|
1053
|
-
const { created:
|
|
1054
|
-
l(
|
|
1057
|
+
const { created: g, updated: b, deleted: w } = n[o + 1];
|
|
1058
|
+
l(g), h(b), p(w), e.emit("redo", n[o + 1]), o += 1;
|
|
1055
1059
|
}
|
|
1056
1060
|
},
|
|
1057
1061
|
undo: () => {
|
|
1058
1062
|
if (o > -1) {
|
|
1059
1063
|
i = !0;
|
|
1060
|
-
const { created:
|
|
1061
|
-
r(
|
|
1064
|
+
const { created: g, updated: b, deleted: w } = n[o];
|
|
1065
|
+
r(g), f(b), u(w), e.emit("undo", n[o]), o -= 1;
|
|
1062
1066
|
}
|
|
1063
1067
|
}
|
|
1064
1068
|
};
|
|
1065
1069
|
}, Bn = () => {
|
|
1066
|
-
const { subscribe: t, set: e } =
|
|
1070
|
+
const { subscribe: t, set: e } = Dt([]);
|
|
1067
1071
|
return {
|
|
1068
1072
|
subscribe: t,
|
|
1069
1073
|
set: e
|
|
1070
1074
|
};
|
|
1071
|
-
},
|
|
1075
|
+
}, Rn = (t, e, n, o) => {
|
|
1072
1076
|
const { hover: i, selection: s, store: a, viewport: r } = t, l = /* @__PURE__ */ new Map();
|
|
1073
|
-
let f = [],
|
|
1074
|
-
const
|
|
1075
|
-
l.has(
|
|
1076
|
-
},
|
|
1077
|
-
const d = l.get(
|
|
1077
|
+
let f = [], h;
|
|
1078
|
+
const u = (w, y) => {
|
|
1079
|
+
l.has(w) ? l.get(w).push(y) : l.set(w, [y]);
|
|
1080
|
+
}, p = (w, y) => {
|
|
1081
|
+
const d = l.get(w);
|
|
1078
1082
|
if (d) {
|
|
1079
|
-
const c = d.indexOf(
|
|
1083
|
+
const c = d.indexOf(y);
|
|
1080
1084
|
c !== -1 && d.splice(c, 1);
|
|
1081
1085
|
}
|
|
1082
|
-
},
|
|
1083
|
-
l.has(
|
|
1084
|
-
l.get(
|
|
1086
|
+
}, g = (w, y, d) => {
|
|
1087
|
+
l.has(w) && setTimeout(() => {
|
|
1088
|
+
l.get(w).forEach((c) => {
|
|
1085
1089
|
if (n) {
|
|
1086
|
-
const
|
|
1087
|
-
c(
|
|
1090
|
+
const A = Array.isArray(y) ? y.map((T) => n.serialize(T)) : n.serialize(y), E = d ? d instanceof PointerEvent ? d : n.serialize(d) : void 0;
|
|
1091
|
+
c(A, E);
|
|
1088
1092
|
} else
|
|
1089
|
-
c(
|
|
1093
|
+
c(y, d);
|
|
1090
1094
|
});
|
|
1091
1095
|
}, 1);
|
|
1092
1096
|
};
|
|
1093
|
-
s.subscribe(({ selected:
|
|
1094
|
-
if (!(f.length === 0 &&
|
|
1095
|
-
if (f.length === 0 &&
|
|
1096
|
-
f =
|
|
1097
|
-
else if (f.length > 0 &&
|
|
1098
|
-
f.forEach((
|
|
1099
|
-
const d = a.getAnnotation(
|
|
1100
|
-
d && !
|
|
1097
|
+
s.subscribe(({ selected: w }) => {
|
|
1098
|
+
if (!(f.length === 0 && w.length === 0)) {
|
|
1099
|
+
if (f.length === 0 && w.length > 0)
|
|
1100
|
+
f = w.map(({ id: y }) => a.getAnnotation(y));
|
|
1101
|
+
else if (f.length > 0 && w.length === 0)
|
|
1102
|
+
f.forEach((y) => {
|
|
1103
|
+
const d = a.getAnnotation(y.id);
|
|
1104
|
+
d && !G(d, y) && g("updateAnnotation", d, y);
|
|
1101
1105
|
}), f = [];
|
|
1102
1106
|
else {
|
|
1103
|
-
const
|
|
1107
|
+
const y = new Set(f.map((c) => c.id)), d = new Set(w.map(({ id: c }) => c));
|
|
1104
1108
|
f.filter((c) => !d.has(c.id)).forEach((c) => {
|
|
1105
|
-
const
|
|
1106
|
-
|
|
1109
|
+
const A = a.getAnnotation(c.id);
|
|
1110
|
+
A && !G(A, c) && g("updateAnnotation", A, c);
|
|
1107
1111
|
}), f = [
|
|
1108
1112
|
// Remove annotations that were deselected
|
|
1109
1113
|
...f.filter((c) => d.has(c.id)),
|
|
1110
1114
|
// Add editable annotations that were selected
|
|
1111
|
-
...
|
|
1115
|
+
...w.filter(({ id: c }) => !y.has(c)).map(({ id: c }) => a.getAnnotation(c))
|
|
1112
1116
|
];
|
|
1113
1117
|
}
|
|
1114
|
-
|
|
1118
|
+
g("selectionChanged", f);
|
|
1115
1119
|
}
|
|
1116
|
-
}), i.subscribe((
|
|
1117
|
-
!
|
|
1118
|
-
}), r == null || r.subscribe((
|
|
1119
|
-
const { created:
|
|
1120
|
-
(
|
|
1120
|
+
}), i.subscribe((w) => {
|
|
1121
|
+
!h && w ? g("mouseEnterAnnotation", a.getAnnotation(w)) : h && !w ? g("mouseLeaveAnnotation", a.getAnnotation(h)) : h && w && (g("mouseLeaveAnnotation", a.getAnnotation(h)), g("mouseEnterAnnotation", a.getAnnotation(w))), h = w;
|
|
1122
|
+
}), r == null || r.subscribe((w) => g("viewportIntersect", w.map((y) => a.getAnnotation(y)))), a.observe((w) => {
|
|
1123
|
+
const { created: y, deleted: d } = w.changes;
|
|
1124
|
+
(y || []).forEach((c) => g("createAnnotation", c)), (d || []).forEach((c) => g("deleteAnnotation", c)), (w.changes.updated || []).filter((c) => [
|
|
1121
1125
|
...c.bodiesCreated || [],
|
|
1122
1126
|
...c.bodiesDeleted || [],
|
|
1123
1127
|
...c.bodiesUpdated || []
|
|
1124
|
-
].length > 0).forEach(({ oldValue: c, newValue:
|
|
1125
|
-
const
|
|
1126
|
-
f = f.map((T) => T.id === c.id ?
|
|
1128
|
+
].length > 0).forEach(({ oldValue: c, newValue: A }) => {
|
|
1129
|
+
const E = f.find((T) => T.id === c.id) || c;
|
|
1130
|
+
f = f.map((T) => T.id === c.id ? A : T), g("updateAnnotation", A, E);
|
|
1127
1131
|
});
|
|
1128
|
-
}, { origin:
|
|
1132
|
+
}, { origin: k.LOCAL }), a.observe((w) => {
|
|
1129
1133
|
if (f) {
|
|
1130
|
-
const
|
|
1131
|
-
d.length > 0 && (f = f.map((c) => d.find((
|
|
1134
|
+
const y = new Set(f.map((c) => c.id)), d = (w.changes.updated || []).filter(({ newValue: c }) => y.has(c.id)).map(({ newValue: c }) => c);
|
|
1135
|
+
d.length > 0 && (f = f.map((c) => d.find((E) => E.id === c.id) || c));
|
|
1132
1136
|
}
|
|
1133
|
-
}, { origin:
|
|
1134
|
-
const
|
|
1135
|
-
const { updated: d } =
|
|
1136
|
-
|
|
1137
|
+
}, { origin: k.REMOTE });
|
|
1138
|
+
const b = (w) => (y) => {
|
|
1139
|
+
const { updated: d } = y;
|
|
1140
|
+
w ? (d || []).forEach((c) => g("updateAnnotation", c.oldValue, c.newValue)) : (d || []).forEach((c) => g("updateAnnotation", c.newValue, c.oldValue));
|
|
1137
1141
|
};
|
|
1138
|
-
return e.on("undo",
|
|
1139
|
-
},
|
|
1142
|
+
return e.on("undo", b(!0)), e.on("redo", b(!1)), { on: u, off: p, emit: g };
|
|
1143
|
+
}, kn = (t) => (e) => e.reduce((n, o) => {
|
|
1140
1144
|
const { parsed: i, error: s } = t.parse(o);
|
|
1141
1145
|
return s ? {
|
|
1142
1146
|
parsed: n.parsed,
|
|
@@ -1147,21 +1151,21 @@ const Mn = 250, Rn = (t) => {
|
|
|
1147
1151
|
} : {
|
|
1148
1152
|
...n
|
|
1149
1153
|
};
|
|
1150
|
-
}, { parsed: [], failed: [] }),
|
|
1154
|
+
}, { parsed: [], failed: [] }), In = (t, e, n) => {
|
|
1151
1155
|
const { store: o, selection: i } = t, s = (d) => {
|
|
1152
1156
|
if (n) {
|
|
1153
|
-
const { parsed: c, error:
|
|
1154
|
-
c ? o.addAnnotation(c,
|
|
1157
|
+
const { parsed: c, error: A } = n.parse(d);
|
|
1158
|
+
c ? o.addAnnotation(c, k.REMOTE) : console.error(A);
|
|
1155
1159
|
} else
|
|
1156
|
-
o.addAnnotation(
|
|
1160
|
+
o.addAnnotation(Ot(d), k.REMOTE);
|
|
1157
1161
|
}, a = () => i.clear(), r = () => o.clear(), l = (d) => {
|
|
1158
1162
|
const c = o.getAnnotation(d);
|
|
1159
1163
|
return n && c ? n.serialize(c) : c;
|
|
1160
|
-
}, f = () => n ? o.all().map(n.serialize) : o.all(),
|
|
1164
|
+
}, f = () => n ? o.all().map(n.serialize) : o.all(), h = () => {
|
|
1161
1165
|
var d;
|
|
1162
|
-
const c = (((d = i.selected) == null ? void 0 : d.map((
|
|
1166
|
+
const c = (((d = i.selected) == null ? void 0 : d.map((A) => A.id)) || []).map((A) => o.getAnnotation(A)).filter(Boolean);
|
|
1163
1167
|
return n ? c.map(n.serialize) : c;
|
|
1164
|
-
},
|
|
1168
|
+
}, u = (d, c = !0) => fetch(d).then((A) => A.json()).then((A) => (g(A, c), A)), p = (d) => {
|
|
1165
1169
|
if (typeof d == "string") {
|
|
1166
1170
|
const c = o.getAnnotation(d);
|
|
1167
1171
|
if (o.deleteAnnotation(d), c)
|
|
@@ -1171,23 +1175,23 @@ const Mn = 250, Rn = (t) => {
|
|
|
1171
1175
|
if (c)
|
|
1172
1176
|
return o.deleteAnnotation(c), d;
|
|
1173
1177
|
}
|
|
1174
|
-
},
|
|
1178
|
+
}, g = (d, c = !0) => {
|
|
1175
1179
|
if (n) {
|
|
1176
|
-
const
|
|
1177
|
-
T.length > 0 && console.warn(`Discarded ${T.length} invalid annotations`, T), o.bulkAddAnnotation(
|
|
1180
|
+
const A = n.parseAll || kn(n), { parsed: E, failed: T } = A(d);
|
|
1181
|
+
T.length > 0 && console.warn(`Discarded ${T.length} invalid annotations`, T), o.bulkAddAnnotation(E, c, k.REMOTE);
|
|
1178
1182
|
} else
|
|
1179
|
-
o.bulkAddAnnotation(d.map(
|
|
1180
|
-
},
|
|
1183
|
+
o.bulkAddAnnotation(d.map(Ot), c, k.REMOTE);
|
|
1184
|
+
}, b = (d, c) => {
|
|
1181
1185
|
d ? i.setSelected(d, c) : i.clear();
|
|
1182
|
-
},
|
|
1186
|
+
}, w = (d) => {
|
|
1183
1187
|
i.clear(), i.setUserSelectAction(d);
|
|
1184
|
-
},
|
|
1188
|
+
}, y = (d) => {
|
|
1185
1189
|
if (n) {
|
|
1186
|
-
const c = n.parse(d).parsed,
|
|
1187
|
-
return o.updateAnnotation(c),
|
|
1190
|
+
const c = n.parse(d).parsed, A = n.serialize(o.getAnnotation(c.id));
|
|
1191
|
+
return o.updateAnnotation(c), A;
|
|
1188
1192
|
} else {
|
|
1189
1193
|
const c = o.getAnnotation(d.id);
|
|
1190
|
-
return o.updateAnnotation(
|
|
1194
|
+
return o.updateAnnotation(Ot(d)), c;
|
|
1191
1195
|
}
|
|
1192
1196
|
};
|
|
1193
1197
|
return {
|
|
@@ -1198,19 +1202,19 @@ const Mn = 250, Rn = (t) => {
|
|
|
1198
1202
|
clearAnnotations: r,
|
|
1199
1203
|
getAnnotationById: l,
|
|
1200
1204
|
getAnnotations: f,
|
|
1201
|
-
getSelected:
|
|
1202
|
-
loadAnnotations:
|
|
1205
|
+
getSelected: h,
|
|
1206
|
+
loadAnnotations: u,
|
|
1203
1207
|
redo: e.redo,
|
|
1204
|
-
removeAnnotation:
|
|
1205
|
-
setAnnotations:
|
|
1206
|
-
setSelected:
|
|
1207
|
-
setUserSelectAction:
|
|
1208
|
+
removeAnnotation: p,
|
|
1209
|
+
setAnnotations: g,
|
|
1210
|
+
setSelected: b,
|
|
1211
|
+
setUserSelectAction: w,
|
|
1208
1212
|
undo: e.undo,
|
|
1209
|
-
updateAnnotation:
|
|
1213
|
+
updateAnnotation: y
|
|
1210
1214
|
};
|
|
1211
|
-
},
|
|
1212
|
-
let
|
|
1213
|
-
let o = (2 << Math.
|
|
1215
|
+
}, _n = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
|
|
1216
|
+
let Nn = (t) => crypto.getRandomValues(new Uint8Array(t)), Un = (t, e, n) => {
|
|
1217
|
+
let o = (2 << Math.log2(t.length - 1)) - 1, i = -~(1.6 * o * e / t.length);
|
|
1214
1218
|
return (s = e) => {
|
|
1215
1219
|
let a = "";
|
|
1216
1220
|
for (; ; ) {
|
|
@@ -1219,13 +1223,13 @@ let Un = (t) => crypto.getRandomValues(new Uint8Array(t)), Vn = (t, e, n) => {
|
|
|
1219
1223
|
if (a += t[r[l] & o] || "", a.length === s) return a;
|
|
1220
1224
|
}
|
|
1221
1225
|
};
|
|
1222
|
-
},
|
|
1226
|
+
}, Vn = (t, e = 21) => Un(t, e, Nn), Yn = (t = 21) => {
|
|
1223
1227
|
let e = "", n = crypto.getRandomValues(new Uint8Array(t));
|
|
1224
1228
|
for (; t--; )
|
|
1225
|
-
e +=
|
|
1229
|
+
e += _n[n[t] & 63];
|
|
1226
1230
|
return e;
|
|
1227
1231
|
};
|
|
1228
|
-
const
|
|
1232
|
+
const Kn = () => ({ isGuest: !0, id: Vn("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_", 20)() }), Dn = (t) => {
|
|
1229
1233
|
const e = JSON.stringify(t);
|
|
1230
1234
|
let n = 0;
|
|
1231
1235
|
for (let o = 0, i = e.length; o < i; o++) {
|
|
@@ -1233,20 +1237,20 @@ const Dn = () => ({ isGuest: !0, id: Kn("1234567890abcdefghijklmnopqrstuvwxyzABC
|
|
|
1233
1237
|
n = (n << 5) - n + s, n |= 0;
|
|
1234
1238
|
}
|
|
1235
1239
|
return `${n}`;
|
|
1236
|
-
},
|
|
1237
|
-
const { id: o, type: i, purpose: s, value: a, created: r, modified: l, creator: f, ...
|
|
1240
|
+
}, ge = (t) => t ? typeof t == "object" ? { ...t } : t : void 0, Xn = (t, e) => (Array.isArray(t) ? t : [t]).map((n) => {
|
|
1241
|
+
const { id: o, type: i, purpose: s, value: a, created: r, modified: l, creator: f, ...h } = n;
|
|
1238
1242
|
return {
|
|
1239
|
-
id: o || `temp-${
|
|
1243
|
+
id: o || `temp-${Dn(n)}`,
|
|
1240
1244
|
annotation: e,
|
|
1241
1245
|
type: i,
|
|
1242
1246
|
purpose: s,
|
|
1243
1247
|
value: a,
|
|
1244
|
-
creator:
|
|
1248
|
+
creator: ge(f),
|
|
1245
1249
|
created: r ? new Date(r) : void 0,
|
|
1246
1250
|
updated: l ? new Date(l) : void 0,
|
|
1247
|
-
...
|
|
1251
|
+
...h
|
|
1248
1252
|
};
|
|
1249
|
-
}),
|
|
1253
|
+
}), Pn = (t) => t.map((e) => {
|
|
1250
1254
|
var n;
|
|
1251
1255
|
const { annotation: o, created: i, updated: s, ...a } = e, r = {
|
|
1252
1256
|
...a,
|
|
@@ -1257,53 +1261,65 @@ const Dn = () => ({ isGuest: !0, id: Kn("1234567890abcdefghijklmnopqrstuvwxyzABC
|
|
|
1257
1261
|
});
|
|
1258
1262
|
Yn();
|
|
1259
1263
|
const Ao = (t, e) => ({
|
|
1260
|
-
parse: (n) =>
|
|
1261
|
-
serialize: (n) =>
|
|
1262
|
-
}),
|
|
1264
|
+
parse: (n) => jn(n),
|
|
1265
|
+
serialize: (n) => zn(n, t, e)
|
|
1266
|
+
}), $n = (t) => t.quote !== void 0 && t.start !== void 0 && t.end !== void 0, Hn = (t) => {
|
|
1263
1267
|
const {
|
|
1264
1268
|
id: e,
|
|
1265
1269
|
creator: n,
|
|
1266
1270
|
created: o,
|
|
1267
1271
|
modified: i,
|
|
1268
1272
|
target: s
|
|
1269
|
-
} = t, a = Array.isArray(s) ? s : [s]
|
|
1270
|
-
|
|
1273
|
+
} = t, a = Array.isArray(s) ? s : [s];
|
|
1274
|
+
if (a.length === 0)
|
|
1275
|
+
return { error: Error(`No targets found for annotation: ${t.id}`) };
|
|
1276
|
+
const r = {
|
|
1277
|
+
creator: ge(n),
|
|
1271
1278
|
created: o ? new Date(o) : void 0,
|
|
1272
1279
|
updated: i ? new Date(i) : void 0,
|
|
1273
1280
|
annotation: e,
|
|
1274
|
-
selector: []
|
|
1281
|
+
selector: [],
|
|
1282
|
+
// @ts-expect-error: `styleClass` is not part of the core `TextAnnotationTarget` type
|
|
1283
|
+
styleClass: "styleClass" in a[0] ? a[0].styleClass : void 0
|
|
1275
1284
|
};
|
|
1276
1285
|
for (const l of a) {
|
|
1277
|
-
const
|
|
1278
|
-
switch (
|
|
1286
|
+
const h = (Array.isArray(l.selector) ? l.selector : [l.selector]).reduce((u, p) => {
|
|
1287
|
+
switch (p.type) {
|
|
1279
1288
|
case "TextQuoteSelector":
|
|
1280
|
-
|
|
1289
|
+
u.quote = p.exact;
|
|
1281
1290
|
break;
|
|
1282
1291
|
case "TextPositionSelector":
|
|
1283
|
-
|
|
1292
|
+
u.start = p.start, u.end = p.end;
|
|
1284
1293
|
break;
|
|
1285
1294
|
}
|
|
1286
|
-
return
|
|
1295
|
+
return u;
|
|
1287
1296
|
}, {});
|
|
1288
|
-
if (
|
|
1289
|
-
r.selector.push(
|
|
1297
|
+
if ($n(h))
|
|
1298
|
+
r.selector.push(
|
|
1299
|
+
{
|
|
1300
|
+
...h,
|
|
1301
|
+
id: l.id,
|
|
1302
|
+
// @ts-expect-error: `scope` is not part of the core `TextSelector` type
|
|
1303
|
+
scope: l.scope
|
|
1304
|
+
}
|
|
1305
|
+
);
|
|
1290
1306
|
else {
|
|
1291
|
-
const
|
|
1292
|
-
|
|
1293
|
-
|
|
1307
|
+
const u = [
|
|
1308
|
+
h.start ? void 0 : "TextPositionSelector",
|
|
1309
|
+
h.quote ? void 0 : "TextQuoteSelector"
|
|
1294
1310
|
].filter(Boolean);
|
|
1295
|
-
return { error: Error(`Missing selector types: ${
|
|
1311
|
+
return { error: Error(`Missing selector types: ${u.join(" and ")} for annotation: ${t.id}`) };
|
|
1296
1312
|
}
|
|
1297
1313
|
}
|
|
1298
1314
|
return { parsed: r };
|
|
1299
|
-
},
|
|
1300
|
-
const e = t.id ||
|
|
1315
|
+
}, jn = (t) => {
|
|
1316
|
+
const e = t.id || fe(), {
|
|
1301
1317
|
creator: n,
|
|
1302
1318
|
created: o,
|
|
1303
1319
|
modified: i,
|
|
1304
1320
|
body: s,
|
|
1305
1321
|
...a
|
|
1306
|
-
} = t, r =
|
|
1322
|
+
} = t, r = Xn(s, e), l = Hn(t);
|
|
1307
1323
|
return "error" in l ? { error: l.error } : {
|
|
1308
1324
|
parsed: {
|
|
1309
1325
|
...a,
|
|
@@ -1312,29 +1328,31 @@ const Ao = (t, e) => ({
|
|
|
1312
1328
|
target: l.parsed
|
|
1313
1329
|
}
|
|
1314
1330
|
};
|
|
1315
|
-
},
|
|
1331
|
+
}, zn = (t, e, n) => {
|
|
1316
1332
|
const { bodies: o, target: i, ...s } = t, {
|
|
1317
1333
|
selector: a,
|
|
1318
1334
|
creator: r,
|
|
1319
1335
|
created: l,
|
|
1320
1336
|
updated: f,
|
|
1321
|
-
...
|
|
1322
|
-
} = i,
|
|
1323
|
-
const { quote:
|
|
1337
|
+
...h
|
|
1338
|
+
} = i, u = a.map((p) => {
|
|
1339
|
+
const { id: g, quote: b, start: w, end: y, range: d } = p, { prefix: c, suffix: A } = Re(d, n), E = [{
|
|
1324
1340
|
type: "TextQuoteSelector",
|
|
1325
|
-
exact:
|
|
1326
|
-
prefix:
|
|
1327
|
-
suffix:
|
|
1341
|
+
exact: b,
|
|
1342
|
+
prefix: c,
|
|
1343
|
+
suffix: A
|
|
1328
1344
|
}, {
|
|
1329
1345
|
type: "TextPositionSelector",
|
|
1330
|
-
start:
|
|
1346
|
+
start: w,
|
|
1331
1347
|
end: y
|
|
1332
1348
|
}];
|
|
1333
1349
|
return {
|
|
1334
|
-
...
|
|
1335
|
-
id: g
|
|
1350
|
+
...h,
|
|
1351
|
+
id: g,
|
|
1352
|
+
// @ts-expect-error: `scope` is not part of the core `TextSelector` type
|
|
1353
|
+
scope: "scope" in p ? p.scope : void 0,
|
|
1336
1354
|
source: e,
|
|
1337
|
-
selector:
|
|
1355
|
+
selector: E
|
|
1338
1356
|
};
|
|
1339
1357
|
});
|
|
1340
1358
|
return {
|
|
@@ -1342,36 +1360,36 @@ const Ao = (t, e) => ({
|
|
|
1342
1360
|
"@context": "http://www.w3.org/ns/anno.jsonld",
|
|
1343
1361
|
id: t.id,
|
|
1344
1362
|
type: "Annotation",
|
|
1345
|
-
body:
|
|
1363
|
+
body: Pn(t.bodies),
|
|
1346
1364
|
creator: r,
|
|
1347
1365
|
created: l == null ? void 0 : l.toISOString(),
|
|
1348
1366
|
modified: f == null ? void 0 : f.toISOString(),
|
|
1349
|
-
target:
|
|
1367
|
+
target: u
|
|
1350
1368
|
};
|
|
1351
1369
|
};
|
|
1352
|
-
function
|
|
1370
|
+
function me(t, e, n = 0, o = t.length - 1, i = Fn) {
|
|
1353
1371
|
for (; o > n; ) {
|
|
1354
1372
|
if (o - n > 600) {
|
|
1355
|
-
const l = o - n + 1, f = e - n + 1,
|
|
1356
|
-
|
|
1373
|
+
const l = o - n + 1, f = e - n + 1, h = Math.log(l), u = 0.5 * Math.exp(2 * h / 3), p = 0.5 * Math.sqrt(h * u * (l - u) / l) * (f - l / 2 < 0 ? -1 : 1), g = Math.max(n, Math.floor(e - f * u / l + p)), b = Math.min(o, Math.floor(e + (l - f) * u / l + p));
|
|
1374
|
+
me(t, e, g, b, i);
|
|
1357
1375
|
}
|
|
1358
1376
|
const s = t[e];
|
|
1359
1377
|
let a = n, r = o;
|
|
1360
|
-
for (
|
|
1361
|
-
for (
|
|
1378
|
+
for (nt(t, n, e), i(t[o], s) > 0 && nt(t, n, o); a < r; ) {
|
|
1379
|
+
for (nt(t, a, r), a++, r--; i(t[a], s) < 0; ) a++;
|
|
1362
1380
|
for (; i(t[r], s) > 0; ) r--;
|
|
1363
1381
|
}
|
|
1364
|
-
i(t[n], s) === 0 ?
|
|
1382
|
+
i(t[n], s) === 0 ? nt(t, n, r) : (r++, nt(t, r, o)), r <= e && (n = r + 1), e <= r && (o = r - 1);
|
|
1365
1383
|
}
|
|
1366
1384
|
}
|
|
1367
|
-
function
|
|
1385
|
+
function nt(t, e, n) {
|
|
1368
1386
|
const o = t[e];
|
|
1369
1387
|
t[e] = t[n], t[n] = o;
|
|
1370
1388
|
}
|
|
1371
|
-
function
|
|
1389
|
+
function Fn(t, e) {
|
|
1372
1390
|
return t < e ? -1 : t > e ? 1 : 0;
|
|
1373
1391
|
}
|
|
1374
|
-
class
|
|
1392
|
+
class Wn {
|
|
1375
1393
|
constructor(e = 9) {
|
|
1376
1394
|
this._maxEntries = Math.max(4, e), this._minEntries = Math.max(2, Math.ceil(this._maxEntries * 0.4)), this.clear();
|
|
1377
1395
|
}
|
|
@@ -1381,12 +1399,12 @@ class qn {
|
|
|
1381
1399
|
search(e) {
|
|
1382
1400
|
let n = this.data;
|
|
1383
1401
|
const o = [];
|
|
1384
|
-
if (!
|
|
1402
|
+
if (!mt(e, n)) return o;
|
|
1385
1403
|
const i = this.toBBox, s = [];
|
|
1386
1404
|
for (; n; ) {
|
|
1387
1405
|
for (let a = 0; a < n.children.length; a++) {
|
|
1388
1406
|
const r = n.children[a], l = n.leaf ? i(r) : r;
|
|
1389
|
-
|
|
1407
|
+
mt(e, l) && (n.leaf ? o.push(r) : Rt(e, l) ? this._all(r, o) : s.push(r));
|
|
1390
1408
|
}
|
|
1391
1409
|
n = s.pop();
|
|
1392
1410
|
}
|
|
@@ -1394,12 +1412,12 @@ class qn {
|
|
|
1394
1412
|
}
|
|
1395
1413
|
collides(e) {
|
|
1396
1414
|
let n = this.data;
|
|
1397
|
-
if (!
|
|
1415
|
+
if (!mt(e, n)) return !1;
|
|
1398
1416
|
const o = [];
|
|
1399
1417
|
for (; n; ) {
|
|
1400
1418
|
for (let i = 0; i < n.children.length; i++) {
|
|
1401
1419
|
const s = n.children[i], a = n.leaf ? this.toBBox(s) : s;
|
|
1402
|
-
if (
|
|
1420
|
+
if (mt(e, a)) {
|
|
1403
1421
|
if (n.leaf || Rt(e, a)) return !0;
|
|
1404
1422
|
o.push(s);
|
|
1405
1423
|
}
|
|
@@ -1433,7 +1451,7 @@ class qn {
|
|
|
1433
1451
|
return e && this._insert(e, this.data.height - 1), this;
|
|
1434
1452
|
}
|
|
1435
1453
|
clear() {
|
|
1436
|
-
return this.data =
|
|
1454
|
+
return this.data = Z([]), this;
|
|
1437
1455
|
}
|
|
1438
1456
|
remove(e, n) {
|
|
1439
1457
|
if (!e) return this;
|
|
@@ -1442,9 +1460,9 @@ class qn {
|
|
|
1442
1460
|
let r, l, f;
|
|
1443
1461
|
for (; o || s.length; ) {
|
|
1444
1462
|
if (o || (o = s.pop(), l = s[s.length - 1], r = a.pop(), f = !0), o.leaf) {
|
|
1445
|
-
const
|
|
1446
|
-
if (
|
|
1447
|
-
return o.children.splice(
|
|
1463
|
+
const h = qn(e, o.children, n);
|
|
1464
|
+
if (h !== -1)
|
|
1465
|
+
return o.children.splice(h, 1), s.push(o), this._condense(s), this;
|
|
1448
1466
|
}
|
|
1449
1467
|
!f && !o.leaf && Rt(o, i) ? (s.push(o), a.push(r), r = 0, l = o, o = o.children[0]) : l ? (r++, o = l.children[r], f = !1) : o = null;
|
|
1450
1468
|
}
|
|
@@ -1475,26 +1493,26 @@ class qn {
|
|
|
1475
1493
|
const s = o - n + 1;
|
|
1476
1494
|
let a = this._maxEntries, r;
|
|
1477
1495
|
if (s <= a)
|
|
1478
|
-
return r =
|
|
1479
|
-
i || (i = Math.ceil(Math.log(s) / Math.log(a)), a = Math.ceil(s / Math.pow(a, i - 1))), r =
|
|
1496
|
+
return r = Z(e.slice(n, o + 1)), J(r, this.toBBox), r;
|
|
1497
|
+
i || (i = Math.ceil(Math.log(s) / Math.log(a)), a = Math.ceil(s / Math.pow(a, i - 1))), r = Z([]), r.leaf = !1, r.height = i;
|
|
1480
1498
|
const l = Math.ceil(s / a), f = l * Math.ceil(Math.sqrt(a));
|
|
1481
|
-
|
|
1482
|
-
for (let
|
|
1483
|
-
const
|
|
1484
|
-
|
|
1485
|
-
for (let
|
|
1486
|
-
const
|
|
1487
|
-
r.children.push(this._build(e,
|
|
1499
|
+
ee(e, n, o, f, this.compareMinX);
|
|
1500
|
+
for (let h = n; h <= o; h += f) {
|
|
1501
|
+
const u = Math.min(h + f - 1, o);
|
|
1502
|
+
ee(e, h, u, l, this.compareMinY);
|
|
1503
|
+
for (let p = h; p <= u; p += l) {
|
|
1504
|
+
const g = Math.min(p + l - 1, u);
|
|
1505
|
+
r.children.push(this._build(e, p, g, i - 1));
|
|
1488
1506
|
}
|
|
1489
1507
|
}
|
|
1490
|
-
return
|
|
1508
|
+
return J(r, this.toBBox), r;
|
|
1491
1509
|
}
|
|
1492
1510
|
_chooseSubtree(e, n, o, i) {
|
|
1493
1511
|
for (; i.push(n), !(n.leaf || i.length - 1 === o); ) {
|
|
1494
1512
|
let s = 1 / 0, a = 1 / 0, r;
|
|
1495
1513
|
for (let l = 0; l < n.children.length; l++) {
|
|
1496
|
-
const f = n.children[l],
|
|
1497
|
-
|
|
1514
|
+
const f = n.children[l], h = Bt(f), u = Jn(e, f) - h;
|
|
1515
|
+
u < a ? (a = u, s = h < s ? h : s, r = f) : u === a && h < s && (s = h, r = f);
|
|
1498
1516
|
}
|
|
1499
1517
|
n = r || n.children[0];
|
|
1500
1518
|
}
|
|
@@ -1502,7 +1520,7 @@ class qn {
|
|
|
1502
1520
|
}
|
|
1503
1521
|
_insert(e, n, o) {
|
|
1504
1522
|
const i = o ? e : this.toBBox(e), s = [], a = this._chooseSubtree(i, this.data, n, s);
|
|
1505
|
-
for (a.children.push(e),
|
|
1523
|
+
for (a.children.push(e), rt(a, i); n >= 0 && s[n].children.length > this._maxEntries; )
|
|
1506
1524
|
this._split(s, n), n--;
|
|
1507
1525
|
this._adjustParentBBoxes(i, s, n);
|
|
1508
1526
|
}
|
|
@@ -1510,95 +1528,95 @@ class qn {
|
|
|
1510
1528
|
_split(e, n) {
|
|
1511
1529
|
const o = e[n], i = o.children.length, s = this._minEntries;
|
|
1512
1530
|
this._chooseSplitAxis(o, s, i);
|
|
1513
|
-
const a = this._chooseSplitIndex(o, s, i), r =
|
|
1514
|
-
r.height = o.height, r.leaf = o.leaf,
|
|
1531
|
+
const a = this._chooseSplitIndex(o, s, i), r = Z(o.children.splice(a, o.children.length - a));
|
|
1532
|
+
r.height = o.height, r.leaf = o.leaf, J(o, this.toBBox), J(r, this.toBBox), n ? e[n - 1].children.push(r) : this._splitRoot(o, r);
|
|
1515
1533
|
}
|
|
1516
1534
|
_splitRoot(e, n) {
|
|
1517
|
-
this.data =
|
|
1535
|
+
this.data = Z([e, n]), this.data.height = e.height + 1, this.data.leaf = !1, J(this.data, this.toBBox);
|
|
1518
1536
|
}
|
|
1519
1537
|
_chooseSplitIndex(e, n, o) {
|
|
1520
1538
|
let i, s = 1 / 0, a = 1 / 0;
|
|
1521
1539
|
for (let r = n; r <= o - n; r++) {
|
|
1522
|
-
const l =
|
|
1523
|
-
|
|
1540
|
+
const l = st(e, 0, r, this.toBBox), f = st(e, r, o, this.toBBox), h = Zn(l, f), u = Bt(l) + Bt(f);
|
|
1541
|
+
h < s ? (s = h, i = r, a = u < a ? u : a) : h === s && u < a && (a = u, i = r);
|
|
1524
1542
|
}
|
|
1525
1543
|
return i || o - n;
|
|
1526
1544
|
}
|
|
1527
1545
|
// sorts node children by the best axis for split
|
|
1528
1546
|
_chooseSplitAxis(e, n, o) {
|
|
1529
|
-
const i = e.leaf ? this.compareMinX :
|
|
1547
|
+
const i = e.leaf ? this.compareMinX : Gn, s = e.leaf ? this.compareMinY : Qn, a = this._allDistMargin(e, n, o, i), r = this._allDistMargin(e, n, o, s);
|
|
1530
1548
|
a < r && e.children.sort(i);
|
|
1531
1549
|
}
|
|
1532
1550
|
// total margin of all possible split distributions where each node is at least m full
|
|
1533
1551
|
_allDistMargin(e, n, o, i) {
|
|
1534
1552
|
e.children.sort(i);
|
|
1535
|
-
const s = this.toBBox, a =
|
|
1536
|
-
let l =
|
|
1553
|
+
const s = this.toBBox, a = st(e, 0, n, s), r = st(e, o - n, o, s);
|
|
1554
|
+
let l = gt(a) + gt(r);
|
|
1537
1555
|
for (let f = n; f < o - n; f++) {
|
|
1538
|
-
const
|
|
1539
|
-
|
|
1556
|
+
const h = e.children[f];
|
|
1557
|
+
rt(a, e.leaf ? s(h) : h), l += gt(a);
|
|
1540
1558
|
}
|
|
1541
1559
|
for (let f = o - n - 1; f >= n; f--) {
|
|
1542
|
-
const
|
|
1543
|
-
|
|
1560
|
+
const h = e.children[f];
|
|
1561
|
+
rt(r, e.leaf ? s(h) : h), l += gt(r);
|
|
1544
1562
|
}
|
|
1545
1563
|
return l;
|
|
1546
1564
|
}
|
|
1547
1565
|
_adjustParentBBoxes(e, n, o) {
|
|
1548
1566
|
for (let i = o; i >= 0; i--)
|
|
1549
|
-
|
|
1567
|
+
rt(n[i], e);
|
|
1550
1568
|
}
|
|
1551
1569
|
_condense(e) {
|
|
1552
1570
|
for (let n = e.length - 1, o; n >= 0; n--)
|
|
1553
|
-
e[n].children.length === 0 ? n > 0 ? (o = e[n - 1].children, o.splice(o.indexOf(e[n]), 1)) : this.clear() :
|
|
1571
|
+
e[n].children.length === 0 ? n > 0 ? (o = e[n - 1].children, o.splice(o.indexOf(e[n]), 1)) : this.clear() : J(e[n], this.toBBox);
|
|
1554
1572
|
}
|
|
1555
1573
|
}
|
|
1556
|
-
function
|
|
1574
|
+
function qn(t, e, n) {
|
|
1557
1575
|
if (!n) return e.indexOf(t);
|
|
1558
1576
|
for (let o = 0; o < e.length; o++)
|
|
1559
1577
|
if (n(t, e[o])) return o;
|
|
1560
1578
|
return -1;
|
|
1561
1579
|
}
|
|
1562
|
-
function
|
|
1563
|
-
|
|
1580
|
+
function J(t, e) {
|
|
1581
|
+
st(t, 0, t.children.length, e, t);
|
|
1564
1582
|
}
|
|
1565
|
-
function
|
|
1566
|
-
i || (i =
|
|
1583
|
+
function st(t, e, n, o, i) {
|
|
1584
|
+
i || (i = Z(null)), i.minX = 1 / 0, i.minY = 1 / 0, i.maxX = -1 / 0, i.maxY = -1 / 0;
|
|
1567
1585
|
for (let s = e; s < n; s++) {
|
|
1568
1586
|
const a = t.children[s];
|
|
1569
|
-
|
|
1587
|
+
rt(i, t.leaf ? o(a) : a);
|
|
1570
1588
|
}
|
|
1571
1589
|
return i;
|
|
1572
1590
|
}
|
|
1573
|
-
function
|
|
1591
|
+
function rt(t, e) {
|
|
1574
1592
|
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;
|
|
1575
1593
|
}
|
|
1576
|
-
function
|
|
1594
|
+
function Gn(t, e) {
|
|
1577
1595
|
return t.minX - e.minX;
|
|
1578
1596
|
}
|
|
1579
|
-
function
|
|
1597
|
+
function Qn(t, e) {
|
|
1580
1598
|
return t.minY - e.minY;
|
|
1581
1599
|
}
|
|
1582
|
-
function
|
|
1600
|
+
function Bt(t) {
|
|
1583
1601
|
return (t.maxX - t.minX) * (t.maxY - t.minY);
|
|
1584
1602
|
}
|
|
1585
|
-
function
|
|
1603
|
+
function gt(t) {
|
|
1586
1604
|
return t.maxX - t.minX + (t.maxY - t.minY);
|
|
1587
1605
|
}
|
|
1588
|
-
function
|
|
1606
|
+
function Jn(t, e) {
|
|
1589
1607
|
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));
|
|
1590
1608
|
}
|
|
1591
|
-
function
|
|
1609
|
+
function Zn(t, e) {
|
|
1592
1610
|
const n = Math.max(t.minX, e.minX), o = Math.max(t.minY, e.minY), i = Math.min(t.maxX, e.maxX), s = Math.min(t.maxY, e.maxY);
|
|
1593
1611
|
return Math.max(0, i - n) * Math.max(0, s - o);
|
|
1594
1612
|
}
|
|
1595
1613
|
function Rt(t, e) {
|
|
1596
1614
|
return t.minX <= e.minX && t.minY <= e.minY && e.maxX <= t.maxX && e.maxY <= t.maxY;
|
|
1597
1615
|
}
|
|
1598
|
-
function
|
|
1616
|
+
function mt(t, e) {
|
|
1599
1617
|
return e.minX <= t.maxX && e.minY <= t.maxY && e.maxX >= t.minX && e.maxY >= t.minY;
|
|
1600
1618
|
}
|
|
1601
|
-
function
|
|
1619
|
+
function Z(t) {
|
|
1602
1620
|
return {
|
|
1603
1621
|
children: t,
|
|
1604
1622
|
height: 1,
|
|
@@ -1609,30 +1627,30 @@ function J(t) {
|
|
|
1609
1627
|
maxY: -1 / 0
|
|
1610
1628
|
};
|
|
1611
1629
|
}
|
|
1612
|
-
function
|
|
1630
|
+
function ee(t, e, n, o, i) {
|
|
1613
1631
|
const s = [e, n];
|
|
1614
1632
|
for (; s.length; ) {
|
|
1615
1633
|
if (n = s.pop(), e = s.pop(), n - e <= o) continue;
|
|
1616
1634
|
const a = e + Math.ceil((n - e) / o / 2) * o;
|
|
1617
|
-
|
|
1635
|
+
me(t, a, e, n, i), s.push(e, a, a, n);
|
|
1618
1636
|
}
|
|
1619
1637
|
}
|
|
1620
|
-
const
|
|
1621
|
-
const n = new
|
|
1622
|
-
const
|
|
1623
|
-
const
|
|
1624
|
-
return Array.from(
|
|
1625
|
-
}),
|
|
1626
|
-
return
|
|
1627
|
-
const { x:
|
|
1638
|
+
const to = (t, e) => {
|
|
1639
|
+
const n = new Wn(), o = /* @__PURE__ */ new Map(), i = (d, c) => {
|
|
1640
|
+
const A = d.selector.flatMap((T) => {
|
|
1641
|
+
const S = F([T]) ? T.range : ae(T, e).range;
|
|
1642
|
+
return Array.from(S.getClientRects());
|
|
1643
|
+
}), E = Ue(A).map(({ left: T, top: S, right: O, bottom: M }) => new DOMRect(T - c.left, S - c.top, O - T, M - S));
|
|
1644
|
+
return E.map((T) => {
|
|
1645
|
+
const { x: S, y: O, width: M, height: L } = T;
|
|
1628
1646
|
return {
|
|
1629
|
-
minX:
|
|
1647
|
+
minX: S,
|
|
1630
1648
|
minY: O,
|
|
1631
|
-
maxX:
|
|
1632
|
-
maxY: O +
|
|
1649
|
+
maxX: S + M,
|
|
1650
|
+
maxY: O + L,
|
|
1633
1651
|
annotation: {
|
|
1634
1652
|
id: d.annotation,
|
|
1635
|
-
rects:
|
|
1653
|
+
rects: E
|
|
1636
1654
|
}
|
|
1637
1655
|
};
|
|
1638
1656
|
});
|
|
@@ -1640,165 +1658,168 @@ const eo = (t, e) => {
|
|
|
1640
1658
|
n.clear(), o.clear();
|
|
1641
1659
|
}, r = (d) => {
|
|
1642
1660
|
const c = i(d, e.getBoundingClientRect());
|
|
1643
|
-
c.forEach((
|
|
1661
|
+
c.forEach((A) => n.insert(A)), o.set(d.annotation, c);
|
|
1644
1662
|
}, l = (d) => {
|
|
1645
1663
|
const c = o.get(d.annotation);
|
|
1646
|
-
c && (c.forEach((
|
|
1664
|
+
c && (c.forEach((A) => n.remove(A)), o.delete(d.annotation));
|
|
1647
1665
|
}, f = (d) => {
|
|
1648
1666
|
l(d), r(d);
|
|
1649
|
-
},
|
|
1667
|
+
}, h = (d, c = !0) => {
|
|
1650
1668
|
c && a();
|
|
1651
|
-
const
|
|
1652
|
-
|
|
1653
|
-
const T =
|
|
1669
|
+
const A = e.getBoundingClientRect(), E = d.map((S) => ({ target: S, rects: i(S, A) }));
|
|
1670
|
+
E.forEach(({ target: S, rects: O }) => o.set(S.annotation, O));
|
|
1671
|
+
const T = E.flatMap(({ rects: S }) => S);
|
|
1654
1672
|
n.load(T);
|
|
1655
|
-
},
|
|
1656
|
-
const
|
|
1673
|
+
}, u = (d, c, A = !1) => {
|
|
1674
|
+
const E = n.search({
|
|
1657
1675
|
minX: d,
|
|
1658
1676
|
minY: c,
|
|
1659
1677
|
maxX: d,
|
|
1660
1678
|
maxY: c
|
|
1661
|
-
}), T = (
|
|
1662
|
-
return
|
|
1663
|
-
},
|
|
1664
|
-
const c =
|
|
1679
|
+
}), T = (S) => S.annotation.rects.reduce((O, M) => O + M.width * M.height, 0);
|
|
1680
|
+
return E.length > 0 ? (E.sort((S, O) => T(S) - T(O)), A ? E.map((S) => S.annotation.id) : [E[0].annotation.id]) : [];
|
|
1681
|
+
}, p = (d) => {
|
|
1682
|
+
const c = g(d);
|
|
1665
1683
|
if (c.length === 0)
|
|
1666
1684
|
return;
|
|
1667
|
-
let
|
|
1685
|
+
let A = c[0].left, E = c[0].top, T = c[0].right, S = c[0].bottom;
|
|
1668
1686
|
for (let O = 1; O < c.length; O++) {
|
|
1669
|
-
const
|
|
1670
|
-
|
|
1687
|
+
const M = c[O];
|
|
1688
|
+
A = Math.min(A, M.left), E = Math.min(E, M.top), T = Math.max(T, M.right), S = Math.max(S, M.bottom);
|
|
1671
1689
|
}
|
|
1672
|
-
return new DOMRect(
|
|
1673
|
-
},
|
|
1690
|
+
return new DOMRect(A, E, T - A, S - E);
|
|
1691
|
+
}, g = (d) => {
|
|
1674
1692
|
const c = o.get(d);
|
|
1675
1693
|
return c ? c[0].annotation.rects : [];
|
|
1676
1694
|
};
|
|
1677
1695
|
return {
|
|
1678
1696
|
all: s,
|
|
1679
1697
|
clear: a,
|
|
1680
|
-
getAt:
|
|
1681
|
-
getAnnotationBounds:
|
|
1682
|
-
getAnnotationRects:
|
|
1683
|
-
getIntersecting: (d, c,
|
|
1684
|
-
const T = n.search({ minX: d, minY: c, maxX:
|
|
1685
|
-
return Array.from(
|
|
1698
|
+
getAt: u,
|
|
1699
|
+
getAnnotationBounds: p,
|
|
1700
|
+
getAnnotationRects: g,
|
|
1701
|
+
getIntersecting: (d, c, A, E) => {
|
|
1702
|
+
const T = n.search({ minX: d, minY: c, maxX: A, maxY: E }), S = new Set(T.map((O) => O.annotation.id));
|
|
1703
|
+
return Array.from(S).map((O) => ({
|
|
1686
1704
|
annotation: t.getAnnotation(O),
|
|
1687
|
-
rects:
|
|
1705
|
+
rects: g(O)
|
|
1688
1706
|
})).filter((O) => !!O.annotation);
|
|
1689
1707
|
},
|
|
1690
1708
|
insert: r,
|
|
1691
|
-
recalculate: () =>
|
|
1709
|
+
recalculate: () => h(t.all().map((d) => d.target), !0),
|
|
1692
1710
|
remove: l,
|
|
1693
|
-
set:
|
|
1711
|
+
set: h,
|
|
1694
1712
|
size: () => n.all().length,
|
|
1695
1713
|
update: f
|
|
1696
1714
|
};
|
|
1697
|
-
},
|
|
1698
|
-
const n =
|
|
1715
|
+
}, eo = (t, e) => {
|
|
1716
|
+
const n = Ln(), o = to(n, t), i = pn(n);
|
|
1699
1717
|
i.setUserSelectAction(e);
|
|
1700
|
-
const s =
|
|
1701
|
-
const c =
|
|
1702
|
-
return
|
|
1703
|
-
}, l = (
|
|
1704
|
-
const
|
|
1705
|
-
return
|
|
1706
|
-
}, f = (
|
|
1707
|
-
const c =
|
|
1708
|
-
return
|
|
1709
|
-
n.getAnnotation(
|
|
1710
|
-
}),
|
|
1711
|
-
},
|
|
1712
|
-
const c =
|
|
1718
|
+
const s = fn(n), a = Bn(), r = (y, d = k.LOCAL) => {
|
|
1719
|
+
const c = xt(y, t), A = F(c.target.selector);
|
|
1720
|
+
return A && n.addAnnotation(c, d), A;
|
|
1721
|
+
}, l = (y, d = !0, c = k.LOCAL) => {
|
|
1722
|
+
const A = y.map((T) => xt(T, t)), E = A.filter((T) => !F(T.target.selector));
|
|
1723
|
+
return n.bulkAddAnnotation(A, d, c), E;
|
|
1724
|
+
}, f = (y, d = k.LOCAL) => {
|
|
1725
|
+
const c = y.map((E) => xt(E, t)), A = c.filter((E) => !F(E.target.selector));
|
|
1726
|
+
return c.forEach((E) => {
|
|
1727
|
+
n.getAnnotation(E.id) ? n.updateAnnotation(E, d) : n.addAnnotation(E, d);
|
|
1728
|
+
}), A;
|
|
1729
|
+
}, h = (y, d = k.LOCAL) => {
|
|
1730
|
+
const c = bt(y, t);
|
|
1713
1731
|
n.updateTarget(c, d);
|
|
1714
|
-
},
|
|
1715
|
-
const c =
|
|
1732
|
+
}, u = (y, d = k.LOCAL) => {
|
|
1733
|
+
const c = y.map((A) => bt(A, t));
|
|
1716
1734
|
n.bulkUpdateTargets(c, d);
|
|
1717
|
-
}
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1735
|
+
};
|
|
1736
|
+
function p(y, d, c, A) {
|
|
1737
|
+
const E = c || !!A, T = o.getAt(y, d, E).map((O) => n.getAnnotation(O)), S = A ? T.filter(A) : T;
|
|
1738
|
+
if (S.length !== 0)
|
|
1739
|
+
return c ? S : S[0];
|
|
1740
|
+
}
|
|
1741
|
+
const g = (y, d, c, A = 5) => {
|
|
1742
|
+
const E = o.getAnnotationRects(y);
|
|
1743
|
+
if (E.length !== 0) {
|
|
1723
1744
|
if (d && c) {
|
|
1724
|
-
const T =
|
|
1745
|
+
const T = E.find(({ top: S, right: O, bottom: M, left: L }) => d >= L - A && d <= O + A && c >= S - A && c <= M + A);
|
|
1725
1746
|
if (T) return T;
|
|
1726
1747
|
}
|
|
1727
|
-
return o.getAnnotationBounds(
|
|
1748
|
+
return o.getAnnotationBounds(y);
|
|
1728
1749
|
}
|
|
1729
|
-
},
|
|
1730
|
-
return n.observe(({ changes:
|
|
1731
|
-
const d = (
|
|
1732
|
-
(d == null ? void 0 : d.length) > 0 && d.forEach((
|
|
1750
|
+
}, b = (y) => o.getAnnotationRects(y), w = () => o.recalculate();
|
|
1751
|
+
return n.observe(({ changes: y }) => {
|
|
1752
|
+
const d = (y.deleted || []).filter((E) => F(E.target.selector)), c = (y.created || []).filter((E) => F(E.target.selector)), A = (y.updated || []).filter((E) => F(E.newValue.target.selector));
|
|
1753
|
+
(d == null ? void 0 : d.length) > 0 && d.forEach((E) => o.remove(E.target)), c.length > 0 && o.set(c.map((E) => E.target), !1), (A == null ? void 0 : A.length) > 0 && A.forEach(({ newValue: E }) => o.update(E.target));
|
|
1733
1754
|
}), {
|
|
1734
1755
|
store: {
|
|
1735
1756
|
...n,
|
|
1736
1757
|
addAnnotation: r,
|
|
1737
1758
|
bulkAddAnnotation: l,
|
|
1738
|
-
bulkUpdateTargets:
|
|
1759
|
+
bulkUpdateTargets: u,
|
|
1739
1760
|
bulkUpsertAnnotations: f,
|
|
1740
|
-
getAnnotationBounds:
|
|
1741
|
-
getAnnotationRects:
|
|
1742
|
-
getAt:
|
|
1761
|
+
getAnnotationBounds: g,
|
|
1762
|
+
getAnnotationRects: b,
|
|
1763
|
+
getAt: p,
|
|
1743
1764
|
getIntersecting: o.getIntersecting,
|
|
1744
|
-
recalculatePositions:
|
|
1745
|
-
updateTarget:
|
|
1765
|
+
recalculatePositions: w,
|
|
1766
|
+
updateTarget: h
|
|
1746
1767
|
},
|
|
1747
1768
|
selection: i,
|
|
1748
1769
|
hover: s,
|
|
1749
1770
|
viewport: a
|
|
1750
1771
|
};
|
|
1751
|
-
},
|
|
1772
|
+
}, no = () => {
|
|
1752
1773
|
const t = document.createElement("canvas");
|
|
1753
1774
|
t.width = 2 * window.innerWidth, t.height = 2 * window.innerHeight, t.className = "r6o-presence-layer";
|
|
1754
1775
|
const e = t.getContext("2d");
|
|
1755
1776
|
return e.scale(2, 2), e.translate(0.5, 0.5), t;
|
|
1756
|
-
},
|
|
1757
|
-
const n =
|
|
1777
|
+
}, oo = (t, e = {}) => {
|
|
1778
|
+
const n = no(), o = n.getContext("2d");
|
|
1758
1779
|
document.body.appendChild(n);
|
|
1759
|
-
const i = /* @__PURE__ */ new Map(), s = (
|
|
1760
|
-
return t.on("selectionChange", (
|
|
1761
|
-
s(
|
|
1780
|
+
const i = /* @__PURE__ */ new Map(), s = (h) => Array.from(i.entries()).filter(([u, p]) => p.presenceKey === h.presenceKey).map(([u, p]) => u);
|
|
1781
|
+
return t.on("selectionChange", (h, u) => {
|
|
1782
|
+
s(h).forEach((g) => i.delete(g)), u && u.forEach((g) => i.set(g, h));
|
|
1762
1783
|
}), {
|
|
1763
1784
|
clear: () => {
|
|
1764
|
-
const { width:
|
|
1765
|
-
o.clearRect(-0.5, -0.5,
|
|
1785
|
+
const { width: h, height: u } = n;
|
|
1786
|
+
o.clearRect(-0.5, -0.5, h + 1, u + 1);
|
|
1766
1787
|
},
|
|
1767
1788
|
destroy: () => {
|
|
1768
1789
|
n.remove();
|
|
1769
1790
|
},
|
|
1770
|
-
paint: (
|
|
1791
|
+
paint: (h, u, p) => {
|
|
1771
1792
|
e.font && (o.font = e.font);
|
|
1772
|
-
const
|
|
1773
|
-
if (
|
|
1774
|
-
const { height:
|
|
1775
|
-
o.fillStyle =
|
|
1776
|
-
const d = o.measureText(
|
|
1777
|
-
return o.fillRect(
|
|
1778
|
-
fill:
|
|
1779
|
-
fillOpacity:
|
|
1793
|
+
const g = i.get(h.annotation.id);
|
|
1794
|
+
if (g) {
|
|
1795
|
+
const { height: b } = h.rects[0], w = h.rects[0].x + u.left, y = h.rects[0].y + u.top;
|
|
1796
|
+
o.fillStyle = g.appearance.color, o.fillRect(w - 2, y - 2.5, 2, b + 5);
|
|
1797
|
+
const d = o.measureText(g.appearance.label), c = d.width + 6, A = d.actualBoundingBoxAscent + d.actualBoundingBoxDescent + 8, E = d.fontBoundingBoxAscent ? 8 : 6.5;
|
|
1798
|
+
return o.fillRect(w - 2, y - 2.5 - A, c, A), o.fillStyle = "#fff", o.fillText(g.appearance.label, w + 1, y - E), {
|
|
1799
|
+
fill: g.appearance.color,
|
|
1800
|
+
fillOpacity: p ? 0.45 : 0.18
|
|
1780
1801
|
};
|
|
1781
1802
|
}
|
|
1782
1803
|
},
|
|
1783
1804
|
reset: () => {
|
|
1784
1805
|
n.width = 2 * window.innerWidth, n.height = 2 * window.innerHeight;
|
|
1785
|
-
const
|
|
1786
|
-
|
|
1806
|
+
const h = n.getContext("2d");
|
|
1807
|
+
h.scale(2, 2), h.translate(0.5, 0.5);
|
|
1787
1808
|
}
|
|
1788
1809
|
};
|
|
1789
|
-
},
|
|
1790
|
-
function
|
|
1810
|
+
}, kt = typeof navigator < "u" ? navigator.userAgent.toLowerCase().indexOf("firefox") > 0 : !1;
|
|
1811
|
+
function It(t, e, n, o) {
|
|
1791
1812
|
t.addEventListener ? t.addEventListener(e, n, o) : t.attachEvent && t.attachEvent("on".concat(e), n);
|
|
1792
1813
|
}
|
|
1793
|
-
function
|
|
1814
|
+
function ot(t, e, n, o) {
|
|
1794
1815
|
t.removeEventListener ? t.removeEventListener(e, n, o) : t.detachEvent && t.detachEvent("on".concat(e), n);
|
|
1795
1816
|
}
|
|
1796
|
-
function
|
|
1817
|
+
function ye(t, e) {
|
|
1797
1818
|
const n = e.slice(0, e.length - 1);
|
|
1798
1819
|
for (let o = 0; o < n.length; o++) n[o] = t[n[o].toLowerCase()];
|
|
1799
1820
|
return n;
|
|
1800
1821
|
}
|
|
1801
|
-
function
|
|
1822
|
+
function be(t) {
|
|
1802
1823
|
typeof t != "string" && (t = ""), t = t.replace(/\s/g, "");
|
|
1803
1824
|
const e = t.split(",");
|
|
1804
1825
|
let n = e.lastIndexOf("");
|
|
@@ -1806,14 +1827,14 @@ function ye(t) {
|
|
|
1806
1827
|
e[n - 1] += ",", e.splice(n, 1), n = e.lastIndexOf("");
|
|
1807
1828
|
return e;
|
|
1808
1829
|
}
|
|
1809
|
-
function
|
|
1830
|
+
function io(t, e) {
|
|
1810
1831
|
const n = t.length >= e.length ? t : e, o = t.length >= e.length ? e : t;
|
|
1811
1832
|
let i = !0;
|
|
1812
1833
|
for (let s = 0; s < n.length; s++)
|
|
1813
1834
|
o.indexOf(n[s]) === -1 && (i = !1);
|
|
1814
1835
|
return i;
|
|
1815
1836
|
}
|
|
1816
|
-
const
|
|
1837
|
+
const lt = {
|
|
1817
1838
|
backspace: 8,
|
|
1818
1839
|
"⌫": 8,
|
|
1819
1840
|
tab: 9,
|
|
@@ -1858,9 +1879,9 @@ const at = {
|
|
|
1858
1879
|
".": 190,
|
|
1859
1880
|
"/": 191,
|
|
1860
1881
|
"`": 192,
|
|
1861
|
-
"-":
|
|
1862
|
-
"=":
|
|
1863
|
-
";":
|
|
1882
|
+
"-": kt ? 173 : 189,
|
|
1883
|
+
"=": kt ? 61 : 187,
|
|
1884
|
+
";": kt ? 59 : 186,
|
|
1864
1885
|
"'": 222,
|
|
1865
1886
|
"[": 219,
|
|
1866
1887
|
"]": 221,
|
|
@@ -1881,7 +1902,7 @@ const at = {
|
|
|
1881
1902
|
"⌘": 91,
|
|
1882
1903
|
cmd: 91,
|
|
1883
1904
|
command: 91
|
|
1884
|
-
},
|
|
1905
|
+
}, Vt = {
|
|
1885
1906
|
16: "shiftKey",
|
|
1886
1907
|
18: "altKey",
|
|
1887
1908
|
17: "ctrlKey",
|
|
@@ -1890,29 +1911,29 @@ const at = {
|
|
|
1890
1911
|
ctrlKey: 17,
|
|
1891
1912
|
altKey: 18,
|
|
1892
1913
|
metaKey: 91
|
|
1893
|
-
},
|
|
1914
|
+
}, D = {
|
|
1894
1915
|
16: !1,
|
|
1895
1916
|
18: !1,
|
|
1896
1917
|
17: !1,
|
|
1897
1918
|
91: !1
|
|
1898
1919
|
}, _ = {};
|
|
1899
1920
|
for (let t = 1; t < 20; t++)
|
|
1900
|
-
|
|
1901
|
-
let I = [],
|
|
1902
|
-
const z = /* @__PURE__ */ new Map(),
|
|
1903
|
-
function
|
|
1904
|
-
|
|
1921
|
+
lt["f".concat(t)] = 111 + t;
|
|
1922
|
+
let I = [], ct = null, we = "all";
|
|
1923
|
+
const z = /* @__PURE__ */ new Map(), ut = (t) => lt[t.toLowerCase()] || H[t.toLowerCase()] || t.toUpperCase().charCodeAt(0), so = (t) => Object.keys(lt).find((e) => lt[e] === t), ro = (t) => Object.keys(H).find((e) => H[e] === t);
|
|
1924
|
+
function Ae(t) {
|
|
1925
|
+
we = t || "all";
|
|
1905
1926
|
}
|
|
1906
|
-
function
|
|
1907
|
-
return
|
|
1927
|
+
function dt() {
|
|
1928
|
+
return we || "all";
|
|
1908
1929
|
}
|
|
1909
|
-
function
|
|
1930
|
+
function ao() {
|
|
1910
1931
|
return I.slice(0);
|
|
1911
1932
|
}
|
|
1912
|
-
function
|
|
1913
|
-
return I.map((t) =>
|
|
1933
|
+
function co() {
|
|
1934
|
+
return I.map((t) => so(t) || ro(t) || String.fromCharCode(t));
|
|
1914
1935
|
}
|
|
1915
|
-
function
|
|
1936
|
+
function lo() {
|
|
1916
1937
|
const t = [];
|
|
1917
1938
|
return Object.keys(_).forEach((e) => {
|
|
1918
1939
|
_[e].forEach((n) => {
|
|
@@ -1926,12 +1947,12 @@ function uo() {
|
|
|
1926
1947
|
scope: i,
|
|
1927
1948
|
shortcut: a,
|
|
1928
1949
|
mods: s,
|
|
1929
|
-
keys: o.split("+").map((r) =>
|
|
1950
|
+
keys: o.split("+").map((r) => ut(r))
|
|
1930
1951
|
});
|
|
1931
1952
|
});
|
|
1932
1953
|
}), t;
|
|
1933
1954
|
}
|
|
1934
|
-
function
|
|
1955
|
+
function uo(t) {
|
|
1935
1956
|
const e = t.target || t.srcElement, {
|
|
1936
1957
|
tagName: n
|
|
1937
1958
|
} = e;
|
|
@@ -1939,12 +1960,12 @@ function fo(t) {
|
|
|
1939
1960
|
const i = n === "INPUT" && !["checkbox", "radio", "range", "button", "file", "reset", "submit", "color"].includes(e.type);
|
|
1940
1961
|
return (e.isContentEditable || (i || n === "TEXTAREA" || n === "SELECT") && !e.readOnly) && (o = !1), o;
|
|
1941
1962
|
}
|
|
1942
|
-
function
|
|
1943
|
-
return typeof t == "string" && (t =
|
|
1963
|
+
function fo(t) {
|
|
1964
|
+
return typeof t == "string" && (t = ut(t)), I.indexOf(t) !== -1;
|
|
1944
1965
|
}
|
|
1945
|
-
function
|
|
1966
|
+
function ho(t, e) {
|
|
1946
1967
|
let n, o;
|
|
1947
|
-
t || (t =
|
|
1968
|
+
t || (t = dt());
|
|
1948
1969
|
for (const i in _)
|
|
1949
1970
|
if (Object.prototype.hasOwnProperty.call(_, i))
|
|
1950
1971
|
for (n = _[i], o = 0; o < n.length; )
|
|
@@ -1952,34 +1973,34 @@ function po(t, e) {
|
|
|
1952
1973
|
let {
|
|
1953
1974
|
element: r
|
|
1954
1975
|
} = a;
|
|
1955
|
-
return
|
|
1976
|
+
return Xt(r);
|
|
1956
1977
|
}) : o++;
|
|
1957
|
-
|
|
1978
|
+
dt() === t && Ae(e || "all");
|
|
1958
1979
|
}
|
|
1959
|
-
function
|
|
1980
|
+
function po(t) {
|
|
1960
1981
|
let e = t.keyCode || t.which || t.charCode;
|
|
1961
1982
|
const n = I.indexOf(e);
|
|
1962
|
-
if (n >= 0 && I.splice(n, 1), t.key && t.key.toLowerCase() === "meta" && I.splice(0, I.length), (e === 93 || e === 224) && (e = 91), e in
|
|
1963
|
-
|
|
1983
|
+
if (n >= 0 && I.splice(n, 1), t.key && t.key.toLowerCase() === "meta" && I.splice(0, I.length), (e === 93 || e === 224) && (e = 91), e in D) {
|
|
1984
|
+
D[e] = !1;
|
|
1964
1985
|
for (const o in H) H[o] === e && (P[o] = !1);
|
|
1965
1986
|
}
|
|
1966
1987
|
}
|
|
1967
|
-
function
|
|
1988
|
+
function xe(t) {
|
|
1968
1989
|
if (typeof t > "u")
|
|
1969
1990
|
Object.keys(_).forEach((i) => {
|
|
1970
|
-
Array.isArray(_[i]) && _[i].forEach((s) =>
|
|
1971
|
-
}),
|
|
1991
|
+
Array.isArray(_[i]) && _[i].forEach((s) => yt(s)), delete _[i];
|
|
1992
|
+
}), Xt(null);
|
|
1972
1993
|
else if (Array.isArray(t))
|
|
1973
1994
|
t.forEach((i) => {
|
|
1974
|
-
i.key &&
|
|
1995
|
+
i.key && yt(i);
|
|
1975
1996
|
});
|
|
1976
1997
|
else if (typeof t == "object")
|
|
1977
|
-
t.key &&
|
|
1998
|
+
t.key && yt(t);
|
|
1978
1999
|
else if (typeof t == "string") {
|
|
1979
2000
|
for (var e = arguments.length, n = new Array(e > 1 ? e - 1 : 0), o = 1; o < e; o++)
|
|
1980
2001
|
n[o - 1] = arguments[o];
|
|
1981
2002
|
let [i, s] = n;
|
|
1982
|
-
typeof i == "function" && (s = i, i = ""),
|
|
2003
|
+
typeof i == "function" && (s = i, i = ""), yt({
|
|
1983
2004
|
key: t,
|
|
1984
2005
|
scope: i,
|
|
1985
2006
|
method: s,
|
|
@@ -1987,73 +2008,73 @@ function ve(t) {
|
|
|
1987
2008
|
});
|
|
1988
2009
|
}
|
|
1989
2010
|
}
|
|
1990
|
-
const
|
|
2011
|
+
const yt = (t) => {
|
|
1991
2012
|
let {
|
|
1992
2013
|
key: e,
|
|
1993
2014
|
scope: n,
|
|
1994
2015
|
method: o,
|
|
1995
2016
|
splitKey: i = "+"
|
|
1996
2017
|
} = t;
|
|
1997
|
-
|
|
1998
|
-
const r = a.split(i), l = r.length, f = r[l - 1],
|
|
1999
|
-
if (!_[
|
|
2000
|
-
n || (n =
|
|
2001
|
-
const
|
|
2002
|
-
_[
|
|
2003
|
-
const
|
|
2004
|
-
return
|
|
2005
|
-
}),
|
|
2018
|
+
be(e).forEach((a) => {
|
|
2019
|
+
const r = a.split(i), l = r.length, f = r[l - 1], h = f === "*" ? "*" : ut(f);
|
|
2020
|
+
if (!_[h]) return;
|
|
2021
|
+
n || (n = dt());
|
|
2022
|
+
const u = l > 1 ? ye(H, r) : [], p = [];
|
|
2023
|
+
_[h] = _[h].filter((g) => {
|
|
2024
|
+
const w = (o ? g.method === o : !0) && g.scope === n && io(g.mods, u);
|
|
2025
|
+
return w && p.push(g.element), !w;
|
|
2026
|
+
}), p.forEach((g) => Xt(g));
|
|
2006
2027
|
});
|
|
2007
2028
|
};
|
|
2008
|
-
function
|
|
2029
|
+
function ne(t, e, n, o) {
|
|
2009
2030
|
if (e.element !== o)
|
|
2010
2031
|
return;
|
|
2011
2032
|
let i;
|
|
2012
2033
|
if (e.scope === n || e.scope === "all") {
|
|
2013
2034
|
i = e.mods.length > 0;
|
|
2014
|
-
for (const s in
|
|
2015
|
-
Object.prototype.hasOwnProperty.call(
|
|
2016
|
-
(e.mods.length === 0 && !
|
|
2035
|
+
for (const s in D)
|
|
2036
|
+
Object.prototype.hasOwnProperty.call(D, s) && (!D[s] && e.mods.indexOf(+s) > -1 || D[s] && e.mods.indexOf(+s) === -1) && (i = !1);
|
|
2037
|
+
(e.mods.length === 0 && !D[16] && !D[18] && !D[17] && !D[91] || i || e.shortcut === "*") && (e.keys = [], e.keys = e.keys.concat(I), e.method(t, e) === !1 && (t.preventDefault ? t.preventDefault() : t.returnValue = !1, t.stopPropagation && t.stopPropagation(), t.cancelBubble && (t.cancelBubble = !0)));
|
|
2017
2038
|
}
|
|
2018
2039
|
}
|
|
2019
|
-
function
|
|
2040
|
+
function oe(t, e) {
|
|
2020
2041
|
const n = _["*"];
|
|
2021
2042
|
let o = t.keyCode || t.which || t.charCode;
|
|
2022
2043
|
if (!P.filter.call(this, t)) return;
|
|
2023
2044
|
if ((o === 93 || o === 224) && (o = 91), I.indexOf(o) === -1 && o !== 229 && I.push(o), ["ctrlKey", "altKey", "shiftKey", "metaKey"].forEach((r) => {
|
|
2024
|
-
const l =
|
|
2045
|
+
const l = Vt[r];
|
|
2025
2046
|
t[r] && I.indexOf(l) === -1 ? I.push(l) : !t[r] && I.indexOf(l) > -1 ? I.splice(I.indexOf(l), 1) : r === "metaKey" && t[r] && I.length === 3 && (t.ctrlKey || t.shiftKey || t.altKey || (I = I.slice(I.indexOf(l))));
|
|
2026
|
-
}), o in
|
|
2027
|
-
|
|
2047
|
+
}), o in D) {
|
|
2048
|
+
D[o] = !0;
|
|
2028
2049
|
for (const r in H)
|
|
2029
2050
|
H[r] === o && (P[r] = !0);
|
|
2030
2051
|
if (!n) return;
|
|
2031
2052
|
}
|
|
2032
|
-
for (const r in
|
|
2033
|
-
Object.prototype.hasOwnProperty.call(
|
|
2034
|
-
t.getModifierState && !(t.altKey && !t.ctrlKey) && t.getModifierState("AltGraph") && (I.indexOf(17) === -1 && I.push(17), I.indexOf(18) === -1 && I.push(18),
|
|
2035
|
-
const i =
|
|
2053
|
+
for (const r in D)
|
|
2054
|
+
Object.prototype.hasOwnProperty.call(D, r) && (D[r] = t[Vt[r]]);
|
|
2055
|
+
t.getModifierState && !(t.altKey && !t.ctrlKey) && t.getModifierState("AltGraph") && (I.indexOf(17) === -1 && I.push(17), I.indexOf(18) === -1 && I.push(18), D[17] = !0, D[18] = !0);
|
|
2056
|
+
const i = dt();
|
|
2036
2057
|
if (n)
|
|
2037
2058
|
for (let r = 0; r < n.length; r++)
|
|
2038
|
-
n[r].scope === i && (t.type === "keydown" && n[r].keydown || t.type === "keyup" && n[r].keyup) &&
|
|
2059
|
+
n[r].scope === i && (t.type === "keydown" && n[r].keydown || t.type === "keyup" && n[r].keyup) && ne(t, n[r], i, e);
|
|
2039
2060
|
if (!(o in _)) return;
|
|
2040
2061
|
const s = _[o], a = s.length;
|
|
2041
2062
|
for (let r = 0; r < a; r++)
|
|
2042
2063
|
if ((t.type === "keydown" && s[r].keydown || t.type === "keyup" && s[r].keyup) && s[r].key) {
|
|
2043
2064
|
const l = s[r], {
|
|
2044
2065
|
splitKey: f
|
|
2045
|
-
} = l,
|
|
2046
|
-
for (let
|
|
2047
|
-
|
|
2048
|
-
|
|
2066
|
+
} = l, h = l.key.split(f), u = [];
|
|
2067
|
+
for (let p = 0; p < h.length; p++)
|
|
2068
|
+
u.push(ut(h[p]));
|
|
2069
|
+
u.sort().join("") === I.sort().join("") && ne(t, l, i, e);
|
|
2049
2070
|
}
|
|
2050
2071
|
}
|
|
2051
2072
|
function P(t, e, n) {
|
|
2052
2073
|
I = [];
|
|
2053
|
-
const o =
|
|
2054
|
-
let i = [], s = "all", a = document, r = 0, l = !1, f = !0,
|
|
2055
|
-
for (n === void 0 && typeof e == "function" && (n = e), Object.prototype.toString.call(e) === "[object Object]" && (e.scope && (s = e.scope), e.element && (a = e.element), e.keyup && (l = e.keyup), e.keydown !== void 0 && (f = e.keydown), e.capture !== void 0 && (
|
|
2056
|
-
t = o[r].split(
|
|
2074
|
+
const o = be(t);
|
|
2075
|
+
let i = [], s = "all", a = document, r = 0, l = !1, f = !0, h = "+", u = !1, p = !1;
|
|
2076
|
+
for (n === void 0 && typeof e == "function" && (n = e), Object.prototype.toString.call(e) === "[object Object]" && (e.scope && (s = e.scope), e.element && (a = e.element), e.keyup && (l = e.keyup), e.keydown !== void 0 && (f = e.keydown), e.capture !== void 0 && (u = e.capture), typeof e.splitKey == "string" && (h = e.splitKey), e.single === !0 && (p = !0)), typeof e == "string" && (s = e), p && xe(t, s); r < o.length; r++)
|
|
2077
|
+
t = o[r].split(h), i = [], t.length > 1 && (i = ye(H, t)), t = t[t.length - 1], t = t === "*" ? "*" : ut(t), t in _ || (_[t] = []), _[t].push({
|
|
2057
2078
|
keyup: l,
|
|
2058
2079
|
keydown: f,
|
|
2059
2080
|
scope: s,
|
|
@@ -2061,36 +2082,36 @@ function P(t, e, n) {
|
|
|
2061
2082
|
shortcut: o[r],
|
|
2062
2083
|
method: n,
|
|
2063
2084
|
key: o[r],
|
|
2064
|
-
splitKey:
|
|
2085
|
+
splitKey: h,
|
|
2065
2086
|
element: a
|
|
2066
2087
|
});
|
|
2067
2088
|
if (typeof a < "u" && window) {
|
|
2068
2089
|
if (!z.has(a)) {
|
|
2069
|
-
const
|
|
2070
|
-
let
|
|
2071
|
-
return
|
|
2072
|
-
},
|
|
2073
|
-
let
|
|
2074
|
-
|
|
2090
|
+
const g = function() {
|
|
2091
|
+
let w = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : window.event;
|
|
2092
|
+
return oe(w, a);
|
|
2093
|
+
}, b = function() {
|
|
2094
|
+
let w = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : window.event;
|
|
2095
|
+
oe(w, a), po(w);
|
|
2075
2096
|
};
|
|
2076
2097
|
z.set(a, {
|
|
2077
|
-
keydownListener:
|
|
2078
|
-
keyupListenr:
|
|
2079
|
-
capture:
|
|
2080
|
-
}),
|
|
2098
|
+
keydownListener: g,
|
|
2099
|
+
keyupListenr: b,
|
|
2100
|
+
capture: u
|
|
2101
|
+
}), It(a, "keydown", g, u), It(a, "keyup", b, u);
|
|
2081
2102
|
}
|
|
2082
|
-
if (!
|
|
2083
|
-
const
|
|
2103
|
+
if (!ct) {
|
|
2104
|
+
const g = () => {
|
|
2084
2105
|
I = [];
|
|
2085
2106
|
};
|
|
2086
|
-
|
|
2087
|
-
listener:
|
|
2088
|
-
capture:
|
|
2089
|
-
},
|
|
2107
|
+
ct = {
|
|
2108
|
+
listener: g,
|
|
2109
|
+
capture: u
|
|
2110
|
+
}, It(window, "focus", g, u);
|
|
2090
2111
|
}
|
|
2091
2112
|
}
|
|
2092
2113
|
}
|
|
2093
|
-
function
|
|
2114
|
+
function go(t) {
|
|
2094
2115
|
let e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "all";
|
|
2095
2116
|
Object.keys(_).forEach((n) => {
|
|
2096
2117
|
_[n].filter((i) => i.scope === e && i.shortcut === t).forEach((i) => {
|
|
@@ -2098,7 +2119,7 @@ function mo(t) {
|
|
|
2098
2119
|
});
|
|
2099
2120
|
});
|
|
2100
2121
|
}
|
|
2101
|
-
function
|
|
2122
|
+
function Xt(t) {
|
|
2102
2123
|
const e = Object.values(_).flat();
|
|
2103
2124
|
if (e.findIndex((o) => {
|
|
2104
2125
|
let {
|
|
@@ -2111,7 +2132,7 @@ function Dt(t) {
|
|
|
2111
2132
|
keyupListenr: i,
|
|
2112
2133
|
capture: s
|
|
2113
2134
|
} = z.get(t) || {};
|
|
2114
|
-
o && i && (
|
|
2135
|
+
o && i && (ot(t, "keyup", i, s), ot(t, "keydown", o, s), z.delete(t));
|
|
2115
2136
|
}
|
|
2116
2137
|
if ((e.length <= 0 || z.size <= 0) && (Object.keys(z).forEach((i) => {
|
|
2117
2138
|
const {
|
|
@@ -2119,212 +2140,219 @@ function Dt(t) {
|
|
|
2119
2140
|
keyupListenr: a,
|
|
2120
2141
|
capture: r
|
|
2121
2142
|
} = z.get(i) || {};
|
|
2122
|
-
s && a && (
|
|
2123
|
-
}), z.clear(), Object.keys(_).forEach((i) => delete _[i]),
|
|
2143
|
+
s && a && (ot(i, "keyup", a, r), ot(i, "keydown", s, r), z.delete(i));
|
|
2144
|
+
}), z.clear(), Object.keys(_).forEach((i) => delete _[i]), ct)) {
|
|
2124
2145
|
const {
|
|
2125
2146
|
listener: i,
|
|
2126
2147
|
capture: s
|
|
2127
|
-
} =
|
|
2128
|
-
|
|
2148
|
+
} = ct;
|
|
2149
|
+
ot(window, "focus", i, s), ct = null;
|
|
2129
2150
|
}
|
|
2130
2151
|
}
|
|
2131
|
-
const
|
|
2132
|
-
getPressedKeyString:
|
|
2133
|
-
setScope:
|
|
2134
|
-
getScope:
|
|
2135
|
-
deleteScope:
|
|
2136
|
-
getPressedKeyCodes:
|
|
2137
|
-
getAllKeyCodes:
|
|
2138
|
-
isPressed:
|
|
2139
|
-
filter:
|
|
2140
|
-
trigger:
|
|
2141
|
-
unbind:
|
|
2142
|
-
keyMap:
|
|
2152
|
+
const _t = {
|
|
2153
|
+
getPressedKeyString: co,
|
|
2154
|
+
setScope: Ae,
|
|
2155
|
+
getScope: dt,
|
|
2156
|
+
deleteScope: ho,
|
|
2157
|
+
getPressedKeyCodes: ao,
|
|
2158
|
+
getAllKeyCodes: lo,
|
|
2159
|
+
isPressed: fo,
|
|
2160
|
+
filter: uo,
|
|
2161
|
+
trigger: go,
|
|
2162
|
+
unbind: xe,
|
|
2163
|
+
keyMap: lt,
|
|
2143
2164
|
modifier: H,
|
|
2144
|
-
modifierMap:
|
|
2165
|
+
modifierMap: Vt
|
|
2145
2166
|
};
|
|
2146
|
-
for (const t in
|
|
2147
|
-
Object.prototype.hasOwnProperty.call(
|
|
2167
|
+
for (const t in _t)
|
|
2168
|
+
Object.prototype.hasOwnProperty.call(_t, t) && (P[t] = _t[t]);
|
|
2148
2169
|
if (typeof window < "u") {
|
|
2149
2170
|
const t = window.hotkeys;
|
|
2150
2171
|
P.noConflict = (e) => (e && window.hotkeys === P && (window.hotkeys = t), P), window.hotkeys = P;
|
|
2151
2172
|
}
|
|
2152
|
-
const
|
|
2153
|
-
...
|
|
2154
|
-
|
|
2155
|
-
],
|
|
2156
|
-
let
|
|
2157
|
-
const s = (
|
|
2158
|
-
let
|
|
2159
|
-
const
|
|
2160
|
-
let
|
|
2161
|
-
const
|
|
2162
|
-
|
|
2163
|
-
annotation:
|
|
2173
|
+
const ie = 300, ve = ["up", "down", "left", "right"], Ee = Te ? "⌘+a" : "ctrl+a", mo = [
|
|
2174
|
+
...ve.map((t) => `shift+${t}`),
|
|
2175
|
+
Ee
|
|
2176
|
+
], yo = (t, e, n) => {
|
|
2177
|
+
let o;
|
|
2178
|
+
const { annotatingEnabled: i, offsetReferenceSelector: s, selectionMode: a } = n, r = (L) => o = L;
|
|
2179
|
+
let l;
|
|
2180
|
+
const f = (L) => l = L, { store: h, selection: u } = e;
|
|
2181
|
+
let p, g, b;
|
|
2182
|
+
const w = (L) => {
|
|
2183
|
+
g !== !1 && (p = it(L.target) ? void 0 : {
|
|
2184
|
+
annotation: fe(),
|
|
2164
2185
|
selector: [],
|
|
2165
|
-
creator:
|
|
2186
|
+
creator: o,
|
|
2166
2187
|
created: /* @__PURE__ */ new Date()
|
|
2167
2188
|
});
|
|
2168
|
-
}, y =
|
|
2169
|
-
const
|
|
2170
|
-
if (
|
|
2171
|
-
|
|
2189
|
+
}, y = Yt((L) => {
|
|
2190
|
+
const m = document.getSelection();
|
|
2191
|
+
if (it(m.anchorNode)) {
|
|
2192
|
+
p = void 0;
|
|
2172
2193
|
return;
|
|
2173
2194
|
}
|
|
2174
|
-
const
|
|
2175
|
-
if ((
|
|
2176
|
-
if (
|
|
2177
|
-
|
|
2195
|
+
const v = L.timeStamp - ((b == null ? void 0 : b.timeStamp) || L.timeStamp);
|
|
2196
|
+
if ((b == null ? void 0 : b.type) === "pointerdown" && (v < 1e3 && !p || m.isCollapsed && v < ie) && w(b || L), !p) return;
|
|
2197
|
+
if (m.isCollapsed) {
|
|
2198
|
+
h.getAnnotation(p.annotation) && (u.clear(), h.deleteAnnotation(p.annotation));
|
|
2178
2199
|
return;
|
|
2179
2200
|
}
|
|
2180
|
-
const
|
|
2181
|
-
if (
|
|
2182
|
-
const
|
|
2183
|
-
(
|
|
2184
|
-
var
|
|
2185
|
-
return
|
|
2186
|
-
})) && (
|
|
2187
|
-
...
|
|
2188
|
-
selector:
|
|
2201
|
+
const x = m.getRangeAt(0), C = Ye(x, t);
|
|
2202
|
+
if (Ie(C)) return;
|
|
2203
|
+
const B = Be(C.cloneRange());
|
|
2204
|
+
(B.length !== p.selector.length || B.some((N, U) => {
|
|
2205
|
+
var et;
|
|
2206
|
+
return N.toString() !== ((et = p.selector[U]) == null ? void 0 : et.quote);
|
|
2207
|
+
})) && (p = {
|
|
2208
|
+
...p,
|
|
2209
|
+
selector: B.map((N) => Ve(N, t, s)),
|
|
2189
2210
|
updated: /* @__PURE__ */ new Date()
|
|
2190
|
-
},
|
|
2191
|
-
}),
|
|
2192
|
-
|
|
2193
|
-
},
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
if (p || nt(E.target) || !h) return;
|
|
2201
|
-
const R = () => {
|
|
2202
|
-
const { x: A, y: x } = t.getBoundingClientRect(), C = E.target instanceof Node && t.contains(E.target) && l.getAt(E.clientX - A, E.clientY - x, a);
|
|
2203
|
-
if (C) {
|
|
2204
|
-
const { selected: k } = f;
|
|
2205
|
-
(k.length !== 1 || k[0].id !== C.id) && f.userSelect(C.id, E);
|
|
2211
|
+
}, h.getAnnotation(p.annotation) ? h.updateTarget(p, k.LOCAL) : u.clear());
|
|
2212
|
+
}), d = (L) => {
|
|
2213
|
+
it(L.target) || (b = At(L), g = b.button === 0);
|
|
2214
|
+
}, c = (L) => {
|
|
2215
|
+
if (it(L.target) || !g) return;
|
|
2216
|
+
const m = () => {
|
|
2217
|
+
const { x, y: C } = t.getBoundingClientRect(), B = L.target instanceof Node && t.contains(L.target) && h.getAt(L.clientX - x, L.clientY - C, a === "all", l);
|
|
2218
|
+
if (B) {
|
|
2219
|
+
const { selected: R } = u, N = new Set(R.map((q) => q.id)), U = Array.isArray(B) ? B.map((q) => q.id) : [B.id];
|
|
2220
|
+
(N.size !== U.length || !U.every((q) => N.has(q))) && u.userSelect(U, L);
|
|
2206
2221
|
} else
|
|
2207
|
-
|
|
2208
|
-
},
|
|
2222
|
+
u.clear();
|
|
2223
|
+
}, v = L.timeStamp - b.timeStamp;
|
|
2209
2224
|
setTimeout(() => {
|
|
2210
|
-
const
|
|
2211
|
-
|
|
2225
|
+
const x = document.getSelection();
|
|
2226
|
+
x != null && x.isCollapsed && v < ie ? (p = void 0, m()) : p && p.selector.length > 0 && (u.clear(), O(), u.userSelect(p.annotation, At(L)));
|
|
2212
2227
|
});
|
|
2213
|
-
},
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
id: u.annotation,
|
|
2228
|
+
}, A = (L) => {
|
|
2229
|
+
const m = document.getSelection();
|
|
2230
|
+
m != null && m.isCollapsed || ((!p || p.selector.length === 0) && y(L), O(), u.userSelect(p.annotation, At(L)));
|
|
2231
|
+
}, E = (L) => {
|
|
2232
|
+
L.key === "Shift" && p && (document.getSelection().isCollapsed || (u.clear(), O(), u.userSelect(p.annotation, ft(L))));
|
|
2233
|
+
}, T = (L) => {
|
|
2234
|
+
const m = () => setTimeout(() => {
|
|
2235
|
+
(p == null ? void 0 : p.selector.length) > 0 && (u.clear(), h.addAnnotation({
|
|
2236
|
+
id: p.annotation,
|
|
2223
2237
|
bodies: [],
|
|
2224
|
-
target:
|
|
2225
|
-
}),
|
|
2238
|
+
target: p
|
|
2239
|
+
}), u.userSelect(p.annotation, ft(L))), document.removeEventListener("selectionchange", m);
|
|
2226
2240
|
}, 100);
|
|
2227
|
-
document.addEventListener("selectionchange",
|
|
2241
|
+
document.addEventListener("selectionchange", m), w(L);
|
|
2228
2242
|
};
|
|
2229
|
-
P(
|
|
2230
|
-
|
|
2231
|
-
}), P(
|
|
2232
|
-
|
|
2243
|
+
P(mo.join(","), { element: t, keydown: !0, keyup: !1 }, (L) => {
|
|
2244
|
+
L.repeat || (b = ft(L));
|
|
2245
|
+
}), P(Ee, { keydown: !0, keyup: !1 }, (L) => {
|
|
2246
|
+
b = ft(L), T(L);
|
|
2233
2247
|
});
|
|
2234
|
-
const
|
|
2235
|
-
|
|
2248
|
+
const S = (L) => {
|
|
2249
|
+
L.repeat || L.target !== t && L.target !== document.body || (p = void 0, u.clear());
|
|
2250
|
+
};
|
|
2251
|
+
P(ve.join(","), { keydown: !0, keyup: !1 }, S);
|
|
2252
|
+
const O = () => {
|
|
2253
|
+
const L = h.getAnnotation(p.annotation);
|
|
2254
|
+
if (!L) {
|
|
2255
|
+
h.addAnnotation({
|
|
2256
|
+
id: p.annotation,
|
|
2257
|
+
bodies: [],
|
|
2258
|
+
target: p
|
|
2259
|
+
});
|
|
2260
|
+
return;
|
|
2261
|
+
}
|
|
2262
|
+
const { target: { updated: m } } = L, { updated: v } = p;
|
|
2263
|
+
(!m || !v || m < v) && h.updateTarget(p);
|
|
2236
2264
|
};
|
|
2237
|
-
return
|
|
2265
|
+
return t.addEventListener("pointerdown", d), document.addEventListener("pointerup", c), document.addEventListener("contextmenu", A), i && (t.addEventListener("keyup", E), t.addEventListener("selectstart", w), document.addEventListener("selectionchange", y)), {
|
|
2238
2266
|
destroy: () => {
|
|
2239
|
-
t.removeEventListener("pointerdown",
|
|
2267
|
+
t.removeEventListener("pointerdown", d), document.removeEventListener("pointerup", c), document.removeEventListener("contextmenu", A), t.removeEventListener("keyup", E), t.removeEventListener("selectstart", w), document.removeEventListener("selectionchange", y), P.unbind();
|
|
2240
2268
|
},
|
|
2241
|
-
setFilter:
|
|
2242
|
-
setUser:
|
|
2269
|
+
setFilter: f,
|
|
2270
|
+
setUser: r
|
|
2243
2271
|
};
|
|
2244
|
-
},
|
|
2272
|
+
}, bo = (t, e) => ({
|
|
2245
2273
|
...t,
|
|
2246
2274
|
annotatingEnabled: t.annotatingEnabled ?? e.annotatingEnabled,
|
|
2247
2275
|
user: t.user || e.user
|
|
2248
|
-
}),
|
|
2249
|
-
|
|
2250
|
-
const n =
|
|
2276
|
+
}), se = "SPANS", xo = (t, e = {}) => {
|
|
2277
|
+
Le(t), Oe(t);
|
|
2278
|
+
const n = bo(e, {
|
|
2251
2279
|
annotatingEnabled: !0,
|
|
2252
|
-
user:
|
|
2253
|
-
}), o =
|
|
2280
|
+
user: Kn()
|
|
2281
|
+
}), o = eo(t, n.userSelectAction), { selection: i, viewport: s } = o, a = o.store, r = Mn(a), l = Rn(o, r, n.adapter);
|
|
2254
2282
|
let f = n.user;
|
|
2255
|
-
const
|
|
2256
|
-
if (!
|
|
2257
|
-
throw `Unknown renderer implementation: ${
|
|
2258
|
-
console.debug(`Using ${
|
|
2259
|
-
const
|
|
2260
|
-
return
|
|
2261
|
-
...
|
|
2283
|
+
const h = n.renderer === "CSS_HIGHLIGHTS" ? CSS.highlights ? "CSS_HIGHLIGHTS" : se : n.renderer || se, u = h === "SPANS" ? rn(t, o, s) : h === "CSS_HIGHLIGHTS" ? nn(t, o, s) : h === "CANVAS" ? ze(t, o, s) : void 0;
|
|
2284
|
+
if (!u)
|
|
2285
|
+
throw `Unknown renderer implementation: ${h}`;
|
|
2286
|
+
console.debug(`Using ${h} renderer`), n.style && u.setStyle(n.style);
|
|
2287
|
+
const p = yo(t, o, n);
|
|
2288
|
+
return p.setUser(f), {
|
|
2289
|
+
...In(o, r, n.adapter),
|
|
2262
2290
|
destroy: () => {
|
|
2263
|
-
|
|
2291
|
+
u.destroy(), p.destroy(), r.destroy();
|
|
2264
2292
|
},
|
|
2265
2293
|
element: t,
|
|
2266
2294
|
getUser: () => f,
|
|
2267
|
-
setFilter: (
|
|
2268
|
-
|
|
2295
|
+
setFilter: (S) => {
|
|
2296
|
+
u.setFilter(S), p.setFilter(S);
|
|
2269
2297
|
},
|
|
2270
|
-
setStyle: (
|
|
2271
|
-
setUser: (
|
|
2272
|
-
f =
|
|
2298
|
+
setStyle: (S) => u.setStyle(S),
|
|
2299
|
+
setUser: (S) => {
|
|
2300
|
+
f = S, p.setUser(S);
|
|
2273
2301
|
},
|
|
2274
|
-
setSelected: (
|
|
2275
|
-
|
|
2302
|
+
setSelected: (S) => {
|
|
2303
|
+
S ? i.setSelected(S) : i.clear();
|
|
2276
2304
|
},
|
|
2277
|
-
setPresenceProvider: (
|
|
2278
|
-
|
|
2305
|
+
setPresenceProvider: (S) => {
|
|
2306
|
+
S && (u.setPainter(oo(S, n.presence)), S.on("selectionChange", () => u.redraw()));
|
|
2279
2307
|
},
|
|
2280
|
-
setVisible: (
|
|
2308
|
+
setVisible: (S) => u.setVisible(S),
|
|
2281
2309
|
on: l.on,
|
|
2282
2310
|
off: l.off,
|
|
2283
|
-
scrollIntoView:
|
|
2311
|
+
scrollIntoView: Ke(t, a),
|
|
2284
2312
|
state: o
|
|
2285
2313
|
};
|
|
2286
2314
|
};
|
|
2287
2315
|
export {
|
|
2288
|
-
|
|
2316
|
+
wt as DEFAULT_SELECTED_STYLE,
|
|
2289
2317
|
W as DEFAULT_STYLE,
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2318
|
+
re as NOT_ANNOTATABLE_CLASS,
|
|
2319
|
+
tt as NOT_ANNOTATABLE_SELECTOR,
|
|
2320
|
+
k as Origin,
|
|
2321
|
+
yo as SelectionHandler,
|
|
2322
|
+
hn as UserSelectAction,
|
|
2295
2323
|
Ao as W3CTextFormat,
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2324
|
+
Le as cancelSingleClickEvents,
|
|
2325
|
+
ft as cloneKeyboardEvent,
|
|
2326
|
+
At as clonePointerEvent,
|
|
2327
|
+
wo as createBody,
|
|
2328
|
+
ze as createCanvasRenderer,
|
|
2329
|
+
nn as createHighlightsRenderer,
|
|
2330
|
+
oo as createPresencePainter,
|
|
2331
|
+
en as createRenderer,
|
|
2332
|
+
rn as createSpansRenderer,
|
|
2305
2333
|
xo as createTextAnnotator,
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2334
|
+
eo as createTextAnnotatorState,
|
|
2335
|
+
Yt as debounce,
|
|
2336
|
+
bo as fillDefaults,
|
|
2337
|
+
Re as getQuoteContext,
|
|
2338
|
+
Nt as getRangeAnnotatableContents,
|
|
2339
|
+
Te as isMac,
|
|
2340
|
+
it as isNotAnnotatable,
|
|
2341
|
+
Ce as isRangeAnnotatable,
|
|
2314
2342
|
F as isRevived,
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2343
|
+
Ie as isWhitespaceOrEmpty,
|
|
2344
|
+
Ue as mergeClientRects,
|
|
2345
|
+
De as paint,
|
|
2346
|
+
jn as parseW3CTextAnnotation,
|
|
2347
|
+
Oe as programmaticallyFocusable,
|
|
2348
|
+
Ve as rangeToSelector,
|
|
2349
|
+
xt as reviveAnnotation,
|
|
2350
|
+
ae as reviveSelector,
|
|
2351
|
+
bt as reviveTarget,
|
|
2352
|
+
Ke as scrollIntoView,
|
|
2353
|
+
zn as serializeW3CTextAnnotation,
|
|
2326
2354
|
Be as splitAnnotatableRanges,
|
|
2327
2355
|
Ye as trimRangeToContainer,
|
|
2328
|
-
|
|
2356
|
+
ke as whitespaceOrEmptyRegex
|
|
2329
2357
|
};
|
|
2330
2358
|
//# sourceMappingURL=text-annotator.es.js.map
|