yxuse 3.0.41 → 3.0.43

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (163) hide show
  1. package/README.md +12 -568
  2. package/lib/api.cjs.js +2 -1
  3. package/lib/api.cjs.js.map +1 -0
  4. package/lib/api.es.js +5 -4
  5. package/lib/api.es.js.map +1 -0
  6. package/lib/app.cjs.js +2 -1
  7. package/lib/app.cjs.js.map +1 -0
  8. package/lib/app.es.js +2 -1
  9. package/lib/app.es.js.map +1 -0
  10. package/lib/components.cjs.js +2 -1
  11. package/lib/components.cjs.js.map +1 -0
  12. package/lib/components.es.js +7 -6
  13. package/lib/components.es.js.map +1 -0
  14. package/lib/dayjs.min.cjs.js +2 -0
  15. package/lib/dayjs.min.cjs.js.map +1 -0
  16. package/lib/dayjs.min.es.js +313 -0
  17. package/lib/dayjs.min.es.js.gz +0 -0
  18. package/lib/dayjs.min.es.js.map +1 -0
  19. package/lib/directives.cjs.js +2 -1
  20. package/lib/directives.cjs.js.map +1 -0
  21. package/lib/directives.es.js +2 -1
  22. package/lib/directives.es.js.map +1 -0
  23. package/lib/hooks.cjs.js +2 -1
  24. package/lib/hooks.cjs.js.map +1 -0
  25. package/lib/hooks.es.js +2 -1
  26. package/lib/hooks.es.js.map +1 -0
  27. package/lib/index.cjs.js +2 -1
  28. package/lib/index.cjs.js.map +1 -0
  29. package/lib/index.cjs10.js +2 -1
  30. package/lib/index.cjs10.js.map +1 -0
  31. package/lib/index.cjs11.js +2 -1
  32. package/lib/index.cjs11.js.map +1 -0
  33. package/lib/index.cjs12.js +2 -1
  34. package/lib/index.cjs12.js.gz +0 -0
  35. package/lib/index.cjs12.js.map +1 -0
  36. package/lib/index.cjs13.js +2 -1
  37. package/lib/index.cjs13.js.map +1 -0
  38. package/lib/index.cjs14.js +2 -0
  39. package/lib/index.cjs14.js.map +1 -0
  40. package/lib/index.cjs2.js +2 -1
  41. package/lib/index.cjs2.js.map +1 -0
  42. package/lib/index.cjs3.js +2 -1
  43. package/lib/index.cjs3.js.map +1 -0
  44. package/lib/index.cjs4.js +2 -1
  45. package/lib/index.cjs4.js.map +1 -0
  46. package/lib/index.cjs5.js +7 -5
  47. package/lib/index.cjs5.js.gz +0 -0
  48. package/lib/index.cjs5.js.map +1 -0
  49. package/lib/index.cjs6.js +5 -1
  50. package/lib/index.cjs6.js.gz +0 -0
  51. package/lib/index.cjs6.js.map +1 -0
  52. package/lib/index.cjs7.js +17 -1
  53. package/lib/index.cjs7.js.gz +0 -0
  54. package/lib/index.cjs7.js.map +1 -0
  55. package/lib/index.cjs8.js +2 -1
  56. package/lib/index.cjs8.js.map +1 -0
  57. package/lib/index.cjs9.js +2 -1
  58. package/lib/index.cjs9.js.map +1 -0
  59. package/lib/index.es.js +8 -17
  60. package/lib/index.es.js.map +1 -0
  61. package/lib/index.es10.js +11 -298
  62. package/lib/index.es10.js.map +1 -0
  63. package/lib/index.es11.js +16 -2363
  64. package/lib/index.es11.js.map +1 -0
  65. package/lib/index.es12.js +2808 -151
  66. package/lib/index.es12.js.gz +0 -0
  67. package/lib/index.es12.js.map +1 -0
  68. package/lib/index.es13.js +231 -20
  69. package/lib/index.es13.js.map +1 -0
  70. package/lib/index.es14.js +23 -0
  71. package/lib/index.es14.js.map +1 -0
  72. package/lib/index.es2.js +101 -3
  73. package/lib/index.es2.js.map +1 -0
  74. package/lib/index.es3.js +3 -2
  75. package/lib/index.es3.js.map +1 -0
  76. package/lib/index.es4.js +3 -2
  77. package/lib/index.es4.js.map +1 -0
  78. package/lib/index.es5.js +14644 -135
  79. package/lib/index.es5.js.gz +0 -0
  80. package/lib/index.es5.js.map +1 -0
  81. package/lib/index.es6.js +20644 -603
  82. package/lib/index.es6.js.gz +0 -0
  83. package/lib/index.es6.js.map +1 -0
  84. package/lib/index.es7.js +5386 -17
  85. package/lib/index.es7.js.gz +0 -0
  86. package/lib/index.es7.js.map +1 -0
  87. package/lib/index.es8.js +25 -4
  88. package/lib/index.es8.js.map +1 -0
  89. package/lib/index.es9.js +5 -9
  90. package/lib/index.es9.js.map +1 -0
  91. package/lib/style.css +1 -1
  92. package/lib/style.css.gz +0 -0
  93. package/lib/theme.cjs.js +2 -1
  94. package/lib/theme.cjs.js.map +1 -0
  95. package/lib/theme.es.js +14 -11
  96. package/lib/theme.es.js.map +1 -0
  97. package/lib/translate.cjs.js +2 -1
  98. package/lib/translate.cjs.js.map +1 -0
  99. package/lib/translate.es.js +12 -6
  100. package/lib/translate.es.js.map +1 -0
  101. package/lib/utils.cjs.js +2 -1
  102. package/lib/utils.cjs.js.map +1 -0
  103. package/lib/utils.es.js +13 -7
  104. package/lib/utils.es.js.map +1 -0
  105. package/lib/yxIcon.cjs.js +2 -1
  106. package/lib/yxIcon.cjs.js.map +1 -0
  107. package/lib/yxIcon.es.js +3 -2
  108. package/lib/yxIcon.es.js.map +1 -0
  109. package/lib/yxi18n.cjs.js +2 -0
  110. package/lib/yxi18n.cjs.js.map +1 -0
  111. package/lib/yxi18n.es.js +6 -0
  112. package/lib/yxi18n.es.js.map +1 -0
  113. package/package.json +14 -6
  114. package/types/api/auth/index.d.ts +2 -0
  115. package/types/components/Common/DynamicComponent/index.vue.d.ts +5 -4
  116. package/types/components/Toolbar/index.d.ts +1 -0
  117. package/types/components/Toolbar/src/index.vue.d.ts +1 -1
  118. package/types/components/Toolbar/src/utils/mounted.d.ts +1 -0
  119. package/types/components/Update/index.d.ts +1 -1
  120. package/types/components/Update/index.vue.d.ts +1 -1
  121. package/types/components/YxDialog/index.d.ts +3 -3
  122. package/types/components/YxDialog/index.vue.d.ts +4 -3
  123. package/types/components/YxDrawer/index.d.ts +3 -0
  124. package/types/components/YxDrawer/index.vue.d.ts +14 -0
  125. package/types/components/YxDrawer/type.d.ts +18 -0
  126. package/types/components/YxForm/index.d.ts +3 -3
  127. package/types/components/YxForm/index.vue.d.ts +47 -0
  128. package/types/components/YxForm/type.d.ts +69 -0
  129. package/types/components/YxIcon/index.d.ts +3 -3
  130. package/types/components/YxIcon/type.d.ts +1 -0
  131. package/types/components/YxSearchForm/index.d.ts +3 -3
  132. package/types/components/YxSearchForm/index.vue.d.ts +8 -7
  133. package/types/components/YxTable/index.d.ts +3 -3
  134. package/types/components/YxTable/index.vue.d.ts +8 -8
  135. package/types/components/YxTable/type.d.ts +18 -6
  136. package/types/components/YxUpload/index.d.ts +3 -3
  137. package/types/components/YxUpload/index.vue.d.ts +7 -4
  138. package/types/components/YxUpload/type.d.ts +7 -1
  139. package/types/components/index.d.ts +9 -9
  140. package/types/components/type.d.ts +5 -5
  141. package/types/directives/index.d.ts +2 -1
  142. package/types/directives/modules/auth.d.ts +2 -1
  143. package/types/hooks/index.d.ts +1 -1
  144. package/types/hooks/useTime/index.d.ts +1 -1
  145. package/types/index.d.ts +12 -12
  146. package/types/theme/config.d.ts +2 -0
  147. package/types/theme/index.d.ts +2 -1
  148. package/types/translate/index.d.ts +3 -1
  149. package/types/utils/common/index.d.ts +20 -1
  150. package/types/utils/common/util.d.ts +2 -1
  151. package/types/utils/excel/index.d.ts +35 -0
  152. package/types/utils/fecth/index.d.ts +8 -0
  153. package/types/utils/fecth/interface.d.ts +8 -0
  154. package/types/utils/http/config.d.ts +1 -0
  155. package/types/utils/http/index.d.ts +2 -1
  156. package/types/utils/index.d.ts +4 -3
  157. package/types/utils/mqtt/index.d.ts +16 -0
  158. package/types/utils/mqtt/interface.d.ts +17 -0
  159. package/types/yxIcon/index.d.ts +2 -1
  160. package/types/yxi18n/index.d.ts +2 -4
  161. package/lib/index.cjs11.js.gz +0 -0
  162. package/lib/index.es10.js.gz +0 -0
  163. package/lib/index.es11.js.gz +0 -0
package/lib/index.es12.js CHANGED
@@ -1,197 +1,2854 @@
1
1
  var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : Symbol.for("Symbol." + name);
8
+ var __typeError = (msg) => {
9
+ throw TypeError(msg);
10
+ };
2
11
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
12
+ var __spreadValues = (a, b) => {
13
+ for (var prop in b || (b = {}))
14
+ if (__hasOwnProp.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ if (__getOwnPropSymbols)
17
+ for (var prop of __getOwnPropSymbols(b)) {
18
+ if (__propIsEnum.call(b, prop))
19
+ __defNormalProp(a, prop, b[prop]);
20
+ }
21
+ return a;
22
+ };
23
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
3
24
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
- const notifyMessageToSystems = (message) => {
5
- const themeBc = new BroadcastChannel("YXUSE_BC");
6
- themeBc.postMessage(message);
25
+ var __async = (__this, __arguments, generator) => {
26
+ return new Promise((resolve, reject) => {
27
+ var fulfilled = (value) => {
28
+ try {
29
+ step(generator.next(value));
30
+ } catch (e) {
31
+ reject(e);
32
+ }
33
+ };
34
+ var rejected = (value) => {
35
+ try {
36
+ step(generator.throw(value));
37
+ } catch (e) {
38
+ reject(e);
39
+ }
40
+ };
41
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
42
+ step((generator = generator.apply(__this, __arguments)).next());
43
+ });
44
+ };
45
+ var __await = function(promise, isYieldStar) {
46
+ this[0] = promise;
47
+ this[1] = isYieldStar;
48
+ };
49
+ var __asyncGenerator = (__this, __arguments, generator) => {
50
+ var resume = (k, v, yes, no) => {
51
+ try {
52
+ var x = generator[k](v), isAwait = (v = x.value) instanceof __await, done = x.done;
53
+ Promise.resolve(isAwait ? v[0] : v).then((y) => isAwait ? resume(k === "return" ? k : "next", v[1] ? { done: y.done, value: y.value } : y, yes, no) : yes({ value: y, done })).catch((e) => resume("throw", e, yes, no));
54
+ } catch (e) {
55
+ no(e);
56
+ }
57
+ }, method = (k) => it[k] = (x) => new Promise((yes, no) => resume(k, x, yes, no)), it = {};
58
+ return generator = generator.apply(__this, __arguments), it[__knownSymbol("asyncIterator")] = () => it, method("next"), method("throw"), method("return"), it;
59
+ };
60
+ var __yieldStar = (value) => {
61
+ var obj = value[__knownSymbol("asyncIterator")], isAwait = false, method, it = {};
62
+ if (obj == null) {
63
+ obj = value[__knownSymbol("iterator")]();
64
+ method = (k) => it[k] = (x) => obj[k](x);
65
+ } else {
66
+ obj = obj.call(value);
67
+ method = (k) => it[k] = (v) => {
68
+ if (isAwait) {
69
+ isAwait = false;
70
+ if (k === "throw") throw v;
71
+ return v;
72
+ }
73
+ isAwait = true;
74
+ return {
75
+ done: false,
76
+ value: new __await(new Promise((resolve) => {
77
+ var x = obj[k](v);
78
+ if (!(x instanceof Object)) __typeError("Object expected");
79
+ resolve(x);
80
+ }), 1)
81
+ };
82
+ };
83
+ }
84
+ return it[__knownSymbol("iterator")] = () => it, method("next"), "throw" in obj ? method("throw") : it.throw = (x) => {
85
+ throw x;
86
+ }, "return" in obj && method("return"), it;
87
+ };
88
+ var __forAwait = (obj, it, method) => (it = obj[__knownSymbol("asyncIterator")]) ? it.call(obj) : (obj = obj[__knownSymbol("iterator")](), it = {}, method = (key, fn) => (fn = obj[key]) && (it[key] = (arg) => new Promise((yes, no, done) => (arg = fn.call(obj, arg), done = arg.done, Promise.resolve(arg.value).then((value) => yes({ value, done }), no)))), method("next"), method("return"), it);
89
+ import { ElMessage, ElLoading, ElNotification } from "element-plus";
90
+ function bind(fn, thisArg) {
91
+ return function wrap() {
92
+ return fn.apply(thisArg, arguments);
93
+ };
94
+ }
95
+ const { toString } = Object.prototype;
96
+ const { getPrototypeOf } = Object;
97
+ const kindOf = /* @__PURE__ */ ((cache) => (thing) => {
98
+ const str = toString.call(thing);
99
+ return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase());
100
+ })(/* @__PURE__ */ Object.create(null));
101
+ const kindOfTest = (type) => {
102
+ type = type.toLowerCase();
103
+ return (thing) => kindOf(thing) === type;
104
+ };
105
+ const typeOfTest = (type) => (thing) => typeof thing === type;
106
+ const { isArray } = Array;
107
+ const isUndefined = typeOfTest("undefined");
108
+ function isBuffer(val) {
109
+ return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor) && isFunction(val.constructor.isBuffer) && val.constructor.isBuffer(val);
110
+ }
111
+ const isArrayBuffer = kindOfTest("ArrayBuffer");
112
+ function isArrayBufferView(val) {
113
+ let result;
114
+ if (typeof ArrayBuffer !== "undefined" && ArrayBuffer.isView) {
115
+ result = ArrayBuffer.isView(val);
116
+ } else {
117
+ result = val && val.buffer && isArrayBuffer(val.buffer);
118
+ }
119
+ return result;
120
+ }
121
+ const isString = typeOfTest("string");
122
+ const isFunction = typeOfTest("function");
123
+ const isNumber = typeOfTest("number");
124
+ const isObject = (thing) => thing !== null && typeof thing === "object";
125
+ const isBoolean = (thing) => thing === true || thing === false;
126
+ const isPlainObject = (val) => {
127
+ if (kindOf(val) !== "object") {
128
+ return false;
129
+ }
130
+ const prototype2 = getPrototypeOf(val);
131
+ return (prototype2 === null || prototype2 === Object.prototype || Object.getPrototypeOf(prototype2) === null) && !(Symbol.toStringTag in val) && !(Symbol.iterator in val);
132
+ };
133
+ const isDate = kindOfTest("Date");
134
+ const isFile = kindOfTest("File");
135
+ const isBlob = kindOfTest("Blob");
136
+ const isFileList = kindOfTest("FileList");
137
+ const isStream = (val) => isObject(val) && isFunction(val.pipe);
138
+ const isFormData = (thing) => {
139
+ let kind;
140
+ return thing && (typeof FormData === "function" && thing instanceof FormData || isFunction(thing.append) && ((kind = kindOf(thing)) === "formdata" || // detect form-data instance
141
+ kind === "object" && isFunction(thing.toString) && thing.toString() === "[object FormData]"));
142
+ };
143
+ const isURLSearchParams = kindOfTest("URLSearchParams");
144
+ const [isReadableStream, isRequest, isResponse, isHeaders] = ["ReadableStream", "Request", "Response", "Headers"].map(kindOfTest);
145
+ const trim = (str) => str.trim ? str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "");
146
+ function forEach(obj, fn, { allOwnKeys = false } = {}) {
147
+ if (obj === null || typeof obj === "undefined") {
148
+ return;
149
+ }
150
+ let i;
151
+ let l;
152
+ if (typeof obj !== "object") {
153
+ obj = [obj];
154
+ }
155
+ if (isArray(obj)) {
156
+ for (i = 0, l = obj.length; i < l; i++) {
157
+ fn.call(null, obj[i], i, obj);
158
+ }
159
+ } else {
160
+ const keys = allOwnKeys ? Object.getOwnPropertyNames(obj) : Object.keys(obj);
161
+ const len = keys.length;
162
+ let key;
163
+ for (i = 0; i < len; i++) {
164
+ key = keys[i];
165
+ fn.call(null, obj[key], key, obj);
166
+ }
167
+ }
168
+ }
169
+ function findKey(obj, key) {
170
+ key = key.toLowerCase();
171
+ const keys = Object.keys(obj);
172
+ let i = keys.length;
173
+ let _key;
174
+ while (i-- > 0) {
175
+ _key = keys[i];
176
+ if (key === _key.toLowerCase()) {
177
+ return _key;
178
+ }
179
+ }
180
+ return null;
181
+ }
182
+ const _global = (() => {
183
+ if (typeof globalThis !== "undefined") return globalThis;
184
+ return typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : global;
185
+ })();
186
+ const isContextDefined = (context) => !isUndefined(context) && context !== _global;
187
+ function merge() {
188
+ const { caseless } = isContextDefined(this) && this || {};
189
+ const result = {};
190
+ const assignValue = (val, key) => {
191
+ const targetKey = caseless && findKey(result, key) || key;
192
+ if (isPlainObject(result[targetKey]) && isPlainObject(val)) {
193
+ result[targetKey] = merge(result[targetKey], val);
194
+ } else if (isPlainObject(val)) {
195
+ result[targetKey] = merge({}, val);
196
+ } else if (isArray(val)) {
197
+ result[targetKey] = val.slice();
198
+ } else {
199
+ result[targetKey] = val;
200
+ }
201
+ };
202
+ for (let i = 0, l = arguments.length; i < l; i++) {
203
+ arguments[i] && forEach(arguments[i], assignValue);
204
+ }
205
+ return result;
206
+ }
207
+ const extend = (a, b, thisArg, { allOwnKeys } = {}) => {
208
+ forEach(b, (val, key) => {
209
+ if (thisArg && isFunction(val)) {
210
+ a[key] = bind(val, thisArg);
211
+ } else {
212
+ a[key] = val;
213
+ }
214
+ }, { allOwnKeys });
215
+ return a;
216
+ };
217
+ const stripBOM = (content) => {
218
+ if (content.charCodeAt(0) === 65279) {
219
+ content = content.slice(1);
220
+ }
221
+ return content;
222
+ };
223
+ const inherits = (constructor, superConstructor, props, descriptors2) => {
224
+ constructor.prototype = Object.create(superConstructor.prototype, descriptors2);
225
+ constructor.prototype.constructor = constructor;
226
+ Object.defineProperty(constructor, "super", {
227
+ value: superConstructor.prototype
228
+ });
229
+ props && Object.assign(constructor.prototype, props);
230
+ };
231
+ const toFlatObject = (sourceObj, destObj, filter2, propFilter) => {
232
+ let props;
233
+ let i;
234
+ let prop;
235
+ const merged = {};
236
+ destObj = destObj || {};
237
+ if (sourceObj == null) return destObj;
238
+ do {
239
+ props = Object.getOwnPropertyNames(sourceObj);
240
+ i = props.length;
241
+ while (i-- > 0) {
242
+ prop = props[i];
243
+ if ((!propFilter || propFilter(prop, sourceObj, destObj)) && !merged[prop]) {
244
+ destObj[prop] = sourceObj[prop];
245
+ merged[prop] = true;
246
+ }
247
+ }
248
+ sourceObj = filter2 !== false && getPrototypeOf(sourceObj);
249
+ } while (sourceObj && (!filter2 || filter2(sourceObj, destObj)) && sourceObj !== Object.prototype);
250
+ return destObj;
251
+ };
252
+ const endsWith = (str, searchString, position) => {
253
+ str = String(str);
254
+ if (position === void 0 || position > str.length) {
255
+ position = str.length;
256
+ }
257
+ position -= searchString.length;
258
+ const lastIndex = str.indexOf(searchString, position);
259
+ return lastIndex !== -1 && lastIndex === position;
260
+ };
261
+ const toArray = (thing) => {
262
+ if (!thing) return null;
263
+ if (isArray(thing)) return thing;
264
+ let i = thing.length;
265
+ if (!isNumber(i)) return null;
266
+ const arr = new Array(i);
267
+ while (i-- > 0) {
268
+ arr[i] = thing[i];
269
+ }
270
+ return arr;
271
+ };
272
+ const isTypedArray = /* @__PURE__ */ ((TypedArray) => {
273
+ return (thing) => {
274
+ return TypedArray && thing instanceof TypedArray;
275
+ };
276
+ })(typeof Uint8Array !== "undefined" && getPrototypeOf(Uint8Array));
277
+ const forEachEntry = (obj, fn) => {
278
+ const generator = obj && obj[Symbol.iterator];
279
+ const iterator = generator.call(obj);
280
+ let result;
281
+ while ((result = iterator.next()) && !result.done) {
282
+ const pair = result.value;
283
+ fn.call(obj, pair[0], pair[1]);
284
+ }
7
285
  };
8
- const receiveMessage = (callback) => {
9
- const themeBc = new BroadcastChannel("YXUSE_BC");
10
- themeBc.onmessage = () => {
11
- callback();
286
+ const matchAll = (regExp, str) => {
287
+ let matches;
288
+ const arr = [];
289
+ while ((matches = regExp.exec(str)) !== null) {
290
+ arr.push(matches);
291
+ }
292
+ return arr;
293
+ };
294
+ const isHTMLForm = kindOfTest("HTMLFormElement");
295
+ const toCamelCase = (str) => {
296
+ return str.toLowerCase().replace(
297
+ /[-_\s]([a-z\d])(\w*)/g,
298
+ function replacer(m, p1, p2) {
299
+ return p1.toUpperCase() + p2;
300
+ }
301
+ );
302
+ };
303
+ const hasOwnProperty = (({ hasOwnProperty: hasOwnProperty2 }) => (obj, prop) => hasOwnProperty2.call(obj, prop))(Object.prototype);
304
+ const isRegExp = kindOfTest("RegExp");
305
+ const reduceDescriptors = (obj, reducer) => {
306
+ const descriptors2 = Object.getOwnPropertyDescriptors(obj);
307
+ const reducedDescriptors = {};
308
+ forEach(descriptors2, (descriptor, name) => {
309
+ let ret;
310
+ if ((ret = reducer(descriptor, name, obj)) !== false) {
311
+ reducedDescriptors[name] = ret || descriptor;
312
+ }
313
+ });
314
+ Object.defineProperties(obj, reducedDescriptors);
315
+ };
316
+ const freezeMethods = (obj) => {
317
+ reduceDescriptors(obj, (descriptor, name) => {
318
+ if (isFunction(obj) && ["arguments", "caller", "callee"].indexOf(name) !== -1) {
319
+ return false;
320
+ }
321
+ const value = obj[name];
322
+ if (!isFunction(value)) return;
323
+ descriptor.enumerable = false;
324
+ if ("writable" in descriptor) {
325
+ descriptor.writable = false;
326
+ return;
327
+ }
328
+ if (!descriptor.set) {
329
+ descriptor.set = () => {
330
+ throw Error("Can not rewrite read-only method '" + name + "'");
331
+ };
332
+ }
333
+ });
334
+ };
335
+ const toObjectSet = (arrayOrString, delimiter) => {
336
+ const obj = {};
337
+ const define = (arr) => {
338
+ arr.forEach((value) => {
339
+ obj[value] = true;
340
+ });
12
341
  };
342
+ isArray(arrayOrString) ? define(arrayOrString) : define(String(arrayOrString).split(delimiter));
343
+ return obj;
344
+ };
345
+ const noop = () => {
346
+ };
347
+ const toFiniteNumber = (value, defaultValue) => {
348
+ return value != null && Number.isFinite(value = +value) ? value : defaultValue;
349
+ };
350
+ const ALPHA = "abcdefghijklmnopqrstuvwxyz";
351
+ const DIGIT = "0123456789";
352
+ const ALPHABET = {
353
+ DIGIT,
354
+ ALPHA,
355
+ ALPHA_DIGIT: ALPHA + ALPHA.toUpperCase() + DIGIT
13
356
  };
14
- const getSelectOptions = (arr, labelKey, valueKey, isValueToNumber) => {
15
- if (!Array.isArray(arr)) return [];
16
- return arr.map((item) => {
357
+ const generateString = (size = 16, alphabet = ALPHABET.ALPHA_DIGIT) => {
358
+ let str = "";
359
+ const { length } = alphabet;
360
+ while (size--) {
361
+ str += alphabet[Math.random() * length | 0];
362
+ }
363
+ return str;
364
+ };
365
+ function isSpecCompliantForm(thing) {
366
+ return !!(thing && isFunction(thing.append) && thing[Symbol.toStringTag] === "FormData" && thing[Symbol.iterator]);
367
+ }
368
+ const toJSONObject = (obj) => {
369
+ const stack = new Array(10);
370
+ const visit = (source, i) => {
371
+ if (isObject(source)) {
372
+ if (stack.indexOf(source) >= 0) {
373
+ return;
374
+ }
375
+ if (!("toJSON" in source)) {
376
+ stack[i] = source;
377
+ const target = isArray(source) ? [] : {};
378
+ forEach(source, (value, key) => {
379
+ const reducedValue = visit(value, i + 1);
380
+ !isUndefined(reducedValue) && (target[key] = reducedValue);
381
+ });
382
+ stack[i] = void 0;
383
+ return target;
384
+ }
385
+ }
386
+ return source;
387
+ };
388
+ return visit(obj, 0);
389
+ };
390
+ const isAsyncFn = kindOfTest("AsyncFunction");
391
+ const isThenable = (thing) => thing && (isObject(thing) || isFunction(thing)) && isFunction(thing.then) && isFunction(thing.catch);
392
+ const _setImmediate = ((setImmediateSupported, postMessageSupported) => {
393
+ if (setImmediateSupported) {
394
+ return setImmediate;
395
+ }
396
+ return postMessageSupported ? ((token, callbacks) => {
397
+ _global.addEventListener("message", ({ source, data }) => {
398
+ if (source === _global && data === token) {
399
+ callbacks.length && callbacks.shift()();
400
+ }
401
+ }, false);
402
+ return (cb) => {
403
+ callbacks.push(cb);
404
+ _global.postMessage(token, "*");
405
+ };
406
+ })(`axios@${Math.random()}`, []) : (cb) => setTimeout(cb);
407
+ })(
408
+ typeof setImmediate === "function",
409
+ isFunction(_global.postMessage)
410
+ );
411
+ const asap = typeof queueMicrotask !== "undefined" ? queueMicrotask.bind(_global) : typeof process !== "undefined" && process.nextTick || _setImmediate;
412
+ const utils$1 = {
413
+ isArray,
414
+ isArrayBuffer,
415
+ isBuffer,
416
+ isFormData,
417
+ isArrayBufferView,
418
+ isString,
419
+ isNumber,
420
+ isBoolean,
421
+ isObject,
422
+ isPlainObject,
423
+ isReadableStream,
424
+ isRequest,
425
+ isResponse,
426
+ isHeaders,
427
+ isUndefined,
428
+ isDate,
429
+ isFile,
430
+ isBlob,
431
+ isRegExp,
432
+ isFunction,
433
+ isStream,
434
+ isURLSearchParams,
435
+ isTypedArray,
436
+ isFileList,
437
+ forEach,
438
+ merge,
439
+ extend,
440
+ trim,
441
+ stripBOM,
442
+ inherits,
443
+ toFlatObject,
444
+ kindOf,
445
+ kindOfTest,
446
+ endsWith,
447
+ toArray,
448
+ forEachEntry,
449
+ matchAll,
450
+ isHTMLForm,
451
+ hasOwnProperty,
452
+ hasOwnProp: hasOwnProperty,
453
+ // an alias to avoid ESLint no-prototype-builtins detection
454
+ reduceDescriptors,
455
+ freezeMethods,
456
+ toObjectSet,
457
+ toCamelCase,
458
+ noop,
459
+ toFiniteNumber,
460
+ findKey,
461
+ global: _global,
462
+ isContextDefined,
463
+ ALPHABET,
464
+ generateString,
465
+ isSpecCompliantForm,
466
+ toJSONObject,
467
+ isAsyncFn,
468
+ isThenable,
469
+ setImmediate: _setImmediate,
470
+ asap
471
+ };
472
+ function AxiosError$1(message, code, config2, request, response) {
473
+ Error.call(this);
474
+ if (Error.captureStackTrace) {
475
+ Error.captureStackTrace(this, this.constructor);
476
+ } else {
477
+ this.stack = new Error().stack;
478
+ }
479
+ this.message = message;
480
+ this.name = "AxiosError";
481
+ code && (this.code = code);
482
+ config2 && (this.config = config2);
483
+ request && (this.request = request);
484
+ if (response) {
485
+ this.response = response;
486
+ this.status = response.status ? response.status : null;
487
+ }
488
+ }
489
+ utils$1.inherits(AxiosError$1, Error, {
490
+ toJSON: function toJSON() {
17
491
  return {
18
- label: item == null ? void 0 : item[labelKey],
19
- value: isValueToNumber ? +item[valueKey] : item[valueKey]
492
+ // Standard
493
+ message: this.message,
494
+ name: this.name,
495
+ // Microsoft
496
+ description: this.description,
497
+ number: this.number,
498
+ // Mozilla
499
+ fileName: this.fileName,
500
+ lineNumber: this.lineNumber,
501
+ columnNumber: this.columnNumber,
502
+ stack: this.stack,
503
+ // Axios
504
+ config: utils$1.toJSONObject(this.config),
505
+ code: this.code,
506
+ status: this.status
20
507
  };
508
+ }
509
+ });
510
+ const prototype$1 = AxiosError$1.prototype;
511
+ const descriptors = {};
512
+ [
513
+ "ERR_BAD_OPTION_VALUE",
514
+ "ERR_BAD_OPTION",
515
+ "ECONNABORTED",
516
+ "ETIMEDOUT",
517
+ "ERR_NETWORK",
518
+ "ERR_FR_TOO_MANY_REDIRECTS",
519
+ "ERR_DEPRECATED",
520
+ "ERR_BAD_RESPONSE",
521
+ "ERR_BAD_REQUEST",
522
+ "ERR_CANCELED",
523
+ "ERR_NOT_SUPPORT",
524
+ "ERR_INVALID_URL"
525
+ // eslint-disable-next-line func-names
526
+ ].forEach((code) => {
527
+ descriptors[code] = { value: code };
528
+ });
529
+ Object.defineProperties(AxiosError$1, descriptors);
530
+ Object.defineProperty(prototype$1, "isAxiosError", { value: true });
531
+ AxiosError$1.from = (error, code, config2, request, response, customProps) => {
532
+ const axiosError = Object.create(prototype$1);
533
+ utils$1.toFlatObject(error, axiosError, function filter2(obj) {
534
+ return obj !== Error.prototype;
535
+ }, (prop) => {
536
+ return prop !== "isAxiosError";
21
537
  });
538
+ AxiosError$1.call(axiosError, error.message, code, config2, request, response);
539
+ axiosError.cause = error;
540
+ axiosError.name = error.name;
541
+ customProps && Object.assign(axiosError, customProps);
542
+ return axiosError;
22
543
  };
23
- const enumToArray = (enumObject) => {
24
- const result = [];
25
- for (const key in enumObject) {
26
- if (isNaN(Number(key))) {
27
- result.push({ label: key, value: enumObject[key] });
544
+ const httpAdapter = null;
545
+ function isVisitable(thing) {
546
+ return utils$1.isPlainObject(thing) || utils$1.isArray(thing);
547
+ }
548
+ function removeBrackets(key) {
549
+ return utils$1.endsWith(key, "[]") ? key.slice(0, -2) : key;
550
+ }
551
+ function renderKey(path, key, dots) {
552
+ if (!path) return key;
553
+ return path.concat(key).map(function each(token, i) {
554
+ token = removeBrackets(token);
555
+ return !dots && i ? "[" + token + "]" : token;
556
+ }).join(dots ? "." : "");
557
+ }
558
+ function isFlatArray(arr) {
559
+ return utils$1.isArray(arr) && !arr.some(isVisitable);
560
+ }
561
+ const predicates = utils$1.toFlatObject(utils$1, {}, null, function filter(prop) {
562
+ return /^is[A-Z]/.test(prop);
563
+ });
564
+ function toFormData$1(obj, formData, options) {
565
+ if (!utils$1.isObject(obj)) {
566
+ throw new TypeError("target must be an object");
567
+ }
568
+ formData = formData || new FormData();
569
+ options = utils$1.toFlatObject(options, {
570
+ metaTokens: true,
571
+ dots: false,
572
+ indexes: false
573
+ }, false, function defined(option, source) {
574
+ return !utils$1.isUndefined(source[option]);
575
+ });
576
+ const metaTokens = options.metaTokens;
577
+ const visitor = options.visitor || defaultVisitor;
578
+ const dots = options.dots;
579
+ const indexes = options.indexes;
580
+ const _Blob = options.Blob || typeof Blob !== "undefined" && Blob;
581
+ const useBlob = _Blob && utils$1.isSpecCompliantForm(formData);
582
+ if (!utils$1.isFunction(visitor)) {
583
+ throw new TypeError("visitor must be a function");
584
+ }
585
+ function convertValue(value) {
586
+ if (value === null) return "";
587
+ if (utils$1.isDate(value)) {
588
+ return value.toISOString();
589
+ }
590
+ if (!useBlob && utils$1.isBlob(value)) {
591
+ throw new AxiosError$1("Blob is not supported. Use a Buffer instead.");
28
592
  }
593
+ if (utils$1.isArrayBuffer(value) || utils$1.isTypedArray(value)) {
594
+ return useBlob && typeof Blob === "function" ? new Blob([value]) : Buffer.from(value);
595
+ }
596
+ return value;
29
597
  }
30
- return result;
598
+ function defaultVisitor(value, key, path) {
599
+ let arr = value;
600
+ if (value && !path && typeof value === "object") {
601
+ if (utils$1.endsWith(key, "{}")) {
602
+ key = metaTokens ? key : key.slice(0, -2);
603
+ value = JSON.stringify(value);
604
+ } else if (utils$1.isArray(value) && isFlatArray(value) || (utils$1.isFileList(value) || utils$1.endsWith(key, "[]")) && (arr = utils$1.toArray(value))) {
605
+ key = removeBrackets(key);
606
+ arr.forEach(function each(el, index2) {
607
+ !(utils$1.isUndefined(el) || el === null) && formData.append(
608
+ // eslint-disable-next-line no-nested-ternary
609
+ indexes === true ? renderKey([key], index2, dots) : indexes === null ? key : key + "[]",
610
+ convertValue(el)
611
+ );
612
+ });
613
+ return false;
614
+ }
615
+ }
616
+ if (isVisitable(value)) {
617
+ return true;
618
+ }
619
+ formData.append(renderKey(path, key, dots), convertValue(value));
620
+ return false;
621
+ }
622
+ const stack = [];
623
+ const exposedHelpers = Object.assign(predicates, {
624
+ defaultVisitor,
625
+ convertValue,
626
+ isVisitable
627
+ });
628
+ function build(value, path) {
629
+ if (utils$1.isUndefined(value)) return;
630
+ if (stack.indexOf(value) !== -1) {
631
+ throw Error("Circular reference detected in " + path.join("."));
632
+ }
633
+ stack.push(value);
634
+ utils$1.forEach(value, function each(el, key) {
635
+ const result = !(utils$1.isUndefined(el) || el === null) && visitor.call(
636
+ formData,
637
+ el,
638
+ utils$1.isString(key) ? key.trim() : key,
639
+ path,
640
+ exposedHelpers
641
+ );
642
+ if (result === true) {
643
+ build(el, path ? path.concat(key) : [key]);
644
+ }
645
+ });
646
+ stack.pop();
647
+ }
648
+ if (!utils$1.isObject(obj)) {
649
+ throw new TypeError("data must be an object");
650
+ }
651
+ build(obj);
652
+ return formData;
653
+ }
654
+ function encode$1(str) {
655
+ const charMap = {
656
+ "!": "%21",
657
+ "'": "%27",
658
+ "(": "%28",
659
+ ")": "%29",
660
+ "~": "%7E",
661
+ "%20": "+",
662
+ "%00": "\0"
663
+ };
664
+ return encodeURIComponent(str).replace(/[!'()~]|%20|%00/g, function replacer(match) {
665
+ return charMap[match];
666
+ });
667
+ }
668
+ function AxiosURLSearchParams(params, options) {
669
+ this._pairs = [];
670
+ params && toFormData$1(params, this, options);
671
+ }
672
+ const prototype = AxiosURLSearchParams.prototype;
673
+ prototype.append = function append(name, value) {
674
+ this._pairs.push([name, value]);
675
+ };
676
+ prototype.toString = function toString2(encoder) {
677
+ const _encode = encoder ? function(value) {
678
+ return encoder.call(this, value, encode$1);
679
+ } : encode$1;
680
+ return this._pairs.map(function each(pair) {
681
+ return _encode(pair[0]) + "=" + _encode(pair[1]);
682
+ }, "").join("&");
683
+ };
684
+ function encode(val) {
685
+ return encodeURIComponent(val).replace(/%3A/gi, ":").replace(/%24/g, "$").replace(/%2C/gi, ",").replace(/%20/g, "+").replace(/%5B/gi, "[").replace(/%5D/gi, "]");
686
+ }
687
+ function buildURL(url, params, options) {
688
+ if (!params) {
689
+ return url;
690
+ }
691
+ const _encode = options && options.encode || encode;
692
+ if (utils$1.isFunction(options)) {
693
+ options = {
694
+ serialize: options
695
+ };
696
+ }
697
+ const serializeFn = options && options.serialize;
698
+ let serializedParams;
699
+ if (serializeFn) {
700
+ serializedParams = serializeFn(params, options);
701
+ } else {
702
+ serializedParams = utils$1.isURLSearchParams(params) ? params.toString() : new AxiosURLSearchParams(params, options).toString(_encode);
703
+ }
704
+ if (serializedParams) {
705
+ const hashmarkIndex = url.indexOf("#");
706
+ if (hashmarkIndex !== -1) {
707
+ url = url.slice(0, hashmarkIndex);
708
+ }
709
+ url += (url.indexOf("?") === -1 ? "?" : "&") + serializedParams;
710
+ }
711
+ return url;
712
+ }
713
+ class InterceptorManager {
714
+ constructor() {
715
+ this.handlers = [];
716
+ }
717
+ /**
718
+ * Add a new interceptor to the stack
719
+ *
720
+ * @param {Function} fulfilled The function to handle `then` for a `Promise`
721
+ * @param {Function} rejected The function to handle `reject` for a `Promise`
722
+ *
723
+ * @return {Number} An ID used to remove interceptor later
724
+ */
725
+ use(fulfilled, rejected, options) {
726
+ this.handlers.push({
727
+ fulfilled,
728
+ rejected,
729
+ synchronous: options ? options.synchronous : false,
730
+ runWhen: options ? options.runWhen : null
731
+ });
732
+ return this.handlers.length - 1;
733
+ }
734
+ /**
735
+ * Remove an interceptor from the stack
736
+ *
737
+ * @param {Number} id The ID that was returned by `use`
738
+ *
739
+ * @returns {Boolean} `true` if the interceptor was removed, `false` otherwise
740
+ */
741
+ eject(id) {
742
+ if (this.handlers[id]) {
743
+ this.handlers[id] = null;
744
+ }
745
+ }
746
+ /**
747
+ * Clear all interceptors from the stack
748
+ *
749
+ * @returns {void}
750
+ */
751
+ clear() {
752
+ if (this.handlers) {
753
+ this.handlers = [];
754
+ }
755
+ }
756
+ /**
757
+ * Iterate over all the registered interceptors
758
+ *
759
+ * This method is particularly useful for skipping over any
760
+ * interceptors that may have become `null` calling `eject`.
761
+ *
762
+ * @param {Function} fn The function to call for each interceptor
763
+ *
764
+ * @returns {void}
765
+ */
766
+ forEach(fn) {
767
+ utils$1.forEach(this.handlers, function forEachHandler(h) {
768
+ if (h !== null) {
769
+ fn(h);
770
+ }
771
+ });
772
+ }
773
+ }
774
+ const transitionalDefaults = {
775
+ silentJSONParsing: true,
776
+ forcedJSONParsing: true,
777
+ clarifyTimeoutError: false
31
778
  };
32
- const isDarkColor = (color) => {
33
- const parseColor = (color2) => {
34
- let r2 = 0, g2 = 0, b2 = 0, a = 1;
35
- if (color2.startsWith("#")) {
36
- color2 = color2.slice(1);
37
- if (color2.length === 3) {
38
- r2 = parseInt(color2[0] + color2[0], 16);
39
- g2 = parseInt(color2[1] + color2[1], 16);
40
- b2 = parseInt(color2[2] + color2[2], 16);
41
- } else if (color2.length === 6) {
42
- r2 = parseInt(color2.slice(0, 2), 16);
43
- g2 = parseInt(color2.slice(2, 4), 16);
44
- b2 = parseInt(color2.slice(4, 6), 16);
779
+ const URLSearchParams$1 = typeof URLSearchParams !== "undefined" ? URLSearchParams : AxiosURLSearchParams;
780
+ const FormData$1 = typeof FormData !== "undefined" ? FormData : null;
781
+ const Blob$1 = typeof Blob !== "undefined" ? Blob : null;
782
+ const platform$1 = {
783
+ isBrowser: true,
784
+ classes: {
785
+ URLSearchParams: URLSearchParams$1,
786
+ FormData: FormData$1,
787
+ Blob: Blob$1
788
+ },
789
+ protocols: ["http", "https", "file", "blob", "url", "data"]
790
+ };
791
+ const hasBrowserEnv = typeof window !== "undefined" && typeof document !== "undefined";
792
+ const _navigator = typeof navigator === "object" && navigator || void 0;
793
+ const hasStandardBrowserEnv = hasBrowserEnv && (!_navigator || ["ReactNative", "NativeScript", "NS"].indexOf(_navigator.product) < 0);
794
+ const hasStandardBrowserWebWorkerEnv = (() => {
795
+ return typeof WorkerGlobalScope !== "undefined" && // eslint-disable-next-line no-undef
796
+ self instanceof WorkerGlobalScope && typeof self.importScripts === "function";
797
+ })();
798
+ const origin = hasBrowserEnv && window.location.href || "http://localhost";
799
+ const utils = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
800
+ __proto__: null,
801
+ hasBrowserEnv,
802
+ hasStandardBrowserEnv,
803
+ hasStandardBrowserWebWorkerEnv,
804
+ navigator: _navigator,
805
+ origin
806
+ }, Symbol.toStringTag, { value: "Module" }));
807
+ const platform = __spreadValues(__spreadValues({}, utils), platform$1);
808
+ function toURLEncodedForm(data, options) {
809
+ return toFormData$1(data, new platform.classes.URLSearchParams(), Object.assign({
810
+ visitor: function(value, key, path, helpers) {
811
+ if (platform.isNode && utils$1.isBuffer(value)) {
812
+ this.append(key, value.toString("base64"));
813
+ return false;
814
+ }
815
+ return helpers.defaultVisitor.apply(this, arguments);
816
+ }
817
+ }, options));
818
+ }
819
+ function parsePropPath(name) {
820
+ return utils$1.matchAll(/\w+|\[(\w*)]/g, name).map((match) => {
821
+ return match[0] === "[]" ? "" : match[1] || match[0];
822
+ });
823
+ }
824
+ function arrayToObject(arr) {
825
+ const obj = {};
826
+ const keys = Object.keys(arr);
827
+ let i;
828
+ const len = keys.length;
829
+ let key;
830
+ for (i = 0; i < len; i++) {
831
+ key = keys[i];
832
+ obj[key] = arr[key];
833
+ }
834
+ return obj;
835
+ }
836
+ function formDataToJSON(formData) {
837
+ function buildPath(path, value, target, index2) {
838
+ let name = path[index2++];
839
+ if (name === "__proto__") return true;
840
+ const isNumericKey = Number.isFinite(+name);
841
+ const isLast = index2 >= path.length;
842
+ name = !name && utils$1.isArray(target) ? target.length : name;
843
+ if (isLast) {
844
+ if (utils$1.hasOwnProp(target, name)) {
845
+ target[name] = [target[name], value];
45
846
  } else {
46
- return null;
847
+ target[name] = value;
47
848
  }
48
- } else if (color2.startsWith("rgb")) {
49
- const rgbaMatch = color2.match(/(\d+(\.\d+)?)/g);
50
- if (rgbaMatch) {
51
- r2 = parseFloat(rgbaMatch[0]);
52
- g2 = parseFloat(rgbaMatch[1]);
53
- b2 = parseFloat(rgbaMatch[2]);
54
- if (rgbaMatch.length > 3) {
55
- a = parseFloat(rgbaMatch[3]);
849
+ return !isNumericKey;
850
+ }
851
+ if (!target[name] || !utils$1.isObject(target[name])) {
852
+ target[name] = [];
853
+ }
854
+ const result = buildPath(path, value, target[name], index2);
855
+ if (result && utils$1.isArray(target[name])) {
856
+ target[name] = arrayToObject(target[name]);
857
+ }
858
+ return !isNumericKey;
859
+ }
860
+ if (utils$1.isFormData(formData) && utils$1.isFunction(formData.entries)) {
861
+ const obj = {};
862
+ utils$1.forEachEntry(formData, (name, value) => {
863
+ buildPath(parsePropPath(name), value, obj, 0);
864
+ });
865
+ return obj;
866
+ }
867
+ return null;
868
+ }
869
+ function stringifySafely(rawValue, parser, encoder) {
870
+ if (utils$1.isString(rawValue)) {
871
+ try {
872
+ (parser || JSON.parse)(rawValue);
873
+ return utils$1.trim(rawValue);
874
+ } catch (e) {
875
+ if (e.name !== "SyntaxError") {
876
+ throw e;
877
+ }
878
+ }
879
+ }
880
+ return (encoder || JSON.stringify)(rawValue);
881
+ }
882
+ const defaults = {
883
+ transitional: transitionalDefaults,
884
+ adapter: ["xhr", "http", "fetch"],
885
+ transformRequest: [function transformRequest(data, headers) {
886
+ const contentType = headers.getContentType() || "";
887
+ const hasJSONContentType = contentType.indexOf("application/json") > -1;
888
+ const isObjectPayload = utils$1.isObject(data);
889
+ if (isObjectPayload && utils$1.isHTMLForm(data)) {
890
+ data = new FormData(data);
891
+ }
892
+ const isFormData2 = utils$1.isFormData(data);
893
+ if (isFormData2) {
894
+ return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
895
+ }
896
+ if (utils$1.isArrayBuffer(data) || utils$1.isBuffer(data) || utils$1.isStream(data) || utils$1.isFile(data) || utils$1.isBlob(data) || utils$1.isReadableStream(data)) {
897
+ return data;
898
+ }
899
+ if (utils$1.isArrayBufferView(data)) {
900
+ return data.buffer;
901
+ }
902
+ if (utils$1.isURLSearchParams(data)) {
903
+ headers.setContentType("application/x-www-form-urlencoded;charset=utf-8", false);
904
+ return data.toString();
905
+ }
906
+ let isFileList2;
907
+ if (isObjectPayload) {
908
+ if (contentType.indexOf("application/x-www-form-urlencoded") > -1) {
909
+ return toURLEncodedForm(data, this.formSerializer).toString();
910
+ }
911
+ if ((isFileList2 = utils$1.isFileList(data)) || contentType.indexOf("multipart/form-data") > -1) {
912
+ const _FormData = this.env && this.env.FormData;
913
+ return toFormData$1(
914
+ isFileList2 ? { "files[]": data } : data,
915
+ _FormData && new _FormData(),
916
+ this.formSerializer
917
+ );
918
+ }
919
+ }
920
+ if (isObjectPayload || hasJSONContentType) {
921
+ headers.setContentType("application/json", false);
922
+ return stringifySafely(data);
923
+ }
924
+ return data;
925
+ }],
926
+ transformResponse: [function transformResponse(data) {
927
+ const transitional2 = this.transitional || defaults.transitional;
928
+ const forcedJSONParsing = transitional2 && transitional2.forcedJSONParsing;
929
+ const JSONRequested = this.responseType === "json";
930
+ if (utils$1.isResponse(data) || utils$1.isReadableStream(data)) {
931
+ return data;
932
+ }
933
+ if (data && utils$1.isString(data) && (forcedJSONParsing && !this.responseType || JSONRequested)) {
934
+ const silentJSONParsing = transitional2 && transitional2.silentJSONParsing;
935
+ const strictJSONParsing = !silentJSONParsing && JSONRequested;
936
+ try {
937
+ return JSON.parse(data);
938
+ } catch (e) {
939
+ if (strictJSONParsing) {
940
+ if (e.name === "SyntaxError") {
941
+ throw AxiosError$1.from(e, AxiosError$1.ERR_BAD_RESPONSE, this, null, this.response);
942
+ }
943
+ throw e;
56
944
  }
945
+ }
946
+ }
947
+ return data;
948
+ }],
949
+ /**
950
+ * A timeout in milliseconds to abort a request. If set to 0 (default) a
951
+ * timeout is not created.
952
+ */
953
+ timeout: 0,
954
+ xsrfCookieName: "XSRF-TOKEN",
955
+ xsrfHeaderName: "X-XSRF-TOKEN",
956
+ maxContentLength: -1,
957
+ maxBodyLength: -1,
958
+ env: {
959
+ FormData: platform.classes.FormData,
960
+ Blob: platform.classes.Blob
961
+ },
962
+ validateStatus: function validateStatus(status) {
963
+ return status >= 200 && status < 300;
964
+ },
965
+ headers: {
966
+ common: {
967
+ "Accept": "application/json, text/plain, */*",
968
+ "Content-Type": void 0
969
+ }
970
+ }
971
+ };
972
+ utils$1.forEach(["delete", "get", "head", "post", "put", "patch"], (method) => {
973
+ defaults.headers[method] = {};
974
+ });
975
+ const ignoreDuplicateOf = utils$1.toObjectSet([
976
+ "age",
977
+ "authorization",
978
+ "content-length",
979
+ "content-type",
980
+ "etag",
981
+ "expires",
982
+ "from",
983
+ "host",
984
+ "if-modified-since",
985
+ "if-unmodified-since",
986
+ "last-modified",
987
+ "location",
988
+ "max-forwards",
989
+ "proxy-authorization",
990
+ "referer",
991
+ "retry-after",
992
+ "user-agent"
993
+ ]);
994
+ const parseHeaders = (rawHeaders) => {
995
+ const parsed = {};
996
+ let key;
997
+ let val;
998
+ let i;
999
+ rawHeaders && rawHeaders.split("\n").forEach(function parser(line) {
1000
+ i = line.indexOf(":");
1001
+ key = line.substring(0, i).trim().toLowerCase();
1002
+ val = line.substring(i + 1).trim();
1003
+ if (!key || parsed[key] && ignoreDuplicateOf[key]) {
1004
+ return;
1005
+ }
1006
+ if (key === "set-cookie") {
1007
+ if (parsed[key]) {
1008
+ parsed[key].push(val);
57
1009
  } else {
58
- return null;
1010
+ parsed[key] = [val];
59
1011
  }
60
1012
  } else {
61
- return null;
1013
+ parsed[key] = parsed[key] ? parsed[key] + ", " + val : val;
62
1014
  }
63
- return [r2, g2, b2, a];
64
- };
65
- const colorComponents = parseColor(color);
66
- if (!colorComponents) {
67
- return null;
68
- }
69
- const [r, g, b, _] = colorComponents;
70
- const normalizedR = r / 255;
71
- const normalizedG = g / 255;
72
- const normalizedB = b / 255;
73
- const max = Math.max(normalizedR, normalizedG, normalizedB);
74
- const min = Math.min(normalizedR, normalizedG, normalizedB);
75
- let l = (max + min) / 2;
76
- return l < 0.5;
77
- };
78
- const areColorsSimilar = (color1, color2, threshold = 100) => {
79
- const getColorComponents = (color) => {
80
- let r, g, b, a = 1;
81
- if (color.startsWith("#")) {
82
- color = color.slice(1);
83
- if (color.length === 3) {
84
- r = parseInt(color[0] + color[0], 16);
85
- g = parseInt(color[1] + color[1], 16);
86
- b = parseInt(color[2] + color[2], 16);
87
- } else if (color.length === 6) {
88
- r = parseInt(color.slice(0, 2), 16);
89
- g = parseInt(color.slice(2, 4), 16);
90
- b = parseInt(color.slice(4, 6), 16);
91
- } else {
92
- return null;
1015
+ });
1016
+ return parsed;
1017
+ };
1018
+ const $internals = Symbol("internals");
1019
+ function normalizeHeader(header) {
1020
+ return header && String(header).trim().toLowerCase();
1021
+ }
1022
+ function normalizeValue(value) {
1023
+ if (value === false || value == null) {
1024
+ return value;
1025
+ }
1026
+ return utils$1.isArray(value) ? value.map(normalizeValue) : String(value);
1027
+ }
1028
+ function parseTokens(str) {
1029
+ const tokens = /* @__PURE__ */ Object.create(null);
1030
+ const tokensRE = /([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;
1031
+ let match;
1032
+ while (match = tokensRE.exec(str)) {
1033
+ tokens[match[1]] = match[2];
1034
+ }
1035
+ return tokens;
1036
+ }
1037
+ const isValidHeaderName = (str) => /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(str.trim());
1038
+ function matchHeaderValue(context, value, header, filter2, isHeaderNameFilter) {
1039
+ if (utils$1.isFunction(filter2)) {
1040
+ return filter2.call(this, value, header);
1041
+ }
1042
+ if (isHeaderNameFilter) {
1043
+ value = header;
1044
+ }
1045
+ if (!utils$1.isString(value)) return;
1046
+ if (utils$1.isString(filter2)) {
1047
+ return value.indexOf(filter2) !== -1;
1048
+ }
1049
+ if (utils$1.isRegExp(filter2)) {
1050
+ return filter2.test(value);
1051
+ }
1052
+ }
1053
+ function formatHeader(header) {
1054
+ return header.trim().toLowerCase().replace(/([a-z\d])(\w*)/g, (w, char, str) => {
1055
+ return char.toUpperCase() + str;
1056
+ });
1057
+ }
1058
+ function buildAccessors(obj, header) {
1059
+ const accessorName = utils$1.toCamelCase(" " + header);
1060
+ ["get", "set", "has"].forEach((methodName) => {
1061
+ Object.defineProperty(obj, methodName + accessorName, {
1062
+ value: function(arg1, arg2, arg3) {
1063
+ return this[methodName].call(this, header, arg1, arg2, arg3);
1064
+ },
1065
+ configurable: true
1066
+ });
1067
+ });
1068
+ }
1069
+ let AxiosHeaders$1 = class AxiosHeaders {
1070
+ constructor(headers) {
1071
+ headers && this.set(headers);
1072
+ }
1073
+ set(header, valueOrRewrite, rewrite) {
1074
+ const self2 = this;
1075
+ function setHeader(_value, _header, _rewrite) {
1076
+ const lHeader = normalizeHeader(_header);
1077
+ if (!lHeader) {
1078
+ throw new Error("header name must be a non-empty string");
93
1079
  }
94
- } else if (color.startsWith("rgb")) {
95
- const rgbaMatch = color.match(/(\d+(\.\d+)?)/g);
96
- r = parseFloat(rgbaMatch[0]);
97
- g = parseFloat(rgbaMatch[1]);
98
- b = parseFloat(rgbaMatch[2]);
99
- if (rgbaMatch.length > 3) {
100
- a = parseFloat(rgbaMatch[3]);
1080
+ const key = utils$1.findKey(self2, lHeader);
1081
+ if (!key || self2[key] === void 0 || _rewrite === true || _rewrite === void 0 && self2[key] !== false) {
1082
+ self2[key || _header] = normalizeValue(_value);
1083
+ }
1084
+ }
1085
+ const setHeaders = (headers, _rewrite) => utils$1.forEach(headers, (_value, _header) => setHeader(_value, _header, _rewrite));
1086
+ if (utils$1.isPlainObject(header) || header instanceof this.constructor) {
1087
+ setHeaders(header, valueOrRewrite);
1088
+ } else if (utils$1.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
1089
+ setHeaders(parseHeaders(header), valueOrRewrite);
1090
+ } else if (utils$1.isHeaders(header)) {
1091
+ for (const [key, value] of header.entries()) {
1092
+ setHeader(value, key, rewrite);
101
1093
  }
102
1094
  } else {
103
- return null;
1095
+ header != null && setHeader(valueOrRewrite, header, rewrite);
1096
+ }
1097
+ return this;
1098
+ }
1099
+ get(header, parser) {
1100
+ header = normalizeHeader(header);
1101
+ if (header) {
1102
+ const key = utils$1.findKey(this, header);
1103
+ if (key) {
1104
+ const value = this[key];
1105
+ if (!parser) {
1106
+ return value;
1107
+ }
1108
+ if (parser === true) {
1109
+ return parseTokens(value);
1110
+ }
1111
+ if (utils$1.isFunction(parser)) {
1112
+ return parser.call(this, value, key);
1113
+ }
1114
+ if (utils$1.isRegExp(parser)) {
1115
+ return parser.exec(value);
1116
+ }
1117
+ throw new TypeError("parser must be boolean|regexp|function");
1118
+ }
1119
+ }
1120
+ }
1121
+ has(header, matcher) {
1122
+ header = normalizeHeader(header);
1123
+ if (header) {
1124
+ const key = utils$1.findKey(this, header);
1125
+ return !!(key && this[key] !== void 0 && (!matcher || matchHeaderValue(this, this[key], key, matcher)));
104
1126
  }
105
- return [r, g, b, a];
106
- };
107
- const color1Components = getColorComponents(color1);
108
- const color2Components = getColorComponents(color2);
109
- if (!color1Components || !color2Components) {
110
1127
  return false;
111
1128
  }
112
- const euclideanDistance = Math.sqrt(
113
- Math.pow(color1Components[0] - color2Components[0], 2) + Math.pow(color1Components[1] - color2Components[1], 2) + Math.pow(color1Components[2] - color2Components[2], 2) + Math.pow(color1Components[3] - color2Components[3], 2)
114
- );
115
- console.log(euclideanDistance);
116
- return euclideanDistance <= threshold;
117
- };
118
- const isColorEqual = (color1, color2) => {
119
- function toRGBA(color) {
120
- if (color.toLowerCase().startsWith("rgba")) {
121
- return color.toLowerCase();
122
- } else if (color.toLowerCase().startsWith("rgb")) {
123
- return color.replace("rgb", "rgba").replace(")", ", 1)");
124
- } else if (color.length === 7) {
125
- const r = parseInt(color.substring(1, 3), 16);
126
- const g = parseInt(color.substring(3, 5), 16);
127
- const b = parseInt(color.substring(5, 7), 16);
128
- return `rgba(${r}, ${g}, ${b}, 1)`;
129
- } else if (color.length === 9 && color.toLowerCase().startsWith("rrggbbaa")) {
130
- const r = parseInt(color.substring(1, 3), 16);
131
- const g = parseInt(color.substring(3, 5), 16);
132
- const b = parseInt(color.substring(5, 7), 16);
133
- const a = Math.round(parseInt(color.substring(7, 9), 16) / 255 * 100) / 100;
134
- return `rgba(${r}, ${g}, ${b}, ${a})`;
1129
+ delete(header, matcher) {
1130
+ const self2 = this;
1131
+ let deleted = false;
1132
+ function deleteHeader(_header) {
1133
+ _header = normalizeHeader(_header);
1134
+ if (_header) {
1135
+ const key = utils$1.findKey(self2, _header);
1136
+ if (key && (!matcher || matchHeaderValue(self2, self2[key], key, matcher))) {
1137
+ delete self2[key];
1138
+ deleted = true;
1139
+ }
1140
+ }
1141
+ }
1142
+ if (utils$1.isArray(header)) {
1143
+ header.forEach(deleteHeader);
135
1144
  } else {
136
- return null;
1145
+ deleteHeader(header);
137
1146
  }
1147
+ return deleted;
138
1148
  }
139
- const rgbaColor1 = toRGBA(convertShortHexToLongHex(color1));
140
- const rgbaColor2 = toRGBA(convertShortHexToLongHex(color2));
141
- if (!rgbaColor1 || !rgbaColor2) {
142
- return false;
1149
+ clear(matcher) {
1150
+ const keys = Object.keys(this);
1151
+ let i = keys.length;
1152
+ let deleted = false;
1153
+ while (i--) {
1154
+ const key = keys[i];
1155
+ if (!matcher || matchHeaderValue(this, this[key], key, matcher, true)) {
1156
+ delete this[key];
1157
+ deleted = true;
1158
+ }
1159
+ }
1160
+ return deleted;
1161
+ }
1162
+ normalize(format) {
1163
+ const self2 = this;
1164
+ const headers = {};
1165
+ utils$1.forEach(this, (value, header) => {
1166
+ const key = utils$1.findKey(headers, header);
1167
+ if (key) {
1168
+ self2[key] = normalizeValue(value);
1169
+ delete self2[header];
1170
+ return;
1171
+ }
1172
+ const normalized = format ? formatHeader(header) : String(header).trim();
1173
+ if (normalized !== header) {
1174
+ delete self2[header];
1175
+ }
1176
+ self2[normalized] = normalizeValue(value);
1177
+ headers[normalized] = true;
1178
+ });
1179
+ return this;
1180
+ }
1181
+ concat(...targets) {
1182
+ return this.constructor.concat(this, ...targets);
1183
+ }
1184
+ toJSON(asStrings) {
1185
+ const obj = /* @__PURE__ */ Object.create(null);
1186
+ utils$1.forEach(this, (value, header) => {
1187
+ value != null && value !== false && (obj[header] = asStrings && utils$1.isArray(value) ? value.join(", ") : value);
1188
+ });
1189
+ return obj;
1190
+ }
1191
+ [Symbol.iterator]() {
1192
+ return Object.entries(this.toJSON())[Symbol.iterator]();
1193
+ }
1194
+ toString() {
1195
+ return Object.entries(this.toJSON()).map(([header, value]) => header + ": " + value).join("\n");
1196
+ }
1197
+ get [Symbol.toStringTag]() {
1198
+ return "AxiosHeaders";
1199
+ }
1200
+ static from(thing) {
1201
+ return thing instanceof this ? thing : new this(thing);
1202
+ }
1203
+ static concat(first, ...targets) {
1204
+ const computed = new this(first);
1205
+ targets.forEach((target) => computed.set(target));
1206
+ return computed;
1207
+ }
1208
+ static accessor(header) {
1209
+ const internals = this[$internals] = this[$internals] = {
1210
+ accessors: {}
1211
+ };
1212
+ const accessors = internals.accessors;
1213
+ const prototype2 = this.prototype;
1214
+ function defineAccessor(_header) {
1215
+ const lHeader = normalizeHeader(_header);
1216
+ if (!accessors[lHeader]) {
1217
+ buildAccessors(prototype2, _header);
1218
+ accessors[lHeader] = true;
1219
+ }
1220
+ }
1221
+ utils$1.isArray(header) ? header.forEach(defineAccessor) : defineAccessor(header);
1222
+ return this;
143
1223
  }
144
- return rgbaColor1 === rgbaColor2;
145
1224
  };
146
- const convertShortHexToLongHex = (shortHex) => {
147
- if (shortHex.length === 4 && shortHex[0] === "#") {
148
- const r = shortHex[1];
149
- const g = shortHex[2];
150
- const b = shortHex[3];
151
- const longHex = `#${r}${r}${g}${g}${b}${b}`;
152
- return longHex;
1225
+ AxiosHeaders$1.accessor(["Content-Type", "Content-Length", "Accept", "Accept-Encoding", "User-Agent", "Authorization"]);
1226
+ utils$1.reduceDescriptors(AxiosHeaders$1.prototype, ({ value }, key) => {
1227
+ let mapped = key[0].toUpperCase() + key.slice(1);
1228
+ return {
1229
+ get: () => value,
1230
+ set(headerValue) {
1231
+ this[mapped] = headerValue;
1232
+ }
1233
+ };
1234
+ });
1235
+ utils$1.freezeMethods(AxiosHeaders$1);
1236
+ function transformData(fns, response) {
1237
+ const config2 = this || defaults;
1238
+ const context = response || config2;
1239
+ const headers = AxiosHeaders$1.from(context.headers);
1240
+ let data = context.data;
1241
+ utils$1.forEach(fns, function transform(fn) {
1242
+ data = fn.call(config2, data, headers.normalize(), response ? response.status : void 0);
1243
+ });
1244
+ headers.normalize();
1245
+ return data;
1246
+ }
1247
+ function isCancel$1(value) {
1248
+ return !!(value && value.__CANCEL__);
1249
+ }
1250
+ function CanceledError$1(message, config2, request) {
1251
+ AxiosError$1.call(this, message == null ? "canceled" : message, AxiosError$1.ERR_CANCELED, config2, request);
1252
+ this.name = "CanceledError";
1253
+ }
1254
+ utils$1.inherits(CanceledError$1, AxiosError$1, {
1255
+ __CANCEL__: true
1256
+ });
1257
+ function settle(resolve, reject, response) {
1258
+ const validateStatus2 = response.config.validateStatus;
1259
+ if (!response.status || !validateStatus2 || validateStatus2(response.status)) {
1260
+ resolve(response);
153
1261
  } else {
154
- return shortHex;
1262
+ reject(new AxiosError$1(
1263
+ "Request failed with status code " + response.status,
1264
+ [AxiosError$1.ERR_BAD_REQUEST, AxiosError$1.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4],
1265
+ response.config,
1266
+ response.request,
1267
+ response
1268
+ ));
155
1269
  }
1270
+ }
1271
+ function parseProtocol(url) {
1272
+ const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
1273
+ return match && match[1] || "";
1274
+ }
1275
+ function speedometer(samplesCount, min) {
1276
+ samplesCount = samplesCount || 10;
1277
+ const bytes = new Array(samplesCount);
1278
+ const timestamps = new Array(samplesCount);
1279
+ let head = 0;
1280
+ let tail = 0;
1281
+ let firstSampleTS;
1282
+ min = min !== void 0 ? min : 1e3;
1283
+ return function push(chunkLength) {
1284
+ const now = Date.now();
1285
+ const startedAt = timestamps[tail];
1286
+ if (!firstSampleTS) {
1287
+ firstSampleTS = now;
1288
+ }
1289
+ bytes[head] = chunkLength;
1290
+ timestamps[head] = now;
1291
+ let i = tail;
1292
+ let bytesCount = 0;
1293
+ while (i !== head) {
1294
+ bytesCount += bytes[i++];
1295
+ i = i % samplesCount;
1296
+ }
1297
+ head = (head + 1) % samplesCount;
1298
+ if (head === tail) {
1299
+ tail = (tail + 1) % samplesCount;
1300
+ }
1301
+ if (now - firstSampleTS < min) {
1302
+ return;
1303
+ }
1304
+ const passed = startedAt && now - startedAt;
1305
+ return passed ? Math.round(bytesCount * 1e3 / passed) : void 0;
1306
+ };
1307
+ }
1308
+ function throttle(fn, freq) {
1309
+ let timestamp = 0;
1310
+ let threshold = 1e3 / freq;
1311
+ let lastArgs;
1312
+ let timer;
1313
+ const invoke = (args, now = Date.now()) => {
1314
+ timestamp = now;
1315
+ lastArgs = null;
1316
+ if (timer) {
1317
+ clearTimeout(timer);
1318
+ timer = null;
1319
+ }
1320
+ fn.apply(null, args);
1321
+ };
1322
+ const throttled = (...args) => {
1323
+ const now = Date.now();
1324
+ const passed = now - timestamp;
1325
+ if (passed >= threshold) {
1326
+ invoke(args, now);
1327
+ } else {
1328
+ lastArgs = args;
1329
+ if (!timer) {
1330
+ timer = setTimeout(() => {
1331
+ timer = null;
1332
+ invoke(lastArgs);
1333
+ }, threshold - passed);
1334
+ }
1335
+ }
1336
+ };
1337
+ const flush = () => lastArgs && invoke(lastArgs);
1338
+ return [throttled, flush];
1339
+ }
1340
+ const progressEventReducer = (listener, isDownloadStream, freq = 3) => {
1341
+ let bytesNotified = 0;
1342
+ const _speedometer = speedometer(50, 250);
1343
+ return throttle((e) => {
1344
+ const loaded = e.loaded;
1345
+ const total = e.lengthComputable ? e.total : void 0;
1346
+ const progressBytes = loaded - bytesNotified;
1347
+ const rate = _speedometer(progressBytes);
1348
+ const inRange = loaded <= total;
1349
+ bytesNotified = loaded;
1350
+ const data = {
1351
+ loaded,
1352
+ total,
1353
+ progress: total ? loaded / total : void 0,
1354
+ bytes: progressBytes,
1355
+ rate: rate ? rate : void 0,
1356
+ estimated: rate && total && inRange ? (total - loaded) / rate : void 0,
1357
+ event: e,
1358
+ lengthComputable: total != null,
1359
+ [isDownloadStream ? "download" : "upload"]: true
1360
+ };
1361
+ listener(data);
1362
+ }, freq);
156
1363
  };
157
- class YxSubscribe {
158
- constructor() {
159
- __publicField(this, "subscribers");
160
- this.subscribers = {};
1364
+ const progressEventDecorator = (total, throttled) => {
1365
+ const lengthComputable = total != null;
1366
+ return [(loaded) => throttled[0]({
1367
+ lengthComputable,
1368
+ total,
1369
+ loaded
1370
+ }), throttled[1]];
1371
+ };
1372
+ const asyncDecorator = (fn) => (...args) => utils$1.asap(() => fn(...args));
1373
+ const isURLSameOrigin = platform.hasStandardBrowserEnv ? /* @__PURE__ */ ((origin2, isMSIE) => (url) => {
1374
+ url = new URL(url, platform.origin);
1375
+ return origin2.protocol === url.protocol && origin2.host === url.host && (isMSIE || origin2.port === url.port);
1376
+ })(
1377
+ new URL(platform.origin),
1378
+ platform.navigator && /(msie|trident)/i.test(platform.navigator.userAgent)
1379
+ ) : () => true;
1380
+ const cookies = platform.hasStandardBrowserEnv ? (
1381
+ // Standard browser envs support document.cookie
1382
+ {
1383
+ write(name, value, expires, path, domain, secure) {
1384
+ const cookie = [name + "=" + encodeURIComponent(value)];
1385
+ utils$1.isNumber(expires) && cookie.push("expires=" + new Date(expires).toGMTString());
1386
+ utils$1.isString(path) && cookie.push("path=" + path);
1387
+ utils$1.isString(domain) && cookie.push("domain=" + domain);
1388
+ secure === true && cookie.push("secure");
1389
+ document.cookie = cookie.join("; ");
1390
+ },
1391
+ read(name) {
1392
+ const match = document.cookie.match(new RegExp("(^|;\\s*)(" + name + ")=([^;]*)"));
1393
+ return match ? decodeURIComponent(match[3]) : null;
1394
+ },
1395
+ remove(name) {
1396
+ this.write(name, "", Date.now() - 864e5);
1397
+ }
1398
+ }
1399
+ ) : (
1400
+ // Non-standard browser env (web workers, react-native) lack needed support.
1401
+ {
1402
+ write() {
1403
+ },
1404
+ read() {
1405
+ return null;
1406
+ },
1407
+ remove() {
1408
+ }
161
1409
  }
162
- subscribe(sub, fn) {
163
- if (!this.subscribers[sub]) {
164
- this.subscribers[sub] = [];
1410
+ );
1411
+ function isAbsoluteURL(url) {
1412
+ return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
1413
+ }
1414
+ function combineURLs(baseURL, relativeURL) {
1415
+ return relativeURL ? baseURL.replace(/\/?\/$/, "") + "/" + relativeURL.replace(/^\/+/, "") : baseURL;
1416
+ }
1417
+ function buildFullPath(baseURL, requestedURL) {
1418
+ if (baseURL && !isAbsoluteURL(requestedURL)) {
1419
+ return combineURLs(baseURL, requestedURL);
1420
+ }
1421
+ return requestedURL;
1422
+ }
1423
+ const headersToObject = (thing) => thing instanceof AxiosHeaders$1 ? __spreadValues({}, thing) : thing;
1424
+ function mergeConfig$1(config1, config2) {
1425
+ config2 = config2 || {};
1426
+ const config3 = {};
1427
+ function getMergedValue(target, source, prop, caseless) {
1428
+ if (utils$1.isPlainObject(target) && utils$1.isPlainObject(source)) {
1429
+ return utils$1.merge.call({ caseless }, target, source);
1430
+ } else if (utils$1.isPlainObject(source)) {
1431
+ return utils$1.merge({}, source);
1432
+ } else if (utils$1.isArray(source)) {
1433
+ return source.slice();
165
1434
  }
166
- this.subscribers[sub].push(fn);
1435
+ return source;
1436
+ }
1437
+ function mergeDeepProperties(a, b, prop, caseless) {
1438
+ if (!utils$1.isUndefined(b)) {
1439
+ return getMergedValue(a, b, prop, caseless);
1440
+ } else if (!utils$1.isUndefined(a)) {
1441
+ return getMergedValue(void 0, a, prop, caseless);
1442
+ }
1443
+ }
1444
+ function valueFromConfig2(a, b) {
1445
+ if (!utils$1.isUndefined(b)) {
1446
+ return getMergedValue(void 0, b);
1447
+ }
1448
+ }
1449
+ function defaultToConfig2(a, b) {
1450
+ if (!utils$1.isUndefined(b)) {
1451
+ return getMergedValue(void 0, b);
1452
+ } else if (!utils$1.isUndefined(a)) {
1453
+ return getMergedValue(void 0, a);
1454
+ }
1455
+ }
1456
+ function mergeDirectKeys(a, b, prop) {
1457
+ if (prop in config2) {
1458
+ return getMergedValue(a, b);
1459
+ } else if (prop in config1) {
1460
+ return getMergedValue(void 0, a);
1461
+ }
1462
+ }
1463
+ const mergeMap = {
1464
+ url: valueFromConfig2,
1465
+ method: valueFromConfig2,
1466
+ data: valueFromConfig2,
1467
+ baseURL: defaultToConfig2,
1468
+ transformRequest: defaultToConfig2,
1469
+ transformResponse: defaultToConfig2,
1470
+ paramsSerializer: defaultToConfig2,
1471
+ timeout: defaultToConfig2,
1472
+ timeoutMessage: defaultToConfig2,
1473
+ withCredentials: defaultToConfig2,
1474
+ withXSRFToken: defaultToConfig2,
1475
+ adapter: defaultToConfig2,
1476
+ responseType: defaultToConfig2,
1477
+ xsrfCookieName: defaultToConfig2,
1478
+ xsrfHeaderName: defaultToConfig2,
1479
+ onUploadProgress: defaultToConfig2,
1480
+ onDownloadProgress: defaultToConfig2,
1481
+ decompress: defaultToConfig2,
1482
+ maxContentLength: defaultToConfig2,
1483
+ maxBodyLength: defaultToConfig2,
1484
+ beforeRedirect: defaultToConfig2,
1485
+ transport: defaultToConfig2,
1486
+ httpAgent: defaultToConfig2,
1487
+ httpsAgent: defaultToConfig2,
1488
+ cancelToken: defaultToConfig2,
1489
+ socketPath: defaultToConfig2,
1490
+ responseEncoding: defaultToConfig2,
1491
+ validateStatus: mergeDirectKeys,
1492
+ headers: (a, b, prop) => mergeDeepProperties(headersToObject(a), headersToObject(b), prop, true)
1493
+ };
1494
+ utils$1.forEach(Object.keys(Object.assign({}, config1, config2)), function computeConfigValue(prop) {
1495
+ const merge2 = mergeMap[prop] || mergeDeepProperties;
1496
+ const configValue = merge2(config1[prop], config2[prop], prop);
1497
+ utils$1.isUndefined(configValue) && merge2 !== mergeDirectKeys || (config3[prop] = configValue);
1498
+ });
1499
+ return config3;
1500
+ }
1501
+ const resolveConfig = (config2) => {
1502
+ const newConfig = mergeConfig$1({}, config2);
1503
+ let { data, withXSRFToken, xsrfHeaderName, xsrfCookieName, headers, auth } = newConfig;
1504
+ newConfig.headers = headers = AxiosHeaders$1.from(headers);
1505
+ newConfig.url = buildURL(buildFullPath(newConfig.baseURL, newConfig.url), config2.params, config2.paramsSerializer);
1506
+ if (auth) {
1507
+ headers.set(
1508
+ "Authorization",
1509
+ "Basic " + btoa((auth.username || "") + ":" + (auth.password ? unescape(encodeURIComponent(auth.password)) : ""))
1510
+ );
1511
+ }
1512
+ let contentType;
1513
+ if (utils$1.isFormData(data)) {
1514
+ if (platform.hasStandardBrowserEnv || platform.hasStandardBrowserWebWorkerEnv) {
1515
+ headers.setContentType(void 0);
1516
+ } else if ((contentType = headers.getContentType()) !== false) {
1517
+ const [type, ...tokens] = contentType ? contentType.split(";").map((token) => token.trim()).filter(Boolean) : [];
1518
+ headers.setContentType([type || "multipart/form-data", ...tokens].join("; "));
1519
+ }
1520
+ }
1521
+ if (platform.hasStandardBrowserEnv) {
1522
+ withXSRFToken && utils$1.isFunction(withXSRFToken) && (withXSRFToken = withXSRFToken(newConfig));
1523
+ if (withXSRFToken || withXSRFToken !== false && isURLSameOrigin(newConfig.url)) {
1524
+ const xsrfValue = xsrfHeaderName && xsrfCookieName && cookies.read(xsrfCookieName);
1525
+ if (xsrfValue) {
1526
+ headers.set(xsrfHeaderName, xsrfValue);
1527
+ }
1528
+ }
1529
+ }
1530
+ return newConfig;
1531
+ };
1532
+ const isXHRAdapterSupported = typeof XMLHttpRequest !== "undefined";
1533
+ const xhrAdapter = isXHRAdapterSupported && function(config2) {
1534
+ return new Promise(function dispatchXhrRequest(resolve, reject) {
1535
+ const _config = resolveConfig(config2);
1536
+ let requestData = _config.data;
1537
+ const requestHeaders = AxiosHeaders$1.from(_config.headers).normalize();
1538
+ let { responseType, onUploadProgress, onDownloadProgress } = _config;
1539
+ let onCanceled;
1540
+ let uploadThrottled, downloadThrottled;
1541
+ let flushUpload, flushDownload;
1542
+ function done() {
1543
+ flushUpload && flushUpload();
1544
+ flushDownload && flushDownload();
1545
+ _config.cancelToken && _config.cancelToken.unsubscribe(onCanceled);
1546
+ _config.signal && _config.signal.removeEventListener("abort", onCanceled);
1547
+ }
1548
+ let request = new XMLHttpRequest();
1549
+ request.open(_config.method.toUpperCase(), _config.url, true);
1550
+ request.timeout = _config.timeout;
1551
+ function onloadend() {
1552
+ if (!request) {
1553
+ return;
1554
+ }
1555
+ const responseHeaders = AxiosHeaders$1.from(
1556
+ "getAllResponseHeaders" in request && request.getAllResponseHeaders()
1557
+ );
1558
+ const responseData = !responseType || responseType === "text" || responseType === "json" ? request.responseText : request.response;
1559
+ const response = {
1560
+ data: responseData,
1561
+ status: request.status,
1562
+ statusText: request.statusText,
1563
+ headers: responseHeaders,
1564
+ config: config2,
1565
+ request
1566
+ };
1567
+ settle(function _resolve(value) {
1568
+ resolve(value);
1569
+ done();
1570
+ }, function _reject(err) {
1571
+ reject(err);
1572
+ done();
1573
+ }, response);
1574
+ request = null;
1575
+ }
1576
+ if ("onloadend" in request) {
1577
+ request.onloadend = onloadend;
1578
+ } else {
1579
+ request.onreadystatechange = function handleLoad() {
1580
+ if (!request || request.readyState !== 4) {
1581
+ return;
1582
+ }
1583
+ if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf("file:") === 0)) {
1584
+ return;
1585
+ }
1586
+ setTimeout(onloadend);
1587
+ };
1588
+ }
1589
+ request.onabort = function handleAbort() {
1590
+ if (!request) {
1591
+ return;
1592
+ }
1593
+ reject(new AxiosError$1("Request aborted", AxiosError$1.ECONNABORTED, config2, request));
1594
+ request = null;
1595
+ };
1596
+ request.onerror = function handleError() {
1597
+ reject(new AxiosError$1("Network Error", AxiosError$1.ERR_NETWORK, config2, request));
1598
+ request = null;
1599
+ };
1600
+ request.ontimeout = function handleTimeout() {
1601
+ let timeoutErrorMessage = _config.timeout ? "timeout of " + _config.timeout + "ms exceeded" : "timeout exceeded";
1602
+ const transitional2 = _config.transitional || transitionalDefaults;
1603
+ if (_config.timeoutErrorMessage) {
1604
+ timeoutErrorMessage = _config.timeoutErrorMessage;
1605
+ }
1606
+ reject(new AxiosError$1(
1607
+ timeoutErrorMessage,
1608
+ transitional2.clarifyTimeoutError ? AxiosError$1.ETIMEDOUT : AxiosError$1.ECONNABORTED,
1609
+ config2,
1610
+ request
1611
+ ));
1612
+ request = null;
1613
+ };
1614
+ requestData === void 0 && requestHeaders.setContentType(null);
1615
+ if ("setRequestHeader" in request) {
1616
+ utils$1.forEach(requestHeaders.toJSON(), function setRequestHeader(val, key) {
1617
+ request.setRequestHeader(key, val);
1618
+ });
1619
+ }
1620
+ if (!utils$1.isUndefined(_config.withCredentials)) {
1621
+ request.withCredentials = !!_config.withCredentials;
1622
+ }
1623
+ if (responseType && responseType !== "json") {
1624
+ request.responseType = _config.responseType;
1625
+ }
1626
+ if (onDownloadProgress) {
1627
+ [downloadThrottled, flushDownload] = progressEventReducer(onDownloadProgress, true);
1628
+ request.addEventListener("progress", downloadThrottled);
1629
+ }
1630
+ if (onUploadProgress && request.upload) {
1631
+ [uploadThrottled, flushUpload] = progressEventReducer(onUploadProgress);
1632
+ request.upload.addEventListener("progress", uploadThrottled);
1633
+ request.upload.addEventListener("loadend", flushUpload);
1634
+ }
1635
+ if (_config.cancelToken || _config.signal) {
1636
+ onCanceled = (cancel) => {
1637
+ if (!request) {
1638
+ return;
1639
+ }
1640
+ reject(!cancel || cancel.type ? new CanceledError$1(null, config2, request) : cancel);
1641
+ request.abort();
1642
+ request = null;
1643
+ };
1644
+ _config.cancelToken && _config.cancelToken.subscribe(onCanceled);
1645
+ if (_config.signal) {
1646
+ _config.signal.aborted ? onCanceled() : _config.signal.addEventListener("abort", onCanceled);
1647
+ }
1648
+ }
1649
+ const protocol = parseProtocol(_config.url);
1650
+ if (protocol && platform.protocols.indexOf(protocol) === -1) {
1651
+ reject(new AxiosError$1("Unsupported protocol " + protocol + ":", AxiosError$1.ERR_BAD_REQUEST, config2));
1652
+ return;
1653
+ }
1654
+ request.send(requestData || null);
1655
+ });
1656
+ };
1657
+ const composeSignals = (signals, timeout) => {
1658
+ const { length } = signals = signals ? signals.filter(Boolean) : [];
1659
+ if (timeout || length) {
1660
+ let controller = new AbortController();
1661
+ let aborted;
1662
+ const onabort = function(reason) {
1663
+ if (!aborted) {
1664
+ aborted = true;
1665
+ unsubscribe();
1666
+ const err = reason instanceof Error ? reason : this.reason;
1667
+ controller.abort(err instanceof AxiosError$1 ? err : new CanceledError$1(err instanceof Error ? err.message : err));
1668
+ }
1669
+ };
1670
+ let timer = timeout && setTimeout(() => {
1671
+ timer = null;
1672
+ onabort(new AxiosError$1(`timeout ${timeout} of ms exceeded`, AxiosError$1.ETIMEDOUT));
1673
+ }, timeout);
1674
+ const unsubscribe = () => {
1675
+ if (signals) {
1676
+ timer && clearTimeout(timer);
1677
+ timer = null;
1678
+ signals.forEach((signal2) => {
1679
+ signal2.unsubscribe ? signal2.unsubscribe(onabort) : signal2.removeEventListener("abort", onabort);
1680
+ });
1681
+ signals = null;
1682
+ }
1683
+ };
1684
+ signals.forEach((signal2) => signal2.addEventListener("abort", onabort));
1685
+ const { signal } = controller;
1686
+ signal.unsubscribe = () => utils$1.asap(unsubscribe);
1687
+ return signal;
1688
+ }
1689
+ };
1690
+ const streamChunk = function* (chunk, chunkSize) {
1691
+ let len = chunk.byteLength;
1692
+ if (len < chunkSize) {
1693
+ yield chunk;
1694
+ return;
167
1695
  }
168
- unsubscribe(sub, fn) {
169
- const subscribers = this.subscribers[sub];
170
- if (!fn) return this.subscribers[sub] = [];
171
- if (subscribers) {
172
- const index = subscribers.indexOf(fn);
173
- if (index !== -1) {
174
- subscribers.splice(index, 1);
1696
+ let pos = 0;
1697
+ let end;
1698
+ while (pos < len) {
1699
+ end = pos + chunkSize;
1700
+ yield chunk.slice(pos, end);
1701
+ pos = end;
1702
+ }
1703
+ };
1704
+ const readBytes = function(iterable, chunkSize) {
1705
+ return __asyncGenerator(this, null, function* () {
1706
+ try {
1707
+ for (var iter = __forAwait(readStream(iterable)), more, temp, error; more = !(temp = yield new __await(iter.next())).done; more = false) {
1708
+ const chunk = temp.value;
1709
+ yield* __yieldStar(streamChunk(chunk, chunkSize));
1710
+ }
1711
+ } catch (temp) {
1712
+ error = [temp];
1713
+ } finally {
1714
+ try {
1715
+ more && (temp = iter.return) && (yield new __await(temp.call(iter)));
1716
+ } finally {
1717
+ if (error)
1718
+ throw error[0];
1719
+ }
1720
+ }
1721
+ });
1722
+ };
1723
+ const readStream = function(stream) {
1724
+ return __asyncGenerator(this, null, function* () {
1725
+ if (stream[Symbol.asyncIterator]) {
1726
+ yield* __yieldStar(stream);
1727
+ return;
1728
+ }
1729
+ const reader = stream.getReader();
1730
+ try {
1731
+ for (; ; ) {
1732
+ const { done, value } = yield new __await(reader.read());
1733
+ if (done) {
1734
+ break;
1735
+ }
1736
+ yield value;
175
1737
  }
1738
+ } finally {
1739
+ yield new __await(reader.cancel());
1740
+ }
1741
+ });
1742
+ };
1743
+ const trackStream = (stream, chunkSize, onProgress, onFinish) => {
1744
+ const iterator = readBytes(stream, chunkSize);
1745
+ let bytes = 0;
1746
+ let done;
1747
+ let _onFinish = (e) => {
1748
+ if (!done) {
1749
+ done = true;
1750
+ onFinish && onFinish(e);
176
1751
  }
1752
+ };
1753
+ return new ReadableStream({
1754
+ pull(controller) {
1755
+ return __async(this, null, function* () {
1756
+ try {
1757
+ const { done: done2, value } = yield iterator.next();
1758
+ if (done2) {
1759
+ _onFinish();
1760
+ controller.close();
1761
+ return;
1762
+ }
1763
+ let len = value.byteLength;
1764
+ if (onProgress) {
1765
+ let loadedBytes = bytes += len;
1766
+ onProgress(loadedBytes);
1767
+ }
1768
+ controller.enqueue(new Uint8Array(value));
1769
+ } catch (err) {
1770
+ _onFinish(err);
1771
+ throw err;
1772
+ }
1773
+ });
1774
+ },
1775
+ cancel(reason) {
1776
+ _onFinish(reason);
1777
+ return iterator.return();
1778
+ }
1779
+ }, {
1780
+ highWaterMark: 2
1781
+ });
1782
+ };
1783
+ const isFetchSupported = typeof fetch === "function" && typeof Request === "function" && typeof Response === "function";
1784
+ const isReadableStreamSupported = isFetchSupported && typeof ReadableStream === "function";
1785
+ const encodeText = isFetchSupported && (typeof TextEncoder === "function" ? /* @__PURE__ */ ((encoder) => (str) => encoder.encode(str))(new TextEncoder()) : (str) => __async(void 0, null, function* () {
1786
+ return new Uint8Array(yield new Response(str).arrayBuffer());
1787
+ }));
1788
+ const test = (fn, ...args) => {
1789
+ try {
1790
+ return !!fn(...args);
1791
+ } catch (e) {
1792
+ return false;
1793
+ }
1794
+ };
1795
+ const supportsRequestStream = isReadableStreamSupported && test(() => {
1796
+ let duplexAccessed = false;
1797
+ const hasContentType = new Request(platform.origin, {
1798
+ body: new ReadableStream(),
1799
+ method: "POST",
1800
+ get duplex() {
1801
+ duplexAccessed = true;
1802
+ return "half";
1803
+ }
1804
+ }).headers.has("Content-Type");
1805
+ return duplexAccessed && !hasContentType;
1806
+ });
1807
+ const DEFAULT_CHUNK_SIZE = 64 * 1024;
1808
+ const supportsResponseStream = isReadableStreamSupported && test(() => utils$1.isReadableStream(new Response("").body));
1809
+ const resolvers = {
1810
+ stream: supportsResponseStream && ((res) => res.body)
1811
+ };
1812
+ isFetchSupported && ((res) => {
1813
+ ["text", "arrayBuffer", "blob", "formData", "stream"].forEach((type) => {
1814
+ !resolvers[type] && (resolvers[type] = utils$1.isFunction(res[type]) ? (res2) => res2[type]() : (_, config2) => {
1815
+ throw new AxiosError$1(`Response type '${type}' is not supported`, AxiosError$1.ERR_NOT_SUPPORT, config2);
1816
+ });
1817
+ });
1818
+ })(new Response());
1819
+ const getBodyLength = (body) => __async(void 0, null, function* () {
1820
+ if (body == null) {
1821
+ return 0;
1822
+ }
1823
+ if (utils$1.isBlob(body)) {
1824
+ return body.size;
1825
+ }
1826
+ if (utils$1.isSpecCompliantForm(body)) {
1827
+ const _request = new Request(platform.origin, {
1828
+ method: "POST",
1829
+ body
1830
+ });
1831
+ return (yield _request.arrayBuffer()).byteLength;
1832
+ }
1833
+ if (utils$1.isArrayBufferView(body) || utils$1.isArrayBuffer(body)) {
1834
+ return body.byteLength;
177
1835
  }
178
- publish(message) {
179
- const subscribers = this.subscribers[message.type];
180
- if (subscribers) {
181
- subscribers.forEach((fn) => {
182
- fn(message.data);
1836
+ if (utils$1.isURLSearchParams(body)) {
1837
+ body = body + "";
1838
+ }
1839
+ if (utils$1.isString(body)) {
1840
+ return (yield encodeText(body)).byteLength;
1841
+ }
1842
+ });
1843
+ const resolveBodyLength = (headers, body) => __async(void 0, null, function* () {
1844
+ const length = utils$1.toFiniteNumber(headers.getContentLength());
1845
+ return length == null ? getBodyLength(body) : length;
1846
+ });
1847
+ const fetchAdapter = isFetchSupported && ((config2) => __async(void 0, null, function* () {
1848
+ let {
1849
+ url,
1850
+ method,
1851
+ data,
1852
+ signal,
1853
+ cancelToken,
1854
+ timeout,
1855
+ onDownloadProgress,
1856
+ onUploadProgress,
1857
+ responseType,
1858
+ headers,
1859
+ withCredentials = "same-origin",
1860
+ fetchOptions
1861
+ } = resolveConfig(config2);
1862
+ responseType = responseType ? (responseType + "").toLowerCase() : "text";
1863
+ let composedSignal = composeSignals([signal, cancelToken && cancelToken.toAbortSignal()], timeout);
1864
+ let request;
1865
+ const unsubscribe = composedSignal && composedSignal.unsubscribe && (() => {
1866
+ composedSignal.unsubscribe();
1867
+ });
1868
+ let requestContentLength;
1869
+ try {
1870
+ if (onUploadProgress && supportsRequestStream && method !== "get" && method !== "head" && (requestContentLength = yield resolveBodyLength(headers, data)) !== 0) {
1871
+ let _request = new Request(url, {
1872
+ method: "POST",
1873
+ body: data,
1874
+ duplex: "half"
1875
+ });
1876
+ let contentTypeHeader;
1877
+ if (utils$1.isFormData(data) && (contentTypeHeader = _request.headers.get("content-type"))) {
1878
+ headers.setContentType(contentTypeHeader);
1879
+ }
1880
+ if (_request.body) {
1881
+ const [onProgress, flush] = progressEventDecorator(
1882
+ requestContentLength,
1883
+ progressEventReducer(asyncDecorator(onUploadProgress))
1884
+ );
1885
+ data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, onProgress, flush);
1886
+ }
1887
+ }
1888
+ if (!utils$1.isString(withCredentials)) {
1889
+ withCredentials = withCredentials ? "include" : "omit";
1890
+ }
1891
+ const isCredentialsSupported = "credentials" in Request.prototype;
1892
+ request = new Request(url, __spreadProps(__spreadValues({}, fetchOptions), {
1893
+ signal: composedSignal,
1894
+ method: method.toUpperCase(),
1895
+ headers: headers.normalize().toJSON(),
1896
+ body: data,
1897
+ duplex: "half",
1898
+ credentials: isCredentialsSupported ? withCredentials : void 0
1899
+ }));
1900
+ let response = yield fetch(request);
1901
+ const isStreamResponse = supportsResponseStream && (responseType === "stream" || responseType === "response");
1902
+ if (supportsResponseStream && (onDownloadProgress || isStreamResponse && unsubscribe)) {
1903
+ const options = {};
1904
+ ["status", "statusText", "headers"].forEach((prop) => {
1905
+ options[prop] = response[prop];
183
1906
  });
1907
+ const responseContentLength = utils$1.toFiniteNumber(response.headers.get("content-length"));
1908
+ const [onProgress, flush] = onDownloadProgress && progressEventDecorator(
1909
+ responseContentLength,
1910
+ progressEventReducer(asyncDecorator(onDownloadProgress), true)
1911
+ ) || [];
1912
+ response = new Response(
1913
+ trackStream(response.body, DEFAULT_CHUNK_SIZE, onProgress, () => {
1914
+ flush && flush();
1915
+ unsubscribe && unsubscribe();
1916
+ }),
1917
+ options
1918
+ );
1919
+ }
1920
+ responseType = responseType || "text";
1921
+ let responseData = yield resolvers[utils$1.findKey(resolvers, responseType) || "text"](response, config2);
1922
+ !isStreamResponse && unsubscribe && unsubscribe();
1923
+ return yield new Promise((resolve, reject) => {
1924
+ settle(resolve, reject, {
1925
+ data: responseData,
1926
+ headers: AxiosHeaders$1.from(response.headers),
1927
+ status: response.status,
1928
+ statusText: response.statusText,
1929
+ config: config2,
1930
+ request
1931
+ });
1932
+ });
1933
+ } catch (err) {
1934
+ unsubscribe && unsubscribe();
1935
+ if (err && err.name === "TypeError" && /fetch/i.test(err.message)) {
1936
+ throw Object.assign(
1937
+ new AxiosError$1("Network Error", AxiosError$1.ERR_NETWORK, config2, request),
1938
+ {
1939
+ cause: err.cause || err
1940
+ }
1941
+ );
1942
+ }
1943
+ throw AxiosError$1.from(err, err && err.code, config2, request);
1944
+ }
1945
+ }));
1946
+ const knownAdapters = {
1947
+ http: httpAdapter,
1948
+ xhr: xhrAdapter,
1949
+ fetch: fetchAdapter
1950
+ };
1951
+ utils$1.forEach(knownAdapters, (fn, value) => {
1952
+ if (fn) {
1953
+ try {
1954
+ Object.defineProperty(fn, "name", { value });
1955
+ } catch (e) {
1956
+ }
1957
+ Object.defineProperty(fn, "adapterName", { value });
1958
+ }
1959
+ });
1960
+ const renderReason = (reason) => `- ${reason}`;
1961
+ const isResolvedHandle = (adapter) => utils$1.isFunction(adapter) || adapter === null || adapter === false;
1962
+ const adapters = {
1963
+ getAdapter: (adapters2) => {
1964
+ adapters2 = utils$1.isArray(adapters2) ? adapters2 : [adapters2];
1965
+ const { length } = adapters2;
1966
+ let nameOrAdapter;
1967
+ let adapter;
1968
+ const rejectedReasons = {};
1969
+ for (let i = 0; i < length; i++) {
1970
+ nameOrAdapter = adapters2[i];
1971
+ let id;
1972
+ adapter = nameOrAdapter;
1973
+ if (!isResolvedHandle(nameOrAdapter)) {
1974
+ adapter = knownAdapters[(id = String(nameOrAdapter)).toLowerCase()];
1975
+ if (adapter === void 0) {
1976
+ throw new AxiosError$1(`Unknown adapter '${id}'`);
1977
+ }
1978
+ }
1979
+ if (adapter) {
1980
+ break;
1981
+ }
1982
+ rejectedReasons[id || "#" + i] = adapter;
1983
+ }
1984
+ if (!adapter) {
1985
+ const reasons = Object.entries(rejectedReasons).map(
1986
+ ([id, state]) => `adapter ${id} ` + (state === false ? "is not supported by the environment" : "is not available in the build")
1987
+ );
1988
+ let s = length ? reasons.length > 1 ? "since :\n" + reasons.map(renderReason).join("\n") : " " + renderReason(reasons[0]) : "as no adapter specified";
1989
+ throw new AxiosError$1(
1990
+ `There is no suitable adapter to dispatch the request ` + s,
1991
+ "ERR_NOT_SUPPORT"
1992
+ );
1993
+ }
1994
+ return adapter;
1995
+ },
1996
+ adapters: knownAdapters
1997
+ };
1998
+ function throwIfCancellationRequested(config2) {
1999
+ if (config2.cancelToken) {
2000
+ config2.cancelToken.throwIfRequested();
2001
+ }
2002
+ if (config2.signal && config2.signal.aborted) {
2003
+ throw new CanceledError$1(null, config2);
2004
+ }
2005
+ }
2006
+ function dispatchRequest(config2) {
2007
+ throwIfCancellationRequested(config2);
2008
+ config2.headers = AxiosHeaders$1.from(config2.headers);
2009
+ config2.data = transformData.call(
2010
+ config2,
2011
+ config2.transformRequest
2012
+ );
2013
+ if (["post", "put", "patch"].indexOf(config2.method) !== -1) {
2014
+ config2.headers.setContentType("application/x-www-form-urlencoded", false);
2015
+ }
2016
+ const adapter = adapters.getAdapter(config2.adapter || defaults.adapter);
2017
+ return adapter(config2).then(function onAdapterResolution(response) {
2018
+ throwIfCancellationRequested(config2);
2019
+ response.data = transformData.call(
2020
+ config2,
2021
+ config2.transformResponse,
2022
+ response
2023
+ );
2024
+ response.headers = AxiosHeaders$1.from(response.headers);
2025
+ return response;
2026
+ }, function onAdapterRejection(reason) {
2027
+ if (!isCancel$1(reason)) {
2028
+ throwIfCancellationRequested(config2);
2029
+ if (reason && reason.response) {
2030
+ reason.response.data = transformData.call(
2031
+ config2,
2032
+ config2.transformResponse,
2033
+ reason.response
2034
+ );
2035
+ reason.response.headers = AxiosHeaders$1.from(reason.response.headers);
2036
+ }
2037
+ }
2038
+ return Promise.reject(reason);
2039
+ });
2040
+ }
2041
+ const VERSION$1 = "1.7.9";
2042
+ const validators$1 = {};
2043
+ ["object", "boolean", "number", "function", "string", "symbol"].forEach((type, i) => {
2044
+ validators$1[type] = function validator2(thing) {
2045
+ return typeof thing === type || "a" + (i < 1 ? "n " : " ") + type;
2046
+ };
2047
+ });
2048
+ const deprecatedWarnings = {};
2049
+ validators$1.transitional = function transitional(validator2, version, message) {
2050
+ function formatMessage(opt, desc) {
2051
+ return "[Axios v" + VERSION$1 + "] Transitional option '" + opt + "'" + desc + (message ? ". " + message : "");
2052
+ }
2053
+ return (value, opt, opts) => {
2054
+ if (validator2 === false) {
2055
+ throw new AxiosError$1(
2056
+ formatMessage(opt, " has been removed" + (version ? " in " + version : "")),
2057
+ AxiosError$1.ERR_DEPRECATED
2058
+ );
2059
+ }
2060
+ if (version && !deprecatedWarnings[opt]) {
2061
+ deprecatedWarnings[opt] = true;
2062
+ }
2063
+ return validator2 ? validator2(value, opt, opts) : true;
2064
+ };
2065
+ };
2066
+ validators$1.spelling = function spelling(correctSpelling) {
2067
+ return (value, opt) => {
2068
+ return true;
2069
+ };
2070
+ };
2071
+ function assertOptions(options, schema, allowUnknown) {
2072
+ if (typeof options !== "object") {
2073
+ throw new AxiosError$1("options must be an object", AxiosError$1.ERR_BAD_OPTION_VALUE);
2074
+ }
2075
+ const keys = Object.keys(options);
2076
+ let i = keys.length;
2077
+ while (i-- > 0) {
2078
+ const opt = keys[i];
2079
+ const validator2 = schema[opt];
2080
+ if (validator2) {
2081
+ const value = options[opt];
2082
+ const result = value === void 0 || validator2(value, opt, options);
2083
+ if (result !== true) {
2084
+ throw new AxiosError$1("option " + opt + " must be " + result, AxiosError$1.ERR_BAD_OPTION_VALUE);
2085
+ }
2086
+ continue;
2087
+ }
2088
+ if (allowUnknown !== true) {
2089
+ throw new AxiosError$1("Unknown option " + opt, AxiosError$1.ERR_BAD_OPTION);
2090
+ }
2091
+ }
2092
+ }
2093
+ const validator = {
2094
+ assertOptions,
2095
+ validators: validators$1
2096
+ };
2097
+ const validators = validator.validators;
2098
+ let Axios$1 = class Axios {
2099
+ constructor(instanceConfig) {
2100
+ this.defaults = instanceConfig;
2101
+ this.interceptors = {
2102
+ request: new InterceptorManager(),
2103
+ response: new InterceptorManager()
2104
+ };
2105
+ }
2106
+ /**
2107
+ * Dispatch a request
2108
+ *
2109
+ * @param {String|Object} configOrUrl The config specific for this request (merged with this.defaults)
2110
+ * @param {?Object} config
2111
+ *
2112
+ * @returns {Promise} The Promise to be fulfilled
2113
+ */
2114
+ request(configOrUrl, config2) {
2115
+ return __async(this, null, function* () {
2116
+ try {
2117
+ return yield this._request(configOrUrl, config2);
2118
+ } catch (err) {
2119
+ if (err instanceof Error) {
2120
+ let dummy = {};
2121
+ Error.captureStackTrace ? Error.captureStackTrace(dummy) : dummy = new Error();
2122
+ const stack = dummy.stack ? dummy.stack.replace(/^.+\n/, "") : "";
2123
+ try {
2124
+ if (!err.stack) {
2125
+ err.stack = stack;
2126
+ } else if (stack && !String(err.stack).endsWith(stack.replace(/^.+\n.+\n/, ""))) {
2127
+ err.stack += "\n" + stack;
2128
+ }
2129
+ } catch (e) {
2130
+ }
2131
+ }
2132
+ throw err;
2133
+ }
2134
+ });
2135
+ }
2136
+ _request(configOrUrl, config2) {
2137
+ if (typeof configOrUrl === "string") {
2138
+ config2 = config2 || {};
2139
+ config2.url = configOrUrl;
2140
+ } else {
2141
+ config2 = configOrUrl || {};
2142
+ }
2143
+ config2 = mergeConfig$1(this.defaults, config2);
2144
+ const { transitional: transitional2, paramsSerializer, headers } = config2;
2145
+ if (transitional2 !== void 0) {
2146
+ validator.assertOptions(transitional2, {
2147
+ silentJSONParsing: validators.transitional(validators.boolean),
2148
+ forcedJSONParsing: validators.transitional(validators.boolean),
2149
+ clarifyTimeoutError: validators.transitional(validators.boolean)
2150
+ }, false);
2151
+ }
2152
+ if (paramsSerializer != null) {
2153
+ if (utils$1.isFunction(paramsSerializer)) {
2154
+ config2.paramsSerializer = {
2155
+ serialize: paramsSerializer
2156
+ };
2157
+ } else {
2158
+ validator.assertOptions(paramsSerializer, {
2159
+ encode: validators.function,
2160
+ serialize: validators.function
2161
+ }, true);
2162
+ }
2163
+ }
2164
+ validator.assertOptions(config2, {
2165
+ baseUrl: validators.spelling("baseURL"),
2166
+ withXsrfToken: validators.spelling("withXSRFToken")
2167
+ }, true);
2168
+ config2.method = (config2.method || this.defaults.method || "get").toLowerCase();
2169
+ let contextHeaders = headers && utils$1.merge(
2170
+ headers.common,
2171
+ headers[config2.method]
2172
+ );
2173
+ headers && utils$1.forEach(
2174
+ ["delete", "get", "head", "post", "put", "patch", "common"],
2175
+ (method) => {
2176
+ delete headers[method];
2177
+ }
2178
+ );
2179
+ config2.headers = AxiosHeaders$1.concat(contextHeaders, headers);
2180
+ const requestInterceptorChain = [];
2181
+ let synchronousRequestInterceptors = true;
2182
+ this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
2183
+ if (typeof interceptor.runWhen === "function" && interceptor.runWhen(config2) === false) {
2184
+ return;
2185
+ }
2186
+ synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
2187
+ requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
2188
+ });
2189
+ const responseInterceptorChain = [];
2190
+ this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
2191
+ responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
2192
+ });
2193
+ let promise;
2194
+ let i = 0;
2195
+ let len;
2196
+ if (!synchronousRequestInterceptors) {
2197
+ const chain = [dispatchRequest.bind(this), void 0];
2198
+ chain.unshift.apply(chain, requestInterceptorChain);
2199
+ chain.push.apply(chain, responseInterceptorChain);
2200
+ len = chain.length;
2201
+ promise = Promise.resolve(config2);
2202
+ while (i < len) {
2203
+ promise = promise.then(chain[i++], chain[i++]);
2204
+ }
2205
+ return promise;
2206
+ }
2207
+ len = requestInterceptorChain.length;
2208
+ let newConfig = config2;
2209
+ i = 0;
2210
+ while (i < len) {
2211
+ const onFulfilled = requestInterceptorChain[i++];
2212
+ const onRejected = requestInterceptorChain[i++];
2213
+ try {
2214
+ newConfig = onFulfilled(newConfig);
2215
+ } catch (error) {
2216
+ onRejected.call(this, error);
2217
+ break;
2218
+ }
2219
+ }
2220
+ try {
2221
+ promise = dispatchRequest.call(this, newConfig);
2222
+ } catch (error) {
2223
+ return Promise.reject(error);
2224
+ }
2225
+ i = 0;
2226
+ len = responseInterceptorChain.length;
2227
+ while (i < len) {
2228
+ promise = promise.then(responseInterceptorChain[i++], responseInterceptorChain[i++]);
2229
+ }
2230
+ return promise;
2231
+ }
2232
+ getUri(config2) {
2233
+ config2 = mergeConfig$1(this.defaults, config2);
2234
+ const fullPath = buildFullPath(config2.baseURL, config2.url);
2235
+ return buildURL(fullPath, config2.params, config2.paramsSerializer);
2236
+ }
2237
+ };
2238
+ utils$1.forEach(["delete", "get", "head", "options"], function forEachMethodNoData(method) {
2239
+ Axios$1.prototype[method] = function(url, config2) {
2240
+ return this.request(mergeConfig$1(config2 || {}, {
2241
+ method,
2242
+ url,
2243
+ data: (config2 || {}).data
2244
+ }));
2245
+ };
2246
+ });
2247
+ utils$1.forEach(["post", "put", "patch"], function forEachMethodWithData(method) {
2248
+ function generateHTTPMethod(isForm) {
2249
+ return function httpMethod(url, data, config2) {
2250
+ return this.request(mergeConfig$1(config2 || {}, {
2251
+ method,
2252
+ headers: isForm ? {
2253
+ "Content-Type": "multipart/form-data"
2254
+ } : {},
2255
+ url,
2256
+ data
2257
+ }));
2258
+ };
2259
+ }
2260
+ Axios$1.prototype[method] = generateHTTPMethod();
2261
+ Axios$1.prototype[method + "Form"] = generateHTTPMethod(true);
2262
+ });
2263
+ let CancelToken$1 = class CancelToken {
2264
+ constructor(executor) {
2265
+ if (typeof executor !== "function") {
2266
+ throw new TypeError("executor must be a function.");
2267
+ }
2268
+ let resolvePromise;
2269
+ this.promise = new Promise(function promiseExecutor(resolve) {
2270
+ resolvePromise = resolve;
2271
+ });
2272
+ const token = this;
2273
+ this.promise.then((cancel) => {
2274
+ if (!token._listeners) return;
2275
+ let i = token._listeners.length;
2276
+ while (i-- > 0) {
2277
+ token._listeners[i](cancel);
2278
+ }
2279
+ token._listeners = null;
2280
+ });
2281
+ this.promise.then = (onfulfilled) => {
2282
+ let _resolve;
2283
+ const promise = new Promise((resolve) => {
2284
+ token.subscribe(resolve);
2285
+ _resolve = resolve;
2286
+ }).then(onfulfilled);
2287
+ promise.cancel = function reject() {
2288
+ token.unsubscribe(_resolve);
2289
+ };
2290
+ return promise;
2291
+ };
2292
+ executor(function cancel(message, config2, request) {
2293
+ if (token.reason) {
2294
+ return;
2295
+ }
2296
+ token.reason = new CanceledError$1(message, config2, request);
2297
+ resolvePromise(token.reason);
2298
+ });
2299
+ }
2300
+ /**
2301
+ * Throws a `CanceledError` if cancellation has been requested.
2302
+ */
2303
+ throwIfRequested() {
2304
+ if (this.reason) {
2305
+ throw this.reason;
2306
+ }
2307
+ }
2308
+ /**
2309
+ * Subscribe to the cancel signal
2310
+ */
2311
+ subscribe(listener) {
2312
+ if (this.reason) {
2313
+ listener(this.reason);
2314
+ return;
2315
+ }
2316
+ if (this._listeners) {
2317
+ this._listeners.push(listener);
2318
+ } else {
2319
+ this._listeners = [listener];
2320
+ }
2321
+ }
2322
+ /**
2323
+ * Unsubscribe from the cancel signal
2324
+ */
2325
+ unsubscribe(listener) {
2326
+ if (!this._listeners) {
2327
+ return;
2328
+ }
2329
+ const index2 = this._listeners.indexOf(listener);
2330
+ if (index2 !== -1) {
2331
+ this._listeners.splice(index2, 1);
2332
+ }
2333
+ }
2334
+ toAbortSignal() {
2335
+ const controller = new AbortController();
2336
+ const abort = (err) => {
2337
+ controller.abort(err);
2338
+ };
2339
+ this.subscribe(abort);
2340
+ controller.signal.unsubscribe = () => this.unsubscribe(abort);
2341
+ return controller.signal;
2342
+ }
2343
+ /**
2344
+ * Returns an object that contains a new `CancelToken` and a function that, when called,
2345
+ * cancels the `CancelToken`.
2346
+ */
2347
+ static source() {
2348
+ let cancel;
2349
+ const token = new CancelToken(function executor(c) {
2350
+ cancel = c;
2351
+ });
2352
+ return {
2353
+ token,
2354
+ cancel
2355
+ };
2356
+ }
2357
+ };
2358
+ function spread$1(callback) {
2359
+ return function wrap(arr) {
2360
+ return callback.apply(null, arr);
2361
+ };
2362
+ }
2363
+ function isAxiosError$1(payload) {
2364
+ return utils$1.isObject(payload) && payload.isAxiosError === true;
2365
+ }
2366
+ const HttpStatusCode$1 = {
2367
+ Continue: 100,
2368
+ SwitchingProtocols: 101,
2369
+ Processing: 102,
2370
+ EarlyHints: 103,
2371
+ Ok: 200,
2372
+ Created: 201,
2373
+ Accepted: 202,
2374
+ NonAuthoritativeInformation: 203,
2375
+ NoContent: 204,
2376
+ ResetContent: 205,
2377
+ PartialContent: 206,
2378
+ MultiStatus: 207,
2379
+ AlreadyReported: 208,
2380
+ ImUsed: 226,
2381
+ MultipleChoices: 300,
2382
+ MovedPermanently: 301,
2383
+ Found: 302,
2384
+ SeeOther: 303,
2385
+ NotModified: 304,
2386
+ UseProxy: 305,
2387
+ Unused: 306,
2388
+ TemporaryRedirect: 307,
2389
+ PermanentRedirect: 308,
2390
+ BadRequest: 400,
2391
+ Unauthorized: 401,
2392
+ PaymentRequired: 402,
2393
+ Forbidden: 403,
2394
+ NotFound: 404,
2395
+ MethodNotAllowed: 405,
2396
+ NotAcceptable: 406,
2397
+ ProxyAuthenticationRequired: 407,
2398
+ RequestTimeout: 408,
2399
+ Conflict: 409,
2400
+ Gone: 410,
2401
+ LengthRequired: 411,
2402
+ PreconditionFailed: 412,
2403
+ PayloadTooLarge: 413,
2404
+ UriTooLong: 414,
2405
+ UnsupportedMediaType: 415,
2406
+ RangeNotSatisfiable: 416,
2407
+ ExpectationFailed: 417,
2408
+ ImATeapot: 418,
2409
+ MisdirectedRequest: 421,
2410
+ UnprocessableEntity: 422,
2411
+ Locked: 423,
2412
+ FailedDependency: 424,
2413
+ TooEarly: 425,
2414
+ UpgradeRequired: 426,
2415
+ PreconditionRequired: 428,
2416
+ TooManyRequests: 429,
2417
+ RequestHeaderFieldsTooLarge: 431,
2418
+ UnavailableForLegalReasons: 451,
2419
+ InternalServerError: 500,
2420
+ NotImplemented: 501,
2421
+ BadGateway: 502,
2422
+ ServiceUnavailable: 503,
2423
+ GatewayTimeout: 504,
2424
+ HttpVersionNotSupported: 505,
2425
+ VariantAlsoNegotiates: 506,
2426
+ InsufficientStorage: 507,
2427
+ LoopDetected: 508,
2428
+ NotExtended: 510,
2429
+ NetworkAuthenticationRequired: 511
2430
+ };
2431
+ Object.entries(HttpStatusCode$1).forEach(([key, value]) => {
2432
+ HttpStatusCode$1[value] = key;
2433
+ });
2434
+ function createInstance(defaultConfig) {
2435
+ const context = new Axios$1(defaultConfig);
2436
+ const instance = bind(Axios$1.prototype.request, context);
2437
+ utils$1.extend(instance, Axios$1.prototype, context, { allOwnKeys: true });
2438
+ utils$1.extend(instance, context, null, { allOwnKeys: true });
2439
+ instance.create = function create(instanceConfig) {
2440
+ return createInstance(mergeConfig$1(defaultConfig, instanceConfig));
2441
+ };
2442
+ return instance;
2443
+ }
2444
+ const axios = createInstance(defaults);
2445
+ axios.Axios = Axios$1;
2446
+ axios.CanceledError = CanceledError$1;
2447
+ axios.CancelToken = CancelToken$1;
2448
+ axios.isCancel = isCancel$1;
2449
+ axios.VERSION = VERSION$1;
2450
+ axios.toFormData = toFormData$1;
2451
+ axios.AxiosError = AxiosError$1;
2452
+ axios.Cancel = axios.CanceledError;
2453
+ axios.all = function all(promises) {
2454
+ return Promise.all(promises);
2455
+ };
2456
+ axios.spread = spread$1;
2457
+ axios.isAxiosError = isAxiosError$1;
2458
+ axios.mergeConfig = mergeConfig$1;
2459
+ axios.AxiosHeaders = AxiosHeaders$1;
2460
+ axios.formToJSON = (thing) => formDataToJSON(utils$1.isHTMLForm(thing) ? new FormData(thing) : thing);
2461
+ axios.getAdapter = adapters.getAdapter;
2462
+ axios.HttpStatusCode = HttpStatusCode$1;
2463
+ axios.default = axios;
2464
+ const {
2465
+ Axios: Axios2,
2466
+ AxiosError,
2467
+ CanceledError,
2468
+ isCancel,
2469
+ CancelToken: CancelToken2,
2470
+ VERSION,
2471
+ all: all2,
2472
+ Cancel,
2473
+ isAxiosError,
2474
+ spread,
2475
+ toFormData,
2476
+ AxiosHeaders: AxiosHeaders2,
2477
+ HttpStatusCode,
2478
+ formToJSON,
2479
+ getAdapter,
2480
+ mergeConfig
2481
+ } = axios;
2482
+ const ttc = {
2483
+ LOGIN_URL: `${window.location.origin}/ttc/cloud/#/login`,
2484
+ HOME_URL: `${window.location.origin}/ttc/cloud/#/cloud`,
2485
+ INTEGRATED_BASE_URL: `/gateway/integrated-management/api/v1`
2486
+ };
2487
+ const URL$1 = {
2488
+ ttc
2489
+ };
2490
+ const BC_THEME_NAME = "THEME";
2491
+ const BC_LANG_NAME = "LANG";
2492
+ const getAuthRouteList = (systemName = "ttc") => {
2493
+ return http.get(`${URL$1[systemName].INTEGRATED_BASE_URL}/account/auth/route/list`);
2494
+ };
2495
+ const getHomeMenuList = (systemName = "ttc") => {
2496
+ return http.get(`${URL$1[systemName].INTEGRATED_BASE_URL}/account/home/menu`);
2497
+ };
2498
+ const removeToken = (systemName = "ttc") => {
2499
+ setSystemConfig({ token: "" });
2500
+ };
2501
+ const getToken = (systemName = "ttc") => {
2502
+ var _a;
2503
+ const GlobalStateKey = `${systemName}GlobalState`;
2504
+ const GlobalState = (_a = localStorage.getItem(GlobalStateKey)) != null ? _a : "{}";
2505
+ const token = JSON.parse(GlobalState) ? JSON.parse(GlobalState).token : null;
2506
+ return token;
2507
+ };
2508
+ const autoLogin = (_0, ..._1) => __async(void 0, [_0, ..._1], function* ({ userName, password }, systemName = "ttc") {
2509
+ const loginApiUrl = getSystemConfig("loginApiUrl");
2510
+ const { data } = yield http.post(loginApiUrl, { userName, password });
2511
+ if (data.tokenValue) {
2512
+ ElMessage.success("登录成功");
2513
+ }
2514
+ setSystemConfig({ token: data.tokenValue, userInfo: data });
2515
+ });
2516
+ const getUserInfo = (systemName = "ttc") => {
2517
+ var _a;
2518
+ const GlobalStateKey = `${systemName}GlobalState`;
2519
+ const GlobalState = (_a = localStorage.getItem(GlobalStateKey)) != null ? _a : "{}";
2520
+ const userInfo = JSON.parse(GlobalState) ? JSON.parse(GlobalState).userInfo : null;
2521
+ return userInfo;
2522
+ };
2523
+ const getUserRouteList = () => __async(void 0, null, function* () {
2524
+ if (!getToken()) return [];
2525
+ const data = yield getHomeMenuList();
2526
+ return data;
2527
+ });
2528
+ const jumpToLogin = () => {
2529
+ if (isProduction()) {
2530
+ removeToken();
2531
+ const curRoute = location.pathname;
2532
+ if (curRoute.includes(getLoginUrl())) {
2533
+ return;
2534
+ } else {
2535
+ location.replace(getLoginUrl());
2536
+ }
2537
+ } else {
2538
+ const userName = window.prompt("当前系统处于开发环境,当前登录过期,请输入登录账号", "");
2539
+ if (userName !== null) {
2540
+ const password = window.prompt("请输入登录密码", "");
2541
+ if (password === null || password == "") window.prompt("请输入登录密码", "");
2542
+ autoLogin({ userName, password });
2543
+ }
2544
+ }
2545
+ };
2546
+ const jumpToHome = () => {
2547
+ window.location.replace(getHomeUrl());
2548
+ };
2549
+ const getLoginUrl = () => {
2550
+ return getSystemConfig("loginUrl");
2551
+ };
2552
+ const getHomeUrl = () => {
2553
+ return getSystemConfig("homeUrl");
2554
+ };
2555
+ const setSystemConfig = (config2) => {
2556
+ var _a;
2557
+ const GlobalState = (_a = localStorage.getItem("ttcGlobalState")) != null ? _a : "{}";
2558
+ const newGlobalState = __spreadValues(__spreadValues({}, JSON.parse(GlobalState)), config2);
2559
+ localStorage.setItem("ttcGlobalState", JSON.stringify(newGlobalState));
2560
+ };
2561
+ const changeSystemConfig = (key, value) => {
2562
+ var _a;
2563
+ const GlobalState = (_a = localStorage.getItem("ttcGlobalState")) != null ? _a : "{}";
2564
+ const newGlobalState = __spreadProps(__spreadValues({}, JSON.parse(GlobalState)), { [key]: value });
2565
+ localStorage.setItem("ttcGlobalState", JSON.stringify(newGlobalState));
2566
+ };
2567
+ const getSystemConfig = (key) => {
2568
+ var _a, _b;
2569
+ const GlobalState = JSON.parse((_a = localStorage.getItem("ttcGlobalState")) != null ? _a : "{}");
2570
+ return (_b = GlobalState[key]) != null ? _b : "";
2571
+ };
2572
+ const isProduction = () => {
2573
+ return getSystemConfig("environment") === "production";
2574
+ };
2575
+ const getUserPermissions = (systemName, isJumpLogin = true, serverName) => __async(void 0, null, function* () {
2576
+ if (!getToken() && isJumpLogin) return jumpToLogin();
2577
+ try {
2578
+ const { data } = yield getAuthRouteList(serverName);
2579
+ const systemPermissionList = data.filter((route) => route.routeTag.includes(systemName));
2580
+ const userMenuList = systemPermissionList.filter((item) => item.routeType === "VIEW");
2581
+ const userBtnList = systemPermissionList.filter((item) => item.routeType === "BTN");
2582
+ sessionStorage.setItem("ttcUserBtnList", JSON.stringify(userBtnList.map((item) => item.routeTag)));
2583
+ return {
2584
+ userMenuList,
2585
+ userBtnList
2586
+ };
2587
+ } catch (err) {
2588
+ }
2589
+ });
2590
+ const getUserRouter = (userMenuList, viewModules, viewConfig) => {
2591
+ let menuList = [];
2592
+ userMenuList.forEach((item) => {
2593
+ const configKey = `/src/views${item.routeView}/config.ts`;
2594
+ const viewKey = `/src/views${item.routeView}/index.vue`;
2595
+ if (viewModules[viewKey] && viewConfig[configKey]) {
2596
+ const pageConfig = viewConfig[configKey];
2597
+ const routerObject = {
2598
+ path: item.routeView,
2599
+ name: item.routeView.split("/")[1],
2600
+ meta: {
2601
+ title: pageConfig.title,
2602
+ icon: pageConfig.icon
2603
+ },
2604
+ component: viewModules[viewKey]
2605
+ };
2606
+ menuList.push(routerObject);
184
2607
  }
2608
+ });
2609
+ return menuList;
2610
+ };
2611
+ const getUserIsHaveBtnPower = (routeTag) => {
2612
+ var _a;
2613
+ if (!routeTag) return false;
2614
+ const authButtonListGet = (_a = sessionStorage.getItem("ttcUserBtnList")) != null ? _a : "[]";
2615
+ return JSON.parse(authButtonListGet).includes(routeTag);
2616
+ };
2617
+ const index = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2618
+ __proto__: null,
2619
+ autoLogin,
2620
+ changeSystemConfig,
2621
+ getHomeUrl,
2622
+ getLoginUrl,
2623
+ getSystemConfig,
2624
+ getToken,
2625
+ getUserInfo,
2626
+ getUserIsHaveBtnPower,
2627
+ getUserPermissions,
2628
+ getUserRouteList,
2629
+ getUserRouter,
2630
+ isProduction,
2631
+ jumpToHome,
2632
+ jumpToLogin,
2633
+ removeToken,
2634
+ setSystemConfig
2635
+ }, Symbol.toStringTag, { value: "Module" }));
2636
+ let loadingInstance;
2637
+ const loadingOptions = {
2638
+ lock: true,
2639
+ text: "loading...",
2640
+ fullscreen: true,
2641
+ background: "rgba(0, 0, 0, 0.6)"
2642
+ };
2643
+ const startLoading = () => {
2644
+ loadingInstance = ElLoading.service(loadingOptions);
2645
+ };
2646
+ const endLoading = () => {
2647
+ loadingInstance.close();
2648
+ };
2649
+ let needLoadingRequestCount = 0;
2650
+ const showFullScreenLoading = () => {
2651
+ if (needLoadingRequestCount === 0) {
2652
+ startLoading();
2653
+ }
2654
+ needLoadingRequestCount++;
2655
+ };
2656
+ const hideFullScreenLoading = () => {
2657
+ if (needLoadingRequestCount <= 0) return;
2658
+ needLoadingRequestCount--;
2659
+ if (needLoadingRequestCount === 0) {
2660
+ endLoading();
2661
+ }
2662
+ };
2663
+ var ResultEnum = /* @__PURE__ */ ((ResultEnum2) => {
2664
+ ResultEnum2[ResultEnum2["SUCCESS"] = 200] = "SUCCESS";
2665
+ ResultEnum2[ResultEnum2["ERROR"] = 500] = "ERROR";
2666
+ ResultEnum2[ResultEnum2["OVERDUE"] = 401] = "OVERDUE";
2667
+ ResultEnum2[ResultEnum2["TIMEOUT"] = 3e4] = "TIMEOUT";
2668
+ return ResultEnum2;
2669
+ })(ResultEnum || {});
2670
+ const config = {
2671
+ // 默认地址请求地址,可在 .env.*** 文件中修改
2672
+ // 设置超时时间(30s)
2673
+ timeout: 3e4,
2674
+ // 跨域时候允许携带凭证
2675
+ withCredentials: true
2676
+ };
2677
+ const checkStatus = (status, msg) => {
2678
+ switch (status) {
2679
+ case 400:
2680
+ ElMessage.error(msg || "请求失败!请您稍后重试");
2681
+ break;
2682
+ case 401:
2683
+ ElMessage.error(msg || "登录失效!请您重新登录");
2684
+ break;
2685
+ case 403:
2686
+ ElMessage.error(msg || "当前账号无权限访问!");
2687
+ break;
2688
+ case 404:
2689
+ ElMessage.error("你所访问的资源不存在");
2690
+ break;
2691
+ case 405:
2692
+ ElMessage.error(msg || "请求方式错误!请您稍后重试");
2693
+ break;
2694
+ case 408:
2695
+ ElMessage.error(msg || "请求超时!请您稍后重试");
2696
+ break;
2697
+ case 500:
2698
+ ElMessage.error(msg || "服务异常!");
2699
+ break;
2700
+ case 502:
2701
+ ElMessage.error(msg || "网关错误!");
2702
+ break;
2703
+ case 503:
2704
+ ElMessage.error(msg || "服务不可用");
2705
+ break;
2706
+ case 504:
2707
+ ElMessage.error(msg || "网关超时!");
2708
+ break;
2709
+ default:
2710
+ ElMessage.error(msg || "请求失败!请您稍后重试!");
2711
+ }
2712
+ };
2713
+ getSystemConfig("isTranslateApi");
2714
+ class YxHttp {
2715
+ constructor(config2) {
2716
+ __publicField(this, "service");
2717
+ /** 自定义响应处理map */
2718
+ __publicField(this, "customResMap");
2719
+ this.service = axios.create(config2);
2720
+ this.setupInterceptors();
2721
+ this.customResMap = {};
2722
+ }
2723
+ setupInterceptors() {
2724
+ this.service.interceptors.request.use(
2725
+ (config2) => {
2726
+ var _a;
2727
+ if (!((_a = config2.headers) == null ? void 0 : _a.noLoading)) {
2728
+ showFullScreenLoading();
2729
+ }
2730
+ config2.headers.token = getToken();
2731
+ if ((config2 == null ? void 0 : config2.customResHandler) && (config2 == null ? void 0 : config2.url)) {
2732
+ this.customResMap[config2 == null ? void 0 : config2.url] = config2.customResHandler;
2733
+ }
2734
+ return config2;
2735
+ },
2736
+ (error) => {
2737
+ return Promise.reject(error);
2738
+ }
2739
+ );
2740
+ this.service.interceptors.response.use(
2741
+ (response) => __async(this, null, function* () {
2742
+ const { config: config2 } = response;
2743
+ let data = response.data;
2744
+ const code = response.status;
2745
+ hideFullScreenLoading();
2746
+ if (config2.url && this.customResMap[config2.url]) {
2747
+ return this.customResMap[config2.url](data);
2748
+ }
2749
+ if (code == ResultEnum.OVERDUE) {
2750
+ this.handleOverdueResponse(data);
2751
+ } else if (code !== ResultEnum.SUCCESS) {
2752
+ this.handleErrorResponse(data);
2753
+ }
2754
+ return data;
2755
+ }),
2756
+ (error) => {
2757
+ var _a;
2758
+ hideFullScreenLoading();
2759
+ const response = error.response;
2760
+ const { config: config2 } = error;
2761
+ if ((config2 == null ? void 0 : config2.url) && this.customResMap[config2.url]) {
2762
+ this.customResMap[config2.url](error.response);
2763
+ }
2764
+ if (error.message.includes("timeout")) {
2765
+ ElMessage.error("请求超时!请稍后重试");
2766
+ } else if (error.message.includes("Network Error")) {
2767
+ ElMessage.error("网络错误!请稍后重试");
2768
+ }
2769
+ if (response) {
2770
+ checkStatus(response.status, (_a = response.data) == null ? void 0 : _a.resultMsg);
2771
+ }
2772
+ if (!window.navigator.onLine) {
2773
+ ElNotification({
2774
+ title: "提示",
2775
+ message: "当前网络似乎开小差了",
2776
+ type: "warning",
2777
+ duration: 5e3
2778
+ });
2779
+ }
2780
+ return Promise.reject(error);
2781
+ }
2782
+ );
2783
+ }
2784
+ handleOverdueResponse(data) {
2785
+ removeToken();
2786
+ jumpToLogin();
2787
+ ElNotification({
2788
+ title: "登录过期提醒",
2789
+ message: data.resultMsg || "当前登录失效",
2790
+ type: "warning",
2791
+ duration: 5e3
2792
+ });
2793
+ return Promise.reject(data);
2794
+ }
2795
+ handleErrorResponse(data) {
2796
+ ElMessage.error(data.resultMsg);
2797
+ return Promise.reject(data);
2798
+ }
2799
+ /**
2800
+ *
2801
+ * @param url
2802
+ * @param params
2803
+ * @param options : AxiosRequestConfig
2804
+ * @description get 请求
2805
+ */
2806
+ get(url, params, options = {}) {
2807
+ return this.service.get(url, __spreadValues({ params }, options));
2808
+ }
2809
+ /**
2810
+ *
2811
+ * @param url
2812
+ * @param params
2813
+ * @param options : AxiosRequestConfig
2814
+ * @description post 请求
2815
+ */
2816
+ post(url, params, options = {}) {
2817
+ return this.service.post(url, params, options);
2818
+ }
2819
+ /**
2820
+ *
2821
+ * @param url
2822
+ * @param params
2823
+ * @param options : AxiosRequestConfig
2824
+ */
2825
+ put(url, params, options = {}) {
2826
+ return this.service.put(url, params, options);
2827
+ }
2828
+ /**
2829
+ *
2830
+ * @param url
2831
+ * @param params
2832
+ * @param options : AxiosRequestConfig
2833
+ */
2834
+ delete(url, params, options = {}) {
2835
+ return this.service.delete(url, __spreadValues({ params }, options));
185
2836
  }
186
2837
  }
187
- const yxSubscribe = new YxSubscribe();
2838
+ const http = new YxHttp(config);
188
2839
  export {
189
- areColorsSimilar as a,
190
- isDarkColor as b,
191
- enumToArray as e,
192
- getSelectOptions as g,
193
- isColorEqual as i,
194
- notifyMessageToSystems as n,
195
- receiveMessage as r,
196
- yxSubscribe as y
2840
+ BC_LANG_NAME as B,
2841
+ URL$1 as U,
2842
+ http as a,
2843
+ getUserIsHaveBtnPower as b,
2844
+ checkStatus as c,
2845
+ changeSystemConfig as d,
2846
+ getSystemConfig as e,
2847
+ BC_THEME_NAME as f,
2848
+ getToken as g,
2849
+ hideFullScreenLoading as h,
2850
+ setSystemConfig as i,
2851
+ index as j,
2852
+ showFullScreenLoading as s
197
2853
  };
2854
+ //# sourceMappingURL=index.es12.js.map