@dracor/react 0.7.0 → 0.9.0

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