@valaxyjs/devtools 0.18.7 → 0.18.8

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