axios.js 145 KB

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