axios.js 147 KB

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