@cccsaurora/clue-ui 1.2.3-dev.266 → 1.2.3

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 (183) hide show
  1. package/ActionForm-DlOXqMUx.js +4460 -0
  2. package/AnnotationDetails-Bk-p0F6h.js +160 -0
  3. package/AnnotationPreview-jzZvkCxJ.js +140 -0
  4. package/ClueEnrichContext-KqRuuWNS.js +418 -0
  5. package/FlexOne-BXWFOd1T.js +6 -0
  6. package/_MapCache-BiTi0iqu.js +180 -0
  7. package/_Uint8Array-BQNOM9Rr.js +101 -0
  8. package/_baseAssignValue-CNMLQZco.js +20 -0
  9. package/_baseClone-BnT-6pyM.js +207 -0
  10. package/_baseExtremum-Ca2EHgy2.js +16 -0
  11. package/_baseFlatten-Bfr_Molw.js +72 -0
  12. package/_baseGet-DSZygzyq.js +79 -0
  13. package/_baseIsEqual-VgvaAFZG.js +147 -0
  14. package/_baseIteratee-Dbfsw5z8.js +95 -0
  15. package/_baseSlice-M5RKzt1A.js +10 -0
  16. package/_baseSum-wEbgNeUs.js +10 -0
  17. package/_baseUniq-BJcj69PL.js +79 -0
  18. package/_commonjsHelpers-DaMA6jEr.js +8 -0
  19. package/_createAggregator-k3TuAnxT.js +53 -0
  20. package/_getPrototype-Cr1Mk7BC.js +5 -0
  21. package/_getTag-CK2Sffaq.js +90 -0
  22. package/_isIterateeCall-DkJP7Rbx.js +13 -0
  23. package/_setToArray-C7yMOeww.js +29 -0
  24. package/cloneDeep-CF8TtLHr.js +8 -0
  25. package/components/AnnotationBody.js +35 -49
  26. package/components/AnnotationDetailPopover.js +30 -36
  27. package/components/AnnotationDetails.js +7 -7
  28. package/components/AnnotationEntry.js +35 -35
  29. package/components/AnnotationPreview.js +5 -5
  30. package/components/ClassificationChip.js +23 -44
  31. package/components/CountBadge.js +26 -31
  32. package/components/EnrichedCard.js +97 -110
  33. package/components/EnrichedChip.js +105 -130
  34. package/components/EnrichedTypography.js +107 -133
  35. package/components/ErrorBoundary.js +24 -28
  36. package/components/RetryFailedEnrichments.js +9 -10
  37. package/components/SourcePicker.js +49 -57
  38. package/components/actions/ActionForm.js +4 -4
  39. package/components/actions/ExecutePopover.js +59 -75
  40. package/components/actions/ResultModal.js +4 -4
  41. package/components/actions/form/schemaAdapter.js +23 -39
  42. package/components/actions/formats/FileResult.js +59 -86
  43. package/components/actions/formats/index.js +10 -21
  44. package/components/display/graph/ExpandMoreButton.js +10 -10
  45. package/components/display/graph/elements/NodeCard.js +91 -111
  46. package/components/display/graph/elements/NodeTag.js +13 -15
  47. package/components/display/graph/index.js +202 -261
  48. package/components/display/graph/visualizations/Leaf.js +69 -88
  49. package/components/display/graph/visualizations/cloud/index.js +81 -98
  50. package/components/display/graph/visualizations/icons/BaseIcon.js +21 -26
  51. package/components/display/graph/visualizations/icons/BugIcon.js +12 -12
  52. package/components/display/graph/visualizations/icons/HostIcon.js +12 -12
  53. package/components/display/graph/visualizations/icons/NetworkIcon.js +12 -12
  54. package/components/display/graph/visualizations/icons/ProcessIcon.js +12 -12
  55. package/components/display/graph/visualizations/icons/TargetIcon.js +13 -13
  56. package/components/display/graph/visualizations/icons/index.js +13 -14
  57. package/components/display/graph/visualizations/panels/NodePanel.js +8 -10
  58. package/components/display/graph/visualizations/tree/BundleLine.js +81 -108
  59. package/components/display/graph/visualizations/tree/Triangle.js +13 -13
  60. package/components/display/graph/visualizations/tree/index.js +306 -408
  61. package/components/display/icons/Iconified.js +12 -27
  62. package/components/display/json/index.js +4 -4
  63. package/components/display/markdown/index.js +5770 -8678
  64. package/components/enrichment/EnrichPopover.js +46 -54
  65. package/components/fetchers/Fetcher.js +119 -158
  66. package/components/fetchers/PreviewModal.js +17 -20
  67. package/components/fetchers/StatusChip.js +17 -21
  68. package/components/group/Entry.js +11 -13
  69. package/components/group/Group.js +10 -13
  70. package/components/group/GroupControl.js +65 -76
  71. package/components/stats/QueryStatus.js +33 -43
  72. package/countBy-CdYegFSu.js +8 -0
  73. package/data/event.js +4 -6
  74. package/database/index.js +2 -2
  75. package/debounce-DryYcbJ4.js +56 -0
  76. package/get-CH7kz5Ix.js +8 -0
  77. package/groupBy-br8xmD2R.js +8 -0
  78. package/hooks/ClueActionContext.js +6 -6
  79. package/hooks/ClueComponentContext.js +23 -29
  80. package/hooks/ClueConfigProvider.js +12 -14
  81. package/hooks/ClueDatabaseContext.js +13 -19
  82. package/hooks/ClueEnrichContext.js +8 -8
  83. package/hooks/ClueFetcherContext.js +56 -83
  84. package/hooks/ClueGroupContext.js +14 -17
  85. package/hooks/CluePopupContext.js +5 -5
  86. package/hooks/ClueProvider.js +10 -12
  87. package/hooks/selectors.js +7 -7
  88. package/hooks/useActionResult.js +2 -2
  89. package/hooks/useAnnotations.js +31 -47
  90. package/hooks/useClue.js +4 -6
  91. package/hooks/useClueActions.js +3 -3
  92. package/hooks/useClueConfig.js +4 -6
  93. package/hooks/useClueTypeConfig.js +3 -3
  94. package/hooks/useComparator.js +435 -722
  95. package/hooks/useErrors.js +18 -22
  96. package/hooks/useFetcherResult.js +24 -33
  97. package/hooks/useMyHighlights.js +36 -66
  98. package/hooks/useMyLocalStorage.js +37 -66
  99. package/iconify-BBckr5AQ.js +1263 -0
  100. package/icons/Action.js +49 -66
  101. package/icons/Assessment.js +69 -85
  102. package/icons/Context.js +63 -77
  103. package/icons/Opinion.js +60 -76
  104. package/icons/iconMap.js +2 -2
  105. package/identity-ByMq8VxU.js +6 -0
  106. package/index-BHAe_V9n.js +12768 -0
  107. package/index-BK-zfYhR.js +358 -0
  108. package/index-CA5CUNZO.js +975 -0
  109. package/index-Dj5C04IX.js +568 -0
  110. package/index-p5_wX7q1.js +11729 -0
  111. package/isNil-CjWwlQS3.js +6 -0
  112. package/isObject-B53jY8Qg.js +7 -0
  113. package/isObjectLike-BatpeCIi.js +29 -0
  114. package/isSymbol-C3_SC0Qp.js +8 -0
  115. package/last-7CdUxN0r.js +7 -0
  116. package/main.js +60 -60
  117. package/maxBy-Bc0dYHcO.js +8 -0
  118. package/package.json +1 -1
  119. package/sortBy-DY2JBf9n.js +75 -0
  120. package/sumBy-DuMASLPd.js +8 -0
  121. package/text/Frequency.js +23 -42
  122. package/toFinite-BMy6GObD.js +14 -0
  123. package/toNumber-YVhnnJv4.js +31 -0
  124. package/useClueTypeConfig-Ct9Ygter.js +2292 -0
  125. package/utils/chain.js +65 -92
  126. package/utils/classificationParser.js +256 -519
  127. package/utils/constants.js +10 -35
  128. package/utils/graph.js +45 -72
  129. package/utils/hashUtil.js +7 -7
  130. package/utils/line.js +81 -131
  131. package/utils/loggerUtil.js +3 -5
  132. package/utils/sessionStorage.js +27 -41
  133. package/utils/time.js +423 -423
  134. package/utils/utils.js +9 -9
  135. package/utils/window.js +10 -21
  136. package/utils-DmwSUrum.js +129 -0
  137. package/ActionForm-uDp92tN2.js +0 -5941
  138. package/AnnotationDetails-DGYfOiWm.js +0 -175
  139. package/AnnotationPreview-bHObsb3P.js +0 -188
  140. package/ClueEnrichContext-CJEJxrgs.js +0 -541
  141. package/FlexOne-BSYAhhtG.js +0 -9
  142. package/_MapCache-WmuDdwuH.js +0 -222
  143. package/_Uint8Array-B7JqpgFX.js +0 -128
  144. package/_baseAssignValue-CGTuELqU.js +0 -25
  145. package/_baseClone-CkNrTyhm.js +0 -283
  146. package/_baseExtremum-kob8QXyt.js +0 -18
  147. package/_baseFlatten-jIR_sN_-.js +0 -92
  148. package/_baseGet-Bx3A4Qfp.js +0 -108
  149. package/_baseIsEqual-C5OTWzTk.js +0 -208
  150. package/_baseIteratee-avi7MX2o.js +0 -126
  151. package/_baseSlice-GAv_YFTT.js +0 -20
  152. package/_baseSum-D0WC1dN0.js +0 -13
  153. package/_baseUniq-BI9GIHMF.js +0 -115
  154. package/_commonjsHelpers-DWwsNxpa.js +0 -8
  155. package/_createAggregator-QD8MzKwe.js +0 -63
  156. package/_getPrototype-CU0j_POw.js +0 -5
  157. package/_getTag-Ckxxfr88.js +0 -126
  158. package/_isIterateeCall-Ds3sw2SF.js +0 -17
  159. package/_setToArray-CaPKQhcz.js +0 -33
  160. package/cloneDeep-DJrLSw8W.js +0 -8
  161. package/countBy-c6S3dvSW.js +0 -14
  162. package/debounce-bV0h5FC5.js +0 -92
  163. package/get-DSsNkRQs.js +0 -8
  164. package/groupBy-xqz-n0Vd.js +0 -14
  165. package/iconify-CXMreGTg.js +0 -1782
  166. package/identity-CPGTqrE4.js +0 -6
  167. package/index-AMfoEg_6.js +0 -696
  168. package/index-B6C2a_Lg.js +0 -1172
  169. package/index-C12gPw2W.js +0 -17698
  170. package/index-DCKkHTvx.js +0 -15750
  171. package/index-JcKyZeoY.js +0 -465
  172. package/isNil-CIubwp4T.js +0 -6
  173. package/isObject-FTY-5JQX.js +0 -7
  174. package/isObjectLike-OAgjjZye.js +0 -48
  175. package/isSymbol-Xd2FsJyp.js +0 -8
  176. package/last-CUCl67Im.js +0 -7
  177. package/maxBy-IKHzFrCS.js +0 -8
  178. package/sortBy-DfSj8IoJ.js +0 -96
  179. package/sumBy-D-hb_NY-.js +0 -8
  180. package/toFinite-Bc55msYj.js +0 -16
  181. package/toNumber-DPxy1FBy.js +0 -39
  182. package/useClueTypeConfig-Z1LFp01b.js +0 -3289
  183. package/utils-HmNPuoDB.js +0 -199
@@ -1,3289 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
- import { i as isNil } from "./isNil-CIubwp4T.js";
5
- import { MY_LOCAL_STORAGE_PREFIX, StorageKey } from "./utils/constants.js";
6
- import { g as getDefaultExportFromCjs } from "./_commonjsHelpers-DWwsNxpa.js";
7
- import { getAxiosCache, setAxiosCache } from "./utils/sessionStorage.js";
8
- import { clueDebugLogger } from "./utils/loggerUtil.js";
9
- import { b as baseUniq, i as isEmpty } from "./_baseUniq-BI9GIHMF.js";
10
- import { useState, useEffect } from "react";
11
- function uniq(array) {
12
- return array && array.length ? baseUniq(array) : [];
13
- }
14
- const get$9 = (actionId, taskId, options = { timeout: null }, config) => {
15
- const searchParams = [];
16
- if (!isNil(options.timeout)) {
17
- searchParams.push(`max_timeout=${options.timeout}`);
18
- }
19
- return hget(
20
- joinUri(uri$c(), `${actionId.replace(".", "/")}/status/${taskId}`),
21
- searchParams.length > 0 ? new URLSearchParams(searchParams.join("&")) : null,
22
- config
23
- );
24
- };
25
- const status$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
26
- __proto__: null,
27
- get: get$9
28
- }, Symbol.toStringTag, { value: "Module" }));
29
- const uri$c = () => {
30
- return joinUri(uri(), "actions");
31
- };
32
- const get$8 = (config) => {
33
- return hget(uri$c(), null, config);
34
- };
35
- const post$3 = (actionId, selectors, params, context, options = { timeout: null }, config) => {
36
- const searchParams = [];
37
- if (!isNil(options.timeout)) {
38
- searchParams.push(`max_timeout=${options.timeout}`);
39
- }
40
- const payload = { ...params };
41
- if (!Array.isArray(selectors)) {
42
- payload.selector = selectors;
43
- payload.selectors = [];
44
- } else if (selectors.length < 2) {
45
- payload.selector = selectors[0];
46
- payload.selectors = [];
47
- } else {
48
- payload.selectors = selectors;
49
- }
50
- payload.context = context ?? null;
51
- return hpost(
52
- joinUri(
53
- joinUri(uri$c(), "execute"),
54
- actionId.replace(".", "/"),
55
- searchParams.length > 0 ? new URLSearchParams(searchParams.join("&")) : null
56
- ),
57
- payload,
58
- config
59
- );
60
- };
61
- const actions = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
62
- __proto__: null,
63
- get: get$8,
64
- post: post$3,
65
- status: status$1,
66
- uri: uri$c
67
- }, Symbol.toStringTag, { value: "Module" }));
68
- const uri$b = (searchParams) => {
69
- return joinUri(uri$a(), "login", searchParams);
70
- };
71
- const post$2 = (body) => {
72
- return hpost(uri$b(), body);
73
- };
74
- const get$7 = (search) => {
75
- const nonce = localStorage.getItem(`${MY_LOCAL_STORAGE_PREFIX}.${StorageKey.LOGIN_NONCE}`);
76
- if (nonce) {
77
- search.set("nonce", JSON.parse(nonce));
78
- localStorage.removeItem(`${MY_LOCAL_STORAGE_PREFIX}.${StorageKey.LOGIN_NONCE}`);
79
- }
80
- return hget(uri$b(), search);
81
- };
82
- const login = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
83
- __proto__: null,
84
- get: get$7,
85
- post: post$2,
86
- uri: uri$b
87
- }, Symbol.toStringTag, { value: "Module" }));
88
- const uri$a = () => {
89
- return joinUri(uri(), "auth");
90
- };
91
- const auth = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
92
- __proto__: null,
93
- login,
94
- uri: uri$a
95
- }, Symbol.toStringTag, { value: "Module" }));
96
- const uri$9 = () => {
97
- return joinUri(uri(), "configs");
98
- };
99
- const get$6 = (config) => {
100
- return hget(uri$9(), null, config);
101
- };
102
- const configs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
103
- __proto__: null,
104
- get: get$6,
105
- uri: uri$9
106
- }, Symbol.toStringTag, { value: "Module" }));
107
- const get$5 = (fetcherId, taskId, options = { timeout: null }, config) => {
108
- const searchParams = [];
109
- if (!isNil(options.timeout)) {
110
- searchParams.push(`max_timeout=${options.timeout}`);
111
- }
112
- return hget(
113
- joinUri(uri$c(), `${fetcherId.replace(".", "/")}/status/${taskId}`),
114
- searchParams.length > 0 ? new URLSearchParams(searchParams.join("&")) : null,
115
- config
116
- );
117
- };
118
- const status = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
119
- __proto__: null,
120
- get: get$5
121
- }, Symbol.toStringTag, { value: "Module" }));
122
- const uri$8 = () => {
123
- return joinUri(uri(), "fetchers");
124
- };
125
- const get$4 = (config) => {
126
- return hget(uri$8(), null, config);
127
- };
128
- const post$1 = (fetcherId, selector, config) => {
129
- return hpost(joinAllUri(uri$8(), fetcherId.replace(".", "/")), selector, config);
130
- };
131
- const fetchers = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
132
- __proto__: null,
133
- get: get$4,
134
- post: post$1,
135
- status,
136
- uri: uri$8
137
- }, Symbol.toStringTag, { value: "Module" }));
138
- const uri$7 = () => {
139
- return joinUri(uri$4(), "enrich");
140
- };
141
- const post = (bulkData, sources = [], options = { timeout: null, includeRaw: false, noCache: false }, config) => {
142
- const searchParams = [];
143
- if ((sources == null ? void 0 : sources.length) > 0) {
144
- searchParams.push(`sources=${sources.join()}`);
145
- }
146
- if (options.classification) {
147
- searchParams.push(`classification=${encodeURIComponent(options.classification)}`);
148
- }
149
- if (!isNil(options.timeout)) {
150
- searchParams.push(`max_timeout=${options.timeout}`);
151
- }
152
- if (options.includeRaw) {
153
- searchParams.push("include_raw=true");
154
- }
155
- if (options.noCache) {
156
- searchParams.push("no_cache=true");
157
- }
158
- return hpost(
159
- joinUri(uri$7(), "", searchParams.length > 0 ? new URLSearchParams(searchParams.join("&")) : null),
160
- bulkData,
161
- config
162
- );
163
- };
164
- const enrich = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
165
- __proto__: null,
166
- post,
167
- uri: uri$7
168
- }, Symbol.toStringTag, { value: "Module" }));
169
- const uri$6 = () => {
170
- return joinUri(uri$4(), "types");
171
- };
172
- const get$3 = (config) => {
173
- return hget(uri$6(), null, config);
174
- };
175
- const types = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
176
- __proto__: null,
177
- get: get$3,
178
- uri: uri$6
179
- }, Symbol.toStringTag, { value: "Module" }));
180
- const uri$5 = () => {
181
- return joinUri(uri$4(), "types_detection");
182
- };
183
- const get$2 = (config) => {
184
- return hget(uri$5(), null, config);
185
- };
186
- const types_detection = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
187
- __proto__: null,
188
- get: get$2,
189
- uri: uri$5
190
- }, Symbol.toStringTag, { value: "Module" }));
191
- const uri$4 = () => {
192
- return joinUri(uri(), "lookup");
193
- };
194
- const lookup = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
195
- __proto__: null,
196
- enrich,
197
- types,
198
- types_detection,
199
- uri: uri$4
200
- }, Symbol.toStringTag, { value: "Module" }));
201
- const uri$3 = (filter2) => {
202
- return joinUri(uri$1(), filter2 ? "/docs?filter=" + filter2 : "/docs");
203
- };
204
- const get$1 = (filter2, config) => {
205
- return hget(uri$3(filter2), null, config);
206
- };
207
- const all_documentation = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
208
- __proto__: null,
209
- get: get$1,
210
- uri: uri$3
211
- }, Symbol.toStringTag, { value: "Module" }));
212
- const uri$2 = (file) => {
213
- return joinAllUri(uri$1(), "docs", file);
214
- };
215
- const get = (file, config) => {
216
- return hget(uri$2(file), null, config);
217
- };
218
- const documentation = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
219
- __proto__: null,
220
- get,
221
- uri: uri$2
222
- }, Symbol.toStringTag, { value: "Module" }));
223
- const uri$1 = () => {
224
- return joinUri(uri(), "static");
225
- };
226
- const _static = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
227
- __proto__: null,
228
- all_documentation,
229
- documentation,
230
- uri: uri$1
231
- }, Symbol.toStringTag, { value: "Module" }));
232
- function bind(fn, thisArg) {
233
- return function wrap() {
234
- return fn.apply(thisArg, arguments);
235
- };
236
- }
237
- const { toString } = Object.prototype;
238
- const { getPrototypeOf } = Object;
239
- const { iterator, toStringTag } = Symbol;
240
- const kindOf = /* @__PURE__ */ ((cache) => (thing) => {
241
- const str = toString.call(thing);
242
- return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase());
243
- })(/* @__PURE__ */ Object.create(null));
244
- const kindOfTest = (type) => {
245
- type = type.toLowerCase();
246
- return (thing) => kindOf(thing) === type;
247
- };
248
- const typeOfTest = (type) => (thing) => typeof thing === type;
249
- const { isArray } = Array;
250
- const isUndefined = typeOfTest("undefined");
251
- function isBuffer(val) {
252
- return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor) && isFunction$1(val.constructor.isBuffer) && val.constructor.isBuffer(val);
253
- }
254
- const isArrayBuffer = kindOfTest("ArrayBuffer");
255
- function isArrayBufferView(val) {
256
- let result;
257
- if (typeof ArrayBuffer !== "undefined" && ArrayBuffer.isView) {
258
- result = ArrayBuffer.isView(val);
259
- } else {
260
- result = val && val.buffer && isArrayBuffer(val.buffer);
261
- }
262
- return result;
263
- }
264
- const isString = typeOfTest("string");
265
- const isFunction$1 = typeOfTest("function");
266
- const isNumber = typeOfTest("number");
267
- const isObject = (thing) => thing !== null && typeof thing === "object";
268
- const isBoolean = (thing) => thing === true || thing === false;
269
- const isPlainObject = (val) => {
270
- if (kindOf(val) !== "object") {
271
- return false;
272
- }
273
- const prototype2 = getPrototypeOf(val);
274
- return (prototype2 === null || prototype2 === Object.prototype || Object.getPrototypeOf(prototype2) === null) && !(toStringTag in val) && !(iterator in val);
275
- };
276
- const isEmptyObject = (val) => {
277
- if (!isObject(val) || isBuffer(val)) {
278
- return false;
279
- }
280
- try {
281
- return Object.keys(val).length === 0 && Object.getPrototypeOf(val) === Object.prototype;
282
- } catch (e) {
283
- return false;
284
- }
285
- };
286
- const isDate = kindOfTest("Date");
287
- const isFile = kindOfTest("File");
288
- const isBlob = kindOfTest("Blob");
289
- const isFileList = kindOfTest("FileList");
290
- const isStream = (val) => isObject(val) && isFunction$1(val.pipe);
291
- const isFormData = (thing) => {
292
- let kind;
293
- return thing && (typeof FormData === "function" && thing instanceof FormData || isFunction$1(thing.append) && ((kind = kindOf(thing)) === "formdata" || // detect form-data instance
294
- kind === "object" && isFunction$1(thing.toString) && thing.toString() === "[object FormData]"));
295
- };
296
- const isURLSearchParams = kindOfTest("URLSearchParams");
297
- const [isReadableStream, isRequest, isResponse, isHeaders] = [
298
- "ReadableStream",
299
- "Request",
300
- "Response",
301
- "Headers"
302
- ].map(kindOfTest);
303
- const trim = (str) => str.trim ? str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "");
304
- function forEach(obj, fn, { allOwnKeys = false } = {}) {
305
- if (obj === null || typeof obj === "undefined") {
306
- return;
307
- }
308
- let i;
309
- let l;
310
- if (typeof obj !== "object") {
311
- obj = [obj];
312
- }
313
- if (isArray(obj)) {
314
- for (i = 0, l = obj.length; i < l; i++) {
315
- fn.call(null, obj[i], i, obj);
316
- }
317
- } else {
318
- if (isBuffer(obj)) {
319
- return;
320
- }
321
- const keys = allOwnKeys ? Object.getOwnPropertyNames(obj) : Object.keys(obj);
322
- const len = keys.length;
323
- let key;
324
- for (i = 0; i < len; i++) {
325
- key = keys[i];
326
- fn.call(null, obj[key], key, obj);
327
- }
328
- }
329
- }
330
- function findKey(obj, key) {
331
- if (isBuffer(obj)) {
332
- return null;
333
- }
334
- key = key.toLowerCase();
335
- const keys = Object.keys(obj);
336
- let i = keys.length;
337
- let _key;
338
- while (i-- > 0) {
339
- _key = keys[i];
340
- if (key === _key.toLowerCase()) {
341
- return _key;
342
- }
343
- }
344
- return null;
345
- }
346
- const _global = (() => {
347
- if (typeof globalThis !== "undefined") return globalThis;
348
- return typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : global;
349
- })();
350
- const isContextDefined = (context) => !isUndefined(context) && context !== _global;
351
- function merge() {
352
- const { caseless, skipUndefined } = isContextDefined(this) && this || {};
353
- const result = {};
354
- const assignValue = (val, key) => {
355
- if (key === "__proto__" || key === "constructor" || key === "prototype") {
356
- return;
357
- }
358
- const targetKey = caseless && findKey(result, key) || key;
359
- if (isPlainObject(result[targetKey]) && isPlainObject(val)) {
360
- result[targetKey] = merge(result[targetKey], val);
361
- } else if (isPlainObject(val)) {
362
- result[targetKey] = merge({}, val);
363
- } else if (isArray(val)) {
364
- result[targetKey] = val.slice();
365
- } else if (!skipUndefined || !isUndefined(val)) {
366
- result[targetKey] = val;
367
- }
368
- };
369
- for (let i = 0, l = arguments.length; i < l; i++) {
370
- arguments[i] && forEach(arguments[i], assignValue);
371
- }
372
- return result;
373
- }
374
- const extend = (a, b, thisArg, { allOwnKeys } = {}) => {
375
- forEach(
376
- b,
377
- (val, key) => {
378
- if (thisArg && isFunction$1(val)) {
379
- Object.defineProperty(a, key, {
380
- value: bind(val, thisArg),
381
- writable: true,
382
- enumerable: true,
383
- configurable: true
384
- });
385
- } else {
386
- Object.defineProperty(a, key, {
387
- value: val,
388
- writable: true,
389
- enumerable: true,
390
- configurable: true
391
- });
392
- }
393
- },
394
- { allOwnKeys }
395
- );
396
- return a;
397
- };
398
- const stripBOM = (content) => {
399
- if (content.charCodeAt(0) === 65279) {
400
- content = content.slice(1);
401
- }
402
- return content;
403
- };
404
- const inherits = (constructor, superConstructor, props, descriptors) => {
405
- constructor.prototype = Object.create(
406
- superConstructor.prototype,
407
- descriptors
408
- );
409
- Object.defineProperty(constructor.prototype, "constructor", {
410
- value: constructor,
411
- writable: true,
412
- enumerable: false,
413
- configurable: true
414
- });
415
- Object.defineProperty(constructor, "super", {
416
- value: superConstructor.prototype
417
- });
418
- props && Object.assign(constructor.prototype, props);
419
- };
420
- const toFlatObject = (sourceObj, destObj, filter2, propFilter) => {
421
- let props;
422
- let i;
423
- let prop;
424
- const merged = {};
425
- destObj = destObj || {};
426
- if (sourceObj == null) return destObj;
427
- do {
428
- props = Object.getOwnPropertyNames(sourceObj);
429
- i = props.length;
430
- while (i-- > 0) {
431
- prop = props[i];
432
- if ((!propFilter || propFilter(prop, sourceObj, destObj)) && !merged[prop]) {
433
- destObj[prop] = sourceObj[prop];
434
- merged[prop] = true;
435
- }
436
- }
437
- sourceObj = filter2 !== false && getPrototypeOf(sourceObj);
438
- } while (sourceObj && (!filter2 || filter2(sourceObj, destObj)) && sourceObj !== Object.prototype);
439
- return destObj;
440
- };
441
- const endsWith = (str, searchString, position) => {
442
- str = String(str);
443
- if (position === void 0 || position > str.length) {
444
- position = str.length;
445
- }
446
- position -= searchString.length;
447
- const lastIndex = str.indexOf(searchString, position);
448
- return lastIndex !== -1 && lastIndex === position;
449
- };
450
- const toArray = (thing) => {
451
- if (!thing) return null;
452
- if (isArray(thing)) return thing;
453
- let i = thing.length;
454
- if (!isNumber(i)) return null;
455
- const arr = new Array(i);
456
- while (i-- > 0) {
457
- arr[i] = thing[i];
458
- }
459
- return arr;
460
- };
461
- const isTypedArray = /* @__PURE__ */ ((TypedArray) => {
462
- return (thing) => {
463
- return TypedArray && thing instanceof TypedArray;
464
- };
465
- })(typeof Uint8Array !== "undefined" && getPrototypeOf(Uint8Array));
466
- const forEachEntry = (obj, fn) => {
467
- const generator = obj && obj[iterator];
468
- const _iterator = generator.call(obj);
469
- let result;
470
- while ((result = _iterator.next()) && !result.done) {
471
- const pair = result.value;
472
- fn.call(obj, pair[0], pair[1]);
473
- }
474
- };
475
- const matchAll = (regExp, str) => {
476
- let matches;
477
- const arr = [];
478
- while ((matches = regExp.exec(str)) !== null) {
479
- arr.push(matches);
480
- }
481
- return arr;
482
- };
483
- const isHTMLForm = kindOfTest("HTMLFormElement");
484
- const toCamelCase = (str) => {
485
- return str.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g, function replacer(m, p1, p2) {
486
- return p1.toUpperCase() + p2;
487
- });
488
- };
489
- const hasOwnProperty = (({ hasOwnProperty: hasOwnProperty2 }) => (obj, prop) => hasOwnProperty2.call(obj, prop))(Object.prototype);
490
- const isRegExp = kindOfTest("RegExp");
491
- const reduceDescriptors = (obj, reducer) => {
492
- const descriptors = Object.getOwnPropertyDescriptors(obj);
493
- const reducedDescriptors = {};
494
- forEach(descriptors, (descriptor, name) => {
495
- let ret;
496
- if ((ret = reducer(descriptor, name, obj)) !== false) {
497
- reducedDescriptors[name] = ret || descriptor;
498
- }
499
- });
500
- Object.defineProperties(obj, reducedDescriptors);
501
- };
502
- const freezeMethods = (obj) => {
503
- reduceDescriptors(obj, (descriptor, name) => {
504
- if (isFunction$1(obj) && ["arguments", "caller", "callee"].indexOf(name) !== -1) {
505
- return false;
506
- }
507
- const value = obj[name];
508
- if (!isFunction$1(value)) return;
509
- descriptor.enumerable = false;
510
- if ("writable" in descriptor) {
511
- descriptor.writable = false;
512
- return;
513
- }
514
- if (!descriptor.set) {
515
- descriptor.set = () => {
516
- throw Error("Can not rewrite read-only method '" + name + "'");
517
- };
518
- }
519
- });
520
- };
521
- const toObjectSet = (arrayOrString, delimiter) => {
522
- const obj = {};
523
- const define = (arr) => {
524
- arr.forEach((value) => {
525
- obj[value] = true;
526
- });
527
- };
528
- isArray(arrayOrString) ? define(arrayOrString) : define(String(arrayOrString).split(delimiter));
529
- return obj;
530
- };
531
- const noop = () => {
532
- };
533
- const toFiniteNumber = (value, defaultValue) => {
534
- return value != null && Number.isFinite(value = +value) ? value : defaultValue;
535
- };
536
- function isSpecCompliantForm(thing) {
537
- return !!(thing && isFunction$1(thing.append) && thing[toStringTag] === "FormData" && thing[iterator]);
538
- }
539
- const toJSONObject = (obj) => {
540
- const stack = new Array(10);
541
- const visit = (source, i) => {
542
- if (isObject(source)) {
543
- if (stack.indexOf(source) >= 0) {
544
- return;
545
- }
546
- if (isBuffer(source)) {
547
- return source;
548
- }
549
- if (!("toJSON" in source)) {
550
- stack[i] = source;
551
- const target = isArray(source) ? [] : {};
552
- forEach(source, (value, key) => {
553
- const reducedValue = visit(value, i + 1);
554
- !isUndefined(reducedValue) && (target[key] = reducedValue);
555
- });
556
- stack[i] = void 0;
557
- return target;
558
- }
559
- }
560
- return source;
561
- };
562
- return visit(obj, 0);
563
- };
564
- const isAsyncFn = kindOfTest("AsyncFunction");
565
- const isThenable = (thing) => thing && (isObject(thing) || isFunction$1(thing)) && isFunction$1(thing.then) && isFunction$1(thing.catch);
566
- const _setImmediate = ((setImmediateSupported, postMessageSupported) => {
567
- if (setImmediateSupported) {
568
- return setImmediate;
569
- }
570
- return postMessageSupported ? ((token, callbacks) => {
571
- _global.addEventListener(
572
- "message",
573
- ({ source, data }) => {
574
- if (source === _global && data === token) {
575
- callbacks.length && callbacks.shift()();
576
- }
577
- },
578
- false
579
- );
580
- return (cb) => {
581
- callbacks.push(cb);
582
- _global.postMessage(token, "*");
583
- };
584
- })(`axios@${Math.random()}`, []) : (cb) => setTimeout(cb);
585
- })(typeof setImmediate === "function", isFunction$1(_global.postMessage));
586
- const asap = typeof queueMicrotask !== "undefined" ? queueMicrotask.bind(_global) : typeof process !== "undefined" && process.nextTick || _setImmediate;
587
- const isIterable = (thing) => thing != null && isFunction$1(thing[iterator]);
588
- const utils$1 = {
589
- isArray,
590
- isArrayBuffer,
591
- isBuffer,
592
- isFormData,
593
- isArrayBufferView,
594
- isString,
595
- isNumber,
596
- isBoolean,
597
- isObject,
598
- isPlainObject,
599
- isEmptyObject,
600
- isReadableStream,
601
- isRequest,
602
- isResponse,
603
- isHeaders,
604
- isUndefined,
605
- isDate,
606
- isFile,
607
- isBlob,
608
- isRegExp,
609
- isFunction: isFunction$1,
610
- isStream,
611
- isURLSearchParams,
612
- isTypedArray,
613
- isFileList,
614
- forEach,
615
- merge,
616
- extend,
617
- trim,
618
- stripBOM,
619
- inherits,
620
- toFlatObject,
621
- kindOf,
622
- kindOfTest,
623
- endsWith,
624
- toArray,
625
- forEachEntry,
626
- matchAll,
627
- isHTMLForm,
628
- hasOwnProperty,
629
- hasOwnProp: hasOwnProperty,
630
- // an alias to avoid ESLint no-prototype-builtins detection
631
- reduceDescriptors,
632
- freezeMethods,
633
- toObjectSet,
634
- toCamelCase,
635
- noop,
636
- toFiniteNumber,
637
- findKey,
638
- global: _global,
639
- isContextDefined,
640
- isSpecCompliantForm,
641
- toJSONObject,
642
- isAsyncFn,
643
- isThenable,
644
- setImmediate: _setImmediate,
645
- asap,
646
- isIterable
647
- };
648
- let AxiosError$1 = class AxiosError extends Error {
649
- static from(error, code, config, request, response, customProps) {
650
- const axiosError = new AxiosError(error.message, code || error.code, config, request, response);
651
- axiosError.cause = error;
652
- axiosError.name = error.name;
653
- customProps && Object.assign(axiosError, customProps);
654
- return axiosError;
655
- }
656
- /**
657
- * Create an Error with the specified message, config, error code, request and response.
658
- *
659
- * @param {string} message The error message.
660
- * @param {string} [code] The error code (for example, 'ECONNABORTED').
661
- * @param {Object} [config] The config.
662
- * @param {Object} [request] The request.
663
- * @param {Object} [response] The response.
664
- *
665
- * @returns {Error} The created error.
666
- */
667
- constructor(message, code, config, request, response) {
668
- super(message);
669
- this.name = "AxiosError";
670
- this.isAxiosError = true;
671
- code && (this.code = code);
672
- config && (this.config = config);
673
- request && (this.request = request);
674
- if (response) {
675
- this.response = response;
676
- this.status = response.status;
677
- }
678
- }
679
- toJSON() {
680
- return {
681
- // Standard
682
- message: this.message,
683
- name: this.name,
684
- // Microsoft
685
- description: this.description,
686
- number: this.number,
687
- // Mozilla
688
- fileName: this.fileName,
689
- lineNumber: this.lineNumber,
690
- columnNumber: this.columnNumber,
691
- stack: this.stack,
692
- // Axios
693
- config: utils$1.toJSONObject(this.config),
694
- code: this.code,
695
- status: this.status
696
- };
697
- }
698
- };
699
- AxiosError$1.ERR_BAD_OPTION_VALUE = "ERR_BAD_OPTION_VALUE";
700
- AxiosError$1.ERR_BAD_OPTION = "ERR_BAD_OPTION";
701
- AxiosError$1.ECONNABORTED = "ECONNABORTED";
702
- AxiosError$1.ETIMEDOUT = "ETIMEDOUT";
703
- AxiosError$1.ERR_NETWORK = "ERR_NETWORK";
704
- AxiosError$1.ERR_FR_TOO_MANY_REDIRECTS = "ERR_FR_TOO_MANY_REDIRECTS";
705
- AxiosError$1.ERR_DEPRECATED = "ERR_DEPRECATED";
706
- AxiosError$1.ERR_BAD_RESPONSE = "ERR_BAD_RESPONSE";
707
- AxiosError$1.ERR_BAD_REQUEST = "ERR_BAD_REQUEST";
708
- AxiosError$1.ERR_CANCELED = "ERR_CANCELED";
709
- AxiosError$1.ERR_NOT_SUPPORT = "ERR_NOT_SUPPORT";
710
- AxiosError$1.ERR_INVALID_URL = "ERR_INVALID_URL";
711
- const httpAdapter = null;
712
- function isVisitable(thing) {
713
- return utils$1.isPlainObject(thing) || utils$1.isArray(thing);
714
- }
715
- function removeBrackets(key) {
716
- return utils$1.endsWith(key, "[]") ? key.slice(0, -2) : key;
717
- }
718
- function renderKey(path, key, dots) {
719
- if (!path) return key;
720
- return path.concat(key).map(function each(token, i) {
721
- token = removeBrackets(token);
722
- return !dots && i ? "[" + token + "]" : token;
723
- }).join(dots ? "." : "");
724
- }
725
- function isFlatArray(arr) {
726
- return utils$1.isArray(arr) && !arr.some(isVisitable);
727
- }
728
- const predicates = utils$1.toFlatObject(utils$1, {}, null, function filter(prop) {
729
- return /^is[A-Z]/.test(prop);
730
- });
731
- function toFormData$1(obj, formData, options) {
732
- if (!utils$1.isObject(obj)) {
733
- throw new TypeError("target must be an object");
734
- }
735
- formData = formData || new FormData();
736
- options = utils$1.toFlatObject(options, {
737
- metaTokens: true,
738
- dots: false,
739
- indexes: false
740
- }, false, function defined(option, source) {
741
- return !utils$1.isUndefined(source[option]);
742
- });
743
- const metaTokens = options.metaTokens;
744
- const visitor = options.visitor || defaultVisitor;
745
- const dots = options.dots;
746
- const indexes = options.indexes;
747
- const _Blob = options.Blob || typeof Blob !== "undefined" && Blob;
748
- const useBlob = _Blob && utils$1.isSpecCompliantForm(formData);
749
- if (!utils$1.isFunction(visitor)) {
750
- throw new TypeError("visitor must be a function");
751
- }
752
- function convertValue(value) {
753
- if (value === null) return "";
754
- if (utils$1.isDate(value)) {
755
- return value.toISOString();
756
- }
757
- if (utils$1.isBoolean(value)) {
758
- return value.toString();
759
- }
760
- if (!useBlob && utils$1.isBlob(value)) {
761
- throw new AxiosError$1("Blob is not supported. Use a Buffer instead.");
762
- }
763
- if (utils$1.isArrayBuffer(value) || utils$1.isTypedArray(value)) {
764
- return useBlob && typeof Blob === "function" ? new Blob([value]) : Buffer.from(value);
765
- }
766
- return value;
767
- }
768
- function defaultVisitor(value, key, path) {
769
- let arr = value;
770
- if (value && !path && typeof value === "object") {
771
- if (utils$1.endsWith(key, "{}")) {
772
- key = metaTokens ? key : key.slice(0, -2);
773
- value = JSON.stringify(value);
774
- } else if (utils$1.isArray(value) && isFlatArray(value) || (utils$1.isFileList(value) || utils$1.endsWith(key, "[]")) && (arr = utils$1.toArray(value))) {
775
- key = removeBrackets(key);
776
- arr.forEach(function each(el, index) {
777
- !(utils$1.isUndefined(el) || el === null) && formData.append(
778
- // eslint-disable-next-line no-nested-ternary
779
- indexes === true ? renderKey([key], index, dots) : indexes === null ? key : key + "[]",
780
- convertValue(el)
781
- );
782
- });
783
- return false;
784
- }
785
- }
786
- if (isVisitable(value)) {
787
- return true;
788
- }
789
- formData.append(renderKey(path, key, dots), convertValue(value));
790
- return false;
791
- }
792
- const stack = [];
793
- const exposedHelpers = Object.assign(predicates, {
794
- defaultVisitor,
795
- convertValue,
796
- isVisitable
797
- });
798
- function build(value, path) {
799
- if (utils$1.isUndefined(value)) return;
800
- if (stack.indexOf(value) !== -1) {
801
- throw Error("Circular reference detected in " + path.join("."));
802
- }
803
- stack.push(value);
804
- utils$1.forEach(value, function each(el, key) {
805
- const result = !(utils$1.isUndefined(el) || el === null) && visitor.call(
806
- formData,
807
- el,
808
- utils$1.isString(key) ? key.trim() : key,
809
- path,
810
- exposedHelpers
811
- );
812
- if (result === true) {
813
- build(el, path ? path.concat(key) : [key]);
814
- }
815
- });
816
- stack.pop();
817
- }
818
- if (!utils$1.isObject(obj)) {
819
- throw new TypeError("data must be an object");
820
- }
821
- build(obj);
822
- return formData;
823
- }
824
- function encode$1(str) {
825
- const charMap = {
826
- "!": "%21",
827
- "'": "%27",
828
- "(": "%28",
829
- ")": "%29",
830
- "~": "%7E",
831
- "%20": "+",
832
- "%00": "\0"
833
- };
834
- return encodeURIComponent(str).replace(/[!'()~]|%20|%00/g, function replacer(match) {
835
- return charMap[match];
836
- });
837
- }
838
- function AxiosURLSearchParams(params, options) {
839
- this._pairs = [];
840
- params && toFormData$1(params, this, options);
841
- }
842
- const prototype = AxiosURLSearchParams.prototype;
843
- prototype.append = function append(name, value) {
844
- this._pairs.push([name, value]);
845
- };
846
- prototype.toString = function toString2(encoder) {
847
- const _encode = encoder ? function(value) {
848
- return encoder.call(this, value, encode$1);
849
- } : encode$1;
850
- return this._pairs.map(function each(pair) {
851
- return _encode(pair[0]) + "=" + _encode(pair[1]);
852
- }, "").join("&");
853
- };
854
- function encode(val) {
855
- return encodeURIComponent(val).replace(/%3A/gi, ":").replace(/%24/g, "$").replace(/%2C/gi, ",").replace(/%20/g, "+");
856
- }
857
- function buildURL(url, params, options) {
858
- if (!params) {
859
- return url;
860
- }
861
- const _encode = options && options.encode || encode;
862
- const _options = utils$1.isFunction(options) ? {
863
- serialize: options
864
- } : options;
865
- const serializeFn = _options && _options.serialize;
866
- let serializedParams;
867
- if (serializeFn) {
868
- serializedParams = serializeFn(params, _options);
869
- } else {
870
- serializedParams = utils$1.isURLSearchParams(params) ? params.toString() : new AxiosURLSearchParams(params, _options).toString(_encode);
871
- }
872
- if (serializedParams) {
873
- const hashmarkIndex = url.indexOf("#");
874
- if (hashmarkIndex !== -1) {
875
- url = url.slice(0, hashmarkIndex);
876
- }
877
- url += (url.indexOf("?") === -1 ? "?" : "&") + serializedParams;
878
- }
879
- return url;
880
- }
881
- class InterceptorManager {
882
- constructor() {
883
- this.handlers = [];
884
- }
885
- /**
886
- * Add a new interceptor to the stack
887
- *
888
- * @param {Function} fulfilled The function to handle `then` for a `Promise`
889
- * @param {Function} rejected The function to handle `reject` for a `Promise`
890
- * @param {Object} options The options for the interceptor, synchronous and runWhen
891
- *
892
- * @return {Number} An ID used to remove interceptor later
893
- */
894
- use(fulfilled, rejected, options) {
895
- this.handlers.push({
896
- fulfilled,
897
- rejected,
898
- synchronous: options ? options.synchronous : false,
899
- runWhen: options ? options.runWhen : null
900
- });
901
- return this.handlers.length - 1;
902
- }
903
- /**
904
- * Remove an interceptor from the stack
905
- *
906
- * @param {Number} id The ID that was returned by `use`
907
- *
908
- * @returns {void}
909
- */
910
- eject(id) {
911
- if (this.handlers[id]) {
912
- this.handlers[id] = null;
913
- }
914
- }
915
- /**
916
- * Clear all interceptors from the stack
917
- *
918
- * @returns {void}
919
- */
920
- clear() {
921
- if (this.handlers) {
922
- this.handlers = [];
923
- }
924
- }
925
- /**
926
- * Iterate over all the registered interceptors
927
- *
928
- * This method is particularly useful for skipping over any
929
- * interceptors that may have become `null` calling `eject`.
930
- *
931
- * @param {Function} fn The function to call for each interceptor
932
- *
933
- * @returns {void}
934
- */
935
- forEach(fn) {
936
- utils$1.forEach(this.handlers, function forEachHandler(h) {
937
- if (h !== null) {
938
- fn(h);
939
- }
940
- });
941
- }
942
- }
943
- const transitionalDefaults = {
944
- silentJSONParsing: true,
945
- forcedJSONParsing: true,
946
- clarifyTimeoutError: false,
947
- legacyInterceptorReqResOrdering: true
948
- };
949
- const URLSearchParams$1 = typeof URLSearchParams !== "undefined" ? URLSearchParams : AxiosURLSearchParams;
950
- const FormData$1 = typeof FormData !== "undefined" ? FormData : null;
951
- const Blob$1 = typeof Blob !== "undefined" ? Blob : null;
952
- const platform$1 = {
953
- isBrowser: true,
954
- classes: {
955
- URLSearchParams: URLSearchParams$1,
956
- FormData: FormData$1,
957
- Blob: Blob$1
958
- },
959
- protocols: ["http", "https", "file", "blob", "url", "data"]
960
- };
961
- const hasBrowserEnv = typeof window !== "undefined" && typeof document !== "undefined";
962
- const _navigator = typeof navigator === "object" && navigator || void 0;
963
- const hasStandardBrowserEnv = hasBrowserEnv && (!_navigator || ["ReactNative", "NativeScript", "NS"].indexOf(_navigator.product) < 0);
964
- const hasStandardBrowserWebWorkerEnv = (() => {
965
- return typeof WorkerGlobalScope !== "undefined" && // eslint-disable-next-line no-undef
966
- self instanceof WorkerGlobalScope && typeof self.importScripts === "function";
967
- })();
968
- const origin = hasBrowserEnv && window.location.href || "http://localhost";
969
- const utils = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
970
- __proto__: null,
971
- hasBrowserEnv,
972
- hasStandardBrowserEnv,
973
- hasStandardBrowserWebWorkerEnv,
974
- navigator: _navigator,
975
- origin
976
- }, Symbol.toStringTag, { value: "Module" }));
977
- const platform = {
978
- ...utils,
979
- ...platform$1
980
- };
981
- function toURLEncodedForm(data, options) {
982
- return toFormData$1(data, new platform.classes.URLSearchParams(), {
983
- visitor: function(value, key, path, helpers) {
984
- if (platform.isNode && utils$1.isBuffer(value)) {
985
- this.append(key, value.toString("base64"));
986
- return false;
987
- }
988
- return helpers.defaultVisitor.apply(this, arguments);
989
- },
990
- ...options
991
- });
992
- }
993
- function parsePropPath(name) {
994
- return utils$1.matchAll(/\w+|\[(\w*)]/g, name).map((match) => {
995
- return match[0] === "[]" ? "" : match[1] || match[0];
996
- });
997
- }
998
- function arrayToObject(arr) {
999
- const obj = {};
1000
- const keys = Object.keys(arr);
1001
- let i;
1002
- const len = keys.length;
1003
- let key;
1004
- for (i = 0; i < len; i++) {
1005
- key = keys[i];
1006
- obj[key] = arr[key];
1007
- }
1008
- return obj;
1009
- }
1010
- function formDataToJSON(formData) {
1011
- function buildPath(path, value, target, index) {
1012
- let name = path[index++];
1013
- if (name === "__proto__") return true;
1014
- const isNumericKey = Number.isFinite(+name);
1015
- const isLast = index >= path.length;
1016
- name = !name && utils$1.isArray(target) ? target.length : name;
1017
- if (isLast) {
1018
- if (utils$1.hasOwnProp(target, name)) {
1019
- target[name] = [target[name], value];
1020
- } else {
1021
- target[name] = value;
1022
- }
1023
- return !isNumericKey;
1024
- }
1025
- if (!target[name] || !utils$1.isObject(target[name])) {
1026
- target[name] = [];
1027
- }
1028
- const result = buildPath(path, value, target[name], index);
1029
- if (result && utils$1.isArray(target[name])) {
1030
- target[name] = arrayToObject(target[name]);
1031
- }
1032
- return !isNumericKey;
1033
- }
1034
- if (utils$1.isFormData(formData) && utils$1.isFunction(formData.entries)) {
1035
- const obj = {};
1036
- utils$1.forEachEntry(formData, (name, value) => {
1037
- buildPath(parsePropPath(name), value, obj, 0);
1038
- });
1039
- return obj;
1040
- }
1041
- return null;
1042
- }
1043
- function stringifySafely(rawValue, parser, encoder) {
1044
- if (utils$1.isString(rawValue)) {
1045
- try {
1046
- (parser || JSON.parse)(rawValue);
1047
- return utils$1.trim(rawValue);
1048
- } catch (e) {
1049
- if (e.name !== "SyntaxError") {
1050
- throw e;
1051
- }
1052
- }
1053
- }
1054
- return (encoder || JSON.stringify)(rawValue);
1055
- }
1056
- const defaults = {
1057
- transitional: transitionalDefaults,
1058
- adapter: ["xhr", "http", "fetch"],
1059
- transformRequest: [function transformRequest(data, headers) {
1060
- const contentType = headers.getContentType() || "";
1061
- const hasJSONContentType = contentType.indexOf("application/json") > -1;
1062
- const isObjectPayload = utils$1.isObject(data);
1063
- if (isObjectPayload && utils$1.isHTMLForm(data)) {
1064
- data = new FormData(data);
1065
- }
1066
- const isFormData2 = utils$1.isFormData(data);
1067
- if (isFormData2) {
1068
- return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
1069
- }
1070
- 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)) {
1071
- return data;
1072
- }
1073
- if (utils$1.isArrayBufferView(data)) {
1074
- return data.buffer;
1075
- }
1076
- if (utils$1.isURLSearchParams(data)) {
1077
- headers.setContentType("application/x-www-form-urlencoded;charset=utf-8", false);
1078
- return data.toString();
1079
- }
1080
- let isFileList2;
1081
- if (isObjectPayload) {
1082
- if (contentType.indexOf("application/x-www-form-urlencoded") > -1) {
1083
- return toURLEncodedForm(data, this.formSerializer).toString();
1084
- }
1085
- if ((isFileList2 = utils$1.isFileList(data)) || contentType.indexOf("multipart/form-data") > -1) {
1086
- const _FormData = this.env && this.env.FormData;
1087
- return toFormData$1(
1088
- isFileList2 ? { "files[]": data } : data,
1089
- _FormData && new _FormData(),
1090
- this.formSerializer
1091
- );
1092
- }
1093
- }
1094
- if (isObjectPayload || hasJSONContentType) {
1095
- headers.setContentType("application/json", false);
1096
- return stringifySafely(data);
1097
- }
1098
- return data;
1099
- }],
1100
- transformResponse: [function transformResponse(data) {
1101
- const transitional2 = this.transitional || defaults.transitional;
1102
- const forcedJSONParsing = transitional2 && transitional2.forcedJSONParsing;
1103
- const JSONRequested = this.responseType === "json";
1104
- if (utils$1.isResponse(data) || utils$1.isReadableStream(data)) {
1105
- return data;
1106
- }
1107
- if (data && utils$1.isString(data) && (forcedJSONParsing && !this.responseType || JSONRequested)) {
1108
- const silentJSONParsing = transitional2 && transitional2.silentJSONParsing;
1109
- const strictJSONParsing = !silentJSONParsing && JSONRequested;
1110
- try {
1111
- return JSON.parse(data, this.parseReviver);
1112
- } catch (e) {
1113
- if (strictJSONParsing) {
1114
- if (e.name === "SyntaxError") {
1115
- throw AxiosError$1.from(e, AxiosError$1.ERR_BAD_RESPONSE, this, null, this.response);
1116
- }
1117
- throw e;
1118
- }
1119
- }
1120
- }
1121
- return data;
1122
- }],
1123
- /**
1124
- * A timeout in milliseconds to abort a request. If set to 0 (default) a
1125
- * timeout is not created.
1126
- */
1127
- timeout: 0,
1128
- xsrfCookieName: "XSRF-TOKEN",
1129
- xsrfHeaderName: "X-XSRF-TOKEN",
1130
- maxContentLength: -1,
1131
- maxBodyLength: -1,
1132
- env: {
1133
- FormData: platform.classes.FormData,
1134
- Blob: platform.classes.Blob
1135
- },
1136
- validateStatus: function validateStatus(status2) {
1137
- return status2 >= 200 && status2 < 300;
1138
- },
1139
- headers: {
1140
- common: {
1141
- "Accept": "application/json, text/plain, */*",
1142
- "Content-Type": void 0
1143
- }
1144
- }
1145
- };
1146
- utils$1.forEach(["delete", "get", "head", "post", "put", "patch"], (method) => {
1147
- defaults.headers[method] = {};
1148
- });
1149
- const ignoreDuplicateOf = utils$1.toObjectSet([
1150
- "age",
1151
- "authorization",
1152
- "content-length",
1153
- "content-type",
1154
- "etag",
1155
- "expires",
1156
- "from",
1157
- "host",
1158
- "if-modified-since",
1159
- "if-unmodified-since",
1160
- "last-modified",
1161
- "location",
1162
- "max-forwards",
1163
- "proxy-authorization",
1164
- "referer",
1165
- "retry-after",
1166
- "user-agent"
1167
- ]);
1168
- const parseHeaders = (rawHeaders) => {
1169
- const parsed = {};
1170
- let key;
1171
- let val;
1172
- let i;
1173
- rawHeaders && rawHeaders.split("\n").forEach(function parser(line) {
1174
- i = line.indexOf(":");
1175
- key = line.substring(0, i).trim().toLowerCase();
1176
- val = line.substring(i + 1).trim();
1177
- if (!key || parsed[key] && ignoreDuplicateOf[key]) {
1178
- return;
1179
- }
1180
- if (key === "set-cookie") {
1181
- if (parsed[key]) {
1182
- parsed[key].push(val);
1183
- } else {
1184
- parsed[key] = [val];
1185
- }
1186
- } else {
1187
- parsed[key] = parsed[key] ? parsed[key] + ", " + val : val;
1188
- }
1189
- });
1190
- return parsed;
1191
- };
1192
- const $internals = Symbol("internals");
1193
- function normalizeHeader(header) {
1194
- return header && String(header).trim().toLowerCase();
1195
- }
1196
- function normalizeValue(value) {
1197
- if (value === false || value == null) {
1198
- return value;
1199
- }
1200
- return utils$1.isArray(value) ? value.map(normalizeValue) : String(value);
1201
- }
1202
- function parseTokens(str) {
1203
- const tokens = /* @__PURE__ */ Object.create(null);
1204
- const tokensRE = /([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;
1205
- let match;
1206
- while (match = tokensRE.exec(str)) {
1207
- tokens[match[1]] = match[2];
1208
- }
1209
- return tokens;
1210
- }
1211
- const isValidHeaderName = (str) => /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(str.trim());
1212
- function matchHeaderValue(context, value, header, filter2, isHeaderNameFilter) {
1213
- if (utils$1.isFunction(filter2)) {
1214
- return filter2.call(this, value, header);
1215
- }
1216
- if (isHeaderNameFilter) {
1217
- value = header;
1218
- }
1219
- if (!utils$1.isString(value)) return;
1220
- if (utils$1.isString(filter2)) {
1221
- return value.indexOf(filter2) !== -1;
1222
- }
1223
- if (utils$1.isRegExp(filter2)) {
1224
- return filter2.test(value);
1225
- }
1226
- }
1227
- function formatHeader(header) {
1228
- return header.trim().toLowerCase().replace(/([a-z\d])(\w*)/g, (w, char, str) => {
1229
- return char.toUpperCase() + str;
1230
- });
1231
- }
1232
- function buildAccessors(obj, header) {
1233
- const accessorName = utils$1.toCamelCase(" " + header);
1234
- ["get", "set", "has"].forEach((methodName) => {
1235
- Object.defineProperty(obj, methodName + accessorName, {
1236
- value: function(arg1, arg2, arg3) {
1237
- return this[methodName].call(this, header, arg1, arg2, arg3);
1238
- },
1239
- configurable: true
1240
- });
1241
- });
1242
- }
1243
- let AxiosHeaders$1 = class AxiosHeaders {
1244
- constructor(headers) {
1245
- headers && this.set(headers);
1246
- }
1247
- set(header, valueOrRewrite, rewrite) {
1248
- const self2 = this;
1249
- function setHeader(_value, _header, _rewrite) {
1250
- const lHeader = normalizeHeader(_header);
1251
- if (!lHeader) {
1252
- throw new Error("header name must be a non-empty string");
1253
- }
1254
- const key = utils$1.findKey(self2, lHeader);
1255
- if (!key || self2[key] === void 0 || _rewrite === true || _rewrite === void 0 && self2[key] !== false) {
1256
- self2[key || _header] = normalizeValue(_value);
1257
- }
1258
- }
1259
- const setHeaders = (headers, _rewrite) => utils$1.forEach(headers, (_value, _header) => setHeader(_value, _header, _rewrite));
1260
- if (utils$1.isPlainObject(header) || header instanceof this.constructor) {
1261
- setHeaders(header, valueOrRewrite);
1262
- } else if (utils$1.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
1263
- setHeaders(parseHeaders(header), valueOrRewrite);
1264
- } else if (utils$1.isObject(header) && utils$1.isIterable(header)) {
1265
- let obj = {}, dest, key;
1266
- for (const entry of header) {
1267
- if (!utils$1.isArray(entry)) {
1268
- throw TypeError("Object iterator must return a key-value pair");
1269
- }
1270
- obj[key = entry[0]] = (dest = obj[key]) ? utils$1.isArray(dest) ? [...dest, entry[1]] : [dest, entry[1]] : entry[1];
1271
- }
1272
- setHeaders(obj, valueOrRewrite);
1273
- } else {
1274
- header != null && setHeader(valueOrRewrite, header, rewrite);
1275
- }
1276
- return this;
1277
- }
1278
- get(header, parser) {
1279
- header = normalizeHeader(header);
1280
- if (header) {
1281
- const key = utils$1.findKey(this, header);
1282
- if (key) {
1283
- const value = this[key];
1284
- if (!parser) {
1285
- return value;
1286
- }
1287
- if (parser === true) {
1288
- return parseTokens(value);
1289
- }
1290
- if (utils$1.isFunction(parser)) {
1291
- return parser.call(this, value, key);
1292
- }
1293
- if (utils$1.isRegExp(parser)) {
1294
- return parser.exec(value);
1295
- }
1296
- throw new TypeError("parser must be boolean|regexp|function");
1297
- }
1298
- }
1299
- }
1300
- has(header, matcher) {
1301
- header = normalizeHeader(header);
1302
- if (header) {
1303
- const key = utils$1.findKey(this, header);
1304
- return !!(key && this[key] !== void 0 && (!matcher || matchHeaderValue(this, this[key], key, matcher)));
1305
- }
1306
- return false;
1307
- }
1308
- delete(header, matcher) {
1309
- const self2 = this;
1310
- let deleted = false;
1311
- function deleteHeader(_header) {
1312
- _header = normalizeHeader(_header);
1313
- if (_header) {
1314
- const key = utils$1.findKey(self2, _header);
1315
- if (key && (!matcher || matchHeaderValue(self2, self2[key], key, matcher))) {
1316
- delete self2[key];
1317
- deleted = true;
1318
- }
1319
- }
1320
- }
1321
- if (utils$1.isArray(header)) {
1322
- header.forEach(deleteHeader);
1323
- } else {
1324
- deleteHeader(header);
1325
- }
1326
- return deleted;
1327
- }
1328
- clear(matcher) {
1329
- const keys = Object.keys(this);
1330
- let i = keys.length;
1331
- let deleted = false;
1332
- while (i--) {
1333
- const key = keys[i];
1334
- if (!matcher || matchHeaderValue(this, this[key], key, matcher, true)) {
1335
- delete this[key];
1336
- deleted = true;
1337
- }
1338
- }
1339
- return deleted;
1340
- }
1341
- normalize(format2) {
1342
- const self2 = this;
1343
- const headers = {};
1344
- utils$1.forEach(this, (value, header) => {
1345
- const key = utils$1.findKey(headers, header);
1346
- if (key) {
1347
- self2[key] = normalizeValue(value);
1348
- delete self2[header];
1349
- return;
1350
- }
1351
- const normalized = format2 ? formatHeader(header) : String(header).trim();
1352
- if (normalized !== header) {
1353
- delete self2[header];
1354
- }
1355
- self2[normalized] = normalizeValue(value);
1356
- headers[normalized] = true;
1357
- });
1358
- return this;
1359
- }
1360
- concat(...targets) {
1361
- return this.constructor.concat(this, ...targets);
1362
- }
1363
- toJSON(asStrings) {
1364
- const obj = /* @__PURE__ */ Object.create(null);
1365
- utils$1.forEach(this, (value, header) => {
1366
- value != null && value !== false && (obj[header] = asStrings && utils$1.isArray(value) ? value.join(", ") : value);
1367
- });
1368
- return obj;
1369
- }
1370
- [Symbol.iterator]() {
1371
- return Object.entries(this.toJSON())[Symbol.iterator]();
1372
- }
1373
- toString() {
1374
- return Object.entries(this.toJSON()).map(([header, value]) => header + ": " + value).join("\n");
1375
- }
1376
- getSetCookie() {
1377
- return this.get("set-cookie") || [];
1378
- }
1379
- get [Symbol.toStringTag]() {
1380
- return "AxiosHeaders";
1381
- }
1382
- static from(thing) {
1383
- return thing instanceof this ? thing : new this(thing);
1384
- }
1385
- static concat(first, ...targets) {
1386
- const computed = new this(first);
1387
- targets.forEach((target) => computed.set(target));
1388
- return computed;
1389
- }
1390
- static accessor(header) {
1391
- const internals = this[$internals] = this[$internals] = {
1392
- accessors: {}
1393
- };
1394
- const accessors = internals.accessors;
1395
- const prototype2 = this.prototype;
1396
- function defineAccessor(_header) {
1397
- const lHeader = normalizeHeader(_header);
1398
- if (!accessors[lHeader]) {
1399
- buildAccessors(prototype2, _header);
1400
- accessors[lHeader] = true;
1401
- }
1402
- }
1403
- utils$1.isArray(header) ? header.forEach(defineAccessor) : defineAccessor(header);
1404
- return this;
1405
- }
1406
- };
1407
- AxiosHeaders$1.accessor(["Content-Type", "Content-Length", "Accept", "Accept-Encoding", "User-Agent", "Authorization"]);
1408
- utils$1.reduceDescriptors(AxiosHeaders$1.prototype, ({ value }, key) => {
1409
- let mapped = key[0].toUpperCase() + key.slice(1);
1410
- return {
1411
- get: () => value,
1412
- set(headerValue) {
1413
- this[mapped] = headerValue;
1414
- }
1415
- };
1416
- });
1417
- utils$1.freezeMethods(AxiosHeaders$1);
1418
- function transformData(fns, response) {
1419
- const config = this || defaults;
1420
- const context = response || config;
1421
- const headers = AxiosHeaders$1.from(context.headers);
1422
- let data = context.data;
1423
- utils$1.forEach(fns, function transform(fn) {
1424
- data = fn.call(config, data, headers.normalize(), response ? response.status : void 0);
1425
- });
1426
- headers.normalize();
1427
- return data;
1428
- }
1429
- function isCancel$1(value) {
1430
- return !!(value && value.__CANCEL__);
1431
- }
1432
- let CanceledError$1 = class CanceledError extends AxiosError$1 {
1433
- /**
1434
- * A `CanceledError` is an object that is thrown when an operation is canceled.
1435
- *
1436
- * @param {string=} message The message.
1437
- * @param {Object=} config The config.
1438
- * @param {Object=} request The request.
1439
- *
1440
- * @returns {CanceledError} The created error.
1441
- */
1442
- constructor(message, config, request) {
1443
- super(message == null ? "canceled" : message, AxiosError$1.ERR_CANCELED, config, request);
1444
- this.name = "CanceledError";
1445
- this.__CANCEL__ = true;
1446
- }
1447
- };
1448
- function settle(resolve, reject, response) {
1449
- const validateStatus2 = response.config.validateStatus;
1450
- if (!response.status || !validateStatus2 || validateStatus2(response.status)) {
1451
- resolve(response);
1452
- } else {
1453
- reject(new AxiosError$1(
1454
- "Request failed with status code " + response.status,
1455
- [AxiosError$1.ERR_BAD_REQUEST, AxiosError$1.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4],
1456
- response.config,
1457
- response.request,
1458
- response
1459
- ));
1460
- }
1461
- }
1462
- function parseProtocol(url) {
1463
- const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
1464
- return match && match[1] || "";
1465
- }
1466
- function speedometer(samplesCount, min) {
1467
- samplesCount = samplesCount || 10;
1468
- const bytes = new Array(samplesCount);
1469
- const timestamps = new Array(samplesCount);
1470
- let head = 0;
1471
- let tail = 0;
1472
- let firstSampleTS;
1473
- min = min !== void 0 ? min : 1e3;
1474
- return function push(chunkLength) {
1475
- const now = Date.now();
1476
- const startedAt = timestamps[tail];
1477
- if (!firstSampleTS) {
1478
- firstSampleTS = now;
1479
- }
1480
- bytes[head] = chunkLength;
1481
- timestamps[head] = now;
1482
- let i = tail;
1483
- let bytesCount = 0;
1484
- while (i !== head) {
1485
- bytesCount += bytes[i++];
1486
- i = i % samplesCount;
1487
- }
1488
- head = (head + 1) % samplesCount;
1489
- if (head === tail) {
1490
- tail = (tail + 1) % samplesCount;
1491
- }
1492
- if (now - firstSampleTS < min) {
1493
- return;
1494
- }
1495
- const passed = startedAt && now - startedAt;
1496
- return passed ? Math.round(bytesCount * 1e3 / passed) : void 0;
1497
- };
1498
- }
1499
- function throttle(fn, freq) {
1500
- let timestamp = 0;
1501
- let threshold = 1e3 / freq;
1502
- let lastArgs;
1503
- let timer;
1504
- const invoke = (args, now = Date.now()) => {
1505
- timestamp = now;
1506
- lastArgs = null;
1507
- if (timer) {
1508
- clearTimeout(timer);
1509
- timer = null;
1510
- }
1511
- fn(...args);
1512
- };
1513
- const throttled = (...args) => {
1514
- const now = Date.now();
1515
- const passed = now - timestamp;
1516
- if (passed >= threshold) {
1517
- invoke(args, now);
1518
- } else {
1519
- lastArgs = args;
1520
- if (!timer) {
1521
- timer = setTimeout(() => {
1522
- timer = null;
1523
- invoke(lastArgs);
1524
- }, threshold - passed);
1525
- }
1526
- }
1527
- };
1528
- const flush = () => lastArgs && invoke(lastArgs);
1529
- return [throttled, flush];
1530
- }
1531
- const progressEventReducer = (listener, isDownloadStream, freq = 3) => {
1532
- let bytesNotified = 0;
1533
- const _speedometer = speedometer(50, 250);
1534
- return throttle((e) => {
1535
- const loaded = e.loaded;
1536
- const total = e.lengthComputable ? e.total : void 0;
1537
- const progressBytes = loaded - bytesNotified;
1538
- const rate = _speedometer(progressBytes);
1539
- const inRange = loaded <= total;
1540
- bytesNotified = loaded;
1541
- const data = {
1542
- loaded,
1543
- total,
1544
- progress: total ? loaded / total : void 0,
1545
- bytes: progressBytes,
1546
- rate: rate ? rate : void 0,
1547
- estimated: rate && total && inRange ? (total - loaded) / rate : void 0,
1548
- event: e,
1549
- lengthComputable: total != null,
1550
- [isDownloadStream ? "download" : "upload"]: true
1551
- };
1552
- listener(data);
1553
- }, freq);
1554
- };
1555
- const progressEventDecorator = (total, throttled) => {
1556
- const lengthComputable = total != null;
1557
- return [(loaded) => throttled[0]({
1558
- lengthComputable,
1559
- total,
1560
- loaded
1561
- }), throttled[1]];
1562
- };
1563
- const asyncDecorator = (fn) => (...args) => utils$1.asap(() => fn(...args));
1564
- const isURLSameOrigin = platform.hasStandardBrowserEnv ? /* @__PURE__ */ ((origin2, isMSIE) => (url) => {
1565
- url = new URL(url, platform.origin);
1566
- return origin2.protocol === url.protocol && origin2.host === url.host && (isMSIE || origin2.port === url.port);
1567
- })(
1568
- new URL(platform.origin),
1569
- platform.navigator && /(msie|trident)/i.test(platform.navigator.userAgent)
1570
- ) : () => true;
1571
- const cookies = platform.hasStandardBrowserEnv ? (
1572
- // Standard browser envs support document.cookie
1573
- {
1574
- write(name, value, expires, path, domain, secure, sameSite) {
1575
- if (typeof document === "undefined") return;
1576
- const cookie = [`${name}=${encodeURIComponent(value)}`];
1577
- if (utils$1.isNumber(expires)) {
1578
- cookie.push(`expires=${new Date(expires).toUTCString()}`);
1579
- }
1580
- if (utils$1.isString(path)) {
1581
- cookie.push(`path=${path}`);
1582
- }
1583
- if (utils$1.isString(domain)) {
1584
- cookie.push(`domain=${domain}`);
1585
- }
1586
- if (secure === true) {
1587
- cookie.push("secure");
1588
- }
1589
- if (utils$1.isString(sameSite)) {
1590
- cookie.push(`SameSite=${sameSite}`);
1591
- }
1592
- document.cookie = cookie.join("; ");
1593
- },
1594
- read(name) {
1595
- if (typeof document === "undefined") return null;
1596
- const match = document.cookie.match(new RegExp("(?:^|; )" + name + "=([^;]*)"));
1597
- return match ? decodeURIComponent(match[1]) : null;
1598
- },
1599
- remove(name) {
1600
- this.write(name, "", Date.now() - 864e5, "/");
1601
- }
1602
- }
1603
- ) : (
1604
- // Non-standard browser env (web workers, react-native) lack needed support.
1605
- {
1606
- write() {
1607
- },
1608
- read() {
1609
- return null;
1610
- },
1611
- remove() {
1612
- }
1613
- }
1614
- );
1615
- function isAbsoluteURL(url) {
1616
- if (typeof url !== "string") {
1617
- return false;
1618
- }
1619
- return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
1620
- }
1621
- function combineURLs(baseURL, relativeURL) {
1622
- return relativeURL ? baseURL.replace(/\/?\/$/, "") + "/" + relativeURL.replace(/^\/+/, "") : baseURL;
1623
- }
1624
- function buildFullPath(baseURL, requestedURL, allowAbsoluteUrls) {
1625
- let isRelativeUrl = !isAbsoluteURL(requestedURL);
1626
- if (baseURL && (isRelativeUrl || allowAbsoluteUrls == false)) {
1627
- return combineURLs(baseURL, requestedURL);
1628
- }
1629
- return requestedURL;
1630
- }
1631
- const headersToObject = (thing) => thing instanceof AxiosHeaders$1 ? { ...thing } : thing;
1632
- function mergeConfig$1(config1, config2) {
1633
- config2 = config2 || {};
1634
- const config = {};
1635
- function getMergedValue(target, source, prop, caseless) {
1636
- if (utils$1.isPlainObject(target) && utils$1.isPlainObject(source)) {
1637
- return utils$1.merge.call({ caseless }, target, source);
1638
- } else if (utils$1.isPlainObject(source)) {
1639
- return utils$1.merge({}, source);
1640
- } else if (utils$1.isArray(source)) {
1641
- return source.slice();
1642
- }
1643
- return source;
1644
- }
1645
- function mergeDeepProperties(a, b, prop, caseless) {
1646
- if (!utils$1.isUndefined(b)) {
1647
- return getMergedValue(a, b, prop, caseless);
1648
- } else if (!utils$1.isUndefined(a)) {
1649
- return getMergedValue(void 0, a, prop, caseless);
1650
- }
1651
- }
1652
- function valueFromConfig2(a, b) {
1653
- if (!utils$1.isUndefined(b)) {
1654
- return getMergedValue(void 0, b);
1655
- }
1656
- }
1657
- function defaultToConfig2(a, b) {
1658
- if (!utils$1.isUndefined(b)) {
1659
- return getMergedValue(void 0, b);
1660
- } else if (!utils$1.isUndefined(a)) {
1661
- return getMergedValue(void 0, a);
1662
- }
1663
- }
1664
- function mergeDirectKeys(a, b, prop) {
1665
- if (prop in config2) {
1666
- return getMergedValue(a, b);
1667
- } else if (prop in config1) {
1668
- return getMergedValue(void 0, a);
1669
- }
1670
- }
1671
- const mergeMap = {
1672
- url: valueFromConfig2,
1673
- method: valueFromConfig2,
1674
- data: valueFromConfig2,
1675
- baseURL: defaultToConfig2,
1676
- transformRequest: defaultToConfig2,
1677
- transformResponse: defaultToConfig2,
1678
- paramsSerializer: defaultToConfig2,
1679
- timeout: defaultToConfig2,
1680
- timeoutMessage: defaultToConfig2,
1681
- withCredentials: defaultToConfig2,
1682
- withXSRFToken: defaultToConfig2,
1683
- adapter: defaultToConfig2,
1684
- responseType: defaultToConfig2,
1685
- xsrfCookieName: defaultToConfig2,
1686
- xsrfHeaderName: defaultToConfig2,
1687
- onUploadProgress: defaultToConfig2,
1688
- onDownloadProgress: defaultToConfig2,
1689
- decompress: defaultToConfig2,
1690
- maxContentLength: defaultToConfig2,
1691
- maxBodyLength: defaultToConfig2,
1692
- beforeRedirect: defaultToConfig2,
1693
- transport: defaultToConfig2,
1694
- httpAgent: defaultToConfig2,
1695
- httpsAgent: defaultToConfig2,
1696
- cancelToken: defaultToConfig2,
1697
- socketPath: defaultToConfig2,
1698
- responseEncoding: defaultToConfig2,
1699
- validateStatus: mergeDirectKeys,
1700
- headers: (a, b, prop) => mergeDeepProperties(headersToObject(a), headersToObject(b), prop, true)
1701
- };
1702
- utils$1.forEach(
1703
- Object.keys({ ...config1, ...config2 }),
1704
- function computeConfigValue(prop) {
1705
- if (prop === "__proto__" || prop === "constructor" || prop === "prototype")
1706
- return;
1707
- const merge2 = utils$1.hasOwnProp(mergeMap, prop) ? mergeMap[prop] : mergeDeepProperties;
1708
- const configValue = merge2(config1[prop], config2[prop], prop);
1709
- utils$1.isUndefined(configValue) && merge2 !== mergeDirectKeys || (config[prop] = configValue);
1710
- }
1711
- );
1712
- return config;
1713
- }
1714
- const resolveConfig = (config) => {
1715
- const newConfig = mergeConfig$1({}, config);
1716
- let { data, withXSRFToken, xsrfHeaderName, xsrfCookieName, headers, auth: auth2 } = newConfig;
1717
- newConfig.headers = headers = AxiosHeaders$1.from(headers);
1718
- newConfig.url = buildURL(buildFullPath(newConfig.baseURL, newConfig.url, newConfig.allowAbsoluteUrls), config.params, config.paramsSerializer);
1719
- if (auth2) {
1720
- headers.set(
1721
- "Authorization",
1722
- "Basic " + btoa((auth2.username || "") + ":" + (auth2.password ? unescape(encodeURIComponent(auth2.password)) : ""))
1723
- );
1724
- }
1725
- if (utils$1.isFormData(data)) {
1726
- if (platform.hasStandardBrowserEnv || platform.hasStandardBrowserWebWorkerEnv) {
1727
- headers.setContentType(void 0);
1728
- } else if (utils$1.isFunction(data.getHeaders)) {
1729
- const formHeaders = data.getHeaders();
1730
- const allowedHeaders = ["content-type", "content-length"];
1731
- Object.entries(formHeaders).forEach(([key, val]) => {
1732
- if (allowedHeaders.includes(key.toLowerCase())) {
1733
- headers.set(key, val);
1734
- }
1735
- });
1736
- }
1737
- }
1738
- if (platform.hasStandardBrowserEnv) {
1739
- withXSRFToken && utils$1.isFunction(withXSRFToken) && (withXSRFToken = withXSRFToken(newConfig));
1740
- if (withXSRFToken || withXSRFToken !== false && isURLSameOrigin(newConfig.url)) {
1741
- const xsrfValue = xsrfHeaderName && xsrfCookieName && cookies.read(xsrfCookieName);
1742
- if (xsrfValue) {
1743
- headers.set(xsrfHeaderName, xsrfValue);
1744
- }
1745
- }
1746
- }
1747
- return newConfig;
1748
- };
1749
- const isXHRAdapterSupported = typeof XMLHttpRequest !== "undefined";
1750
- const xhrAdapter = isXHRAdapterSupported && function(config) {
1751
- return new Promise(function dispatchXhrRequest(resolve, reject) {
1752
- const _config = resolveConfig(config);
1753
- let requestData = _config.data;
1754
- const requestHeaders = AxiosHeaders$1.from(_config.headers).normalize();
1755
- let { responseType, onUploadProgress, onDownloadProgress } = _config;
1756
- let onCanceled;
1757
- let uploadThrottled, downloadThrottled;
1758
- let flushUpload, flushDownload;
1759
- function done() {
1760
- flushUpload && flushUpload();
1761
- flushDownload && flushDownload();
1762
- _config.cancelToken && _config.cancelToken.unsubscribe(onCanceled);
1763
- _config.signal && _config.signal.removeEventListener("abort", onCanceled);
1764
- }
1765
- let request = new XMLHttpRequest();
1766
- request.open(_config.method.toUpperCase(), _config.url, true);
1767
- request.timeout = _config.timeout;
1768
- function onloadend() {
1769
- if (!request) {
1770
- return;
1771
- }
1772
- const responseHeaders = AxiosHeaders$1.from(
1773
- "getAllResponseHeaders" in request && request.getAllResponseHeaders()
1774
- );
1775
- const responseData = !responseType || responseType === "text" || responseType === "json" ? request.responseText : request.response;
1776
- const response = {
1777
- data: responseData,
1778
- status: request.status,
1779
- statusText: request.statusText,
1780
- headers: responseHeaders,
1781
- config,
1782
- request
1783
- };
1784
- settle(function _resolve(value) {
1785
- resolve(value);
1786
- done();
1787
- }, function _reject(err) {
1788
- reject(err);
1789
- done();
1790
- }, response);
1791
- request = null;
1792
- }
1793
- if ("onloadend" in request) {
1794
- request.onloadend = onloadend;
1795
- } else {
1796
- request.onreadystatechange = function handleLoad() {
1797
- if (!request || request.readyState !== 4) {
1798
- return;
1799
- }
1800
- if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf("file:") === 0)) {
1801
- return;
1802
- }
1803
- setTimeout(onloadend);
1804
- };
1805
- }
1806
- request.onabort = function handleAbort() {
1807
- if (!request) {
1808
- return;
1809
- }
1810
- reject(new AxiosError$1("Request aborted", AxiosError$1.ECONNABORTED, config, request));
1811
- request = null;
1812
- };
1813
- request.onerror = function handleError(event) {
1814
- const msg = event && event.message ? event.message : "Network Error";
1815
- const err = new AxiosError$1(msg, AxiosError$1.ERR_NETWORK, config, request);
1816
- err.event = event || null;
1817
- reject(err);
1818
- request = null;
1819
- };
1820
- request.ontimeout = function handleTimeout() {
1821
- let timeoutErrorMessage = _config.timeout ? "timeout of " + _config.timeout + "ms exceeded" : "timeout exceeded";
1822
- const transitional2 = _config.transitional || transitionalDefaults;
1823
- if (_config.timeoutErrorMessage) {
1824
- timeoutErrorMessage = _config.timeoutErrorMessage;
1825
- }
1826
- reject(new AxiosError$1(
1827
- timeoutErrorMessage,
1828
- transitional2.clarifyTimeoutError ? AxiosError$1.ETIMEDOUT : AxiosError$1.ECONNABORTED,
1829
- config,
1830
- request
1831
- ));
1832
- request = null;
1833
- };
1834
- requestData === void 0 && requestHeaders.setContentType(null);
1835
- if ("setRequestHeader" in request) {
1836
- utils$1.forEach(requestHeaders.toJSON(), function setRequestHeader(val, key) {
1837
- request.setRequestHeader(key, val);
1838
- });
1839
- }
1840
- if (!utils$1.isUndefined(_config.withCredentials)) {
1841
- request.withCredentials = !!_config.withCredentials;
1842
- }
1843
- if (responseType && responseType !== "json") {
1844
- request.responseType = _config.responseType;
1845
- }
1846
- if (onDownloadProgress) {
1847
- [downloadThrottled, flushDownload] = progressEventReducer(onDownloadProgress, true);
1848
- request.addEventListener("progress", downloadThrottled);
1849
- }
1850
- if (onUploadProgress && request.upload) {
1851
- [uploadThrottled, flushUpload] = progressEventReducer(onUploadProgress);
1852
- request.upload.addEventListener("progress", uploadThrottled);
1853
- request.upload.addEventListener("loadend", flushUpload);
1854
- }
1855
- if (_config.cancelToken || _config.signal) {
1856
- onCanceled = (cancel) => {
1857
- if (!request) {
1858
- return;
1859
- }
1860
- reject(!cancel || cancel.type ? new CanceledError$1(null, config, request) : cancel);
1861
- request.abort();
1862
- request = null;
1863
- };
1864
- _config.cancelToken && _config.cancelToken.subscribe(onCanceled);
1865
- if (_config.signal) {
1866
- _config.signal.aborted ? onCanceled() : _config.signal.addEventListener("abort", onCanceled);
1867
- }
1868
- }
1869
- const protocol = parseProtocol(_config.url);
1870
- if (protocol && platform.protocols.indexOf(protocol) === -1) {
1871
- reject(new AxiosError$1("Unsupported protocol " + protocol + ":", AxiosError$1.ERR_BAD_REQUEST, config));
1872
- return;
1873
- }
1874
- request.send(requestData || null);
1875
- });
1876
- };
1877
- const composeSignals = (signals, timeout) => {
1878
- const { length } = signals = signals ? signals.filter(Boolean) : [];
1879
- if (timeout || length) {
1880
- let controller = new AbortController();
1881
- let aborted;
1882
- const onabort = function(reason) {
1883
- if (!aborted) {
1884
- aborted = true;
1885
- unsubscribe();
1886
- const err = reason instanceof Error ? reason : this.reason;
1887
- controller.abort(err instanceof AxiosError$1 ? err : new CanceledError$1(err instanceof Error ? err.message : err));
1888
- }
1889
- };
1890
- let timer = timeout && setTimeout(() => {
1891
- timer = null;
1892
- onabort(new AxiosError$1(`timeout of ${timeout}ms exceeded`, AxiosError$1.ETIMEDOUT));
1893
- }, timeout);
1894
- const unsubscribe = () => {
1895
- if (signals) {
1896
- timer && clearTimeout(timer);
1897
- timer = null;
1898
- signals.forEach((signal2) => {
1899
- signal2.unsubscribe ? signal2.unsubscribe(onabort) : signal2.removeEventListener("abort", onabort);
1900
- });
1901
- signals = null;
1902
- }
1903
- };
1904
- signals.forEach((signal2) => signal2.addEventListener("abort", onabort));
1905
- const { signal } = controller;
1906
- signal.unsubscribe = () => utils$1.asap(unsubscribe);
1907
- return signal;
1908
- }
1909
- };
1910
- const streamChunk = function* (chunk, chunkSize) {
1911
- let len = chunk.byteLength;
1912
- if (len < chunkSize) {
1913
- yield chunk;
1914
- return;
1915
- }
1916
- let pos = 0;
1917
- let end;
1918
- while (pos < len) {
1919
- end = pos + chunkSize;
1920
- yield chunk.slice(pos, end);
1921
- pos = end;
1922
- }
1923
- };
1924
- const readBytes = async function* (iterable, chunkSize) {
1925
- for await (const chunk of readStream(iterable)) {
1926
- yield* streamChunk(chunk, chunkSize);
1927
- }
1928
- };
1929
- const readStream = async function* (stream) {
1930
- if (stream[Symbol.asyncIterator]) {
1931
- yield* stream;
1932
- return;
1933
- }
1934
- const reader = stream.getReader();
1935
- try {
1936
- for (; ; ) {
1937
- const { done, value } = await reader.read();
1938
- if (done) {
1939
- break;
1940
- }
1941
- yield value;
1942
- }
1943
- } finally {
1944
- await reader.cancel();
1945
- }
1946
- };
1947
- const trackStream = (stream, chunkSize, onProgress, onFinish) => {
1948
- const iterator2 = readBytes(stream, chunkSize);
1949
- let bytes = 0;
1950
- let done;
1951
- let _onFinish = (e) => {
1952
- if (!done) {
1953
- done = true;
1954
- onFinish && onFinish(e);
1955
- }
1956
- };
1957
- return new ReadableStream({
1958
- async pull(controller) {
1959
- try {
1960
- const { done: done2, value } = await iterator2.next();
1961
- if (done2) {
1962
- _onFinish();
1963
- controller.close();
1964
- return;
1965
- }
1966
- let len = value.byteLength;
1967
- if (onProgress) {
1968
- let loadedBytes = bytes += len;
1969
- onProgress(loadedBytes);
1970
- }
1971
- controller.enqueue(new Uint8Array(value));
1972
- } catch (err) {
1973
- _onFinish(err);
1974
- throw err;
1975
- }
1976
- },
1977
- cancel(reason) {
1978
- _onFinish(reason);
1979
- return iterator2.return();
1980
- }
1981
- }, {
1982
- highWaterMark: 2
1983
- });
1984
- };
1985
- const DEFAULT_CHUNK_SIZE = 64 * 1024;
1986
- const { isFunction } = utils$1;
1987
- const globalFetchAPI = (({ Request, Response }) => ({
1988
- Request,
1989
- Response
1990
- }))(utils$1.global);
1991
- const {
1992
- ReadableStream: ReadableStream$1,
1993
- TextEncoder
1994
- } = utils$1.global;
1995
- const test = (fn, ...args) => {
1996
- try {
1997
- return !!fn(...args);
1998
- } catch (e) {
1999
- return false;
2000
- }
2001
- };
2002
- const factory = (env) => {
2003
- env = utils$1.merge.call({
2004
- skipUndefined: true
2005
- }, globalFetchAPI, env);
2006
- const { fetch: envFetch, Request, Response } = env;
2007
- const isFetchSupported = envFetch ? isFunction(envFetch) : typeof fetch === "function";
2008
- const isRequestSupported = isFunction(Request);
2009
- const isResponseSupported = isFunction(Response);
2010
- if (!isFetchSupported) {
2011
- return false;
2012
- }
2013
- const isReadableStreamSupported = isFetchSupported && isFunction(ReadableStream$1);
2014
- const encodeText = isFetchSupported && (typeof TextEncoder === "function" ? /* @__PURE__ */ ((encoder) => (str) => encoder.encode(str))(new TextEncoder()) : async (str) => new Uint8Array(await new Request(str).arrayBuffer()));
2015
- const supportsRequestStream = isRequestSupported && isReadableStreamSupported && test(() => {
2016
- let duplexAccessed = false;
2017
- const hasContentType = new Request(platform.origin, {
2018
- body: new ReadableStream$1(),
2019
- method: "POST",
2020
- get duplex() {
2021
- duplexAccessed = true;
2022
- return "half";
2023
- }
2024
- }).headers.has("Content-Type");
2025
- return duplexAccessed && !hasContentType;
2026
- });
2027
- const supportsResponseStream = isResponseSupported && isReadableStreamSupported && test(() => utils$1.isReadableStream(new Response("").body));
2028
- const resolvers = {
2029
- stream: supportsResponseStream && ((res) => res.body)
2030
- };
2031
- isFetchSupported && (() => {
2032
- ["text", "arrayBuffer", "blob", "formData", "stream"].forEach((type) => {
2033
- !resolvers[type] && (resolvers[type] = (res, config) => {
2034
- let method = res && res[type];
2035
- if (method) {
2036
- return method.call(res);
2037
- }
2038
- throw new AxiosError$1(`Response type '${type}' is not supported`, AxiosError$1.ERR_NOT_SUPPORT, config);
2039
- });
2040
- });
2041
- })();
2042
- const getBodyLength = async (body) => {
2043
- if (body == null) {
2044
- return 0;
2045
- }
2046
- if (utils$1.isBlob(body)) {
2047
- return body.size;
2048
- }
2049
- if (utils$1.isSpecCompliantForm(body)) {
2050
- const _request = new Request(platform.origin, {
2051
- method: "POST",
2052
- body
2053
- });
2054
- return (await _request.arrayBuffer()).byteLength;
2055
- }
2056
- if (utils$1.isArrayBufferView(body) || utils$1.isArrayBuffer(body)) {
2057
- return body.byteLength;
2058
- }
2059
- if (utils$1.isURLSearchParams(body)) {
2060
- body = body + "";
2061
- }
2062
- if (utils$1.isString(body)) {
2063
- return (await encodeText(body)).byteLength;
2064
- }
2065
- };
2066
- const resolveBodyLength = async (headers, body) => {
2067
- const length = utils$1.toFiniteNumber(headers.getContentLength());
2068
- return length == null ? getBodyLength(body) : length;
2069
- };
2070
- return async (config) => {
2071
- let {
2072
- url,
2073
- method,
2074
- data,
2075
- signal,
2076
- cancelToken,
2077
- timeout,
2078
- onDownloadProgress,
2079
- onUploadProgress,
2080
- responseType,
2081
- headers,
2082
- withCredentials = "same-origin",
2083
- fetchOptions
2084
- } = resolveConfig(config);
2085
- let _fetch = envFetch || fetch;
2086
- responseType = responseType ? (responseType + "").toLowerCase() : "text";
2087
- let composedSignal = composeSignals([signal, cancelToken && cancelToken.toAbortSignal()], timeout);
2088
- let request = null;
2089
- const unsubscribe = composedSignal && composedSignal.unsubscribe && (() => {
2090
- composedSignal.unsubscribe();
2091
- });
2092
- let requestContentLength;
2093
- try {
2094
- if (onUploadProgress && supportsRequestStream && method !== "get" && method !== "head" && (requestContentLength = await resolveBodyLength(headers, data)) !== 0) {
2095
- let _request = new Request(url, {
2096
- method: "POST",
2097
- body: data,
2098
- duplex: "half"
2099
- });
2100
- let contentTypeHeader;
2101
- if (utils$1.isFormData(data) && (contentTypeHeader = _request.headers.get("content-type"))) {
2102
- headers.setContentType(contentTypeHeader);
2103
- }
2104
- if (_request.body) {
2105
- const [onProgress, flush] = progressEventDecorator(
2106
- requestContentLength,
2107
- progressEventReducer(asyncDecorator(onUploadProgress))
2108
- );
2109
- data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, onProgress, flush);
2110
- }
2111
- }
2112
- if (!utils$1.isString(withCredentials)) {
2113
- withCredentials = withCredentials ? "include" : "omit";
2114
- }
2115
- const isCredentialsSupported = isRequestSupported && "credentials" in Request.prototype;
2116
- const resolvedOptions = {
2117
- ...fetchOptions,
2118
- signal: composedSignal,
2119
- method: method.toUpperCase(),
2120
- headers: headers.normalize().toJSON(),
2121
- body: data,
2122
- duplex: "half",
2123
- credentials: isCredentialsSupported ? withCredentials : void 0
2124
- };
2125
- request = isRequestSupported && new Request(url, resolvedOptions);
2126
- let response = await (isRequestSupported ? _fetch(request, fetchOptions) : _fetch(url, resolvedOptions));
2127
- const isStreamResponse = supportsResponseStream && (responseType === "stream" || responseType === "response");
2128
- if (supportsResponseStream && (onDownloadProgress || isStreamResponse && unsubscribe)) {
2129
- const options = {};
2130
- ["status", "statusText", "headers"].forEach((prop) => {
2131
- options[prop] = response[prop];
2132
- });
2133
- const responseContentLength = utils$1.toFiniteNumber(response.headers.get("content-length"));
2134
- const [onProgress, flush] = onDownloadProgress && progressEventDecorator(
2135
- responseContentLength,
2136
- progressEventReducer(asyncDecorator(onDownloadProgress), true)
2137
- ) || [];
2138
- response = new Response(
2139
- trackStream(response.body, DEFAULT_CHUNK_SIZE, onProgress, () => {
2140
- flush && flush();
2141
- unsubscribe && unsubscribe();
2142
- }),
2143
- options
2144
- );
2145
- }
2146
- responseType = responseType || "text";
2147
- let responseData = await resolvers[utils$1.findKey(resolvers, responseType) || "text"](response, config);
2148
- !isStreamResponse && unsubscribe && unsubscribe();
2149
- return await new Promise((resolve, reject) => {
2150
- settle(resolve, reject, {
2151
- data: responseData,
2152
- headers: AxiosHeaders$1.from(response.headers),
2153
- status: response.status,
2154
- statusText: response.statusText,
2155
- config,
2156
- request
2157
- });
2158
- });
2159
- } catch (err) {
2160
- unsubscribe && unsubscribe();
2161
- if (err && err.name === "TypeError" && /Load failed|fetch/i.test(err.message)) {
2162
- throw Object.assign(
2163
- new AxiosError$1("Network Error", AxiosError$1.ERR_NETWORK, config, request, err && err.response),
2164
- {
2165
- cause: err.cause || err
2166
- }
2167
- );
2168
- }
2169
- throw AxiosError$1.from(err, err && err.code, config, request, err && err.response);
2170
- }
2171
- };
2172
- };
2173
- const seedCache = /* @__PURE__ */ new Map();
2174
- const getFetch = (config) => {
2175
- let env = config && config.env || {};
2176
- const { fetch: fetch2, Request, Response } = env;
2177
- const seeds = [
2178
- Request,
2179
- Response,
2180
- fetch2
2181
- ];
2182
- let len = seeds.length, i = len, seed, target, map = seedCache;
2183
- while (i--) {
2184
- seed = seeds[i];
2185
- target = map.get(seed);
2186
- target === void 0 && map.set(seed, target = i ? /* @__PURE__ */ new Map() : factory(env));
2187
- map = target;
2188
- }
2189
- return target;
2190
- };
2191
- getFetch();
2192
- const knownAdapters = {
2193
- http: httpAdapter,
2194
- xhr: xhrAdapter,
2195
- fetch: {
2196
- get: getFetch
2197
- }
2198
- };
2199
- utils$1.forEach(knownAdapters, (fn, value) => {
2200
- if (fn) {
2201
- try {
2202
- Object.defineProperty(fn, "name", { value });
2203
- } catch (e) {
2204
- }
2205
- Object.defineProperty(fn, "adapterName", { value });
2206
- }
2207
- });
2208
- const renderReason = (reason) => `- ${reason}`;
2209
- const isResolvedHandle = (adapter) => utils$1.isFunction(adapter) || adapter === null || adapter === false;
2210
- function getAdapter$1(adapters2, config) {
2211
- adapters2 = utils$1.isArray(adapters2) ? adapters2 : [adapters2];
2212
- const { length } = adapters2;
2213
- let nameOrAdapter;
2214
- let adapter;
2215
- const rejectedReasons = {};
2216
- for (let i = 0; i < length; i++) {
2217
- nameOrAdapter = adapters2[i];
2218
- let id;
2219
- adapter = nameOrAdapter;
2220
- if (!isResolvedHandle(nameOrAdapter)) {
2221
- adapter = knownAdapters[(id = String(nameOrAdapter)).toLowerCase()];
2222
- if (adapter === void 0) {
2223
- throw new AxiosError$1(`Unknown adapter '${id}'`);
2224
- }
2225
- }
2226
- if (adapter && (utils$1.isFunction(adapter) || (adapter = adapter.get(config)))) {
2227
- break;
2228
- }
2229
- rejectedReasons[id || "#" + i] = adapter;
2230
- }
2231
- if (!adapter) {
2232
- const reasons = Object.entries(rejectedReasons).map(
2233
- ([id, state]) => `adapter ${id} ` + (state === false ? "is not supported by the environment" : "is not available in the build")
2234
- );
2235
- let s = length ? reasons.length > 1 ? "since :\n" + reasons.map(renderReason).join("\n") : " " + renderReason(reasons[0]) : "as no adapter specified";
2236
- throw new AxiosError$1(
2237
- `There is no suitable adapter to dispatch the request ` + s,
2238
- "ERR_NOT_SUPPORT"
2239
- );
2240
- }
2241
- return adapter;
2242
- }
2243
- const adapters = {
2244
- /**
2245
- * Resolve an adapter from a list of adapter names or functions.
2246
- * @type {Function}
2247
- */
2248
- getAdapter: getAdapter$1,
2249
- /**
2250
- * Exposes all known adapters
2251
- * @type {Object<string, Function|Object>}
2252
- */
2253
- adapters: knownAdapters
2254
- };
2255
- function throwIfCancellationRequested(config) {
2256
- if (config.cancelToken) {
2257
- config.cancelToken.throwIfRequested();
2258
- }
2259
- if (config.signal && config.signal.aborted) {
2260
- throw new CanceledError$1(null, config);
2261
- }
2262
- }
2263
- function dispatchRequest(config) {
2264
- throwIfCancellationRequested(config);
2265
- config.headers = AxiosHeaders$1.from(config.headers);
2266
- config.data = transformData.call(
2267
- config,
2268
- config.transformRequest
2269
- );
2270
- if (["post", "put", "patch"].indexOf(config.method) !== -1) {
2271
- config.headers.setContentType("application/x-www-form-urlencoded", false);
2272
- }
2273
- const adapter = adapters.getAdapter(config.adapter || defaults.adapter, config);
2274
- return adapter(config).then(function onAdapterResolution(response) {
2275
- throwIfCancellationRequested(config);
2276
- response.data = transformData.call(
2277
- config,
2278
- config.transformResponse,
2279
- response
2280
- );
2281
- response.headers = AxiosHeaders$1.from(response.headers);
2282
- return response;
2283
- }, function onAdapterRejection(reason) {
2284
- if (!isCancel$1(reason)) {
2285
- throwIfCancellationRequested(config);
2286
- if (reason && reason.response) {
2287
- reason.response.data = transformData.call(
2288
- config,
2289
- config.transformResponse,
2290
- reason.response
2291
- );
2292
- reason.response.headers = AxiosHeaders$1.from(reason.response.headers);
2293
- }
2294
- }
2295
- return Promise.reject(reason);
2296
- });
2297
- }
2298
- const VERSION$1 = "1.13.5";
2299
- const validators$1 = {};
2300
- ["object", "boolean", "number", "function", "string", "symbol"].forEach((type, i) => {
2301
- validators$1[type] = function validator2(thing) {
2302
- return typeof thing === type || "a" + (i < 1 ? "n " : " ") + type;
2303
- };
2304
- });
2305
- const deprecatedWarnings = {};
2306
- validators$1.transitional = function transitional(validator2, version, message) {
2307
- function formatMessage(opt, desc) {
2308
- return "[Axios v" + VERSION$1 + "] Transitional option '" + opt + "'" + desc + (message ? ". " + message : "");
2309
- }
2310
- return (value, opt, opts) => {
2311
- if (validator2 === false) {
2312
- throw new AxiosError$1(
2313
- formatMessage(opt, " has been removed" + (version ? " in " + version : "")),
2314
- AxiosError$1.ERR_DEPRECATED
2315
- );
2316
- }
2317
- if (version && !deprecatedWarnings[opt]) {
2318
- deprecatedWarnings[opt] = true;
2319
- console.warn(
2320
- formatMessage(
2321
- opt,
2322
- " has been deprecated since v" + version + " and will be removed in the near future"
2323
- )
2324
- );
2325
- }
2326
- return validator2 ? validator2(value, opt, opts) : true;
2327
- };
2328
- };
2329
- validators$1.spelling = function spelling(correctSpelling) {
2330
- return (value, opt) => {
2331
- console.warn(`${opt} is likely a misspelling of ${correctSpelling}`);
2332
- return true;
2333
- };
2334
- };
2335
- function assertOptions(options, schema, allowUnknown) {
2336
- if (typeof options !== "object") {
2337
- throw new AxiosError$1("options must be an object", AxiosError$1.ERR_BAD_OPTION_VALUE);
2338
- }
2339
- const keys = Object.keys(options);
2340
- let i = keys.length;
2341
- while (i-- > 0) {
2342
- const opt = keys[i];
2343
- const validator2 = schema[opt];
2344
- if (validator2) {
2345
- const value = options[opt];
2346
- const result = value === void 0 || validator2(value, opt, options);
2347
- if (result !== true) {
2348
- throw new AxiosError$1("option " + opt + " must be " + result, AxiosError$1.ERR_BAD_OPTION_VALUE);
2349
- }
2350
- continue;
2351
- }
2352
- if (allowUnknown !== true) {
2353
- throw new AxiosError$1("Unknown option " + opt, AxiosError$1.ERR_BAD_OPTION);
2354
- }
2355
- }
2356
- }
2357
- const validator = {
2358
- assertOptions,
2359
- validators: validators$1
2360
- };
2361
- const validators = validator.validators;
2362
- let Axios$1 = class Axios {
2363
- constructor(instanceConfig) {
2364
- this.defaults = instanceConfig || {};
2365
- this.interceptors = {
2366
- request: new InterceptorManager(),
2367
- response: new InterceptorManager()
2368
- };
2369
- }
2370
- /**
2371
- * Dispatch a request
2372
- *
2373
- * @param {String|Object} configOrUrl The config specific for this request (merged with this.defaults)
2374
- * @param {?Object} config
2375
- *
2376
- * @returns {Promise} The Promise to be fulfilled
2377
- */
2378
- async request(configOrUrl, config) {
2379
- try {
2380
- return await this._request(configOrUrl, config);
2381
- } catch (err) {
2382
- if (err instanceof Error) {
2383
- let dummy = {};
2384
- Error.captureStackTrace ? Error.captureStackTrace(dummy) : dummy = new Error();
2385
- const stack = dummy.stack ? dummy.stack.replace(/^.+\n/, "") : "";
2386
- try {
2387
- if (!err.stack) {
2388
- err.stack = stack;
2389
- } else if (stack && !String(err.stack).endsWith(stack.replace(/^.+\n.+\n/, ""))) {
2390
- err.stack += "\n" + stack;
2391
- }
2392
- } catch (e) {
2393
- }
2394
- }
2395
- throw err;
2396
- }
2397
- }
2398
- _request(configOrUrl, config) {
2399
- if (typeof configOrUrl === "string") {
2400
- config = config || {};
2401
- config.url = configOrUrl;
2402
- } else {
2403
- config = configOrUrl || {};
2404
- }
2405
- config = mergeConfig$1(this.defaults, config);
2406
- const { transitional: transitional2, paramsSerializer, headers } = config;
2407
- if (transitional2 !== void 0) {
2408
- validator.assertOptions(transitional2, {
2409
- silentJSONParsing: validators.transitional(validators.boolean),
2410
- forcedJSONParsing: validators.transitional(validators.boolean),
2411
- clarifyTimeoutError: validators.transitional(validators.boolean),
2412
- legacyInterceptorReqResOrdering: validators.transitional(validators.boolean)
2413
- }, false);
2414
- }
2415
- if (paramsSerializer != null) {
2416
- if (utils$1.isFunction(paramsSerializer)) {
2417
- config.paramsSerializer = {
2418
- serialize: paramsSerializer
2419
- };
2420
- } else {
2421
- validator.assertOptions(paramsSerializer, {
2422
- encode: validators.function,
2423
- serialize: validators.function
2424
- }, true);
2425
- }
2426
- }
2427
- if (config.allowAbsoluteUrls !== void 0) ;
2428
- else if (this.defaults.allowAbsoluteUrls !== void 0) {
2429
- config.allowAbsoluteUrls = this.defaults.allowAbsoluteUrls;
2430
- } else {
2431
- config.allowAbsoluteUrls = true;
2432
- }
2433
- validator.assertOptions(config, {
2434
- baseUrl: validators.spelling("baseURL"),
2435
- withXsrfToken: validators.spelling("withXSRFToken")
2436
- }, true);
2437
- config.method = (config.method || this.defaults.method || "get").toLowerCase();
2438
- let contextHeaders = headers && utils$1.merge(
2439
- headers.common,
2440
- headers[config.method]
2441
- );
2442
- headers && utils$1.forEach(
2443
- ["delete", "get", "head", "post", "put", "patch", "common"],
2444
- (method) => {
2445
- delete headers[method];
2446
- }
2447
- );
2448
- config.headers = AxiosHeaders$1.concat(contextHeaders, headers);
2449
- const requestInterceptorChain = [];
2450
- let synchronousRequestInterceptors = true;
2451
- this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
2452
- if (typeof interceptor.runWhen === "function" && interceptor.runWhen(config) === false) {
2453
- return;
2454
- }
2455
- synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
2456
- const transitional3 = config.transitional || transitionalDefaults;
2457
- const legacyInterceptorReqResOrdering = transitional3 && transitional3.legacyInterceptorReqResOrdering;
2458
- if (legacyInterceptorReqResOrdering) {
2459
- requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
2460
- } else {
2461
- requestInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
2462
- }
2463
- });
2464
- const responseInterceptorChain = [];
2465
- this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
2466
- responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
2467
- });
2468
- let promise;
2469
- let i = 0;
2470
- let len;
2471
- if (!synchronousRequestInterceptors) {
2472
- const chain = [dispatchRequest.bind(this), void 0];
2473
- chain.unshift(...requestInterceptorChain);
2474
- chain.push(...responseInterceptorChain);
2475
- len = chain.length;
2476
- promise = Promise.resolve(config);
2477
- while (i < len) {
2478
- promise = promise.then(chain[i++], chain[i++]);
2479
- }
2480
- return promise;
2481
- }
2482
- len = requestInterceptorChain.length;
2483
- let newConfig = config;
2484
- while (i < len) {
2485
- const onFulfilled = requestInterceptorChain[i++];
2486
- const onRejected = requestInterceptorChain[i++];
2487
- try {
2488
- newConfig = onFulfilled(newConfig);
2489
- } catch (error) {
2490
- onRejected.call(this, error);
2491
- break;
2492
- }
2493
- }
2494
- try {
2495
- promise = dispatchRequest.call(this, newConfig);
2496
- } catch (error) {
2497
- return Promise.reject(error);
2498
- }
2499
- i = 0;
2500
- len = responseInterceptorChain.length;
2501
- while (i < len) {
2502
- promise = promise.then(responseInterceptorChain[i++], responseInterceptorChain[i++]);
2503
- }
2504
- return promise;
2505
- }
2506
- getUri(config) {
2507
- config = mergeConfig$1(this.defaults, config);
2508
- const fullPath = buildFullPath(config.baseURL, config.url, config.allowAbsoluteUrls);
2509
- return buildURL(fullPath, config.params, config.paramsSerializer);
2510
- }
2511
- };
2512
- utils$1.forEach(["delete", "get", "head", "options"], function forEachMethodNoData(method) {
2513
- Axios$1.prototype[method] = function(url, config) {
2514
- return this.request(mergeConfig$1(config || {}, {
2515
- method,
2516
- url,
2517
- data: (config || {}).data
2518
- }));
2519
- };
2520
- });
2521
- utils$1.forEach(["post", "put", "patch"], function forEachMethodWithData(method) {
2522
- function generateHTTPMethod(isForm) {
2523
- return function httpMethod(url, data, config) {
2524
- return this.request(mergeConfig$1(config || {}, {
2525
- method,
2526
- headers: isForm ? {
2527
- "Content-Type": "multipart/form-data"
2528
- } : {},
2529
- url,
2530
- data
2531
- }));
2532
- };
2533
- }
2534
- Axios$1.prototype[method] = generateHTTPMethod();
2535
- Axios$1.prototype[method + "Form"] = generateHTTPMethod(true);
2536
- });
2537
- let CancelToken$1 = class CancelToken {
2538
- constructor(executor) {
2539
- if (typeof executor !== "function") {
2540
- throw new TypeError("executor must be a function.");
2541
- }
2542
- let resolvePromise;
2543
- this.promise = new Promise(function promiseExecutor(resolve) {
2544
- resolvePromise = resolve;
2545
- });
2546
- const token = this;
2547
- this.promise.then((cancel) => {
2548
- if (!token._listeners) return;
2549
- let i = token._listeners.length;
2550
- while (i-- > 0) {
2551
- token._listeners[i](cancel);
2552
- }
2553
- token._listeners = null;
2554
- });
2555
- this.promise.then = (onfulfilled) => {
2556
- let _resolve;
2557
- const promise = new Promise((resolve) => {
2558
- token.subscribe(resolve);
2559
- _resolve = resolve;
2560
- }).then(onfulfilled);
2561
- promise.cancel = function reject() {
2562
- token.unsubscribe(_resolve);
2563
- };
2564
- return promise;
2565
- };
2566
- executor(function cancel(message, config, request) {
2567
- if (token.reason) {
2568
- return;
2569
- }
2570
- token.reason = new CanceledError$1(message, config, request);
2571
- resolvePromise(token.reason);
2572
- });
2573
- }
2574
- /**
2575
- * Throws a `CanceledError` if cancellation has been requested.
2576
- */
2577
- throwIfRequested() {
2578
- if (this.reason) {
2579
- throw this.reason;
2580
- }
2581
- }
2582
- /**
2583
- * Subscribe to the cancel signal
2584
- */
2585
- subscribe(listener) {
2586
- if (this.reason) {
2587
- listener(this.reason);
2588
- return;
2589
- }
2590
- if (this._listeners) {
2591
- this._listeners.push(listener);
2592
- } else {
2593
- this._listeners = [listener];
2594
- }
2595
- }
2596
- /**
2597
- * Unsubscribe from the cancel signal
2598
- */
2599
- unsubscribe(listener) {
2600
- if (!this._listeners) {
2601
- return;
2602
- }
2603
- const index = this._listeners.indexOf(listener);
2604
- if (index !== -1) {
2605
- this._listeners.splice(index, 1);
2606
- }
2607
- }
2608
- toAbortSignal() {
2609
- const controller = new AbortController();
2610
- const abort = (err) => {
2611
- controller.abort(err);
2612
- };
2613
- this.subscribe(abort);
2614
- controller.signal.unsubscribe = () => this.unsubscribe(abort);
2615
- return controller.signal;
2616
- }
2617
- /**
2618
- * Returns an object that contains a new `CancelToken` and a function that, when called,
2619
- * cancels the `CancelToken`.
2620
- */
2621
- static source() {
2622
- let cancel;
2623
- const token = new CancelToken(function executor(c) {
2624
- cancel = c;
2625
- });
2626
- return {
2627
- token,
2628
- cancel
2629
- };
2630
- }
2631
- };
2632
- function spread$1(callback) {
2633
- return function wrap(arr) {
2634
- return callback.apply(null, arr);
2635
- };
2636
- }
2637
- function isAxiosError$1(payload) {
2638
- return utils$1.isObject(payload) && payload.isAxiosError === true;
2639
- }
2640
- const HttpStatusCode$1 = {
2641
- Continue: 100,
2642
- SwitchingProtocols: 101,
2643
- Processing: 102,
2644
- EarlyHints: 103,
2645
- Ok: 200,
2646
- Created: 201,
2647
- Accepted: 202,
2648
- NonAuthoritativeInformation: 203,
2649
- NoContent: 204,
2650
- ResetContent: 205,
2651
- PartialContent: 206,
2652
- MultiStatus: 207,
2653
- AlreadyReported: 208,
2654
- ImUsed: 226,
2655
- MultipleChoices: 300,
2656
- MovedPermanently: 301,
2657
- Found: 302,
2658
- SeeOther: 303,
2659
- NotModified: 304,
2660
- UseProxy: 305,
2661
- Unused: 306,
2662
- TemporaryRedirect: 307,
2663
- PermanentRedirect: 308,
2664
- BadRequest: 400,
2665
- Unauthorized: 401,
2666
- PaymentRequired: 402,
2667
- Forbidden: 403,
2668
- NotFound: 404,
2669
- MethodNotAllowed: 405,
2670
- NotAcceptable: 406,
2671
- ProxyAuthenticationRequired: 407,
2672
- RequestTimeout: 408,
2673
- Conflict: 409,
2674
- Gone: 410,
2675
- LengthRequired: 411,
2676
- PreconditionFailed: 412,
2677
- PayloadTooLarge: 413,
2678
- UriTooLong: 414,
2679
- UnsupportedMediaType: 415,
2680
- RangeNotSatisfiable: 416,
2681
- ExpectationFailed: 417,
2682
- ImATeapot: 418,
2683
- MisdirectedRequest: 421,
2684
- UnprocessableEntity: 422,
2685
- Locked: 423,
2686
- FailedDependency: 424,
2687
- TooEarly: 425,
2688
- UpgradeRequired: 426,
2689
- PreconditionRequired: 428,
2690
- TooManyRequests: 429,
2691
- RequestHeaderFieldsTooLarge: 431,
2692
- UnavailableForLegalReasons: 451,
2693
- InternalServerError: 500,
2694
- NotImplemented: 501,
2695
- BadGateway: 502,
2696
- ServiceUnavailable: 503,
2697
- GatewayTimeout: 504,
2698
- HttpVersionNotSupported: 505,
2699
- VariantAlsoNegotiates: 506,
2700
- InsufficientStorage: 507,
2701
- LoopDetected: 508,
2702
- NotExtended: 510,
2703
- NetworkAuthenticationRequired: 511,
2704
- WebServerIsDown: 521,
2705
- ConnectionTimedOut: 522,
2706
- OriginIsUnreachable: 523,
2707
- TimeoutOccurred: 524,
2708
- SslHandshakeFailed: 525,
2709
- InvalidSslCertificate: 526
2710
- };
2711
- Object.entries(HttpStatusCode$1).forEach(([key, value]) => {
2712
- HttpStatusCode$1[value] = key;
2713
- });
2714
- function createInstance(defaultConfig) {
2715
- const context = new Axios$1(defaultConfig);
2716
- const instance = bind(Axios$1.prototype.request, context);
2717
- utils$1.extend(instance, Axios$1.prototype, context, { allOwnKeys: true });
2718
- utils$1.extend(instance, context, null, { allOwnKeys: true });
2719
- instance.create = function create(instanceConfig) {
2720
- return createInstance(mergeConfig$1(defaultConfig, instanceConfig));
2721
- };
2722
- return instance;
2723
- }
2724
- const axios = createInstance(defaults);
2725
- axios.Axios = Axios$1;
2726
- axios.CanceledError = CanceledError$1;
2727
- axios.CancelToken = CancelToken$1;
2728
- axios.isCancel = isCancel$1;
2729
- axios.VERSION = VERSION$1;
2730
- axios.toFormData = toFormData$1;
2731
- axios.AxiosError = AxiosError$1;
2732
- axios.Cancel = axios.CanceledError;
2733
- axios.all = function all(promises) {
2734
- return Promise.all(promises);
2735
- };
2736
- axios.spread = spread$1;
2737
- axios.isAxiosError = isAxiosError$1;
2738
- axios.mergeConfig = mergeConfig$1;
2739
- axios.AxiosHeaders = AxiosHeaders$1;
2740
- axios.formToJSON = (thing) => formDataToJSON(utils$1.isHTMLForm(thing) ? new FormData(thing) : thing);
2741
- axios.getAdapter = adapters.getAdapter;
2742
- axios.HttpStatusCode = HttpStatusCode$1;
2743
- axios.default = axios;
2744
- const {
2745
- Axios: Axios2,
2746
- AxiosError: AxiosError2,
2747
- CanceledError: CanceledError2,
2748
- isCancel,
2749
- CancelToken: CancelToken2,
2750
- VERSION,
2751
- all: all2,
2752
- Cancel,
2753
- isAxiosError,
2754
- spread,
2755
- toFormData,
2756
- AxiosHeaders: AxiosHeaders2,
2757
- HttpStatusCode,
2758
- formToJSON,
2759
- getAdapter,
2760
- mergeConfig
2761
- } = axios;
2762
- const denyList = /* @__PURE__ */ new Set([
2763
- "ENOTFOUND",
2764
- "ENETUNREACH",
2765
- // SSL errors from https://github.com/nodejs/node/blob/fc8e3e2cdc521978351de257030db0076d79e0ab/src/crypto/crypto_common.cc#L301-L328
2766
- "UNABLE_TO_GET_ISSUER_CERT",
2767
- "UNABLE_TO_GET_CRL",
2768
- "UNABLE_TO_DECRYPT_CERT_SIGNATURE",
2769
- "UNABLE_TO_DECRYPT_CRL_SIGNATURE",
2770
- "UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY",
2771
- "CERT_SIGNATURE_FAILURE",
2772
- "CRL_SIGNATURE_FAILURE",
2773
- "CERT_NOT_YET_VALID",
2774
- "CERT_HAS_EXPIRED",
2775
- "CRL_NOT_YET_VALID",
2776
- "CRL_HAS_EXPIRED",
2777
- "ERROR_IN_CERT_NOT_BEFORE_FIELD",
2778
- "ERROR_IN_CERT_NOT_AFTER_FIELD",
2779
- "ERROR_IN_CRL_LAST_UPDATE_FIELD",
2780
- "ERROR_IN_CRL_NEXT_UPDATE_FIELD",
2781
- "OUT_OF_MEM",
2782
- "DEPTH_ZERO_SELF_SIGNED_CERT",
2783
- "SELF_SIGNED_CERT_IN_CHAIN",
2784
- "UNABLE_TO_GET_ISSUER_CERT_LOCALLY",
2785
- "UNABLE_TO_VERIFY_LEAF_SIGNATURE",
2786
- "CERT_CHAIN_TOO_LONG",
2787
- "CERT_REVOKED",
2788
- "INVALID_CA",
2789
- "PATH_LENGTH_EXCEEDED",
2790
- "INVALID_PURPOSE",
2791
- "CERT_UNTRUSTED",
2792
- "CERT_REJECTED",
2793
- "HOSTNAME_MISMATCH"
2794
- ]);
2795
- var isRetryAllowed = (error) => !denyList.has(error && error.code);
2796
- const isRetryAllowed$1 = /* @__PURE__ */ getDefaultExportFromCjs(isRetryAllowed);
2797
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
2798
- try {
2799
- var info = gen[key](arg);
2800
- var value = info.value;
2801
- } catch (error) {
2802
- reject(error);
2803
- return;
2804
- }
2805
- if (info.done) {
2806
- resolve(value);
2807
- } else {
2808
- Promise.resolve(value).then(_next, _throw);
2809
- }
2810
- }
2811
- function _asyncToGenerator(fn) {
2812
- return function() {
2813
- var self2 = this, args = arguments;
2814
- return new Promise(function(resolve, reject) {
2815
- var gen = fn.apply(self2, args);
2816
- function _next(value) {
2817
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
2818
- }
2819
- function _throw(err) {
2820
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
2821
- }
2822
- _next(void 0);
2823
- });
2824
- };
2825
- }
2826
- function ownKeys(object, enumerableOnly) {
2827
- var keys = Object.keys(object);
2828
- if (Object.getOwnPropertySymbols) {
2829
- var symbols = Object.getOwnPropertySymbols(object);
2830
- if (enumerableOnly) {
2831
- symbols = symbols.filter(function(sym) {
2832
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
2833
- });
2834
- }
2835
- keys.push.apply(keys, symbols);
2836
- }
2837
- return keys;
2838
- }
2839
- function _objectSpread(target) {
2840
- for (var i = 1; i < arguments.length; i++) {
2841
- var source = arguments[i] != null ? arguments[i] : {};
2842
- if (i % 2) {
2843
- ownKeys(Object(source), true).forEach(function(key) {
2844
- _defineProperty(target, key, source[key]);
2845
- });
2846
- } else if (Object.getOwnPropertyDescriptors) {
2847
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
2848
- } else {
2849
- ownKeys(Object(source)).forEach(function(key) {
2850
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
2851
- });
2852
- }
2853
- }
2854
- return target;
2855
- }
2856
- function _defineProperty(obj, key, value) {
2857
- if (key in obj) {
2858
- Object.defineProperty(obj, key, { value, enumerable: true, configurable: true, writable: true });
2859
- } else {
2860
- obj[key] = value;
2861
- }
2862
- return obj;
2863
- }
2864
- var namespace = "axios-retry";
2865
- function isNetworkError(error) {
2866
- var CODE_EXCLUDE_LIST = ["ERR_CANCELED", "ECONNABORTED"];
2867
- return !error.response && Boolean(error.code) && // Prevents retrying cancelled requests
2868
- !CODE_EXCLUDE_LIST.includes(error.code) && // Prevents retrying timed out & cancelled requests
2869
- isRetryAllowed$1(error);
2870
- }
2871
- var SAFE_HTTP_METHODS = ["get", "head", "options"];
2872
- var IDEMPOTENT_HTTP_METHODS = SAFE_HTTP_METHODS.concat(["put", "delete"]);
2873
- function isRetryableError(error) {
2874
- return error.code !== "ECONNABORTED" && (!error.response || error.response.status >= 500 && error.response.status <= 599);
2875
- }
2876
- function isSafeRequestError(error) {
2877
- if (!error.config) {
2878
- return false;
2879
- }
2880
- return isRetryableError(error) && SAFE_HTTP_METHODS.indexOf(error.config.method) !== -1;
2881
- }
2882
- function isIdempotentRequestError(error) {
2883
- if (!error.config) {
2884
- return false;
2885
- }
2886
- return isRetryableError(error) && IDEMPOTENT_HTTP_METHODS.indexOf(error.config.method) !== -1;
2887
- }
2888
- function isNetworkOrIdempotentRequestError(error) {
2889
- return isNetworkError(error) || isIdempotentRequestError(error);
2890
- }
2891
- function noDelay() {
2892
- return 0;
2893
- }
2894
- function exponentialDelay() {
2895
- var retryNumber = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 0;
2896
- var delayFactor = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 100;
2897
- var delay = Math.pow(2, retryNumber) * delayFactor;
2898
- var randomSum = delay * 0.2 * Math.random();
2899
- return delay + randomSum;
2900
- }
2901
- var DEFAULT_OPTIONS = {
2902
- retries: 3,
2903
- retryCondition: isNetworkOrIdempotentRequestError,
2904
- retryDelay: noDelay,
2905
- shouldResetTimeout: false,
2906
- onRetry: () => {
2907
- }
2908
- };
2909
- function getRequestOptions(config, defaultOptions) {
2910
- return _objectSpread(_objectSpread(_objectSpread({}, DEFAULT_OPTIONS), defaultOptions), config[namespace]);
2911
- }
2912
- function getCurrentState(config, defaultOptions) {
2913
- var currentState = getRequestOptions(config, defaultOptions);
2914
- currentState.retryCount = currentState.retryCount || 0;
2915
- config[namespace] = currentState;
2916
- return currentState;
2917
- }
2918
- function fixConfig(axios2, config) {
2919
- if (axios2.defaults.agent === config.agent) {
2920
- delete config.agent;
2921
- }
2922
- if (axios2.defaults.httpAgent === config.httpAgent) {
2923
- delete config.httpAgent;
2924
- }
2925
- if (axios2.defaults.httpsAgent === config.httpsAgent) {
2926
- delete config.httpsAgent;
2927
- }
2928
- }
2929
- function shouldRetry(_x, _x2) {
2930
- return _shouldRetry.apply(this, arguments);
2931
- }
2932
- function _shouldRetry() {
2933
- _shouldRetry = _asyncToGenerator(function* (currentState, error) {
2934
- var {
2935
- retries,
2936
- retryCondition
2937
- } = currentState;
2938
- var shouldRetryOrPromise = currentState.retryCount < retries && retryCondition(error);
2939
- if (typeof shouldRetryOrPromise === "object") {
2940
- try {
2941
- var shouldRetryPromiseResult = yield shouldRetryOrPromise;
2942
- return shouldRetryPromiseResult !== false;
2943
- } catch (_err) {
2944
- return false;
2945
- }
2946
- }
2947
- return shouldRetryOrPromise;
2948
- });
2949
- return _shouldRetry.apply(this, arguments);
2950
- }
2951
- function axiosRetry(axios2, defaultOptions) {
2952
- var requestInterceptorId = axios2.interceptors.request.use((config) => {
2953
- var currentState = getCurrentState(config, defaultOptions);
2954
- currentState.lastRequestTime = Date.now();
2955
- return config;
2956
- });
2957
- var responseInterceptorId = axios2.interceptors.response.use(null, /* @__PURE__ */ function() {
2958
- var _ref = _asyncToGenerator(function* (error) {
2959
- var {
2960
- config
2961
- } = error;
2962
- if (!config) {
2963
- return Promise.reject(error);
2964
- }
2965
- var currentState = getCurrentState(config, defaultOptions);
2966
- if (yield shouldRetry(currentState, error)) {
2967
- currentState.retryCount += 1;
2968
- var {
2969
- retryDelay,
2970
- shouldResetTimeout,
2971
- onRetry
2972
- } = currentState;
2973
- var delay = retryDelay(currentState.retryCount, error);
2974
- fixConfig(axios2, config);
2975
- if (!shouldResetTimeout && config.timeout && currentState.lastRequestTime) {
2976
- var lastRequestDuration = Date.now() - currentState.lastRequestTime;
2977
- var timeout = config.timeout - lastRequestDuration - delay;
2978
- if (timeout <= 0) {
2979
- return Promise.reject(error);
2980
- }
2981
- config.timeout = timeout;
2982
- }
2983
- config.transformRequest = [(data) => data];
2984
- yield onRetry(currentState.retryCount, error, config);
2985
- return new Promise((resolve) => setTimeout(() => resolve(axios2(config)), delay));
2986
- }
2987
- return Promise.reject(error);
2988
- });
2989
- return function(_x3) {
2990
- return _ref.apply(this, arguments);
2991
- };
2992
- }());
2993
- return {
2994
- requestInterceptorId,
2995
- responseInterceptorId
2996
- };
2997
- }
2998
- axiosRetry.isNetworkError = isNetworkError;
2999
- axiosRetry.isSafeRequestError = isSafeRequestError;
3000
- axiosRetry.isIdempotentRequestError = isIdempotentRequestError;
3001
- axiosRetry.isNetworkOrIdempotentRequestError = isNetworkOrIdempotentRequestError;
3002
- axiosRetry.exponentialDelay = exponentialDelay;
3003
- axiosRetry.isRetryableError = isRetryableError;
3004
- class AxiosCache {
3005
- constructor(_axios) {
3006
- _axios.interceptors.response.use(async (res) => {
3007
- const cache = getAxiosCache();
3008
- if (res.status >= 200 && res.status < 300 && res.headers.etag) {
3009
- setAxiosCache(res.headers.etag, res.data);
3010
- }
3011
- if (res.status === 304) {
3012
- const etag = res.config.headers["If-Match"];
3013
- if (etag) {
3014
- res.data = cache[etag];
3015
- }
3016
- }
3017
- return res;
3018
- });
3019
- }
3020
- }
3021
- class AxiosClient {
3022
- constructor() {
3023
- __publicField(this, "client");
3024
- this.client = axios.create({
3025
- validateStatus: (status2) => status2 >= 200 && status2 < 300 || status2 === 304
3026
- });
3027
- new AxiosCache(this.client);
3028
- axiosRetry(this.client, {
3029
- retries: 3,
3030
- retryCondition: (err) => {
3031
- var _a, _b, _c;
3032
- return (
3033
- // Don't retry 502s, as we assume the server handles retries in those cases
3034
- isNetworkError(err) || ((_a = err == null ? void 0 : err.response) == null ? void 0 : _a.status) >= 500 && ((_b = err == null ? void 0 : err.response) == null ? void 0 : _b.status) !== 502 || ((_c = err == null ? void 0 : err.response) == null ? void 0 : _c.status) === 429
3035
- );
3036
- },
3037
- retryDelay: exponentialDelay
3038
- });
3039
- }
3040
- async fetch(url, method = "get", body, params, axiosConfig) {
3041
- var _a;
3042
- const config = {
3043
- url,
3044
- params,
3045
- method,
3046
- withCredentials: true,
3047
- data: JSON.stringify(body),
3048
- ...axiosConfig ?? {}
3049
- };
3050
- try {
3051
- const response = await this.client(config);
3052
- return [response.data, response.status, response.headers];
3053
- } catch (e) {
3054
- if (e instanceof AxiosError2 && ((_a = e.response) == null ? void 0 : _a.data)) {
3055
- return [e.response.data, e.response.status, e.response.headers];
3056
- }
3057
- throw e;
3058
- }
3059
- }
3060
- }
3061
- function normalize(strArray) {
3062
- var resultArray = [];
3063
- if (strArray.length === 0) {
3064
- return "";
3065
- }
3066
- if (typeof strArray[0] !== "string") {
3067
- throw new TypeError("Url must be a string. Received " + strArray[0]);
3068
- }
3069
- if (strArray[0].match(/^[^/:]+:\/*$/) && strArray.length > 1) {
3070
- var first = strArray.shift();
3071
- strArray[0] = first + strArray[0];
3072
- }
3073
- if (strArray[0].match(/^file:\/\/\//)) {
3074
- strArray[0] = strArray[0].replace(/^([^/:]+):\/*/, "$1:///");
3075
- } else {
3076
- strArray[0] = strArray[0].replace(/^([^/:]+):\/*/, "$1://");
3077
- }
3078
- for (var i = 0; i < strArray.length; i++) {
3079
- var component = strArray[i];
3080
- if (typeof component !== "string") {
3081
- throw new TypeError("Url must be a string. Received " + component);
3082
- }
3083
- if (component === "") {
3084
- continue;
3085
- }
3086
- if (i > 0) {
3087
- component = component.replace(/^[\/]+/, "");
3088
- }
3089
- if (i < strArray.length - 1) {
3090
- component = component.replace(/[\/]+$/, "");
3091
- } else {
3092
- component = component.replace(/[\/]+$/, "/");
3093
- }
3094
- resultArray.push(component);
3095
- }
3096
- var str = resultArray.join("/");
3097
- str = str.replace(/\/(\?|&|#[^!])/g, "$1");
3098
- var parts = str.split("?");
3099
- str = parts.shift() + (parts.length > 0 ? "?" : "") + parts.join("&");
3100
- return str;
3101
- }
3102
- function urlJoin() {
3103
- var input;
3104
- if (typeof arguments[0] === "object") {
3105
- input = arguments[0];
3106
- } else {
3107
- input = [].slice.call(arguments);
3108
- }
3109
- return normalize(input);
3110
- }
3111
- const buildName = (name) => `${MY_LOCAL_STORAGE_PREFIX}.${name}`;
3112
- const removeStored = (name) => {
3113
- localStorage.removeItem(buildName(name));
3114
- };
3115
- const setStored = (name, item) => {
3116
- localStorage.setItem(buildName(name), JSON.stringify(item));
3117
- };
3118
- const getStored = (name) => {
3119
- try {
3120
- return JSON.parse(localStorage.getItem(buildName(name)));
3121
- } catch {
3122
- return localStorage.getItem(buildName(name));
3123
- }
3124
- };
3125
- const saveLoginCredential = (loginRes) => {
3126
- if (loginRes == null ? void 0 : loginRes.app_token) {
3127
- setStored(StorageKey.APP_TOKEN, loginRes.app_token);
3128
- if (loginRes.refresh_token) {
3129
- setStored(StorageKey.REFRESH_TOKEN, loginRes.refresh_token);
3130
- setStored(StorageKey.PROVIDER, loginRes.provider);
3131
- }
3132
- return true;
3133
- }
3134
- removeStored(StorageKey.REFRESH_TOKEN);
3135
- removeStored(StorageKey.APP_TOKEN);
3136
- removeStored(StorageKey.PROVIDER);
3137
- return false;
3138
- };
3139
- const getXSRFCookie = () => {
3140
- if (document.cookie !== void 0) {
3141
- try {
3142
- return document.cookie.split("; ").find((row) => row.startsWith("XSRF-TOKEN")).split("=")[1];
3143
- } catch {
3144
- }
3145
- }
3146
- return null;
3147
- };
3148
- const client = new AxiosClient();
3149
- const api = {
3150
- auth,
3151
- configs,
3152
- lookup,
3153
- actions,
3154
- fetchers,
3155
- _static
3156
- };
3157
- const uri = () => {
3158
- return "/api/v1";
3159
- };
3160
- const format = (_uri, baseURL) => {
3161
- const path = _uri.startsWith(uri()) ? _uri : `${uri()}/${_uri.replace(/\/$/, "")}`.replace("//", "/");
3162
- return baseURL ? baseURL + path : path;
3163
- };
3164
- const joinParams = (_uri, searchParams) => {
3165
- return `${_uri}${searchParams ? `${_uri.indexOf("?") > 0 ? "&" : "?"}${searchParams.toString()}` : ""}`;
3166
- };
3167
- const joinUri = (uri1, uri2, searchParams) => {
3168
- const _uri = format(urlJoin(uri1, uri2));
3169
- return searchParams ? joinParams(_uri, searchParams) : _uri;
3170
- };
3171
- const joinAllUri = (...urlParts) => {
3172
- return urlJoin(...urlParts);
3173
- };
3174
- const hfetch = async (_uri, method = "get", body, searchParams, axiosConfig) => {
3175
- const authToken = getStored(StorageKey.APP_TOKEN);
3176
- const config = {
3177
- ...axiosConfig ?? {},
3178
- headers: {
3179
- ...(axiosConfig == null ? void 0 : axiosConfig.headers) ?? {},
3180
- "Content-Type": "application/json",
3181
- "X-XSRF-TOKEN": getXSRFCookie()
3182
- }
3183
- };
3184
- if (authToken && !config.headers.Authorization) {
3185
- config.headers.Authorization = `Bearer ${authToken}`;
3186
- }
3187
- const [json, statusCode] = await client.fetch(
3188
- format(_uri, config.baseURL),
3189
- method,
3190
- body,
3191
- searchParams,
3192
- config
3193
- );
3194
- if (!json) {
3195
- return null;
3196
- }
3197
- if (statusCode < 300 || statusCode === 304) {
3198
- return json.api_response;
3199
- }
3200
- if (statusCode === 401) {
3201
- if (!getStored(StorageKey.NEXT_LOCATION)) {
3202
- setStored(StorageKey.NEXT_LOCATION, window.location.pathname);
3203
- setStored(StorageKey.NEXT_SEARCH, window.location.search);
3204
- }
3205
- if (!_uri.includes("/auth/login") && getStored(StorageKey.REFRESH_TOKEN)) {
3206
- const refreshToken = getStored(StorageKey.REFRESH_TOKEN);
3207
- const provider = getStored(StorageKey.PROVIDER);
3208
- const refreshResponse = await api.auth.login.post({
3209
- refresh_token: refreshToken,
3210
- provider
3211
- });
3212
- if (refreshResponse) {
3213
- saveLoginCredential(refreshResponse);
3214
- const result = await hfetch(_uri, method, body, searchParams);
3215
- removeStored(StorageKey.NEXT_LOCATION);
3216
- removeStored(StorageKey.NEXT_SEARCH);
3217
- return result;
3218
- }
3219
- }
3220
- saveLoginCredential({});
3221
- return;
3222
- }
3223
- throw new Error(
3224
- json.api_error_message || json || `Error while fetching ${_uri} - ${method.toUpperCase()}`,
3225
- {
3226
- cause: json
3227
- }
3228
- );
3229
- };
3230
- const hget = (_uri, searchParams, config = {}) => {
3231
- return hfetch(_uri, "get", null, searchParams, config);
3232
- };
3233
- const hpost = (_uri, body, config = {}) => {
3234
- return hfetch(_uri, "post", body, void 0, config);
3235
- };
3236
- const useClueTypeConfig = (ready, baseURL, debugLogging, getToken, onNetworkCall) => {
3237
- const [availableSources, setAvailableSources] = useState([]);
3238
- const [typesDetection, setTypesDetection] = useState({});
3239
- const [supportedTypes, setSupportedTypes] = useState([]);
3240
- useEffect(() => {
3241
- if (!ready) {
3242
- return;
3243
- }
3244
- if ((availableSources == null ? void 0 : availableSources.length) > 0 && !isEmpty(typesDetection)) {
3245
- return;
3246
- }
3247
- const headers = {};
3248
- const token = getToken == null ? void 0 : getToken();
3249
- if (token) {
3250
- headers.Authorization = `Bearer ${token}`;
3251
- }
3252
- (async () => {
3253
- let requestConfig = { baseURL, headers };
3254
- if (onNetworkCall) {
3255
- requestConfig = onNetworkCall(requestConfig);
3256
- }
3257
- clueDebugLogger("Executing types and type detection lookup", debugLogging);
3258
- const [_typesPerSource, _typesDetections] = await Promise.all([
3259
- get$3(requestConfig),
3260
- get$2(requestConfig)
3261
- ]);
3262
- if (_typesPerSource) {
3263
- setAvailableSources(Object.keys(_typesPerSource));
3264
- setSupportedTypes(uniq(Object.values(_typesPerSource).flat()));
3265
- }
3266
- if (_typesDetections) {
3267
- setTypesDetection(
3268
- Object.entries(_typesDetections).reduce((acc, [key, regex]) => {
3269
- if (regex !== null) {
3270
- acc[key] = new RegExp(regex);
3271
- }
3272
- return acc;
3273
- }, {})
3274
- );
3275
- }
3276
- })();
3277
- }, [baseURL, ready]);
3278
- return {
3279
- availableSources,
3280
- typesDetection,
3281
- supportedTypes
3282
- };
3283
- };
3284
- export {
3285
- api as a,
3286
- useClueTypeConfig as b,
3287
- post as p,
3288
- uniq as u
3289
- };