@soomo/react-text-annotator 3.0.0-staging.4 → 3.0.0-staging.40

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 (77) hide show
  1. package/dist/TextAnnotator.d.ts +3 -3
  2. package/dist/TextAnnotator.d.ts.map +1 -1
  3. package/dist/TextAnnotatorPlugin.d.ts +1 -2
  4. package/dist/TextAnnotatorPlugin.d.ts.map +1 -1
  5. package/dist/TextAnnotatorPopup/TextAnnotatorPopup.d.ts +16 -0
  6. package/dist/TextAnnotatorPopup/TextAnnotatorPopup.d.ts.map +1 -0
  7. package/dist/TextAnnotatorPopup/index.d.ts +2 -0
  8. package/dist/TextAnnotatorPopup/index.d.ts.map +1 -0
  9. package/dist/hooks/index.d.ts +3 -0
  10. package/dist/hooks/index.d.ts.map +1 -0
  11. package/dist/hooks/useAnnouncePopupNavigation.d.ts +10 -0
  12. package/dist/hooks/useAnnouncePopupNavigation.d.ts.map +1 -0
  13. package/dist/hooks/useRestoreSelectionCaret.d.ts +13 -0
  14. package/dist/hooks/useRestoreSelectionCaret.d.ts.map +1 -0
  15. package/dist/index.d.ts +7 -2
  16. package/dist/index.d.ts.map +1 -1
  17. package/dist/react-text-annotator.css +31 -1
  18. package/dist/react-text-annotator.es.js +14 -4
  19. package/dist/react-text-annotator.es.js.map +1 -1
  20. package/dist/react-text-annotator.es11.js +459 -861
  21. package/dist/react-text-annotator.es11.js.map +1 -1
  22. package/dist/react-text-annotator.es12.js +64 -2
  23. package/dist/react-text-annotator.es12.js.map +1 -1
  24. package/dist/react-text-annotator.es13.js +45 -2
  25. package/dist/react-text-annotator.es13.js.map +1 -1
  26. package/dist/react-text-annotator.es14.js +1444 -107
  27. package/dist/react-text-annotator.es14.js.map +1 -1
  28. package/dist/react-text-annotator.es16.js +228 -45
  29. package/dist/react-text-annotator.es16.js.map +1 -1
  30. package/dist/react-text-annotator.es17.js +565 -16
  31. package/dist/react-text-annotator.es17.js.map +1 -1
  32. package/dist/react-text-annotator.es18.js +5 -0
  33. package/dist/react-text-annotator.es18.js.map +1 -0
  34. package/dist/{react-text-annotator.es10.js → react-text-annotator.es19.js} +7 -11
  35. package/dist/{react-text-annotator.es10.js.map → react-text-annotator.es19.js.map} +1 -1
  36. package/dist/react-text-annotator.es2.js +2 -2
  37. package/dist/react-text-annotator.es20.js +901 -0
  38. package/dist/react-text-annotator.es20.js.map +1 -0
  39. package/dist/react-text-annotator.es21.js +117 -0
  40. package/dist/react-text-annotator.es21.js.map +1 -0
  41. package/dist/{react-text-annotator.es15.js → react-text-annotator.es22.js} +1 -1
  42. package/dist/{react-text-annotator.es15.js.map → react-text-annotator.es22.js.map} +1 -1
  43. package/dist/react-text-annotator.es23.js +61 -0
  44. package/dist/react-text-annotator.es23.js.map +1 -0
  45. package/dist/react-text-annotator.es24.js +23 -0
  46. package/dist/react-text-annotator.es24.js.map +1 -0
  47. package/dist/react-text-annotator.es25.js +5 -0
  48. package/dist/react-text-annotator.es25.js.map +1 -0
  49. package/dist/react-text-annotator.es26.js +5 -0
  50. package/dist/react-text-annotator.es26.js.map +1 -0
  51. package/dist/react-text-annotator.es27.js +130 -0
  52. package/dist/react-text-annotator.es27.js.map +1 -0
  53. package/dist/react-text-annotator.es28.js +155 -0
  54. package/dist/react-text-annotator.es28.js.map +1 -0
  55. package/dist/react-text-annotator.es29.js +314 -0
  56. package/dist/react-text-annotator.es29.js.map +1 -0
  57. package/dist/react-text-annotator.es3.js +2 -2
  58. package/dist/react-text-annotator.es30.js +152 -0
  59. package/dist/react-text-annotator.es30.js.map +1 -0
  60. package/dist/react-text-annotator.es31.js +563 -0
  61. package/dist/react-text-annotator.es31.js.map +1 -0
  62. package/dist/react-text-annotator.es4.js +29 -27
  63. package/dist/react-text-annotator.es4.js.map +1 -1
  64. package/dist/react-text-annotator.es5.js +38 -48
  65. package/dist/react-text-annotator.es5.js.map +1 -1
  66. package/dist/react-text-annotator.es6.js +25 -10
  67. package/dist/react-text-annotator.es6.js.map +1 -1
  68. package/dist/react-text-annotator.es7.js +134 -1
  69. package/dist/react-text-annotator.es7.js.map +1 -1
  70. package/dist/react-text-annotator.es8.js +177 -486
  71. package/dist/react-text-annotator.es8.js.map +1 -1
  72. package/dist/react-text-annotator.es9.js +10 -2
  73. package/dist/react-text-annotator.es9.js.map +1 -1
  74. package/dist/tei/TEIAnnotator.d.ts +2 -2
  75. package/package.json +23 -15
  76. package/dist/TextAnnotatorPopup.d.ts +0 -14
  77. package/dist/TextAnnotatorPopup.d.ts.map +0 -1
@@ -1,892 +1,490 @@
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.es21.js";
2
+ import * as utilities from "./react-text-annotator.es22.js";
3
+ import { hideContent, defineCustomElement, tagName } from "./react-text-annotator.es22.js";
4
+ import { addBehaviors, addBehavior, removeBehavior } from "./react-text-annotator.es23.js";
5
+ import { learnElementNames, learnCustomElementNames } from "./react-text-annotator.es24.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") return "http://www.tei-c.org/ns/1.0";
121
+ }, 1, null);
122
+ newElement.setAttribute("data-level", level.numberValue);
123
+ }
124
+ if (el.localName == "tagsDecl") {
125
+ let style = this.document.createElement("style");
126
+ for (let node of Array.from(el.childNodes)) {
127
+ if (node.nodeType == 1 && node.localName == "rendition" && node.getAttribute("scheme") == "css") {
128
+ let rule = "";
129
+ if (node.hasAttribute("selector")) {
130
+ rule += node.getAttribute("selector").replace(/([^#, >]+\w*)/g, "tei-$1").replace(/#tei-/g, "#") + "{\n";
131
+ rule += node.textContent;
305
132
  } else {
306
- try {
307
- Fake.call();
308
- } catch (x) {
309
- control = x;
310
- }
311
- fn.call(Fake.prototype);
133
+ rule += "." + node.getAttribute("xml:id") + "{\n";
134
+ rule += node.textContent;
312
135
  }
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();
136
+ rule += "\n}\n";
137
+ style.appendChild(this.document.createTextNode(rule));
359
138
  }
360
- Error.prepareStackTrace = previousPrepareStackTrace;
361
139
  }
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);
140
+ if (style.childNodes.length > 0) {
141
+ newElement.appendChild(style);
142
+ this.hasStyle = true;
374
143
  }
375
144
  }
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;
536
- }
537
- }
538
- }
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
- });
568
- }
569
- }
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
145
+ if (el.localName == "prefixDef") {
146
+ this.prefixDefs.push(el.getAttribute("ident"));
147
+ this.prefixDefs[el.getAttribute("ident")] = {
148
+ "matchPattern": el.getAttribute("matchPattern"),
149
+ "replacementPattern": el.getAttribute("replacementPattern")
581
150
  };
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
151
  }
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
- }
152
+ for (let node of Array.from(el.childNodes)) {
153
+ if (node.nodeType == 1) {
154
+ newElement.appendChild(convertEl(node));
155
+ } else {
156
+ newElement.appendChild(node.cloneNode());
667
157
  }
668
158
  }
669
- var propTypesMisspellWarningShown;
670
- {
671
- propTypesMisspellWarningShown = false;
159
+ if (perElementFn) {
160
+ perElementFn(newElement, el);
672
161
  }
673
- function isValidElement(object) {
674
- {
675
- return typeof object === "object" && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
676
- }
162
+ return newElement;
163
+ };
164
+ this.dom = this.document.createDocumentFragment();
165
+ for (let node of Array.from(XML_dom.childNodes)) {
166
+ if (node.nodeType == 1) {
167
+ this.dom.appendChild(convertEl(node));
677
168
  }
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
- }
169
+ if (node.nodeType == 7) {
170
+ this.dom.appendChild(this.document.importNode(node, true));
688
171
  }
689
- function getSourceInfoErrorAddendum(source) {
690
- {
691
- if (source !== void 0) {
692
- var fileName = source.fileName.replace(/^.*[\\\/]/, "");
693
- var lineNumber = source.lineNumber;
694
- return "\n\nCheck your code at " + fileName + ":" + lineNumber + ".";
695
- }
696
- return "";
697
- }
172
+ if (node.nodeType == 8) {
173
+ this.dom.appendChild(this.document.importNode(node, true));
698
174
  }
699
- var ownerHasKeyUseWarning = {};
700
- function getCurrentComponentErrorInfo(parentType) {
701
- {
702
- var info = getDeclarationErrorAddendum();
703
- if (!info) {
704
- var parentName = typeof parentType === "string" ? parentType : parentType.displayName || parentType.name;
705
- if (parentName) {
706
- info = "\n\nCheck the top-level render call using <" + parentName + ">.";
707
- }
708
- }
709
- return info;
710
- }
175
+ }
176
+ this.utilities.dom = this.dom.firstElementChild;
177
+ if (callback) {
178
+ callback(this.dom, this);
179
+ if (window) {
180
+ window.dispatchEvent(ceteiceanLoad);
711
181
  }
712
- function validateExplicitKey(element, parentType) {
713
- {
714
- if (!element._store || element._store.validated || element.key != null) {
715
- return;
716
- }
717
- element._store.validated = true;
718
- var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType);
719
- if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {
720
- return;
721
- }
722
- ownerHasKeyUseWarning[currentComponentErrorInfo] = true;
723
- var childOwner = "";
724
- if (element && element._owner && element._owner !== ReactCurrentOwner$1.current) {
725
- childOwner = " It was passed a child from " + getComponentNameFromType(element._owner.type) + ".";
726
- }
727
- setCurrentlyValidatingElement$1(element);
728
- 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);
729
- setCurrentlyValidatingElement$1(null);
730
- }
182
+ } else {
183
+ if (typeof window !== "undefined") {
184
+ window.dispatchEvent(ceteiceanLoad);
731
185
  }
732
- function validateChildKeys(node, parentType) {
733
- {
734
- if (typeof node !== "object") {
735
- return;
736
- }
737
- if (isArray(node)) {
738
- for (var i = 0; i < node.length; i++) {
739
- var child = node[i];
740
- if (isValidElement(child)) {
741
- validateExplicitKey(child, parentType);
742
- }
743
- }
744
- } else if (isValidElement(node)) {
745
- if (node._store) {
746
- node._store.validated = true;
747
- }
748
- } else if (node) {
749
- var iteratorFn = getIteratorFn(node);
750
- if (typeof iteratorFn === "function") {
751
- if (iteratorFn !== node.entries) {
752
- var iterator = iteratorFn.call(node);
753
- var step;
754
- while (!(step = iterator.next()).done) {
755
- if (isValidElement(step.value)) {
756
- validateExplicitKey(step.value, parentType);
757
- }
758
- }
759
- }
760
- }
186
+ return this.dom;
187
+ }
188
+ }
189
+ /*
190
+ Converts the supplied XML DOM into HTML5 Custom Elements. If a callback
191
+ function is supplied, calls it on the result.
192
+ */
193
+ domToHTML5(XML_dom, callback, perElementFn) {
194
+ this.preprocess(XML_dom, null, perElementFn);
195
+ this.applyBehaviors();
196
+ this.done = true;
197
+ if (callback) {
198
+ callback(this.dom, this);
199
+ if (window) {
200
+ window.dispatchEvent(ceteiceanLoad);
201
+ }
202
+ } else {
203
+ if (typeof window !== "undefined") {
204
+ window.dispatchEvent(ceteiceanLoad);
205
+ }
206
+ return this.dom;
207
+ }
208
+ }
209
+ /*
210
+ Convenience method for HTML pages containing pre-processed CETEIcean Custom
211
+ Elements. Usage:
212
+ const c = new CETEI();
213
+ c.processPage();
214
+ */
215
+ processPage() {
216
+ this.els = learnCustomElementNames(this.document);
217
+ this.applyBehaviors();
218
+ if (window) {
219
+ window.dispatchEvent(ceteiceanLoad);
220
+ }
221
+ }
222
+ /*
223
+ To change a namespace -> prefix mapping, the namespace must first be
224
+ unset. Takes a namespace URI. In order to process a TEI P4 document, e.g.,
225
+ the TEI namespace must be unset before it can be set to the empty string.
226
+ */
227
+ unsetNamespace(ns) {
228
+ this.namespaces.delete(ns);
229
+ }
230
+ /*
231
+ Sets the base URL for the document. Used to rewrite relative links in the
232
+ XML source (which may be in a completely different location from the HTML
233
+ wrapper).
234
+ */
235
+ setBaseUrl(base) {
236
+ this.base = base;
237
+ }
238
+ /*
239
+ Appends any element returned by the function passed in the first
240
+ parameter to the element in the second parameter. If the function
241
+ returns nothing, this is a no-op aside from any side effects caused
242
+ by the provided function.
243
+
244
+ Called by getHandler() and fallback()
245
+ */
246
+ append(fn, elt) {
247
+ let self = this;
248
+ if (elt && !elt.hasAttribute("data-processed")) {
249
+ let content = fn.call(self.utilities, elt);
250
+ if (content) {
251
+ self.appendBasic(elt, content);
252
+ }
253
+ } else {
254
+ return function() {
255
+ if (!this.hasAttribute("data-processed")) {
256
+ let content = fn.call(self.utilities, this);
257
+ if (content) {
258
+ self.appendBasic(this, content);
761
259
  }
762
260
  }
763
- }
764
- function validatePropTypes(element) {
765
- {
766
- var type = element.type;
767
- if (type === null || type === void 0 || typeof type === "string") {
768
- return;
769
- }
770
- var propTypes;
771
- if (typeof type === "function") {
772
- propTypes = type.propTypes;
773
- } else if (typeof type === "object" && (type.$$typeof === REACT_FORWARD_REF_TYPE || // Note: Memo only checks outer props here.
774
- // Inner props are checked in the reconciler.
775
- type.$$typeof === REACT_MEMO_TYPE)) {
776
- propTypes = type.propTypes;
261
+ };
262
+ }
263
+ }
264
+ appendBasic(elt, content) {
265
+ if (this.discardContent) {
266
+ elt.innerHTML = "";
267
+ } else {
268
+ hideContent(elt, true);
269
+ }
270
+ elt.appendChild(content);
271
+ }
272
+ // Given an element, return its qualified name as defined in a behaviors object
273
+ bName(e) {
274
+ return e.tagName.substring(0, e.tagName.indexOf("-")).toLowerCase() + ":" + e.getAttribute("data-origname");
275
+ }
276
+ /*
277
+ Private method called by append(). Takes a child element and a name, and recurses through the
278
+ child's siblings until an element with that name is found, returning true if it is and false if not.
279
+ */
280
+ childExists(elt, name) {
281
+ if (elt && elt.nodeName == name) {
282
+ return true;
283
+ } else {
284
+ return elt && elt.nextElementSibling && this.childExists(elt.nextElementSibling, name);
285
+ }
286
+ }
287
+ /*
288
+ Takes a template in the form of either an array of 1 or 2
289
+ strings or an object with CSS selector keys and either functions
290
+ or arrays as described above. Returns a closure around a function
291
+ that can be called in the element constructor or applied to an
292
+ individual element. An empty array is considered a no-op.
293
+
294
+ Called by the getHandler() and getFallback() methods
295
+ */
296
+ decorator(template) {
297
+ if (Array.isArray(template) && template.length == 0) {
298
+ return function(e) {
299
+ };
300
+ }
301
+ if (Array.isArray(template) && !Array.isArray(template[0])) {
302
+ return this.applyDecorator(template);
303
+ }
304
+ let self = this;
305
+ return function(elt) {
306
+ for (let rule of template) {
307
+ if (elt.matches(rule[0]) || rule[0] === "_") {
308
+ if (Array.isArray(rule[1])) {
309
+ return self.decorator(rule[1]).call(this, elt);
777
310
  } else {
778
- return;
779
- }
780
- if (propTypes) {
781
- var name = getComponentNameFromType(type);
782
- checkPropTypes(propTypes, element.props, "prop", name, element);
783
- } else if (type.PropTypes !== void 0 && !propTypesMisspellWarningShown) {
784
- propTypesMisspellWarningShown = true;
785
- var _name = getComponentNameFromType(type);
786
- error("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", _name || "Unknown");
787
- }
788
- if (typeof type.getDefaultProps === "function" && !type.getDefaultProps.isReactClassApproved) {
789
- error("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.");
311
+ return rule[1].call(this, elt);
790
312
  }
791
313
  }
792
314
  }
793
- function validateFragmentProps(fragment) {
794
- {
795
- var keys = Object.keys(fragment.props);
796
- for (var i = 0; i < keys.length; i++) {
797
- var key = keys[i];
798
- if (key !== "children" && key !== "key") {
799
- setCurrentlyValidatingElement$1(fragment);
800
- error("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", key);
801
- setCurrentlyValidatingElement$1(null);
802
- break;
803
- }
804
- }
805
- if (fragment.ref !== null) {
806
- setCurrentlyValidatingElement$1(fragment);
807
- error("Invalid attribute `ref` supplied to `React.Fragment`.");
808
- setCurrentlyValidatingElement$1(null);
809
- }
810
- }
811
- }
812
- function jsxWithValidation(type, props, key, isStaticChildren, source, self) {
813
- {
814
- var validType = isValidElementType(type);
815
- if (!validType) {
816
- var info = "";
817
- if (type === void 0 || typeof type === "object" && type !== null && Object.keys(type).length === 0) {
818
- 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.";
819
- }
820
- var sourceInfo = getSourceInfoErrorAddendum(source);
821
- if (sourceInfo) {
822
- info += sourceInfo;
823
- } else {
824
- info += getDeclarationErrorAddendum();
825
- }
826
- var typeString;
827
- if (type === null) {
828
- typeString = "null";
829
- } else if (isArray(type)) {
830
- typeString = "array";
831
- } else if (type !== void 0 && type.$$typeof === REACT_ELEMENT_TYPE) {
832
- typeString = "<" + (getComponentNameFromType(type.type) || "Unknown") + " />";
833
- info = " Did you accidentally export a JSX literal instead of a component?";
834
- } else {
835
- typeString = typeof type;
836
- }
837
- 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);
838
- }
839
- var element = jsxDEV(type, props, key, source, self);
840
- if (element == null) {
841
- return element;
842
- }
843
- if (validType) {
844
- var children = props.children;
845
- if (children !== void 0) {
846
- if (isStaticChildren) {
847
- if (isArray(children)) {
848
- for (var i = 0; i < children.length; i++) {
849
- validateChildKeys(children[i], type);
850
- }
851
- if (Object.freeze) {
852
- Object.freeze(children);
853
- }
854
- } else {
855
- 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.");
856
- }
857
- } else {
858
- validateChildKeys(children, type);
859
- }
860
- }
861
- }
862
- if (type === REACT_FRAGMENT_TYPE) {
863
- validateFragmentProps(element);
315
+ };
316
+ }
317
+ applyDecorator(strings) {
318
+ let self = this;
319
+ return function(elt) {
320
+ let copy = [];
321
+ for (let i = 0; i < strings.length; i++) {
322
+ copy.push(self.template(strings[i], elt));
323
+ }
324
+ return self.insert(elt, copy);
325
+ };
326
+ }
327
+ /*
328
+ Returns the fallback function for the given element name.
329
+ Called by fallback().
330
+ */
331
+ getFallback(behaviors, fn) {
332
+ if (behaviors[fn]) {
333
+ if (behaviors[fn] instanceof Function) {
334
+ return behaviors[fn];
335
+ } else {
336
+ return this.decorator(behaviors[fn]);
337
+ }
338
+ }
339
+ }
340
+ /*
341
+ Returns the handler function for the given element name
342
+ Called by define().
343
+ */
344
+ getHandler(behaviors, fn) {
345
+ if (behaviors[fn]) {
346
+ if (behaviors[fn] instanceof Function) {
347
+ return this.append(behaviors[fn]);
348
+ } else {
349
+ return this.append(this.decorator(behaviors[fn]));
350
+ }
351
+ }
352
+ }
353
+ insert(elt, strings) {
354
+ let content = this.document.createElement("cetei-content");
355
+ for (let node of Array.from(elt.childNodes)) {
356
+ if (node.nodeType === 1 && !node.hasAttribute("data-processed")) {
357
+ this.processElement(node);
358
+ }
359
+ }
360
+ if (strings[0].match("<[^>]+>") && strings[1] && strings[1].match("<[^>]+>")) {
361
+ content.innerHTML = strings[0] + elt.innerHTML + (strings[1] ? strings[1] : "");
362
+ } else {
363
+ content.innerHTML = strings[0];
364
+ content.setAttribute("data-before", strings[0].replace(/<[^>]+>/g, "").length);
365
+ for (let node of Array.from(elt.childNodes)) {
366
+ content.appendChild(node.cloneNode(true));
367
+ }
368
+ if (strings.length > 1) {
369
+ content.innerHTML += strings[1];
370
+ content.setAttribute("data-after", strings[1].replace(/<[^>]+>/g, "").length);
371
+ }
372
+ }
373
+ if (content.childNodes.length < 2) {
374
+ return content.firstChild;
375
+ } else {
376
+ return content;
377
+ }
378
+ }
379
+ // Runs behaviors recursively on the supplied element and children
380
+ processElement(elt) {
381
+ if (elt.hasAttribute("data-origname") && !elt.hasAttribute("data-processed")) {
382
+ let fn = this.getFallback(this.bName(elt));
383
+ if (fn) {
384
+ this.append(fn, elt);
385
+ elt.setAttribute("data-processed", "");
386
+ }
387
+ }
388
+ for (let node of Array.from(elt.childNodes)) {
389
+ if (node.nodeType === 1) {
390
+ this.processElement(node);
391
+ }
392
+ }
393
+ }
394
+ template(str, elt) {
395
+ let result = str;
396
+ if (str.search(/\$(\w*)(@([a-zA-Z:]+))/)) {
397
+ let re = /\$(\w*)@([a-zA-Z:]+)/g;
398
+ let replacements;
399
+ while (replacements = re.exec(str)) {
400
+ if (elt.hasAttribute(replacements[2])) {
401
+ if (replacements[1] && this.utilities[replacements[1]]) {
402
+ result = result.replace(replacements[0], this.utilities[replacements[1]](elt.getAttribute(replacements[2])));
864
403
  } else {
865
- validatePropTypes(element);
404
+ result = result.replace(replacements[0], elt.getAttribute(replacements[2]));
866
405
  }
867
- return element;
406
+ } else {
407
+ result = result.replace(replacements[0], "");
868
408
  }
869
409
  }
870
- function jsxWithValidationStatic(type, props, key) {
871
- {
872
- return jsxWithValidation(type, props, key, true);
873
- }
874
- }
875
- function jsxWithValidationDynamic(type, props, key) {
876
- {
877
- return jsxWithValidation(type, props, key, false);
878
- }
879
- }
880
- var jsx = jsxWithValidationDynamic;
881
- var jsxs = jsxWithValidationStatic;
882
- reactJsxRuntime_development.Fragment = REACT_FRAGMENT_TYPE;
883
- reactJsxRuntime_development.jsx = jsx;
884
- reactJsxRuntime_development.jsxs = jsxs;
885
- })();
410
+ }
411
+ return result;
412
+ }
413
+ // Define or apply behaviors for the document
414
+ applyBehaviors() {
415
+ if (typeof window !== "undefined" && window.customElements) {
416
+ this.define.call(this, this.els);
417
+ } else {
418
+ this.fallback.call(this, this.els);
419
+ }
420
+ }
421
+ /*
422
+ Registers the list of elements provided with the browser.
423
+ Called by makeHTML5(), but can be called independently if, for example,
424
+ you've created Custom Elements via an XSLT transformation instead.
425
+ */
426
+ define(names) {
427
+ for (let name of names) {
428
+ const fn = this.getHandler(this.behaviors, name);
429
+ defineCustomElement(name, fn, this.debug);
430
+ }
431
+ }
432
+ /*
433
+ Provides fallback functionality for environments where Custom Elements
434
+ are not supported.
435
+
436
+ Like define(), this is called by makeHTML5(), but can be called
437
+ independently.
438
+ */
439
+ fallback(names) {
440
+ for (let name of names) {
441
+ let fn = this.getFallback(this.behaviors, name);
442
+ if (fn) {
443
+ for (let elt of Array.from((this.dom && !this.done ? this.dom : this.document).querySelectorAll(tagName(name)))) {
444
+ if (!elt.hasAttribute("data-processed")) {
445
+ this.append(fn, elt);
446
+ elt.setAttribute("data-processed", "");
447
+ }
448
+ }
449
+ }
450
+ }
451
+ }
452
+ /**********************
453
+ * Utility functions *
454
+ **********************/
455
+ static savePosition() {
456
+ window.sessionStorage.setItem(window.location + "-scroll", window.scrollY);
457
+ }
458
+ static restorePosition() {
459
+ if (!window.location.hash) {
460
+ let scroll;
461
+ if (scroll = window.sessionStorage.getItem(window.location + "-scroll")) {
462
+ window.sessionStorage.removeItem(window.location + "-scroll");
463
+ setTimeout(function() {
464
+ window.scrollTo(0, scroll);
465
+ }, 100);
466
+ }
467
+ } else {
468
+ setTimeout(function() {
469
+ let h = this.document.querySelector(window.decodeURI(window.location.hash));
470
+ if (h) {
471
+ h.scrollIntoView();
472
+ }
473
+ }, 100);
474
+ }
475
+ }
476
+ }
477
+ try {
478
+ if (typeof window !== "undefined") {
479
+ window.CETEI = CETEI;
480
+ window.addEventListener("beforeunload", CETEI.savePosition);
481
+ var ceteiceanLoad = new Event("ceteiceanload");
482
+ window.addEventListener("ceteiceanload", CETEI.restorePosition);
886
483
  }
887
- return reactJsxRuntime_development;
484
+ } catch (e) {
485
+ console.log(e);
888
486
  }
889
487
  export {
890
- requireReactJsxRuntime_development as __require
488
+ CETEI as default
891
489
  };
892
490
  //# sourceMappingURL=react-text-annotator.es11.js.map