@soomo/react-text-annotator 3.0.0-staging.7 → 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.
Files changed (45) hide show
  1. package/dist/TextAnnotatorPopup.d.ts +5 -4
  2. package/dist/TextAnnotatorPopup.d.ts.map +1 -1
  3. package/dist/index.d.ts +1 -1
  4. package/dist/index.d.ts.map +1 -1
  5. package/dist/react-text-annotator.es10.js +565 -34
  6. package/dist/react-text-annotator.es10.js.map +1 -1
  7. package/dist/react-text-annotator.es11.js +460 -856
  8. package/dist/react-text-annotator.es11.js.map +1 -1
  9. package/dist/react-text-annotator.es12.js +2 -2
  10. package/dist/react-text-annotator.es13.js +35 -2
  11. package/dist/react-text-annotator.es13.js.map +1 -1
  12. package/dist/react-text-annotator.es14.js +894 -109
  13. package/dist/react-text-annotator.es14.js.map +1 -1
  14. package/dist/react-text-annotator.es15.js +208 -289
  15. package/dist/react-text-annotator.es15.js.map +1 -1
  16. package/dist/react-text-annotator.es16.js +127 -49
  17. package/dist/react-text-annotator.es16.js.map +1 -1
  18. package/dist/react-text-annotator.es17.js +113 -19
  19. package/dist/react-text-annotator.es17.js.map +1 -1
  20. package/dist/react-text-annotator.es18.js +312 -0
  21. package/dist/react-text-annotator.es18.js.map +1 -0
  22. package/dist/react-text-annotator.es19.js +61 -0
  23. package/dist/react-text-annotator.es19.js.map +1 -0
  24. package/dist/react-text-annotator.es2.js +1 -1
  25. package/dist/react-text-annotator.es20.js +23 -0
  26. package/dist/react-text-annotator.es20.js.map +1 -0
  27. package/dist/react-text-annotator.es21.js +5 -0
  28. package/dist/react-text-annotator.es21.js.map +1 -0
  29. package/dist/react-text-annotator.es22.js +5 -0
  30. package/dist/react-text-annotator.es22.js.map +1 -0
  31. package/dist/react-text-annotator.es23.js +124 -0
  32. package/dist/react-text-annotator.es23.js.map +1 -0
  33. package/dist/react-text-annotator.es24.js +555 -0
  34. package/dist/react-text-annotator.es24.js.map +1 -0
  35. package/dist/react-text-annotator.es4.js.map +1 -1
  36. package/dist/react-text-annotator.es5.js +60 -36
  37. package/dist/react-text-annotator.es5.js.map +1 -1
  38. package/dist/react-text-annotator.es6.js +3 -3
  39. package/dist/react-text-annotator.es8.js +24 -488
  40. package/dist/react-text-annotator.es8.js.map +1 -1
  41. package/dist/react-text-annotator.es9.js +196 -2
  42. package/dist/react-text-annotator.es9.js.map +1 -1
  43. package/dist/utils.d.ts +14 -0
  44. package/dist/utils.d.ts.map +1 -0
  45. package/package.json +4 -3
@@ -1,887 +1,491 @@
1
- import { __exports as reactJsxRuntime_development } from "./react-text-annotator.es13.js";
2
- import require$$0 from "react";
3
- /**
4
- * @license React
5
- * react-jsx-runtime.development.js
6
- *
7
- * Copyright (c) Facebook, Inc. and its affiliates.
8
- *
9
- * This source code is licensed under the MIT license found in the
10
- * LICENSE file in the root directory of this source tree.
11
- */
12
- var hasRequiredReactJsxRuntime_development;
13
- function requireReactJsxRuntime_development() {
14
- if (hasRequiredReactJsxRuntime_development)
15
- return reactJsxRuntime_development;
16
- hasRequiredReactJsxRuntime_development = 1;
17
- if (process.env.NODE_ENV !== "production") {
18
- (function() {
19
- var React = require$$0;
20
- var REACT_ELEMENT_TYPE = Symbol.for("react.element");
21
- var REACT_PORTAL_TYPE = Symbol.for("react.portal");
22
- var REACT_FRAGMENT_TYPE = Symbol.for("react.fragment");
23
- var REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode");
24
- var REACT_PROFILER_TYPE = Symbol.for("react.profiler");
25
- var REACT_PROVIDER_TYPE = Symbol.for("react.provider");
26
- var REACT_CONTEXT_TYPE = Symbol.for("react.context");
27
- var REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref");
28
- var REACT_SUSPENSE_TYPE = Symbol.for("react.suspense");
29
- var REACT_SUSPENSE_LIST_TYPE = Symbol.for("react.suspense_list");
30
- var REACT_MEMO_TYPE = Symbol.for("react.memo");
31
- var REACT_LAZY_TYPE = Symbol.for("react.lazy");
32
- var REACT_OFFSCREEN_TYPE = Symbol.for("react.offscreen");
33
- var MAYBE_ITERATOR_SYMBOL = Symbol.iterator;
34
- var FAUX_ITERATOR_SYMBOL = "@@iterator";
35
- function getIteratorFn(maybeIterable) {
36
- if (maybeIterable === null || typeof maybeIterable !== "object") {
37
- return null;
38
- }
39
- var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
40
- if (typeof maybeIterator === "function") {
41
- return maybeIterator;
42
- }
43
- return null;
44
- }
45
- var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
46
- function error(format) {
47
- {
48
- {
49
- for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
50
- args[_key2 - 1] = arguments[_key2];
51
- }
52
- printWarning("error", format, args);
53
- }
54
- }
55
- }
56
- function printWarning(level, format, args) {
57
- {
58
- var ReactDebugCurrentFrame2 = ReactSharedInternals.ReactDebugCurrentFrame;
59
- var stack = ReactDebugCurrentFrame2.getStackAddendum();
60
- if (stack !== "") {
61
- format += "%s";
62
- args = args.concat([stack]);
63
- }
64
- var argsWithFormat = args.map(function(item) {
65
- return String(item);
66
- });
67
- argsWithFormat.unshift("Warning: " + format);
68
- Function.prototype.apply.call(console[level], console, argsWithFormat);
69
- }
70
- }
71
- var enableScopeAPI = false;
72
- var enableCacheElement = false;
73
- var enableTransitionTracing = false;
74
- var enableLegacyHidden = false;
75
- var enableDebugTracing = false;
76
- var REACT_MODULE_REFERENCE;
77
- {
78
- REACT_MODULE_REFERENCE = Symbol.for("react.module.reference");
79
- }
80
- function isValidElementType(type) {
81
- if (typeof type === "string" || typeof type === "function") {
82
- return true;
83
- }
84
- if (type === REACT_FRAGMENT_TYPE || type === REACT_PROFILER_TYPE || enableDebugTracing || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || enableLegacyHidden || type === REACT_OFFSCREEN_TYPE || enableScopeAPI || enableCacheElement || enableTransitionTracing) {
85
- return true;
86
- }
87
- if (typeof type === "object" && type !== null) {
88
- if (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || // This needs to include all possible module reference object
89
- // types supported by any Flight configuration anywhere since
90
- // we don't know which Flight build this will end up being used
91
- // with.
92
- type.$$typeof === REACT_MODULE_REFERENCE || type.getModuleId !== void 0) {
93
- return true;
94
- }
95
- }
96
- return false;
97
- }
98
- function getWrappedName(outerType, innerType, wrapperName) {
99
- var displayName = outerType.displayName;
100
- if (displayName) {
101
- return displayName;
102
- }
103
- var functionName = innerType.displayName || innerType.name || "";
104
- return functionName !== "" ? wrapperName + "(" + functionName + ")" : wrapperName;
105
- }
106
- function getContextName(type) {
107
- return type.displayName || "Context";
108
- }
109
- function getComponentNameFromType(type) {
110
- if (type == null) {
111
- return null;
112
- }
113
- {
114
- if (typeof type.tag === "number") {
115
- error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue.");
116
- }
117
- }
118
- if (typeof type === "function") {
119
- return type.displayName || type.name || null;
120
- }
121
- if (typeof type === "string") {
122
- return type;
123
- }
124
- switch (type) {
125
- case REACT_FRAGMENT_TYPE:
126
- return "Fragment";
127
- case REACT_PORTAL_TYPE:
128
- return "Portal";
129
- case REACT_PROFILER_TYPE:
130
- return "Profiler";
131
- case REACT_STRICT_MODE_TYPE:
132
- return "StrictMode";
133
- case REACT_SUSPENSE_TYPE:
134
- return "Suspense";
135
- case REACT_SUSPENSE_LIST_TYPE:
136
- return "SuspenseList";
137
- }
138
- if (typeof type === "object") {
139
- switch (type.$$typeof) {
140
- case REACT_CONTEXT_TYPE:
141
- var context = type;
142
- return getContextName(context) + ".Consumer";
143
- case REACT_PROVIDER_TYPE:
144
- var provider = type;
145
- return getContextName(provider._context) + ".Provider";
146
- case REACT_FORWARD_REF_TYPE:
147
- return getWrappedName(type, type.render, "ForwardRef");
148
- case REACT_MEMO_TYPE:
149
- var outerName = type.displayName || null;
150
- if (outerName !== null) {
151
- return outerName;
152
- }
153
- return getComponentNameFromType(type.type) || "Memo";
154
- case REACT_LAZY_TYPE: {
155
- var lazyComponent = type;
156
- var payload = lazyComponent._payload;
157
- var init = lazyComponent._init;
158
- try {
159
- return getComponentNameFromType(init(payload));
160
- } catch (x) {
161
- return null;
162
- }
163
- }
164
- }
165
- }
166
- return null;
167
- }
168
- var assign = Object.assign;
169
- var disabledDepth = 0;
170
- var prevLog;
171
- var prevInfo;
172
- var prevWarn;
173
- var prevError;
174
- var prevGroup;
175
- var prevGroupCollapsed;
176
- var prevGroupEnd;
177
- function disabledLog() {
178
- }
179
- disabledLog.__reactDisabledLog = true;
180
- function disableLogs() {
181
- {
182
- if (disabledDepth === 0) {
183
- prevLog = console.log;
184
- prevInfo = console.info;
185
- prevWarn = console.warn;
186
- prevError = console.error;
187
- prevGroup = console.group;
188
- prevGroupCollapsed = console.groupCollapsed;
189
- prevGroupEnd = console.groupEnd;
190
- var props = {
191
- configurable: true,
192
- enumerable: true,
193
- value: disabledLog,
194
- writable: true
195
- };
196
- Object.defineProperties(console, {
197
- info: props,
198
- log: props,
199
- warn: props,
200
- error: props,
201
- group: props,
202
- groupCollapsed: props,
203
- groupEnd: props
204
- });
205
- }
206
- disabledDepth++;
207
- }
208
- }
209
- function reenableLogs() {
210
- {
211
- disabledDepth--;
212
- if (disabledDepth === 0) {
213
- var props = {
214
- configurable: true,
215
- enumerable: true,
216
- writable: true
217
- };
218
- Object.defineProperties(console, {
219
- log: assign({}, props, {
220
- value: prevLog
221
- }),
222
- info: assign({}, props, {
223
- value: prevInfo
224
- }),
225
- warn: assign({}, props, {
226
- value: prevWarn
227
- }),
228
- error: assign({}, props, {
229
- value: prevError
230
- }),
231
- group: assign({}, props, {
232
- value: prevGroup
233
- }),
234
- groupCollapsed: assign({}, props, {
235
- value: prevGroupCollapsed
236
- }),
237
- groupEnd: assign({}, props, {
238
- value: prevGroupEnd
239
- })
240
- });
241
- }
242
- if (disabledDepth < 0) {
243
- error("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
244
- }
245
- }
246
- }
247
- var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;
248
- var prefix;
249
- function describeBuiltInComponentFrame(name, source, ownerFn) {
250
- {
251
- if (prefix === void 0) {
252
- try {
253
- throw Error();
254
- } catch (x) {
255
- var match = x.stack.trim().match(/\n( *(at )?)/);
256
- prefix = match && match[1] || "";
257
- }
258
- }
259
- return "\n" + prefix + name;
260
- }
261
- }
262
- var reentry = false;
263
- var componentFrameCache;
264
- {
265
- var PossiblyWeakMap = typeof WeakMap === "function" ? WeakMap : Map;
266
- componentFrameCache = new PossiblyWeakMap();
267
- }
268
- function describeNativeComponentFrame(fn, construct) {
269
- if (!fn || reentry) {
270
- return "";
271
- }
272
- {
273
- var frame = componentFrameCache.get(fn);
274
- if (frame !== void 0) {
275
- return frame;
276
- }
277
- }
278
- var control;
279
- reentry = true;
280
- var previousPrepareStackTrace = Error.prepareStackTrace;
281
- Error.prepareStackTrace = void 0;
282
- var previousDispatcher;
283
- {
284
- previousDispatcher = ReactCurrentDispatcher.current;
285
- ReactCurrentDispatcher.current = null;
286
- disableLogs();
287
- }
288
- try {
289
- if (construct) {
290
- var Fake = function() {
291
- throw Error();
292
- };
293
- Object.defineProperty(Fake.prototype, "props", {
294
- set: function() {
295
- throw Error();
296
- }
297
- });
298
- if (typeof Reflect === "object" && Reflect.construct) {
299
- try {
300
- Reflect.construct(Fake, []);
301
- } catch (x) {
302
- control = x;
303
- }
304
- Reflect.construct(fn, [], Fake);
1
+ import defaultBehaviors from "./react-text-annotator.es17.js";
2
+ import * as utilities from "./react-text-annotator.es18.js";
3
+ import { hideContent, defineCustomElement, tagName } from "./react-text-annotator.es18.js";
4
+ import { addBehaviors, addBehavior, removeBehavior } from "./react-text-annotator.es19.js";
5
+ import { learnElementNames, learnCustomElementNames } from "./react-text-annotator.es20.js";
6
+ class CETEI {
7
+ constructor(options) {
8
+ this.options = options ? options : {};
9
+ this.document = this.options.documentObject ? this.options.documentObject : void 0;
10
+ if (this.document === void 0) {
11
+ if (typeof window !== "undefined" && window.document) {
12
+ this.document = window.document;
13
+ } else if (typeof global !== "undefined" && global.document) {
14
+ this.document = global.document;
15
+ }
16
+ }
17
+ this.addBehaviors = addBehaviors.bind(this);
18
+ this.addBehavior = addBehavior.bind(this);
19
+ this.removeBehavior = removeBehavior.bind(this);
20
+ this.utilities = {};
21
+ for (const u of Object.keys(utilities)) {
22
+ if (["getPrefixDef", "rw", "resolveURI"].includes(u)) {
23
+ this.utilities[u] = utilities[u].bind(this);
24
+ } else {
25
+ this.utilities[u] = utilities[u];
26
+ }
27
+ }
28
+ this.els = [];
29
+ this.namespaces = /* @__PURE__ */ new Map();
30
+ this.behaviors = {};
31
+ this.hasStyle = false;
32
+ this.prefixDefs = [];
33
+ this.debug = this.options.debug === true ? true : false;
34
+ this.discardContent = this.options.discardContent === true ? true : false;
35
+ if (this.options.base) {
36
+ this.base = this.options.base;
37
+ } else {
38
+ try {
39
+ if (window) {
40
+ this.base = window.location.href.replace(/\/[^\/]*$/, "/");
41
+ }
42
+ } catch (e) {
43
+ this.base = "";
44
+ }
45
+ }
46
+ if (!this.options.omitDefaultBehaviors) {
47
+ this.addBehaviors(defaultBehaviors);
48
+ }
49
+ if (this.options.ignoreFragmentId) {
50
+ if (window) {
51
+ window.removeEventListener("ceteiceanload", CETEI.restorePosition);
52
+ }
53
+ }
54
+ }
55
+ /*
56
+ Returns a Promise that fetches an XML source document from the URL
57
+ provided in the first parameter and then calls the makeHTML5 method
58
+ on the returned document.
59
+ */
60
+ async getHTML5(XML_url, callback, perElementFn) {
61
+ if (window && window.location.href.startsWith(this.base) && XML_url.indexOf("/") >= 0) {
62
+ this.base = XML_url.replace(/\/[^\/]*$/, "/");
63
+ }
64
+ try {
65
+ const response = await fetch(XML_url);
66
+ if (response.ok) {
67
+ const XML = await response.text();
68
+ return this.makeHTML5(XML, callback, perElementFn);
69
+ } else {
70
+ console.log(`Could not get XML file ${XML_url}.
71
+ Server returned ${response.status}: ${response.statusText}`);
72
+ }
73
+ } catch (error) {
74
+ console.log(error);
75
+ }
76
+ }
77
+ /*
78
+ Converts the supplied XML string into HTML5 Custom Elements. If a callback
79
+ function is supplied, calls it on the result.
80
+ */
81
+ makeHTML5(XML, callback, perElementFn) {
82
+ this.XML_dom = new DOMParser().parseFromString(XML, "text/xml");
83
+ return this.domToHTML5(this.XML_dom, callback, perElementFn);
84
+ }
85
+ preprocess(XML_dom, callback, perElementFn) {
86
+ this.els = learnElementNames(XML_dom, this.namespaces);
87
+ let convertEl = (el) => {
88
+ let newElement;
89
+ if (this.namespaces.has(el.namespaceURI ? el.namespaceURI : "")) {
90
+ let prefix = this.namespaces.get(el.namespaceURI ? el.namespaceURI : "");
91
+ newElement = this.document.createElement(`${prefix}-${el.localName.toLowerCase()}`);
92
+ } else {
93
+ newElement = this.document.importNode(el, false);
94
+ }
95
+ for (let att of Array.from(el.attributes)) {
96
+ if (att.name == "xmlns") {
97
+ newElement.setAttribute("data-xmlns", att.value);
98
+ } else {
99
+ newElement.setAttribute(att.name, att.value);
100
+ }
101
+ if (att.name == "xml:id") {
102
+ newElement.setAttribute("id", att.value);
103
+ }
104
+ if (att.name == "xml:lang") {
105
+ newElement.setAttribute("lang", att.value);
106
+ }
107
+ if (att.name == "rendition") {
108
+ newElement.setAttribute("class", att.value.replace(/#/g, ""));
109
+ }
110
+ }
111
+ newElement.setAttribute("data-origname", el.localName);
112
+ if (el.hasAttributes()) {
113
+ newElement.setAttribute("data-origatts", el.getAttributeNames().join(" "));
114
+ }
115
+ if (el.childNodes.length == 0) {
116
+ newElement.setAttribute("data-empty", "");
117
+ }
118
+ if (el.localName == "head") {
119
+ let level = XML_dom.evaluate("count(ancestor::*[tei:head])", el, function(ns) {
120
+ if (ns == "tei")
121
+ return "http://www.tei-c.org/ns/1.0";
122
+ }, 1, null);
123
+ newElement.setAttribute("data-level", level.numberValue);
124
+ }
125
+ if (el.localName == "tagsDecl") {
126
+ let style = this.document.createElement("style");
127
+ for (let node of Array.from(el.childNodes)) {
128
+ if (node.nodeType == 1 && node.localName == "rendition" && node.getAttribute("scheme") == "css") {
129
+ let rule = "";
130
+ if (node.hasAttribute("selector")) {
131
+ rule += node.getAttribute("selector").replace(/([^#, >]+\w*)/g, "tei-$1").replace(/#tei-/g, "#") + "{\n";
132
+ rule += node.textContent;
305
133
  } else {
306
- try {
307
- Fake.call();
308
- } catch (x) {
309
- control = x;
310
- }
311
- fn.call(Fake.prototype);
312
- }
313
- } else {
314
- try {
315
- throw Error();
316
- } catch (x) {
317
- control = x;
318
- }
319
- fn();
320
- }
321
- } catch (sample) {
322
- if (sample && control && typeof sample.stack === "string") {
323
- var sampleLines = sample.stack.split("\n");
324
- var controlLines = control.stack.split("\n");
325
- var s = sampleLines.length - 1;
326
- var c = controlLines.length - 1;
327
- while (s >= 1 && c >= 0 && sampleLines[s] !== controlLines[c]) {
328
- c--;
329
- }
330
- for (; s >= 1 && c >= 0; s--, c--) {
331
- if (sampleLines[s] !== controlLines[c]) {
332
- if (s !== 1 || c !== 1) {
333
- do {
334
- s--;
335
- c--;
336
- if (c < 0 || sampleLines[s] !== controlLines[c]) {
337
- var _frame = "\n" + sampleLines[s].replace(" at new ", " at ");
338
- if (fn.displayName && _frame.includes("<anonymous>")) {
339
- _frame = _frame.replace("<anonymous>", fn.displayName);
340
- }
341
- {
342
- if (typeof fn === "function") {
343
- componentFrameCache.set(fn, _frame);
344
- }
345
- }
346
- return _frame;
347
- }
348
- } while (s >= 1 && c >= 0);
349
- }
350
- break;
351
- }
352
- }
353
- }
354
- } finally {
355
- reentry = false;
356
- {
357
- ReactCurrentDispatcher.current = previousDispatcher;
358
- reenableLogs();
359
- }
360
- Error.prepareStackTrace = previousPrepareStackTrace;
361
- }
362
- var name = fn ? fn.displayName || fn.name : "";
363
- var syntheticFrame = name ? describeBuiltInComponentFrame(name) : "";
364
- {
365
- if (typeof fn === "function") {
366
- componentFrameCache.set(fn, syntheticFrame);
367
- }
368
- }
369
- return syntheticFrame;
370
- }
371
- function describeFunctionComponentFrame(fn, source, ownerFn) {
372
- {
373
- return describeNativeComponentFrame(fn, false);
374
- }
375
- }
376
- function shouldConstruct(Component) {
377
- var prototype = Component.prototype;
378
- return !!(prototype && prototype.isReactComponent);
379
- }
380
- function describeUnknownElementTypeFrameInDEV(type, source, ownerFn) {
381
- if (type == null) {
382
- return "";
383
- }
384
- if (typeof type === "function") {
385
- {
386
- return describeNativeComponentFrame(type, shouldConstruct(type));
387
- }
388
- }
389
- if (typeof type === "string") {
390
- return describeBuiltInComponentFrame(type);
391
- }
392
- switch (type) {
393
- case REACT_SUSPENSE_TYPE:
394
- return describeBuiltInComponentFrame("Suspense");
395
- case REACT_SUSPENSE_LIST_TYPE:
396
- return describeBuiltInComponentFrame("SuspenseList");
397
- }
398
- if (typeof type === "object") {
399
- switch (type.$$typeof) {
400
- case REACT_FORWARD_REF_TYPE:
401
- return describeFunctionComponentFrame(type.render);
402
- case REACT_MEMO_TYPE:
403
- return describeUnknownElementTypeFrameInDEV(type.type, source, ownerFn);
404
- case REACT_LAZY_TYPE: {
405
- var lazyComponent = type;
406
- var payload = lazyComponent._payload;
407
- var init = lazyComponent._init;
408
- try {
409
- return describeUnknownElementTypeFrameInDEV(init(payload), source, ownerFn);
410
- } catch (x) {
411
- }
412
- }
413
- }
414
- }
415
- return "";
416
- }
417
- var hasOwnProperty = Object.prototype.hasOwnProperty;
418
- var loggedTypeFailures = {};
419
- var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
420
- function setCurrentlyValidatingElement(element) {
421
- {
422
- if (element) {
423
- var owner = element._owner;
424
- var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null);
425
- ReactDebugCurrentFrame.setExtraStackFrame(stack);
426
- } else {
427
- ReactDebugCurrentFrame.setExtraStackFrame(null);
428
- }
429
- }
430
- }
431
- function checkPropTypes(typeSpecs, values, location, componentName, element) {
432
- {
433
- var has = Function.call.bind(hasOwnProperty);
434
- for (var typeSpecName in typeSpecs) {
435
- if (has(typeSpecs, typeSpecName)) {
436
- var error$1 = void 0;
437
- try {
438
- if (typeof typeSpecs[typeSpecName] !== "function") {
439
- var err = Error((componentName || "React class") + ": " + location + " type `" + typeSpecName + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof typeSpecs[typeSpecName] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");
440
- err.name = "Invariant Violation";
441
- throw err;
442
- }
443
- error$1 = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
444
- } catch (ex) {
445
- error$1 = ex;
446
- }
447
- if (error$1 && !(error$1 instanceof Error)) {
448
- setCurrentlyValidatingElement(element);
449
- error("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", componentName || "React class", location, typeSpecName, typeof error$1);
450
- setCurrentlyValidatingElement(null);
451
- }
452
- if (error$1 instanceof Error && !(error$1.message in loggedTypeFailures)) {
453
- loggedTypeFailures[error$1.message] = true;
454
- setCurrentlyValidatingElement(element);
455
- error("Failed %s type: %s", location, error$1.message);
456
- setCurrentlyValidatingElement(null);
457
- }
458
- }
459
- }
460
- }
461
- }
462
- var isArrayImpl = Array.isArray;
463
- function isArray(a) {
464
- return isArrayImpl(a);
465
- }
466
- function typeName(value) {
467
- {
468
- var hasToStringTag = typeof Symbol === "function" && Symbol.toStringTag;
469
- var type = hasToStringTag && value[Symbol.toStringTag] || value.constructor.name || "Object";
470
- return type;
471
- }
472
- }
473
- function willCoercionThrow(value) {
474
- {
475
- try {
476
- testStringCoercion(value);
477
- return false;
478
- } catch (e) {
479
- return true;
480
- }
481
- }
482
- }
483
- function testStringCoercion(value) {
484
- return "" + value;
485
- }
486
- function checkKeyStringCoercion(value) {
487
- {
488
- if (willCoercionThrow(value)) {
489
- error("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", typeName(value));
490
- return testStringCoercion(value);
491
- }
492
- }
493
- }
494
- var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;
495
- var RESERVED_PROPS = {
496
- key: true,
497
- ref: true,
498
- __self: true,
499
- __source: true
500
- };
501
- var specialPropKeyWarningShown;
502
- var specialPropRefWarningShown;
503
- var didWarnAboutStringRefs;
504
- {
505
- didWarnAboutStringRefs = {};
506
- }
507
- function hasValidRef(config) {
508
- {
509
- if (hasOwnProperty.call(config, "ref")) {
510
- var getter = Object.getOwnPropertyDescriptor(config, "ref").get;
511
- if (getter && getter.isReactWarning) {
512
- return false;
513
- }
514
- }
515
- }
516
- return config.ref !== void 0;
517
- }
518
- function hasValidKey(config) {
519
- {
520
- if (hasOwnProperty.call(config, "key")) {
521
- var getter = Object.getOwnPropertyDescriptor(config, "key").get;
522
- if (getter && getter.isReactWarning) {
523
- return false;
524
- }
525
- }
526
- }
527
- return config.key !== void 0;
528
- }
529
- function warnIfStringRefCannotBeAutoConverted(config, self) {
530
- {
531
- if (typeof config.ref === "string" && ReactCurrentOwner.current && self && ReactCurrentOwner.current.stateNode !== self) {
532
- var componentName = getComponentNameFromType(ReactCurrentOwner.current.type);
533
- if (!didWarnAboutStringRefs[componentName]) {
534
- error('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref', getComponentNameFromType(ReactCurrentOwner.current.type), config.ref);
535
- didWarnAboutStringRefs[componentName] = true;
134
+ rule += "." + node.getAttribute("xml:id") + "{\n";
135
+ rule += node.textContent;
536
136
  }
137
+ rule += "\n}\n";
138
+ style.appendChild(this.document.createTextNode(rule));
537
139
  }
538
140
  }
539
- }
540
- function defineKeyPropWarningGetter(props, displayName) {
541
- {
542
- var warnAboutAccessingKey = function() {
543
- if (!specialPropKeyWarningShown) {
544
- specialPropKeyWarningShown = true;
545
- error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", displayName);
546
- }
547
- };
548
- warnAboutAccessingKey.isReactWarning = true;
549
- Object.defineProperty(props, "key", {
550
- get: warnAboutAccessingKey,
551
- configurable: true
552
- });
553
- }
554
- }
555
- function defineRefPropWarningGetter(props, displayName) {
556
- {
557
- var warnAboutAccessingRef = function() {
558
- if (!specialPropRefWarningShown) {
559
- specialPropRefWarningShown = true;
560
- error("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", displayName);
561
- }
562
- };
563
- warnAboutAccessingRef.isReactWarning = true;
564
- Object.defineProperty(props, "ref", {
565
- get: warnAboutAccessingRef,
566
- configurable: true
567
- });
141
+ if (style.childNodes.length > 0) {
142
+ newElement.appendChild(style);
143
+ this.hasStyle = true;
568
144
  }
569
145
  }
570
- var ReactElement = function(type, key, ref, self, source, owner, props) {
571
- var element = {
572
- // This tag allows us to uniquely identify this as a React Element
573
- $$typeof: REACT_ELEMENT_TYPE,
574
- // Built-in properties that belong on the element
575
- type,
576
- key,
577
- ref,
578
- props,
579
- // Record the component responsible for creating this element.
580
- _owner: owner
146
+ if (el.localName == "prefixDef") {
147
+ this.prefixDefs.push(el.getAttribute("ident"));
148
+ this.prefixDefs[el.getAttribute("ident")] = {
149
+ "matchPattern": el.getAttribute("matchPattern"),
150
+ "replacementPattern": el.getAttribute("replacementPattern")
581
151
  };
582
- {
583
- element._store = {};
584
- Object.defineProperty(element._store, "validated", {
585
- configurable: false,
586
- enumerable: false,
587
- writable: true,
588
- value: false
589
- });
590
- Object.defineProperty(element, "_self", {
591
- configurable: false,
592
- enumerable: false,
593
- writable: false,
594
- value: self
595
- });
596
- Object.defineProperty(element, "_source", {
597
- configurable: false,
598
- enumerable: false,
599
- writable: false,
600
- value: source
601
- });
602
- if (Object.freeze) {
603
- Object.freeze(element.props);
604
- Object.freeze(element);
605
- }
606
- }
607
- return element;
608
- };
609
- function jsxDEV(type, config, maybeKey, source, self) {
610
- {
611
- var propName;
612
- var props = {};
613
- var key = null;
614
- var ref = null;
615
- if (maybeKey !== void 0) {
616
- {
617
- checkKeyStringCoercion(maybeKey);
618
- }
619
- key = "" + maybeKey;
620
- }
621
- if (hasValidKey(config)) {
622
- {
623
- checkKeyStringCoercion(config.key);
624
- }
625
- key = "" + config.key;
626
- }
627
- if (hasValidRef(config)) {
628
- ref = config.ref;
629
- warnIfStringRefCannotBeAutoConverted(config, self);
630
- }
631
- for (propName in config) {
632
- if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
633
- props[propName] = config[propName];
634
- }
635
- }
636
- if (type && type.defaultProps) {
637
- var defaultProps = type.defaultProps;
638
- for (propName in defaultProps) {
639
- if (props[propName] === void 0) {
640
- props[propName] = defaultProps[propName];
641
- }
642
- }
643
- }
644
- if (key || ref) {
645
- var displayName = typeof type === "function" ? type.displayName || type.name || "Unknown" : type;
646
- if (key) {
647
- defineKeyPropWarningGetter(props, displayName);
648
- }
649
- if (ref) {
650
- defineRefPropWarningGetter(props, displayName);
651
- }
652
- }
653
- return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props);
654
- }
655
152
  }
656
- var ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner;
657
- var ReactDebugCurrentFrame$1 = ReactSharedInternals.ReactDebugCurrentFrame;
658
- function setCurrentlyValidatingElement$1(element) {
659
- {
660
- if (element) {
661
- var owner = element._owner;
662
- var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null);
663
- ReactDebugCurrentFrame$1.setExtraStackFrame(stack);
664
- } else {
665
- ReactDebugCurrentFrame$1.setExtraStackFrame(null);
666
- }
153
+ for (let node of Array.from(el.childNodes)) {
154
+ if (node.nodeType == 1) {
155
+ newElement.appendChild(convertEl(node));
156
+ } else {
157
+ newElement.appendChild(node.cloneNode());
667
158
  }
668
159
  }
669
- var propTypesMisspellWarningShown;
670
- {
671
- propTypesMisspellWarningShown = false;
160
+ if (perElementFn) {
161
+ perElementFn(newElement, el);
672
162
  }
673
- function isValidElement(object) {
674
- {
675
- return typeof object === "object" && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
676
- }
163
+ return newElement;
164
+ };
165
+ this.dom = this.document.createDocumentFragment();
166
+ for (let node of Array.from(XML_dom.childNodes)) {
167
+ if (node.nodeType == 1) {
168
+ this.dom.appendChild(convertEl(node));
677
169
  }
678
- function getDeclarationErrorAddendum() {
679
- {
680
- if (ReactCurrentOwner$1.current) {
681
- var name = getComponentNameFromType(ReactCurrentOwner$1.current.type);
682
- if (name) {
683
- return "\n\nCheck the render method of `" + name + "`.";
684
- }
685
- }
686
- return "";
687
- }
170
+ if (node.nodeType == 7) {
171
+ this.dom.appendChild(this.document.importNode(node, true));
688
172
  }
689
- function getSourceInfoErrorAddendum(source) {
690
- {
691
- return "";
692
- }
173
+ if (node.nodeType == 8) {
174
+ this.dom.appendChild(this.document.importNode(node, true));
693
175
  }
694
- var ownerHasKeyUseWarning = {};
695
- function getCurrentComponentErrorInfo(parentType) {
696
- {
697
- var info = getDeclarationErrorAddendum();
698
- if (!info) {
699
- var parentName = typeof parentType === "string" ? parentType : parentType.displayName || parentType.name;
700
- if (parentName) {
701
- info = "\n\nCheck the top-level render call using <" + parentName + ">.";
702
- }
703
- }
704
- return info;
705
- }
176
+ }
177
+ this.utilities.dom = this.dom.firstElementChild;
178
+ if (callback) {
179
+ callback(this.dom, this);
180
+ if (window) {
181
+ window.dispatchEvent(ceteiceanLoad);
706
182
  }
707
- function validateExplicitKey(element, parentType) {
708
- {
709
- if (!element._store || element._store.validated || element.key != null) {
710
- return;
711
- }
712
- element._store.validated = true;
713
- var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType);
714
- if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {
715
- return;
716
- }
717
- ownerHasKeyUseWarning[currentComponentErrorInfo] = true;
718
- var childOwner = "";
719
- if (element && element._owner && element._owner !== ReactCurrentOwner$1.current) {
720
- childOwner = " It was passed a child from " + getComponentNameFromType(element._owner.type) + ".";
721
- }
722
- setCurrentlyValidatingElement$1(element);
723
- error('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', currentComponentErrorInfo, childOwner);
724
- setCurrentlyValidatingElement$1(null);
725
- }
183
+ } else {
184
+ if (typeof window !== "undefined") {
185
+ window.dispatchEvent(ceteiceanLoad);
726
186
  }
727
- function validateChildKeys(node, parentType) {
728
- {
729
- if (typeof node !== "object") {
730
- return;
731
- }
732
- if (isArray(node)) {
733
- for (var i = 0; i < node.length; i++) {
734
- var child = node[i];
735
- if (isValidElement(child)) {
736
- validateExplicitKey(child, parentType);
737
- }
738
- }
739
- } else if (isValidElement(node)) {
740
- if (node._store) {
741
- node._store.validated = true;
742
- }
743
- } else if (node) {
744
- var iteratorFn = getIteratorFn(node);
745
- if (typeof iteratorFn === "function") {
746
- if (iteratorFn !== node.entries) {
747
- var iterator = iteratorFn.call(node);
748
- var step;
749
- while (!(step = iterator.next()).done) {
750
- if (isValidElement(step.value)) {
751
- validateExplicitKey(step.value, parentType);
752
- }
753
- }
754
- }
755
- }
187
+ return this.dom;
188
+ }
189
+ }
190
+ /*
191
+ Converts the supplied XML DOM into HTML5 Custom Elements. If a callback
192
+ function is supplied, calls it on the result.
193
+ */
194
+ domToHTML5(XML_dom, callback, perElementFn) {
195
+ this.preprocess(XML_dom, null, perElementFn);
196
+ this.applyBehaviors();
197
+ this.done = true;
198
+ if (callback) {
199
+ callback(this.dom, this);
200
+ if (window) {
201
+ window.dispatchEvent(ceteiceanLoad);
202
+ }
203
+ } else {
204
+ if (typeof window !== "undefined") {
205
+ window.dispatchEvent(ceteiceanLoad);
206
+ }
207
+ return this.dom;
208
+ }
209
+ }
210
+ /*
211
+ Convenience method for HTML pages containing pre-processed CETEIcean Custom
212
+ Elements. Usage:
213
+ const c = new CETEI();
214
+ c.processPage();
215
+ */
216
+ processPage() {
217
+ this.els = learnCustomElementNames(this.document);
218
+ this.applyBehaviors();
219
+ if (window) {
220
+ window.dispatchEvent(ceteiceanLoad);
221
+ }
222
+ }
223
+ /*
224
+ To change a namespace -> prefix mapping, the namespace must first be
225
+ unset. Takes a namespace URI. In order to process a TEI P4 document, e.g.,
226
+ the TEI namespace must be unset before it can be set to the empty string.
227
+ */
228
+ unsetNamespace(ns) {
229
+ this.namespaces.delete(ns);
230
+ }
231
+ /*
232
+ Sets the base URL for the document. Used to rewrite relative links in the
233
+ XML source (which may be in a completely different location from the HTML
234
+ wrapper).
235
+ */
236
+ setBaseUrl(base) {
237
+ this.base = base;
238
+ }
239
+ /*
240
+ Appends any element returned by the function passed in the first
241
+ parameter to the element in the second parameter. If the function
242
+ returns nothing, this is a no-op aside from any side effects caused
243
+ by the provided function.
244
+
245
+ Called by getHandler() and fallback()
246
+ */
247
+ append(fn, elt) {
248
+ let self = this;
249
+ if (elt && !elt.hasAttribute("data-processed")) {
250
+ let content = fn.call(self.utilities, elt);
251
+ if (content) {
252
+ self.appendBasic(elt, content);
253
+ }
254
+ } else {
255
+ return function() {
256
+ if (!this.hasAttribute("data-processed")) {
257
+ let content = fn.call(self.utilities, this);
258
+ if (content) {
259
+ self.appendBasic(this, content);
756
260
  }
757
261
  }
758
- }
759
- function validatePropTypes(element) {
760
- {
761
- var type = element.type;
762
- if (type === null || type === void 0 || typeof type === "string") {
763
- return;
764
- }
765
- var propTypes;
766
- if (typeof type === "function") {
767
- propTypes = type.propTypes;
768
- } else if (typeof type === "object" && (type.$$typeof === REACT_FORWARD_REF_TYPE || // Note: Memo only checks outer props here.
769
- // Inner props are checked in the reconciler.
770
- type.$$typeof === REACT_MEMO_TYPE)) {
771
- propTypes = type.propTypes;
262
+ };
263
+ }
264
+ }
265
+ appendBasic(elt, content) {
266
+ if (this.discardContent) {
267
+ elt.innerHTML = "";
268
+ } else {
269
+ hideContent(elt, true);
270
+ }
271
+ elt.appendChild(content);
272
+ }
273
+ // Given an element, return its qualified name as defined in a behaviors object
274
+ bName(e) {
275
+ return e.tagName.substring(0, e.tagName.indexOf("-")).toLowerCase() + ":" + e.getAttribute("data-origname");
276
+ }
277
+ /*
278
+ Private method called by append(). Takes a child element and a name, and recurses through the
279
+ child's siblings until an element with that name is found, returning true if it is and false if not.
280
+ */
281
+ childExists(elt, name) {
282
+ if (elt && elt.nodeName == name) {
283
+ return true;
284
+ } else {
285
+ return elt && elt.nextElementSibling && this.childExists(elt.nextElementSibling, name);
286
+ }
287
+ }
288
+ /*
289
+ Takes a template in the form of either an array of 1 or 2
290
+ strings or an object with CSS selector keys and either functions
291
+ or arrays as described above. Returns a closure around a function
292
+ that can be called in the element constructor or applied to an
293
+ individual element. An empty array is considered a no-op.
294
+
295
+ Called by the getHandler() and getFallback() methods
296
+ */
297
+ decorator(template) {
298
+ if (Array.isArray(template) && template.length == 0) {
299
+ return function(e) {
300
+ };
301
+ }
302
+ if (Array.isArray(template) && !Array.isArray(template[0])) {
303
+ return this.applyDecorator(template);
304
+ }
305
+ let self = this;
306
+ return function(elt) {
307
+ for (let rule of template) {
308
+ if (elt.matches(rule[0]) || rule[0] === "_") {
309
+ if (Array.isArray(rule[1])) {
310
+ return self.decorator(rule[1]).call(this, elt);
772
311
  } else {
773
- return;
774
- }
775
- if (propTypes) {
776
- var name = getComponentNameFromType(type);
777
- checkPropTypes(propTypes, element.props, "prop", name, element);
778
- } else if (type.PropTypes !== void 0 && !propTypesMisspellWarningShown) {
779
- propTypesMisspellWarningShown = true;
780
- var _name = getComponentNameFromType(type);
781
- error("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", _name || "Unknown");
782
- }
783
- if (typeof type.getDefaultProps === "function" && !type.getDefaultProps.isReactClassApproved) {
784
- error("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.");
312
+ return rule[1].call(this, elt);
785
313
  }
786
314
  }
787
315
  }
788
- function validateFragmentProps(fragment) {
789
- {
790
- var keys = Object.keys(fragment.props);
791
- for (var i = 0; i < keys.length; i++) {
792
- var key = keys[i];
793
- if (key !== "children" && key !== "key") {
794
- setCurrentlyValidatingElement$1(fragment);
795
- error("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", key);
796
- setCurrentlyValidatingElement$1(null);
797
- break;
798
- }
799
- }
800
- if (fragment.ref !== null) {
801
- setCurrentlyValidatingElement$1(fragment);
802
- error("Invalid attribute `ref` supplied to `React.Fragment`.");
803
- setCurrentlyValidatingElement$1(null);
804
- }
805
- }
806
- }
807
- function jsxWithValidation(type, props, key, isStaticChildren, source, self) {
808
- {
809
- var validType = isValidElementType(type);
810
- if (!validType) {
811
- var info = "";
812
- if (type === void 0 || typeof type === "object" && type !== null && Object.keys(type).length === 0) {
813
- info += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.";
814
- }
815
- var sourceInfo = getSourceInfoErrorAddendum();
816
- if (sourceInfo) {
817
- info += sourceInfo;
818
- } else {
819
- info += getDeclarationErrorAddendum();
820
- }
821
- var typeString;
822
- if (type === null) {
823
- typeString = "null";
824
- } else if (isArray(type)) {
825
- typeString = "array";
826
- } else if (type !== void 0 && type.$$typeof === REACT_ELEMENT_TYPE) {
827
- typeString = "<" + (getComponentNameFromType(type.type) || "Unknown") + " />";
828
- info = " Did you accidentally export a JSX literal instead of a component?";
829
- } else {
830
- typeString = typeof type;
831
- }
832
- error("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", typeString, info);
833
- }
834
- var element = jsxDEV(type, props, key, source, self);
835
- if (element == null) {
836
- return element;
837
- }
838
- if (validType) {
839
- var children = props.children;
840
- if (children !== void 0) {
841
- if (isStaticChildren) {
842
- if (isArray(children)) {
843
- for (var i = 0; i < children.length; i++) {
844
- validateChildKeys(children[i], type);
845
- }
846
- if (Object.freeze) {
847
- Object.freeze(children);
848
- }
849
- } else {
850
- error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
851
- }
852
- } else {
853
- validateChildKeys(children, type);
854
- }
855
- }
856
- }
857
- if (type === REACT_FRAGMENT_TYPE) {
858
- validateFragmentProps(element);
316
+ };
317
+ }
318
+ applyDecorator(strings) {
319
+ let self = this;
320
+ return function(elt) {
321
+ let copy = [];
322
+ for (let i = 0; i < strings.length; i++) {
323
+ copy.push(self.template(strings[i], elt));
324
+ }
325
+ return self.insert(elt, copy);
326
+ };
327
+ }
328
+ /*
329
+ Returns the fallback function for the given element name.
330
+ Called by fallback().
331
+ */
332
+ getFallback(behaviors, fn) {
333
+ if (behaviors[fn]) {
334
+ if (behaviors[fn] instanceof Function) {
335
+ return behaviors[fn];
336
+ } else {
337
+ return this.decorator(behaviors[fn]);
338
+ }
339
+ }
340
+ }
341
+ /*
342
+ Returns the handler function for the given element name
343
+ Called by define().
344
+ */
345
+ getHandler(behaviors, fn) {
346
+ if (behaviors[fn]) {
347
+ if (behaviors[fn] instanceof Function) {
348
+ return this.append(behaviors[fn]);
349
+ } else {
350
+ return this.append(this.decorator(behaviors[fn]));
351
+ }
352
+ }
353
+ }
354
+ insert(elt, strings) {
355
+ let content = this.document.createElement("cetei-content");
356
+ for (let node of Array.from(elt.childNodes)) {
357
+ if (node.nodeType === 1 && !node.hasAttribute("data-processed")) {
358
+ this.processElement(node);
359
+ }
360
+ }
361
+ if (strings[0].match("<[^>]+>") && strings[1] && strings[1].match("<[^>]+>")) {
362
+ content.innerHTML = strings[0] + elt.innerHTML + (strings[1] ? strings[1] : "");
363
+ } else {
364
+ content.innerHTML = strings[0];
365
+ content.setAttribute("data-before", strings[0].replace(/<[^>]+>/g, "").length);
366
+ for (let node of Array.from(elt.childNodes)) {
367
+ content.appendChild(node.cloneNode(true));
368
+ }
369
+ if (strings.length > 1) {
370
+ content.innerHTML += strings[1];
371
+ content.setAttribute("data-after", strings[1].replace(/<[^>]+>/g, "").length);
372
+ }
373
+ }
374
+ if (content.childNodes.length < 2) {
375
+ return content.firstChild;
376
+ } else {
377
+ return content;
378
+ }
379
+ }
380
+ // Runs behaviors recursively on the supplied element and children
381
+ processElement(elt) {
382
+ if (elt.hasAttribute("data-origname") && !elt.hasAttribute("data-processed")) {
383
+ let fn = this.getFallback(this.bName(elt));
384
+ if (fn) {
385
+ this.append(fn, elt);
386
+ elt.setAttribute("data-processed", "");
387
+ }
388
+ }
389
+ for (let node of Array.from(elt.childNodes)) {
390
+ if (node.nodeType === 1) {
391
+ this.processElement(node);
392
+ }
393
+ }
394
+ }
395
+ template(str, elt) {
396
+ let result = str;
397
+ if (str.search(/\$(\w*)(@([a-zA-Z:]+))/)) {
398
+ let re = /\$(\w*)@([a-zA-Z:]+)/g;
399
+ let replacements;
400
+ while (replacements = re.exec(str)) {
401
+ if (elt.hasAttribute(replacements[2])) {
402
+ if (replacements[1] && this.utilities[replacements[1]]) {
403
+ result = result.replace(replacements[0], this.utilities[replacements[1]](elt.getAttribute(replacements[2])));
859
404
  } else {
860
- validatePropTypes(element);
405
+ result = result.replace(replacements[0], elt.getAttribute(replacements[2]));
861
406
  }
862
- return element;
407
+ } else {
408
+ result = result.replace(replacements[0], "");
863
409
  }
864
410
  }
865
- function jsxWithValidationStatic(type, props, key) {
866
- {
867
- return jsxWithValidation(type, props, key, true);
868
- }
869
- }
870
- function jsxWithValidationDynamic(type, props, key) {
871
- {
872
- return jsxWithValidation(type, props, key, false);
873
- }
874
- }
875
- var jsx = jsxWithValidationDynamic;
876
- var jsxs = jsxWithValidationStatic;
877
- reactJsxRuntime_development.Fragment = REACT_FRAGMENT_TYPE;
878
- reactJsxRuntime_development.jsx = jsx;
879
- reactJsxRuntime_development.jsxs = jsxs;
880
- })();
411
+ }
412
+ return result;
413
+ }
414
+ // Define or apply behaviors for the document
415
+ applyBehaviors() {
416
+ if (typeof window !== "undefined" && window.customElements) {
417
+ this.define.call(this, this.els);
418
+ } else {
419
+ this.fallback.call(this, this.els);
420
+ }
421
+ }
422
+ /*
423
+ Registers the list of elements provided with the browser.
424
+ Called by makeHTML5(), but can be called independently if, for example,
425
+ you've created Custom Elements via an XSLT transformation instead.
426
+ */
427
+ define(names) {
428
+ for (let name of names) {
429
+ const fn = this.getHandler(this.behaviors, name);
430
+ defineCustomElement(name, fn, this.debug);
431
+ }
432
+ }
433
+ /*
434
+ Provides fallback functionality for environments where Custom Elements
435
+ are not supported.
436
+
437
+ Like define(), this is called by makeHTML5(), but can be called
438
+ independently.
439
+ */
440
+ fallback(names) {
441
+ for (let name of names) {
442
+ let fn = this.getFallback(this.behaviors, name);
443
+ if (fn) {
444
+ for (let elt of Array.from((this.dom && !this.done ? this.dom : this.document).querySelectorAll(tagName(name)))) {
445
+ if (!elt.hasAttribute("data-processed")) {
446
+ this.append(fn, elt);
447
+ elt.setAttribute("data-processed", "");
448
+ }
449
+ }
450
+ }
451
+ }
452
+ }
453
+ /**********************
454
+ * Utility functions *
455
+ **********************/
456
+ static savePosition() {
457
+ window.sessionStorage.setItem(window.location + "-scroll", window.scrollY);
458
+ }
459
+ static restorePosition() {
460
+ if (!window.location.hash) {
461
+ let scroll;
462
+ if (scroll = window.sessionStorage.getItem(window.location + "-scroll")) {
463
+ window.sessionStorage.removeItem(window.location + "-scroll");
464
+ setTimeout(function() {
465
+ window.scrollTo(0, scroll);
466
+ }, 100);
467
+ }
468
+ } else {
469
+ setTimeout(function() {
470
+ let h = this.document.querySelector(window.decodeURI(window.location.hash));
471
+ if (h) {
472
+ h.scrollIntoView();
473
+ }
474
+ }, 100);
475
+ }
476
+ }
477
+ }
478
+ try {
479
+ if (typeof window !== "undefined") {
480
+ window.CETEI = CETEI;
481
+ window.addEventListener("beforeunload", CETEI.savePosition);
482
+ var ceteiceanLoad = new Event("ceteiceanload");
483
+ window.addEventListener("ceteiceanload", CETEI.restorePosition);
881
484
  }
882
- return reactJsxRuntime_development;
485
+ } catch (e) {
486
+ console.log(e);
883
487
  }
884
488
  export {
885
- requireReactJsxRuntime_development as __require
489
+ CETEI as default
886
490
  };
887
491
  //# sourceMappingURL=react-text-annotator.es11.js.map