axios.js 143 KB

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