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