axios.js 164 KB

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