@dracor/react 0.9.0 → 1.0.0-alpha.2

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 (114) hide show
  1. package/README.md +42 -22
  2. package/dist/index.d.ts +201 -117
  3. package/dist/index.es.js +1514 -0
  4. package/dist/index.es.js.map +1 -0
  5. package/dist/index.umd.js +44 -0
  6. package/dist/index.umd.js.map +1 -0
  7. package/package.json +96 -75
  8. package/src/dracor.css +142 -0
  9. package/ceteicean.js +0 -46
  10. package/dist/cjs/index.js +0 -4631
  11. package/dist/cjs/index.js.map +0 -1
  12. package/dist/cjs/types/components/ApiDoc/ApiDoc.d.ts +0 -6
  13. package/dist/cjs/types/components/ApiDoc/ApiDoc.stories.d.ts +0 -21
  14. package/dist/cjs/types/components/ApiDoc/ApiDoc.test.d.ts +0 -1
  15. package/dist/cjs/types/components/ApiDoc/index.d.ts +0 -1
  16. package/dist/cjs/types/components/AuthorInfo/AuthorInfo.d.ts +0 -7
  17. package/dist/cjs/types/components/AuthorInfo/AuthorInfo.stories.d.ts +0 -10
  18. package/dist/cjs/types/components/AuthorInfo/AuthorInfo.test.d.ts +0 -1
  19. package/dist/cjs/types/components/AuthorInfo/index.d.ts +0 -1
  20. package/dist/cjs/types/components/Authors/Authors.d.ts +0 -10
  21. package/dist/cjs/types/components/Authors/Authors.stories.d.ts +0 -12
  22. package/dist/cjs/types/components/Authors/Authors.test.d.ts +0 -1
  23. package/dist/cjs/types/components/Authors/index.d.ts +0 -1
  24. package/dist/cjs/types/components/DebouncedInput/DebouncedInput.d.ts +0 -6
  25. package/dist/cjs/types/components/DebouncedInput/index.d.ts +0 -1
  26. package/dist/cjs/types/components/IdCopy/IdCopy.d.ts +0 -8
  27. package/dist/cjs/types/components/IdCopy/IdCopy.stories.d.ts +0 -11
  28. package/dist/cjs/types/components/IdCopy/IdCopy.test.d.ts +0 -1
  29. package/dist/cjs/types/components/IdCopy/index.d.ts +0 -1
  30. package/dist/cjs/types/components/IdLink/IdLink.d.ts +0 -7
  31. package/dist/cjs/types/components/IdLink/IdLink.stories.d.ts +0 -15
  32. package/dist/cjs/types/components/IdLink/IdLink.test.d.ts +0 -1
  33. package/dist/cjs/types/components/IdLink/index.d.ts +0 -1
  34. package/dist/cjs/types/components/Navigation/NavBar.d.ts +0 -13
  35. package/dist/cjs/types/components/Navigation/NavBar.stories.d.ts +0 -28
  36. package/dist/cjs/types/components/Navigation/NavBar.test.d.ts +0 -1
  37. package/dist/cjs/types/components/Navigation/NavItem.d.ts +0 -8
  38. package/dist/cjs/types/components/Navigation/NavItem.stories.d.ts +0 -19
  39. package/dist/cjs/types/components/Navigation/NavMenu.d.ts +0 -12
  40. package/dist/cjs/types/components/Navigation/NavMenu.stories.d.ts +0 -19
  41. package/dist/cjs/types/components/Navigation/index.d.ts +0 -1
  42. package/dist/cjs/types/components/TEIText/TEIText.d.ts +0 -14
  43. package/dist/cjs/types/components/TEIText/TEIText.stories.d.ts +0 -10
  44. package/dist/cjs/types/components/TEIText/index.d.ts +0 -1
  45. package/dist/cjs/types/components/Table/Table.d.ts +0 -11
  46. package/dist/cjs/types/components/Table/Table.stories.d.ts +0 -9
  47. package/dist/cjs/types/components/Table/Table.test.d.ts +0 -1
  48. package/dist/cjs/types/components/Table/index.d.ts +0 -1
  49. package/dist/cjs/types/components/Tabs/Tabs.d.ts +0 -11
  50. package/dist/cjs/types/components/Tabs/Tabs.stories.d.ts +0 -23
  51. package/dist/cjs/types/components/Tabs/Tabs.test.d.ts +0 -1
  52. package/dist/cjs/types/components/Tabs/index.d.ts +0 -1
  53. package/dist/cjs/types/components/Years/Years.d.ts +0 -10
  54. package/dist/cjs/types/components/Years/Years.stories.d.ts +0 -11
  55. package/dist/cjs/types/components/Years/Years.test.d.ts +0 -1
  56. package/dist/cjs/types/components/Years/index.d.ts +0 -1
  57. package/dist/cjs/types/components/index.d.ts +0 -10
  58. package/dist/cjs/types/einakter-gh.d.ts +0 -2
  59. package/dist/cjs/types/index.d.ts +0 -2
  60. package/dist/cjs/types/testHelpers.d.ts +0 -7
  61. package/dist/cjs/types/utils.d.ts +0 -2
  62. package/dist/esm/index.js +0 -4618
  63. package/dist/esm/index.js.map +0 -1
  64. package/dist/esm/types/components/ApiDoc/ApiDoc.d.ts +0 -6
  65. package/dist/esm/types/components/ApiDoc/ApiDoc.stories.d.ts +0 -21
  66. package/dist/esm/types/components/ApiDoc/ApiDoc.test.d.ts +0 -1
  67. package/dist/esm/types/components/ApiDoc/index.d.ts +0 -1
  68. package/dist/esm/types/components/AuthorInfo/AuthorInfo.d.ts +0 -7
  69. package/dist/esm/types/components/AuthorInfo/AuthorInfo.stories.d.ts +0 -10
  70. package/dist/esm/types/components/AuthorInfo/AuthorInfo.test.d.ts +0 -1
  71. package/dist/esm/types/components/AuthorInfo/index.d.ts +0 -1
  72. package/dist/esm/types/components/Authors/Authors.d.ts +0 -10
  73. package/dist/esm/types/components/Authors/Authors.stories.d.ts +0 -12
  74. package/dist/esm/types/components/Authors/Authors.test.d.ts +0 -1
  75. package/dist/esm/types/components/Authors/index.d.ts +0 -1
  76. package/dist/esm/types/components/DebouncedInput/DebouncedInput.d.ts +0 -6
  77. package/dist/esm/types/components/DebouncedInput/index.d.ts +0 -1
  78. package/dist/esm/types/components/IdCopy/IdCopy.d.ts +0 -8
  79. package/dist/esm/types/components/IdCopy/IdCopy.stories.d.ts +0 -11
  80. package/dist/esm/types/components/IdCopy/IdCopy.test.d.ts +0 -1
  81. package/dist/esm/types/components/IdCopy/index.d.ts +0 -1
  82. package/dist/esm/types/components/IdLink/IdLink.d.ts +0 -7
  83. package/dist/esm/types/components/IdLink/IdLink.stories.d.ts +0 -15
  84. package/dist/esm/types/components/IdLink/IdLink.test.d.ts +0 -1
  85. package/dist/esm/types/components/IdLink/index.d.ts +0 -1
  86. package/dist/esm/types/components/Navigation/NavBar.d.ts +0 -13
  87. package/dist/esm/types/components/Navigation/NavBar.stories.d.ts +0 -28
  88. package/dist/esm/types/components/Navigation/NavBar.test.d.ts +0 -1
  89. package/dist/esm/types/components/Navigation/NavItem.d.ts +0 -8
  90. package/dist/esm/types/components/Navigation/NavItem.stories.d.ts +0 -19
  91. package/dist/esm/types/components/Navigation/NavMenu.d.ts +0 -12
  92. package/dist/esm/types/components/Navigation/NavMenu.stories.d.ts +0 -19
  93. package/dist/esm/types/components/Navigation/index.d.ts +0 -1
  94. package/dist/esm/types/components/TEIText/TEIText.d.ts +0 -14
  95. package/dist/esm/types/components/TEIText/TEIText.stories.d.ts +0 -10
  96. package/dist/esm/types/components/TEIText/index.d.ts +0 -1
  97. package/dist/esm/types/components/Table/Table.d.ts +0 -11
  98. package/dist/esm/types/components/Table/Table.stories.d.ts +0 -9
  99. package/dist/esm/types/components/Table/Table.test.d.ts +0 -1
  100. package/dist/esm/types/components/Table/index.d.ts +0 -1
  101. package/dist/esm/types/components/Tabs/Tabs.d.ts +0 -11
  102. package/dist/esm/types/components/Tabs/Tabs.stories.d.ts +0 -23
  103. package/dist/esm/types/components/Tabs/Tabs.test.d.ts +0 -1
  104. package/dist/esm/types/components/Tabs/index.d.ts +0 -1
  105. package/dist/esm/types/components/Years/Years.d.ts +0 -10
  106. package/dist/esm/types/components/Years/Years.stories.d.ts +0 -11
  107. package/dist/esm/types/components/Years/Years.test.d.ts +0 -1
  108. package/dist/esm/types/components/Years/index.d.ts +0 -1
  109. package/dist/esm/types/components/index.d.ts +0 -10
  110. package/dist/esm/types/einakter-gh.d.ts +0 -2
  111. package/dist/esm/types/index.d.ts +0 -2
  112. package/dist/esm/types/testHelpers.d.ts +0 -7
  113. package/dist/esm/types/utils.d.ts +0 -2
  114. package/tailwind.js +0 -57
package/dist/cjs/index.js DELETED
@@ -1,4631 +0,0 @@
1
- 'use strict';
2
-
3
- var jsxRuntime = require('react/jsx-runtime');
4
- var react = require('react');
5
- var reactFontawesome = require('@fortawesome/react-fontawesome');
6
- var freeSolidSvgIcons = require('@fortawesome/free-solid-svg-icons');
7
- var reactCopyToClipboard = require('react-copy-to-clipboard');
8
- var reactRouterDom = require('react-router-dom');
9
- var freeBrandsSvgIcons = require('@fortawesome/free-brands-svg-icons');
10
- var react$1 = require('@headlessui/react');
11
- var reactTable = require('@tanstack/react-table');
12
-
13
- /******************************************************************************
14
- Copyright (c) Microsoft Corporation.
15
-
16
- Permission to use, copy, modify, and/or distribute this software for any
17
- purpose with or without fee is hereby granted.
18
-
19
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
20
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
21
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
22
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
23
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
24
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
25
- PERFORMANCE OF THIS SOFTWARE.
26
- ***************************************************************************** */
27
- /* global Reflect, Promise, SuppressedError, Symbol */
28
-
29
-
30
- function __rest(s, e) {
31
- var t = {};
32
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
33
- t[p] = s[p];
34
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
35
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
36
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
37
- t[p[i]] = s[p[i]];
38
- }
39
- return t;
40
- }
41
-
42
- function __awaiter(thisArg, _arguments, P, generator) {
43
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
44
- return new (P || (P = Promise))(function (resolve, reject) {
45
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
46
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
47
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
48
- step((generator = generator.apply(thisArg, _arguments || [])).next());
49
- });
50
- }
51
-
52
- typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
53
- var e = new Error(message);
54
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
55
- };
56
-
57
- function bind(fn, thisArg) {
58
- return function wrap() {
59
- return fn.apply(thisArg, arguments);
60
- };
61
- }
62
-
63
- // utils is a library of generic helper functions non-specific to axios
64
-
65
- const {toString} = Object.prototype;
66
- const {getPrototypeOf} = Object;
67
-
68
- const kindOf = (cache => thing => {
69
- const str = toString.call(thing);
70
- return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase());
71
- })(Object.create(null));
72
-
73
- const kindOfTest = (type) => {
74
- type = type.toLowerCase();
75
- return (thing) => kindOf(thing) === type
76
- };
77
-
78
- const typeOfTest = type => thing => typeof thing === type;
79
-
80
- /**
81
- * Determine if a value is an Array
82
- *
83
- * @param {Object} val The value to test
84
- *
85
- * @returns {boolean} True if value is an Array, otherwise false
86
- */
87
- const {isArray} = Array;
88
-
89
- /**
90
- * Determine if a value is undefined
91
- *
92
- * @param {*} val The value to test
93
- *
94
- * @returns {boolean} True if the value is undefined, otherwise false
95
- */
96
- const isUndefined = typeOfTest('undefined');
97
-
98
- /**
99
- * Determine if a value is a Buffer
100
- *
101
- * @param {*} val The value to test
102
- *
103
- * @returns {boolean} True if value is a Buffer, otherwise false
104
- */
105
- function isBuffer(val) {
106
- return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor)
107
- && isFunction(val.constructor.isBuffer) && val.constructor.isBuffer(val);
108
- }
109
-
110
- /**
111
- * Determine if a value is an ArrayBuffer
112
- *
113
- * @param {*} val The value to test
114
- *
115
- * @returns {boolean} True if value is an ArrayBuffer, otherwise false
116
- */
117
- const isArrayBuffer = kindOfTest('ArrayBuffer');
118
-
119
-
120
- /**
121
- * Determine if a value is a view on an ArrayBuffer
122
- *
123
- * @param {*} val The value to test
124
- *
125
- * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false
126
- */
127
- function isArrayBufferView(val) {
128
- let result;
129
- if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {
130
- result = ArrayBuffer.isView(val);
131
- } else {
132
- result = (val) && (val.buffer) && (isArrayBuffer(val.buffer));
133
- }
134
- return result;
135
- }
136
-
137
- /**
138
- * Determine if a value is a String
139
- *
140
- * @param {*} val The value to test
141
- *
142
- * @returns {boolean} True if value is a String, otherwise false
143
- */
144
- const isString = typeOfTest('string');
145
-
146
- /**
147
- * Determine if a value is a Function
148
- *
149
- * @param {*} val The value to test
150
- * @returns {boolean} True if value is a Function, otherwise false
151
- */
152
- const isFunction = typeOfTest('function');
153
-
154
- /**
155
- * Determine if a value is a Number
156
- *
157
- * @param {*} val The value to test
158
- *
159
- * @returns {boolean} True if value is a Number, otherwise false
160
- */
161
- const isNumber = typeOfTest('number');
162
-
163
- /**
164
- * Determine if a value is an Object
165
- *
166
- * @param {*} thing The value to test
167
- *
168
- * @returns {boolean} True if value is an Object, otherwise false
169
- */
170
- const isObject = (thing) => thing !== null && typeof thing === 'object';
171
-
172
- /**
173
- * Determine if a value is a Boolean
174
- *
175
- * @param {*} thing The value to test
176
- * @returns {boolean} True if value is a Boolean, otherwise false
177
- */
178
- const isBoolean = thing => thing === true || thing === false;
179
-
180
- /**
181
- * Determine if a value is a plain Object
182
- *
183
- * @param {*} val The value to test
184
- *
185
- * @returns {boolean} True if value is a plain Object, otherwise false
186
- */
187
- const isPlainObject = (val) => {
188
- if (kindOf(val) !== 'object') {
189
- return false;
190
- }
191
-
192
- const prototype = getPrototypeOf(val);
193
- return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(Symbol.toStringTag in val) && !(Symbol.iterator in val);
194
- };
195
-
196
- /**
197
- * Determine if a value is a Date
198
- *
199
- * @param {*} val The value to test
200
- *
201
- * @returns {boolean} True if value is a Date, otherwise false
202
- */
203
- const isDate = kindOfTest('Date');
204
-
205
- /**
206
- * Determine if a value is a File
207
- *
208
- * @param {*} val The value to test
209
- *
210
- * @returns {boolean} True if value is a File, otherwise false
211
- */
212
- const isFile = kindOfTest('File');
213
-
214
- /**
215
- * Determine if a value is a Blob
216
- *
217
- * @param {*} val The value to test
218
- *
219
- * @returns {boolean} True if value is a Blob, otherwise false
220
- */
221
- const isBlob = kindOfTest('Blob');
222
-
223
- /**
224
- * Determine if a value is a FileList
225
- *
226
- * @param {*} val The value to test
227
- *
228
- * @returns {boolean} True if value is a File, otherwise false
229
- */
230
- const isFileList = kindOfTest('FileList');
231
-
232
- /**
233
- * Determine if a value is a Stream
234
- *
235
- * @param {*} val The value to test
236
- *
237
- * @returns {boolean} True if value is a Stream, otherwise false
238
- */
239
- const isStream = (val) => isObject(val) && isFunction(val.pipe);
240
-
241
- /**
242
- * Determine if a value is a FormData
243
- *
244
- * @param {*} thing The value to test
245
- *
246
- * @returns {boolean} True if value is an FormData, otherwise false
247
- */
248
- const isFormData = (thing) => {
249
- let kind;
250
- return thing && (
251
- (typeof FormData === 'function' && thing instanceof FormData) || (
252
- isFunction(thing.append) && (
253
- (kind = kindOf(thing)) === 'formdata' ||
254
- // detect form-data instance
255
- (kind === 'object' && isFunction(thing.toString) && thing.toString() === '[object FormData]')
256
- )
257
- )
258
- )
259
- };
260
-
261
- /**
262
- * Determine if a value is a URLSearchParams object
263
- *
264
- * @param {*} val The value to test
265
- *
266
- * @returns {boolean} True if value is a URLSearchParams object, otherwise false
267
- */
268
- const isURLSearchParams = kindOfTest('URLSearchParams');
269
-
270
- /**
271
- * Trim excess whitespace off the beginning and end of a string
272
- *
273
- * @param {String} str The String to trim
274
- *
275
- * @returns {String} The String freed of excess whitespace
276
- */
277
- const trim = (str) => str.trim ?
278
- str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
279
-
280
- /**
281
- * Iterate over an Array or an Object invoking a function for each item.
282
- *
283
- * If `obj` is an Array callback will be called passing
284
- * the value, index, and complete array for each item.
285
- *
286
- * If 'obj' is an Object callback will be called passing
287
- * the value, key, and complete object for each property.
288
- *
289
- * @param {Object|Array} obj The object to iterate
290
- * @param {Function} fn The callback to invoke for each item
291
- *
292
- * @param {Boolean} [allOwnKeys = false]
293
- * @returns {any}
294
- */
295
- function forEach(obj, fn, {allOwnKeys = false} = {}) {
296
- // Don't bother if no value provided
297
- if (obj === null || typeof obj === 'undefined') {
298
- return;
299
- }
300
-
301
- let i;
302
- let l;
303
-
304
- // Force an array if not already something iterable
305
- if (typeof obj !== 'object') {
306
- /*eslint no-param-reassign:0*/
307
- obj = [obj];
308
- }
309
-
310
- if (isArray(obj)) {
311
- // Iterate over array values
312
- for (i = 0, l = obj.length; i < l; i++) {
313
- fn.call(null, obj[i], i, obj);
314
- }
315
- } else {
316
- // Iterate over object keys
317
- const keys = allOwnKeys ? Object.getOwnPropertyNames(obj) : Object.keys(obj);
318
- const len = keys.length;
319
- let key;
320
-
321
- for (i = 0; i < len; i++) {
322
- key = keys[i];
323
- fn.call(null, obj[key], key, obj);
324
- }
325
- }
326
- }
327
-
328
- function findKey(obj, key) {
329
- key = key.toLowerCase();
330
- const keys = Object.keys(obj);
331
- let i = keys.length;
332
- let _key;
333
- while (i-- > 0) {
334
- _key = keys[i];
335
- if (key === _key.toLowerCase()) {
336
- return _key;
337
- }
338
- }
339
- return null;
340
- }
341
-
342
- const _global = (() => {
343
- /*eslint no-undef:0*/
344
- if (typeof globalThis !== "undefined") return globalThis;
345
- return typeof self !== "undefined" ? self : (typeof window !== 'undefined' ? window : global)
346
- })();
347
-
348
- const isContextDefined = (context) => !isUndefined(context) && context !== _global;
349
-
350
- /**
351
- * Accepts varargs expecting each argument to be an object, then
352
- * immutably merges the properties of each object and returns result.
353
- *
354
- * When multiple objects contain the same key the later object in
355
- * the arguments list will take precedence.
356
- *
357
- * Example:
358
- *
359
- * ```js
360
- * var result = merge({foo: 123}, {foo: 456});
361
- * console.log(result.foo); // outputs 456
362
- * ```
363
- *
364
- * @param {Object} obj1 Object to merge
365
- *
366
- * @returns {Object} Result of all merge properties
367
- */
368
- function merge(/* obj1, obj2, obj3, ... */) {
369
- const {caseless} = isContextDefined(this) && this || {};
370
- const result = {};
371
- const assignValue = (val, key) => {
372
- const targetKey = caseless && findKey(result, key) || key;
373
- if (isPlainObject(result[targetKey]) && isPlainObject(val)) {
374
- result[targetKey] = merge(result[targetKey], val);
375
- } else if (isPlainObject(val)) {
376
- result[targetKey] = merge({}, val);
377
- } else if (isArray(val)) {
378
- result[targetKey] = val.slice();
379
- } else {
380
- result[targetKey] = val;
381
- }
382
- };
383
-
384
- for (let i = 0, l = arguments.length; i < l; i++) {
385
- arguments[i] && forEach(arguments[i], assignValue);
386
- }
387
- return result;
388
- }
389
-
390
- /**
391
- * Extends object a by mutably adding to it the properties of object b.
392
- *
393
- * @param {Object} a The object to be extended
394
- * @param {Object} b The object to copy properties from
395
- * @param {Object} thisArg The object to bind function to
396
- *
397
- * @param {Boolean} [allOwnKeys]
398
- * @returns {Object} The resulting value of object a
399
- */
400
- const extend = (a, b, thisArg, {allOwnKeys}= {}) => {
401
- forEach(b, (val, key) => {
402
- if (thisArg && isFunction(val)) {
403
- a[key] = bind(val, thisArg);
404
- } else {
405
- a[key] = val;
406
- }
407
- }, {allOwnKeys});
408
- return a;
409
- };
410
-
411
- /**
412
- * Remove byte order marker. This catches EF BB BF (the UTF-8 BOM)
413
- *
414
- * @param {string} content with BOM
415
- *
416
- * @returns {string} content value without BOM
417
- */
418
- const stripBOM = (content) => {
419
- if (content.charCodeAt(0) === 0xFEFF) {
420
- content = content.slice(1);
421
- }
422
- return content;
423
- };
424
-
425
- /**
426
- * Inherit the prototype methods from one constructor into another
427
- * @param {function} constructor
428
- * @param {function} superConstructor
429
- * @param {object} [props]
430
- * @param {object} [descriptors]
431
- *
432
- * @returns {void}
433
- */
434
- const inherits = (constructor, superConstructor, props, descriptors) => {
435
- constructor.prototype = Object.create(superConstructor.prototype, descriptors);
436
- constructor.prototype.constructor = constructor;
437
- Object.defineProperty(constructor, 'super', {
438
- value: superConstructor.prototype
439
- });
440
- props && Object.assign(constructor.prototype, props);
441
- };
442
-
443
- /**
444
- * Resolve object with deep prototype chain to a flat object
445
- * @param {Object} sourceObj source object
446
- * @param {Object} [destObj]
447
- * @param {Function|Boolean} [filter]
448
- * @param {Function} [propFilter]
449
- *
450
- * @returns {Object}
451
- */
452
- const toFlatObject = (sourceObj, destObj, filter, propFilter) => {
453
- let props;
454
- let i;
455
- let prop;
456
- const merged = {};
457
-
458
- destObj = destObj || {};
459
- // eslint-disable-next-line no-eq-null,eqeqeq
460
- if (sourceObj == null) return destObj;
461
-
462
- do {
463
- props = Object.getOwnPropertyNames(sourceObj);
464
- i = props.length;
465
- while (i-- > 0) {
466
- prop = props[i];
467
- if ((!propFilter || propFilter(prop, sourceObj, destObj)) && !merged[prop]) {
468
- destObj[prop] = sourceObj[prop];
469
- merged[prop] = true;
470
- }
471
- }
472
- sourceObj = filter !== false && getPrototypeOf(sourceObj);
473
- } while (sourceObj && (!filter || filter(sourceObj, destObj)) && sourceObj !== Object.prototype);
474
-
475
- return destObj;
476
- };
477
-
478
- /**
479
- * Determines whether a string ends with the characters of a specified string
480
- *
481
- * @param {String} str
482
- * @param {String} searchString
483
- * @param {Number} [position= 0]
484
- *
485
- * @returns {boolean}
486
- */
487
- const endsWith = (str, searchString, position) => {
488
- str = String(str);
489
- if (position === undefined || position > str.length) {
490
- position = str.length;
491
- }
492
- position -= searchString.length;
493
- const lastIndex = str.indexOf(searchString, position);
494
- return lastIndex !== -1 && lastIndex === position;
495
- };
496
-
497
-
498
- /**
499
- * Returns new array from array like object or null if failed
500
- *
501
- * @param {*} [thing]
502
- *
503
- * @returns {?Array}
504
- */
505
- const toArray = (thing) => {
506
- if (!thing) return null;
507
- if (isArray(thing)) return thing;
508
- let i = thing.length;
509
- if (!isNumber(i)) return null;
510
- const arr = new Array(i);
511
- while (i-- > 0) {
512
- arr[i] = thing[i];
513
- }
514
- return arr;
515
- };
516
-
517
- /**
518
- * Checking if the Uint8Array exists and if it does, it returns a function that checks if the
519
- * thing passed in is an instance of Uint8Array
520
- *
521
- * @param {TypedArray}
522
- *
523
- * @returns {Array}
524
- */
525
- // eslint-disable-next-line func-names
526
- const isTypedArray = (TypedArray => {
527
- // eslint-disable-next-line func-names
528
- return thing => {
529
- return TypedArray && thing instanceof TypedArray;
530
- };
531
- })(typeof Uint8Array !== 'undefined' && getPrototypeOf(Uint8Array));
532
-
533
- /**
534
- * For each entry in the object, call the function with the key and value.
535
- *
536
- * @param {Object<any, any>} obj - The object to iterate over.
537
- * @param {Function} fn - The function to call for each entry.
538
- *
539
- * @returns {void}
540
- */
541
- const forEachEntry = (obj, fn) => {
542
- const generator = obj && obj[Symbol.iterator];
543
-
544
- const iterator = generator.call(obj);
545
-
546
- let result;
547
-
548
- while ((result = iterator.next()) && !result.done) {
549
- const pair = result.value;
550
- fn.call(obj, pair[0], pair[1]);
551
- }
552
- };
553
-
554
- /**
555
- * It takes a regular expression and a string, and returns an array of all the matches
556
- *
557
- * @param {string} regExp - The regular expression to match against.
558
- * @param {string} str - The string to search.
559
- *
560
- * @returns {Array<boolean>}
561
- */
562
- const matchAll = (regExp, str) => {
563
- let matches;
564
- const arr = [];
565
-
566
- while ((matches = regExp.exec(str)) !== null) {
567
- arr.push(matches);
568
- }
569
-
570
- return arr;
571
- };
572
-
573
- /* Checking if the kindOfTest function returns true when passed an HTMLFormElement. */
574
- const isHTMLForm = kindOfTest('HTMLFormElement');
575
-
576
- const toCamelCase = str => {
577
- return str.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,
578
- function replacer(m, p1, p2) {
579
- return p1.toUpperCase() + p2;
580
- }
581
- );
582
- };
583
-
584
- /* Creating a function that will check if an object has a property. */
585
- const hasOwnProperty = (({hasOwnProperty}) => (obj, prop) => hasOwnProperty.call(obj, prop))(Object.prototype);
586
-
587
- /**
588
- * Determine if a value is a RegExp object
589
- *
590
- * @param {*} val The value to test
591
- *
592
- * @returns {boolean} True if value is a RegExp object, otherwise false
593
- */
594
- const isRegExp = kindOfTest('RegExp');
595
-
596
- const reduceDescriptors = (obj, reducer) => {
597
- const descriptors = Object.getOwnPropertyDescriptors(obj);
598
- const reducedDescriptors = {};
599
-
600
- forEach(descriptors, (descriptor, name) => {
601
- if (reducer(descriptor, name, obj) !== false) {
602
- reducedDescriptors[name] = descriptor;
603
- }
604
- });
605
-
606
- Object.defineProperties(obj, reducedDescriptors);
607
- };
608
-
609
- /**
610
- * Makes all methods read-only
611
- * @param {Object} obj
612
- */
613
-
614
- const freezeMethods = (obj) => {
615
- reduceDescriptors(obj, (descriptor, name) => {
616
- // skip restricted props in strict mode
617
- if (isFunction(obj) && ['arguments', 'caller', 'callee'].indexOf(name) !== -1) {
618
- return false;
619
- }
620
-
621
- const value = obj[name];
622
-
623
- if (!isFunction(value)) return;
624
-
625
- descriptor.enumerable = false;
626
-
627
- if ('writable' in descriptor) {
628
- descriptor.writable = false;
629
- return;
630
- }
631
-
632
- if (!descriptor.set) {
633
- descriptor.set = () => {
634
- throw Error('Can not rewrite read-only method \'' + name + '\'');
635
- };
636
- }
637
- });
638
- };
639
-
640
- const toObjectSet = (arrayOrString, delimiter) => {
641
- const obj = {};
642
-
643
- const define = (arr) => {
644
- arr.forEach(value => {
645
- obj[value] = true;
646
- });
647
- };
648
-
649
- isArray(arrayOrString) ? define(arrayOrString) : define(String(arrayOrString).split(delimiter));
650
-
651
- return obj;
652
- };
653
-
654
- const noop = () => {};
655
-
656
- const toFiniteNumber = (value, defaultValue) => {
657
- value = +value;
658
- return Number.isFinite(value) ? value : defaultValue;
659
- };
660
-
661
- const ALPHA = 'abcdefghijklmnopqrstuvwxyz';
662
-
663
- const DIGIT = '0123456789';
664
-
665
- const ALPHABET = {
666
- DIGIT,
667
- ALPHA,
668
- ALPHA_DIGIT: ALPHA + ALPHA.toUpperCase() + DIGIT
669
- };
670
-
671
- const generateString = (size = 16, alphabet = ALPHABET.ALPHA_DIGIT) => {
672
- let str = '';
673
- const {length} = alphabet;
674
- while (size--) {
675
- str += alphabet[Math.random() * length|0];
676
- }
677
-
678
- return str;
679
- };
680
-
681
- /**
682
- * If the thing is a FormData object, return true, otherwise return false.
683
- *
684
- * @param {unknown} thing - The thing to check.
685
- *
686
- * @returns {boolean}
687
- */
688
- function isSpecCompliantForm(thing) {
689
- return !!(thing && isFunction(thing.append) && thing[Symbol.toStringTag] === 'FormData' && thing[Symbol.iterator]);
690
- }
691
-
692
- const toJSONObject = (obj) => {
693
- const stack = new Array(10);
694
-
695
- const visit = (source, i) => {
696
-
697
- if (isObject(source)) {
698
- if (stack.indexOf(source) >= 0) {
699
- return;
700
- }
701
-
702
- if(!('toJSON' in source)) {
703
- stack[i] = source;
704
- const target = isArray(source) ? [] : {};
705
-
706
- forEach(source, (value, key) => {
707
- const reducedValue = visit(value, i + 1);
708
- !isUndefined(reducedValue) && (target[key] = reducedValue);
709
- });
710
-
711
- stack[i] = undefined;
712
-
713
- return target;
714
- }
715
- }
716
-
717
- return source;
718
- };
719
-
720
- return visit(obj, 0);
721
- };
722
-
723
- const isAsyncFn = kindOfTest('AsyncFunction');
724
-
725
- const isThenable = (thing) =>
726
- thing && (isObject(thing) || isFunction(thing)) && isFunction(thing.then) && isFunction(thing.catch);
727
-
728
- var utils = {
729
- isArray,
730
- isArrayBuffer,
731
- isBuffer,
732
- isFormData,
733
- isArrayBufferView,
734
- isString,
735
- isNumber,
736
- isBoolean,
737
- isObject,
738
- isPlainObject,
739
- isUndefined,
740
- isDate,
741
- isFile,
742
- isBlob,
743
- isRegExp,
744
- isFunction,
745
- isStream,
746
- isURLSearchParams,
747
- isTypedArray,
748
- isFileList,
749
- forEach,
750
- merge,
751
- extend,
752
- trim,
753
- stripBOM,
754
- inherits,
755
- toFlatObject,
756
- kindOf,
757
- kindOfTest,
758
- endsWith,
759
- toArray,
760
- forEachEntry,
761
- matchAll,
762
- isHTMLForm,
763
- hasOwnProperty,
764
- hasOwnProp: hasOwnProperty, // an alias to avoid ESLint no-prototype-builtins detection
765
- reduceDescriptors,
766
- freezeMethods,
767
- toObjectSet,
768
- toCamelCase,
769
- noop,
770
- toFiniteNumber,
771
- findKey,
772
- global: _global,
773
- isContextDefined,
774
- ALPHABET,
775
- generateString,
776
- isSpecCompliantForm,
777
- toJSONObject,
778
- isAsyncFn,
779
- isThenable
780
- };
781
-
782
- /**
783
- * Create an Error with the specified message, config, error code, request and response.
784
- *
785
- * @param {string} message The error message.
786
- * @param {string} [code] The error code (for example, 'ECONNABORTED').
787
- * @param {Object} [config] The config.
788
- * @param {Object} [request] The request.
789
- * @param {Object} [response] The response.
790
- *
791
- * @returns {Error} The created error.
792
- */
793
- function AxiosError(message, code, config, request, response) {
794
- Error.call(this);
795
-
796
- if (Error.captureStackTrace) {
797
- Error.captureStackTrace(this, this.constructor);
798
- } else {
799
- this.stack = (new Error()).stack;
800
- }
801
-
802
- this.message = message;
803
- this.name = 'AxiosError';
804
- code && (this.code = code);
805
- config && (this.config = config);
806
- request && (this.request = request);
807
- response && (this.response = response);
808
- }
809
-
810
- utils.inherits(AxiosError, Error, {
811
- toJSON: function toJSON() {
812
- return {
813
- // Standard
814
- message: this.message,
815
- name: this.name,
816
- // Microsoft
817
- description: this.description,
818
- number: this.number,
819
- // Mozilla
820
- fileName: this.fileName,
821
- lineNumber: this.lineNumber,
822
- columnNumber: this.columnNumber,
823
- stack: this.stack,
824
- // Axios
825
- config: utils.toJSONObject(this.config),
826
- code: this.code,
827
- status: this.response && this.response.status ? this.response.status : null
828
- };
829
- }
830
- });
831
-
832
- const prototype$1 = AxiosError.prototype;
833
- const descriptors = {};
834
-
835
- [
836
- 'ERR_BAD_OPTION_VALUE',
837
- 'ERR_BAD_OPTION',
838
- 'ECONNABORTED',
839
- 'ETIMEDOUT',
840
- 'ERR_NETWORK',
841
- 'ERR_FR_TOO_MANY_REDIRECTS',
842
- 'ERR_DEPRECATED',
843
- 'ERR_BAD_RESPONSE',
844
- 'ERR_BAD_REQUEST',
845
- 'ERR_CANCELED',
846
- 'ERR_NOT_SUPPORT',
847
- 'ERR_INVALID_URL'
848
- // eslint-disable-next-line func-names
849
- ].forEach(code => {
850
- descriptors[code] = {value: code};
851
- });
852
-
853
- Object.defineProperties(AxiosError, descriptors);
854
- Object.defineProperty(prototype$1, 'isAxiosError', {value: true});
855
-
856
- // eslint-disable-next-line func-names
857
- AxiosError.from = (error, code, config, request, response, customProps) => {
858
- const axiosError = Object.create(prototype$1);
859
-
860
- utils.toFlatObject(error, axiosError, function filter(obj) {
861
- return obj !== Error.prototype;
862
- }, prop => {
863
- return prop !== 'isAxiosError';
864
- });
865
-
866
- AxiosError.call(axiosError, error.message, code, config, request, response);
867
-
868
- axiosError.cause = error;
869
-
870
- axiosError.name = error.name;
871
-
872
- customProps && Object.assign(axiosError, customProps);
873
-
874
- return axiosError;
875
- };
876
-
877
- // eslint-disable-next-line strict
878
- var httpAdapter = null;
879
-
880
- /**
881
- * Determines if the given thing is a array or js object.
882
- *
883
- * @param {string} thing - The object or array to be visited.
884
- *
885
- * @returns {boolean}
886
- */
887
- function isVisitable(thing) {
888
- return utils.isPlainObject(thing) || utils.isArray(thing);
889
- }
890
-
891
- /**
892
- * It removes the brackets from the end of a string
893
- *
894
- * @param {string} key - The key of the parameter.
895
- *
896
- * @returns {string} the key without the brackets.
897
- */
898
- function removeBrackets(key) {
899
- return utils.endsWith(key, '[]') ? key.slice(0, -2) : key;
900
- }
901
-
902
- /**
903
- * It takes a path, a key, and a boolean, and returns a string
904
- *
905
- * @param {string} path - The path to the current key.
906
- * @param {string} key - The key of the current object being iterated over.
907
- * @param {string} dots - If true, the key will be rendered with dots instead of brackets.
908
- *
909
- * @returns {string} The path to the current key.
910
- */
911
- function renderKey(path, key, dots) {
912
- if (!path) return key;
913
- return path.concat(key).map(function each(token, i) {
914
- // eslint-disable-next-line no-param-reassign
915
- token = removeBrackets(token);
916
- return !dots && i ? '[' + token + ']' : token;
917
- }).join(dots ? '.' : '');
918
- }
919
-
920
- /**
921
- * If the array is an array and none of its elements are visitable, then it's a flat array.
922
- *
923
- * @param {Array<any>} arr - The array to check
924
- *
925
- * @returns {boolean}
926
- */
927
- function isFlatArray(arr) {
928
- return utils.isArray(arr) && !arr.some(isVisitable);
929
- }
930
-
931
- const predicates = utils.toFlatObject(utils, {}, null, function filter(prop) {
932
- return /^is[A-Z]/.test(prop);
933
- });
934
-
935
- /**
936
- * Convert a data object to FormData
937
- *
938
- * @param {Object} obj
939
- * @param {?Object} [formData]
940
- * @param {?Object} [options]
941
- * @param {Function} [options.visitor]
942
- * @param {Boolean} [options.metaTokens = true]
943
- * @param {Boolean} [options.dots = false]
944
- * @param {?Boolean} [options.indexes = false]
945
- *
946
- * @returns {Object}
947
- **/
948
-
949
- /**
950
- * It converts an object into a FormData object
951
- *
952
- * @param {Object<any, any>} obj - The object to convert to form data.
953
- * @param {string} formData - The FormData object to append to.
954
- * @param {Object<string, any>} options
955
- *
956
- * @returns
957
- */
958
- function toFormData(obj, formData, options) {
959
- if (!utils.isObject(obj)) {
960
- throw new TypeError('target must be an object');
961
- }
962
-
963
- // eslint-disable-next-line no-param-reassign
964
- formData = formData || new (FormData)();
965
-
966
- // eslint-disable-next-line no-param-reassign
967
- options = utils.toFlatObject(options, {
968
- metaTokens: true,
969
- dots: false,
970
- indexes: false
971
- }, false, function defined(option, source) {
972
- // eslint-disable-next-line no-eq-null,eqeqeq
973
- return !utils.isUndefined(source[option]);
974
- });
975
-
976
- const metaTokens = options.metaTokens;
977
- // eslint-disable-next-line no-use-before-define
978
- const visitor = options.visitor || defaultVisitor;
979
- const dots = options.dots;
980
- const indexes = options.indexes;
981
- const _Blob = options.Blob || typeof Blob !== 'undefined' && Blob;
982
- const useBlob = _Blob && utils.isSpecCompliantForm(formData);
983
-
984
- if (!utils.isFunction(visitor)) {
985
- throw new TypeError('visitor must be a function');
986
- }
987
-
988
- function convertValue(value) {
989
- if (value === null) return '';
990
-
991
- if (utils.isDate(value)) {
992
- return value.toISOString();
993
- }
994
-
995
- if (!useBlob && utils.isBlob(value)) {
996
- throw new AxiosError('Blob is not supported. Use a Buffer instead.');
997
- }
998
-
999
- if (utils.isArrayBuffer(value) || utils.isTypedArray(value)) {
1000
- return useBlob && typeof Blob === 'function' ? new Blob([value]) : Buffer.from(value);
1001
- }
1002
-
1003
- return value;
1004
- }
1005
-
1006
- /**
1007
- * Default visitor.
1008
- *
1009
- * @param {*} value
1010
- * @param {String|Number} key
1011
- * @param {Array<String|Number>} path
1012
- * @this {FormData}
1013
- *
1014
- * @returns {boolean} return true to visit the each prop of the value recursively
1015
- */
1016
- function defaultVisitor(value, key, path) {
1017
- let arr = value;
1018
-
1019
- if (value && !path && typeof value === 'object') {
1020
- if (utils.endsWith(key, '{}')) {
1021
- // eslint-disable-next-line no-param-reassign
1022
- key = metaTokens ? key : key.slice(0, -2);
1023
- // eslint-disable-next-line no-param-reassign
1024
- value = JSON.stringify(value);
1025
- } else if (
1026
- (utils.isArray(value) && isFlatArray(value)) ||
1027
- ((utils.isFileList(value) || utils.endsWith(key, '[]')) && (arr = utils.toArray(value))
1028
- )) {
1029
- // eslint-disable-next-line no-param-reassign
1030
- key = removeBrackets(key);
1031
-
1032
- arr.forEach(function each(el, index) {
1033
- !(utils.isUndefined(el) || el === null) && formData.append(
1034
- // eslint-disable-next-line no-nested-ternary
1035
- indexes === true ? renderKey([key], index, dots) : (indexes === null ? key : key + '[]'),
1036
- convertValue(el)
1037
- );
1038
- });
1039
- return false;
1040
- }
1041
- }
1042
-
1043
- if (isVisitable(value)) {
1044
- return true;
1045
- }
1046
-
1047
- formData.append(renderKey(path, key, dots), convertValue(value));
1048
-
1049
- return false;
1050
- }
1051
-
1052
- const stack = [];
1053
-
1054
- const exposedHelpers = Object.assign(predicates, {
1055
- defaultVisitor,
1056
- convertValue,
1057
- isVisitable
1058
- });
1059
-
1060
- function build(value, path) {
1061
- if (utils.isUndefined(value)) return;
1062
-
1063
- if (stack.indexOf(value) !== -1) {
1064
- throw Error('Circular reference detected in ' + path.join('.'));
1065
- }
1066
-
1067
- stack.push(value);
1068
-
1069
- utils.forEach(value, function each(el, key) {
1070
- const result = !(utils.isUndefined(el) || el === null) && visitor.call(
1071
- formData, el, utils.isString(key) ? key.trim() : key, path, exposedHelpers
1072
- );
1073
-
1074
- if (result === true) {
1075
- build(el, path ? path.concat(key) : [key]);
1076
- }
1077
- });
1078
-
1079
- stack.pop();
1080
- }
1081
-
1082
- if (!utils.isObject(obj)) {
1083
- throw new TypeError('data must be an object');
1084
- }
1085
-
1086
- build(obj);
1087
-
1088
- return formData;
1089
- }
1090
-
1091
- /**
1092
- * It encodes a string by replacing all characters that are not in the unreserved set with
1093
- * their percent-encoded equivalents
1094
- *
1095
- * @param {string} str - The string to encode.
1096
- *
1097
- * @returns {string} The encoded string.
1098
- */
1099
- function encode$1(str) {
1100
- const charMap = {
1101
- '!': '%21',
1102
- "'": '%27',
1103
- '(': '%28',
1104
- ')': '%29',
1105
- '~': '%7E',
1106
- '%20': '+',
1107
- '%00': '\x00'
1108
- };
1109
- return encodeURIComponent(str).replace(/[!'()~]|%20|%00/g, function replacer(match) {
1110
- return charMap[match];
1111
- });
1112
- }
1113
-
1114
- /**
1115
- * It takes a params object and converts it to a FormData object
1116
- *
1117
- * @param {Object<string, any>} params - The parameters to be converted to a FormData object.
1118
- * @param {Object<string, any>} options - The options object passed to the Axios constructor.
1119
- *
1120
- * @returns {void}
1121
- */
1122
- function AxiosURLSearchParams(params, options) {
1123
- this._pairs = [];
1124
-
1125
- params && toFormData(params, this, options);
1126
- }
1127
-
1128
- const prototype = AxiosURLSearchParams.prototype;
1129
-
1130
- prototype.append = function append(name, value) {
1131
- this._pairs.push([name, value]);
1132
- };
1133
-
1134
- prototype.toString = function toString(encoder) {
1135
- const _encode = encoder ? function(value) {
1136
- return encoder.call(this, value, encode$1);
1137
- } : encode$1;
1138
-
1139
- return this._pairs.map(function each(pair) {
1140
- return _encode(pair[0]) + '=' + _encode(pair[1]);
1141
- }, '').join('&');
1142
- };
1143
-
1144
- /**
1145
- * It replaces all instances of the characters `:`, `$`, `,`, `+`, `[`, and `]` with their
1146
- * URI encoded counterparts
1147
- *
1148
- * @param {string} val The value to be encoded.
1149
- *
1150
- * @returns {string} The encoded value.
1151
- */
1152
- function encode(val) {
1153
- return encodeURIComponent(val).
1154
- replace(/%3A/gi, ':').
1155
- replace(/%24/g, '$').
1156
- replace(/%2C/gi, ',').
1157
- replace(/%20/g, '+').
1158
- replace(/%5B/gi, '[').
1159
- replace(/%5D/gi, ']');
1160
- }
1161
-
1162
- /**
1163
- * Build a URL by appending params to the end
1164
- *
1165
- * @param {string} url The base of the url (e.g., http://www.google.com)
1166
- * @param {object} [params] The params to be appended
1167
- * @param {?object} options
1168
- *
1169
- * @returns {string} The formatted url
1170
- */
1171
- function buildURL(url, params, options) {
1172
- /*eslint no-param-reassign:0*/
1173
- if (!params) {
1174
- return url;
1175
- }
1176
-
1177
- const _encode = options && options.encode || encode;
1178
-
1179
- const serializeFn = options && options.serialize;
1180
-
1181
- let serializedParams;
1182
-
1183
- if (serializeFn) {
1184
- serializedParams = serializeFn(params, options);
1185
- } else {
1186
- serializedParams = utils.isURLSearchParams(params) ?
1187
- params.toString() :
1188
- new AxiosURLSearchParams(params, options).toString(_encode);
1189
- }
1190
-
1191
- if (serializedParams) {
1192
- const hashmarkIndex = url.indexOf("#");
1193
-
1194
- if (hashmarkIndex !== -1) {
1195
- url = url.slice(0, hashmarkIndex);
1196
- }
1197
- url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
1198
- }
1199
-
1200
- return url;
1201
- }
1202
-
1203
- class InterceptorManager {
1204
- constructor() {
1205
- this.handlers = [];
1206
- }
1207
-
1208
- /**
1209
- * Add a new interceptor to the stack
1210
- *
1211
- * @param {Function} fulfilled The function to handle `then` for a `Promise`
1212
- * @param {Function} rejected The function to handle `reject` for a `Promise`
1213
- *
1214
- * @return {Number} An ID used to remove interceptor later
1215
- */
1216
- use(fulfilled, rejected, options) {
1217
- this.handlers.push({
1218
- fulfilled,
1219
- rejected,
1220
- synchronous: options ? options.synchronous : false,
1221
- runWhen: options ? options.runWhen : null
1222
- });
1223
- return this.handlers.length - 1;
1224
- }
1225
-
1226
- /**
1227
- * Remove an interceptor from the stack
1228
- *
1229
- * @param {Number} id The ID that was returned by `use`
1230
- *
1231
- * @returns {Boolean} `true` if the interceptor was removed, `false` otherwise
1232
- */
1233
- eject(id) {
1234
- if (this.handlers[id]) {
1235
- this.handlers[id] = null;
1236
- }
1237
- }
1238
-
1239
- /**
1240
- * Clear all interceptors from the stack
1241
- *
1242
- * @returns {void}
1243
- */
1244
- clear() {
1245
- if (this.handlers) {
1246
- this.handlers = [];
1247
- }
1248
- }
1249
-
1250
- /**
1251
- * Iterate over all the registered interceptors
1252
- *
1253
- * This method is particularly useful for skipping over any
1254
- * interceptors that may have become `null` calling `eject`.
1255
- *
1256
- * @param {Function} fn The function to call for each interceptor
1257
- *
1258
- * @returns {void}
1259
- */
1260
- forEach(fn) {
1261
- utils.forEach(this.handlers, function forEachHandler(h) {
1262
- if (h !== null) {
1263
- fn(h);
1264
- }
1265
- });
1266
- }
1267
- }
1268
-
1269
- var InterceptorManager$1 = InterceptorManager;
1270
-
1271
- var transitionalDefaults = {
1272
- silentJSONParsing: true,
1273
- forcedJSONParsing: true,
1274
- clarifyTimeoutError: false
1275
- };
1276
-
1277
- var URLSearchParams$1 = typeof URLSearchParams !== 'undefined' ? URLSearchParams : AxiosURLSearchParams;
1278
-
1279
- var FormData$1 = typeof FormData !== 'undefined' ? FormData : null;
1280
-
1281
- var Blob$1 = typeof Blob !== 'undefined' ? Blob : null;
1282
-
1283
- /**
1284
- * Determine if we're running in a standard browser environment
1285
- *
1286
- * This allows axios to run in a web worker, and react-native.
1287
- * Both environments support XMLHttpRequest, but not fully standard globals.
1288
- *
1289
- * web workers:
1290
- * typeof window -> undefined
1291
- * typeof document -> undefined
1292
- *
1293
- * react-native:
1294
- * navigator.product -> 'ReactNative'
1295
- * nativescript
1296
- * navigator.product -> 'NativeScript' or 'NS'
1297
- *
1298
- * @returns {boolean}
1299
- */
1300
- const isStandardBrowserEnv = (() => {
1301
- let product;
1302
- if (typeof navigator !== 'undefined' && (
1303
- (product = navigator.product) === 'ReactNative' ||
1304
- product === 'NativeScript' ||
1305
- product === 'NS')
1306
- ) {
1307
- return false;
1308
- }
1309
-
1310
- return typeof window !== 'undefined' && typeof document !== 'undefined';
1311
- })();
1312
-
1313
- /**
1314
- * Determine if we're running in a standard browser webWorker environment
1315
- *
1316
- * Although the `isStandardBrowserEnv` method indicates that
1317
- * `allows axios to run in a web worker`, the WebWorker will still be
1318
- * filtered out due to its judgment standard
1319
- * `typeof window !== 'undefined' && typeof document !== 'undefined'`.
1320
- * This leads to a problem when axios post `FormData` in webWorker
1321
- */
1322
- const isStandardBrowserWebWorkerEnv = (() => {
1323
- return (
1324
- typeof WorkerGlobalScope !== 'undefined' &&
1325
- // eslint-disable-next-line no-undef
1326
- self instanceof WorkerGlobalScope &&
1327
- typeof self.importScripts === 'function'
1328
- );
1329
- })();
1330
-
1331
-
1332
- var platform = {
1333
- isBrowser: true,
1334
- classes: {
1335
- URLSearchParams: URLSearchParams$1,
1336
- FormData: FormData$1,
1337
- Blob: Blob$1
1338
- },
1339
- isStandardBrowserEnv,
1340
- isStandardBrowserWebWorkerEnv,
1341
- protocols: ['http', 'https', 'file', 'blob', 'url', 'data']
1342
- };
1343
-
1344
- function toURLEncodedForm(data, options) {
1345
- return toFormData(data, new platform.classes.URLSearchParams(), Object.assign({
1346
- visitor: function(value, key, path, helpers) {
1347
- if (platform.isNode && utils.isBuffer(value)) {
1348
- this.append(key, value.toString('base64'));
1349
- return false;
1350
- }
1351
-
1352
- return helpers.defaultVisitor.apply(this, arguments);
1353
- }
1354
- }, options));
1355
- }
1356
-
1357
- /**
1358
- * It takes a string like `foo[x][y][z]` and returns an array like `['foo', 'x', 'y', 'z']
1359
- *
1360
- * @param {string} name - The name of the property to get.
1361
- *
1362
- * @returns An array of strings.
1363
- */
1364
- function parsePropPath(name) {
1365
- // foo[x][y][z]
1366
- // foo.x.y.z
1367
- // foo-x-y-z
1368
- // foo x y z
1369
- return utils.matchAll(/\w+|\[(\w*)]/g, name).map(match => {
1370
- return match[0] === '[]' ? '' : match[1] || match[0];
1371
- });
1372
- }
1373
-
1374
- /**
1375
- * Convert an array to an object.
1376
- *
1377
- * @param {Array<any>} arr - The array to convert to an object.
1378
- *
1379
- * @returns An object with the same keys and values as the array.
1380
- */
1381
- function arrayToObject(arr) {
1382
- const obj = {};
1383
- const keys = Object.keys(arr);
1384
- let i;
1385
- const len = keys.length;
1386
- let key;
1387
- for (i = 0; i < len; i++) {
1388
- key = keys[i];
1389
- obj[key] = arr[key];
1390
- }
1391
- return obj;
1392
- }
1393
-
1394
- /**
1395
- * It takes a FormData object and returns a JavaScript object
1396
- *
1397
- * @param {string} formData The FormData object to convert to JSON.
1398
- *
1399
- * @returns {Object<string, any> | null} The converted object.
1400
- */
1401
- function formDataToJSON(formData) {
1402
- function buildPath(path, value, target, index) {
1403
- let name = path[index++];
1404
- const isNumericKey = Number.isFinite(+name);
1405
- const isLast = index >= path.length;
1406
- name = !name && utils.isArray(target) ? target.length : name;
1407
-
1408
- if (isLast) {
1409
- if (utils.hasOwnProp(target, name)) {
1410
- target[name] = [target[name], value];
1411
- } else {
1412
- target[name] = value;
1413
- }
1414
-
1415
- return !isNumericKey;
1416
- }
1417
-
1418
- if (!target[name] || !utils.isObject(target[name])) {
1419
- target[name] = [];
1420
- }
1421
-
1422
- const result = buildPath(path, value, target[name], index);
1423
-
1424
- if (result && utils.isArray(target[name])) {
1425
- target[name] = arrayToObject(target[name]);
1426
- }
1427
-
1428
- return !isNumericKey;
1429
- }
1430
-
1431
- if (utils.isFormData(formData) && utils.isFunction(formData.entries)) {
1432
- const obj = {};
1433
-
1434
- utils.forEachEntry(formData, (name, value) => {
1435
- buildPath(parsePropPath(name), value, obj, 0);
1436
- });
1437
-
1438
- return obj;
1439
- }
1440
-
1441
- return null;
1442
- }
1443
-
1444
- const DEFAULT_CONTENT_TYPE = {
1445
- 'Content-Type': undefined
1446
- };
1447
-
1448
- /**
1449
- * It takes a string, tries to parse it, and if it fails, it returns the stringified version
1450
- * of the input
1451
- *
1452
- * @param {any} rawValue - The value to be stringified.
1453
- * @param {Function} parser - A function that parses a string into a JavaScript object.
1454
- * @param {Function} encoder - A function that takes a value and returns a string.
1455
- *
1456
- * @returns {string} A stringified version of the rawValue.
1457
- */
1458
- function stringifySafely(rawValue, parser, encoder) {
1459
- if (utils.isString(rawValue)) {
1460
- try {
1461
- (parser || JSON.parse)(rawValue);
1462
- return utils.trim(rawValue);
1463
- } catch (e) {
1464
- if (e.name !== 'SyntaxError') {
1465
- throw e;
1466
- }
1467
- }
1468
- }
1469
-
1470
- return (encoder || JSON.stringify)(rawValue);
1471
- }
1472
-
1473
- const defaults = {
1474
-
1475
- transitional: transitionalDefaults,
1476
-
1477
- adapter: ['xhr', 'http'],
1478
-
1479
- transformRequest: [function transformRequest(data, headers) {
1480
- const contentType = headers.getContentType() || '';
1481
- const hasJSONContentType = contentType.indexOf('application/json') > -1;
1482
- const isObjectPayload = utils.isObject(data);
1483
-
1484
- if (isObjectPayload && utils.isHTMLForm(data)) {
1485
- data = new FormData(data);
1486
- }
1487
-
1488
- const isFormData = utils.isFormData(data);
1489
-
1490
- if (isFormData) {
1491
- if (!hasJSONContentType) {
1492
- return data;
1493
- }
1494
- return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
1495
- }
1496
-
1497
- if (utils.isArrayBuffer(data) ||
1498
- utils.isBuffer(data) ||
1499
- utils.isStream(data) ||
1500
- utils.isFile(data) ||
1501
- utils.isBlob(data)
1502
- ) {
1503
- return data;
1504
- }
1505
- if (utils.isArrayBufferView(data)) {
1506
- return data.buffer;
1507
- }
1508
- if (utils.isURLSearchParams(data)) {
1509
- headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
1510
- return data.toString();
1511
- }
1512
-
1513
- let isFileList;
1514
-
1515
- if (isObjectPayload) {
1516
- if (contentType.indexOf('application/x-www-form-urlencoded') > -1) {
1517
- return toURLEncodedForm(data, this.formSerializer).toString();
1518
- }
1519
-
1520
- if ((isFileList = utils.isFileList(data)) || contentType.indexOf('multipart/form-data') > -1) {
1521
- const _FormData = this.env && this.env.FormData;
1522
-
1523
- return toFormData(
1524
- isFileList ? {'files[]': data} : data,
1525
- _FormData && new _FormData(),
1526
- this.formSerializer
1527
- );
1528
- }
1529
- }
1530
-
1531
- if (isObjectPayload || hasJSONContentType ) {
1532
- headers.setContentType('application/json', false);
1533
- return stringifySafely(data);
1534
- }
1535
-
1536
- return data;
1537
- }],
1538
-
1539
- transformResponse: [function transformResponse(data) {
1540
- const transitional = this.transitional || defaults.transitional;
1541
- const forcedJSONParsing = transitional && transitional.forcedJSONParsing;
1542
- const JSONRequested = this.responseType === 'json';
1543
-
1544
- if (data && utils.isString(data) && ((forcedJSONParsing && !this.responseType) || JSONRequested)) {
1545
- const silentJSONParsing = transitional && transitional.silentJSONParsing;
1546
- const strictJSONParsing = !silentJSONParsing && JSONRequested;
1547
-
1548
- try {
1549
- return JSON.parse(data);
1550
- } catch (e) {
1551
- if (strictJSONParsing) {
1552
- if (e.name === 'SyntaxError') {
1553
- throw AxiosError.from(e, AxiosError.ERR_BAD_RESPONSE, this, null, this.response);
1554
- }
1555
- throw e;
1556
- }
1557
- }
1558
- }
1559
-
1560
- return data;
1561
- }],
1562
-
1563
- /**
1564
- * A timeout in milliseconds to abort a request. If set to 0 (default) a
1565
- * timeout is not created.
1566
- */
1567
- timeout: 0,
1568
-
1569
- xsrfCookieName: 'XSRF-TOKEN',
1570
- xsrfHeaderName: 'X-XSRF-TOKEN',
1571
-
1572
- maxContentLength: -1,
1573
- maxBodyLength: -1,
1574
-
1575
- env: {
1576
- FormData: platform.classes.FormData,
1577
- Blob: platform.classes.Blob
1578
- },
1579
-
1580
- validateStatus: function validateStatus(status) {
1581
- return status >= 200 && status < 300;
1582
- },
1583
-
1584
- headers: {
1585
- common: {
1586
- 'Accept': 'application/json, text/plain, */*'
1587
- }
1588
- }
1589
- };
1590
-
1591
- utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
1592
- defaults.headers[method] = {};
1593
- });
1594
-
1595
- utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
1596
- defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
1597
- });
1598
-
1599
- var defaults$1 = defaults;
1600
-
1601
- // RawAxiosHeaders whose duplicates are ignored by node
1602
- // c.f. https://nodejs.org/api/http.html#http_message_headers
1603
- const ignoreDuplicateOf = utils.toObjectSet([
1604
- 'age', 'authorization', 'content-length', 'content-type', 'etag',
1605
- 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',
1606
- 'last-modified', 'location', 'max-forwards', 'proxy-authorization',
1607
- 'referer', 'retry-after', 'user-agent'
1608
- ]);
1609
-
1610
- /**
1611
- * Parse headers into an object
1612
- *
1613
- * ```
1614
- * Date: Wed, 27 Aug 2014 08:58:49 GMT
1615
- * Content-Type: application/json
1616
- * Connection: keep-alive
1617
- * Transfer-Encoding: chunked
1618
- * ```
1619
- *
1620
- * @param {String} rawHeaders Headers needing to be parsed
1621
- *
1622
- * @returns {Object} Headers parsed into an object
1623
- */
1624
- var parseHeaders = rawHeaders => {
1625
- const parsed = {};
1626
- let key;
1627
- let val;
1628
- let i;
1629
-
1630
- rawHeaders && rawHeaders.split('\n').forEach(function parser(line) {
1631
- i = line.indexOf(':');
1632
- key = line.substring(0, i).trim().toLowerCase();
1633
- val = line.substring(i + 1).trim();
1634
-
1635
- if (!key || (parsed[key] && ignoreDuplicateOf[key])) {
1636
- return;
1637
- }
1638
-
1639
- if (key === 'set-cookie') {
1640
- if (parsed[key]) {
1641
- parsed[key].push(val);
1642
- } else {
1643
- parsed[key] = [val];
1644
- }
1645
- } else {
1646
- parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
1647
- }
1648
- });
1649
-
1650
- return parsed;
1651
- };
1652
-
1653
- const $internals = Symbol('internals');
1654
-
1655
- function normalizeHeader(header) {
1656
- return header && String(header).trim().toLowerCase();
1657
- }
1658
-
1659
- function normalizeValue(value) {
1660
- if (value === false || value == null) {
1661
- return value;
1662
- }
1663
-
1664
- return utils.isArray(value) ? value.map(normalizeValue) : String(value);
1665
- }
1666
-
1667
- function parseTokens(str) {
1668
- const tokens = Object.create(null);
1669
- const tokensRE = /([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;
1670
- let match;
1671
-
1672
- while ((match = tokensRE.exec(str))) {
1673
- tokens[match[1]] = match[2];
1674
- }
1675
-
1676
- return tokens;
1677
- }
1678
-
1679
- const isValidHeaderName = (str) => /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(str.trim());
1680
-
1681
- function matchHeaderValue(context, value, header, filter, isHeaderNameFilter) {
1682
- if (utils.isFunction(filter)) {
1683
- return filter.call(this, value, header);
1684
- }
1685
-
1686
- if (isHeaderNameFilter) {
1687
- value = header;
1688
- }
1689
-
1690
- if (!utils.isString(value)) return;
1691
-
1692
- if (utils.isString(filter)) {
1693
- return value.indexOf(filter) !== -1;
1694
- }
1695
-
1696
- if (utils.isRegExp(filter)) {
1697
- return filter.test(value);
1698
- }
1699
- }
1700
-
1701
- function formatHeader(header) {
1702
- return header.trim()
1703
- .toLowerCase().replace(/([a-z\d])(\w*)/g, (w, char, str) => {
1704
- return char.toUpperCase() + str;
1705
- });
1706
- }
1707
-
1708
- function buildAccessors(obj, header) {
1709
- const accessorName = utils.toCamelCase(' ' + header);
1710
-
1711
- ['get', 'set', 'has'].forEach(methodName => {
1712
- Object.defineProperty(obj, methodName + accessorName, {
1713
- value: function(arg1, arg2, arg3) {
1714
- return this[methodName].call(this, header, arg1, arg2, arg3);
1715
- },
1716
- configurable: true
1717
- });
1718
- });
1719
- }
1720
-
1721
- class AxiosHeaders {
1722
- constructor(headers) {
1723
- headers && this.set(headers);
1724
- }
1725
-
1726
- set(header, valueOrRewrite, rewrite) {
1727
- const self = this;
1728
-
1729
- function setHeader(_value, _header, _rewrite) {
1730
- const lHeader = normalizeHeader(_header);
1731
-
1732
- if (!lHeader) {
1733
- throw new Error('header name must be a non-empty string');
1734
- }
1735
-
1736
- const key = utils.findKey(self, lHeader);
1737
-
1738
- if(!key || self[key] === undefined || _rewrite === true || (_rewrite === undefined && self[key] !== false)) {
1739
- self[key || _header] = normalizeValue(_value);
1740
- }
1741
- }
1742
-
1743
- const setHeaders = (headers, _rewrite) =>
1744
- utils.forEach(headers, (_value, _header) => setHeader(_value, _header, _rewrite));
1745
-
1746
- if (utils.isPlainObject(header) || header instanceof this.constructor) {
1747
- setHeaders(header, valueOrRewrite);
1748
- } else if(utils.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
1749
- setHeaders(parseHeaders(header), valueOrRewrite);
1750
- } else {
1751
- header != null && setHeader(valueOrRewrite, header, rewrite);
1752
- }
1753
-
1754
- return this;
1755
- }
1756
-
1757
- get(header, parser) {
1758
- header = normalizeHeader(header);
1759
-
1760
- if (header) {
1761
- const key = utils.findKey(this, header);
1762
-
1763
- if (key) {
1764
- const value = this[key];
1765
-
1766
- if (!parser) {
1767
- return value;
1768
- }
1769
-
1770
- if (parser === true) {
1771
- return parseTokens(value);
1772
- }
1773
-
1774
- if (utils.isFunction(parser)) {
1775
- return parser.call(this, value, key);
1776
- }
1777
-
1778
- if (utils.isRegExp(parser)) {
1779
- return parser.exec(value);
1780
- }
1781
-
1782
- throw new TypeError('parser must be boolean|regexp|function');
1783
- }
1784
- }
1785
- }
1786
-
1787
- has(header, matcher) {
1788
- header = normalizeHeader(header);
1789
-
1790
- if (header) {
1791
- const key = utils.findKey(this, header);
1792
-
1793
- return !!(key && this[key] !== undefined && (!matcher || matchHeaderValue(this, this[key], key, matcher)));
1794
- }
1795
-
1796
- return false;
1797
- }
1798
-
1799
- delete(header, matcher) {
1800
- const self = this;
1801
- let deleted = false;
1802
-
1803
- function deleteHeader(_header) {
1804
- _header = normalizeHeader(_header);
1805
-
1806
- if (_header) {
1807
- const key = utils.findKey(self, _header);
1808
-
1809
- if (key && (!matcher || matchHeaderValue(self, self[key], key, matcher))) {
1810
- delete self[key];
1811
-
1812
- deleted = true;
1813
- }
1814
- }
1815
- }
1816
-
1817
- if (utils.isArray(header)) {
1818
- header.forEach(deleteHeader);
1819
- } else {
1820
- deleteHeader(header);
1821
- }
1822
-
1823
- return deleted;
1824
- }
1825
-
1826
- clear(matcher) {
1827
- const keys = Object.keys(this);
1828
- let i = keys.length;
1829
- let deleted = false;
1830
-
1831
- while (i--) {
1832
- const key = keys[i];
1833
- if(!matcher || matchHeaderValue(this, this[key], key, matcher, true)) {
1834
- delete this[key];
1835
- deleted = true;
1836
- }
1837
- }
1838
-
1839
- return deleted;
1840
- }
1841
-
1842
- normalize(format) {
1843
- const self = this;
1844
- const headers = {};
1845
-
1846
- utils.forEach(this, (value, header) => {
1847
- const key = utils.findKey(headers, header);
1848
-
1849
- if (key) {
1850
- self[key] = normalizeValue(value);
1851
- delete self[header];
1852
- return;
1853
- }
1854
-
1855
- const normalized = format ? formatHeader(header) : String(header).trim();
1856
-
1857
- if (normalized !== header) {
1858
- delete self[header];
1859
- }
1860
-
1861
- self[normalized] = normalizeValue(value);
1862
-
1863
- headers[normalized] = true;
1864
- });
1865
-
1866
- return this;
1867
- }
1868
-
1869
- concat(...targets) {
1870
- return this.constructor.concat(this, ...targets);
1871
- }
1872
-
1873
- toJSON(asStrings) {
1874
- const obj = Object.create(null);
1875
-
1876
- utils.forEach(this, (value, header) => {
1877
- value != null && value !== false && (obj[header] = asStrings && utils.isArray(value) ? value.join(', ') : value);
1878
- });
1879
-
1880
- return obj;
1881
- }
1882
-
1883
- [Symbol.iterator]() {
1884
- return Object.entries(this.toJSON())[Symbol.iterator]();
1885
- }
1886
-
1887
- toString() {
1888
- return Object.entries(this.toJSON()).map(([header, value]) => header + ': ' + value).join('\n');
1889
- }
1890
-
1891
- get [Symbol.toStringTag]() {
1892
- return 'AxiosHeaders';
1893
- }
1894
-
1895
- static from(thing) {
1896
- return thing instanceof this ? thing : new this(thing);
1897
- }
1898
-
1899
- static concat(first, ...targets) {
1900
- const computed = new this(first);
1901
-
1902
- targets.forEach((target) => computed.set(target));
1903
-
1904
- return computed;
1905
- }
1906
-
1907
- static accessor(header) {
1908
- const internals = this[$internals] = (this[$internals] = {
1909
- accessors: {}
1910
- });
1911
-
1912
- const accessors = internals.accessors;
1913
- const prototype = this.prototype;
1914
-
1915
- function defineAccessor(_header) {
1916
- const lHeader = normalizeHeader(_header);
1917
-
1918
- if (!accessors[lHeader]) {
1919
- buildAccessors(prototype, _header);
1920
- accessors[lHeader] = true;
1921
- }
1922
- }
1923
-
1924
- utils.isArray(header) ? header.forEach(defineAccessor) : defineAccessor(header);
1925
-
1926
- return this;
1927
- }
1928
- }
1929
-
1930
- AxiosHeaders.accessor(['Content-Type', 'Content-Length', 'Accept', 'Accept-Encoding', 'User-Agent', 'Authorization']);
1931
-
1932
- utils.freezeMethods(AxiosHeaders.prototype);
1933
- utils.freezeMethods(AxiosHeaders);
1934
-
1935
- var AxiosHeaders$1 = AxiosHeaders;
1936
-
1937
- /**
1938
- * Transform the data for a request or a response
1939
- *
1940
- * @param {Array|Function} fns A single function or Array of functions
1941
- * @param {?Object} response The response object
1942
- *
1943
- * @returns {*} The resulting transformed data
1944
- */
1945
- function transformData(fns, response) {
1946
- const config = this || defaults$1;
1947
- const context = response || config;
1948
- const headers = AxiosHeaders$1.from(context.headers);
1949
- let data = context.data;
1950
-
1951
- utils.forEach(fns, function transform(fn) {
1952
- data = fn.call(config, data, headers.normalize(), response ? response.status : undefined);
1953
- });
1954
-
1955
- headers.normalize();
1956
-
1957
- return data;
1958
- }
1959
-
1960
- function isCancel(value) {
1961
- return !!(value && value.__CANCEL__);
1962
- }
1963
-
1964
- /**
1965
- * A `CanceledError` is an object that is thrown when an operation is canceled.
1966
- *
1967
- * @param {string=} message The message.
1968
- * @param {Object=} config The config.
1969
- * @param {Object=} request The request.
1970
- *
1971
- * @returns {CanceledError} The created error.
1972
- */
1973
- function CanceledError(message, config, request) {
1974
- // eslint-disable-next-line no-eq-null,eqeqeq
1975
- AxiosError.call(this, message == null ? 'canceled' : message, AxiosError.ERR_CANCELED, config, request);
1976
- this.name = 'CanceledError';
1977
- }
1978
-
1979
- utils.inherits(CanceledError, AxiosError, {
1980
- __CANCEL__: true
1981
- });
1982
-
1983
- /**
1984
- * Resolve or reject a Promise based on response status.
1985
- *
1986
- * @param {Function} resolve A function that resolves the promise.
1987
- * @param {Function} reject A function that rejects the promise.
1988
- * @param {object} response The response.
1989
- *
1990
- * @returns {object} The response.
1991
- */
1992
- function settle(resolve, reject, response) {
1993
- const validateStatus = response.config.validateStatus;
1994
- if (!response.status || !validateStatus || validateStatus(response.status)) {
1995
- resolve(response);
1996
- } else {
1997
- reject(new AxiosError(
1998
- 'Request failed with status code ' + response.status,
1999
- [AxiosError.ERR_BAD_REQUEST, AxiosError.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4],
2000
- response.config,
2001
- response.request,
2002
- response
2003
- ));
2004
- }
2005
- }
2006
-
2007
- var cookies = platform.isStandardBrowserEnv ?
2008
-
2009
- // Standard browser envs support document.cookie
2010
- (function standardBrowserEnv() {
2011
- return {
2012
- write: function write(name, value, expires, path, domain, secure) {
2013
- const cookie = [];
2014
- cookie.push(name + '=' + encodeURIComponent(value));
2015
-
2016
- if (utils.isNumber(expires)) {
2017
- cookie.push('expires=' + new Date(expires).toGMTString());
2018
- }
2019
-
2020
- if (utils.isString(path)) {
2021
- cookie.push('path=' + path);
2022
- }
2023
-
2024
- if (utils.isString(domain)) {
2025
- cookie.push('domain=' + domain);
2026
- }
2027
-
2028
- if (secure === true) {
2029
- cookie.push('secure');
2030
- }
2031
-
2032
- document.cookie = cookie.join('; ');
2033
- },
2034
-
2035
- read: function read(name) {
2036
- const match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
2037
- return (match ? decodeURIComponent(match[3]) : null);
2038
- },
2039
-
2040
- remove: function remove(name) {
2041
- this.write(name, '', Date.now() - 86400000);
2042
- }
2043
- };
2044
- })() :
2045
-
2046
- // Non standard browser env (web workers, react-native) lack needed support.
2047
- (function nonStandardBrowserEnv() {
2048
- return {
2049
- write: function write() {},
2050
- read: function read() { return null; },
2051
- remove: function remove() {}
2052
- };
2053
- })();
2054
-
2055
- /**
2056
- * Determines whether the specified URL is absolute
2057
- *
2058
- * @param {string} url The URL to test
2059
- *
2060
- * @returns {boolean} True if the specified URL is absolute, otherwise false
2061
- */
2062
- function isAbsoluteURL(url) {
2063
- // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
2064
- // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
2065
- // by any combination of letters, digits, plus, period, or hyphen.
2066
- return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
2067
- }
2068
-
2069
- /**
2070
- * Creates a new URL by combining the specified URLs
2071
- *
2072
- * @param {string} baseURL The base URL
2073
- * @param {string} relativeURL The relative URL
2074
- *
2075
- * @returns {string} The combined URL
2076
- */
2077
- function combineURLs(baseURL, relativeURL) {
2078
- return relativeURL
2079
- ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '')
2080
- : baseURL;
2081
- }
2082
-
2083
- /**
2084
- * Creates a new URL by combining the baseURL with the requestedURL,
2085
- * only when the requestedURL is not already an absolute URL.
2086
- * If the requestURL is absolute, this function returns the requestedURL untouched.
2087
- *
2088
- * @param {string} baseURL The base URL
2089
- * @param {string} requestedURL Absolute or relative URL to combine
2090
- *
2091
- * @returns {string} The combined full path
2092
- */
2093
- function buildFullPath(baseURL, requestedURL) {
2094
- if (baseURL && !isAbsoluteURL(requestedURL)) {
2095
- return combineURLs(baseURL, requestedURL);
2096
- }
2097
- return requestedURL;
2098
- }
2099
-
2100
- var isURLSameOrigin = platform.isStandardBrowserEnv ?
2101
-
2102
- // Standard browser envs have full support of the APIs needed to test
2103
- // whether the request URL is of the same origin as current location.
2104
- (function standardBrowserEnv() {
2105
- const msie = /(msie|trident)/i.test(navigator.userAgent);
2106
- const urlParsingNode = document.createElement('a');
2107
- let originURL;
2108
-
2109
- /**
2110
- * Parse a URL to discover it's components
2111
- *
2112
- * @param {String} url The URL to be parsed
2113
- * @returns {Object}
2114
- */
2115
- function resolveURL(url) {
2116
- let href = url;
2117
-
2118
- if (msie) {
2119
- // IE needs attribute set twice to normalize properties
2120
- urlParsingNode.setAttribute('href', href);
2121
- href = urlParsingNode.href;
2122
- }
2123
-
2124
- urlParsingNode.setAttribute('href', href);
2125
-
2126
- // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
2127
- return {
2128
- href: urlParsingNode.href,
2129
- protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
2130
- host: urlParsingNode.host,
2131
- search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
2132
- hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
2133
- hostname: urlParsingNode.hostname,
2134
- port: urlParsingNode.port,
2135
- pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
2136
- urlParsingNode.pathname :
2137
- '/' + urlParsingNode.pathname
2138
- };
2139
- }
2140
-
2141
- originURL = resolveURL(window.location.href);
2142
-
2143
- /**
2144
- * Determine if a URL shares the same origin as the current location
2145
- *
2146
- * @param {String} requestURL The URL to test
2147
- * @returns {boolean} True if URL shares the same origin, otherwise false
2148
- */
2149
- return function isURLSameOrigin(requestURL) {
2150
- const parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
2151
- return (parsed.protocol === originURL.protocol &&
2152
- parsed.host === originURL.host);
2153
- };
2154
- })() :
2155
-
2156
- // Non standard browser envs (web workers, react-native) lack needed support.
2157
- (function nonStandardBrowserEnv() {
2158
- return function isURLSameOrigin() {
2159
- return true;
2160
- };
2161
- })();
2162
-
2163
- function parseProtocol(url) {
2164
- const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
2165
- return match && match[1] || '';
2166
- }
2167
-
2168
- /**
2169
- * Calculate data maxRate
2170
- * @param {Number} [samplesCount= 10]
2171
- * @param {Number} [min= 1000]
2172
- * @returns {Function}
2173
- */
2174
- function speedometer(samplesCount, min) {
2175
- samplesCount = samplesCount || 10;
2176
- const bytes = new Array(samplesCount);
2177
- const timestamps = new Array(samplesCount);
2178
- let head = 0;
2179
- let tail = 0;
2180
- let firstSampleTS;
2181
-
2182
- min = min !== undefined ? min : 1000;
2183
-
2184
- return function push(chunkLength) {
2185
- const now = Date.now();
2186
-
2187
- const startedAt = timestamps[tail];
2188
-
2189
- if (!firstSampleTS) {
2190
- firstSampleTS = now;
2191
- }
2192
-
2193
- bytes[head] = chunkLength;
2194
- timestamps[head] = now;
2195
-
2196
- let i = tail;
2197
- let bytesCount = 0;
2198
-
2199
- while (i !== head) {
2200
- bytesCount += bytes[i++];
2201
- i = i % samplesCount;
2202
- }
2203
-
2204
- head = (head + 1) % samplesCount;
2205
-
2206
- if (head === tail) {
2207
- tail = (tail + 1) % samplesCount;
2208
- }
2209
-
2210
- if (now - firstSampleTS < min) {
2211
- return;
2212
- }
2213
-
2214
- const passed = startedAt && now - startedAt;
2215
-
2216
- return passed ? Math.round(bytesCount * 1000 / passed) : undefined;
2217
- };
2218
- }
2219
-
2220
- function progressEventReducer(listener, isDownloadStream) {
2221
- let bytesNotified = 0;
2222
- const _speedometer = speedometer(50, 250);
2223
-
2224
- return e => {
2225
- const loaded = e.loaded;
2226
- const total = e.lengthComputable ? e.total : undefined;
2227
- const progressBytes = loaded - bytesNotified;
2228
- const rate = _speedometer(progressBytes);
2229
- const inRange = loaded <= total;
2230
-
2231
- bytesNotified = loaded;
2232
-
2233
- const data = {
2234
- loaded,
2235
- total,
2236
- progress: total ? (loaded / total) : undefined,
2237
- bytes: progressBytes,
2238
- rate: rate ? rate : undefined,
2239
- estimated: rate && total && inRange ? (total - loaded) / rate : undefined,
2240
- event: e
2241
- };
2242
-
2243
- data[isDownloadStream ? 'download' : 'upload'] = true;
2244
-
2245
- listener(data);
2246
- };
2247
- }
2248
-
2249
- const isXHRAdapterSupported = typeof XMLHttpRequest !== 'undefined';
2250
-
2251
- var xhrAdapter = isXHRAdapterSupported && function (config) {
2252
- return new Promise(function dispatchXhrRequest(resolve, reject) {
2253
- let requestData = config.data;
2254
- const requestHeaders = AxiosHeaders$1.from(config.headers).normalize();
2255
- const responseType = config.responseType;
2256
- let onCanceled;
2257
- function done() {
2258
- if (config.cancelToken) {
2259
- config.cancelToken.unsubscribe(onCanceled);
2260
- }
2261
-
2262
- if (config.signal) {
2263
- config.signal.removeEventListener('abort', onCanceled);
2264
- }
2265
- }
2266
-
2267
- if (utils.isFormData(requestData)) {
2268
- if (platform.isStandardBrowserEnv || platform.isStandardBrowserWebWorkerEnv) {
2269
- requestHeaders.setContentType(false); // Let the browser set it
2270
- } else {
2271
- requestHeaders.setContentType('multipart/form-data;', false); // mobile/desktop app frameworks
2272
- }
2273
- }
2274
-
2275
- let request = new XMLHttpRequest();
2276
-
2277
- // HTTP basic authentication
2278
- if (config.auth) {
2279
- const username = config.auth.username || '';
2280
- const password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : '';
2281
- requestHeaders.set('Authorization', 'Basic ' + btoa(username + ':' + password));
2282
- }
2283
-
2284
- const fullPath = buildFullPath(config.baseURL, config.url);
2285
-
2286
- request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true);
2287
-
2288
- // Set the request timeout in MS
2289
- request.timeout = config.timeout;
2290
-
2291
- function onloadend() {
2292
- if (!request) {
2293
- return;
2294
- }
2295
- // Prepare the response
2296
- const responseHeaders = AxiosHeaders$1.from(
2297
- 'getAllResponseHeaders' in request && request.getAllResponseHeaders()
2298
- );
2299
- const responseData = !responseType || responseType === 'text' || responseType === 'json' ?
2300
- request.responseText : request.response;
2301
- const response = {
2302
- data: responseData,
2303
- status: request.status,
2304
- statusText: request.statusText,
2305
- headers: responseHeaders,
2306
- config,
2307
- request
2308
- };
2309
-
2310
- settle(function _resolve(value) {
2311
- resolve(value);
2312
- done();
2313
- }, function _reject(err) {
2314
- reject(err);
2315
- done();
2316
- }, response);
2317
-
2318
- // Clean up request
2319
- request = null;
2320
- }
2321
-
2322
- if ('onloadend' in request) {
2323
- // Use onloadend if available
2324
- request.onloadend = onloadend;
2325
- } else {
2326
- // Listen for ready state to emulate onloadend
2327
- request.onreadystatechange = function handleLoad() {
2328
- if (!request || request.readyState !== 4) {
2329
- return;
2330
- }
2331
-
2332
- // The request errored out and we didn't get a response, this will be
2333
- // handled by onerror instead
2334
- // With one exception: request that using file: protocol, most browsers
2335
- // will return status as 0 even though it's a successful request
2336
- if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
2337
- return;
2338
- }
2339
- // readystate handler is calling before onerror or ontimeout handlers,
2340
- // so we should call onloadend on the next 'tick'
2341
- setTimeout(onloadend);
2342
- };
2343
- }
2344
-
2345
- // Handle browser request cancellation (as opposed to a manual cancellation)
2346
- request.onabort = function handleAbort() {
2347
- if (!request) {
2348
- return;
2349
- }
2350
-
2351
- reject(new AxiosError('Request aborted', AxiosError.ECONNABORTED, config, request));
2352
-
2353
- // Clean up request
2354
- request = null;
2355
- };
2356
-
2357
- // Handle low level network errors
2358
- request.onerror = function handleError() {
2359
- // Real errors are hidden from us by the browser
2360
- // onerror should only fire if it's a network error
2361
- reject(new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request));
2362
-
2363
- // Clean up request
2364
- request = null;
2365
- };
2366
-
2367
- // Handle timeout
2368
- request.ontimeout = function handleTimeout() {
2369
- let timeoutErrorMessage = config.timeout ? 'timeout of ' + config.timeout + 'ms exceeded' : 'timeout exceeded';
2370
- const transitional = config.transitional || transitionalDefaults;
2371
- if (config.timeoutErrorMessage) {
2372
- timeoutErrorMessage = config.timeoutErrorMessage;
2373
- }
2374
- reject(new AxiosError(
2375
- timeoutErrorMessage,
2376
- transitional.clarifyTimeoutError ? AxiosError.ETIMEDOUT : AxiosError.ECONNABORTED,
2377
- config,
2378
- request));
2379
-
2380
- // Clean up request
2381
- request = null;
2382
- };
2383
-
2384
- // Add xsrf header
2385
- // This is only done if running in a standard browser environment.
2386
- // Specifically not if we're in a web worker, or react-native.
2387
- if (platform.isStandardBrowserEnv) {
2388
- // Add xsrf header
2389
- const xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath))
2390
- && config.xsrfCookieName && cookies.read(config.xsrfCookieName);
2391
-
2392
- if (xsrfValue) {
2393
- requestHeaders.set(config.xsrfHeaderName, xsrfValue);
2394
- }
2395
- }
2396
-
2397
- // Remove Content-Type if data is undefined
2398
- requestData === undefined && requestHeaders.setContentType(null);
2399
-
2400
- // Add headers to the request
2401
- if ('setRequestHeader' in request) {
2402
- utils.forEach(requestHeaders.toJSON(), function setRequestHeader(val, key) {
2403
- request.setRequestHeader(key, val);
2404
- });
2405
- }
2406
-
2407
- // Add withCredentials to request if needed
2408
- if (!utils.isUndefined(config.withCredentials)) {
2409
- request.withCredentials = !!config.withCredentials;
2410
- }
2411
-
2412
- // Add responseType to request if needed
2413
- if (responseType && responseType !== 'json') {
2414
- request.responseType = config.responseType;
2415
- }
2416
-
2417
- // Handle progress if needed
2418
- if (typeof config.onDownloadProgress === 'function') {
2419
- request.addEventListener('progress', progressEventReducer(config.onDownloadProgress, true));
2420
- }
2421
-
2422
- // Not all browsers support upload events
2423
- if (typeof config.onUploadProgress === 'function' && request.upload) {
2424
- request.upload.addEventListener('progress', progressEventReducer(config.onUploadProgress));
2425
- }
2426
-
2427
- if (config.cancelToken || config.signal) {
2428
- // Handle cancellation
2429
- // eslint-disable-next-line func-names
2430
- onCanceled = cancel => {
2431
- if (!request) {
2432
- return;
2433
- }
2434
- reject(!cancel || cancel.type ? new CanceledError(null, config, request) : cancel);
2435
- request.abort();
2436
- request = null;
2437
- };
2438
-
2439
- config.cancelToken && config.cancelToken.subscribe(onCanceled);
2440
- if (config.signal) {
2441
- config.signal.aborted ? onCanceled() : config.signal.addEventListener('abort', onCanceled);
2442
- }
2443
- }
2444
-
2445
- const protocol = parseProtocol(fullPath);
2446
-
2447
- if (protocol && platform.protocols.indexOf(protocol) === -1) {
2448
- reject(new AxiosError('Unsupported protocol ' + protocol + ':', AxiosError.ERR_BAD_REQUEST, config));
2449
- return;
2450
- }
2451
-
2452
-
2453
- // Send the request
2454
- request.send(requestData || null);
2455
- });
2456
- };
2457
-
2458
- const knownAdapters = {
2459
- http: httpAdapter,
2460
- xhr: xhrAdapter
2461
- };
2462
-
2463
- utils.forEach(knownAdapters, (fn, value) => {
2464
- if(fn) {
2465
- try {
2466
- Object.defineProperty(fn, 'name', {value});
2467
- } catch (e) {
2468
- // eslint-disable-next-line no-empty
2469
- }
2470
- Object.defineProperty(fn, 'adapterName', {value});
2471
- }
2472
- });
2473
-
2474
- var adapters = {
2475
- getAdapter: (adapters) => {
2476
- adapters = utils.isArray(adapters) ? adapters : [adapters];
2477
-
2478
- const {length} = adapters;
2479
- let nameOrAdapter;
2480
- let adapter;
2481
-
2482
- for (let i = 0; i < length; i++) {
2483
- nameOrAdapter = adapters[i];
2484
- if((adapter = utils.isString(nameOrAdapter) ? knownAdapters[nameOrAdapter.toLowerCase()] : nameOrAdapter)) {
2485
- break;
2486
- }
2487
- }
2488
-
2489
- if (!adapter) {
2490
- if (adapter === false) {
2491
- throw new AxiosError(
2492
- `Adapter ${nameOrAdapter} is not supported by the environment`,
2493
- 'ERR_NOT_SUPPORT'
2494
- );
2495
- }
2496
-
2497
- throw new Error(
2498
- utils.hasOwnProp(knownAdapters, nameOrAdapter) ?
2499
- `Adapter '${nameOrAdapter}' is not available in the build` :
2500
- `Unknown adapter '${nameOrAdapter}'`
2501
- );
2502
- }
2503
-
2504
- if (!utils.isFunction(adapter)) {
2505
- throw new TypeError('adapter is not a function');
2506
- }
2507
-
2508
- return adapter;
2509
- },
2510
- adapters: knownAdapters
2511
- };
2512
-
2513
- /**
2514
- * Throws a `CanceledError` if cancellation has been requested.
2515
- *
2516
- * @param {Object} config The config that is to be used for the request
2517
- *
2518
- * @returns {void}
2519
- */
2520
- function throwIfCancellationRequested(config) {
2521
- if (config.cancelToken) {
2522
- config.cancelToken.throwIfRequested();
2523
- }
2524
-
2525
- if (config.signal && config.signal.aborted) {
2526
- throw new CanceledError(null, config);
2527
- }
2528
- }
2529
-
2530
- /**
2531
- * Dispatch a request to the server using the configured adapter.
2532
- *
2533
- * @param {object} config The config that is to be used for the request
2534
- *
2535
- * @returns {Promise} The Promise to be fulfilled
2536
- */
2537
- function dispatchRequest(config) {
2538
- throwIfCancellationRequested(config);
2539
-
2540
- config.headers = AxiosHeaders$1.from(config.headers);
2541
-
2542
- // Transform request data
2543
- config.data = transformData.call(
2544
- config,
2545
- config.transformRequest
2546
- );
2547
-
2548
- if (['post', 'put', 'patch'].indexOf(config.method) !== -1) {
2549
- config.headers.setContentType('application/x-www-form-urlencoded', false);
2550
- }
2551
-
2552
- const adapter = adapters.getAdapter(config.adapter || defaults$1.adapter);
2553
-
2554
- return adapter(config).then(function onAdapterResolution(response) {
2555
- throwIfCancellationRequested(config);
2556
-
2557
- // Transform response data
2558
- response.data = transformData.call(
2559
- config,
2560
- config.transformResponse,
2561
- response
2562
- );
2563
-
2564
- response.headers = AxiosHeaders$1.from(response.headers);
2565
-
2566
- return response;
2567
- }, function onAdapterRejection(reason) {
2568
- if (!isCancel(reason)) {
2569
- throwIfCancellationRequested(config);
2570
-
2571
- // Transform response data
2572
- if (reason && reason.response) {
2573
- reason.response.data = transformData.call(
2574
- config,
2575
- config.transformResponse,
2576
- reason.response
2577
- );
2578
- reason.response.headers = AxiosHeaders$1.from(reason.response.headers);
2579
- }
2580
- }
2581
-
2582
- return Promise.reject(reason);
2583
- });
2584
- }
2585
-
2586
- const headersToObject = (thing) => thing instanceof AxiosHeaders$1 ? thing.toJSON() : thing;
2587
-
2588
- /**
2589
- * Config-specific merge-function which creates a new config-object
2590
- * by merging two configuration objects together.
2591
- *
2592
- * @param {Object} config1
2593
- * @param {Object} config2
2594
- *
2595
- * @returns {Object} New object resulting from merging config2 to config1
2596
- */
2597
- function mergeConfig(config1, config2) {
2598
- // eslint-disable-next-line no-param-reassign
2599
- config2 = config2 || {};
2600
- const config = {};
2601
-
2602
- function getMergedValue(target, source, caseless) {
2603
- if (utils.isPlainObject(target) && utils.isPlainObject(source)) {
2604
- return utils.merge.call({caseless}, target, source);
2605
- } else if (utils.isPlainObject(source)) {
2606
- return utils.merge({}, source);
2607
- } else if (utils.isArray(source)) {
2608
- return source.slice();
2609
- }
2610
- return source;
2611
- }
2612
-
2613
- // eslint-disable-next-line consistent-return
2614
- function mergeDeepProperties(a, b, caseless) {
2615
- if (!utils.isUndefined(b)) {
2616
- return getMergedValue(a, b, caseless);
2617
- } else if (!utils.isUndefined(a)) {
2618
- return getMergedValue(undefined, a, caseless);
2619
- }
2620
- }
2621
-
2622
- // eslint-disable-next-line consistent-return
2623
- function valueFromConfig2(a, b) {
2624
- if (!utils.isUndefined(b)) {
2625
- return getMergedValue(undefined, b);
2626
- }
2627
- }
2628
-
2629
- // eslint-disable-next-line consistent-return
2630
- function defaultToConfig2(a, b) {
2631
- if (!utils.isUndefined(b)) {
2632
- return getMergedValue(undefined, b);
2633
- } else if (!utils.isUndefined(a)) {
2634
- return getMergedValue(undefined, a);
2635
- }
2636
- }
2637
-
2638
- // eslint-disable-next-line consistent-return
2639
- function mergeDirectKeys(a, b, prop) {
2640
- if (prop in config2) {
2641
- return getMergedValue(a, b);
2642
- } else if (prop in config1) {
2643
- return getMergedValue(undefined, a);
2644
- }
2645
- }
2646
-
2647
- const mergeMap = {
2648
- url: valueFromConfig2,
2649
- method: valueFromConfig2,
2650
- data: valueFromConfig2,
2651
- baseURL: defaultToConfig2,
2652
- transformRequest: defaultToConfig2,
2653
- transformResponse: defaultToConfig2,
2654
- paramsSerializer: defaultToConfig2,
2655
- timeout: defaultToConfig2,
2656
- timeoutMessage: defaultToConfig2,
2657
- withCredentials: defaultToConfig2,
2658
- adapter: defaultToConfig2,
2659
- responseType: defaultToConfig2,
2660
- xsrfCookieName: defaultToConfig2,
2661
- xsrfHeaderName: defaultToConfig2,
2662
- onUploadProgress: defaultToConfig2,
2663
- onDownloadProgress: defaultToConfig2,
2664
- decompress: defaultToConfig2,
2665
- maxContentLength: defaultToConfig2,
2666
- maxBodyLength: defaultToConfig2,
2667
- beforeRedirect: defaultToConfig2,
2668
- transport: defaultToConfig2,
2669
- httpAgent: defaultToConfig2,
2670
- httpsAgent: defaultToConfig2,
2671
- cancelToken: defaultToConfig2,
2672
- socketPath: defaultToConfig2,
2673
- responseEncoding: defaultToConfig2,
2674
- validateStatus: mergeDirectKeys,
2675
- headers: (a, b) => mergeDeepProperties(headersToObject(a), headersToObject(b), true)
2676
- };
2677
-
2678
- utils.forEach(Object.keys(Object.assign({}, config1, config2)), function computeConfigValue(prop) {
2679
- const merge = mergeMap[prop] || mergeDeepProperties;
2680
- const configValue = merge(config1[prop], config2[prop], prop);
2681
- (utils.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
2682
- });
2683
-
2684
- return config;
2685
- }
2686
-
2687
- const VERSION = "1.4.0";
2688
-
2689
- const validators$1 = {};
2690
-
2691
- // eslint-disable-next-line func-names
2692
- ['object', 'boolean', 'number', 'function', 'string', 'symbol'].forEach((type, i) => {
2693
- validators$1[type] = function validator(thing) {
2694
- return typeof thing === type || 'a' + (i < 1 ? 'n ' : ' ') + type;
2695
- };
2696
- });
2697
-
2698
- const deprecatedWarnings = {};
2699
-
2700
- /**
2701
- * Transitional option validator
2702
- *
2703
- * @param {function|boolean?} validator - set to false if the transitional option has been removed
2704
- * @param {string?} version - deprecated version / removed since version
2705
- * @param {string?} message - some message with additional info
2706
- *
2707
- * @returns {function}
2708
- */
2709
- validators$1.transitional = function transitional(validator, version, message) {
2710
- function formatMessage(opt, desc) {
2711
- return '[Axios v' + VERSION + '] Transitional option \'' + opt + '\'' + desc + (message ? '. ' + message : '');
2712
- }
2713
-
2714
- // eslint-disable-next-line func-names
2715
- return (value, opt, opts) => {
2716
- if (validator === false) {
2717
- throw new AxiosError(
2718
- formatMessage(opt, ' has been removed' + (version ? ' in ' + version : '')),
2719
- AxiosError.ERR_DEPRECATED
2720
- );
2721
- }
2722
-
2723
- if (version && !deprecatedWarnings[opt]) {
2724
- deprecatedWarnings[opt] = true;
2725
- // eslint-disable-next-line no-console
2726
- console.warn(
2727
- formatMessage(
2728
- opt,
2729
- ' has been deprecated since v' + version + ' and will be removed in the near future'
2730
- )
2731
- );
2732
- }
2733
-
2734
- return validator ? validator(value, opt, opts) : true;
2735
- };
2736
- };
2737
-
2738
- /**
2739
- * Assert object's properties type
2740
- *
2741
- * @param {object} options
2742
- * @param {object} schema
2743
- * @param {boolean?} allowUnknown
2744
- *
2745
- * @returns {object}
2746
- */
2747
-
2748
- function assertOptions(options, schema, allowUnknown) {
2749
- if (typeof options !== 'object') {
2750
- throw new AxiosError('options must be an object', AxiosError.ERR_BAD_OPTION_VALUE);
2751
- }
2752
- const keys = Object.keys(options);
2753
- let i = keys.length;
2754
- while (i-- > 0) {
2755
- const opt = keys[i];
2756
- const validator = schema[opt];
2757
- if (validator) {
2758
- const value = options[opt];
2759
- const result = value === undefined || validator(value, opt, options);
2760
- if (result !== true) {
2761
- throw new AxiosError('option ' + opt + ' must be ' + result, AxiosError.ERR_BAD_OPTION_VALUE);
2762
- }
2763
- continue;
2764
- }
2765
- if (allowUnknown !== true) {
2766
- throw new AxiosError('Unknown option ' + opt, AxiosError.ERR_BAD_OPTION);
2767
- }
2768
- }
2769
- }
2770
-
2771
- var validator = {
2772
- assertOptions,
2773
- validators: validators$1
2774
- };
2775
-
2776
- const validators = validator.validators;
2777
-
2778
- /**
2779
- * Create a new instance of Axios
2780
- *
2781
- * @param {Object} instanceConfig The default config for the instance
2782
- *
2783
- * @return {Axios} A new instance of Axios
2784
- */
2785
- class Axios {
2786
- constructor(instanceConfig) {
2787
- this.defaults = instanceConfig;
2788
- this.interceptors = {
2789
- request: new InterceptorManager$1(),
2790
- response: new InterceptorManager$1()
2791
- };
2792
- }
2793
-
2794
- /**
2795
- * Dispatch a request
2796
- *
2797
- * @param {String|Object} configOrUrl The config specific for this request (merged with this.defaults)
2798
- * @param {?Object} config
2799
- *
2800
- * @returns {Promise} The Promise to be fulfilled
2801
- */
2802
- request(configOrUrl, config) {
2803
- /*eslint no-param-reassign:0*/
2804
- // Allow for axios('example/url'[, config]) a la fetch API
2805
- if (typeof configOrUrl === 'string') {
2806
- config = config || {};
2807
- config.url = configOrUrl;
2808
- } else {
2809
- config = configOrUrl || {};
2810
- }
2811
-
2812
- config = mergeConfig(this.defaults, config);
2813
-
2814
- const {transitional, paramsSerializer, headers} = config;
2815
-
2816
- if (transitional !== undefined) {
2817
- validator.assertOptions(transitional, {
2818
- silentJSONParsing: validators.transitional(validators.boolean),
2819
- forcedJSONParsing: validators.transitional(validators.boolean),
2820
- clarifyTimeoutError: validators.transitional(validators.boolean)
2821
- }, false);
2822
- }
2823
-
2824
- if (paramsSerializer != null) {
2825
- if (utils.isFunction(paramsSerializer)) {
2826
- config.paramsSerializer = {
2827
- serialize: paramsSerializer
2828
- };
2829
- } else {
2830
- validator.assertOptions(paramsSerializer, {
2831
- encode: validators.function,
2832
- serialize: validators.function
2833
- }, true);
2834
- }
2835
- }
2836
-
2837
- // Set config.method
2838
- config.method = (config.method || this.defaults.method || 'get').toLowerCase();
2839
-
2840
- let contextHeaders;
2841
-
2842
- // Flatten headers
2843
- contextHeaders = headers && utils.merge(
2844
- headers.common,
2845
- headers[config.method]
2846
- );
2847
-
2848
- contextHeaders && utils.forEach(
2849
- ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
2850
- (method) => {
2851
- delete headers[method];
2852
- }
2853
- );
2854
-
2855
- config.headers = AxiosHeaders$1.concat(contextHeaders, headers);
2856
-
2857
- // filter out skipped interceptors
2858
- const requestInterceptorChain = [];
2859
- let synchronousRequestInterceptors = true;
2860
- this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
2861
- if (typeof interceptor.runWhen === 'function' && interceptor.runWhen(config) === false) {
2862
- return;
2863
- }
2864
-
2865
- synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
2866
-
2867
- requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
2868
- });
2869
-
2870
- const responseInterceptorChain = [];
2871
- this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
2872
- responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
2873
- });
2874
-
2875
- let promise;
2876
- let i = 0;
2877
- let len;
2878
-
2879
- if (!synchronousRequestInterceptors) {
2880
- const chain = [dispatchRequest.bind(this), undefined];
2881
- chain.unshift.apply(chain, requestInterceptorChain);
2882
- chain.push.apply(chain, responseInterceptorChain);
2883
- len = chain.length;
2884
-
2885
- promise = Promise.resolve(config);
2886
-
2887
- while (i < len) {
2888
- promise = promise.then(chain[i++], chain[i++]);
2889
- }
2890
-
2891
- return promise;
2892
- }
2893
-
2894
- len = requestInterceptorChain.length;
2895
-
2896
- let newConfig = config;
2897
-
2898
- i = 0;
2899
-
2900
- while (i < len) {
2901
- const onFulfilled = requestInterceptorChain[i++];
2902
- const onRejected = requestInterceptorChain[i++];
2903
- try {
2904
- newConfig = onFulfilled(newConfig);
2905
- } catch (error) {
2906
- onRejected.call(this, error);
2907
- break;
2908
- }
2909
- }
2910
-
2911
- try {
2912
- promise = dispatchRequest.call(this, newConfig);
2913
- } catch (error) {
2914
- return Promise.reject(error);
2915
- }
2916
-
2917
- i = 0;
2918
- len = responseInterceptorChain.length;
2919
-
2920
- while (i < len) {
2921
- promise = promise.then(responseInterceptorChain[i++], responseInterceptorChain[i++]);
2922
- }
2923
-
2924
- return promise;
2925
- }
2926
-
2927
- getUri(config) {
2928
- config = mergeConfig(this.defaults, config);
2929
- const fullPath = buildFullPath(config.baseURL, config.url);
2930
- return buildURL(fullPath, config.params, config.paramsSerializer);
2931
- }
2932
- }
2933
-
2934
- // Provide aliases for supported request methods
2935
- utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
2936
- /*eslint func-names:0*/
2937
- Axios.prototype[method] = function(url, config) {
2938
- return this.request(mergeConfig(config || {}, {
2939
- method,
2940
- url,
2941
- data: (config || {}).data
2942
- }));
2943
- };
2944
- });
2945
-
2946
- utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
2947
- /*eslint func-names:0*/
2948
-
2949
- function generateHTTPMethod(isForm) {
2950
- return function httpMethod(url, data, config) {
2951
- return this.request(mergeConfig(config || {}, {
2952
- method,
2953
- headers: isForm ? {
2954
- 'Content-Type': 'multipart/form-data'
2955
- } : {},
2956
- url,
2957
- data
2958
- }));
2959
- };
2960
- }
2961
-
2962
- Axios.prototype[method] = generateHTTPMethod();
2963
-
2964
- Axios.prototype[method + 'Form'] = generateHTTPMethod(true);
2965
- });
2966
-
2967
- var Axios$1 = Axios;
2968
-
2969
- /**
2970
- * A `CancelToken` is an object that can be used to request cancellation of an operation.
2971
- *
2972
- * @param {Function} executor The executor function.
2973
- *
2974
- * @returns {CancelToken}
2975
- */
2976
- class CancelToken {
2977
- constructor(executor) {
2978
- if (typeof executor !== 'function') {
2979
- throw new TypeError('executor must be a function.');
2980
- }
2981
-
2982
- let resolvePromise;
2983
-
2984
- this.promise = new Promise(function promiseExecutor(resolve) {
2985
- resolvePromise = resolve;
2986
- });
2987
-
2988
- const token = this;
2989
-
2990
- // eslint-disable-next-line func-names
2991
- this.promise.then(cancel => {
2992
- if (!token._listeners) return;
2993
-
2994
- let i = token._listeners.length;
2995
-
2996
- while (i-- > 0) {
2997
- token._listeners[i](cancel);
2998
- }
2999
- token._listeners = null;
3000
- });
3001
-
3002
- // eslint-disable-next-line func-names
3003
- this.promise.then = onfulfilled => {
3004
- let _resolve;
3005
- // eslint-disable-next-line func-names
3006
- const promise = new Promise(resolve => {
3007
- token.subscribe(resolve);
3008
- _resolve = resolve;
3009
- }).then(onfulfilled);
3010
-
3011
- promise.cancel = function reject() {
3012
- token.unsubscribe(_resolve);
3013
- };
3014
-
3015
- return promise;
3016
- };
3017
-
3018
- executor(function cancel(message, config, request) {
3019
- if (token.reason) {
3020
- // Cancellation has already been requested
3021
- return;
3022
- }
3023
-
3024
- token.reason = new CanceledError(message, config, request);
3025
- resolvePromise(token.reason);
3026
- });
3027
- }
3028
-
3029
- /**
3030
- * Throws a `CanceledError` if cancellation has been requested.
3031
- */
3032
- throwIfRequested() {
3033
- if (this.reason) {
3034
- throw this.reason;
3035
- }
3036
- }
3037
-
3038
- /**
3039
- * Subscribe to the cancel signal
3040
- */
3041
-
3042
- subscribe(listener) {
3043
- if (this.reason) {
3044
- listener(this.reason);
3045
- return;
3046
- }
3047
-
3048
- if (this._listeners) {
3049
- this._listeners.push(listener);
3050
- } else {
3051
- this._listeners = [listener];
3052
- }
3053
- }
3054
-
3055
- /**
3056
- * Unsubscribe from the cancel signal
3057
- */
3058
-
3059
- unsubscribe(listener) {
3060
- if (!this._listeners) {
3061
- return;
3062
- }
3063
- const index = this._listeners.indexOf(listener);
3064
- if (index !== -1) {
3065
- this._listeners.splice(index, 1);
3066
- }
3067
- }
3068
-
3069
- /**
3070
- * Returns an object that contains a new `CancelToken` and a function that, when called,
3071
- * cancels the `CancelToken`.
3072
- */
3073
- static source() {
3074
- let cancel;
3075
- const token = new CancelToken(function executor(c) {
3076
- cancel = c;
3077
- });
3078
- return {
3079
- token,
3080
- cancel
3081
- };
3082
- }
3083
- }
3084
-
3085
- var CancelToken$1 = CancelToken;
3086
-
3087
- /**
3088
- * Syntactic sugar for invoking a function and expanding an array for arguments.
3089
- *
3090
- * Common use case would be to use `Function.prototype.apply`.
3091
- *
3092
- * ```js
3093
- * function f(x, y, z) {}
3094
- * var args = [1, 2, 3];
3095
- * f.apply(null, args);
3096
- * ```
3097
- *
3098
- * With `spread` this example can be re-written.
3099
- *
3100
- * ```js
3101
- * spread(function(x, y, z) {})([1, 2, 3]);
3102
- * ```
3103
- *
3104
- * @param {Function} callback
3105
- *
3106
- * @returns {Function}
3107
- */
3108
- function spread(callback) {
3109
- return function wrap(arr) {
3110
- return callback.apply(null, arr);
3111
- };
3112
- }
3113
-
3114
- /**
3115
- * Determines whether the payload is an error thrown by Axios
3116
- *
3117
- * @param {*} payload The value to test
3118
- *
3119
- * @returns {boolean} True if the payload is an error thrown by Axios, otherwise false
3120
- */
3121
- function isAxiosError(payload) {
3122
- return utils.isObject(payload) && (payload.isAxiosError === true);
3123
- }
3124
-
3125
- const HttpStatusCode = {
3126
- Continue: 100,
3127
- SwitchingProtocols: 101,
3128
- Processing: 102,
3129
- EarlyHints: 103,
3130
- Ok: 200,
3131
- Created: 201,
3132
- Accepted: 202,
3133
- NonAuthoritativeInformation: 203,
3134
- NoContent: 204,
3135
- ResetContent: 205,
3136
- PartialContent: 206,
3137
- MultiStatus: 207,
3138
- AlreadyReported: 208,
3139
- ImUsed: 226,
3140
- MultipleChoices: 300,
3141
- MovedPermanently: 301,
3142
- Found: 302,
3143
- SeeOther: 303,
3144
- NotModified: 304,
3145
- UseProxy: 305,
3146
- Unused: 306,
3147
- TemporaryRedirect: 307,
3148
- PermanentRedirect: 308,
3149
- BadRequest: 400,
3150
- Unauthorized: 401,
3151
- PaymentRequired: 402,
3152
- Forbidden: 403,
3153
- NotFound: 404,
3154
- MethodNotAllowed: 405,
3155
- NotAcceptable: 406,
3156
- ProxyAuthenticationRequired: 407,
3157
- RequestTimeout: 408,
3158
- Conflict: 409,
3159
- Gone: 410,
3160
- LengthRequired: 411,
3161
- PreconditionFailed: 412,
3162
- PayloadTooLarge: 413,
3163
- UriTooLong: 414,
3164
- UnsupportedMediaType: 415,
3165
- RangeNotSatisfiable: 416,
3166
- ExpectationFailed: 417,
3167
- ImATeapot: 418,
3168
- MisdirectedRequest: 421,
3169
- UnprocessableEntity: 422,
3170
- Locked: 423,
3171
- FailedDependency: 424,
3172
- TooEarly: 425,
3173
- UpgradeRequired: 426,
3174
- PreconditionRequired: 428,
3175
- TooManyRequests: 429,
3176
- RequestHeaderFieldsTooLarge: 431,
3177
- UnavailableForLegalReasons: 451,
3178
- InternalServerError: 500,
3179
- NotImplemented: 501,
3180
- BadGateway: 502,
3181
- ServiceUnavailable: 503,
3182
- GatewayTimeout: 504,
3183
- HttpVersionNotSupported: 505,
3184
- VariantAlsoNegotiates: 506,
3185
- InsufficientStorage: 507,
3186
- LoopDetected: 508,
3187
- NotExtended: 510,
3188
- NetworkAuthenticationRequired: 511,
3189
- };
3190
-
3191
- Object.entries(HttpStatusCode).forEach(([key, value]) => {
3192
- HttpStatusCode[value] = key;
3193
- });
3194
-
3195
- var HttpStatusCode$1 = HttpStatusCode;
3196
-
3197
- /**
3198
- * Create an instance of Axios
3199
- *
3200
- * @param {Object} defaultConfig The default config for the instance
3201
- *
3202
- * @returns {Axios} A new instance of Axios
3203
- */
3204
- function createInstance(defaultConfig) {
3205
- const context = new Axios$1(defaultConfig);
3206
- const instance = bind(Axios$1.prototype.request, context);
3207
-
3208
- // Copy axios.prototype to instance
3209
- utils.extend(instance, Axios$1.prototype, context, {allOwnKeys: true});
3210
-
3211
- // Copy context to instance
3212
- utils.extend(instance, context, null, {allOwnKeys: true});
3213
-
3214
- // Factory for creating new instances
3215
- instance.create = function create(instanceConfig) {
3216
- return createInstance(mergeConfig(defaultConfig, instanceConfig));
3217
- };
3218
-
3219
- return instance;
3220
- }
3221
-
3222
- // Create the default instance to be exported
3223
- const axios = createInstance(defaults$1);
3224
-
3225
- // Expose Axios class to allow class inheritance
3226
- axios.Axios = Axios$1;
3227
-
3228
- // Expose Cancel & CancelToken
3229
- axios.CanceledError = CanceledError;
3230
- axios.CancelToken = CancelToken$1;
3231
- axios.isCancel = isCancel;
3232
- axios.VERSION = VERSION;
3233
- axios.toFormData = toFormData;
3234
-
3235
- // Expose AxiosError class
3236
- axios.AxiosError = AxiosError;
3237
-
3238
- // alias for CanceledError for backward compatibility
3239
- axios.Cancel = axios.CanceledError;
3240
-
3241
- // Expose all/spread
3242
- axios.all = function all(promises) {
3243
- return Promise.all(promises);
3244
- };
3245
-
3246
- axios.spread = spread;
3247
-
3248
- // Expose isAxiosError
3249
- axios.isAxiosError = isAxiosError;
3250
-
3251
- // Expose mergeConfig
3252
- axios.mergeConfig = mergeConfig;
3253
-
3254
- axios.AxiosHeaders = AxiosHeaders$1;
3255
-
3256
- axios.formToJSON = thing => formDataToJSON(utils.isHTMLForm(thing) ? new FormData(thing) : thing);
3257
-
3258
- axios.HttpStatusCode = HttpStatusCode$1;
3259
-
3260
- axios.default = axios;
3261
-
3262
- // this module should only have a default export
3263
- var axios$1 = axios;
3264
-
3265
- const types = [
3266
- {
3267
- schema: 'wikidata',
3268
- label: 'Wikidata',
3269
- url: 'https://www.wikidata.org/wiki',
3270
- pattern: 'https://www.wikidata.org/(?:wiki|entity)',
3271
- classes: 'pl-[26px] bg-wikidata bg-[length:17px]',
3272
- },
3273
- {
3274
- schema: 'dracor',
3275
- label: 'DraCor',
3276
- url: 'https://dracor.org/id',
3277
- classes: 'pl-[23px] bg-dracor bg-[length:13px]'
3278
- },
3279
- {
3280
- schema: 'wega',
3281
- label: 'Carl-Maria-von-Weber-Gesamtausgabe (WeGA)',
3282
- url: 'https://weber-gesamtausgabe.de',
3283
- classes: 'pl-[23px] bg-wega bg-[length:13px]'
3284
- },
3285
- {
3286
- schema: 'isni',
3287
- label: 'ISNI',
3288
- url: 'https://isni.org/isni',
3289
- },
3290
- {
3291
- schema: 'pnd',
3292
- label: 'PND',
3293
- url: 'https://d-nb.info/gnd',
3294
- },
3295
- ];
3296
- function IdLink({ showLabel, children, className }) {
3297
- let spanClasses = 'inline-flex bg-white bg-no-repeat bg-[5px] rounded px-1.5 gap-1 align-text-bottom';
3298
- let id;
3299
- const type = types.find(({ pattern, url, schema }) => {
3300
- const rx = new RegExp(`^(?:${pattern || url}/|${schema}:)([a-z\\d]+)$`, 'i');
3301
- const m = children.match(rx);
3302
- if (m) {
3303
- id = m[1];
3304
- return true;
3305
- }
3306
- return false;
3307
- });
3308
- if (!type) {
3309
- return jsxRuntime.jsx("span", { className: spanClasses, children: children });
3310
- }
3311
- const { url, label, schema, classes = '' } = type;
3312
- spanClasses += ` ${classes}`;
3313
- return (jsxRuntime.jsxs("span", { className: spanClasses, children: [showLabel && `${label}: `, jsxRuntime.jsx("a", { className: className, href: `${url}/${id}`, title: label, children: id })] }));
3314
- }
3315
-
3316
- function formatEra(year, ceBefore = 0) {
3317
- if (year === null) {
3318
- return '';
3319
- }
3320
- const y = parseInt(year, 10);
3321
- if (y < 0) {
3322
- return `${y * -1} BCE`;
3323
- }
3324
- if (y < ceBefore) {
3325
- return `${y} CE`;
3326
- }
3327
- return String(y);
3328
- }
3329
- function formatYear(year, locale = 'en-GB') {
3330
- const yearString = `${year}`;
3331
- // range, both BCE
3332
- if (yearString.match('^-[0-9]{4}/-[0-9]{4}$')) {
3333
- const years = yearString.split('/').map(y => parseInt(y, 10) * -1);
3334
- return `${years[0]}-${years[1]} BCE`;
3335
- }
3336
- // range, mixed era
3337
- if (yearString.match('^-?[0-9]{4}/-?[0-9]{4}$')) {
3338
- const years = yearString.split('/');
3339
- return `${formatEra(years[0])}-${formatEra(years[1], 1000)}`;
3340
- }
3341
- // YYYY-MM
3342
- if (yearString.match('^[0-9]{4}-[0-9]{2}$')) {
3343
- const date = new Date(yearString);
3344
- return date.toLocaleDateString(locale, { month: 'long', year: 'numeric' });
3345
- }
3346
- // YYYY-MM-DD
3347
- if (yearString.match('^[0-9]{4}-[0-9]{2}-[0-9]{2}$')) {
3348
- const date = new Date(yearString);
3349
- return date.toLocaleDateString(locale, {
3350
- day: 'numeric',
3351
- month: 'long',
3352
- year: 'numeric'
3353
- });
3354
- }
3355
- // not before
3356
- if (yearString.match('^>-?[0-9]{4}')) {
3357
- const year = yearString.substring(1);
3358
- return `after ${formatEra(year, 1000)}`;
3359
- }
3360
- // not after
3361
- if (yearString.match('^<-?[0-9]{4}')) {
3362
- const year = yearString.substring(1);
3363
- return `before ${formatEra(year, 1000)}`;
3364
- }
3365
- // single year
3366
- if (yearString.match('^-?[0-9]{4}')) {
3367
- return formatEra(yearString, 1000);
3368
- }
3369
- return yearString;
3370
- }
3371
-
3372
- const endpoint = 'https://query.wikidata.org/sparql';
3373
- const commonsIcon = "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.1' width='102' height='137' viewBox='-305 -516 610 820'%3E%3Ctitle%3EWikimedia Commons Logo%3C/title%3E%3Cdefs%3E%3CclipPath id='c'%3E%3Ccircle r='298'/%3E%3C/clipPath%3E%3C/defs%3E%3Ccircle r='100' fill='%23900'/%3E%3Cg fill='%23069'%3E%3Cg id='arrow' clip-path='url(%23c)'%3E%3Cpath d='m-11 180v118h22v-118'/%3E%3Cpath d='m-43 185l43-75 43 75'/%3E%3C/g%3E%3Cg id='arrows3'%3E%3Cuse xlink:href='%23arrow' transform='rotate(45)'/%3E%3Cuse xlink:href='%23arrow' transform='rotate(90)'/%3E%3Cuse xlink:href='%23arrow' transform='rotate(135)'/%3E%3C/g%3E%3Cuse xlink:href='%23arrows3' transform='scale(-1 1)'/%3E%3Cpath id='blue_path' transform='rotate(-45)' stroke='%23069' stroke-width='84' fill='none' d='M 0,-256 A 256 256 0 1 0 256,0 C 256,-100 155,-150 250,-275'/%3E%3Cpath id='arrow_top' d='m-23-515s-36 135-80 185 116-62 170-5-90-180-90-180z'/%3E%3C/g%3E%3C/svg%3E";
3374
- function AuthorInfo({ wikidataId, name: fullname, birthLabel = 'b.', deathLabel = 'd.' }) {
3375
- const [info, setInfo] = react.useState(null);
3376
- react.useEffect(() => {
3377
- function fetchInfo(id) {
3378
- var _a;
3379
- return __awaiter(this, void 0, void 0, function* () {
3380
- const sparql = `
3381
- SELECT ?author ?authorLabel ?birthDate ?deathDate ?gender ?genderLabel
3382
- ?birthPlace ?birthPlaceLabel ?birthCoord
3383
- ?deathPlace ?deathPlaceLabel ?deathCoord
3384
- ?img ?gnd
3385
- WHERE {
3386
- BIND (wd:${id} AS ?author)
3387
- OPTIONAL { ?author wdt:P569 ?birthDate. }
3388
- OPTIONAL { ?author wdt:P570 ?deathDate. }
3389
- OPTIONAL { ?author wdt:P21 ?gender. }
3390
- OPTIONAL { ?author wdt:P19 ?birthPlace. }
3391
- OPTIONAL { ?author wdt:P20 ?deathPlace. }
3392
- #OPTIONAL { ?birthPlace wdt:P625 ?birthCoord. }
3393
- OPTIONAL { ?author wdt:P18 ?img. }
3394
- OPTIONAL { ?author wdt:P227 ?gnd. }
3395
- SERVICE wikibase:label { bd:serviceParam wikibase:language "de,en". }
3396
- }
3397
- `;
3398
- const url = `${endpoint}?query=${encodeURIComponent(sparql)}`;
3399
- try {
3400
- const response = yield axios$1.get(url);
3401
- if (response.status === 200) {
3402
- const sparqlResults = ((_a = response.data.results) === null || _a === void 0 ? void 0 : _a.bindings) || [];
3403
- const { authorLabel, img, birthDate, birthPlaceLabel, deathDate, deathPlaceLabel, } = sparqlResults[0];
3404
- const birth = [];
3405
- const death = [];
3406
- if (birthDate === null || birthDate === void 0 ? void 0 : birthDate.value) {
3407
- birth.push(formatYear(birthDate === null || birthDate === void 0 ? void 0 : birthDate.value.replace(/^(-?\d{4}).*$/, '$1')));
3408
- }
3409
- if (birthPlaceLabel === null || birthPlaceLabel === void 0 ? void 0 : birthPlaceLabel.value)
3410
- birth.push(birthPlaceLabel.value);
3411
- if (deathDate === null || deathDate === void 0 ? void 0 : deathDate.value) {
3412
- death.push(formatYear(deathDate === null || deathDate === void 0 ? void 0 : deathDate.value.replace(/^(-?\d{4}).*$/, '$1')));
3413
- }
3414
- if (deathPlaceLabel === null || deathPlaceLabel === void 0 ? void 0 : deathPlaceLabel.value)
3415
- death.push(deathPlaceLabel.value);
3416
- const aInfo = { name: authorLabel.value, birth, death };
3417
- if (img === null || img === void 0 ? void 0 : img.value) {
3418
- aInfo.imageUrl = img.value.replace(/^http:/, 'https:');
3419
- aInfo.commonsPage = img.value
3420
- .replace(/Special:FilePath\//, 'File:')
3421
- .replace(/^http:/, 'https:');
3422
- }
3423
- setInfo(aInfo);
3424
- }
3425
- else {
3426
- console.log(response.status);
3427
- }
3428
- }
3429
- catch (error) {
3430
- console.log(error);
3431
- }
3432
- });
3433
- }
3434
- if (wikidataId)
3435
- fetchInfo(wikidataId);
3436
- }, [wikidataId]);
3437
- const { name, imageUrl, commonsPage, birth = [], death = [] } = info || {};
3438
- return (jsxRuntime.jsxs("div", { className: "flex whitespace-nowrap", children: [jsxRuntime.jsxs("div", { className: "relative w-[5em] h-[6em] overflow-hidden bg-author bg-no-repeat bg-center bg-primary rounded-md border-2 border-primary mr-4", style: { backgroundSize: '70%' }, children: [imageUrl && (jsxRuntime.jsx("img", { src: imageUrl, title: name, alt: "", className: "object-cover object-top w-full h-full" })), commonsPage && (jsxRuntime.jsx("a", { href: commonsPage, title: "\u00A9 Wikimedia Commons", className: "absolute flex inset-0 z-10 bg-white/0 hover:bg-white/60", children: jsxRuntime.jsx("img", { src: commonsIcon, className: "opacity-0 hover:opacity-100 place-self-center w-full h-full p-[20%]", width: "17", alt: "Wikimedia Commons" }) }))] }), jsxRuntime.jsxs("span", { children: [jsxRuntime.jsx("div", { className: "text-lg", children: fullname || name }), wikidataId && (jsxRuntime.jsx("div", { children: jsxRuntime.jsx(IdLink, { children: `wikidata:${wikidataId}` }) })), birth.length > 0 && jsxRuntime.jsxs("div", { children: [birthLabel, " ", birth.join(', ')] }), death.length > 0 && jsxRuntime.jsxs("div", { children: [deathLabel, " ", death.join(', ')] })] })] }));
3439
- }
3440
-
3441
- const Authors = ({ data }) => {
3442
- return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: data.map((author, i) => (jsxRuntime.jsxs("span", { children: [i > 0 && jsxRuntime.jsx("br", {}), author.name, author.pseudonym && (jsxRuntime.jsxs("i", { children: [" (", author.pseudonym, ")"] })), (author.ref) && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [' ', jsxRuntime.jsx("small", { children: jsxRuntime.jsx(IdLink, { children: author.ref }) })] }))] }, `${i}-${author.name}`))) }));
3443
- };
3444
-
3445
- function DebouncedInput(_a) {
3446
- var { value: initialValue, onChange, debounce = 500 } = _a, props = __rest(_a, ["value", "onChange", "debounce"]);
3447
- const [value, setValue] = react.useState(initialValue);
3448
- react.useEffect(() => {
3449
- setValue(initialValue);
3450
- }, [initialValue]);
3451
- react.useEffect(() => {
3452
- const timeout = setTimeout(() => {
3453
- onChange(value);
3454
- }, debounce);
3455
- return () => clearTimeout(timeout);
3456
- // eslint-disable-next-line react-hooks/exhaustive-deps
3457
- }, [value]);
3458
- return (jsxRuntime.jsx("input", Object.assign({}, props, { value: value, onChange: (e) => setValue(e.target.value) })));
3459
- }
3460
-
3461
- const { protocol, host } = window.location;
3462
- const defaultPrefix = `${protocol}//${host}/id/`;
3463
- function IdCopy({ children, className = '', uri, prefix }) {
3464
- const id = children;
3465
- const text = uri || `${prefix || defaultPrefix}${id}`;
3466
- return (jsxRuntime.jsx("span", { className: `inline-flex bg-white rounded px-1.5 gap-1 align-text-bottom cursor-pointer ${className}`, children: jsxRuntime.jsx(reactCopyToClipboard.CopyToClipboard, { text: text, children: jsxRuntime.jsxs("span", { title: "copy to clipboard", children: [jsxRuntime.jsx("span", { className: "pr-1", children: id }), jsxRuntime.jsx(reactFontawesome.FontAwesomeIcon, { icon: freeSolidSvgIcons.faClipboard, size: "sm" })] }) }) }));
3467
- }
3468
-
3469
- var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
3470
-
3471
- var bundle = {exports: {}};
3472
-
3473
- (function (module, exports) {
3474
- !function(t,e){e(exports);}(commonjsGlobal,(function(t){function e(t){var o,i,r="";if("string"==typeof t||"number"==typeof t)r+=t;else if("object"==typeof t)if(Array.isArray(t))for(o=0;o<t.length;o++)t[o]&&(i=e(t[o]))&&(r&&(r+=" "),r+=i);else for(o in t)t[o]&&(r&&(r+=" "),r+=o);return r}function o(){for(var t,o,i=0,r="";i<arguments.length;)(t=arguments[i++])&&(o=e(t))&&(r&&(r+=" "),r+=o);return r}var i=o,r=o,a=o,n=o,l=o,s=o,d=o,c=o,g=o,p=o,f=o,u=o,b=o,y=o,h=o,m=o,k=o,x=o,C=o,S=o,w=o,v=o,O=o,A=o,B=o,R=o,W=o,D=o,I=o,T=o,j=o,z=o,F=o,P=o,H=o,M=o,E=o,G=o,U=o,N=o,L=o,V=o,_=o,q=o,J=o,K=o,Q=o,X=o,Y=o,Z=o,$=o,tt=o,et=o,ot=o,it=o,rt=o,at=o,nt=o,lt=o,st=o,dt=o,ct=o,gt=o,pt=o,ft=o,ut=o,bt=o,yt=o,ht=o,mt=o,kt=o,xt=o,Ct=o,St=o,wt=o,vt=o,Ot=o,At=o,Bt=o,Rt=o,Wt=o,Dt=o,It=o,Tt=o,jt=o,zt=o,Ft=o,Pt=o,Ht=o,Mt=o,Et=o,Gt=o,Ut=o,Nt=o,Lt=o,Vt=o,_t=o,qt=o,Jt=o,Kt=o,Qt=o,Xt=o,Yt=o,Zt=o,$t=o,te=o,ee=o,oe=o,ie=o,re=o,ae=o,ne=o,le=o,se=o,de=o,ce=o,ge=o,pe=o,fe=o,ue=o,be=o,ye=o,he=o,me=o,ke=o,xe=o,Ce=o,Se=o,we=o,ve=o,Oe=o,Ae=o,Be=o,Re=o,We=o,De=o,Ie=o,Te=o,je=o,ze=o,Fe=o,Pe=o,He=o,Me=o,Ee=o,Ge=o,Ue=o,Ne=o,Le=o,Ve=o,_e=o,qe=o,Je=o,Ke=o,Qe=o,Xe=o,Ye=o,Ze=o,$e=o,to=o,eo=o,oo=o,io=o,ro=o,ao=o,no=o,lo=o,so=o,co=o,go=o,po=o,fo=o,uo=o,bo=o,yo=o,ho=o,mo=o,ko=o,xo=o,Co=o,So=o,wo=o,vo=o,Oo=o,Ao=o,Bo=o,Ro=o,Wo={screenReaders:i,backgroundAttachment:r,backgroundClip:a,backgroundOrigin:n,backgroundRepeat:l,backgroundOpacity:s,backgroundColor:d,backgroundPosition:c,backgroundSize:g,backgroundImage:p,gradientColorStops:f,borderStyle:u,divideStyle:b,outlineStyle:y,borderColor:h,borderOpacity:m,borderRadius:k,borderWidth:x,divideColor:C,divideOpacity:S,divideWidth:w,ringColor:v,ringWidth:O,ringOpacity:A,ringOffsetColor:B,ringOffsetWidth:R,outlineOffset:W,outlineWidth:D,outlineColor:I,borderCollapse:T,tableLayout:j,borderSpacing:z,mixBlendMode:F,backgroundBlendMode:P,boxShadow:H,boxShadowColor:M,opacity:E,transitionProperty:G,transitionDuration:U,transitionTimingFunction:N,transitionDelay:L,animation:V,filter:_,backdropFilter:q,blur:J,brightness:K,contrast:Q,dropShadow:X,grayscale:Y,hueRotate:Z,invert:$,saturate:tt,sepia:et,backdropBlur:ot,backdropBrightness:it,backdropContrast:rt,backdropGrayscale:at,backdropHueRotate:nt,backdropInvert:lt,backdropOpacity:st,backdropSaturate:dt,backdropSepia:ct,flexDirection:gt,flexWrap:pt,alignItems:ft,alignContent:ut,alignSelf:bt,placeContent:yt,placeItems:ht,placeSelf:mt,justifyContent:kt,justifyItems:xt,justifySelf:Ct,flex:St,flexBasis:wt,flexGrow:vt,flexShrink:Ot,order:At,gridAutoFlow:Bt,gridTemplateColumns:Rt,gridAutoColumns:Wt,gridColumn:Dt,gridColumnStart:It,gridColumnEnd:Tt,gridTemplateRows:jt,gridAutoRows:zt,gridRow:Ft,gridRowStart:Pt,gridRowEnd:Ht,gap:Mt,group:Et,peer:Gt,padding:Ut,margin:Nt,space:Lt,appearance:Vt,pointerEvents:_t,resize:qt,userSelect:Jt,scrollSnap:Kt,scrollBehavior:Qt,touchAction:Xt,cursor:Yt,caretColor:Zt,willChange:$t,accentColor:te,scrollPadding:ee,scrollMargin:oe,display:ie,boxDecorationBreak:re,boxSizing:ae,container:ne,float:le,clear:se,isolation:de,objectFit:ce,overflow:ge,overscrollBehavior:pe,position:fe,visibility:ue,breakBefore:be,breakInside:ye,breakAfter:he,objectPosition:me,inset:ke,zIndex:xe,aspectRatio:Ce,columns:Se,width:we,minWidth:ve,maxWidth:Oe,height:Ae,minHeight:Be,maxHeight:Re,fill:We,stroke:De,strokeWidth:Ie,hardwareAcceleration:Te,scale:je,rotate:ze,translate:Fe,skew:Pe,transformOrigin:He,fontSmoothing:Me,fontStyle:Ee,fontVariantNumeric:Ge,listStylePosition:Ue,textAlign:Ne,textDecoration:Le,textTransform:Ve,textOverflow:_e,verticalAlign:qe,whitespace:Je,wordBreak:Ke,textDecorationStyle:Qe,fontFamily:Xe,fontSize:Ye,fontWeight:Ze,letterSpacing:$e,lineHeight:to,listStyleType:eo,placeholderColor:oo,placeholderOpacity:io,textColor:ro,textOpacity:ao,content:no,textIndent:lo,textDecorationColor:so,textDecorationThickness:co,textUnderlineOffset:go},Do={accessibility:po,backgrounds:fo,borders:uo,tables:bo,effects:yo,transitionsAndAnimations:ho,filters:mo,flexBox:ko,grid:xo,grouping:Co,spacing:So,interactivity:wo,layout:vo,sizing:Oo,svg:Ao,transforms:Bo,typography:Ro},Io=Do,To=Wo,jo=o;t.CN=Do,t.TW=Wo,t.accentColor=te,t.accessibility=po,t.alignContent=ut,t.alignItems=ft,t.alignSelf=bt,t.animation=V,t.appearance=Vt,t.aspectRatio=Ce,t.backdropBlur=ot,t.backdropBrightness=it,t.backdropContrast=rt,t.backdropFilter=q,t.backdropGrayscale=at,t.backdropHueRotate=nt,t.backdropInvert=lt,t.backdropOpacity=st,t.backdropSaturate=dt,t.backdropSepia=ct,t.backgroundAttachment=r,t.backgroundBlendMode=P,t.backgroundClip=a,t.backgroundColor=d,t.backgroundImage=p,t.backgroundOpacity=s,t.backgroundOrigin=n,t.backgroundPosition=c,t.backgroundRepeat=l,t.backgroundSize=g,t.backgrounds=fo,t.blur=J,t.borderCollapse=T,t.borderColor=h,t.borderOpacity=m,t.borderRadius=k,t.borderSpacing=z,t.borderStyle=u,t.borderWidth=x,t.borders=uo,t.boxDecorationBreak=re,t.boxShadow=H,t.boxShadowColor=M,t.boxSizing=ae,t.breakAfter=he,t.breakBefore=be,t.breakInside=ye,t.brightness=K,t.caretColor=Zt,t.classnames=jo,t.clear=se,t.columns=Se,t.container=ne,t.content=no,t.contrast=Q,t.cursor=Yt,t.default=jo,t.display=ie,t.divideColor=C,t.divideOpacity=S,t.divideStyle=b,t.divideWidth=w,t.dropShadow=X,t.effects=yo,t.fill=We,t.filter=_,t.filters=mo,t.flex=St,t.flexBasis=wt,t.flexBox=ko,t.flexDirection=gt,t.flexGrow=vt,t.flexShrink=Ot,t.flexWrap=pt,t.float=le,t.fontFamily=Xe,t.fontSize=Ye,t.fontSmoothing=Me,t.fontStyle=Ee,t.fontVariantNumeric=Ge,t.fontWeight=Ze,t.gap=Mt,t.gradientColorStops=f,t.grayscale=Y,t.grid=xo,t.gridAutoColumns=Wt,t.gridAutoFlow=Bt,t.gridAutoRows=zt,t.gridColumn=Dt,t.gridColumnEnd=Tt,t.gridColumnStart=It,t.gridRow=Ft,t.gridRowEnd=Ht,t.gridRowStart=Pt,t.gridTemplateColumns=Rt,t.gridTemplateRows=jt,t.group=Et,t.grouping=Co,t.hardwareAcceleration=Te,t.height=Ae,t.hueRotate=Z,t.inset=ke,t.interactivity=wo,t.invert=$,t.isolation=de,t.justifyContent=kt,t.justifyItems=xt,t.justifySelf=Ct,t.layout=vo,t.letterSpacing=$e,t.lineHeight=to,t.listStylePosition=Ue,t.listStyleType=eo,t.mainCategoriesUtilityFunctions=Io,t.margin=Nt,t.maxHeight=Re,t.maxWidth=Oe,t.minHeight=Be,t.minWidth=ve,t.mixBlendMode=F,t.objectFit=ce,t.objectPosition=me,t.opacity=E,t.order=At,t.outlineColor=I,t.outlineOffset=W,t.outlineStyle=y,t.outlineWidth=D,t.overflow=ge,t.overscrollBehavior=pe,t.padding=Ut,t.peer=Gt,t.placeContent=yt,t.placeItems=ht,t.placeSelf=mt,t.placeholderColor=oo,t.placeholderOpacity=io,t.pointerEvents=_t,t.position=fe,t.resize=qt,t.ringColor=v,t.ringOffsetColor=B,t.ringOffsetWidth=R,t.ringOpacity=A,t.ringWidth=O,t.rotate=ze,t.saturate=tt,t.scale=je,t.screenReaders=i,t.scrollBehavior=Qt,t.scrollMargin=oe,t.scrollPadding=ee,t.scrollSnap=Kt,t.sepia=et,t.sizing=Oo,t.skew=Pe,t.space=Lt,t.spacing=So,t.stroke=De,t.strokeWidth=Ie,t.subCategoriesUtilityFunctions=To,t.svg=Ao,t.tableLayout=j,t.tables=bo,t.textAlign=Ne,t.textColor=ro,t.textDecoration=Le,t.textDecorationColor=so,t.textDecorationStyle=Qe,t.textDecorationThickness=co,t.textIndent=lo,t.textOpacity=ao,t.textOverflow=_e,t.textTransform=Ve,t.textUnderlineOffset=go,t.touchAction=Xt,t.transformOrigin=He,t.transforms=Bo,t.transitionDelay=L,t.transitionDuration=U,t.transitionProperty=G,t.transitionTimingFunction=N,t.transitionsAndAnimations=ho,t.translate=Fe,t.typography=Ro,t.userSelect=Jt,t.verticalAlign=qe,t.visibility=ue,t.whitespace=Je,t.width=we,t.willChange=$t,t.wordBreak=Ke,t.zIndex=xe,Object.defineProperty(t,"__esModule",{value:!0});}));
3475
-
3476
- } (bundle, bundle.exports));
3477
-
3478
- var bundleExports = bundle.exports;
3479
-
3480
- function NavItem({ label, href, active, className }) {
3481
- return (jsxRuntime.jsx(reactRouterDom.Link, { to: href, className: itemClassNames(active, className), children: label }));
3482
- }
3483
- function itemClassNames(active = false, className = '') {
3484
- return `block md:inline-block justify-center text-white hover:text-blue-100
3485
- uppercase
3486
- ${active ? 'border-b-4' : ''} ${className}`;
3487
- }
3488
-
3489
- function NavMenu({ label, items, menuClass }) {
3490
- const location = reactRouterDom.useLocation();
3491
- function isActive({ href, selected }) {
3492
- if (selected !== undefined) {
3493
- return selected;
3494
- }
3495
- return location.pathname.startsWith(href);
3496
- }
3497
- const active = Boolean(items.find((item) => isActive(item)));
3498
- return (jsxRuntime.jsxs(react$1.Menu, { as: "div", className: "relative inline-block text-left", children: [jsxRuntime.jsx("div", { children: jsxRuntime.jsxs(react$1.Menu.Button, { className: itemClassNames(active, menuClass), children: [label, jsxRuntime.jsx(reactFontawesome.FontAwesomeIcon, { icon: freeSolidSvgIcons.faCaretDown, className: "ml-2 mt-1", size: "sm", "aria-hidden": "true" })] }) }), jsxRuntime.jsx(react$1.Transition, { as: react.Fragment, enter: "transition ease-out duration-100", enterFrom: "transform opacity-0 scale-95", enterTo: "transform opacity-100 scale-100", leave: "transition ease-in duration-75", leaveFrom: "transform opacity-100 scale-100", leaveTo: "transform opacity-0 scale-95", children: jsxRuntime.jsx(react$1.Menu.Items, { className: "absolute left-0 mt-2 min-w-fit whitespace-nowrap origin-top-right divide-y divide-gray-100 rounded-md bg-white shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none", children: jsxRuntime.jsx("div", { className: "px-1 py-1", children: items.map((item) => (jsxRuntime.jsx(react$1.Menu.Item, { children: ({ active }) => (jsxRuntime.jsx(reactRouterDom.Link, { to: item.href, className: `${active ? 'bg-blue-100' : ''} ${isActive(item) ? 'bg-blue-300 text-white' : ''} text-gray-900 group flex w-full items-center rounded-md px-2 py-1 text-sm`, children: item.label })) }, item.href))) }) }) })] }));
3499
- }
3500
-
3501
- function NavBar({ title, logo, logoClass, version, gitHubUrl, gitHubIcon, navItems }) {
3502
- const [showNav, setShowNav] = react.useState(false);
3503
- const location = reactRouterDom.useLocation();
3504
- function isActive({ href, active }) {
3505
- if (active !== undefined) {
3506
- return active;
3507
- }
3508
- return location.pathname.startsWith(href);
3509
- }
3510
- const menuWrapperClasses = bundleExports.classnames(bundleExports.display('block', 'md:flex', { hidden: !showNav }), bundleExports.flexGrow('grow'), bundleExports.alignItems('md:items-center'), bundleExports.width('w-full', 'md:w-auto'));
3511
- return (jsxRuntime.jsxs("nav", { className: "flex items-center justify-between flex-wrap p-4 bg-primary text-white font-medium", children: [jsxRuntime.jsx(reactRouterDom.Link, { to: "/", children: jsxRuntime.jsx("img", { alt: `${title} logo`, title: `${title}${version ? ` (${version})` : ''}`, className: `h-12 ${logoClass || ''}`, src: logo }) }), jsxRuntime.jsx("div", { className: "block md:hidden", children: jsxRuntime.jsx("button", { className: "flex items-center px-3 py-2 hover:text-blue-100", onClick: () => setShowNav(!showNav), children: jsxRuntime.jsxs("svg", { className: "fill-current h-10 w-10", viewBox: "0 0 20 20", xmlns: "http://www.w3.org/2000/svg", children: [jsxRuntime.jsx("title", { children: "Menu" }), jsxRuntime.jsx("path", { d: "M0 3h20v2H0V3zm0 6h20v2H0V9zm0 6h20v2H0v-2z" })] }) }) }), jsxRuntime.jsxs("div", { className: menuWrapperClasses, children: [(navItems === null || navItems === void 0 ? void 0 : navItems.length) && (jsxRuntime.jsx("div", { className: "my-2 md:flex-grow md:flex-row flex justify-center flex-col gap-4", children: navItems.map((item) => ('items' in item
3512
- ? jsxRuntime.jsx(NavMenu, { label: item.label, items: item.items }, item.label)
3513
- : jsxRuntime.jsx(NavItem, { label: item.label, href: item.href, active: isActive(item) }, item.label))) })), gitHubUrl && (jsxRuntime.jsx("div", { children: jsxRuntime.jsx("a", { href: gitHubUrl, title: "EcoCor Github", className: "text-white text-2xl", children: gitHubIcon
3514
- ? gitHubIcon
3515
- : jsxRuntime.jsx(reactFontawesome.FontAwesomeIcon, { icon: freeBrandsSvgIcons.faGithub, size: "2xl" }) }) }))] })] }));
3516
- }
3517
-
3518
- const Table = ({ columns, data: initialData, defaultSort = [] }) => {
3519
- const [sorting, setSorting] = react.useState(defaultSort);
3520
- const [globalFilter, setGlobalFilter] = react.useState('');
3521
- const [data] = react.useState(initialData);
3522
- const table = reactTable.useReactTable({
3523
- data,
3524
- columns,
3525
- state: {
3526
- sorting,
3527
- globalFilter,
3528
- },
3529
- onSortingChange: setSorting,
3530
- onGlobalFilterChange: setGlobalFilter,
3531
- getCoreRowModel: reactTable.getCoreRowModel(),
3532
- getSortedRowModel: reactTable.getSortedRowModel(),
3533
- getFilteredRowModel: reactTable.getFilteredRowModel(),
3534
- debugTable: true,
3535
- });
3536
- return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs("div", { className: "mb-2", children: [jsxRuntime.jsx(DebouncedInput, { value: globalFilter !== null && globalFilter !== void 0 ? globalFilter : '', onChange: (value) => setGlobalFilter(String(value)), placeholder: 'Search' }), globalFilter !== '' && (jsxRuntime.jsxs("span", { className: "ml-2", children: ["(", table.getRowModel().rows.length, ")"] }))] }), jsxRuntime.jsx("div", { className: "flex", children: jsxRuntime.jsxs("table", { children: [jsxRuntime.jsx("thead", { children: table.getHeaderGroups().map((headerGroup) => (jsxRuntime.jsx("tr", { children: headerGroup.headers.map((header) => (jsxRuntime.jsx("th", { colSpan: header.colSpan, children: header.isPlaceholder ? null : (jsxRuntime.jsxs("div", { className: header.column.getCanSort()
3537
- ? 'cursor-pointer select-none'
3538
- : '',
3539
- onClick: header.column.getToggleSortingHandler(), children: [reactTable.flexRender(header.column.columnDef.header, header.getContext()), ' ', jsxRuntime.jsx(SortIndicator, { status: header.column.getIsSorted() })] })) }, header.id))) }, headerGroup.id))) }), jsxRuntime.jsx("tbody", { children: table.getRowModel().rows.map((row, i) => (jsxRuntime.jsx("tr", { className: i % 2 ? '' : 'bg-neutral-200', children: row.getVisibleCells().map((cell) => (jsxRuntime.jsx("td", { children: reactTable.flexRender(cell.column.columnDef.cell, cell.getContext()) }, cell.id))) }, row.id))) })] }) })] }));
3540
- };
3541
- function SortIndicator({ status }) {
3542
- return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("span", { className: status !== 'asc' ? 'opacity-40' : '', children: "\u25B2" }), jsxRuntime.jsx("span", { className: status !== 'desc' ? 'opacity-40' : '', children: "\u25BC" })] }));
3543
- }
3544
-
3545
- function Tabs({ data: tabs }) {
3546
- return (jsxRuntime.jsx("div", { className: "text-sm font-medium text-center text-gray-500 border-b border-gray-200 dark:text-gray-400 dark:border-gray-700", children: jsxRuntime.jsx("div", { className: "flex flex-wrap -mb-px gap-3", children: tabs.map(({ label, href, active }) => (jsxRuntime.jsx("div", { children: jsxRuntime.jsx(reactRouterDom.Link, { to: href, className: linkClasses(active || false), children: label }) }, href))) }) }));
3547
- }
3548
- function linkClasses(active) {
3549
- let classes = 'inline-block p-4 border-b-2 text-gray-500 hover:text-gray-600';
3550
- if (active) {
3551
- classes += ' border-primary';
3552
- }
3553
- else {
3554
- classes += ' border-transparent hover:border-gray-300';
3555
- }
3556
- return classes;
3557
- }
3558
-
3559
- var defaultBehaviors = {
3560
- "namespaces": {
3561
- "tei": "http://www.tei-c.org/ns/1.0",
3562
- "teieg": "http://www.tei-c.org/ns/Examples",
3563
- "rng": "http://relaxng.org/ns/structure/1.0"
3564
- },
3565
- "tei": {
3566
- "eg": ["<pre>","</pre>"],
3567
- // inserts a link inside <ptr> using the @target; the link in the
3568
- // @href is piped through the rw (rewrite) function before insertion
3569
- "ptr": ["<a href=\"$rw@target\">$@target</a>"],
3570
- // wraps the content of the <ref> in an HTML link
3571
- "ref": [
3572
- ["[target]", ["<a href=\"$rw@target\">","</a>"]]
3573
- ],
3574
- "graphic": function(elt) {
3575
- let content = new Image();
3576
- content.src = this.rw(elt.getAttribute("url"));
3577
- if (elt.hasAttribute("width")) {
3578
- content.setAttribute("width",elt.getAttribute("width"));
3579
- }
3580
- if (elt.hasAttribute("height")) {
3581
- content.setAttribute("height",elt.getAttribute("height"));
3582
- }
3583
- return content;
3584
- },
3585
- "list": [
3586
- // will only run on a list where @type="gloss"
3587
- ["[type=gloss]", function(elt) {
3588
- const doc = elt.ownerDocument;
3589
- let dl = doc.createElement("dl");
3590
- for (let child of Array.from(elt.children)) {
3591
- // nodeType 1 is Node.ELEMENT_NODE
3592
- if (child.nodeType == 1) {
3593
- if (child.localName == "tei-label") {
3594
- let dt = doc.createElement("dt");
3595
- dt.innerHTML = child.innerHTML;
3596
- dl.appendChild(dt);
3597
- }
3598
- if (child.localName == "tei-item") {
3599
- let dd = doc.createElement("dd");
3600
- dd.innerHTML = child.innerHTML;
3601
- dl.appendChild(dd);
3602
- }
3603
- }
3604
- }
3605
- return dl;
3606
- }
3607
- ]],
3608
- "note": [
3609
- // Make endnotes
3610
- ["[place=end]", function(elt){
3611
- const doc = elt.ownerDocument;
3612
- if (!this.noteIndex){
3613
- this["noteIndex"] = 1;
3614
- } else {
3615
- this.noteIndex++;
3616
- }
3617
- let id = "_note_" + this.noteIndex;
3618
- let link = doc.createElement("a");
3619
- link.setAttribute("id", "src" + id);
3620
- link.setAttribute("href", "#" + id);
3621
- link.innerHTML = this.noteIndex;
3622
- let content = doc.createElement("sup");
3623
- content.appendChild(link);
3624
- let notes = doc.querySelector("ol.notes");
3625
- if (!notes) {
3626
- notes = doc.createElement("ol");
3627
- notes.setAttribute("class", "notes");
3628
- this.dom.appendChild(notes);
3629
- }
3630
- let note = doc.createElement("li");
3631
- note.id = id;
3632
- note.innerHTML = elt.innerHTML;
3633
- notes.appendChild(note);
3634
- return content;
3635
- }],
3636
- ["_", ["(",")"]]
3637
- ],
3638
- "teiHeader": function(e) {
3639
- this.hideContent(e, false);
3640
- },
3641
- "title": [
3642
- ["tei-titlestmt>tei-title", function(elt) {
3643
- const doc = elt.ownerDocument;
3644
- let title = doc.createElement("title");
3645
- title.innerHTML = elt.innerText;
3646
- doc.querySelector("head").appendChild(title);
3647
- }]
3648
- ],
3649
- },
3650
- "teieg": {
3651
- "egXML": function(elt) {
3652
- const doc = elt.ownerDocument;
3653
- let pre = doc.createElement("pre");
3654
- let content = this.serialize(elt, true).replace(/</g, "&lt;");
3655
- let ws = content.match(/^[\t ]+/);
3656
- if (ws) {
3657
- content = content.replace(new RegExp("^" + ws[0], "mg"), "");
3658
- }
3659
- pre.innerHTML = content;
3660
- return pre;
3661
- }
3662
- }
3663
- };
3664
-
3665
- function getOrdinality(elt, name) {
3666
- let pos = 1;
3667
- let e = elt;
3668
- while (e && e.previousElementSibling !== null && (name?e.previousElementSibling.localName == name:true)) {
3669
- pos++;
3670
- e = e.previousElementSibling;
3671
- if (!e.previousElementSibling) {
3672
- break;
3673
- }
3674
- }
3675
- return pos;
3676
- }
3677
-
3678
- /*
3679
- Performs a deep copy operation of the input node while stripping
3680
- out child elements introduced by CETEIcean.
3681
- */
3682
- function copyAndReset(node) {
3683
- const doc = node.ownerDocument;
3684
- let clone = (n) => {
3685
- // nodeType 1 is Node.ELEMENT_NODE
3686
- let result = n.nodeType === 1
3687
- ? doc.createElement(n.nodeName)
3688
- : n.cloneNode(true);
3689
- if (n.attributes) {
3690
- for (let att of Array.from(n.attributes)) {
3691
- if (att.name !== "data-processed") {
3692
- result.setAttribute(att.name,att.value);
3693
- }
3694
- }
3695
- }
3696
- for (let nd of Array.from(n.childNodes)){
3697
- // nodeType 1 is Node.ELEMENT_NODE
3698
- if (nd.nodeType == 1) {
3699
- if (!n.hasAttribute("data-empty")) {
3700
- if (nd.hasAttribute("data-original")) {
3701
- for (let childNode of Array.from(nd.childNodes)) {
3702
- let child = result.appendChild(clone(childNode));
3703
- // nodeType 1 is Node.ELEMENT_NODE
3704
- if (child.nodeType === 1 && child.hasAttribute("data-origid")) {
3705
- child.setAttribute("id", child.getAttribute("data-origid"));
3706
- child.removeAttribute("data-origid");
3707
- }
3708
- }
3709
- return result;
3710
- } else {
3711
- result.appendChild(clone(nd));
3712
- }
3713
- }
3714
- }
3715
- else {
3716
- result.appendChild(nd.cloneNode());
3717
- }
3718
- }
3719
- return result;
3720
- };
3721
- return clone(node);
3722
- }
3723
-
3724
- /*
3725
- Given a space-separated list of URLs (e.g. in a ref with multiple
3726
- targets), returns just the first one.
3727
- */
3728
- function first(urls) {
3729
- return urls.replace(/ .*$/, "");
3730
- }
3731
-
3732
- /*
3733
- Wraps the content of the element parameter in a <span data-original>
3734
- with display set to "none".
3735
- */
3736
- function hideContent(elt, rewriteIds = true) {
3737
- const doc = elt.ownerDocument;
3738
- if (elt.childNodes.length > 0) {
3739
- let hidden = doc.createElement("span");
3740
- elt.appendChild(hidden);
3741
- hidden.setAttribute("hidden", "");
3742
- hidden.setAttribute("data-original", "");
3743
- for (let node of Array.from(elt.childNodes)) {
3744
- if (node !== hidden) {
3745
- // nodeType 1 is Node.ELEMENT_NODE
3746
- if (node.nodeType === 1) {
3747
- node.setAttribute("data-processed", "");
3748
- for (let e of node.querySelectorAll("*")) {
3749
- e.setAttribute("data-processed", "");
3750
- }
3751
- }
3752
- hidden.appendChild(elt.removeChild(node));
3753
- }
3754
- }
3755
- if (rewriteIds) {
3756
- for (let e of Array.from(hidden.querySelectorAll("*"))) {
3757
- if (e.hasAttribute("id")) {
3758
- e.setAttribute("data-origid", e.getAttribute("id"));
3759
- e.removeAttribute("id");
3760
- }
3761
- }
3762
- }
3763
- }
3764
- }
3765
-
3766
- function normalizeURI(urls) {
3767
- return this.rw(this.first(urls))
3768
- }
3769
-
3770
- /*
3771
- Takes a string and a number and returns the original string
3772
- printed that number of times.
3773
- */
3774
- function repeat(str, times) {
3775
- let result = "";
3776
- for (let i = 0; i < times; i++) {
3777
- result += str;
3778
- }
3779
- return result;
3780
- }
3781
-
3782
- /*
3783
- Resolves URIs that use TEI prefixDefs into full URIs.
3784
- See https://www.tei-c.org/release/doc/tei-p5-doc/en/html/ref-prefixDef.html
3785
- */
3786
- function resolveURI(uri) {
3787
- let prefixdef = this.prefixDefs[uri.substring(0,uri.indexOf(":"))];
3788
- return uri.replace(new RegExp(prefixdef["matchPattern"]), prefixdef["replacementPattern"]);
3789
- }
3790
-
3791
- /*
3792
- Convenience function for getting prefix definitions, Takes a prefix
3793
- and returns an object with "matchPattern" and "replacementPattern"
3794
- keys.
3795
- */
3796
- function getPrefixDef(prefix) {
3797
- return this.prefixDefs[prefix];
3798
- }
3799
-
3800
- /*
3801
- Takes a relative URL and rewrites it based on the base URL of the
3802
- HTML document
3803
- */
3804
- function rw(url) {
3805
- if (!url.match(/^(?:http|mailto|file|\/|#).*$/)) {
3806
- return this.base + this.utilities.first(url);
3807
- } else {
3808
- return url;
3809
- }
3810
- }
3811
-
3812
- /*
3813
- Takes an element and serializes it to an XML string or, if the stripElt
3814
- parameter is set, serializes the element's content. The ws parameter, if
3815
- set, will switch on minimal "pretty-printing" and indenting of the serialized
3816
- result.
3817
- */
3818
- function serialize(el, stripElt, ws) {
3819
- let str = "";
3820
- let ignorable = (txt) => {
3821
- return !(/[^\t\n\r ]/.test(txt));
3822
- };
3823
- // nodeType 1 is Node.ELEMENT_NODE
3824
- if (!stripElt && el.nodeType == 1) {
3825
- if ((typeof ws === "string") && ws !== "") {
3826
- str += "\n" + ws + "<";
3827
- } else {
3828
- str += "<";
3829
- }
3830
- str += el.getAttribute("data-origname");
3831
- // HTML5 lowercases all attribute names; @data-origatts contains the original names
3832
- let attrNames = el.hasAttribute("data-origatts") ? el.getAttribute("data-origatts").split(" ") : [];
3833
- for (let attr of Array.from(el.attributes)) {
3834
- if (!attr.name.startsWith("data-") && !(["id", "lang", "class"].includes(attr.name))) {
3835
- str += " " + attrNames.find(function(e) {return e.toLowerCase() == attr.name}) + "=\"" + attr.value + "\"";
3836
- }
3837
- if (attr.name == "data-xmlns") {
3838
- str += " xmlns=\"" + attr.value +"\"";
3839
- }
3840
- }
3841
- if (el.childNodes.length > 0) {
3842
- str += ">";
3843
- } else {
3844
- str += "/>";
3845
- }
3846
- }
3847
- //TODO: Be smarter about skipping generated content with hidden original
3848
- for (let node of Array.from(el.childNodes)) {
3849
- // nodeType 1 is Node.ELEMENT_NODE
3850
- // nodeType 7 is Node.PROCESSING_INSTRUCTION_NODE
3851
- // nodeType 8 is Node.COMMENT_NODE
3852
- switch (node.nodeType) {
3853
- case 1:
3854
- if (typeof ws === "string") {
3855
- str += serialize(node, false, ws + " ");
3856
- } else {
3857
- str += serialize(node, false, ws);
3858
- }
3859
- break;
3860
- case 7:
3861
- str += "<?" + node.nodeValue + "?>";
3862
- break;
3863
- case 8:
3864
- str += "<!--" + node.nodeValue + "-->";
3865
- break;
3866
- default:
3867
- if (stripElt && ignorable(node.nodeValue)) {
3868
- str += node.nodeValue.replace(/^\s*\n/, "");
3869
- }
3870
- if ((typeof ws === "string") && ignorable(node.nodeValue)) {
3871
- break;
3872
- }
3873
- str += node.nodeValue;
3874
- }
3875
- }
3876
- if (!stripElt && el.childNodes.length > 0) {
3877
- if (typeof ws === "string") {
3878
- str += "\n" + ws + "</";
3879
- } else {
3880
- str += "</";
3881
- }
3882
- str += el.getAttribute("data-origname") + ">";
3883
- }
3884
- return str;
3885
- }
3886
-
3887
- function unEscapeEntities(str) {
3888
- return str.replace(/&gt;/, ">")
3889
- .replace(/&quot;/, "\"")
3890
- .replace(/&apos;/, "'")
3891
- .replace(/&amp;/, "&");
3892
- }
3893
-
3894
- // Given a qualified name (e.g. tei:text), return the element name
3895
- function tagName(name) {
3896
- if (name.includes(":"), 1) {
3897
- return name.replace(/:/,"-").toLowerCase();
3898
- }
3899
- }
3900
-
3901
- function defineCustomElement(name, behavior = null, debug = false) {
3902
- /*
3903
- Registers the list of elements provided with the browser.
3904
- Called by makeHTML5(), but can be called independently if, for example,
3905
- you've created Custom Elements via an XSLT transformation instead.
3906
- */
3907
- try {
3908
- window.customElements.define(tagName(name), class extends HTMLElement {
3909
- constructor() {
3910
- super();
3911
- if (!this.matches(":defined")) { // "Upgraded" undefined elements can have attributes & children; new elements can't
3912
- if (behavior) {
3913
- behavior.call(this);
3914
- }
3915
- // We don't want to double-process elements, so add a flag
3916
- this.setAttribute("data-processed", "");
3917
- }
3918
- }
3919
- // Process new elements when they are connected to the browser DOM
3920
- connectedCallback() {
3921
- if (!this.hasAttribute("data-processed")) {
3922
- if (behavior) {
3923
- behavior.call(this);
3924
- }
3925
- this.setAttribute("data-processed", "");
3926
- }
3927
- };
3928
- });
3929
- } catch (error) {
3930
- // When using the same CETEIcean instance for multiple TEI files, this error becomes very common.
3931
- // It's muted by default unless the debug option is set.
3932
- if (debug) {
3933
- console.log(tagName(name) + " couldn't be registered or is already registered.");
3934
- console.log(error);
3935
- }
3936
- }
3937
- }
3938
-
3939
- var utilities = /*#__PURE__*/Object.freeze({
3940
- __proto__: null,
3941
- copyAndReset: copyAndReset,
3942
- defineCustomElement: defineCustomElement,
3943
- first: first,
3944
- getOrdinality: getOrdinality,
3945
- getPrefixDef: getPrefixDef,
3946
- hideContent: hideContent,
3947
- normalizeURI: normalizeURI,
3948
- repeat: repeat,
3949
- resolveURI: resolveURI,
3950
- rw: rw,
3951
- serialize: serialize,
3952
- tagName: tagName,
3953
- unEscapeEntities: unEscapeEntities
3954
- });
3955
-
3956
- /*
3957
- Add a user-defined set of behaviors to CETEIcean's processing
3958
- workflow. Added behaviors will override predefined behaviors with the
3959
- same name.
3960
- */
3961
- function addBehaviors(bhvs) {
3962
- if (bhvs.namespaces) {
3963
- for (let prefix of Object.keys(bhvs.namespaces)) {
3964
- if (!this.namespaces.has(bhvs.namespaces[prefix]) && !Array.from(this.namespaces.values()).includes(prefix)) {
3965
- this.namespaces.set(bhvs.namespaces[prefix], prefix);
3966
- }
3967
- }
3968
- }
3969
- for (let prefix of this.namespaces.values()) {
3970
- if (bhvs[prefix]) {
3971
- for (let b of Object.keys(bhvs[prefix])) {
3972
- this.behaviors[`${prefix}:${b}`] = bhvs[prefix][b];
3973
- }
3974
- }
3975
- }
3976
- if (bhvs["functions"]) {
3977
- for (let fn of Object.keys(bhvs["functions"])) {
3978
- this.utilities[fn] = bhvs["functions"][fn];
3979
- }
3980
- }
3981
- if (bhvs["handlers"]) {
3982
- console.log("Behavior handlers are no longer used.");
3983
- }
3984
- if (bhvs["fallbacks"]) {
3985
- console.log("Fallback behaviors are no longer used.");
3986
- }
3987
- }
3988
-
3989
- /*
3990
- Adds or replaces an individual behavior. Takes a namespace prefix or namespace definition,
3991
- the element name, and the behavior. E.g.
3992
- addBehavior("tei", "add", ["`","`"]) for an already-declared namespace or
3993
- addBehavior({"doc": "http://docbook.org/ns/docbook"}, "note", ["[","]"]) for a new one
3994
- */
3995
- function addBehavior(ns, element, b) {
3996
- let p;
3997
- if (ns === Object(ns)) {
3998
- for (let prefix of Object.keys(ns)) {
3999
- if (!this.namespaces.has(ns[prefix])) {
4000
- this.namespaces.set(ns[prefix], prefix);
4001
- p = prefix;
4002
- }
4003
- }
4004
- } else {
4005
- p = ns;
4006
- }
4007
- this.behaviors[`${p}:${element}`] = b;
4008
- }
4009
-
4010
- /*
4011
- Removes a previously-defined or default behavior. Takes a namespace prefix or namespace definition
4012
- and the element name.
4013
- */
4014
- function removeBehavior(ns, element) {
4015
- let p;
4016
- if (ns === Object(ns)) {
4017
- for (let prefix of Object.keys(ns)) {
4018
- if (!this.namespaces.has(ns[prefix])) {
4019
- this.namespaces.set(ns[prefix], prefix);
4020
- p = prefix;
4021
- }
4022
- }
4023
- } else {
4024
- p = ns;
4025
- }
4026
- delete this.behaviors[`${p}:${element}`];
4027
- }
4028
-
4029
- function learnElementNames(XML_dom, namespaces) {
4030
- const root = XML_dom.documentElement;
4031
- let i = 1;
4032
- let qname = function(e) {
4033
- if (!namespaces.has(e.namespaceURI ? e.namespaceURI : "")) {
4034
- namespaces.set(e.namespaceURI, "ns" + i++);
4035
- }
4036
- return namespaces.get(e.namespaceURI ? e.namespaceURI : "") + ":" + e.localName;
4037
- };
4038
- const els = new Set(
4039
- Array.from(root.querySelectorAll("*"), qname));
4040
-
4041
- // Add the root element to the array
4042
- els.add(qname(root));
4043
- return els
4044
- }
4045
-
4046
- function learnCustomElementNames(HTML_dom) {
4047
- return Array.from(HTML_dom.querySelectorAll("*[data-origname]"), e => e.localName.replace(/(\w+)-.+/,"$1:") + e.getAttribute("data-origname"));
4048
- }
4049
-
4050
- class CETEI {
4051
- constructor(options){
4052
- this.options = options ? options : {};
4053
-
4054
- // Set a local reference to the Document object
4055
- // Determine document in this order of preference: options, window, global
4056
- this.document = this.options.documentObject ? this.options.documentObject : undefined;
4057
- if (this.document === undefined) {
4058
- if (typeof window !== 'undefined' && window.document) {
4059
- this.document = window.document;
4060
- } else if (typeof global !== 'undefined' && global.document) {
4061
- this.document = global.document;
4062
- }
4063
- }
4064
-
4065
- // Bind methods
4066
- this.addBehaviors = addBehaviors.bind(this);
4067
- this.addBehavior = addBehavior.bind(this);
4068
- this.removeBehavior = removeBehavior.bind(this);
4069
-
4070
- // Bind selected utilities
4071
- this.utilities = {};
4072
- for (const u of Object.keys(utilities)) {
4073
- if (["getPrefixDef", "rw", "resolveURI"].includes(u)) {
4074
- this.utilities[u] = utilities[u].bind(this);
4075
- } else {
4076
- this.utilities[u] = utilities[u];
4077
- }
4078
- }
4079
-
4080
- // Set properties
4081
- this.els = [];
4082
- this.namespaces = new Map();
4083
- this.behaviors = {};
4084
- this.hasStyle = false;
4085
- this.prefixDefs = [];
4086
- this.debug = this.options.debug === true ? true : false;
4087
- this.discardContent = this.options.discardContent === true ? true : false;
4088
-
4089
- if (this.options.base) {
4090
- this.base = this.options.base;
4091
- } else {
4092
- try {
4093
- if (window) {
4094
- this.base = window.location.href.replace(/\/[^\/]*$/, "/");
4095
- }
4096
- } catch (e) {
4097
- this.base = "";
4098
- }
4099
- }
4100
- if (!this.options.omitDefaultBehaviors) {
4101
- this.addBehaviors(defaultBehaviors);
4102
- }
4103
- if (this.options.ignoreFragmentId) {
4104
- if (window) {
4105
- window.removeEventListener("ceteiceanload", CETEI.restorePosition);
4106
- }
4107
- }
4108
-
4109
- }
4110
-
4111
- /*
4112
- Returns a Promise that fetches an XML source document from the URL
4113
- provided in the first parameter and then calls the makeHTML5 method
4114
- on the returned document.
4115
- */
4116
- getHTML5(XML_url, callback, perElementFn){
4117
- if (window && window.location.href.startsWith(this.base) && (XML_url.indexOf("/") >= 0)) {
4118
- this.base = XML_url.replace(/\/[^\/]*$/, "/");
4119
- }
4120
- // Get XML from XML_url and create a promise
4121
- let promise = new Promise( function (resolve, reject) {
4122
- let client = new XMLHttpRequest();
4123
- client.open('GET', XML_url);
4124
- client.send();
4125
- client.onload = function () {
4126
- if (this.status >= 200 && this.status < 300) {
4127
- resolve(this.response);
4128
- } else {
4129
- reject(this.statusText);
4130
- }
4131
- };
4132
- client.onerror = function () {
4133
- reject(this.statusText);
4134
- };
4135
- })
4136
- .catch( function(reason) {
4137
- console.log("Could not get XML file.");
4138
- if (this.debug) {
4139
- console.log(reason);
4140
- }
4141
- });
4142
-
4143
- return promise.then((XML) => {
4144
- return this.makeHTML5(XML, callback, perElementFn);
4145
- });
4146
- }
4147
-
4148
- /*
4149
- Converts the supplied XML string into HTML5 Custom Elements. If a callback
4150
- function is supplied, calls it on the result.
4151
- */
4152
- makeHTML5(XML, callback, perElementFn){
4153
- // XML is assumed to be a string
4154
- this.XML_dom = ( new DOMParser() ).parseFromString(XML, "text/xml");
4155
- return this.domToHTML5(this.XML_dom, callback, perElementFn);
4156
- }
4157
-
4158
- preprocess(XML_dom, callback, perElementFn) {
4159
- this.els = learnElementNames(XML_dom, this.namespaces);
4160
-
4161
- let convertEl = (el) => {
4162
- // Elements with defined namespaces get the prefix mapped to that element. All others keep
4163
- // their namespaces and are copied as-is.
4164
- let newElement;
4165
- if (this.namespaces.has(el.namespaceURI ? el.namespaceURI : "")) {
4166
- let prefix = this.namespaces.get(el.namespaceURI ? el.namespaceURI : "");
4167
- newElement = this.document.createElement(`${prefix}-${el.localName}`);
4168
- } else {
4169
- newElement = this.document.importNode(el, false);
4170
- }
4171
- // Copy attributes; @xmlns, @xml:id, @xml:lang, and
4172
- // @rendition get special handling.
4173
- for (let att of Array.from(el.attributes)) {
4174
- if (att.name == "xmlns") {
4175
- //Strip default namespaces, but hang on to the values
4176
- newElement.setAttribute("data-xmlns", att.value);
4177
- } else {
4178
- newElement.setAttribute(att.name, att.value);
4179
- }
4180
- if (att.name == "xml:id") {
4181
- newElement.setAttribute("id", att.value);
4182
- }
4183
- if (att.name == "xml:lang") {
4184
- newElement.setAttribute("lang", att.value);
4185
- }
4186
- if (att.name == "rendition") {
4187
- newElement.setAttribute("class", att.value.replace(/#/g, ""));
4188
- }
4189
- }
4190
- // Preserve element name so we can use it later
4191
- newElement.setAttribute("data-origname", el.localName);
4192
- if (el.hasAttributes()) {
4193
- newElement.setAttribute("data-origatts", el.getAttributeNames().join(" "));
4194
- }
4195
- // If element is empty, flag it
4196
- if (el.childNodes.length == 0) {
4197
- newElement.setAttribute("data-empty", "");
4198
- }
4199
- // <head> elements need to know their level
4200
- if (el.localName == "head") {
4201
- // 1 is XPathResult.NUMBER_TYPE
4202
- let level = XML_dom.evaluate("count(ancestor::*[tei:head])", el, function(ns) {
4203
- if (ns == "tei") return "http://www.tei-c.org/ns/1.0";
4204
- }, 1, null);
4205
- newElement.setAttribute("data-level", level.numberValue);
4206
- }
4207
- // Turn <rendition scheme="css"> elements into HTML styles
4208
- if (el.localName == "tagsDecl") {
4209
- let style = this.document.createElement("style");
4210
- for (let node of Array.from(el.childNodes)){
4211
- // nodeType 1 is Node.ELEMENT_NODE
4212
- if (node.nodeType == 1 && node.localName == "rendition" && node.getAttribute("scheme") == "css") {
4213
- let rule = "";
4214
- if (node.hasAttribute("selector")) {
4215
- //rewrite element names in selectors
4216
- rule += node.getAttribute("selector").replace(/([^#, >]+\w*)/g, "tei-$1").replace(/#tei-/g, "#") + "{\n";
4217
- rule += node.textContent;
4218
- } else {
4219
- rule += "." + node.getAttribute("xml:id") + "{\n";
4220
- rule += node.textContent;
4221
- }
4222
- rule += "\n}\n";
4223
- style.appendChild(this.document.createTextNode(rule));
4224
- }
4225
- }
4226
- if (style.childNodes.length > 0) {
4227
- newElement.appendChild(style);
4228
- this.hasStyle = true;
4229
- }
4230
- }
4231
- // Get prefix definitions
4232
- if (el.localName == "prefixDef") {
4233
- this.prefixDefs.push(el.getAttribute("ident"));
4234
- this.prefixDefs[el.getAttribute("ident")] = {
4235
- "matchPattern": el.getAttribute("matchPattern"),
4236
- "replacementPattern": el.getAttribute("replacementPattern")
4237
- };
4238
- }
4239
- for (let node of Array.from(el.childNodes)) {
4240
- // Node.ELEMENT_NODE
4241
- if (node.nodeType == 1 ) {
4242
- newElement.appendChild(convertEl(node));
4243
- }
4244
- else {
4245
- newElement.appendChild(node.cloneNode());
4246
- }
4247
- }
4248
- if (perElementFn) {
4249
- perElementFn(newElement, el);
4250
- }
4251
- return newElement;
4252
- };
4253
-
4254
- this.dom = convertEl(XML_dom.documentElement);
4255
- this.utilities.dom = this.dom;
4256
-
4257
- if (callback) {
4258
- callback(this.dom, this);
4259
- if (window) {
4260
- window.dispatchEvent(ceteiceanLoad);
4261
- }
4262
- } else {
4263
- if (typeof window !== 'undefined') {
4264
- window.dispatchEvent(ceteiceanLoad);
4265
- }
4266
- return this.dom;
4267
- }
4268
- }
4269
-
4270
- /*
4271
- Converts the supplied XML DOM into HTML5 Custom Elements. If a callback
4272
- function is supplied, calls it on the result.
4273
- */
4274
- domToHTML5(XML_dom, callback, perElementFn){
4275
-
4276
- this.preprocess(XML_dom, null, perElementFn);
4277
-
4278
- this.applyBehaviors();
4279
- this.done = true;
4280
- if (callback) {
4281
- callback(this.dom, this);
4282
- if (window) {
4283
- window.dispatchEvent(ceteiceanLoad);
4284
- }
4285
- } else {
4286
- if (typeof window !== 'undefined') {
4287
- window.dispatchEvent(ceteiceanLoad);
4288
- }
4289
- return this.dom;
4290
- }
4291
- }
4292
-
4293
- /*
4294
- Convenience method for HTML pages containing pre-processed CETEIcean Custom
4295
- Elements. Usage:
4296
- const c = new CETEI();
4297
- c.processPage();
4298
- */
4299
- processPage() {
4300
- this.els = learnCustomElementNames(this.document);
4301
- this.applyBehaviors();
4302
- }
4303
-
4304
- /*
4305
- To change a namespace -> prefix mapping, the namespace must first be
4306
- unset. Takes a namespace URI. In order to process a TEI P4 document, e.g.,
4307
- the TEI namespace must be unset before it can be set to the empty string.
4308
- */
4309
- unsetNamespace(ns) {
4310
- this.namespaces.delete(ns);
4311
- }
4312
-
4313
- /*
4314
- Sets the base URL for the document. Used to rewrite relative links in the
4315
- XML source (which may be in a completely different location from the HTML
4316
- wrapper).
4317
- */
4318
- setBaseUrl(base) {
4319
- this.base = base;
4320
- }
4321
-
4322
- /*
4323
- Appends any element returned by the function passed in the first
4324
- parameter to the element in the second parameter. If the function
4325
- returns nothing, this is a no-op aside from any side effects caused
4326
- by the provided function.
4327
-
4328
- Called by getHandler() and fallback()
4329
- */
4330
- append(fn, elt) {
4331
- let self = this;
4332
- if (elt) {
4333
- let content = fn.call(self.utilities, elt);
4334
- if (content && !self.childExists(elt.firstElementChild, content.nodeName)) {
4335
- self.appendBasic(elt, content);
4336
- }
4337
- } else {
4338
- return function() {
4339
- if (!this.hasAttribute("data-processed")) {
4340
- let content = fn.call(self.utilities, this);
4341
- if (content && !self.childExists(this.firstElementChild, content.nodeName)) {
4342
- self.appendBasic(this, content);
4343
- }
4344
- }
4345
- }
4346
- }
4347
- }
4348
-
4349
- appendBasic(elt, content) {
4350
- if (this.discardContent) {
4351
- elt.innerHTML = "";
4352
- } else {
4353
- hideContent(elt, true);
4354
- }
4355
- elt.appendChild(content);
4356
- }
4357
-
4358
- // Given an element, return its qualified name as defined in a behaviors object
4359
- bName(e) {
4360
- return e.tagName.substring(0,e.tagName.indexOf("-")).toLowerCase() + ":" + e.getAttribute("data-origname");
4361
- }
4362
-
4363
- /*
4364
- Private method called by append(). Takes a child element and a name, and recurses through the
4365
- child's siblings until an element with that name is found, returning true if it is and false if not.
4366
- */
4367
- childExists(elt, name) {
4368
- if (elt && elt.nodeName == name) {
4369
- return true;
4370
- } else {
4371
- return elt && elt.nextElementSibling && this.childExists(elt.nextElementSibling, name);
4372
- }
4373
- }
4374
-
4375
- /*
4376
- Takes a template in the form of either an array of 1 or 2
4377
- strings or an object with CSS selector keys and either functions
4378
- or arrays as described above. Returns a closure around a function
4379
- that can be called in the element constructor or applied to an
4380
- individual element. An empty array is considered a no-op.
4381
-
4382
- Called by the getHandler() and getFallback() methods
4383
- */
4384
- decorator(template) {
4385
- if (Array.isArray(template) && template.length == 0) {
4386
- return function(e) {};
4387
- }
4388
- if (Array.isArray(template) && !Array.isArray(template[0])) {
4389
- return this.applyDecorator(template)
4390
- }
4391
- let self = this;
4392
- return function(elt) {
4393
- for (let rule of template) {
4394
- if (elt.matches(rule[0]) || rule[0] === "_") {
4395
- if (Array.isArray(rule[1])) {
4396
- return self.decorator(rule[1]).call(this, elt);
4397
- } else {
4398
- return rule[1].call(this, elt);
4399
- }
4400
- }
4401
- }
4402
- }
4403
- }
4404
-
4405
- applyDecorator(strings) {
4406
- let self = this;
4407
- return function (elt) {
4408
- let copy = [];
4409
- for (let i = 0; i < strings.length; i++) {
4410
- copy.push(self.template(strings[i], elt));
4411
- }
4412
- return self.insert(elt, copy);
4413
- }
4414
- }
4415
-
4416
- /*
4417
- Returns the fallback function for the given element name.
4418
- Called by fallback().
4419
- */
4420
- getFallback(behaviors, fn) {
4421
- if (behaviors[fn]) {
4422
- if (behaviors[fn] instanceof Function) {
4423
- return behaviors[fn];
4424
- } else {
4425
- return this.decorator(behaviors[fn]);
4426
- }
4427
- }
4428
- }
4429
-
4430
- /*
4431
- Returns the handler function for the given element name
4432
- Called by define().
4433
- */
4434
- getHandler(behaviors, fn) {
4435
- if (behaviors[fn]) {
4436
- if (behaviors[fn] instanceof Function) {
4437
- return this.append(behaviors[fn]);
4438
- } else {
4439
- return this.append(this.decorator(behaviors[fn]));
4440
- }
4441
- }
4442
- }
4443
-
4444
- insert(elt, strings) {
4445
- let span = this.document.createElement("span");
4446
- for (let node of Array.from(elt.childNodes)) {
4447
- // nodeType 1 is Node.ELEMENT_NODE
4448
- if (node.nodeType === 1 && !node.hasAttribute("data-processed")) {
4449
- this.processElement(node);
4450
- }
4451
- }
4452
- // If we have before and after tags have them parsed by
4453
- // .innerHTML and then add the content to the resulting child
4454
- if (strings[0].match("<[^>]+>") && strings[1] && strings[1].match("<[^>]+>")) {
4455
- span.innerHTML = strings[0] + elt.innerHTML + (strings[1]?strings[1]:"");
4456
- } else {
4457
- span.innerHTML = strings[0];
4458
- span.setAttribute("data-before", strings[0].replace(/<[^>]+>/g,"").length);
4459
- for (let node of Array.from(elt.childNodes)) {
4460
- span.appendChild(node.cloneNode(true));
4461
- }
4462
- if (strings.length > 1) {
4463
- span.innerHTML += strings[1];
4464
- span.setAttribute("data-after", strings[1].replace(/<[^>]+>/g,"").length);
4465
- }
4466
- }
4467
- return span;
4468
- }
4469
-
4470
- // Runs behaviors recursively on the supplied element and children
4471
- processElement(elt) {
4472
- if (elt.hasAttribute("data-origname") && ! elt.hasAttribute("data-processed")) {
4473
- let fn = this.getFallback(this.bName(elt));
4474
- if (fn) {
4475
- this.append(fn,elt);
4476
- elt.setAttribute("data-processed", "");
4477
- }
4478
- }
4479
- for (let node of Array.from(elt.childNodes)) {
4480
- // nodeType 1 is Node.ELEMENT_NODE
4481
- if (node.nodeType === 1) {
4482
- this.processElement(node);
4483
- }
4484
- }
4485
- }
4486
-
4487
- template(str, elt) {
4488
- let result = str;
4489
- if (str.search(/\$(\w*)(@([a-zA-Z:]+))/ )) {
4490
- let re = /\$(\w*)@([a-zA-Z:]+)/g;
4491
- let replacements;
4492
- while (replacements = re.exec(str)) {
4493
- if (elt.hasAttribute(replacements[2])) {
4494
- if (replacements[1] && this.utilities[replacements[1]]) {
4495
- result = result.replace(replacements[0], this.utilities[replacements[1]](elt.getAttribute(replacements[2])));
4496
- } else {
4497
- result = result.replace(replacements[0], elt.getAttribute(replacements[2]));
4498
- }
4499
- } else {
4500
- result = result.replace(replacements[0], "");
4501
- }
4502
- }
4503
- }
4504
- return result;
4505
- }
4506
-
4507
- // Define or apply behaviors for the document
4508
- applyBehaviors() {
4509
- if (typeof window !== 'undefined' && window.customElements) {
4510
- this.define.call(this, this.els);
4511
- } else {
4512
- this.fallback.call(this, this.els);
4513
- }
4514
- }
4515
-
4516
- /*
4517
- Registers the list of elements provided with the browser.
4518
- Called by makeHTML5(), but can be called independently if, for example,
4519
- you've created Custom Elements via an XSLT transformation instead.
4520
- */
4521
- define(names) {
4522
- for (let name of names) {
4523
- const fn = this.getHandler(this.behaviors, name);
4524
- defineCustomElement(name, fn, this.debug);
4525
- }
4526
- }
4527
-
4528
- /*
4529
- Provides fallback functionality for browsers where Custom Elements
4530
- are not supported.
4531
-
4532
- Like define(), this is called by makeHTML5(), but can be called
4533
- independently.
4534
- */
4535
- fallback(names) {
4536
- for (let name of names) {
4537
- let fn = this.getFallback(this.behaviors, name);
4538
- if (fn) {
4539
- for (let elt of Array.from((
4540
- this.dom && !this.done
4541
- ? this.dom
4542
- : this.document
4543
- ).getElementsByTagName(tagName(name)))) {
4544
- if (!elt.hasAttribute("data-processed")) {
4545
- this.append(fn, elt);
4546
- }
4547
- }
4548
- }
4549
- }
4550
- }
4551
-
4552
- /**********************
4553
- * Utility functions *
4554
- **********************/
4555
-
4556
-
4557
- static savePosition() {
4558
- window.sessionStorage.setItem(window.location + "-scroll", window.scrollY);
4559
- }
4560
-
4561
- static restorePosition() {
4562
- if (!window.location.hash) {
4563
- let scroll;
4564
- if (scroll = window.sessionStorage.getItem(window.location + "-scroll")) {
4565
- setTimeout(function() {
4566
- window.scrollTo(0, scroll);
4567
- }, 100);
4568
- }
4569
- } else {
4570
- setTimeout(function() {
4571
- let h = this.document.querySelector(window.decodeURI(window.location.hash));
4572
- if (h) {
4573
- h.scrollIntoView();
4574
- }
4575
- }, 100);
4576
- }
4577
- }
4578
-
4579
- }
4580
-
4581
- try {
4582
- if (typeof window !== 'undefined') {
4583
- window.CETEI = CETEI;
4584
- window.addEventListener("beforeunload", CETEI.savePosition);
4585
- var ceteiceanLoad = new Event("ceteiceanload");
4586
- window.addEventListener("ceteiceanload", CETEI.restorePosition);
4587
- }
4588
- } catch (e) {
4589
- console.log(e);
4590
- }
4591
-
4592
- /**
4593
- * Component rendering a TEI document using [CETEIcean](https://github.com/TEIC/CETEIcean)
4594
- *
4595
- * Styling of the TEI elements is supported via the `ceteicean` tailwindcss
4596
- * plugin. Add `require('@dracor/react/ceteicean')` to the plugins array of your
4597
- * tailwind.config.js.
4598
- */
4599
- function TEIText({ url }) {
4600
- const ref = react.useRef(null);
4601
- react.useEffect(() => {
4602
- var _a;
4603
- const CETEIcean = new CETEI();
4604
- while ((_a = ref.current) === null || _a === void 0 ? void 0 : _a.firstChild) {
4605
- ref.current.removeChild(ref.current.firstChild);
4606
- }
4607
- CETEIcean.getHTML5(url, (data) => {
4608
- var _a;
4609
- (_a = ref.current) === null || _a === void 0 ? void 0 : _a.appendChild(data);
4610
- });
4611
- }, [url]);
4612
- return (jsxRuntime.jsx("div", { children: jsxRuntime.jsx("div", { ref: ref }) }));
4613
- }
4614
-
4615
- function Years({ written, premiere, print, locale, labelPremiered = 'premiered', labelPrinted = 'printed', labelWritten = 'written', }) {
4616
- return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [written && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs("span", { title: labelWritten, children: [jsxRuntime.jsx(reactFontawesome.FontAwesomeIcon, { icon: freeSolidSvgIcons.faPenFancy, size: "sm" }), "\u00A0", formatYear(written, locale)] }), ' '] })), premiere && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs("span", { title: labelPremiered, children: [jsxRuntime.jsx(reactFontawesome.FontAwesomeIcon, { icon: freeSolidSvgIcons.faTheaterMasks, size: "sm" }), "\u00A0", formatYear(premiere, locale)] }), ' '] })), print && (jsxRuntime.jsxs("span", { title: labelPrinted, children: [jsxRuntime.jsx(reactFontawesome.FontAwesomeIcon, { icon: freeSolidSvgIcons.faBook, size: "sm" }), "\u00A0", formatYear(print, locale)] }))] }));
4617
- }
4618
-
4619
- exports.AuthorInfo = AuthorInfo;
4620
- exports.Authors = Authors;
4621
- exports.DebouncedInput = DebouncedInput;
4622
- exports.IdCopy = IdCopy;
4623
- exports.IdLink = IdLink;
4624
- exports.NavBar = NavBar;
4625
- exports.TEIText = TEIText;
4626
- exports.Table = Table;
4627
- exports.Tabs = Tabs;
4628
- exports.Years = Years;
4629
- exports.formatEra = formatEra;
4630
- exports.formatYear = formatYear;
4631
- //# sourceMappingURL=index.js.map