@soomo/react-text-annotator 3.0.0-staging.8 → 3.0.0-staging.9
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/TextAnnotatorPopup.d.ts +5 -4
- package/dist/TextAnnotatorPopup.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/react-text-annotator.es10.js +565 -34
- package/dist/react-text-annotator.es10.js.map +1 -1
- package/dist/react-text-annotator.es11.js +460 -856
- package/dist/react-text-annotator.es11.js.map +1 -1
- package/dist/react-text-annotator.es12.js +2 -2
- package/dist/react-text-annotator.es13.js +35 -2
- package/dist/react-text-annotator.es13.js.map +1 -1
- package/dist/react-text-annotator.es14.js +894 -109
- package/dist/react-text-annotator.es14.js.map +1 -1
- package/dist/react-text-annotator.es15.js +208 -289
- package/dist/react-text-annotator.es15.js.map +1 -1
- package/dist/react-text-annotator.es16.js +127 -49
- package/dist/react-text-annotator.es16.js.map +1 -1
- package/dist/react-text-annotator.es17.js +113 -19
- package/dist/react-text-annotator.es17.js.map +1 -1
- package/dist/react-text-annotator.es18.js +312 -0
- package/dist/react-text-annotator.es18.js.map +1 -0
- package/dist/react-text-annotator.es19.js +61 -0
- package/dist/react-text-annotator.es19.js.map +1 -0
- package/dist/react-text-annotator.es2.js +1 -1
- package/dist/react-text-annotator.es20.js +23 -0
- package/dist/react-text-annotator.es20.js.map +1 -0
- package/dist/react-text-annotator.es21.js +5 -0
- package/dist/react-text-annotator.es21.js.map +1 -0
- package/dist/react-text-annotator.es22.js +5 -0
- package/dist/react-text-annotator.es22.js.map +1 -0
- package/dist/react-text-annotator.es23.js +124 -0
- package/dist/react-text-annotator.es23.js.map +1 -0
- package/dist/react-text-annotator.es24.js +555 -0
- package/dist/react-text-annotator.es24.js.map +1 -0
- package/dist/react-text-annotator.es5.js +60 -36
- package/dist/react-text-annotator.es5.js.map +1 -1
- package/dist/react-text-annotator.es6.js +3 -3
- package/dist/react-text-annotator.es8.js +24 -488
- package/dist/react-text-annotator.es8.js.map +1 -1
- package/dist/react-text-annotator.es9.js +196 -2
- package/dist/react-text-annotator.es9.js.map +1 -1
- package/dist/utils.d.ts +14 -0
- package/dist/utils.d.ts.map +1 -0
- package/package.json +4 -3
|
@@ -1,312 +1,231 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { computePosition } from "./react-text-annotator.es10.js";
|
|
2
|
+
import { autoPlacement, autoUpdate, inline, offset, platform, shift } from "./react-text-annotator.es10.js";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { useLayoutEffect, useEffect } from "react";
|
|
5
|
+
import * as ReactDOM from "react-dom";
|
|
6
|
+
var index = typeof document !== "undefined" ? useLayoutEffect : useEffect;
|
|
7
|
+
function deepEqual(a, b) {
|
|
8
|
+
if (a === b) {
|
|
9
|
+
return true;
|
|
10
10
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
result = n.cloneNode(true);
|
|
29
|
-
}
|
|
30
|
-
if (n.attributes) {
|
|
31
|
-
for (let att of Array.from(n.attributes)) {
|
|
32
|
-
if (att.name !== "data-processed") {
|
|
33
|
-
result.setAttribute(att.name, att.value);
|
|
11
|
+
if (typeof a !== typeof b) {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
if (typeof a === "function" && a.toString() === b.toString()) {
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
let length;
|
|
18
|
+
let i;
|
|
19
|
+
let keys;
|
|
20
|
+
if (a && b && typeof a === "object") {
|
|
21
|
+
if (Array.isArray(a)) {
|
|
22
|
+
length = a.length;
|
|
23
|
+
if (length !== b.length)
|
|
24
|
+
return false;
|
|
25
|
+
for (i = length; i-- !== 0; ) {
|
|
26
|
+
if (!deepEqual(a[i], b[i])) {
|
|
27
|
+
return false;
|
|
34
28
|
}
|
|
35
29
|
}
|
|
30
|
+
return true;
|
|
36
31
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
let child = result.appendChild(clone(childNode));
|
|
42
|
-
if (child.nodeType === 1 && child.hasAttribute("data-origid")) {
|
|
43
|
-
child.setAttribute("id", child.getAttribute("data-origid"));
|
|
44
|
-
child.removeAttribute("data-origid");
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
return result;
|
|
48
|
-
} else if (nd.hasAttribute("data-origname")) {
|
|
49
|
-
result.appendChild(clone(nd));
|
|
50
|
-
}
|
|
51
|
-
} else {
|
|
52
|
-
result.appendChild(nd.cloneNode());
|
|
53
|
-
}
|
|
32
|
+
keys = Object.keys(a);
|
|
33
|
+
length = keys.length;
|
|
34
|
+
if (length !== Object.keys(b).length) {
|
|
35
|
+
return false;
|
|
54
36
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
function first(urls) {
|
|
60
|
-
return urls.replace(/ .*$/, "");
|
|
61
|
-
}
|
|
62
|
-
function hideContent(elt, rewriteIds = true) {
|
|
63
|
-
const doc = elt.ownerDocument;
|
|
64
|
-
if (elt.childNodes.length > 0) {
|
|
65
|
-
let hidden = doc.createElement("cetei-original");
|
|
66
|
-
elt.appendChild(hidden);
|
|
67
|
-
hidden.setAttribute("hidden", "");
|
|
68
|
-
hidden.setAttribute("data-original", "");
|
|
69
|
-
for (let node of Array.from(elt.childNodes)) {
|
|
70
|
-
if (node !== hidden) {
|
|
71
|
-
if (node.nodeType === 1) {
|
|
72
|
-
node.setAttribute("data-processed", "");
|
|
73
|
-
for (let e of node.querySelectorAll("*")) {
|
|
74
|
-
e.setAttribute("data-processed", "");
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
hidden.appendChild(elt.removeChild(node));
|
|
37
|
+
for (i = length; i-- !== 0; ) {
|
|
38
|
+
if (!{}.hasOwnProperty.call(b, keys[i])) {
|
|
39
|
+
return false;
|
|
78
40
|
}
|
|
79
41
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
42
|
+
for (i = length; i-- !== 0; ) {
|
|
43
|
+
const key = keys[i];
|
|
44
|
+
if (key === "_owner" && a.$$typeof) {
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
if (!deepEqual(a[key], b[key])) {
|
|
48
|
+
return false;
|
|
86
49
|
}
|
|
87
50
|
}
|
|
51
|
+
return true;
|
|
88
52
|
}
|
|
53
|
+
return a !== a && b !== b;
|
|
89
54
|
}
|
|
90
|
-
function
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
function repeat(str, times) {
|
|
94
|
-
let result = "";
|
|
95
|
-
for (let i = 0; i < times; i++) {
|
|
96
|
-
result += str;
|
|
97
|
-
}
|
|
98
|
-
return result;
|
|
99
|
-
}
|
|
100
|
-
function resolveURI(uri) {
|
|
101
|
-
let prefixdef = this.prefixDefs[uri.substring(0, uri.indexOf(":"))];
|
|
102
|
-
return uri.replace(new RegExp(prefixdef["matchPattern"]), prefixdef["replacementPattern"]);
|
|
103
|
-
}
|
|
104
|
-
function getPrefixDef(prefix) {
|
|
105
|
-
return this.prefixDefs[prefix];
|
|
106
|
-
}
|
|
107
|
-
function rw(url) {
|
|
108
|
-
if (!url.match(/^(?:http|mailto|file|\/|#).*$/)) {
|
|
109
|
-
return this.base + first(url);
|
|
110
|
-
} else {
|
|
111
|
-
return url;
|
|
55
|
+
function getDPR(element) {
|
|
56
|
+
if (typeof window === "undefined") {
|
|
57
|
+
return 1;
|
|
112
58
|
}
|
|
59
|
+
const win = element.ownerDocument.defaultView || window;
|
|
60
|
+
return win.devicePixelRatio || 1;
|
|
113
61
|
}
|
|
114
|
-
function
|
|
115
|
-
|
|
62
|
+
function roundByDPR(element, value) {
|
|
63
|
+
const dpr = getDPR(element);
|
|
64
|
+
return Math.round(value * dpr) / dpr;
|
|
116
65
|
}
|
|
117
|
-
function
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
str += '<?xml version="1.0" encoding="UTF-8"?>\n';
|
|
124
|
-
}
|
|
125
|
-
if (!stripElt && el.nodeType == 1) {
|
|
126
|
-
if (typeof ws === "string" && ws !== "") {
|
|
127
|
-
str += "\n" + ws + "<";
|
|
128
|
-
} else {
|
|
129
|
-
str += "<";
|
|
130
|
-
}
|
|
131
|
-
str += el.getAttribute("data-origname");
|
|
132
|
-
let attrNames = el.hasAttribute("data-origatts") ? el.getAttribute("data-origatts").split(" ") : [];
|
|
133
|
-
for (let attr of Array.from(el.attributes)) {
|
|
134
|
-
if (!attr.name.startsWith("data-") && !["id", "lang", "class"].includes(attr.name)) {
|
|
135
|
-
str += " " + attrNames.find(function(e) {
|
|
136
|
-
return e.toLowerCase() == attr.name;
|
|
137
|
-
}) + '="' + attr.value + '"';
|
|
138
|
-
}
|
|
139
|
-
if (attr.name == "data-xmlns") {
|
|
140
|
-
str += ' xmlns="' + attr.value + '"';
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
if (el.childNodes.length > 0) {
|
|
144
|
-
str += ">";
|
|
145
|
-
} else {
|
|
146
|
-
str += "/>";
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
for (let node of Array.from(el.childNodes)) {
|
|
150
|
-
switch (node.nodeType) {
|
|
151
|
-
case 1:
|
|
152
|
-
if (typeof ws === "string") {
|
|
153
|
-
str += serialize(node, false, ws + " ");
|
|
154
|
-
} else {
|
|
155
|
-
str += serialize(node, false, ws);
|
|
156
|
-
}
|
|
157
|
-
break;
|
|
158
|
-
case 7:
|
|
159
|
-
str += `<?${node.nodeName} ${node.nodeValue}?>`;
|
|
160
|
-
if (el.nodeType === 9 || el.nodeType === 11) {
|
|
161
|
-
str += "\n";
|
|
162
|
-
}
|
|
163
|
-
break;
|
|
164
|
-
case 8:
|
|
165
|
-
str += `<!--${node.nodeValue}-->`;
|
|
166
|
-
if (el.nodeType === 9 || el.nodeType === 11) {
|
|
167
|
-
str += "\n";
|
|
168
|
-
}
|
|
169
|
-
break;
|
|
170
|
-
default:
|
|
171
|
-
if (stripElt && ignorable(node.nodeValue)) {
|
|
172
|
-
str += node.nodeValue.replace(/^\s*\n/, "");
|
|
173
|
-
}
|
|
174
|
-
if (typeof ws === "string" && ignorable(node.nodeValue)) {
|
|
175
|
-
break;
|
|
176
|
-
}
|
|
177
|
-
str += node.nodeValue;
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
if (!stripElt && el.nodeType == 1 && el.childNodes.length > 0) {
|
|
181
|
-
if (typeof ws === "string") {
|
|
182
|
-
str += "\n" + ws + "</";
|
|
183
|
-
} else {
|
|
184
|
-
str += "</";
|
|
185
|
-
}
|
|
186
|
-
str += el.getAttribute("data-origname") + ">";
|
|
187
|
-
}
|
|
188
|
-
if (el.nodeType === 9 || el.nodeType === 11) {
|
|
189
|
-
str += "\n";
|
|
190
|
-
}
|
|
191
|
-
return str;
|
|
66
|
+
function useLatestRef(value) {
|
|
67
|
+
const ref = React.useRef(value);
|
|
68
|
+
index(() => {
|
|
69
|
+
ref.current = value;
|
|
70
|
+
});
|
|
71
|
+
return ref;
|
|
192
72
|
}
|
|
193
|
-
function
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
const ignorable = (txt) => {
|
|
197
|
-
return !/[^\t\n\r ]/.test(txt);
|
|
198
|
-
};
|
|
199
|
-
if (!stripElt && el.nodeType == 1) {
|
|
200
|
-
if (typeof ws === "string" && ws !== "") {
|
|
201
|
-
str += "\n" + ws + "<";
|
|
202
|
-
} else {
|
|
203
|
-
str += "<";
|
|
204
|
-
}
|
|
205
|
-
str += el.nodeName;
|
|
206
|
-
for (let attr of Array.from(el.attributes)) {
|
|
207
|
-
str += " " + attr.name + '="' + attr.value + '"';
|
|
208
|
-
}
|
|
209
|
-
str += ">";
|
|
210
|
-
}
|
|
211
|
-
for (let node of Array.from(el.childNodes)) {
|
|
212
|
-
switch (node.nodeType) {
|
|
213
|
-
case 1:
|
|
214
|
-
if (typeof ws === "string") {
|
|
215
|
-
str += serializeHTML(node, false, ws + " ");
|
|
216
|
-
} else {
|
|
217
|
-
str += serializeHTML(node, false, ws);
|
|
218
|
-
}
|
|
219
|
-
break;
|
|
220
|
-
case 7:
|
|
221
|
-
str += `<?${node.nodeName} ${node.nodeValue}?>`;
|
|
222
|
-
if (el.nodeType === 9 || el.nodeType === 11) {
|
|
223
|
-
str += "\n";
|
|
224
|
-
}
|
|
225
|
-
break;
|
|
226
|
-
case 8:
|
|
227
|
-
str += `<!--${node.nodeValue}-->`;
|
|
228
|
-
if (el.nodeType === 9 || el.nodeType === 11) {
|
|
229
|
-
str += "\n";
|
|
230
|
-
}
|
|
231
|
-
break;
|
|
232
|
-
default:
|
|
233
|
-
if (stripElt && ignorable(node.nodeValue)) {
|
|
234
|
-
str += node.nodeValue.replace(/^\s*\n/, "");
|
|
235
|
-
}
|
|
236
|
-
if (typeof ws === "string" && ignorable(node.nodeValue)) {
|
|
237
|
-
break;
|
|
238
|
-
}
|
|
239
|
-
str += node.nodeValue.replace(/</g, "<");
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
if (!EMPTY_ELEMENTS.includes(el.nodeName)) {
|
|
243
|
-
if (!stripElt && el.nodeType == 1) {
|
|
244
|
-
if (typeof ws === "string") {
|
|
245
|
-
str += `
|
|
246
|
-
${ws}</`;
|
|
247
|
-
} else {
|
|
248
|
-
str += "</";
|
|
249
|
-
}
|
|
250
|
-
str += `${el.nodeName}>`;
|
|
251
|
-
}
|
|
73
|
+
function useFloating(options) {
|
|
74
|
+
if (options === void 0) {
|
|
75
|
+
options = {};
|
|
252
76
|
}
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
77
|
+
const {
|
|
78
|
+
placement = "bottom",
|
|
79
|
+
strategy = "absolute",
|
|
80
|
+
middleware = [],
|
|
81
|
+
platform: platform2,
|
|
82
|
+
elements: {
|
|
83
|
+
reference: externalReference,
|
|
84
|
+
floating: externalFloating
|
|
85
|
+
} = {},
|
|
86
|
+
transform = true,
|
|
87
|
+
whileElementsMounted,
|
|
88
|
+
open
|
|
89
|
+
} = options;
|
|
90
|
+
const [data, setData] = React.useState({
|
|
91
|
+
x: 0,
|
|
92
|
+
y: 0,
|
|
93
|
+
strategy,
|
|
94
|
+
placement,
|
|
95
|
+
middlewareData: {},
|
|
96
|
+
isPositioned: false
|
|
97
|
+
});
|
|
98
|
+
const [latestMiddleware, setLatestMiddleware] = React.useState(middleware);
|
|
99
|
+
if (!deepEqual(latestMiddleware, middleware)) {
|
|
100
|
+
setLatestMiddleware(middleware);
|
|
264
101
|
}
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
102
|
+
const [_reference, _setReference] = React.useState(null);
|
|
103
|
+
const [_floating, _setFloating] = React.useState(null);
|
|
104
|
+
const setReference = React.useCallback((node) => {
|
|
105
|
+
if (node !== referenceRef.current) {
|
|
106
|
+
referenceRef.current = node;
|
|
107
|
+
_setReference(node);
|
|
108
|
+
}
|
|
109
|
+
}, []);
|
|
110
|
+
const setFloating = React.useCallback((node) => {
|
|
111
|
+
if (node !== floatingRef.current) {
|
|
112
|
+
floatingRef.current = node;
|
|
113
|
+
_setFloating(node);
|
|
114
|
+
}
|
|
115
|
+
}, []);
|
|
116
|
+
const referenceEl = externalReference || _reference;
|
|
117
|
+
const floatingEl = externalFloating || _floating;
|
|
118
|
+
const referenceRef = React.useRef(null);
|
|
119
|
+
const floatingRef = React.useRef(null);
|
|
120
|
+
const dataRef = React.useRef(data);
|
|
121
|
+
const hasWhileElementsMounted = whileElementsMounted != null;
|
|
122
|
+
const whileElementsMountedRef = useLatestRef(whileElementsMounted);
|
|
123
|
+
const platformRef = useLatestRef(platform2);
|
|
124
|
+
const update = React.useCallback(() => {
|
|
125
|
+
if (!referenceRef.current || !floatingRef.current) {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
const config = {
|
|
129
|
+
placement,
|
|
130
|
+
strategy,
|
|
131
|
+
middleware: latestMiddleware
|
|
132
|
+
};
|
|
133
|
+
if (platformRef.current) {
|
|
134
|
+
config.platform = platformRef.current;
|
|
135
|
+
}
|
|
136
|
+
computePosition(referenceRef.current, floatingRef.current, config).then((data2) => {
|
|
137
|
+
const fullData = {
|
|
138
|
+
...data2,
|
|
139
|
+
isPositioned: true
|
|
140
|
+
};
|
|
141
|
+
if (isMountedRef.current && !deepEqual(dataRef.current, fullData)) {
|
|
142
|
+
dataRef.current = fullData;
|
|
143
|
+
ReactDOM.flushSync(() => {
|
|
144
|
+
setData(fullData);
|
|
145
|
+
});
|
|
286
146
|
}
|
|
287
147
|
});
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
148
|
+
}, [latestMiddleware, placement, strategy, platformRef]);
|
|
149
|
+
index(() => {
|
|
150
|
+
if (open === false && dataRef.current.isPositioned) {
|
|
151
|
+
dataRef.current.isPositioned = false;
|
|
152
|
+
setData((data2) => ({
|
|
153
|
+
...data2,
|
|
154
|
+
isPositioned: false
|
|
155
|
+
}));
|
|
156
|
+
}
|
|
157
|
+
}, [open]);
|
|
158
|
+
const isMountedRef = React.useRef(false);
|
|
159
|
+
index(() => {
|
|
160
|
+
isMountedRef.current = true;
|
|
161
|
+
return () => {
|
|
162
|
+
isMountedRef.current = false;
|
|
163
|
+
};
|
|
164
|
+
}, []);
|
|
165
|
+
index(() => {
|
|
166
|
+
if (referenceEl)
|
|
167
|
+
referenceRef.current = referenceEl;
|
|
168
|
+
if (floatingEl)
|
|
169
|
+
floatingRef.current = floatingEl;
|
|
170
|
+
if (referenceEl && floatingEl) {
|
|
171
|
+
if (whileElementsMountedRef.current) {
|
|
172
|
+
return whileElementsMountedRef.current(referenceEl, floatingEl, update);
|
|
173
|
+
}
|
|
174
|
+
update();
|
|
175
|
+
}
|
|
176
|
+
}, [referenceEl, floatingEl, update, whileElementsMountedRef, hasWhileElementsMounted]);
|
|
177
|
+
const refs = React.useMemo(() => ({
|
|
178
|
+
reference: referenceRef,
|
|
179
|
+
floating: floatingRef,
|
|
180
|
+
setReference,
|
|
181
|
+
setFloating
|
|
182
|
+
}), [setReference, setFloating]);
|
|
183
|
+
const elements = React.useMemo(() => ({
|
|
184
|
+
reference: referenceEl,
|
|
185
|
+
floating: floatingEl
|
|
186
|
+
}), [referenceEl, floatingEl]);
|
|
187
|
+
const floatingStyles = React.useMemo(() => {
|
|
188
|
+
const initialStyles = {
|
|
189
|
+
position: strategy,
|
|
190
|
+
left: 0,
|
|
191
|
+
top: 0
|
|
192
|
+
};
|
|
193
|
+
if (!elements.floating) {
|
|
194
|
+
return initialStyles;
|
|
195
|
+
}
|
|
196
|
+
const x = roundByDPR(elements.floating, data.x);
|
|
197
|
+
const y = roundByDPR(elements.floating, data.y);
|
|
198
|
+
if (transform) {
|
|
199
|
+
return {
|
|
200
|
+
...initialStyles,
|
|
201
|
+
transform: "translate(" + x + "px, " + y + "px)",
|
|
202
|
+
...getDPR(elements.floating) >= 1.5 && {
|
|
203
|
+
willChange: "transform"
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
return {
|
|
208
|
+
position: strategy,
|
|
209
|
+
left: x,
|
|
210
|
+
top: y
|
|
211
|
+
};
|
|
212
|
+
}, [strategy, transform, elements.floating, data.x, data.y]);
|
|
213
|
+
return React.useMemo(() => ({
|
|
214
|
+
...data,
|
|
215
|
+
update,
|
|
216
|
+
refs,
|
|
217
|
+
elements,
|
|
218
|
+
floatingStyles
|
|
219
|
+
}), [data, update, refs, elements, floatingStyles]);
|
|
294
220
|
}
|
|
295
221
|
export {
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
resetAndSerialize,
|
|
305
|
-
resolveURI,
|
|
306
|
-
rw,
|
|
307
|
-
serialize,
|
|
308
|
-
serializeHTML,
|
|
309
|
-
tagName,
|
|
310
|
-
unEscapeEntities
|
|
222
|
+
autoPlacement,
|
|
223
|
+
autoUpdate,
|
|
224
|
+
computePosition,
|
|
225
|
+
inline,
|
|
226
|
+
offset,
|
|
227
|
+
platform,
|
|
228
|
+
shift,
|
|
229
|
+
useFloating
|
|
311
230
|
};
|
|
312
231
|
//# sourceMappingURL=react-text-annotator.es15.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react-text-annotator.es15.js","sources":["../../../node_modules/CETEIcean/src/utilities.js"],"sourcesContent":["export function getOrdinality(elt, name) {\n let pos = 1;\n let e = elt;\n while (e && e.previousElementSibling !== null && (name ? e.previousElementSibling.localName == name : true)) {\n pos++;\n e = e.previousElementSibling;\n if (!e.previousElementSibling) {\n break;\n }\n }\n return pos;\n}\n\n/* \n Performs a deep copy operation of the input node while stripping\n out child elements introduced by CETEIcean.\n*/ \nexport function copyAndReset(node) {\n const doc = node.ownerDocument;\n let clone = (n) => { \n let result;\n switch (n.nodeType) {\n case 1: // nodeType 1 is Node.ELEMENT_NODE\n result = doc.createElement(n.nodeName);\n break;\n case 9: // nodeType 9 is Node.DOCUMENT_NODE\n result = doc.implementation.createDocument();\n break;\n case 11: // nodeType 11 is Node.DOCUMENT_FRAGMENT_NODE\n result = doc.createDocumentFragment();\n break;\n default:\n result = n.cloneNode(true);\n }\n if (n.attributes) {\n for (let att of Array.from(n.attributes)) {\n if (att.name !== \"data-processed\") {\n result.setAttribute(att.name,att.value);\n }\n }\n }\n for (let nd of Array.from(n.childNodes)){\n // nodeType 1 is Node.ELEMENT_NODE\n if (nd.nodeType == 1) {\n if (nd.hasAttribute(\"data-original\")) {\n for (let childNode of Array.from(nd.childNodes)) {\n let child = result.appendChild(clone(childNode));\n // nodeType 1 is Node.ELEMENT_NODE\n if (child.nodeType === 1 && child.hasAttribute(\"data-origid\")) {\n child.setAttribute(\"id\", child.getAttribute(\"data-origid\"));\n child.removeAttribute(\"data-origid\");\n }\n }\n return result;\n } else if (nd.hasAttribute(\"data-origname\")) {\n result.appendChild(clone(nd));\n }\n } else {\n result.appendChild(nd.cloneNode());\n }\n }\n return result;\n }\n return clone(node);\n}\n\n/* \n Given a space-separated list of URLs (e.g. in a ref with multiple\n targets), returns just the first one.\n*/\nexport function first(urls) {\n return urls.replace(/ .*$/, \"\");\n}\n\n/* \n Wraps the content of the element parameter in a hidden <cetei-original data-original>\n*/\nexport function hideContent(elt, rewriteIds = true) {\n const doc = elt.ownerDocument;\n if (elt.childNodes.length > 0) {\n let hidden = doc.createElement(\"cetei-original\");\n elt.appendChild(hidden);\n hidden.setAttribute(\"hidden\", \"\");\n hidden.setAttribute(\"data-original\", \"\");\n for (let node of Array.from(elt.childNodes)) {\n if (node !== hidden) {\n // nodeType 1 is Node.ELEMENT_NODE\n if (node.nodeType === 1) {\n node.setAttribute(\"data-processed\", \"\");\n for (let e of node.querySelectorAll(\"*\")) {\n e.setAttribute(\"data-processed\", \"\");\n }\n }\n hidden.appendChild(elt.removeChild(node));\n }\n }\n if (rewriteIds) {\n for (let e of Array.from(hidden.querySelectorAll(\"*\"))) {\n if (e.hasAttribute(\"id\")) {\n e.setAttribute(\"data-origid\", e.getAttribute(\"id\"));\n e.removeAttribute(\"id\");\n }\n }\n }\n }\n}\n\nexport function normalizeURI(urls) {\n return this.rw(this.first(urls))\n}\n\n/* \n Takes a string and a number and returns the original string\n printed that number of times.\n*/\nexport function repeat(str, times) {\n let result = \"\";\n for (let i = 0; i < times; i++) {\n result += str;\n }\n return result;\n}\n\n/* \n Resolves URIs that use TEI prefixDefs into full URIs.\n See https://www.tei-c.org/release/doc/tei-p5-doc/en/html/ref-prefixDef.html\n*/\nexport function resolveURI(uri) {\n let prefixdef = this.prefixDefs[uri.substring(0,uri.indexOf(\":\"))];\n return uri.replace(new RegExp(prefixdef[\"matchPattern\"]), prefixdef[\"replacementPattern\"]);\n}\n\n/*\n Convenience function for getting prefix definitions, Takes a prefix\n and returns an object with \"matchPattern\" and \"replacementPattern\"\n keys.\n*/\nexport function getPrefixDef(prefix) {\n return this.prefixDefs[prefix];\n}\n\n/* \n Takes a relative URL and rewrites it based on the base URL of the\n HTML document\n*/\nexport function rw(url) {\n if (!url.match(/^(?:http|mailto|file|\\/|#).*$/)) {\n return this.base + first(url);\n } else {\n return url;\n }\n}\n\n/*\n Combines the functionality of copyAndReset() and serialize() to return\n a \"clean\" version of the XML markup.\n */\nexport function resetAndSerialize(el, stripElt, ws) {\n return serialize(copyAndReset(el), stripElt, ws);\n}\n\n/* \n Takes an element and serializes it to an XML string or, if the stripElt\n parameter is set, serializes the element's content. The ws parameter, if\n set, will switch on minimal \"pretty-printing\" and indenting of the serialized\n result.\n*/\nexport function serialize(el, stripElt, ws) {\n let str = \"\";\n const ignorable = (txt) => {\n return !(/[^\\t\\n\\r ]/.test(txt));\n }\n if (el.nodeType === 9 || el.nodeType === 11) { // nodeType 9 is Node.DOCUMENT_NODE; nodeType 11 is Node.DOCUMENT_FRAGMENT_NODE\n str += \"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?>\\n\";\n }\n // nodeType 1 is Node.ELEMENT_NODE\n if (!stripElt && el.nodeType == 1) {\n if ((typeof ws === \"string\") && ws !== \"\") {\n str += \"\\n\" + ws + \"<\";\n } else {\n str += \"<\";\n }\n str += el.getAttribute(\"data-origname\");\n // HTML5 lowercases all attribute names; @data-origatts contains the original names\n let attrNames = el.hasAttribute(\"data-origatts\") ? el.getAttribute(\"data-origatts\").split(\" \") : [];\n for (let attr of Array.from(el.attributes)) {\n if (!attr.name.startsWith(\"data-\") && !([\"id\", \"lang\", \"class\"].includes(attr.name))) {\n str += \" \" + attrNames.find(function(e) {return e.toLowerCase() == attr.name}) + \"=\\\"\" + attr.value + \"\\\"\";\n }\n if (attr.name == \"data-xmlns\") {\n str += \" xmlns=\\\"\" + attr.value +\"\\\"\";\n }\n }\n if (el.childNodes.length > 0) {\n str += \">\";\n } else {\n str += \"/>\";\n }\n }\n for (let node of Array.from(el.childNodes)) {\n // nodeType 1 is Node.ELEMENT_NODE\n // nodeType 7 is Node.PROCESSING_INSTRUCTION_NODE\n // nodeType 8 is Node.COMMENT_NODE\n switch (node.nodeType) {\n case 1:\n if (typeof ws === \"string\") {\n str += serialize(node, false, ws + \" \");\n } else {\n str += serialize(node, false, ws);\n }\n break;\n case 7:\n str += `<?${node.nodeName} ${node.nodeValue}?>`;\n if (el.nodeType === 9 || el.nodeType === 11) {\n str += \"\\n\";\n }\n break;\n case 8:\n str += `<!--${node.nodeValue}-->`;\n if (el.nodeType === 9 || el.nodeType === 11) {\n str += \"\\n\";\n }\n break;\n default:\n if (stripElt && ignorable(node.nodeValue)) {\n str += node.nodeValue.replace(/^\\s*\\n/, \"\");\n }\n if ((typeof ws === \"string\") && ignorable(node.nodeValue)) {\n break;\n }\n str += node.nodeValue;\n }\n }\n if (!stripElt && el.nodeType == 1 && el.childNodes.length > 0) {\n if (typeof ws === \"string\") {\n str += \"\\n\" + ws + \"</\";\n } else {\n str += \"</\";\n }\n str += el.getAttribute(\"data-origname\") + \">\";\n }\n if (el.nodeType === 9 || el.nodeType === 11) {\n str += \"\\n\";\n }\n return str;\n}\n\n/* \n Write out the HTML markup to a string, using HTML conventions.\n */\nexport function serializeHTML(el, stripElt, ws) {\n const EMPTY_ELEMENTS = ['area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'link', 'meta', 'param', 'source', 'track', 'wbr'];\n let str = \"\";\n const ignorable = (txt) => {\n return !(/[^\\t\\n\\r ]/.test(txt));\n }\n // nodeType 1 is Node.ELEMENT_NODE\n if (!stripElt && el.nodeType == 1) {\n if ((typeof ws === \"string\") && ws !== \"\") {\n str += \"\\n\" + ws + \"<\";\n } else {\n str += \"<\";\n }\n str += el.nodeName;\n for (let attr of Array.from(el.attributes)) {\n str += \" \" + attr.name + \"=\\\"\" + attr.value + \"\\\"\";\n }\n str += \">\";\n }\n for (let node of Array.from(el.childNodes)) {\n // nodeType 1 is Node.ELEMENT_NODE\n // nodeType 7 is Node.PROCESSING_INSTRUCTION_NODE\n // nodeType 8 is Node.COMMENT_NODE\n switch (node.nodeType) {\n case 1:\n if (typeof ws === \"string\") {\n str += serializeHTML(node, false, ws + \" \");\n } else {\n str += serializeHTML(node, false, ws);\n }\n break;\n case 7:\n str += `<?${node.nodeName} ${node.nodeValue}?>`;\n if (el.nodeType === 9 || el.nodeType === 11) {\n str += \"\\n\";\n }\n break;\n case 8:\n str += `<!--${node.nodeValue}-->`;\n if (el.nodeType === 9 || el.nodeType === 11) {\n str += \"\\n\";\n }\n break;\n default:\n if (stripElt && ignorable(node.nodeValue)) {\n str += node.nodeValue.replace(/^\\s*\\n/, \"\");\n }\n if ((typeof ws === \"string\") && ignorable(node.nodeValue)) {\n break;\n }\n str += node.nodeValue.replace(/</g, \"<\");\n }\n }\n if (!EMPTY_ELEMENTS.includes(el.nodeName)) {\n if (!stripElt && el.nodeType == 1) {\n if (typeof ws === \"string\") {\n str += `\\n${ws}</`;\n } else {\n str += \"</\";\n }\n str += `${el.nodeName}>`;\n }\n }\n if (el.nodeType === 9 || el.nodeType === 11) {\n str += \"\\n\";\n }\n return str;\n}\n\nexport function unEscapeEntities(str) {\n return str.replace(/>/, \">\")\n .replace(/"/, \"\\\"\")\n .replace(/'/, \"'\")\n .replace(/&/, \"&\");\n}\n\n// Given a qualified name (e.g. tei:text), return the element name\nexport function tagName(name) {\n if (name.includes(\":\"), 1) {\n return name.replace(/:/,\"-\").toLowerCase();\n } else {\n return \"ceteicean-\" + name.toLowerCase();\n }\n}\n\nexport function defineCustomElement(name, behavior = null, debug = false) {\n /* \n Registers the list of elements provided with the browser.\n Called by makeHTML5(), but can be called independently if, for example,\n you've created Custom Elements via an XSLT transformation instead.\n */\n try {\n window.customElements.define(tagName(name), class extends HTMLElement {\n constructor() {\n super(); \n if (!this.matches(\":defined\")) { // \"Upgraded\" undefined elements can have attributes & children; new elements can't\n if (behavior) {\n behavior.call(this);\n // We don't want to double-process elements, so add a flag\n this.setAttribute(\"data-processed\", \"\");\n }\n }\n }\n // Process new elements when they are connected to the browser DOM\n connectedCallback() {\n if (!this.hasAttribute(\"data-processed\")) {\n if (behavior) {\n behavior.call(this);\n this.setAttribute(\"data-processed\", \"\");\n }\n }\n };\n });\n } catch (error) {\n // When using the same CETEIcean instance for multiple TEI files, this error becomes very common. \n // It's muted by default unless the debug option is set.\n if (debug) {\n console.log(tagName(name) + \" couldn't be registered or is already registered.\");\n console.log(error);\n }\n }\n}\n"],"names":[],"mappings":"AAAO,SAAS,cAAc,KAAK,MAAM;AACvC,MAAI,MAAM;AACV,MAAI,IAAI;AACR,SAAO,KAAK,EAAE,2BAA2B,SAAS,OAAO,EAAE,uBAAuB,aAAa,OAAO,OAAO;AAC3G;AACA,QAAI,EAAE;AACN,QAAI,CAAC,EAAE,wBAAwB;AAC7B;AAAA,IACD;AAAA,EACF;AACD,SAAO;AACT;AAMO,SAAS,aAAa,MAAM;AACjC,QAAM,MAAM,KAAK;AACjB,MAAI,QAAQ,CAAC,MAAM;AACjB,QAAI;AACJ,YAAQ,EAAE,UAAQ;AAAA,MAChB,KAAK;AACH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AQ,QAAQ,GAAG,EACnB,QAAQ,UAAU,GAAI,EACtB,QAAQ,UAAU,GAAG,EACrB,QAAQ,SAAS,GAAG;AACjC;AAGO,SAAS,QAAQ,MAAM;AAC5B,MAAI,KAAK,SAAS,GAAG,GAAG,GAAG;AACzB,WAAO,KAAK,QAAQ,KAAI,GAAG,EAAE,YAAW;AAAA,EAGzC;AACH;AAEO,SAAS,oBAAoB,MAAM,WAAW,MAAM,QAAQ,OAAO;AAMxE,MAAI;AACF,WAAO,eAAe,OAAO,QAAQ,IAAI,GAAG,cAAc,YAAY;AAAA,MACpE,cAAc;AACZ;AACA,YAAI,CAAC,KAAK,QAAQ,UAAU,GAAG;AAC7B,cAAI,UAAU;AACZ,qBAAS,KAAK,IAAI;AAElB,iBAAK,aAAa,kBAAkB,EAAE;AAAA,UACvC;AAAA,QACF;AAAA,MACF;AAAA;AAAA,MAED,oBAAoB;AAClB,YAAI,CAAC,KAAK,aAAa,gBAAgB,GAAG;AACxC,cAAI,UAAU;AACZ,qBAAS,KAAK,IAAI;AAClB,iBAAK,aAAa,kBAAkB,EAAE;AAAA,UACvC;AAAA,QACF;AAAA,MACF;AAAA,IACP,CAAK;AAAA,EACF,SAAQ,OAAO;AAGd,QAAI,OAAO;AACP,cAAQ,IAAI,QAAQ,IAAI,IAAI,mDAAmD;AAC/E,cAAQ,IAAI,KAAK;AAAA,IACpB;AAAA,EACF;AACH;","x_google_ignoreList":[0]}
|
|
1
|
+
{"version":3,"file":"react-text-annotator.es15.js","sources":["../../../node_modules/@floating-ui/react-dom/dist/floating-ui.react-dom.mjs"],"sourcesContent":["import { arrow as arrow$1, computePosition } from '@floating-ui/dom';\nexport { autoPlacement, autoUpdate, computePosition, detectOverflow, flip, getOverflowAncestors, hide, inline, limitShift, offset, platform, shift, size } from '@floating-ui/dom';\nimport * as React from 'react';\nimport { useLayoutEffect, useEffect } from 'react';\nimport * as ReactDOM from 'react-dom';\n\n/**\n * Provides data to position an inner element of the floating element so that it\n * appears centered to the reference element.\n * This wraps the core `arrow` middleware to allow React refs as the element.\n * @see https://floating-ui.com/docs/arrow\n */\nconst arrow = options => {\n function isRef(value) {\n return {}.hasOwnProperty.call(value, 'current');\n }\n return {\n name: 'arrow',\n options,\n fn(state) {\n const {\n element,\n padding\n } = typeof options === 'function' ? options(state) : options;\n if (element && isRef(element)) {\n if (element.current != null) {\n return arrow$1({\n element: element.current,\n padding\n }).fn(state);\n }\n return {};\n }\n if (element) {\n return arrow$1({\n element,\n padding\n }).fn(state);\n }\n return {};\n }\n };\n};\n\nvar index = typeof document !== 'undefined' ? useLayoutEffect : useEffect;\n\n// Fork of `fast-deep-equal` that only does the comparisons we need and compares\n// functions\nfunction deepEqual(a, b) {\n if (a === b) {\n return true;\n }\n if (typeof a !== typeof b) {\n return false;\n }\n if (typeof a === 'function' && a.toString() === b.toString()) {\n return true;\n }\n let length;\n let i;\n let keys;\n if (a && b && typeof a === 'object') {\n if (Array.isArray(a)) {\n length = a.length;\n if (length !== b.length) return false;\n for (i = length; i-- !== 0;) {\n if (!deepEqual(a[i], b[i])) {\n return false;\n }\n }\n return true;\n }\n keys = Object.keys(a);\n length = keys.length;\n if (length !== Object.keys(b).length) {\n return false;\n }\n for (i = length; i-- !== 0;) {\n if (!{}.hasOwnProperty.call(b, keys[i])) {\n return false;\n }\n }\n for (i = length; i-- !== 0;) {\n const key = keys[i];\n if (key === '_owner' && a.$$typeof) {\n continue;\n }\n if (!deepEqual(a[key], b[key])) {\n return false;\n }\n }\n return true;\n }\n return a !== a && b !== b;\n}\n\nfunction getDPR(element) {\n if (typeof window === 'undefined') {\n return 1;\n }\n const win = element.ownerDocument.defaultView || window;\n return win.devicePixelRatio || 1;\n}\n\nfunction roundByDPR(element, value) {\n const dpr = getDPR(element);\n return Math.round(value * dpr) / dpr;\n}\n\nfunction useLatestRef(value) {\n const ref = React.useRef(value);\n index(() => {\n ref.current = value;\n });\n return ref;\n}\n\n/**\n * Provides data to position a floating element.\n * @see https://floating-ui.com/docs/useFloating\n */\nfunction useFloating(options) {\n if (options === void 0) {\n options = {};\n }\n const {\n placement = 'bottom',\n strategy = 'absolute',\n middleware = [],\n platform,\n elements: {\n reference: externalReference,\n floating: externalFloating\n } = {},\n transform = true,\n whileElementsMounted,\n open\n } = options;\n const [data, setData] = React.useState({\n x: 0,\n y: 0,\n strategy,\n placement,\n middlewareData: {},\n isPositioned: false\n });\n const [latestMiddleware, setLatestMiddleware] = React.useState(middleware);\n if (!deepEqual(latestMiddleware, middleware)) {\n setLatestMiddleware(middleware);\n }\n const [_reference, _setReference] = React.useState(null);\n const [_floating, _setFloating] = React.useState(null);\n const setReference = React.useCallback(node => {\n if (node !== referenceRef.current) {\n referenceRef.current = node;\n _setReference(node);\n }\n }, []);\n const setFloating = React.useCallback(node => {\n if (node !== floatingRef.current) {\n floatingRef.current = node;\n _setFloating(node);\n }\n }, []);\n const referenceEl = externalReference || _reference;\n const floatingEl = externalFloating || _floating;\n const referenceRef = React.useRef(null);\n const floatingRef = React.useRef(null);\n const dataRef = React.useRef(data);\n const hasWhileElementsMounted = whileElementsMounted != null;\n const whileElementsMountedRef = useLatestRef(whileElementsMounted);\n const platformRef = useLatestRef(platform);\n const update = React.useCallback(() => {\n if (!referenceRef.current || !floatingRef.current) {\n return;\n }\n const config = {\n placement,\n strategy,\n middleware: latestMiddleware\n };\n if (platformRef.current) {\n config.platform = platformRef.current;\n }\n computePosition(referenceRef.current, floatingRef.current, config).then(data => {\n const fullData = {\n ...data,\n isPositioned: true\n };\n if (isMountedRef.current && !deepEqual(dataRef.current, fullData)) {\n dataRef.current = fullData;\n ReactDOM.flushSync(() => {\n setData(fullData);\n });\n }\n });\n }, [latestMiddleware, placement, strategy, platformRef]);\n index(() => {\n if (open === false && dataRef.current.isPositioned) {\n dataRef.current.isPositioned = false;\n setData(data => ({\n ...data,\n isPositioned: false\n }));\n }\n }, [open]);\n const isMountedRef = React.useRef(false);\n index(() => {\n isMountedRef.current = true;\n return () => {\n isMountedRef.current = false;\n };\n }, []);\n index(() => {\n if (referenceEl) referenceRef.current = referenceEl;\n if (floatingEl) floatingRef.current = floatingEl;\n if (referenceEl && floatingEl) {\n if (whileElementsMountedRef.current) {\n return whileElementsMountedRef.current(referenceEl, floatingEl, update);\n }\n update();\n }\n }, [referenceEl, floatingEl, update, whileElementsMountedRef, hasWhileElementsMounted]);\n const refs = React.useMemo(() => ({\n reference: referenceRef,\n floating: floatingRef,\n setReference,\n setFloating\n }), [setReference, setFloating]);\n const elements = React.useMemo(() => ({\n reference: referenceEl,\n floating: floatingEl\n }), [referenceEl, floatingEl]);\n const floatingStyles = React.useMemo(() => {\n const initialStyles = {\n position: strategy,\n left: 0,\n top: 0\n };\n if (!elements.floating) {\n return initialStyles;\n }\n const x = roundByDPR(elements.floating, data.x);\n const y = roundByDPR(elements.floating, data.y);\n if (transform) {\n return {\n ...initialStyles,\n transform: \"translate(\" + x + \"px, \" + y + \"px)\",\n ...(getDPR(elements.floating) >= 1.5 && {\n willChange: 'transform'\n })\n };\n }\n return {\n position: strategy,\n left: x,\n top: y\n };\n }, [strategy, transform, elements.floating, data.x, data.y]);\n return React.useMemo(() => ({\n ...data,\n update,\n refs,\n elements,\n floatingStyles\n }), [data, update, refs, elements, floatingStyles]);\n}\n\nexport { arrow, useFloating };\n"],"names":["platform","data"],"mappings":";;;;;AA4CA,IAAI,QAAQ,OAAO,aAAa,cAAc,kBAAkB;AAIhE,SAAS,UAAU,GAAG,GAAG;AACvB,MAAI,MAAM,GAAG;AACX,WAAO;AAAA,EACR;AACD,MAAI,OAAO,MAAM,OAAO,GAAG;AACzB,WAAO;AAAA,EACR;AACD,MAAI,OAAO,MAAM,cAAc,EAAE,eAAe,EAAE,YAAY;AAC5D,WAAO;AAAA,EACR;AACD,MAAI;AACJ,MAAI;AACJ,MAAI;AACJ,MAAI,KAAK,KAAK,OAAO,MAAM,UAAU;AACnC,QAAI,MAAM,QAAQ,CAAC,GAAG;AACpB,eAAS,EAAE;AACX,UAAI,WAAW,EAAE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