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