@cccsaurora/clue-ui 0.15.0-dev.27 → 0.15.0-dev.29

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