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