axios.js 111 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448
  1. // Axios v1.6.8 Copyright (c) 2024 Matt Zabriskie and contributors
  2. (function (global, factory) {
  3. typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
  4. typeof define === 'function' && define.amd ? define(factory) :
  5. (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.axios = factory());
  6. })(this, (function () { 'use strict';
  7. function _iterableToArrayLimit(r, l) {
  8. var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
  9. if (null != t) {
  10. var e,
  11. n,
  12. i,
  13. u,
  14. a = [],
  15. f = !0,
  16. o = !1;
  17. try {
  18. if (i = (t = t.call(r)).next, 0 === l) {
  19. if (Object(t) !== t) return;
  20. f = !1;
  21. } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
  22. } catch (r) {
  23. o = !0, n = r;
  24. } finally {
  25. try {
  26. if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
  27. } finally {
  28. if (o) throw n;
  29. }
  30. }
  31. return a;
  32. }
  33. }
  34. function ownKeys(e, r) {
  35. var t = Object.keys(e);
  36. if (Object.getOwnPropertySymbols) {
  37. var o = Object.getOwnPropertySymbols(e);
  38. r && (o = o.filter(function (r) {
  39. return Object.getOwnPropertyDescriptor(e, r).enumerable;
  40. })), t.push.apply(t, o);
  41. }
  42. return t;
  43. }
  44. function _objectSpread2(e) {
  45. for (var r = 1; r < arguments.length; r++) {
  46. var t = null != arguments[r] ? arguments[r] : {};
  47. r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
  48. _defineProperty(e, r, t[r]);
  49. }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
  50. Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
  51. });
  52. }
  53. return e;
  54. }
  55. function _regeneratorRuntime() {
  56. _regeneratorRuntime = function () {
  57. return e;
  58. };
  59. var t,
  60. e = {},
  61. r = Object.prototype,
  62. n = r.hasOwnProperty,
  63. o = Object.defineProperty || function (t, e, r) {
  64. t[e] = r.value;
  65. },
  66. i = "function" == typeof Symbol ? Symbol : {},
  67. a = i.iterator || "@@iterator",
  68. c = i.asyncIterator || "@@asyncIterator",
  69. u = i.toStringTag || "@@toStringTag";
  70. function define(t, e, r) {
  71. return Object.defineProperty(t, e, {
  72. value: r,
  73. enumerable: !0,
  74. configurable: !0,
  75. writable: !0
  76. }), t[e];
  77. }
  78. try {
  79. define({}, "");
  80. } catch (t) {
  81. define = function (t, e, r) {
  82. return t[e] = r;
  83. };
  84. }
  85. function wrap(t, e, r, n) {
  86. var i = e && e.prototype instanceof Generator ? e : Generator,
  87. a = Object.create(i.prototype),
  88. c = new Context(n || []);
  89. return o(a, "_invoke", {
  90. value: makeInvokeMethod(t, r, c)
  91. }), a;
  92. }
  93. function tryCatch(t, e, r) {
  94. try {
  95. return {
  96. type: "normal",
  97. arg: t.call(e, r)
  98. };
  99. } catch (t) {
  100. return {
  101. type: "throw",
  102. arg: t
  103. };
  104. }
  105. }
  106. e.wrap = wrap;
  107. var h = "suspendedStart",
  108. l = "suspendedYield",
  109. f = "executing",
  110. s = "completed",
  111. y = {};
  112. function Generator() {}
  113. function GeneratorFunction() {}
  114. function GeneratorFunctionPrototype() {}
  115. var p = {};
  116. define(p, a, function () {
  117. return this;
  118. });
  119. var d = Object.getPrototypeOf,
  120. v = d && d(d(values([])));
  121. v && v !== r && n.call(v, a) && (p = v);
  122. var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p);
  123. function defineIteratorMethods(t) {
  124. ["next", "throw", "return"].forEach(function (e) {
  125. define(t, e, function (t) {
  126. return this._invoke(e, t);
  127. });
  128. });
  129. }
  130. function AsyncIterator(t, e) {
  131. function invoke(r, o, i, a) {
  132. var c = tryCatch(t[r], t, o);
  133. if ("throw" !== c.type) {
  134. var u = c.arg,
  135. h = u.value;
  136. return h && "object" == typeof h && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) {
  137. invoke("next", t, i, a);
  138. }, function (t) {
  139. invoke("throw", t, i, a);
  140. }) : e.resolve(h).then(function (t) {
  141. u.value = t, i(u);
  142. }, function (t) {
  143. return invoke("throw", t, i, a);
  144. });
  145. }
  146. a(c.arg);
  147. }
  148. var r;
  149. o(this, "_invoke", {
  150. value: function (t, n) {
  151. function callInvokeWithMethodAndArg() {
  152. return new e(function (e, r) {
  153. invoke(t, n, e, r);
  154. });
  155. }
  156. return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
  157. }
  158. });
  159. }
  160. function makeInvokeMethod(e, r, n) {
  161. var o = h;
  162. return function (i, a) {
  163. if (o === f) throw new Error("Generator is already running");
  164. if (o === s) {
  165. if ("throw" === i) throw a;
  166. return {
  167. value: t,
  168. done: !0
  169. };
  170. }
  171. for (n.method = i, n.arg = a;;) {
  172. var c = n.delegate;
  173. if (c) {
  174. var u = maybeInvokeDelegate(c, n);
  175. if (u) {
  176. if (u === y) continue;
  177. return u;
  178. }
  179. }
  180. if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) {
  181. if (o === h) throw o = s, n.arg;
  182. n.dispatchException(n.arg);
  183. } else "return" === n.method && n.abrupt("return", n.arg);
  184. o = f;
  185. var p = tryCatch(e, r, n);
  186. if ("normal" === p.type) {
  187. if (o = n.done ? s : l, p.arg === y) continue;
  188. return {
  189. value: p.arg,
  190. done: n.done
  191. };
  192. }
  193. "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg);
  194. }
  195. };
  196. }
  197. function maybeInvokeDelegate(e, r) {
  198. var n = r.method,
  199. o = e.iterator[n];
  200. if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y;
  201. var i = tryCatch(o, e.iterator, r.arg);
  202. if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y;
  203. var a = i.arg;
  204. return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y);
  205. }
  206. function pushTryEntry(t) {
  207. var e = {
  208. tryLoc: t[0]
  209. };
  210. 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e);
  211. }
  212. function resetTryEntry(t) {
  213. var e = t.completion || {};
  214. e.type = "normal", delete e.arg, t.completion = e;
  215. }
  216. function Context(t) {
  217. this.tryEntries = [{
  218. tryLoc: "root"
  219. }], t.forEach(pushTryEntry, this), this.reset(!0);
  220. }
  221. function values(e) {
  222. if (e || "" === e) {
  223. var r = e[a];
  224. if (r) return r.call(e);
  225. if ("function" == typeof e.next) return e;
  226. if (!isNaN(e.length)) {
  227. var o = -1,
  228. i = function next() {
  229. for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next;
  230. return next.value = t, next.done = !0, next;
  231. };
  232. return i.next = i;
  233. }
  234. }
  235. throw new TypeError(typeof e + " is not iterable");
  236. }
  237. return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", {
  238. value: GeneratorFunctionPrototype,
  239. configurable: !0
  240. }), o(GeneratorFunctionPrototype, "constructor", {
  241. value: GeneratorFunction,
  242. configurable: !0
  243. }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) {
  244. var e = "function" == typeof t && t.constructor;
  245. return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name));
  246. }, e.mark = function (t) {
  247. return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t;
  248. }, e.awrap = function (t) {
  249. return {
  250. __await: t
  251. };
  252. }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () {
  253. return this;
  254. }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) {
  255. void 0 === i && (i = Promise);
  256. var a = new AsyncIterator(wrap(t, r, n, o), i);
  257. return e.isGeneratorFunction(r) ? a : a.next().then(function (t) {
  258. return t.done ? t.value : a.next();
  259. });
  260. }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () {
  261. return this;
  262. }), define(g, "toString", function () {
  263. return "[object Generator]";
  264. }), e.keys = function (t) {
  265. var e = Object(t),
  266. r = [];
  267. for (var n in e) r.push(n);
  268. return r.reverse(), function next() {
  269. for (; r.length;) {
  270. var t = r.pop();
  271. if (t in e) return next.value = t, next.done = !1, next;
  272. }
  273. return next.done = !0, next;
  274. };
  275. }, e.values = values, Context.prototype = {
  276. constructor: Context,
  277. reset: function (e) {
  278. if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t);
  279. },
  280. stop: function () {
  281. this.done = !0;
  282. var t = this.tryEntries[0].completion;
  283. if ("throw" === t.type) throw t.arg;
  284. return this.rval;
  285. },
  286. dispatchException: function (e) {
  287. if (this.done) throw e;
  288. var r = this;
  289. function handle(n, o) {
  290. return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o;
  291. }
  292. for (var o = this.tryEntries.length - 1; o >= 0; --o) {
  293. var i = this.tryEntries[o],
  294. a = i.completion;
  295. if ("root" === i.tryLoc) return handle("end");
  296. if (i.tryLoc <= this.prev) {
  297. var c = n.call(i, "catchLoc"),
  298. u = n.call(i, "finallyLoc");
  299. if (c && u) {
  300. if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
  301. if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
  302. } else if (c) {
  303. if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
  304. } else {
  305. if (!u) throw new Error("try statement without catch or finally");
  306. if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
  307. }
  308. }
  309. }
  310. },
  311. abrupt: function (t, e) {
  312. for (var r = this.tryEntries.length - 1; r >= 0; --r) {
  313. var o = this.tryEntries[r];
  314. if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) {
  315. var i = o;
  316. break;
  317. }
  318. }
  319. i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null);
  320. var a = i ? i.completion : {};
  321. return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a);
  322. },
  323. complete: function (t, e) {
  324. if ("throw" === t.type) throw t.arg;
  325. return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y;
  326. },
  327. finish: function (t) {
  328. for (var e = this.tryEntries.length - 1; e >= 0; --e) {
  329. var r = this.tryEntries[e];
  330. if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y;
  331. }
  332. },
  333. catch: function (t) {
  334. for (var e = this.tryEntries.length - 1; e >= 0; --e) {
  335. var r = this.tryEntries[e];
  336. if (r.tryLoc === t) {
  337. var n = r.completion;
  338. if ("throw" === n.type) {
  339. var o = n.arg;
  340. resetTryEntry(r);
  341. }
  342. return o;
  343. }
  344. }
  345. throw new Error("illegal catch attempt");
  346. },
  347. delegateYield: function (e, r, n) {
  348. return this.delegate = {
  349. iterator: values(e),
  350. resultName: r,
  351. nextLoc: n
  352. }, "next" === this.method && (this.arg = t), y;
  353. }
  354. }, e;
  355. }
  356. function _toPrimitive(t, r) {
  357. if ("object" != typeof t || !t) return t;
  358. var e = t[Symbol.toPrimitive];
  359. if (void 0 !== e) {
  360. var i = e.call(t, r || "default");
  361. if ("object" != typeof i) return i;
  362. throw new TypeError("@@toPrimitive must return a primitive value.");
  363. }
  364. return ("string" === r ? String : Number)(t);
  365. }
  366. function _toPropertyKey(t) {
  367. var i = _toPrimitive(t, "string");
  368. return "symbol" == typeof i ? i : String(i);
  369. }
  370. function _typeof(o) {
  371. "@babel/helpers - typeof";
  372. return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
  373. return typeof o;
  374. } : function (o) {
  375. return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
  376. }, _typeof(o);
  377. }
  378. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
  379. try {
  380. var info = gen[key](arg);
  381. var value = info.value;
  382. } catch (error) {
  383. reject(error);
  384. return;
  385. }
  386. if (info.done) {
  387. resolve(value);
  388. } else {
  389. Promise.resolve(value).then(_next, _throw);
  390. }
  391. }
  392. function _asyncToGenerator(fn) {
  393. return function () {
  394. var self = this,
  395. args = arguments;
  396. return new Promise(function (resolve, reject) {
  397. var gen = fn.apply(self, args);
  398. function _next(value) {
  399. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
  400. }
  401. function _throw(err) {
  402. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
  403. }
  404. _next(undefined);
  405. });
  406. };
  407. }
  408. function _classCallCheck(instance, Constructor) {
  409. if (!(instance instanceof Constructor)) {
  410. throw new TypeError("Cannot call a class as a function");
  411. }
  412. }
  413. function _defineProperties(target, props) {
  414. for (var i = 0; i < props.length; i++) {
  415. var descriptor = props[i];
  416. descriptor.enumerable = descriptor.enumerable || false;
  417. descriptor.configurable = true;
  418. if ("value" in descriptor) descriptor.writable = true;
  419. Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
  420. }
  421. }
  422. function _createClass(Constructor, protoProps, staticProps) {
  423. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  424. if (staticProps) _defineProperties(Constructor, staticProps);
  425. Object.defineProperty(Constructor, "prototype", {
  426. writable: false
  427. });
  428. return Constructor;
  429. }
  430. function _defineProperty(obj, key, value) {
  431. key = _toPropertyKey(key);
  432. if (key in obj) {
  433. Object.defineProperty(obj, key, {
  434. value: value,
  435. enumerable: true,
  436. configurable: true,
  437. writable: true
  438. });
  439. } else {
  440. obj[key] = value;
  441. }
  442. return obj;
  443. }
  444. function _slicedToArray(arr, i) {
  445. return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
  446. }
  447. function _toArray(arr) {
  448. return _arrayWithHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableRest();
  449. }
  450. function _toConsumableArray(arr) {
  451. return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
  452. }
  453. function _arrayWithoutHoles(arr) {
  454. if (Array.isArray(arr)) return _arrayLikeToArray(arr);
  455. }
  456. function _arrayWithHoles(arr) {
  457. if (Array.isArray(arr)) return arr;
  458. }
  459. function _iterableToArray(iter) {
  460. if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
  461. }
  462. function _unsupportedIterableToArray(o, minLen) {
  463. if (!o) return;
  464. if (typeof o === "string") return _arrayLikeToArray(o, minLen);
  465. var n = Object.prototype.toString.call(o).slice(8, -1);
  466. if (n === "Object" && o.constructor) n = o.constructor.name;
  467. if (n === "Map" || n === "Set") return Array.from(o);
  468. if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
  469. }
  470. function _arrayLikeToArray(arr, len) {
  471. if (len == null || len > arr.length) len = arr.length;
  472. for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
  473. return arr2;
  474. }
  475. function _nonIterableSpread() {
  476. throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  477. }
  478. function _nonIterableRest() {
  479. throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  480. }
  481. function bind(fn, thisArg) {
  482. return function wrap() {
  483. return fn.apply(thisArg, arguments);
  484. };
  485. }
  486. // utils is a library of generic helper functions non-specific to axios
  487. var toString = Object.prototype.toString;
  488. var getPrototypeOf = Object.getPrototypeOf;
  489. var kindOf = function (cache) {
  490. return function (thing) {
  491. var str = toString.call(thing);
  492. return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase());
  493. };
  494. }(Object.create(null));
  495. var kindOfTest = function kindOfTest(type) {
  496. type = type.toLowerCase();
  497. return function (thing) {
  498. return kindOf(thing) === type;
  499. };
  500. };
  501. var typeOfTest = function typeOfTest(type) {
  502. return function (thing) {
  503. return _typeof(thing) === type;
  504. };
  505. };
  506. /**
  507. * Determine if a value is an Array
  508. *
  509. * @param {Object} val The value to test
  510. *
  511. * @returns {boolean} True if value is an Array, otherwise false
  512. */
  513. var isArray = Array.isArray;
  514. /**
  515. * Determine if a value is undefined
  516. *
  517. * @param {*} val The value to test
  518. *
  519. * @returns {boolean} True if the value is undefined, otherwise false
  520. */
  521. var isUndefined = typeOfTest('undefined');
  522. /**
  523. * Determine if a value is a Buffer
  524. *
  525. * @param {*} val The value to test
  526. *
  527. * @returns {boolean} True if value is a Buffer, otherwise false
  528. */
  529. function isBuffer(val) {
  530. return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor) && isFunction(val.constructor.isBuffer) && val.constructor.isBuffer(val);
  531. }
  532. /**
  533. * Determine if a value is an ArrayBuffer
  534. *
  535. * @param {*} val The value to test
  536. *
  537. * @returns {boolean} True if value is an ArrayBuffer, otherwise false
  538. */
  539. var isArrayBuffer = kindOfTest('ArrayBuffer');
  540. /**
  541. * Determine if a value is a view on an ArrayBuffer
  542. *
  543. * @param {*} val The value to test
  544. *
  545. * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false
  546. */
  547. function isArrayBufferView(val) {
  548. var result;
  549. if (typeof ArrayBuffer !== 'undefined' && ArrayBuffer.isView) {
  550. result = ArrayBuffer.isView(val);
  551. } else {
  552. result = val && val.buffer && isArrayBuffer(val.buffer);
  553. }
  554. return result;
  555. }
  556. /**
  557. * Determine if a value is a String
  558. *
  559. * @param {*} val The value to test
  560. *
  561. * @returns {boolean} True if value is a String, otherwise false
  562. */
  563. var isString = typeOfTest('string');
  564. /**
  565. * Determine if a value is a Function
  566. *
  567. * @param {*} val The value to test
  568. * @returns {boolean} True if value is a Function, otherwise false
  569. */
  570. var isFunction = typeOfTest('function');
  571. /**
  572. * Determine if a value is a Number
  573. *
  574. * @param {*} val The value to test
  575. *
  576. * @returns {boolean} True if value is a Number, otherwise false
  577. */
  578. var isNumber = typeOfTest('number');
  579. /**
  580. * Determine if a value is an Object
  581. *
  582. * @param {*} thing The value to test
  583. *
  584. * @returns {boolean} True if value is an Object, otherwise false
  585. */
  586. var isObject = function isObject(thing) {
  587. return thing !== null && _typeof(thing) === 'object';
  588. };
  589. /**
  590. * Determine if a value is a Boolean
  591. *
  592. * @param {*} thing The value to test
  593. * @returns {boolean} True if value is a Boolean, otherwise false
  594. */
  595. var isBoolean = function isBoolean(thing) {
  596. return thing === true || thing === false;
  597. };
  598. /**
  599. * Determine if a value is a plain Object
  600. *
  601. * @param {*} val The value to test
  602. *
  603. * @returns {boolean} True if value is a plain Object, otherwise false
  604. */
  605. var isPlainObject = function isPlainObject(val) {
  606. if (kindOf(val) !== 'object') {
  607. return false;
  608. }
  609. var prototype = getPrototypeOf(val);
  610. return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(Symbol.toStringTag in val) && !(Symbol.iterator in val);
  611. };
  612. /**
  613. * Determine if a value is a Date
  614. *
  615. * @param {*} val The value to test
  616. *
  617. * @returns {boolean} True if value is a Date, otherwise false
  618. */
  619. var isDate = kindOfTest('Date');
  620. /**
  621. * Determine if a value is a File
  622. *
  623. * @param {*} val The value to test
  624. *
  625. * @returns {boolean} True if value is a File, otherwise false
  626. */
  627. var isFile = kindOfTest('File');
  628. /**
  629. * Determine if a value is a Blob
  630. *
  631. * @param {*} val The value to test
  632. *
  633. * @returns {boolean} True if value is a Blob, otherwise false
  634. */
  635. var isBlob = kindOfTest('Blob');
  636. /**
  637. * Determine if a value is a FileList
  638. *
  639. * @param {*} val The value to test
  640. *
  641. * @returns {boolean} True if value is a File, otherwise false
  642. */
  643. var isFileList = kindOfTest('FileList');
  644. /**
  645. * Determine if a value is a Stream
  646. *
  647. * @param {*} val The value to test
  648. *
  649. * @returns {boolean} True if value is a Stream, otherwise false
  650. */
  651. var isStream = function isStream(val) {
  652. return isObject(val) && isFunction(val.pipe);
  653. };
  654. /**
  655. * Determine if a value is a FormData
  656. *
  657. * @param {*} thing The value to test
  658. *
  659. * @returns {boolean} True if value is an FormData, otherwise false
  660. */
  661. var isFormData = function isFormData(thing) {
  662. var kind;
  663. return thing && (typeof FormData === 'function' && thing instanceof FormData || isFunction(thing.append) && ((kind = kindOf(thing)) === 'formdata' ||
  664. // detect form-data instance
  665. kind === 'object' && isFunction(thing.toString) && thing.toString() === '[object FormData]'));
  666. };
  667. /**
  668. * Determine if a value is a URLSearchParams object
  669. *
  670. * @param {*} val The value to test
  671. *
  672. * @returns {boolean} True if value is a URLSearchParams object, otherwise false
  673. */
  674. var isURLSearchParams = kindOfTest('URLSearchParams');
  675. /**
  676. * Trim excess whitespace off the beginning and end of a string
  677. *
  678. * @param {String} str The String to trim
  679. *
  680. * @returns {String} The String freed of excess whitespace
  681. */
  682. var trim = function trim(str) {
  683. return str.trim ? str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
  684. };
  685. /**
  686. * Iterate over an Array or an Object invoking a function for each item.
  687. *
  688. * If `obj` is an Array callback will be called passing
  689. * the value, index, and complete array for each item.
  690. *
  691. * If 'obj' is an Object callback will be called passing
  692. * the value, key, and complete object for each property.
  693. *
  694. * @param {Object|Array} obj The object to iterate
  695. * @param {Function} fn The callback to invoke for each item
  696. *
  697. * @param {Boolean} [allOwnKeys = false]
  698. * @returns {any}
  699. */
  700. function forEach(obj, fn) {
  701. var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
  702. _ref$allOwnKeys = _ref.allOwnKeys,
  703. allOwnKeys = _ref$allOwnKeys === void 0 ? false : _ref$allOwnKeys;
  704. // Don't bother if no value provided
  705. if (obj === null || typeof obj === 'undefined') {
  706. return;
  707. }
  708. var i;
  709. var l;
  710. // Force an array if not already something iterable
  711. if (_typeof(obj) !== 'object') {
  712. /*eslint no-param-reassign:0*/
  713. obj = [obj];
  714. }
  715. if (isArray(obj)) {
  716. // Iterate over array values
  717. for (i = 0, l = obj.length; i < l; i++) {
  718. fn.call(null, obj[i], i, obj);
  719. }
  720. } else {
  721. // Iterate over object keys
  722. var keys = allOwnKeys ? Object.getOwnPropertyNames(obj) : Object.keys(obj);
  723. var len = keys.length;
  724. var key;
  725. for (i = 0; i < len; i++) {
  726. key = keys[i];
  727. fn.call(null, obj[key], key, obj);
  728. }
  729. }
  730. }
  731. function findKey(obj, key) {
  732. key = key.toLowerCase();
  733. var keys = Object.keys(obj);
  734. var i = keys.length;
  735. var _key;
  736. while (i-- > 0) {
  737. _key = keys[i];
  738. if (key === _key.toLowerCase()) {
  739. return _key;
  740. }
  741. }
  742. return null;
  743. }
  744. var _global = function () {
  745. /*eslint no-undef:0*/
  746. if (typeof globalThis !== "undefined") return globalThis;
  747. return typeof self !== "undefined" ? self : typeof window !== 'undefined' ? window : global;
  748. }();
  749. var isContextDefined = function isContextDefined(context) {
  750. return !isUndefined(context) && context !== _global;
  751. };
  752. /**
  753. * Accepts varargs expecting each argument to be an object, then
  754. * immutably merges the properties of each object and returns result.
  755. *
  756. * When multiple objects contain the same key the later object in
  757. * the arguments list will take precedence.
  758. *
  759. * Example:
  760. *
  761. * ```js
  762. * var result = merge({foo: 123}, {foo: 456});
  763. * console.log(result.foo); // outputs 456
  764. * ```
  765. *
  766. * @param {Object} obj1 Object to merge
  767. *
  768. * @returns {Object} Result of all merge properties
  769. */
  770. function merge( /* obj1, obj2, obj3, ... */
  771. ) {
  772. var _ref2 = isContextDefined(this) && this || {},
  773. caseless = _ref2.caseless;
  774. var result = {};
  775. var assignValue = function assignValue(val, key) {
  776. var targetKey = caseless && findKey(result, key) || key;
  777. if (isPlainObject(result[targetKey]) && isPlainObject(val)) {
  778. result[targetKey] = merge(result[targetKey], val);
  779. } else if (isPlainObject(val)) {
  780. result[targetKey] = merge({}, val);
  781. } else if (isArray(val)) {
  782. result[targetKey] = val.slice();
  783. } else {
  784. result[targetKey] = val;
  785. }
  786. };
  787. for (var i = 0, l = arguments.length; i < l; i++) {
  788. arguments[i] && forEach(arguments[i], assignValue);
  789. }
  790. return result;
  791. }
  792. /**
  793. * Extends object a by mutably adding to it the properties of object b.
  794. *
  795. * @param {Object} a The object to be extended
  796. * @param {Object} b The object to copy properties from
  797. * @param {Object} thisArg The object to bind function to
  798. *
  799. * @param {Boolean} [allOwnKeys]
  800. * @returns {Object} The resulting value of object a
  801. */
  802. var extend = function extend(a, b, thisArg) {
  803. var _ref3 = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {},
  804. allOwnKeys = _ref3.allOwnKeys;
  805. forEach(b, function (val, key) {
  806. if (thisArg && isFunction(val)) {
  807. a[key] = bind(val, thisArg);
  808. } else {
  809. a[key] = val;
  810. }
  811. }, {
  812. allOwnKeys: allOwnKeys
  813. });
  814. return a;
  815. };
  816. /**
  817. * Remove byte order marker. This catches EF BB BF (the UTF-8 BOM)
  818. *
  819. * @param {string} content with BOM
  820. *
  821. * @returns {string} content value without BOM
  822. */
  823. var stripBOM = function stripBOM(content) {
  824. if (content.charCodeAt(0) === 0xFEFF) {
  825. content = content.slice(1);
  826. }
  827. return content;
  828. };
  829. /**
  830. * Inherit the prototype methods from one constructor into another
  831. * @param {function} constructor
  832. * @param {function} superConstructor
  833. * @param {object} [props]
  834. * @param {object} [descriptors]
  835. *
  836. * @returns {void}
  837. */
  838. var inherits = function inherits(constructor, superConstructor, props, descriptors) {
  839. constructor.prototype = Object.create(superConstructor.prototype, descriptors);
  840. constructor.prototype.constructor = constructor;
  841. Object.defineProperty(constructor, 'super', {
  842. value: superConstructor.prototype
  843. });
  844. props && Object.assign(constructor.prototype, props);
  845. };
  846. /**
  847. * Resolve object with deep prototype chain to a flat object
  848. * @param {Object} sourceObj source object
  849. * @param {Object} [destObj]
  850. * @param {Function|Boolean} [filter]
  851. * @param {Function} [propFilter]
  852. *
  853. * @returns {Object}
  854. */
  855. var toFlatObject = function toFlatObject(sourceObj, destObj, filter, propFilter) {
  856. var props;
  857. var i;
  858. var prop;
  859. var merged = {};
  860. destObj = destObj || {};
  861. // eslint-disable-next-line no-eq-null,eqeqeq
  862. if (sourceObj == null) return destObj;
  863. do {
  864. props = Object.getOwnPropertyNames(sourceObj);
  865. i = props.length;
  866. while (i-- > 0) {
  867. prop = props[i];
  868. if ((!propFilter || propFilter(prop, sourceObj, destObj)) && !merged[prop]) {
  869. destObj[prop] = sourceObj[prop];
  870. merged[prop] = true;
  871. }
  872. }
  873. sourceObj = filter !== false && getPrototypeOf(sourceObj);
  874. } while (sourceObj && (!filter || filter(sourceObj, destObj)) && sourceObj !== Object.prototype);
  875. return destObj;
  876. };
  877. /**
  878. * Determines whether a string ends with the characters of a specified string
  879. *
  880. * @param {String} str
  881. * @param {String} searchString
  882. * @param {Number} [position= 0]
  883. *
  884. * @returns {boolean}
  885. */
  886. var endsWith = function endsWith(str, searchString, position) {
  887. str = String(str);
  888. if (position === undefined || position > str.length) {
  889. position = str.length;
  890. }
  891. position -= searchString.length;
  892. var lastIndex = str.indexOf(searchString, position);
  893. return lastIndex !== -1 && lastIndex === position;
  894. };
  895. /**
  896. * Returns new array from array like object or null if failed
  897. *
  898. * @param {*} [thing]
  899. *
  900. * @returns {?Array}
  901. */
  902. var toArray = function toArray(thing) {
  903. if (!thing) return null;
  904. if (isArray(thing)) return thing;
  905. var i = thing.length;
  906. if (!isNumber(i)) return null;
  907. var arr = new Array(i);
  908. while (i-- > 0) {
  909. arr[i] = thing[i];
  910. }
  911. return arr;
  912. };
  913. /**
  914. * Checking if the Uint8Array exists and if it does, it returns a function that checks if the
  915. * thing passed in is an instance of Uint8Array
  916. *
  917. * @param {TypedArray}
  918. *
  919. * @returns {Array}
  920. */
  921. // eslint-disable-next-line func-names
  922. var isTypedArray = function (TypedArray) {
  923. // eslint-disable-next-line func-names
  924. return function (thing) {
  925. return TypedArray && thing instanceof TypedArray;
  926. };
  927. }(typeof Uint8Array !== 'undefined' && getPrototypeOf(Uint8Array));
  928. /**
  929. * For each entry in the object, call the function with the key and value.
  930. *
  931. * @param {Object<any, any>} obj - The object to iterate over.
  932. * @param {Function} fn - The function to call for each entry.
  933. *
  934. * @returns {void}
  935. */
  936. var forEachEntry = function forEachEntry(obj, fn) {
  937. var generator = obj && obj[Symbol.iterator];
  938. var iterator = generator.call(obj);
  939. var result;
  940. while ((result = iterator.next()) && !result.done) {
  941. var pair = result.value;
  942. fn.call(obj, pair[0], pair[1]);
  943. }
  944. };
  945. /**
  946. * It takes a regular expression and a string, and returns an array of all the matches
  947. *
  948. * @param {string} regExp - The regular expression to match against.
  949. * @param {string} str - The string to search.
  950. *
  951. * @returns {Array<boolean>}
  952. */
  953. var matchAll = function matchAll(regExp, str) {
  954. var matches;
  955. var arr = [];
  956. while ((matches = regExp.exec(str)) !== null) {
  957. arr.push(matches);
  958. }
  959. return arr;
  960. };
  961. /* Checking if the kindOfTest function returns true when passed an HTMLFormElement. */
  962. var isHTMLForm = kindOfTest('HTMLFormElement');
  963. var toCamelCase = function toCamelCase(str) {
  964. return str.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g, function replacer(m, p1, p2) {
  965. return p1.toUpperCase() + p2;
  966. });
  967. };
  968. /* Creating a function that will check if an object has a property. */
  969. var hasOwnProperty = function (_ref4) {
  970. var hasOwnProperty = _ref4.hasOwnProperty;
  971. return function (obj, prop) {
  972. return hasOwnProperty.call(obj, prop);
  973. };
  974. }(Object.prototype);
  975. /**
  976. * Determine if a value is a RegExp object
  977. *
  978. * @param {*} val The value to test
  979. *
  980. * @returns {boolean} True if value is a RegExp object, otherwise false
  981. */
  982. var isRegExp = kindOfTest('RegExp');
  983. var reduceDescriptors = function reduceDescriptors(obj, reducer) {
  984. var descriptors = Object.getOwnPropertyDescriptors(obj);
  985. var reducedDescriptors = {};
  986. forEach(descriptors, function (descriptor, name) {
  987. var ret;
  988. if ((ret = reducer(descriptor, name, obj)) !== false) {
  989. reducedDescriptors[name] = ret || descriptor;
  990. }
  991. });
  992. Object.defineProperties(obj, reducedDescriptors);
  993. };
  994. /**
  995. * Makes all methods read-only
  996. * @param {Object} obj
  997. */
  998. var freezeMethods = function freezeMethods(obj) {
  999. reduceDescriptors(obj, function (descriptor, name) {
  1000. // skip restricted props in strict mode
  1001. if (isFunction(obj) && ['arguments', 'caller', 'callee'].indexOf(name) !== -1) {
  1002. return false;
  1003. }
  1004. var value = obj[name];
  1005. if (!isFunction(value)) return;
  1006. descriptor.enumerable = false;
  1007. if ('writable' in descriptor) {
  1008. descriptor.writable = false;
  1009. return;
  1010. }
  1011. if (!descriptor.set) {
  1012. descriptor.set = function () {
  1013. throw Error('Can not rewrite read-only method \'' + name + '\'');
  1014. };
  1015. }
  1016. });
  1017. };
  1018. var toObjectSet = function toObjectSet(arrayOrString, delimiter) {
  1019. var obj = {};
  1020. var define = function define(arr) {
  1021. arr.forEach(function (value) {
  1022. obj[value] = true;
  1023. });
  1024. };
  1025. isArray(arrayOrString) ? define(arrayOrString) : define(String(arrayOrString).split(delimiter));
  1026. return obj;
  1027. };
  1028. var noop = function noop() {};
  1029. var toFiniteNumber = function toFiniteNumber(value, defaultValue) {
  1030. value = +value;
  1031. return Number.isFinite(value) ? value : defaultValue;
  1032. };
  1033. var ALPHA = 'abcdefghijklmnopqrstuvwxyz';
  1034. var DIGIT = '0123456789';
  1035. var ALPHABET = {
  1036. DIGIT: DIGIT,
  1037. ALPHA: ALPHA,
  1038. ALPHA_DIGIT: ALPHA + ALPHA.toUpperCase() + DIGIT
  1039. };
  1040. var generateString = function generateString() {
  1041. var size = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 16;
  1042. var alphabet = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ALPHABET.ALPHA_DIGIT;
  1043. var str = '';
  1044. var length = alphabet.length;
  1045. while (size--) {
  1046. str += alphabet[Math.random() * length | 0];
  1047. }
  1048. return str;
  1049. };
  1050. /**
  1051. * If the thing is a FormData object, return true, otherwise return false.
  1052. *
  1053. * @param {unknown} thing - The thing to check.
  1054. *
  1055. * @returns {boolean}
  1056. */
  1057. function isSpecCompliantForm(thing) {
  1058. return !!(thing && isFunction(thing.append) && thing[Symbol.toStringTag] === 'FormData' && thing[Symbol.iterator]);
  1059. }
  1060. var toJSONObject = function toJSONObject(obj) {
  1061. var stack = new Array(10);
  1062. var visit = function visit(source, i) {
  1063. if (isObject(source)) {
  1064. if (stack.indexOf(source) >= 0) {
  1065. return;
  1066. }
  1067. if (!('toJSON' in source)) {
  1068. stack[i] = source;
  1069. var target = isArray(source) ? [] : {};
  1070. forEach(source, function (value, key) {
  1071. var reducedValue = visit(value, i + 1);
  1072. !isUndefined(reducedValue) && (target[key] = reducedValue);
  1073. });
  1074. stack[i] = undefined;
  1075. return target;
  1076. }
  1077. }
  1078. return source;
  1079. };
  1080. return visit(obj, 0);
  1081. };
  1082. var isAsyncFn = kindOfTest('AsyncFunction');
  1083. var isThenable = function isThenable(thing) {
  1084. return thing && (isObject(thing) || isFunction(thing)) && isFunction(thing.then) && isFunction(thing["catch"]);
  1085. };
  1086. var utils$1 = {
  1087. isArray: isArray,
  1088. isArrayBuffer: isArrayBuffer,
  1089. isBuffer: isBuffer,
  1090. isFormData: isFormData,
  1091. isArrayBufferView: isArrayBufferView,
  1092. isString: isString,
  1093. isNumber: isNumber,
  1094. isBoolean: isBoolean,
  1095. isObject: isObject,
  1096. isPlainObject: isPlainObject,
  1097. isUndefined: isUndefined,
  1098. isDate: isDate,
  1099. isFile: isFile,
  1100. isBlob: isBlob,
  1101. isRegExp: isRegExp,
  1102. isFunction: isFunction,
  1103. isStream: isStream,
  1104. isURLSearchParams: isURLSearchParams,
  1105. isTypedArray: isTypedArray,
  1106. isFileList: isFileList,
  1107. forEach: forEach,
  1108. merge: merge,
  1109. extend: extend,
  1110. trim: trim,
  1111. stripBOM: stripBOM,
  1112. inherits: inherits,
  1113. toFlatObject: toFlatObject,
  1114. kindOf: kindOf,
  1115. kindOfTest: kindOfTest,
  1116. endsWith: endsWith,
  1117. toArray: toArray,
  1118. forEachEntry: forEachEntry,
  1119. matchAll: matchAll,
  1120. isHTMLForm: isHTMLForm,
  1121. hasOwnProperty: hasOwnProperty,
  1122. hasOwnProp: hasOwnProperty,
  1123. // an alias to avoid ESLint no-prototype-builtins detection
  1124. reduceDescriptors: reduceDescriptors,
  1125. freezeMethods: freezeMethods,
  1126. toObjectSet: toObjectSet,
  1127. toCamelCase: toCamelCase,
  1128. noop: noop,
  1129. toFiniteNumber: toFiniteNumber,
  1130. findKey: findKey,
  1131. global: _global,
  1132. isContextDefined: isContextDefined,
  1133. ALPHABET: ALPHABET,
  1134. generateString: generateString,
  1135. isSpecCompliantForm: isSpecCompliantForm,
  1136. toJSONObject: toJSONObject,
  1137. isAsyncFn: isAsyncFn,
  1138. isThenable: isThenable
  1139. };
  1140. /**
  1141. * Create an Error with the specified message, config, error code, request and response.
  1142. *
  1143. * @param {string} message The error message.
  1144. * @param {string} [code] The error code (for example, 'ECONNABORTED').
  1145. * @param {Object} [config] The config.
  1146. * @param {Object} [request] The request.
  1147. * @param {Object} [response] The response.
  1148. *
  1149. * @returns {Error} The created error.
  1150. */
  1151. function AxiosError(message, code, config, request, response) {
  1152. Error.call(this);
  1153. if (Error.captureStackTrace) {
  1154. Error.captureStackTrace(this, this.constructor);
  1155. } else {
  1156. this.stack = new Error().stack;
  1157. }
  1158. this.message = message;
  1159. this.name = 'AxiosError';
  1160. code && (this.code = code);
  1161. config && (this.config = config);
  1162. request && (this.request = request);
  1163. response && (this.response = response);
  1164. }
  1165. utils$1.inherits(AxiosError, Error, {
  1166. toJSON: function toJSON() {
  1167. return {
  1168. // Standard
  1169. message: this.message,
  1170. name: this.name,
  1171. // Microsoft
  1172. description: this.description,
  1173. number: this.number,
  1174. // Mozilla
  1175. fileName: this.fileName,
  1176. lineNumber: this.lineNumber,
  1177. columnNumber: this.columnNumber,
  1178. stack: this.stack,
  1179. // Axios
  1180. config: utils$1.toJSONObject(this.config),
  1181. code: this.code,
  1182. status: this.response && this.response.status ? this.response.status : null
  1183. };
  1184. }
  1185. });
  1186. var prototype$1 = AxiosError.prototype;
  1187. var descriptors = {};
  1188. ['ERR_BAD_OPTION_VALUE', 'ERR_BAD_OPTION', 'ECONNABORTED', 'ETIMEDOUT', 'ERR_NETWORK', 'ERR_FR_TOO_MANY_REDIRECTS', 'ERR_DEPRECATED', 'ERR_BAD_RESPONSE', 'ERR_BAD_REQUEST', 'ERR_CANCELED', 'ERR_NOT_SUPPORT', 'ERR_INVALID_URL'
  1189. // eslint-disable-next-line func-names
  1190. ].forEach(function (code) {
  1191. descriptors[code] = {
  1192. value: code
  1193. };
  1194. });
  1195. Object.defineProperties(AxiosError, descriptors);
  1196. Object.defineProperty(prototype$1, 'isAxiosError', {
  1197. value: true
  1198. });
  1199. // eslint-disable-next-line func-names
  1200. AxiosError.from = function (error, code, config, request, response, customProps) {
  1201. var axiosError = Object.create(prototype$1);
  1202. utils$1.toFlatObject(error, axiosError, function filter(obj) {
  1203. return obj !== Error.prototype;
  1204. }, function (prop) {
  1205. return prop !== 'isAxiosError';
  1206. });
  1207. AxiosError.call(axiosError, error.message, code, config, request, response);
  1208. axiosError.cause = error;
  1209. axiosError.name = error.name;
  1210. customProps && Object.assign(axiosError, customProps);
  1211. return axiosError;
  1212. };
  1213. // eslint-disable-next-line strict
  1214. var httpAdapter = null;
  1215. /**
  1216. * Determines if the given thing is a array or js object.
  1217. *
  1218. * @param {string} thing - The object or array to be visited.
  1219. *
  1220. * @returns {boolean}
  1221. */
  1222. function isVisitable(thing) {
  1223. return utils$1.isPlainObject(thing) || utils$1.isArray(thing);
  1224. }
  1225. /**
  1226. * It removes the brackets from the end of a string
  1227. *
  1228. * @param {string} key - The key of the parameter.
  1229. *
  1230. * @returns {string} the key without the brackets.
  1231. */
  1232. function removeBrackets(key) {
  1233. return utils$1.endsWith(key, '[]') ? key.slice(0, -2) : key;
  1234. }
  1235. /**
  1236. * It takes a path, a key, and a boolean, and returns a string
  1237. *
  1238. * @param {string} path - The path to the current key.
  1239. * @param {string} key - The key of the current object being iterated over.
  1240. * @param {string} dots - If true, the key will be rendered with dots instead of brackets.
  1241. *
  1242. * @returns {string} The path to the current key.
  1243. */
  1244. function renderKey(path, key, dots) {
  1245. if (!path) return key;
  1246. return path.concat(key).map(function each(token, i) {
  1247. // eslint-disable-next-line no-param-reassign
  1248. token = removeBrackets(token);
  1249. return !dots && i ? '[' + token + ']' : token;
  1250. }).join(dots ? '.' : '');
  1251. }
  1252. /**
  1253. * If the array is an array and none of its elements are visitable, then it's a flat array.
  1254. *
  1255. * @param {Array<any>} arr - The array to check
  1256. *
  1257. * @returns {boolean}
  1258. */
  1259. function isFlatArray(arr) {
  1260. return utils$1.isArray(arr) && !arr.some(isVisitable);
  1261. }
  1262. var predicates = utils$1.toFlatObject(utils$1, {}, null, function filter(prop) {
  1263. return /^is[A-Z]/.test(prop);
  1264. });
  1265. /**
  1266. * Convert a data object to FormData
  1267. *
  1268. * @param {Object} obj
  1269. * @param {?Object} [formData]
  1270. * @param {?Object} [options]
  1271. * @param {Function} [options.visitor]
  1272. * @param {Boolean} [options.metaTokens = true]
  1273. * @param {Boolean} [options.dots = false]
  1274. * @param {?Boolean} [options.indexes = false]
  1275. *
  1276. * @returns {Object}
  1277. **/
  1278. /**
  1279. * It converts an object into a FormData object
  1280. *
  1281. * @param {Object<any, any>} obj - The object to convert to form data.
  1282. * @param {string} formData - The FormData object to append to.
  1283. * @param {Object<string, any>} options
  1284. *
  1285. * @returns
  1286. */
  1287. function toFormData(obj, formData, options) {
  1288. if (!utils$1.isObject(obj)) {
  1289. throw new TypeError('target must be an object');
  1290. }
  1291. // eslint-disable-next-line no-param-reassign
  1292. formData = formData || new (FormData)();
  1293. // eslint-disable-next-line no-param-reassign
  1294. options = utils$1.toFlatObject(options, {
  1295. metaTokens: true,
  1296. dots: false,
  1297. indexes: false
  1298. }, false, function defined(option, source) {
  1299. // eslint-disable-next-line no-eq-null,eqeqeq
  1300. return !utils$1.isUndefined(source[option]);
  1301. });
  1302. var metaTokens = options.metaTokens;
  1303. // eslint-disable-next-line no-use-before-define
  1304. var visitor = options.visitor || defaultVisitor;
  1305. var dots = options.dots;
  1306. var indexes = options.indexes;
  1307. var _Blob = options.Blob || typeof Blob !== 'undefined' && Blob;
  1308. var useBlob = _Blob && utils$1.isSpecCompliantForm(formData);
  1309. if (!utils$1.isFunction(visitor)) {
  1310. throw new TypeError('visitor must be a function');
  1311. }
  1312. function convertValue(value) {
  1313. if (value === null) return '';
  1314. if (utils$1.isDate(value)) {
  1315. return value.toISOString();
  1316. }
  1317. if (!useBlob && utils$1.isBlob(value)) {
  1318. throw new AxiosError('Blob is not supported. Use a Buffer instead.');
  1319. }
  1320. if (utils$1.isArrayBuffer(value) || utils$1.isTypedArray(value)) {
  1321. return useBlob && typeof Blob === 'function' ? new Blob([value]) : Buffer.from(value);
  1322. }
  1323. return value;
  1324. }
  1325. /**
  1326. * Default visitor.
  1327. *
  1328. * @param {*} value
  1329. * @param {String|Number} key
  1330. * @param {Array<String|Number>} path
  1331. * @this {FormData}
  1332. *
  1333. * @returns {boolean} return true to visit the each prop of the value recursively
  1334. */
  1335. function defaultVisitor(value, key, path) {
  1336. var arr = value;
  1337. if (value && !path && _typeof(value) === 'object') {
  1338. if (utils$1.endsWith(key, '{}')) {
  1339. // eslint-disable-next-line no-param-reassign
  1340. key = metaTokens ? key : key.slice(0, -2);
  1341. // eslint-disable-next-line no-param-reassign
  1342. value = JSON.stringify(value);
  1343. } else if (utils$1.isArray(value) && isFlatArray(value) || (utils$1.isFileList(value) || utils$1.endsWith(key, '[]')) && (arr = utils$1.toArray(value))) {
  1344. // eslint-disable-next-line no-param-reassign
  1345. key = removeBrackets(key);
  1346. arr.forEach(function each(el, index) {
  1347. !(utils$1.isUndefined(el) || el === null) && formData.append(
  1348. // eslint-disable-next-line no-nested-ternary
  1349. indexes === true ? renderKey([key], index, dots) : indexes === null ? key : key + '[]', convertValue(el));
  1350. });
  1351. return false;
  1352. }
  1353. }
  1354. if (isVisitable(value)) {
  1355. return true;
  1356. }
  1357. formData.append(renderKey(path, key, dots), convertValue(value));
  1358. return false;
  1359. }
  1360. var stack = [];
  1361. var exposedHelpers = Object.assign(predicates, {
  1362. defaultVisitor: defaultVisitor,
  1363. convertValue: convertValue,
  1364. isVisitable: isVisitable
  1365. });
  1366. function build(value, path) {
  1367. if (utils$1.isUndefined(value)) return;
  1368. if (stack.indexOf(value) !== -1) {
  1369. throw Error('Circular reference detected in ' + path.join('.'));
  1370. }
  1371. stack.push(value);
  1372. utils$1.forEach(value, function each(el, key) {
  1373. var result = !(utils$1.isUndefined(el) || el === null) && visitor.call(formData, el, utils$1.isString(key) ? key.trim() : key, path, exposedHelpers);
  1374. if (result === true) {
  1375. build(el, path ? path.concat(key) : [key]);
  1376. }
  1377. });
  1378. stack.pop();
  1379. }
  1380. if (!utils$1.isObject(obj)) {
  1381. throw new TypeError('data must be an object');
  1382. }
  1383. build(obj);
  1384. return formData;
  1385. }
  1386. /**
  1387. * It encodes a string by replacing all characters that are not in the unreserved set with
  1388. * their percent-encoded equivalents
  1389. *
  1390. * @param {string} str - The string to encode.
  1391. *
  1392. * @returns {string} The encoded string.
  1393. */
  1394. function encode$1(str) {
  1395. var charMap = {
  1396. '!': '%21',
  1397. "'": '%27',
  1398. '(': '%28',
  1399. ')': '%29',
  1400. '~': '%7E',
  1401. '%20': '+',
  1402. '%00': '\x00'
  1403. };
  1404. return encodeURIComponent(str).replace(/[!'()~]|%20|%00/g, function replacer(match) {
  1405. return charMap[match];
  1406. });
  1407. }
  1408. /**
  1409. * It takes a params object and converts it to a FormData object
  1410. *
  1411. * @param {Object<string, any>} params - The parameters to be converted to a FormData object.
  1412. * @param {Object<string, any>} options - The options object passed to the Axios constructor.
  1413. *
  1414. * @returns {void}
  1415. */
  1416. function AxiosURLSearchParams(params, options) {
  1417. this._pairs = [];
  1418. params && toFormData(params, this, options);
  1419. }
  1420. var prototype = AxiosURLSearchParams.prototype;
  1421. prototype.append = function append(name, value) {
  1422. this._pairs.push([name, value]);
  1423. };
  1424. prototype.toString = function toString(encoder) {
  1425. var _encode = encoder ? function (value) {
  1426. return encoder.call(this, value, encode$1);
  1427. } : encode$1;
  1428. return this._pairs.map(function each(pair) {
  1429. return _encode(pair[0]) + '=' + _encode(pair[1]);
  1430. }, '').join('&');
  1431. };
  1432. /**
  1433. * It replaces all instances of the characters `:`, `$`, `,`, `+`, `[`, and `]` with their
  1434. * URI encoded counterparts
  1435. *
  1436. * @param {string} val The value to be encoded.
  1437. *
  1438. * @returns {string} The encoded value.
  1439. */
  1440. function encode(val) {
  1441. return encodeURIComponent(val).replace(/%3A/gi, ':').replace(/%24/g, '$').replace(/%2C/gi, ',').replace(/%20/g, '+').replace(/%5B/gi, '[').replace(/%5D/gi, ']');
  1442. }
  1443. /**
  1444. * Build a URL by appending params to the end
  1445. *
  1446. * @param {string} url The base of the url (e.g., http://www.google.com)
  1447. * @param {object} [params] The params to be appended
  1448. * @param {?object} options
  1449. *
  1450. * @returns {string} The formatted url
  1451. */
  1452. function buildURL(url, params, options) {
  1453. /*eslint no-param-reassign:0*/
  1454. if (!params) {
  1455. return url;
  1456. }
  1457. var _encode = options && options.encode || encode;
  1458. var serializeFn = options && options.serialize;
  1459. var serializedParams;
  1460. if (serializeFn) {
  1461. serializedParams = serializeFn(params, options);
  1462. } else {
  1463. serializedParams = utils$1.isURLSearchParams(params) ? params.toString() : new AxiosURLSearchParams(params, options).toString(_encode);
  1464. }
  1465. if (serializedParams) {
  1466. var hashmarkIndex = url.indexOf("#");
  1467. if (hashmarkIndex !== -1) {
  1468. url = url.slice(0, hashmarkIndex);
  1469. }
  1470. url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
  1471. }
  1472. return url;
  1473. }
  1474. var InterceptorManager = /*#__PURE__*/function () {
  1475. function InterceptorManager() {
  1476. _classCallCheck(this, InterceptorManager);
  1477. this.handlers = [];
  1478. }
  1479. /**
  1480. * Add a new interceptor to the stack
  1481. *
  1482. * @param {Function} fulfilled The function to handle `then` for a `Promise`
  1483. * @param {Function} rejected The function to handle `reject` for a `Promise`
  1484. *
  1485. * @return {Number} An ID used to remove interceptor later
  1486. */
  1487. _createClass(InterceptorManager, [{
  1488. key: "use",
  1489. value: function use(fulfilled, rejected, options) {
  1490. this.handlers.push({
  1491. fulfilled: fulfilled,
  1492. rejected: rejected,
  1493. synchronous: options ? options.synchronous : false,
  1494. runWhen: options ? options.runWhen : null
  1495. });
  1496. return this.handlers.length - 1;
  1497. }
  1498. /**
  1499. * Remove an interceptor from the stack
  1500. *
  1501. * @param {Number} id The ID that was returned by `use`
  1502. *
  1503. * @returns {Boolean} `true` if the interceptor was removed, `false` otherwise
  1504. */
  1505. }, {
  1506. key: "eject",
  1507. value: function eject(id) {
  1508. if (this.handlers[id]) {
  1509. this.handlers[id] = null;
  1510. }
  1511. }
  1512. /**
  1513. * Clear all interceptors from the stack
  1514. *
  1515. * @returns {void}
  1516. */
  1517. }, {
  1518. key: "clear",
  1519. value: function clear() {
  1520. if (this.handlers) {
  1521. this.handlers = [];
  1522. }
  1523. }
  1524. /**
  1525. * Iterate over all the registered interceptors
  1526. *
  1527. * This method is particularly useful for skipping over any
  1528. * interceptors that may have become `null` calling `eject`.
  1529. *
  1530. * @param {Function} fn The function to call for each interceptor
  1531. *
  1532. * @returns {void}
  1533. */
  1534. }, {
  1535. key: "forEach",
  1536. value: function forEach(fn) {
  1537. utils$1.forEach(this.handlers, function forEachHandler(h) {
  1538. if (h !== null) {
  1539. fn(h);
  1540. }
  1541. });
  1542. }
  1543. }]);
  1544. return InterceptorManager;
  1545. }();
  1546. var InterceptorManager$1 = InterceptorManager;
  1547. var transitionalDefaults = {
  1548. silentJSONParsing: true,
  1549. forcedJSONParsing: true,
  1550. clarifyTimeoutError: false
  1551. };
  1552. var URLSearchParams$1 = typeof URLSearchParams !== 'undefined' ? URLSearchParams : AxiosURLSearchParams;
  1553. var FormData$1 = typeof FormData !== 'undefined' ? FormData : null;
  1554. var Blob$1 = typeof Blob !== 'undefined' ? Blob : null;
  1555. var platform$1 = {
  1556. isBrowser: true,
  1557. classes: {
  1558. URLSearchParams: URLSearchParams$1,
  1559. FormData: FormData$1,
  1560. Blob: Blob$1
  1561. },
  1562. protocols: ['http', 'https', 'file', 'blob', 'url', 'data']
  1563. };
  1564. var hasBrowserEnv = typeof window !== 'undefined' && typeof document !== 'undefined';
  1565. /**
  1566. * Determine if we're running in a standard browser environment
  1567. *
  1568. * This allows axios to run in a web worker, and react-native.
  1569. * Both environments support XMLHttpRequest, but not fully standard globals.
  1570. *
  1571. * web workers:
  1572. * typeof window -> undefined
  1573. * typeof document -> undefined
  1574. *
  1575. * react-native:
  1576. * navigator.product -> 'ReactNative'
  1577. * nativescript
  1578. * navigator.product -> 'NativeScript' or 'NS'
  1579. *
  1580. * @returns {boolean}
  1581. */
  1582. var hasStandardBrowserEnv = function (product) {
  1583. return hasBrowserEnv && ['ReactNative', 'NativeScript', 'NS'].indexOf(product) < 0;
  1584. }(typeof navigator !== 'undefined' && navigator.product);
  1585. /**
  1586. * Determine if we're running in a standard browser webWorker environment
  1587. *
  1588. * Although the `isStandardBrowserEnv` method indicates that
  1589. * `allows axios to run in a web worker`, the WebWorker will still be
  1590. * filtered out due to its judgment standard
  1591. * `typeof window !== 'undefined' && typeof document !== 'undefined'`.
  1592. * This leads to a problem when axios post `FormData` in webWorker
  1593. */
  1594. var hasStandardBrowserWebWorkerEnv = function () {
  1595. return typeof WorkerGlobalScope !== 'undefined' &&
  1596. // eslint-disable-next-line no-undef
  1597. self instanceof WorkerGlobalScope && typeof self.importScripts === 'function';
  1598. }();
  1599. var utils = /*#__PURE__*/Object.freeze({
  1600. __proto__: null,
  1601. hasBrowserEnv: hasBrowserEnv,
  1602. hasStandardBrowserWebWorkerEnv: hasStandardBrowserWebWorkerEnv,
  1603. hasStandardBrowserEnv: hasStandardBrowserEnv
  1604. });
  1605. var platform = _objectSpread2(_objectSpread2({}, utils), platform$1);
  1606. function toURLEncodedForm(data, options) {
  1607. return toFormData(data, new platform.classes.URLSearchParams(), Object.assign({
  1608. visitor: function visitor(value, key, path, helpers) {
  1609. if (platform.isNode && utils$1.isBuffer(value)) {
  1610. this.append(key, value.toString('base64'));
  1611. return false;
  1612. }
  1613. return helpers.defaultVisitor.apply(this, arguments);
  1614. }
  1615. }, options));
  1616. }
  1617. /**
  1618. * It takes a string like `foo[x][y][z]` and returns an array like `['foo', 'x', 'y', 'z']
  1619. *
  1620. * @param {string} name - The name of the property to get.
  1621. *
  1622. * @returns An array of strings.
  1623. */
  1624. function parsePropPath(name) {
  1625. // foo[x][y][z]
  1626. // foo.x.y.z
  1627. // foo-x-y-z
  1628. // foo x y z
  1629. return utils$1.matchAll(/\w+|\[(\w*)]/g, name).map(function (match) {
  1630. return match[0] === '[]' ? '' : match[1] || match[0];
  1631. });
  1632. }
  1633. /**
  1634. * Convert an array to an object.
  1635. *
  1636. * @param {Array<any>} arr - The array to convert to an object.
  1637. *
  1638. * @returns An object with the same keys and values as the array.
  1639. */
  1640. function arrayToObject(arr) {
  1641. var obj = {};
  1642. var keys = Object.keys(arr);
  1643. var i;
  1644. var len = keys.length;
  1645. var key;
  1646. for (i = 0; i < len; i++) {
  1647. key = keys[i];
  1648. obj[key] = arr[key];
  1649. }
  1650. return obj;
  1651. }
  1652. /**
  1653. * It takes a FormData object and returns a JavaScript object
  1654. *
  1655. * @param {string} formData The FormData object to convert to JSON.
  1656. *
  1657. * @returns {Object<string, any> | null} The converted object.
  1658. */
  1659. function formDataToJSON(formData) {
  1660. function buildPath(path, value, target, index) {
  1661. var name = path[index++];
  1662. if (name === '__proto__') return true;
  1663. var isNumericKey = Number.isFinite(+name);
  1664. var isLast = index >= path.length;
  1665. name = !name && utils$1.isArray(target) ? target.length : name;
  1666. if (isLast) {
  1667. if (utils$1.hasOwnProp(target, name)) {
  1668. target[name] = [target[name], value];
  1669. } else {
  1670. target[name] = value;
  1671. }
  1672. return !isNumericKey;
  1673. }
  1674. if (!target[name] || !utils$1.isObject(target[name])) {
  1675. target[name] = [];
  1676. }
  1677. var result = buildPath(path, value, target[name], index);
  1678. if (result && utils$1.isArray(target[name])) {
  1679. target[name] = arrayToObject(target[name]);
  1680. }
  1681. return !isNumericKey;
  1682. }
  1683. if (utils$1.isFormData(formData) && utils$1.isFunction(formData.entries)) {
  1684. var obj = {};
  1685. utils$1.forEachEntry(formData, function (name, value) {
  1686. buildPath(parsePropPath(name), value, obj, 0);
  1687. });
  1688. return obj;
  1689. }
  1690. return null;
  1691. }
  1692. /**
  1693. * It takes a string, tries to parse it, and if it fails, it returns the stringified version
  1694. * of the input
  1695. *
  1696. * @param {any} rawValue - The value to be stringified.
  1697. * @param {Function} parser - A function that parses a string into a JavaScript object.
  1698. * @param {Function} encoder - A function that takes a value and returns a string.
  1699. *
  1700. * @returns {string} A stringified version of the rawValue.
  1701. */
  1702. function stringifySafely(rawValue, parser, encoder) {
  1703. if (utils$1.isString(rawValue)) {
  1704. try {
  1705. (parser || JSON.parse)(rawValue);
  1706. return utils$1.trim(rawValue);
  1707. } catch (e) {
  1708. if (e.name !== 'SyntaxError') {
  1709. throw e;
  1710. }
  1711. }
  1712. }
  1713. return (encoder || JSON.stringify)(rawValue);
  1714. }
  1715. var defaults = {
  1716. transitional: transitionalDefaults,
  1717. adapter: ['xhr', 'http'],
  1718. transformRequest: [function transformRequest(data, headers) {
  1719. var contentType = headers.getContentType() || '';
  1720. var hasJSONContentType = contentType.indexOf('application/json') > -1;
  1721. var isObjectPayload = utils$1.isObject(data);
  1722. if (isObjectPayload && utils$1.isHTMLForm(data)) {
  1723. data = new FormData(data);
  1724. }
  1725. var isFormData = utils$1.isFormData(data);
  1726. if (isFormData) {
  1727. return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
  1728. }
  1729. if (utils$1.isArrayBuffer(data) || utils$1.isBuffer(data) || utils$1.isStream(data) || utils$1.isFile(data) || utils$1.isBlob(data)) {
  1730. return data;
  1731. }
  1732. if (utils$1.isArrayBufferView(data)) {
  1733. return data.buffer;
  1734. }
  1735. if (utils$1.isURLSearchParams(data)) {
  1736. headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
  1737. return data.toString();
  1738. }
  1739. var isFileList;
  1740. if (isObjectPayload) {
  1741. if (contentType.indexOf('application/x-www-form-urlencoded') > -1) {
  1742. return toURLEncodedForm(data, this.formSerializer).toString();
  1743. }
  1744. if ((isFileList = utils$1.isFileList(data)) || contentType.indexOf('multipart/form-data') > -1) {
  1745. var _FormData = this.env && this.env.FormData;
  1746. return toFormData(isFileList ? {
  1747. 'files[]': data
  1748. } : data, _FormData && new _FormData(), this.formSerializer);
  1749. }
  1750. }
  1751. if (isObjectPayload || hasJSONContentType) {
  1752. headers.setContentType('application/json', false);
  1753. return stringifySafely(data);
  1754. }
  1755. return data;
  1756. }],
  1757. transformResponse: [function transformResponse(data) {
  1758. var transitional = this.transitional || defaults.transitional;
  1759. var forcedJSONParsing = transitional && transitional.forcedJSONParsing;
  1760. var JSONRequested = this.responseType === 'json';
  1761. if (data && utils$1.isString(data) && (forcedJSONParsing && !this.responseType || JSONRequested)) {
  1762. var silentJSONParsing = transitional && transitional.silentJSONParsing;
  1763. var strictJSONParsing = !silentJSONParsing && JSONRequested;
  1764. try {
  1765. return JSON.parse(data);
  1766. } catch (e) {
  1767. if (strictJSONParsing) {
  1768. if (e.name === 'SyntaxError') {
  1769. throw AxiosError.from(e, AxiosError.ERR_BAD_RESPONSE, this, null, this.response);
  1770. }
  1771. throw e;
  1772. }
  1773. }
  1774. }
  1775. return data;
  1776. }],
  1777. /**
  1778. * A timeout in milliseconds to abort a request. If set to 0 (default) a
  1779. * timeout is not created.
  1780. */
  1781. timeout: 0,
  1782. xsrfCookieName: 'XSRF-TOKEN',
  1783. xsrfHeaderName: 'X-XSRF-TOKEN',
  1784. maxContentLength: -1,
  1785. maxBodyLength: -1,
  1786. env: {
  1787. FormData: platform.classes.FormData,
  1788. Blob: platform.classes.Blob
  1789. },
  1790. validateStatus: function validateStatus(status) {
  1791. return status >= 200 && status < 300;
  1792. },
  1793. headers: {
  1794. common: {
  1795. 'Accept': 'application/json, text/plain, */*',
  1796. 'Content-Type': undefined
  1797. }
  1798. }
  1799. };
  1800. utils$1.forEach(['delete', 'get', 'head', 'post', 'put', 'patch'], function (method) {
  1801. defaults.headers[method] = {};
  1802. });
  1803. var defaults$1 = defaults;
  1804. // RawAxiosHeaders whose duplicates are ignored by node
  1805. // c.f. https://nodejs.org/api/http.html#http_message_headers
  1806. var ignoreDuplicateOf = utils$1.toObjectSet(['age', 'authorization', 'content-length', 'content-type', 'etag', 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since', 'last-modified', 'location', 'max-forwards', 'proxy-authorization', 'referer', 'retry-after', 'user-agent']);
  1807. /**
  1808. * Parse headers into an object
  1809. *
  1810. * ```
  1811. * Date: Wed, 27 Aug 2014 08:58:49 GMT
  1812. * Content-Type: application/json
  1813. * Connection: keep-alive
  1814. * Transfer-Encoding: chunked
  1815. * ```
  1816. *
  1817. * @param {String} rawHeaders Headers needing to be parsed
  1818. *
  1819. * @returns {Object} Headers parsed into an object
  1820. */
  1821. var parseHeaders = (function (rawHeaders) {
  1822. var parsed = {};
  1823. var key;
  1824. var val;
  1825. var i;
  1826. rawHeaders && rawHeaders.split('\n').forEach(function parser(line) {
  1827. i = line.indexOf(':');
  1828. key = line.substring(0, i).trim().toLowerCase();
  1829. val = line.substring(i + 1).trim();
  1830. if (!key || parsed[key] && ignoreDuplicateOf[key]) {
  1831. return;
  1832. }
  1833. if (key === 'set-cookie') {
  1834. if (parsed[key]) {
  1835. parsed[key].push(val);
  1836. } else {
  1837. parsed[key] = [val];
  1838. }
  1839. } else {
  1840. parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
  1841. }
  1842. });
  1843. return parsed;
  1844. });
  1845. var $internals = Symbol('internals');
  1846. function normalizeHeader(header) {
  1847. return header && String(header).trim().toLowerCase();
  1848. }
  1849. function normalizeValue(value) {
  1850. if (value === false || value == null) {
  1851. return value;
  1852. }
  1853. return utils$1.isArray(value) ? value.map(normalizeValue) : String(value);
  1854. }
  1855. function parseTokens(str) {
  1856. var tokens = Object.create(null);
  1857. var tokensRE = /([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;
  1858. var match;
  1859. while (match = tokensRE.exec(str)) {
  1860. tokens[match[1]] = match[2];
  1861. }
  1862. return tokens;
  1863. }
  1864. var isValidHeaderName = function isValidHeaderName(str) {
  1865. return /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(str.trim());
  1866. };
  1867. function matchHeaderValue(context, value, header, filter, isHeaderNameFilter) {
  1868. if (utils$1.isFunction(filter)) {
  1869. return filter.call(this, value, header);
  1870. }
  1871. if (isHeaderNameFilter) {
  1872. value = header;
  1873. }
  1874. if (!utils$1.isString(value)) return;
  1875. if (utils$1.isString(filter)) {
  1876. return value.indexOf(filter) !== -1;
  1877. }
  1878. if (utils$1.isRegExp(filter)) {
  1879. return filter.test(value);
  1880. }
  1881. }
  1882. function formatHeader(header) {
  1883. return header.trim().toLowerCase().replace(/([a-z\d])(\w*)/g, function (w, _char, str) {
  1884. return _char.toUpperCase() + str;
  1885. });
  1886. }
  1887. function buildAccessors(obj, header) {
  1888. var accessorName = utils$1.toCamelCase(' ' + header);
  1889. ['get', 'set', 'has'].forEach(function (methodName) {
  1890. Object.defineProperty(obj, methodName + accessorName, {
  1891. value: function value(arg1, arg2, arg3) {
  1892. return this[methodName].call(this, header, arg1, arg2, arg3);
  1893. },
  1894. configurable: true
  1895. });
  1896. });
  1897. }
  1898. var AxiosHeaders = /*#__PURE__*/function (_Symbol$iterator, _Symbol$toStringTag) {
  1899. function AxiosHeaders(headers) {
  1900. _classCallCheck(this, AxiosHeaders);
  1901. headers && this.set(headers);
  1902. }
  1903. _createClass(AxiosHeaders, [{
  1904. key: "set",
  1905. value: function set(header, valueOrRewrite, rewrite) {
  1906. var self = this;
  1907. function setHeader(_value, _header, _rewrite) {
  1908. var lHeader = normalizeHeader(_header);
  1909. if (!lHeader) {
  1910. throw new Error('header name must be a non-empty string');
  1911. }
  1912. var key = utils$1.findKey(self, lHeader);
  1913. if (!key || self[key] === undefined || _rewrite === true || _rewrite === undefined && self[key] !== false) {
  1914. self[key || _header] = normalizeValue(_value);
  1915. }
  1916. }
  1917. var setHeaders = function setHeaders(headers, _rewrite) {
  1918. return utils$1.forEach(headers, function (_value, _header) {
  1919. return setHeader(_value, _header, _rewrite);
  1920. });
  1921. };
  1922. if (utils$1.isPlainObject(header) || header instanceof this.constructor) {
  1923. setHeaders(header, valueOrRewrite);
  1924. } else if (utils$1.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
  1925. setHeaders(parseHeaders(header), valueOrRewrite);
  1926. } else {
  1927. header != null && setHeader(valueOrRewrite, header, rewrite);
  1928. }
  1929. return this;
  1930. }
  1931. }, {
  1932. key: "get",
  1933. value: function get(header, parser) {
  1934. header = normalizeHeader(header);
  1935. if (header) {
  1936. var key = utils$1.findKey(this, header);
  1937. if (key) {
  1938. var value = this[key];
  1939. if (!parser) {
  1940. return value;
  1941. }
  1942. if (parser === true) {
  1943. return parseTokens(value);
  1944. }
  1945. if (utils$1.isFunction(parser)) {
  1946. return parser.call(this, value, key);
  1947. }
  1948. if (utils$1.isRegExp(parser)) {
  1949. return parser.exec(value);
  1950. }
  1951. throw new TypeError('parser must be boolean|regexp|function');
  1952. }
  1953. }
  1954. }
  1955. }, {
  1956. key: "has",
  1957. value: function has(header, matcher) {
  1958. header = normalizeHeader(header);
  1959. if (header) {
  1960. var key = utils$1.findKey(this, header);
  1961. return !!(key && this[key] !== undefined && (!matcher || matchHeaderValue(this, this[key], key, matcher)));
  1962. }
  1963. return false;
  1964. }
  1965. }, {
  1966. key: "delete",
  1967. value: function _delete(header, matcher) {
  1968. var self = this;
  1969. var deleted = false;
  1970. function deleteHeader(_header) {
  1971. _header = normalizeHeader(_header);
  1972. if (_header) {
  1973. var key = utils$1.findKey(self, _header);
  1974. if (key && (!matcher || matchHeaderValue(self, self[key], key, matcher))) {
  1975. delete self[key];
  1976. deleted = true;
  1977. }
  1978. }
  1979. }
  1980. if (utils$1.isArray(header)) {
  1981. header.forEach(deleteHeader);
  1982. } else {
  1983. deleteHeader(header);
  1984. }
  1985. return deleted;
  1986. }
  1987. }, {
  1988. key: "clear",
  1989. value: function clear(matcher) {
  1990. var keys = Object.keys(this);
  1991. var i = keys.length;
  1992. var deleted = false;
  1993. while (i--) {
  1994. var key = keys[i];
  1995. if (!matcher || matchHeaderValue(this, this[key], key, matcher, true)) {
  1996. delete this[key];
  1997. deleted = true;
  1998. }
  1999. }
  2000. return deleted;
  2001. }
  2002. }, {
  2003. key: "normalize",
  2004. value: function normalize(format) {
  2005. var self = this;
  2006. var headers = {};
  2007. utils$1.forEach(this, function (value, header) {
  2008. var key = utils$1.findKey(headers, header);
  2009. if (key) {
  2010. self[key] = normalizeValue(value);
  2011. delete self[header];
  2012. return;
  2013. }
  2014. var normalized = format ? formatHeader(header) : String(header).trim();
  2015. if (normalized !== header) {
  2016. delete self[header];
  2017. }
  2018. self[normalized] = normalizeValue(value);
  2019. headers[normalized] = true;
  2020. });
  2021. return this;
  2022. }
  2023. }, {
  2024. key: "concat",
  2025. value: function concat() {
  2026. var _this$constructor;
  2027. for (var _len = arguments.length, targets = new Array(_len), _key = 0; _key < _len; _key++) {
  2028. targets[_key] = arguments[_key];
  2029. }
  2030. return (_this$constructor = this.constructor).concat.apply(_this$constructor, [this].concat(targets));
  2031. }
  2032. }, {
  2033. key: "toJSON",
  2034. value: function toJSON(asStrings) {
  2035. var obj = Object.create(null);
  2036. utils$1.forEach(this, function (value, header) {
  2037. value != null && value !== false && (obj[header] = asStrings && utils$1.isArray(value) ? value.join(', ') : value);
  2038. });
  2039. return obj;
  2040. }
  2041. }, {
  2042. key: _Symbol$iterator,
  2043. value: function value() {
  2044. return Object.entries(this.toJSON())[Symbol.iterator]();
  2045. }
  2046. }, {
  2047. key: "toString",
  2048. value: function toString() {
  2049. return Object.entries(this.toJSON()).map(function (_ref) {
  2050. var _ref2 = _slicedToArray(_ref, 2),
  2051. header = _ref2[0],
  2052. value = _ref2[1];
  2053. return header + ': ' + value;
  2054. }).join('\n');
  2055. }
  2056. }, {
  2057. key: _Symbol$toStringTag,
  2058. get: function get() {
  2059. return 'AxiosHeaders';
  2060. }
  2061. }], [{
  2062. key: "from",
  2063. value: function from(thing) {
  2064. return thing instanceof this ? thing : new this(thing);
  2065. }
  2066. }, {
  2067. key: "concat",
  2068. value: function concat(first) {
  2069. var computed = new this(first);
  2070. for (var _len2 = arguments.length, targets = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
  2071. targets[_key2 - 1] = arguments[_key2];
  2072. }
  2073. targets.forEach(function (target) {
  2074. return computed.set(target);
  2075. });
  2076. return computed;
  2077. }
  2078. }, {
  2079. key: "accessor",
  2080. value: function accessor(header) {
  2081. var internals = this[$internals] = this[$internals] = {
  2082. accessors: {}
  2083. };
  2084. var accessors = internals.accessors;
  2085. var prototype = this.prototype;
  2086. function defineAccessor(_header) {
  2087. var lHeader = normalizeHeader(_header);
  2088. if (!accessors[lHeader]) {
  2089. buildAccessors(prototype, _header);
  2090. accessors[lHeader] = true;
  2091. }
  2092. }
  2093. utils$1.isArray(header) ? header.forEach(defineAccessor) : defineAccessor(header);
  2094. return this;
  2095. }
  2096. }]);
  2097. return AxiosHeaders;
  2098. }(Symbol.iterator, Symbol.toStringTag);
  2099. AxiosHeaders.accessor(['Content-Type', 'Content-Length', 'Accept', 'Accept-Encoding', 'User-Agent', 'Authorization']);
  2100. // reserved names hotfix
  2101. utils$1.reduceDescriptors(AxiosHeaders.prototype, function (_ref3, key) {
  2102. var value = _ref3.value;
  2103. var mapped = key[0].toUpperCase() + key.slice(1); // map `set` => `Set`
  2104. return {
  2105. get: function get() {
  2106. return value;
  2107. },
  2108. set: function set(headerValue) {
  2109. this[mapped] = headerValue;
  2110. }
  2111. };
  2112. });
  2113. utils$1.freezeMethods(AxiosHeaders);
  2114. var AxiosHeaders$1 = AxiosHeaders;
  2115. /**
  2116. * Transform the data for a request or a response
  2117. *
  2118. * @param {Array|Function} fns A single function or Array of functions
  2119. * @param {?Object} response The response object
  2120. *
  2121. * @returns {*} The resulting transformed data
  2122. */
  2123. function transformData(fns, response) {
  2124. var config = this || defaults$1;
  2125. var context = response || config;
  2126. var headers = AxiosHeaders$1.from(context.headers);
  2127. var data = context.data;
  2128. utils$1.forEach(fns, function transform(fn) {
  2129. data = fn.call(config, data, headers.normalize(), response ? response.status : undefined);
  2130. });
  2131. headers.normalize();
  2132. return data;
  2133. }
  2134. function isCancel(value) {
  2135. return !!(value && value.__CANCEL__);
  2136. }
  2137. /**
  2138. * A `CanceledError` is an object that is thrown when an operation is canceled.
  2139. *
  2140. * @param {string=} message The message.
  2141. * @param {Object=} config The config.
  2142. * @param {Object=} request The request.
  2143. *
  2144. * @returns {CanceledError} The created error.
  2145. */
  2146. function CanceledError(message, config, request) {
  2147. // eslint-disable-next-line no-eq-null,eqeqeq
  2148. AxiosError.call(this, message == null ? 'canceled' : message, AxiosError.ERR_CANCELED, config, request);
  2149. this.name = 'CanceledError';
  2150. }
  2151. utils$1.inherits(CanceledError, AxiosError, {
  2152. __CANCEL__: true
  2153. });
  2154. /**
  2155. * Resolve or reject a Promise based on response status.
  2156. *
  2157. * @param {Function} resolve A function that resolves the promise.
  2158. * @param {Function} reject A function that rejects the promise.
  2159. * @param {object} response The response.
  2160. *
  2161. * @returns {object} The response.
  2162. */
  2163. function settle(resolve, reject, response) {
  2164. var validateStatus = response.config.validateStatus;
  2165. if (!response.status || !validateStatus || validateStatus(response.status)) {
  2166. resolve(response);
  2167. } else {
  2168. reject(new AxiosError('Request failed with status code ' + response.status, [AxiosError.ERR_BAD_REQUEST, AxiosError.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4], response.config, response.request, response));
  2169. }
  2170. }
  2171. var cookies = platform.hasStandardBrowserEnv ?
  2172. // Standard browser envs support document.cookie
  2173. {
  2174. write: function write(name, value, expires, path, domain, secure) {
  2175. var cookie = [name + '=' + encodeURIComponent(value)];
  2176. utils$1.isNumber(expires) && cookie.push('expires=' + new Date(expires).toGMTString());
  2177. utils$1.isString(path) && cookie.push('path=' + path);
  2178. utils$1.isString(domain) && cookie.push('domain=' + domain);
  2179. secure === true && cookie.push('secure');
  2180. document.cookie = cookie.join('; ');
  2181. },
  2182. read: function read(name) {
  2183. var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
  2184. return match ? decodeURIComponent(match[3]) : null;
  2185. },
  2186. remove: function remove(name) {
  2187. this.write(name, '', Date.now() - 86400000);
  2188. }
  2189. } :
  2190. // Non-standard browser env (web workers, react-native) lack needed support.
  2191. {
  2192. write: function write() {},
  2193. read: function read() {
  2194. return null;
  2195. },
  2196. remove: function remove() {}
  2197. };
  2198. /**
  2199. * Determines whether the specified URL is absolute
  2200. *
  2201. * @param {string} url The URL to test
  2202. *
  2203. * @returns {boolean} True if the specified URL is absolute, otherwise false
  2204. */
  2205. function isAbsoluteURL(url) {
  2206. // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
  2207. // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
  2208. // by any combination of letters, digits, plus, period, or hyphen.
  2209. return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
  2210. }
  2211. /**
  2212. * Creates a new URL by combining the specified URLs
  2213. *
  2214. * @param {string} baseURL The base URL
  2215. * @param {string} relativeURL The relative URL
  2216. *
  2217. * @returns {string} The combined URL
  2218. */
  2219. function combineURLs(baseURL, relativeURL) {
  2220. return relativeURL ? baseURL.replace(/\/?\/$/, '') + '/' + relativeURL.replace(/^\/+/, '') : baseURL;
  2221. }
  2222. /**
  2223. * Creates a new URL by combining the baseURL with the requestedURL,
  2224. * only when the requestedURL is not already an absolute URL.
  2225. * If the requestURL is absolute, this function returns the requestedURL untouched.
  2226. *
  2227. * @param {string} baseURL The base URL
  2228. * @param {string} requestedURL Absolute or relative URL to combine
  2229. *
  2230. * @returns {string} The combined full path
  2231. */
  2232. function buildFullPath(baseURL, requestedURL) {
  2233. if (baseURL && !isAbsoluteURL(requestedURL)) {
  2234. return combineURLs(baseURL, requestedURL);
  2235. }
  2236. return requestedURL;
  2237. }
  2238. var isURLSameOrigin = platform.hasStandardBrowserEnv ?
  2239. // Standard browser envs have full support of the APIs needed to test
  2240. // whether the request URL is of the same origin as current location.
  2241. function standardBrowserEnv() {
  2242. var msie = /(msie|trident)/i.test(navigator.userAgent);
  2243. var urlParsingNode = document.createElement('a');
  2244. var originURL;
  2245. /**
  2246. * Parse a URL to discover its components
  2247. *
  2248. * @param {String} url The URL to be parsed
  2249. * @returns {Object}
  2250. */
  2251. function resolveURL(url) {
  2252. var href = url;
  2253. if (msie) {
  2254. // IE needs attribute set twice to normalize properties
  2255. urlParsingNode.setAttribute('href', href);
  2256. href = urlParsingNode.href;
  2257. }
  2258. urlParsingNode.setAttribute('href', href);
  2259. // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
  2260. return {
  2261. href: urlParsingNode.href,
  2262. protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
  2263. host: urlParsingNode.host,
  2264. search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
  2265. hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
  2266. hostname: urlParsingNode.hostname,
  2267. port: urlParsingNode.port,
  2268. pathname: urlParsingNode.pathname.charAt(0) === '/' ? urlParsingNode.pathname : '/' + urlParsingNode.pathname
  2269. };
  2270. }
  2271. originURL = resolveURL(window.location.href);
  2272. /**
  2273. * Determine if a URL shares the same origin as the current location
  2274. *
  2275. * @param {String} requestURL The URL to test
  2276. * @returns {boolean} True if URL shares the same origin, otherwise false
  2277. */
  2278. return function isURLSameOrigin(requestURL) {
  2279. var parsed = utils$1.isString(requestURL) ? resolveURL(requestURL) : requestURL;
  2280. return parsed.protocol === originURL.protocol && parsed.host === originURL.host;
  2281. };
  2282. }() :
  2283. // Non standard browser envs (web workers, react-native) lack needed support.
  2284. function nonStandardBrowserEnv() {
  2285. return function isURLSameOrigin() {
  2286. return true;
  2287. };
  2288. }();
  2289. function parseProtocol(url) {
  2290. var match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
  2291. return match && match[1] || '';
  2292. }
  2293. /**
  2294. * Calculate data maxRate
  2295. * @param {Number} [samplesCount= 10]
  2296. * @param {Number} [min= 1000]
  2297. * @returns {Function}
  2298. */
  2299. function speedometer(samplesCount, min) {
  2300. samplesCount = samplesCount || 10;
  2301. var bytes = new Array(samplesCount);
  2302. var timestamps = new Array(samplesCount);
  2303. var head = 0;
  2304. var tail = 0;
  2305. var firstSampleTS;
  2306. min = min !== undefined ? min : 1000;
  2307. return function push(chunkLength) {
  2308. var now = Date.now();
  2309. var startedAt = timestamps[tail];
  2310. if (!firstSampleTS) {
  2311. firstSampleTS = now;
  2312. }
  2313. bytes[head] = chunkLength;
  2314. timestamps[head] = now;
  2315. var i = tail;
  2316. var bytesCount = 0;
  2317. while (i !== head) {
  2318. bytesCount += bytes[i++];
  2319. i = i % samplesCount;
  2320. }
  2321. head = (head + 1) % samplesCount;
  2322. if (head === tail) {
  2323. tail = (tail + 1) % samplesCount;
  2324. }
  2325. if (now - firstSampleTS < min) {
  2326. return;
  2327. }
  2328. var passed = startedAt && now - startedAt;
  2329. return passed ? Math.round(bytesCount * 1000 / passed) : undefined;
  2330. };
  2331. }
  2332. function progressEventReducer(listener, isDownloadStream) {
  2333. var bytesNotified = 0;
  2334. var _speedometer = speedometer(50, 250);
  2335. return function (e) {
  2336. var loaded = e.loaded;
  2337. var total = e.lengthComputable ? e.total : undefined;
  2338. var progressBytes = loaded - bytesNotified;
  2339. var rate = _speedometer(progressBytes);
  2340. var inRange = loaded <= total;
  2341. bytesNotified = loaded;
  2342. var data = {
  2343. loaded: loaded,
  2344. total: total,
  2345. progress: total ? loaded / total : undefined,
  2346. bytes: progressBytes,
  2347. rate: rate ? rate : undefined,
  2348. estimated: rate && total && inRange ? (total - loaded) / rate : undefined,
  2349. event: e
  2350. };
  2351. data[isDownloadStream ? 'download' : 'upload'] = true;
  2352. listener(data);
  2353. };
  2354. }
  2355. var isXHRAdapterSupported = typeof XMLHttpRequest !== 'undefined';
  2356. var xhrAdapter = isXHRAdapterSupported && function (config) {
  2357. return new Promise(function dispatchXhrRequest(resolve, reject) {
  2358. var requestData = config.data;
  2359. var requestHeaders = AxiosHeaders$1.from(config.headers).normalize();
  2360. var responseType = config.responseType,
  2361. withXSRFToken = config.withXSRFToken;
  2362. var onCanceled;
  2363. function done() {
  2364. if (config.cancelToken) {
  2365. config.cancelToken.unsubscribe(onCanceled);
  2366. }
  2367. if (config.signal) {
  2368. config.signal.removeEventListener('abort', onCanceled);
  2369. }
  2370. }
  2371. var contentType;
  2372. if (utils$1.isFormData(requestData)) {
  2373. if (platform.hasStandardBrowserEnv || platform.hasStandardBrowserWebWorkerEnv) {
  2374. requestHeaders.setContentType(false); // Let the browser set it
  2375. } else if ((contentType = requestHeaders.getContentType()) !== false) {
  2376. // fix semicolon duplication issue for ReactNative FormData implementation
  2377. var _ref = contentType ? contentType.split(';').map(function (token) {
  2378. return token.trim();
  2379. }).filter(Boolean) : [],
  2380. _ref2 = _toArray(_ref),
  2381. type = _ref2[0],
  2382. tokens = _ref2.slice(1);
  2383. requestHeaders.setContentType([type || 'multipart/form-data'].concat(_toConsumableArray(tokens)).join('; '));
  2384. }
  2385. }
  2386. var request = new XMLHttpRequest();
  2387. // HTTP basic authentication
  2388. if (config.auth) {
  2389. var username = config.auth.username || '';
  2390. var password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : '';
  2391. requestHeaders.set('Authorization', 'Basic ' + btoa(username + ':' + password));
  2392. }
  2393. var fullPath = buildFullPath(config.baseURL, config.url);
  2394. request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true);
  2395. // Set the request timeout in MS
  2396. request.timeout = config.timeout;
  2397. function onloadend() {
  2398. if (!request) {
  2399. return;
  2400. }
  2401. // Prepare the response
  2402. var responseHeaders = AxiosHeaders$1.from('getAllResponseHeaders' in request && request.getAllResponseHeaders());
  2403. var responseData = !responseType || responseType === 'text' || responseType === 'json' ? request.responseText : request.response;
  2404. var response = {
  2405. data: responseData,
  2406. status: request.status,
  2407. statusText: request.statusText,
  2408. headers: responseHeaders,
  2409. config: config,
  2410. request: request
  2411. };
  2412. settle(function _resolve(value) {
  2413. resolve(value);
  2414. done();
  2415. }, function _reject(err) {
  2416. reject(err);
  2417. done();
  2418. }, response);
  2419. // Clean up request
  2420. request = null;
  2421. }
  2422. if ('onloadend' in request) {
  2423. // Use onloadend if available
  2424. request.onloadend = onloadend;
  2425. } else {
  2426. // Listen for ready state to emulate onloadend
  2427. request.onreadystatechange = function handleLoad() {
  2428. if (!request || request.readyState !== 4) {
  2429. return;
  2430. }
  2431. // The request errored out and we didn't get a response, this will be
  2432. // handled by onerror instead
  2433. // With one exception: request that using file: protocol, most browsers
  2434. // will return status as 0 even though it's a successful request
  2435. if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
  2436. return;
  2437. }
  2438. // readystate handler is calling before onerror or ontimeout handlers,
  2439. // so we should call onloadend on the next 'tick'
  2440. setTimeout(onloadend);
  2441. };
  2442. }
  2443. // Handle browser request cancellation (as opposed to a manual cancellation)
  2444. request.onabort = function handleAbort() {
  2445. if (!request) {
  2446. return;
  2447. }
  2448. reject(new AxiosError('Request aborted', AxiosError.ECONNABORTED, config, request));
  2449. // Clean up request
  2450. request = null;
  2451. };
  2452. // Handle low level network errors
  2453. request.onerror = function handleError() {
  2454. // Real errors are hidden from us by the browser
  2455. // onerror should only fire if it's a network error
  2456. reject(new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request));
  2457. // Clean up request
  2458. request = null;
  2459. };
  2460. // Handle timeout
  2461. request.ontimeout = function handleTimeout() {
  2462. var timeoutErrorMessage = config.timeout ? 'timeout of ' + config.timeout + 'ms exceeded' : 'timeout exceeded';
  2463. var transitional = config.transitional || transitionalDefaults;
  2464. if (config.timeoutErrorMessage) {
  2465. timeoutErrorMessage = config.timeoutErrorMessage;
  2466. }
  2467. reject(new AxiosError(timeoutErrorMessage, transitional.clarifyTimeoutError ? AxiosError.ETIMEDOUT : AxiosError.ECONNABORTED, config, request));
  2468. // Clean up request
  2469. request = null;
  2470. };
  2471. // Add xsrf header
  2472. // This is only done if running in a standard browser environment.
  2473. // Specifically not if we're in a web worker, or react-native.
  2474. if (platform.hasStandardBrowserEnv) {
  2475. withXSRFToken && utils$1.isFunction(withXSRFToken) && (withXSRFToken = withXSRFToken(config));
  2476. if (withXSRFToken || withXSRFToken !== false && isURLSameOrigin(fullPath)) {
  2477. // Add xsrf header
  2478. var xsrfValue = config.xsrfHeaderName && config.xsrfCookieName && cookies.read(config.xsrfCookieName);
  2479. if (xsrfValue) {
  2480. requestHeaders.set(config.xsrfHeaderName, xsrfValue);
  2481. }
  2482. }
  2483. }
  2484. // Remove Content-Type if data is undefined
  2485. requestData === undefined && requestHeaders.setContentType(null);
  2486. // Add headers to the request
  2487. if ('setRequestHeader' in request) {
  2488. utils$1.forEach(requestHeaders.toJSON(), function setRequestHeader(val, key) {
  2489. request.setRequestHeader(key, val);
  2490. });
  2491. }
  2492. // Add withCredentials to request if needed
  2493. if (!utils$1.isUndefined(config.withCredentials)) {
  2494. request.withCredentials = !!config.withCredentials;
  2495. }
  2496. // Add responseType to request if needed
  2497. if (responseType && responseType !== 'json') {
  2498. request.responseType = config.responseType;
  2499. }
  2500. // Handle progress if needed
  2501. if (typeof config.onDownloadProgress === 'function') {
  2502. request.addEventListener('progress', progressEventReducer(config.onDownloadProgress, true));
  2503. }
  2504. // Not all browsers support upload events
  2505. if (typeof config.onUploadProgress === 'function' && request.upload) {
  2506. request.upload.addEventListener('progress', progressEventReducer(config.onUploadProgress));
  2507. }
  2508. if (config.cancelToken || config.signal) {
  2509. // Handle cancellation
  2510. // eslint-disable-next-line func-names
  2511. onCanceled = function onCanceled(cancel) {
  2512. if (!request) {
  2513. return;
  2514. }
  2515. reject(!cancel || cancel.type ? new CanceledError(null, config, request) : cancel);
  2516. request.abort();
  2517. request = null;
  2518. };
  2519. config.cancelToken && config.cancelToken.subscribe(onCanceled);
  2520. if (config.signal) {
  2521. config.signal.aborted ? onCanceled() : config.signal.addEventListener('abort', onCanceled);
  2522. }
  2523. }
  2524. var protocol = parseProtocol(fullPath);
  2525. if (protocol && platform.protocols.indexOf(protocol) === -1) {
  2526. reject(new AxiosError('Unsupported protocol ' + protocol + ':', AxiosError.ERR_BAD_REQUEST, config));
  2527. return;
  2528. }
  2529. // Send the request
  2530. request.send(requestData || null);
  2531. });
  2532. };
  2533. var knownAdapters = {
  2534. http: httpAdapter,
  2535. xhr: xhrAdapter
  2536. };
  2537. utils$1.forEach(knownAdapters, function (fn, value) {
  2538. if (fn) {
  2539. try {
  2540. Object.defineProperty(fn, 'name', {
  2541. value: value
  2542. });
  2543. } catch (e) {
  2544. // eslint-disable-next-line no-empty
  2545. }
  2546. Object.defineProperty(fn, 'adapterName', {
  2547. value: value
  2548. });
  2549. }
  2550. });
  2551. var renderReason = function renderReason(reason) {
  2552. return "- ".concat(reason);
  2553. };
  2554. var isResolvedHandle = function isResolvedHandle(adapter) {
  2555. return utils$1.isFunction(adapter) || adapter === null || adapter === false;
  2556. };
  2557. var adapters = {
  2558. getAdapter: function getAdapter(adapters) {
  2559. adapters = utils$1.isArray(adapters) ? adapters : [adapters];
  2560. var _adapters = adapters,
  2561. length = _adapters.length;
  2562. var nameOrAdapter;
  2563. var adapter;
  2564. var rejectedReasons = {};
  2565. for (var i = 0; i < length; i++) {
  2566. nameOrAdapter = adapters[i];
  2567. var id = void 0;
  2568. adapter = nameOrAdapter;
  2569. if (!isResolvedHandle(nameOrAdapter)) {
  2570. adapter = knownAdapters[(id = String(nameOrAdapter)).toLowerCase()];
  2571. if (adapter === undefined) {
  2572. throw new AxiosError("Unknown adapter '".concat(id, "'"));
  2573. }
  2574. }
  2575. if (adapter) {
  2576. break;
  2577. }
  2578. rejectedReasons[id || '#' + i] = adapter;
  2579. }
  2580. if (!adapter) {
  2581. var reasons = Object.entries(rejectedReasons).map(function (_ref) {
  2582. var _ref2 = _slicedToArray(_ref, 2),
  2583. id = _ref2[0],
  2584. state = _ref2[1];
  2585. return "adapter ".concat(id, " ") + (state === false ? 'is not supported by the environment' : 'is not available in the build');
  2586. });
  2587. var s = length ? reasons.length > 1 ? 'since :\n' + reasons.map(renderReason).join('\n') : ' ' + renderReason(reasons[0]) : 'as no adapter specified';
  2588. throw new AxiosError("There is no suitable adapter to dispatch the request " + s, 'ERR_NOT_SUPPORT');
  2589. }
  2590. return adapter;
  2591. },
  2592. adapters: knownAdapters
  2593. };
  2594. /**
  2595. * Throws a `CanceledError` if cancellation has been requested.
  2596. *
  2597. * @param {Object} config The config that is to be used for the request
  2598. *
  2599. * @returns {void}
  2600. */
  2601. function throwIfCancellationRequested(config) {
  2602. if (config.cancelToken) {
  2603. config.cancelToken.throwIfRequested();
  2604. }
  2605. if (config.signal && config.signal.aborted) {
  2606. throw new CanceledError(null, config);
  2607. }
  2608. }
  2609. /**
  2610. * Dispatch a request to the server using the configured adapter.
  2611. *
  2612. * @param {object} config The config that is to be used for the request
  2613. *
  2614. * @returns {Promise} The Promise to be fulfilled
  2615. */
  2616. function dispatchRequest(config) {
  2617. throwIfCancellationRequested(config);
  2618. config.headers = AxiosHeaders$1.from(config.headers);
  2619. // Transform request data
  2620. config.data = transformData.call(config, config.transformRequest);
  2621. if (['post', 'put', 'patch'].indexOf(config.method) !== -1) {
  2622. config.headers.setContentType('application/x-www-form-urlencoded', false);
  2623. }
  2624. var adapter = adapters.getAdapter(config.adapter || defaults$1.adapter);
  2625. return adapter(config).then(function onAdapterResolution(response) {
  2626. throwIfCancellationRequested(config);
  2627. // Transform response data
  2628. response.data = transformData.call(config, config.transformResponse, response);
  2629. response.headers = AxiosHeaders$1.from(response.headers);
  2630. return response;
  2631. }, function onAdapterRejection(reason) {
  2632. if (!isCancel(reason)) {
  2633. throwIfCancellationRequested(config);
  2634. // Transform response data
  2635. if (reason && reason.response) {
  2636. reason.response.data = transformData.call(config, config.transformResponse, reason.response);
  2637. reason.response.headers = AxiosHeaders$1.from(reason.response.headers);
  2638. }
  2639. }
  2640. return Promise.reject(reason);
  2641. });
  2642. }
  2643. var headersToObject = function headersToObject(thing) {
  2644. return thing instanceof AxiosHeaders$1 ? _objectSpread2({}, thing) : thing;
  2645. };
  2646. /**
  2647. * Config-specific merge-function which creates a new config-object
  2648. * by merging two configuration objects together.
  2649. *
  2650. * @param {Object} config1
  2651. * @param {Object} config2
  2652. *
  2653. * @returns {Object} New object resulting from merging config2 to config1
  2654. */
  2655. function mergeConfig(config1, config2) {
  2656. // eslint-disable-next-line no-param-reassign
  2657. config2 = config2 || {};
  2658. var config = {};
  2659. function getMergedValue(target, source, caseless) {
  2660. if (utils$1.isPlainObject(target) && utils$1.isPlainObject(source)) {
  2661. return utils$1.merge.call({
  2662. caseless: caseless
  2663. }, target, source);
  2664. } else if (utils$1.isPlainObject(source)) {
  2665. return utils$1.merge({}, source);
  2666. } else if (utils$1.isArray(source)) {
  2667. return source.slice();
  2668. }
  2669. return source;
  2670. }
  2671. // eslint-disable-next-line consistent-return
  2672. function mergeDeepProperties(a, b, caseless) {
  2673. if (!utils$1.isUndefined(b)) {
  2674. return getMergedValue(a, b, caseless);
  2675. } else if (!utils$1.isUndefined(a)) {
  2676. return getMergedValue(undefined, a, caseless);
  2677. }
  2678. }
  2679. // eslint-disable-next-line consistent-return
  2680. function valueFromConfig2(a, b) {
  2681. if (!utils$1.isUndefined(b)) {
  2682. return getMergedValue(undefined, b);
  2683. }
  2684. }
  2685. // eslint-disable-next-line consistent-return
  2686. function defaultToConfig2(a, b) {
  2687. if (!utils$1.isUndefined(b)) {
  2688. return getMergedValue(undefined, b);
  2689. } else if (!utils$1.isUndefined(a)) {
  2690. return getMergedValue(undefined, a);
  2691. }
  2692. }
  2693. // eslint-disable-next-line consistent-return
  2694. function mergeDirectKeys(a, b, prop) {
  2695. if (prop in config2) {
  2696. return getMergedValue(a, b);
  2697. } else if (prop in config1) {
  2698. return getMergedValue(undefined, a);
  2699. }
  2700. }
  2701. var mergeMap = {
  2702. url: valueFromConfig2,
  2703. method: valueFromConfig2,
  2704. data: valueFromConfig2,
  2705. baseURL: defaultToConfig2,
  2706. transformRequest: defaultToConfig2,
  2707. transformResponse: defaultToConfig2,
  2708. paramsSerializer: defaultToConfig2,
  2709. timeout: defaultToConfig2,
  2710. timeoutMessage: defaultToConfig2,
  2711. withCredentials: defaultToConfig2,
  2712. withXSRFToken: defaultToConfig2,
  2713. adapter: defaultToConfig2,
  2714. responseType: defaultToConfig2,
  2715. xsrfCookieName: defaultToConfig2,
  2716. xsrfHeaderName: defaultToConfig2,
  2717. onUploadProgress: defaultToConfig2,
  2718. onDownloadProgress: defaultToConfig2,
  2719. decompress: defaultToConfig2,
  2720. maxContentLength: defaultToConfig2,
  2721. maxBodyLength: defaultToConfig2,
  2722. beforeRedirect: defaultToConfig2,
  2723. transport: defaultToConfig2,
  2724. httpAgent: defaultToConfig2,
  2725. httpsAgent: defaultToConfig2,
  2726. cancelToken: defaultToConfig2,
  2727. socketPath: defaultToConfig2,
  2728. responseEncoding: defaultToConfig2,
  2729. validateStatus: mergeDirectKeys,
  2730. headers: function headers(a, b) {
  2731. return mergeDeepProperties(headersToObject(a), headersToObject(b), true);
  2732. }
  2733. };
  2734. utils$1.forEach(Object.keys(Object.assign({}, config1, config2)), function computeConfigValue(prop) {
  2735. var merge = mergeMap[prop] || mergeDeepProperties;
  2736. var configValue = merge(config1[prop], config2[prop], prop);
  2737. utils$1.isUndefined(configValue) && merge !== mergeDirectKeys || (config[prop] = configValue);
  2738. });
  2739. return config;
  2740. }
  2741. var VERSION = "1.6.8";
  2742. var validators$1 = {};
  2743. // eslint-disable-next-line func-names
  2744. ['object', 'boolean', 'number', 'function', 'string', 'symbol'].forEach(function (type, i) {
  2745. validators$1[type] = function validator(thing) {
  2746. return _typeof(thing) === type || 'a' + (i < 1 ? 'n ' : ' ') + type;
  2747. };
  2748. });
  2749. var deprecatedWarnings = {};
  2750. /**
  2751. * Transitional option validator
  2752. *
  2753. * @param {function|boolean?} validator - set to false if the transitional option has been removed
  2754. * @param {string?} version - deprecated version / removed since version
  2755. * @param {string?} message - some message with additional info
  2756. *
  2757. * @returns {function}
  2758. */
  2759. validators$1.transitional = function transitional(validator, version, message) {
  2760. function formatMessage(opt, desc) {
  2761. return '[Axios v' + VERSION + '] Transitional option \'' + opt + '\'' + desc + (message ? '. ' + message : '');
  2762. }
  2763. // eslint-disable-next-line func-names
  2764. return function (value, opt, opts) {
  2765. if (validator === false) {
  2766. throw new AxiosError(formatMessage(opt, ' has been removed' + (version ? ' in ' + version : '')), AxiosError.ERR_DEPRECATED);
  2767. }
  2768. if (version && !deprecatedWarnings[opt]) {
  2769. deprecatedWarnings[opt] = true;
  2770. // eslint-disable-next-line no-console
  2771. console.warn(formatMessage(opt, ' has been deprecated since v' + version + ' and will be removed in the near future'));
  2772. }
  2773. return validator ? validator(value, opt, opts) : true;
  2774. };
  2775. };
  2776. /**
  2777. * Assert object's properties type
  2778. *
  2779. * @param {object} options
  2780. * @param {object} schema
  2781. * @param {boolean?} allowUnknown
  2782. *
  2783. * @returns {object}
  2784. */
  2785. function assertOptions(options, schema, allowUnknown) {
  2786. if (_typeof(options) !== 'object') {
  2787. throw new AxiosError('options must be an object', AxiosError.ERR_BAD_OPTION_VALUE);
  2788. }
  2789. var keys = Object.keys(options);
  2790. var i = keys.length;
  2791. while (i-- > 0) {
  2792. var opt = keys[i];
  2793. var validator = schema[opt];
  2794. if (validator) {
  2795. var value = options[opt];
  2796. var result = value === undefined || validator(value, opt, options);
  2797. if (result !== true) {
  2798. throw new AxiosError('option ' + opt + ' must be ' + result, AxiosError.ERR_BAD_OPTION_VALUE);
  2799. }
  2800. continue;
  2801. }
  2802. if (allowUnknown !== true) {
  2803. throw new AxiosError('Unknown option ' + opt, AxiosError.ERR_BAD_OPTION);
  2804. }
  2805. }
  2806. }
  2807. var validator = {
  2808. assertOptions: assertOptions,
  2809. validators: validators$1
  2810. };
  2811. var validators = validator.validators;
  2812. /**
  2813. * Create a new instance of Axios
  2814. *
  2815. * @param {Object} instanceConfig The default config for the instance
  2816. *
  2817. * @return {Axios} A new instance of Axios
  2818. */
  2819. var Axios = /*#__PURE__*/function () {
  2820. function Axios(instanceConfig) {
  2821. _classCallCheck(this, Axios);
  2822. this.defaults = instanceConfig;
  2823. this.interceptors = {
  2824. request: new InterceptorManager$1(),
  2825. response: new InterceptorManager$1()
  2826. };
  2827. }
  2828. /**
  2829. * Dispatch a request
  2830. *
  2831. * @param {String|Object} configOrUrl The config specific for this request (merged with this.defaults)
  2832. * @param {?Object} config
  2833. *
  2834. * @returns {Promise} The Promise to be fulfilled
  2835. */
  2836. _createClass(Axios, [{
  2837. key: "request",
  2838. value: (function () {
  2839. var _request2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(configOrUrl, config) {
  2840. var dummy, stack;
  2841. return _regeneratorRuntime().wrap(function _callee$(_context) {
  2842. while (1) switch (_context.prev = _context.next) {
  2843. case 0:
  2844. _context.prev = 0;
  2845. _context.next = 3;
  2846. return this._request(configOrUrl, config);
  2847. case 3:
  2848. return _context.abrupt("return", _context.sent);
  2849. case 6:
  2850. _context.prev = 6;
  2851. _context.t0 = _context["catch"](0);
  2852. if (_context.t0 instanceof Error) {
  2853. Error.captureStackTrace ? Error.captureStackTrace(dummy = {}) : dummy = new Error();
  2854. // slice off the Error: ... line
  2855. stack = dummy.stack ? dummy.stack.replace(/^.+\n/, '') : '';
  2856. if (!_context.t0.stack) {
  2857. _context.t0.stack = stack;
  2858. // match without the 2 top stack lines
  2859. } else if (stack && !String(_context.t0.stack).endsWith(stack.replace(/^.+\n.+\n/, ''))) {
  2860. _context.t0.stack += '\n' + stack;
  2861. }
  2862. }
  2863. throw _context.t0;
  2864. case 10:
  2865. case "end":
  2866. return _context.stop();
  2867. }
  2868. }, _callee, this, [[0, 6]]);
  2869. }));
  2870. function request(_x, _x2) {
  2871. return _request2.apply(this, arguments);
  2872. }
  2873. return request;
  2874. }())
  2875. }, {
  2876. key: "_request",
  2877. value: function _request(configOrUrl, config) {
  2878. /*eslint no-param-reassign:0*/
  2879. // Allow for axios('example/url'[, config]) a la fetch API
  2880. if (typeof configOrUrl === 'string') {
  2881. config = config || {};
  2882. config.url = configOrUrl;
  2883. } else {
  2884. config = configOrUrl || {};
  2885. }
  2886. config = mergeConfig(this.defaults, config);
  2887. var _config = config,
  2888. transitional = _config.transitional,
  2889. paramsSerializer = _config.paramsSerializer,
  2890. headers = _config.headers;
  2891. if (transitional !== undefined) {
  2892. validator.assertOptions(transitional, {
  2893. silentJSONParsing: validators.transitional(validators["boolean"]),
  2894. forcedJSONParsing: validators.transitional(validators["boolean"]),
  2895. clarifyTimeoutError: validators.transitional(validators["boolean"])
  2896. }, false);
  2897. }
  2898. if (paramsSerializer != null) {
  2899. if (utils$1.isFunction(paramsSerializer)) {
  2900. config.paramsSerializer = {
  2901. serialize: paramsSerializer
  2902. };
  2903. } else {
  2904. validator.assertOptions(paramsSerializer, {
  2905. encode: validators["function"],
  2906. serialize: validators["function"]
  2907. }, true);
  2908. }
  2909. }
  2910. // Set config.method
  2911. config.method = (config.method || this.defaults.method || 'get').toLowerCase();
  2912. // Flatten headers
  2913. var contextHeaders = headers && utils$1.merge(headers.common, headers[config.method]);
  2914. headers && utils$1.forEach(['delete', 'get', 'head', 'post', 'put', 'patch', 'common'], function (method) {
  2915. delete headers[method];
  2916. });
  2917. config.headers = AxiosHeaders$1.concat(contextHeaders, headers);
  2918. // filter out skipped interceptors
  2919. var requestInterceptorChain = [];
  2920. var synchronousRequestInterceptors = true;
  2921. this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
  2922. if (typeof interceptor.runWhen === 'function' && interceptor.runWhen(config) === false) {
  2923. return;
  2924. }
  2925. synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
  2926. requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
  2927. });
  2928. var responseInterceptorChain = [];
  2929. this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
  2930. responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
  2931. });
  2932. var promise;
  2933. var i = 0;
  2934. var len;
  2935. if (!synchronousRequestInterceptors) {
  2936. var chain = [dispatchRequest.bind(this), undefined];
  2937. chain.unshift.apply(chain, requestInterceptorChain);
  2938. chain.push.apply(chain, responseInterceptorChain);
  2939. len = chain.length;
  2940. promise = Promise.resolve(config);
  2941. while (i < len) {
  2942. promise = promise.then(chain[i++], chain[i++]);
  2943. }
  2944. return promise;
  2945. }
  2946. len = requestInterceptorChain.length;
  2947. var newConfig = config;
  2948. i = 0;
  2949. while (i < len) {
  2950. var onFulfilled = requestInterceptorChain[i++];
  2951. var onRejected = requestInterceptorChain[i++];
  2952. try {
  2953. newConfig = onFulfilled(newConfig);
  2954. } catch (error) {
  2955. onRejected.call(this, error);
  2956. break;
  2957. }
  2958. }
  2959. try {
  2960. promise = dispatchRequest.call(this, newConfig);
  2961. } catch (error) {
  2962. return Promise.reject(error);
  2963. }
  2964. i = 0;
  2965. len = responseInterceptorChain.length;
  2966. while (i < len) {
  2967. promise = promise.then(responseInterceptorChain[i++], responseInterceptorChain[i++]);
  2968. }
  2969. return promise;
  2970. }
  2971. }, {
  2972. key: "getUri",
  2973. value: function getUri(config) {
  2974. config = mergeConfig(this.defaults, config);
  2975. var fullPath = buildFullPath(config.baseURL, config.url);
  2976. return buildURL(fullPath, config.params, config.paramsSerializer);
  2977. }
  2978. }]);
  2979. return Axios;
  2980. }(); // Provide aliases for supported request methods
  2981. utils$1.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
  2982. /*eslint func-names:0*/
  2983. Axios.prototype[method] = function (url, config) {
  2984. return this.request(mergeConfig(config || {}, {
  2985. method: method,
  2986. url: url,
  2987. data: (config || {}).data
  2988. }));
  2989. };
  2990. });
  2991. utils$1.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
  2992. /*eslint func-names:0*/
  2993. function generateHTTPMethod(isForm) {
  2994. return function httpMethod(url, data, config) {
  2995. return this.request(mergeConfig(config || {}, {
  2996. method: method,
  2997. headers: isForm ? {
  2998. 'Content-Type': 'multipart/form-data'
  2999. } : {},
  3000. url: url,
  3001. data: data
  3002. }));
  3003. };
  3004. }
  3005. Axios.prototype[method] = generateHTTPMethod();
  3006. Axios.prototype[method + 'Form'] = generateHTTPMethod(true);
  3007. });
  3008. var Axios$1 = Axios;
  3009. /**
  3010. * A `CancelToken` is an object that can be used to request cancellation of an operation.
  3011. *
  3012. * @param {Function} executor The executor function.
  3013. *
  3014. * @returns {CancelToken}
  3015. */
  3016. var CancelToken = /*#__PURE__*/function () {
  3017. function CancelToken(executor) {
  3018. _classCallCheck(this, CancelToken);
  3019. if (typeof executor !== 'function') {
  3020. throw new TypeError('executor must be a function.');
  3021. }
  3022. var resolvePromise;
  3023. this.promise = new Promise(function promiseExecutor(resolve) {
  3024. resolvePromise = resolve;
  3025. });
  3026. var token = this;
  3027. // eslint-disable-next-line func-names
  3028. this.promise.then(function (cancel) {
  3029. if (!token._listeners) return;
  3030. var i = token._listeners.length;
  3031. while (i-- > 0) {
  3032. token._listeners[i](cancel);
  3033. }
  3034. token._listeners = null;
  3035. });
  3036. // eslint-disable-next-line func-names
  3037. this.promise.then = function (onfulfilled) {
  3038. var _resolve;
  3039. // eslint-disable-next-line func-names
  3040. var promise = new Promise(function (resolve) {
  3041. token.subscribe(resolve);
  3042. _resolve = resolve;
  3043. }).then(onfulfilled);
  3044. promise.cancel = function reject() {
  3045. token.unsubscribe(_resolve);
  3046. };
  3047. return promise;
  3048. };
  3049. executor(function cancel(message, config, request) {
  3050. if (token.reason) {
  3051. // Cancellation has already been requested
  3052. return;
  3053. }
  3054. token.reason = new CanceledError(message, config, request);
  3055. resolvePromise(token.reason);
  3056. });
  3057. }
  3058. /**
  3059. * Throws a `CanceledError` if cancellation has been requested.
  3060. */
  3061. _createClass(CancelToken, [{
  3062. key: "throwIfRequested",
  3063. value: function throwIfRequested() {
  3064. if (this.reason) {
  3065. throw this.reason;
  3066. }
  3067. }
  3068. /**
  3069. * Subscribe to the cancel signal
  3070. */
  3071. }, {
  3072. key: "subscribe",
  3073. value: function subscribe(listener) {
  3074. if (this.reason) {
  3075. listener(this.reason);
  3076. return;
  3077. }
  3078. if (this._listeners) {
  3079. this._listeners.push(listener);
  3080. } else {
  3081. this._listeners = [listener];
  3082. }
  3083. }
  3084. /**
  3085. * Unsubscribe from the cancel signal
  3086. */
  3087. }, {
  3088. key: "unsubscribe",
  3089. value: function unsubscribe(listener) {
  3090. if (!this._listeners) {
  3091. return;
  3092. }
  3093. var index = this._listeners.indexOf(listener);
  3094. if (index !== -1) {
  3095. this._listeners.splice(index, 1);
  3096. }
  3097. }
  3098. /**
  3099. * Returns an object that contains a new `CancelToken` and a function that, when called,
  3100. * cancels the `CancelToken`.
  3101. */
  3102. }], [{
  3103. key: "source",
  3104. value: function source() {
  3105. var cancel;
  3106. var token = new CancelToken(function executor(c) {
  3107. cancel = c;
  3108. });
  3109. return {
  3110. token: token,
  3111. cancel: cancel
  3112. };
  3113. }
  3114. }]);
  3115. return CancelToken;
  3116. }();
  3117. var CancelToken$1 = CancelToken;
  3118. /**
  3119. * Syntactic sugar for invoking a function and expanding an array for arguments.
  3120. *
  3121. * Common use case would be to use `Function.prototype.apply`.
  3122. *
  3123. * ```js
  3124. * function f(x, y, z) {}
  3125. * var args = [1, 2, 3];
  3126. * f.apply(null, args);
  3127. * ```
  3128. *
  3129. * With `spread` this example can be re-written.
  3130. *
  3131. * ```js
  3132. * spread(function(x, y, z) {})([1, 2, 3]);
  3133. * ```
  3134. *
  3135. * @param {Function} callback
  3136. *
  3137. * @returns {Function}
  3138. */
  3139. function spread(callback) {
  3140. return function wrap(arr) {
  3141. return callback.apply(null, arr);
  3142. };
  3143. }
  3144. /**
  3145. * Determines whether the payload is an error thrown by Axios
  3146. *
  3147. * @param {*} payload The value to test
  3148. *
  3149. * @returns {boolean} True if the payload is an error thrown by Axios, otherwise false
  3150. */
  3151. function isAxiosError(payload) {
  3152. return utils$1.isObject(payload) && payload.isAxiosError === true;
  3153. }
  3154. var HttpStatusCode = {
  3155. Continue: 100,
  3156. SwitchingProtocols: 101,
  3157. Processing: 102,
  3158. EarlyHints: 103,
  3159. Ok: 200,
  3160. Created: 201,
  3161. Accepted: 202,
  3162. NonAuthoritativeInformation: 203,
  3163. NoContent: 204,
  3164. ResetContent: 205,
  3165. PartialContent: 206,
  3166. MultiStatus: 207,
  3167. AlreadyReported: 208,
  3168. ImUsed: 226,
  3169. MultipleChoices: 300,
  3170. MovedPermanently: 301,
  3171. Found: 302,
  3172. SeeOther: 303,
  3173. NotModified: 304,
  3174. UseProxy: 305,
  3175. Unused: 306,
  3176. TemporaryRedirect: 307,
  3177. PermanentRedirect: 308,
  3178. BadRequest: 400,
  3179. Unauthorized: 401,
  3180. PaymentRequired: 402,
  3181. Forbidden: 403,
  3182. NotFound: 404,
  3183. MethodNotAllowed: 405,
  3184. NotAcceptable: 406,
  3185. ProxyAuthenticationRequired: 407,
  3186. RequestTimeout: 408,
  3187. Conflict: 409,
  3188. Gone: 410,
  3189. LengthRequired: 411,
  3190. PreconditionFailed: 412,
  3191. PayloadTooLarge: 413,
  3192. UriTooLong: 414,
  3193. UnsupportedMediaType: 415,
  3194. RangeNotSatisfiable: 416,
  3195. ExpectationFailed: 417,
  3196. ImATeapot: 418,
  3197. MisdirectedRequest: 421,
  3198. UnprocessableEntity: 422,
  3199. Locked: 423,
  3200. FailedDependency: 424,
  3201. TooEarly: 425,
  3202. UpgradeRequired: 426,
  3203. PreconditionRequired: 428,
  3204. TooManyRequests: 429,
  3205. RequestHeaderFieldsTooLarge: 431,
  3206. UnavailableForLegalReasons: 451,
  3207. InternalServerError: 500,
  3208. NotImplemented: 501,
  3209. BadGateway: 502,
  3210. ServiceUnavailable: 503,
  3211. GatewayTimeout: 504,
  3212. HttpVersionNotSupported: 505,
  3213. VariantAlsoNegotiates: 506,
  3214. InsufficientStorage: 507,
  3215. LoopDetected: 508,
  3216. NotExtended: 510,
  3217. NetworkAuthenticationRequired: 511
  3218. };
  3219. Object.entries(HttpStatusCode).forEach(function (_ref) {
  3220. var _ref2 = _slicedToArray(_ref, 2),
  3221. key = _ref2[0],
  3222. value = _ref2[1];
  3223. HttpStatusCode[value] = key;
  3224. });
  3225. var HttpStatusCode$1 = HttpStatusCode;
  3226. /**
  3227. * Create an instance of Axios
  3228. *
  3229. * @param {Object} defaultConfig The default config for the instance
  3230. *
  3231. * @returns {Axios} A new instance of Axios
  3232. */
  3233. function createInstance(defaultConfig) {
  3234. var context = new Axios$1(defaultConfig);
  3235. var instance = bind(Axios$1.prototype.request, context);
  3236. // Copy axios.prototype to instance
  3237. utils$1.extend(instance, Axios$1.prototype, context, {
  3238. allOwnKeys: true
  3239. });
  3240. // Copy context to instance
  3241. utils$1.extend(instance, context, null, {
  3242. allOwnKeys: true
  3243. });
  3244. // Factory for creating new instances
  3245. instance.create = function create(instanceConfig) {
  3246. return createInstance(mergeConfig(defaultConfig, instanceConfig));
  3247. };
  3248. return instance;
  3249. }
  3250. // Create the default instance to be exported
  3251. var axios = createInstance(defaults$1);
  3252. // Expose Axios class to allow class inheritance
  3253. axios.Axios = Axios$1;
  3254. // Expose Cancel & CancelToken
  3255. axios.CanceledError = CanceledError;
  3256. axios.CancelToken = CancelToken$1;
  3257. axios.isCancel = isCancel;
  3258. axios.VERSION = VERSION;
  3259. axios.toFormData = toFormData;
  3260. // Expose AxiosError class
  3261. axios.AxiosError = AxiosError;
  3262. // alias for CanceledError for backward compatibility
  3263. axios.Cancel = axios.CanceledError;
  3264. // Expose all/spread
  3265. axios.all = function all(promises) {
  3266. return Promise.all(promises);
  3267. };
  3268. axios.spread = spread;
  3269. // Expose isAxiosError
  3270. axios.isAxiosError = isAxiosError;
  3271. // Expose mergeConfig
  3272. axios.mergeConfig = mergeConfig;
  3273. axios.AxiosHeaders = AxiosHeaders$1;
  3274. axios.formToJSON = function (thing) {
  3275. return formDataToJSON(utils$1.isHTMLForm(thing) ? new FormData(thing) : thing);
  3276. };
  3277. axios.getAdapter = adapters.getAdapter;
  3278. axios.HttpStatusCode = HttpStatusCode$1;
  3279. axios["default"] = axios;
  3280. return axios;
  3281. }));
  3282. //# sourceMappingURL=axios.js.map