axios.js 137 KB

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