@cccsaurora/clue-ui 1.1.1-dev.108 → 1.1.1

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