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