axios.cjs 95 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730
  1. /*! Axios v1.10.0 Copyright (c) 2025 Matt Zabriskie and contributors */
  2. 'use strict';
  3. function bind(fn, thisArg) {
  4. return function wrap() {
  5. return fn.apply(thisArg, arguments);
  6. };
  7. }
  8. // utils is a library of generic helper functions non-specific to axios
  9. const {toString} = Object.prototype;
  10. const {getPrototypeOf} = Object;
  11. const {iterator, toStringTag} = Symbol;
  12. const kindOf = (cache => thing => {
  13. const str = toString.call(thing);
  14. return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase());
  15. })(Object.create(null));
  16. const kindOfTest = (type) => {
  17. type = type.toLowerCase();
  18. return (thing) => kindOf(thing) === type
  19. };
  20. const typeOfTest = type => thing => typeof thing === type;
  21. /**
  22. * Determine if a value is an Array
  23. *
  24. * @param {Object} val The value to test
  25. *
  26. * @returns {boolean} True if value is an Array, otherwise false
  27. */
  28. const {isArray} = Array;
  29. /**
  30. * Determine if a value is undefined
  31. *
  32. * @param {*} val The value to test
  33. *
  34. * @returns {boolean} True if the value is undefined, otherwise false
  35. */
  36. const isUndefined = typeOfTest('undefined');
  37. /**
  38. * Determine if a value is a Buffer
  39. *
  40. * @param {*} val The value to test
  41. *
  42. * @returns {boolean} True if value is a Buffer, otherwise false
  43. */
  44. function isBuffer(val) {
  45. return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor)
  46. && isFunction(val.constructor.isBuffer) && val.constructor.isBuffer(val);
  47. }
  48. /**
  49. * Determine if a value is an ArrayBuffer
  50. *
  51. * @param {*} val The value to test
  52. *
  53. * @returns {boolean} True if value is an ArrayBuffer, otherwise false
  54. */
  55. const isArrayBuffer = kindOfTest('ArrayBuffer');
  56. /**
  57. * Determine if a value is a view on an ArrayBuffer
  58. *
  59. * @param {*} val The value to test
  60. *
  61. * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false
  62. */
  63. function isArrayBufferView(val) {
  64. let result;
  65. if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {
  66. result = ArrayBuffer.isView(val);
  67. } else {
  68. result = (val) && (val.buffer) && (isArrayBuffer(val.buffer));
  69. }
  70. return result;
  71. }
  72. /**
  73. * Determine if a value is a String
  74. *
  75. * @param {*} val The value to test
  76. *
  77. * @returns {boolean} True if value is a String, otherwise false
  78. */
  79. const isString = typeOfTest('string');
  80. /**
  81. * Determine if a value is a Function
  82. *
  83. * @param {*} val The value to test
  84. * @returns {boolean} True if value is a Function, otherwise false
  85. */
  86. const isFunction = typeOfTest('function');
  87. /**
  88. * Determine if a value is a Number
  89. *
  90. * @param {*} val The value to test
  91. *
  92. * @returns {boolean} True if value is a Number, otherwise false
  93. */
  94. const isNumber = typeOfTest('number');
  95. /**
  96. * Determine if a value is an Object
  97. *
  98. * @param {*} thing The value to test
  99. *
  100. * @returns {boolean} True if value is an Object, otherwise false
  101. */
  102. const isObject = (thing) => thing !== null && typeof thing === 'object';
  103. /**
  104. * Determine if a value is a Boolean
  105. *
  106. * @param {*} thing The value to test
  107. * @returns {boolean} True if value is a Boolean, otherwise false
  108. */
  109. const isBoolean = thing => thing === true || thing === false;
  110. /**
  111. * Determine if a value is a plain Object
  112. *
  113. * @param {*} val The value to test
  114. *
  115. * @returns {boolean} True if value is a plain Object, otherwise false
  116. */
  117. const isPlainObject = (val) => {
  118. if (kindOf(val) !== 'object') {
  119. return false;
  120. }
  121. const prototype = getPrototypeOf(val);
  122. return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(toStringTag in val) && !(iterator in val);
  123. };
  124. /**
  125. * Determine if a value is a Date
  126. *
  127. * @param {*} val The value to test
  128. *
  129. * @returns {boolean} True if value is a Date, otherwise false
  130. */
  131. const isDate = kindOfTest('Date');
  132. /**
  133. * Determine if a value is a File
  134. *
  135. * @param {*} val The value to test
  136. *
  137. * @returns {boolean} True if value is a File, otherwise false
  138. */
  139. const isFile = kindOfTest('File');
  140. /**
  141. * Determine if a value is a Blob
  142. *
  143. * @param {*} val The value to test
  144. *
  145. * @returns {boolean} True if value is a Blob, otherwise false
  146. */
  147. const isBlob = kindOfTest('Blob');
  148. /**
  149. * Determine if a value is a FileList
  150. *
  151. * @param {*} val The value to test
  152. *
  153. * @returns {boolean} True if value is a File, otherwise false
  154. */
  155. const isFileList = kindOfTest('FileList');
  156. /**
  157. * Determine if a value is a Stream
  158. *
  159. * @param {*} val The value to test
  160. *
  161. * @returns {boolean} True if value is a Stream, otherwise false
  162. */
  163. const isStream = (val) => isObject(val) && isFunction(val.pipe);
  164. /**
  165. * Determine if a value is a FormData
  166. *
  167. * @param {*} thing The value to test
  168. *
  169. * @returns {boolean} True if value is an FormData, otherwise false
  170. */
  171. const isFormData = (thing) => {
  172. let kind;
  173. return thing && (
  174. (typeof FormData === 'function' && thing instanceof FormData) || (
  175. isFunction(thing.append) && (
  176. (kind = kindOf(thing)) === 'formdata' ||
  177. // detect form-data instance
  178. (kind === 'object' && isFunction(thing.toString) && thing.toString() === '[object FormData]')
  179. )
  180. )
  181. )
  182. };
  183. /**
  184. * Determine if a value is a URLSearchParams object
  185. *
  186. * @param {*} val The value to test
  187. *
  188. * @returns {boolean} True if value is a URLSearchParams object, otherwise false
  189. */
  190. const isURLSearchParams = kindOfTest('URLSearchParams');
  191. const [isReadableStream, isRequest, isResponse, isHeaders] = ['ReadableStream', 'Request', 'Response', 'Headers'].map(kindOfTest);
  192. /**
  193. * Trim excess whitespace off the beginning and end of a string
  194. *
  195. * @param {String} str The String to trim
  196. *
  197. * @returns {String} The String freed of excess whitespace
  198. */
  199. const trim = (str) => str.trim ?
  200. str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
  201. /**
  202. * Iterate over an Array or an Object invoking a function for each item.
  203. *
  204. * If `obj` is an Array callback will be called passing
  205. * the value, index, and complete array for each item.
  206. *
  207. * If 'obj' is an Object callback will be called passing
  208. * the value, key, and complete object for each property.
  209. *
  210. * @param {Object|Array} obj The object to iterate
  211. * @param {Function} fn The callback to invoke for each item
  212. *
  213. * @param {Boolean} [allOwnKeys = false]
  214. * @returns {any}
  215. */
  216. function forEach(obj, fn, {allOwnKeys = false} = {}) {
  217. // Don't bother if no value provided
  218. if (obj === null || typeof obj === 'undefined') {
  219. return;
  220. }
  221. let i;
  222. let l;
  223. // Force an array if not already something iterable
  224. if (typeof obj !== 'object') {
  225. /*eslint no-param-reassign:0*/
  226. obj = [obj];
  227. }
  228. if (isArray(obj)) {
  229. // Iterate over array values
  230. for (i = 0, l = obj.length; i < l; i++) {
  231. fn.call(null, obj[i], i, obj);
  232. }
  233. } else {
  234. // Iterate over object keys
  235. const keys = allOwnKeys ? Object.getOwnPropertyNames(obj) : Object.keys(obj);
  236. const len = keys.length;
  237. let key;
  238. for (i = 0; i < len; i++) {
  239. key = keys[i];
  240. fn.call(null, obj[key], key, obj);
  241. }
  242. }
  243. }
  244. function findKey(obj, key) {
  245. key = key.toLowerCase();
  246. const keys = Object.keys(obj);
  247. let i = keys.length;
  248. let _key;
  249. while (i-- > 0) {
  250. _key = keys[i];
  251. if (key === _key.toLowerCase()) {
  252. return _key;
  253. }
  254. }
  255. return null;
  256. }
  257. const _global = (() => {
  258. /*eslint no-undef:0*/
  259. if (typeof globalThis !== "undefined") return globalThis;
  260. return typeof self !== "undefined" ? self : (typeof window !== 'undefined' ? window : global)
  261. })();
  262. const isContextDefined = (context) => !isUndefined(context) && context !== _global;
  263. /**
  264. * Accepts varargs expecting each argument to be an object, then
  265. * immutably merges the properties of each object and returns result.
  266. *
  267. * When multiple objects contain the same key the later object in
  268. * the arguments list will take precedence.
  269. *
  270. * Example:
  271. *
  272. * ```js
  273. * var result = merge({foo: 123}, {foo: 456});
  274. * console.log(result.foo); // outputs 456
  275. * ```
  276. *
  277. * @param {Object} obj1 Object to merge
  278. *
  279. * @returns {Object} Result of all merge properties
  280. */
  281. function merge(/* obj1, obj2, obj3, ... */) {
  282. const {caseless} = isContextDefined(this) && this || {};
  283. const result = {};
  284. const assignValue = (val, key) => {
  285. const targetKey = caseless && findKey(result, key) || key;
  286. if (isPlainObject(result[targetKey]) && isPlainObject(val)) {
  287. result[targetKey] = merge(result[targetKey], val);
  288. } else if (isPlainObject(val)) {
  289. result[targetKey] = merge({}, val);
  290. } else if (isArray(val)) {
  291. result[targetKey] = val.slice();
  292. } else {
  293. result[targetKey] = val;
  294. }
  295. };
  296. for (let i = 0, l = arguments.length; i < l; i++) {
  297. arguments[i] && forEach(arguments[i], assignValue);
  298. }
  299. return result;
  300. }
  301. /**
  302. * Extends object a by mutably adding to it the properties of object b.
  303. *
  304. * @param {Object} a The object to be extended
  305. * @param {Object} b The object to copy properties from
  306. * @param {Object} thisArg The object to bind function to
  307. *
  308. * @param {Boolean} [allOwnKeys]
  309. * @returns {Object} The resulting value of object a
  310. */
  311. const extend = (a, b, thisArg, {allOwnKeys}= {}) => {
  312. forEach(b, (val, key) => {
  313. if (thisArg && isFunction(val)) {
  314. a[key] = bind(val, thisArg);
  315. } else {
  316. a[key] = val;
  317. }
  318. }, {allOwnKeys});
  319. return a;
  320. };
  321. /**
  322. * Remove byte order marker. This catches EF BB BF (the UTF-8 BOM)
  323. *
  324. * @param {string} content with BOM
  325. *
  326. * @returns {string} content value without BOM
  327. */
  328. const stripBOM = (content) => {
  329. if (content.charCodeAt(0) === 0xFEFF) {
  330. content = content.slice(1);
  331. }
  332. return content;
  333. };
  334. /**
  335. * Inherit the prototype methods from one constructor into another
  336. * @param {function} constructor
  337. * @param {function} superConstructor
  338. * @param {object} [props]
  339. * @param {object} [descriptors]
  340. *
  341. * @returns {void}
  342. */
  343. const inherits = (constructor, superConstructor, props, descriptors) => {
  344. constructor.prototype = Object.create(superConstructor.prototype, descriptors);
  345. constructor.prototype.constructor = constructor;
  346. Object.defineProperty(constructor, 'super', {
  347. value: superConstructor.prototype
  348. });
  349. props && Object.assign(constructor.prototype, props);
  350. };
  351. /**
  352. * Resolve object with deep prototype chain to a flat object
  353. * @param {Object} sourceObj source object
  354. * @param {Object} [destObj]
  355. * @param {Function|Boolean} [filter]
  356. * @param {Function} [propFilter]
  357. *
  358. * @returns {Object}
  359. */
  360. const toFlatObject = (sourceObj, destObj, filter, propFilter) => {
  361. let props;
  362. let i;
  363. let prop;
  364. const merged = {};
  365. destObj = destObj || {};
  366. // eslint-disable-next-line no-eq-null,eqeqeq
  367. if (sourceObj == null) return destObj;
  368. do {
  369. props = Object.getOwnPropertyNames(sourceObj);
  370. i = props.length;
  371. while (i-- > 0) {
  372. prop = props[i];
  373. if ((!propFilter || propFilter(prop, sourceObj, destObj)) && !merged[prop]) {
  374. destObj[prop] = sourceObj[prop];
  375. merged[prop] = true;
  376. }
  377. }
  378. sourceObj = filter !== false && getPrototypeOf(sourceObj);
  379. } while (sourceObj && (!filter || filter(sourceObj, destObj)) && sourceObj !== Object.prototype);
  380. return destObj;
  381. };
  382. /**
  383. * Determines whether a string ends with the characters of a specified string
  384. *
  385. * @param {String} str
  386. * @param {String} searchString
  387. * @param {Number} [position= 0]
  388. *
  389. * @returns {boolean}
  390. */
  391. const endsWith = (str, searchString, position) => {
  392. str = String(str);
  393. if (position === undefined || position > str.length) {
  394. position = str.length;
  395. }
  396. position -= searchString.length;
  397. const lastIndex = str.indexOf(searchString, position);
  398. return lastIndex !== -1 && lastIndex === position;
  399. };
  400. /**
  401. * Returns new array from array like object or null if failed
  402. *
  403. * @param {*} [thing]
  404. *
  405. * @returns {?Array}
  406. */
  407. const toArray = (thing) => {
  408. if (!thing) return null;
  409. if (isArray(thing)) return thing;
  410. let i = thing.length;
  411. if (!isNumber(i)) return null;
  412. const arr = new Array(i);
  413. while (i-- > 0) {
  414. arr[i] = thing[i];
  415. }
  416. return arr;
  417. };
  418. /**
  419. * Checking if the Uint8Array exists and if it does, it returns a function that checks if the
  420. * thing passed in is an instance of Uint8Array
  421. *
  422. * @param {TypedArray}
  423. *
  424. * @returns {Array}
  425. */
  426. // eslint-disable-next-line func-names
  427. const isTypedArray = (TypedArray => {
  428. // eslint-disable-next-line func-names
  429. return thing => {
  430. return TypedArray && thing instanceof TypedArray;
  431. };
  432. })(typeof Uint8Array !== 'undefined' && getPrototypeOf(Uint8Array));
  433. /**
  434. * For each entry in the object, call the function with the key and value.
  435. *
  436. * @param {Object<any, any>} obj - The object to iterate over.
  437. * @param {Function} fn - The function to call for each entry.
  438. *
  439. * @returns {void}
  440. */
  441. const forEachEntry = (obj, fn) => {
  442. const generator = obj && obj[iterator];
  443. const _iterator = generator.call(obj);
  444. let result;
  445. while ((result = _iterator.next()) && !result.done) {
  446. const pair = result.value;
  447. fn.call(obj, pair[0], pair[1]);
  448. }
  449. };
  450. /**
  451. * It takes a regular expression and a string, and returns an array of all the matches
  452. *
  453. * @param {string} regExp - The regular expression to match against.
  454. * @param {string} str - The string to search.
  455. *
  456. * @returns {Array<boolean>}
  457. */
  458. const matchAll = (regExp, str) => {
  459. let matches;
  460. const arr = [];
  461. while ((matches = regExp.exec(str)) !== null) {
  462. arr.push(matches);
  463. }
  464. return arr;
  465. };
  466. /* Checking if the kindOfTest function returns true when passed an HTMLFormElement. */
  467. const isHTMLForm = kindOfTest('HTMLFormElement');
  468. const toCamelCase = str => {
  469. return str.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,
  470. function replacer(m, p1, p2) {
  471. return p1.toUpperCase() + p2;
  472. }
  473. );
  474. };
  475. /* Creating a function that will check if an object has a property. */
  476. const hasOwnProperty = (({hasOwnProperty}) => (obj, prop) => hasOwnProperty.call(obj, prop))(Object.prototype);
  477. /**
  478. * Determine if a value is a RegExp object
  479. *
  480. * @param {*} val The value to test
  481. *
  482. * @returns {boolean} True if value is a RegExp object, otherwise false
  483. */
  484. const isRegExp = kindOfTest('RegExp');
  485. const reduceDescriptors = (obj, reducer) => {
  486. const descriptors = Object.getOwnPropertyDescriptors(obj);
  487. const reducedDescriptors = {};
  488. forEach(descriptors, (descriptor, name) => {
  489. let ret;
  490. if ((ret = reducer(descriptor, name, obj)) !== false) {
  491. reducedDescriptors[name] = ret || descriptor;
  492. }
  493. });
  494. Object.defineProperties(obj, reducedDescriptors);
  495. };
  496. /**
  497. * Makes all methods read-only
  498. * @param {Object} obj
  499. */
  500. const freezeMethods = (obj) => {
  501. reduceDescriptors(obj, (descriptor, name) => {
  502. // skip restricted props in strict mode
  503. if (isFunction(obj) && ['arguments', 'caller', 'callee'].indexOf(name) !== -1) {
  504. return false;
  505. }
  506. const value = obj[name];
  507. if (!isFunction(value)) return;
  508. descriptor.enumerable = false;
  509. if ('writable' in descriptor) {
  510. descriptor.writable = false;
  511. return;
  512. }
  513. if (!descriptor.set) {
  514. descriptor.set = () => {
  515. throw Error('Can not rewrite read-only method \'' + name + '\'');
  516. };
  517. }
  518. });
  519. };
  520. const toObjectSet = (arrayOrString, delimiter) => {
  521. const obj = {};
  522. const define = (arr) => {
  523. arr.forEach(value => {
  524. obj[value] = true;
  525. });
  526. };
  527. isArray(arrayOrString) ? define(arrayOrString) : define(String(arrayOrString).split(delimiter));
  528. return obj;
  529. };
  530. const noop = () => {};
  531. const toFiniteNumber = (value, defaultValue) => {
  532. return value != null && Number.isFinite(value = +value) ? value : defaultValue;
  533. };
  534. /**
  535. * If the thing is a FormData object, return true, otherwise return false.
  536. *
  537. * @param {unknown} thing - The thing to check.
  538. *
  539. * @returns {boolean}
  540. */
  541. function isSpecCompliantForm(thing) {
  542. return !!(thing && isFunction(thing.append) && thing[toStringTag] === 'FormData' && thing[iterator]);
  543. }
  544. const toJSONObject = (obj) => {
  545. const stack = new Array(10);
  546. const visit = (source, i) => {
  547. if (isObject(source)) {
  548. if (stack.indexOf(source) >= 0) {
  549. return;
  550. }
  551. if(!('toJSON' in source)) {
  552. stack[i] = source;
  553. const target = isArray(source) ? [] : {};
  554. forEach(source, (value, key) => {
  555. const reducedValue = visit(value, i + 1);
  556. !isUndefined(reducedValue) && (target[key] = reducedValue);
  557. });
  558. stack[i] = undefined;
  559. return target;
  560. }
  561. }
  562. return source;
  563. };
  564. return visit(obj, 0);
  565. };
  566. const isAsyncFn = kindOfTest('AsyncFunction');
  567. const isThenable = (thing) =>
  568. thing && (isObject(thing) || isFunction(thing)) && isFunction(thing.then) && isFunction(thing.catch);
  569. // original code
  570. // https://github.com/DigitalBrainJS/AxiosPromise/blob/16deab13710ec09779922131f3fa5954320f83ab/lib/utils.js#L11-L34
  571. const _setImmediate = ((setImmediateSupported, postMessageSupported) => {
  572. if (setImmediateSupported) {
  573. return setImmediate;
  574. }
  575. return postMessageSupported ? ((token, callbacks) => {
  576. _global.addEventListener("message", ({source, data}) => {
  577. if (source === _global && data === token) {
  578. callbacks.length && callbacks.shift()();
  579. }
  580. }, false);
  581. return (cb) => {
  582. callbacks.push(cb);
  583. _global.postMessage(token, "*");
  584. }
  585. })(`axios@${Math.random()}`, []) : (cb) => setTimeout(cb);
  586. })(
  587. typeof setImmediate === 'function',
  588. isFunction(_global.postMessage)
  589. );
  590. const asap = typeof queueMicrotask !== 'undefined' ?
  591. queueMicrotask.bind(_global) : ( typeof process !== 'undefined' && process.nextTick || _setImmediate);
  592. // *********************
  593. const isIterable = (thing) => thing != null && isFunction(thing[iterator]);
  594. var utils$1 = {
  595. isArray,
  596. isArrayBuffer,
  597. isBuffer,
  598. isFormData,
  599. isArrayBufferView,
  600. isString,
  601. isNumber,
  602. isBoolean,
  603. isObject,
  604. isPlainObject,
  605. isReadableStream,
  606. isRequest,
  607. isResponse,
  608. isHeaders,
  609. isUndefined,
  610. isDate,
  611. isFile,
  612. isBlob,
  613. isRegExp,
  614. isFunction,
  615. isStream,
  616. isURLSearchParams,
  617. isTypedArray,
  618. isFileList,
  619. forEach,
  620. merge,
  621. extend,
  622. trim,
  623. stripBOM,
  624. inherits,
  625. toFlatObject,
  626. kindOf,
  627. kindOfTest,
  628. endsWith,
  629. toArray,
  630. forEachEntry,
  631. matchAll,
  632. isHTMLForm,
  633. hasOwnProperty,
  634. hasOwnProp: hasOwnProperty, // an alias to avoid ESLint no-prototype-builtins detection
  635. reduceDescriptors,
  636. freezeMethods,
  637. toObjectSet,
  638. toCamelCase,
  639. noop,
  640. toFiniteNumber,
  641. findKey,
  642. global: _global,
  643. isContextDefined,
  644. isSpecCompliantForm,
  645. toJSONObject,
  646. isAsyncFn,
  647. isThenable,
  648. setImmediate: _setImmediate,
  649. asap,
  650. isIterable
  651. };
  652. /**
  653. * Create an Error with the specified message, config, error code, request and response.
  654. *
  655. * @param {string} message The error message.
  656. * @param {string} [code] The error code (for example, 'ECONNABORTED').
  657. * @param {Object} [config] The config.
  658. * @param {Object} [request] The request.
  659. * @param {Object} [response] The response.
  660. *
  661. * @returns {Error} The created error.
  662. */
  663. function AxiosError(message, code, config, request, response) {
  664. Error.call(this);
  665. if (Error.captureStackTrace) {
  666. Error.captureStackTrace(this, this.constructor);
  667. } else {
  668. this.stack = (new Error()).stack;
  669. }
  670. this.message = message;
  671. this.name = 'AxiosError';
  672. code && (this.code = code);
  673. config && (this.config = config);
  674. request && (this.request = request);
  675. if (response) {
  676. this.response = response;
  677. this.status = response.status ? response.status : null;
  678. }
  679. }
  680. utils$1.inherits(AxiosError, Error, {
  681. toJSON: function toJSON() {
  682. return {
  683. // Standard
  684. message: this.message,
  685. name: this.name,
  686. // Microsoft
  687. description: this.description,
  688. number: this.number,
  689. // Mozilla
  690. fileName: this.fileName,
  691. lineNumber: this.lineNumber,
  692. columnNumber: this.columnNumber,
  693. stack: this.stack,
  694. // Axios
  695. config: utils$1.toJSONObject(this.config),
  696. code: this.code,
  697. status: this.status
  698. };
  699. }
  700. });
  701. const prototype$1 = AxiosError.prototype;
  702. const descriptors = {};
  703. [
  704. 'ERR_BAD_OPTION_VALUE',
  705. 'ERR_BAD_OPTION',
  706. 'ECONNABORTED',
  707. 'ETIMEDOUT',
  708. 'ERR_NETWORK',
  709. 'ERR_FR_TOO_MANY_REDIRECTS',
  710. 'ERR_DEPRECATED',
  711. 'ERR_BAD_RESPONSE',
  712. 'ERR_BAD_REQUEST',
  713. 'ERR_CANCELED',
  714. 'ERR_NOT_SUPPORT',
  715. 'ERR_INVALID_URL'
  716. // eslint-disable-next-line func-names
  717. ].forEach(code => {
  718. descriptors[code] = {value: code};
  719. });
  720. Object.defineProperties(AxiosError, descriptors);
  721. Object.defineProperty(prototype$1, 'isAxiosError', {value: true});
  722. // eslint-disable-next-line func-names
  723. AxiosError.from = (error, code, config, request, response, customProps) => {
  724. const axiosError = Object.create(prototype$1);
  725. utils$1.toFlatObject(error, axiosError, function filter(obj) {
  726. return obj !== Error.prototype;
  727. }, prop => {
  728. return prop !== 'isAxiosError';
  729. });
  730. AxiosError.call(axiosError, error.message, code, config, request, response);
  731. axiosError.cause = error;
  732. axiosError.name = error.name;
  733. customProps && Object.assign(axiosError, customProps);
  734. return axiosError;
  735. };
  736. // eslint-disable-next-line strict
  737. var httpAdapter = null;
  738. /**
  739. * Determines if the given thing is a array or js object.
  740. *
  741. * @param {string} thing - The object or array to be visited.
  742. *
  743. * @returns {boolean}
  744. */
  745. function isVisitable(thing) {
  746. return utils$1.isPlainObject(thing) || utils$1.isArray(thing);
  747. }
  748. /**
  749. * It removes the brackets from the end of a string
  750. *
  751. * @param {string} key - The key of the parameter.
  752. *
  753. * @returns {string} the key without the brackets.
  754. */
  755. function removeBrackets(key) {
  756. return utils$1.endsWith(key, '[]') ? key.slice(0, -2) : key;
  757. }
  758. /**
  759. * It takes a path, a key, and a boolean, and returns a string
  760. *
  761. * @param {string} path - The path to the current key.
  762. * @param {string} key - The key of the current object being iterated over.
  763. * @param {string} dots - If true, the key will be rendered with dots instead of brackets.
  764. *
  765. * @returns {string} The path to the current key.
  766. */
  767. function renderKey(path, key, dots) {
  768. if (!path) return key;
  769. return path.concat(key).map(function each(token, i) {
  770. // eslint-disable-next-line no-param-reassign
  771. token = removeBrackets(token);
  772. return !dots && i ? '[' + token + ']' : token;
  773. }).join(dots ? '.' : '');
  774. }
  775. /**
  776. * If the array is an array and none of its elements are visitable, then it's a flat array.
  777. *
  778. * @param {Array<any>} arr - The array to check
  779. *
  780. * @returns {boolean}
  781. */
  782. function isFlatArray(arr) {
  783. return utils$1.isArray(arr) && !arr.some(isVisitable);
  784. }
  785. const predicates = utils$1.toFlatObject(utils$1, {}, null, function filter(prop) {
  786. return /^is[A-Z]/.test(prop);
  787. });
  788. /**
  789. * Convert a data object to FormData
  790. *
  791. * @param {Object} obj
  792. * @param {?Object} [formData]
  793. * @param {?Object} [options]
  794. * @param {Function} [options.visitor]
  795. * @param {Boolean} [options.metaTokens = true]
  796. * @param {Boolean} [options.dots = false]
  797. * @param {?Boolean} [options.indexes = false]
  798. *
  799. * @returns {Object}
  800. **/
  801. /**
  802. * It converts an object into a FormData object
  803. *
  804. * @param {Object<any, any>} obj - The object to convert to form data.
  805. * @param {string} formData - The FormData object to append to.
  806. * @param {Object<string, any>} options
  807. *
  808. * @returns
  809. */
  810. function toFormData(obj, formData, options) {
  811. if (!utils$1.isObject(obj)) {
  812. throw new TypeError('target must be an object');
  813. }
  814. // eslint-disable-next-line no-param-reassign
  815. formData = formData || new (FormData)();
  816. // eslint-disable-next-line no-param-reassign
  817. options = utils$1.toFlatObject(options, {
  818. metaTokens: true,
  819. dots: false,
  820. indexes: false
  821. }, false, function defined(option, source) {
  822. // eslint-disable-next-line no-eq-null,eqeqeq
  823. return !utils$1.isUndefined(source[option]);
  824. });
  825. const metaTokens = options.metaTokens;
  826. // eslint-disable-next-line no-use-before-define
  827. const visitor = options.visitor || defaultVisitor;
  828. const dots = options.dots;
  829. const indexes = options.indexes;
  830. const _Blob = options.Blob || typeof Blob !== 'undefined' && Blob;
  831. const useBlob = _Blob && utils$1.isSpecCompliantForm(formData);
  832. if (!utils$1.isFunction(visitor)) {
  833. throw new TypeError('visitor must be a function');
  834. }
  835. function convertValue(value) {
  836. if (value === null) return '';
  837. if (utils$1.isDate(value)) {
  838. return value.toISOString();
  839. }
  840. if (utils$1.isBoolean(value)) {
  841. return value.toString();
  842. }
  843. if (!useBlob && utils$1.isBlob(value)) {
  844. throw new AxiosError('Blob is not supported. Use a Buffer instead.');
  845. }
  846. if (utils$1.isArrayBuffer(value) || utils$1.isTypedArray(value)) {
  847. return useBlob && typeof Blob === 'function' ? new Blob([value]) : Buffer.from(value);
  848. }
  849. return value;
  850. }
  851. /**
  852. * Default visitor.
  853. *
  854. * @param {*} value
  855. * @param {String|Number} key
  856. * @param {Array<String|Number>} path
  857. * @this {FormData}
  858. *
  859. * @returns {boolean} return true to visit the each prop of the value recursively
  860. */
  861. function defaultVisitor(value, key, path) {
  862. let arr = value;
  863. if (value && !path && typeof value === 'object') {
  864. if (utils$1.endsWith(key, '{}')) {
  865. // eslint-disable-next-line no-param-reassign
  866. key = metaTokens ? key : key.slice(0, -2);
  867. // eslint-disable-next-line no-param-reassign
  868. value = JSON.stringify(value);
  869. } else if (
  870. (utils$1.isArray(value) && isFlatArray(value)) ||
  871. ((utils$1.isFileList(value) || utils$1.endsWith(key, '[]')) && (arr = utils$1.toArray(value))
  872. )) {
  873. // eslint-disable-next-line no-param-reassign
  874. key = removeBrackets(key);
  875. arr.forEach(function each(el, index) {
  876. !(utils$1.isUndefined(el) || el === null) && formData.append(
  877. // eslint-disable-next-line no-nested-ternary
  878. indexes === true ? renderKey([key], index, dots) : (indexes === null ? key : key + '[]'),
  879. convertValue(el)
  880. );
  881. });
  882. return false;
  883. }
  884. }
  885. if (isVisitable(value)) {
  886. return true;
  887. }
  888. formData.append(renderKey(path, key, dots), convertValue(value));
  889. return false;
  890. }
  891. const stack = [];
  892. const exposedHelpers = Object.assign(predicates, {
  893. defaultVisitor,
  894. convertValue,
  895. isVisitable
  896. });
  897. function build(value, path) {
  898. if (utils$1.isUndefined(value)) return;
  899. if (stack.indexOf(value) !== -1) {
  900. throw Error('Circular reference detected in ' + path.join('.'));
  901. }
  902. stack.push(value);
  903. utils$1.forEach(value, function each(el, key) {
  904. const result = !(utils$1.isUndefined(el) || el === null) && visitor.call(
  905. formData, el, utils$1.isString(key) ? key.trim() : key, path, exposedHelpers
  906. );
  907. if (result === true) {
  908. build(el, path ? path.concat(key) : [key]);
  909. }
  910. });
  911. stack.pop();
  912. }
  913. if (!utils$1.isObject(obj)) {
  914. throw new TypeError('data must be an object');
  915. }
  916. build(obj);
  917. return formData;
  918. }
  919. /**
  920. * It encodes a string by replacing all characters that are not in the unreserved set with
  921. * their percent-encoded equivalents
  922. *
  923. * @param {string} str - The string to encode.
  924. *
  925. * @returns {string} The encoded string.
  926. */
  927. function encode$1(str) {
  928. const charMap = {
  929. '!': '%21',
  930. "'": '%27',
  931. '(': '%28',
  932. ')': '%29',
  933. '~': '%7E',
  934. '%20': '+',
  935. '%00': '\x00'
  936. };
  937. return encodeURIComponent(str).replace(/[!'()~]|%20|%00/g, function replacer(match) {
  938. return charMap[match];
  939. });
  940. }
  941. /**
  942. * It takes a params object and converts it to a FormData object
  943. *
  944. * @param {Object<string, any>} params - The parameters to be converted to a FormData object.
  945. * @param {Object<string, any>} options - The options object passed to the Axios constructor.
  946. *
  947. * @returns {void}
  948. */
  949. function AxiosURLSearchParams(params, options) {
  950. this._pairs = [];
  951. params && toFormData(params, this, options);
  952. }
  953. const prototype = AxiosURLSearchParams.prototype;
  954. prototype.append = function append(name, value) {
  955. this._pairs.push([name, value]);
  956. };
  957. prototype.toString = function toString(encoder) {
  958. const _encode = encoder ? function(value) {
  959. return encoder.call(this, value, encode$1);
  960. } : encode$1;
  961. return this._pairs.map(function each(pair) {
  962. return _encode(pair[0]) + '=' + _encode(pair[1]);
  963. }, '').join('&');
  964. };
  965. /**
  966. * It replaces all instances of the characters `:`, `$`, `,`, `+`, `[`, and `]` with their
  967. * URI encoded counterparts
  968. *
  969. * @param {string} val The value to be encoded.
  970. *
  971. * @returns {string} The encoded value.
  972. */
  973. function encode(val) {
  974. return encodeURIComponent(val).
  975. replace(/%3A/gi, ':').
  976. replace(/%24/g, '$').
  977. replace(/%2C/gi, ',').
  978. replace(/%20/g, '+').
  979. replace(/%5B/gi, '[').
  980. replace(/%5D/gi, ']');
  981. }
  982. /**
  983. * Build a URL by appending params to the end
  984. *
  985. * @param {string} url The base of the url (e.g., http://www.google.com)
  986. * @param {object} [params] The params to be appended
  987. * @param {?(object|Function)} options
  988. *
  989. * @returns {string} The formatted url
  990. */
  991. function buildURL(url, params, options) {
  992. /*eslint no-param-reassign:0*/
  993. if (!params) {
  994. return url;
  995. }
  996. const _encode = options && options.encode || encode;
  997. if (utils$1.isFunction(options)) {
  998. options = {
  999. serialize: options
  1000. };
  1001. }
  1002. const serializeFn = options && options.serialize;
  1003. let serializedParams;
  1004. if (serializeFn) {
  1005. serializedParams = serializeFn(params, options);
  1006. } else {
  1007. serializedParams = utils$1.isURLSearchParams(params) ?
  1008. params.toString() :
  1009. new AxiosURLSearchParams(params, options).toString(_encode);
  1010. }
  1011. if (serializedParams) {
  1012. const hashmarkIndex = url.indexOf("#");
  1013. if (hashmarkIndex !== -1) {
  1014. url = url.slice(0, hashmarkIndex);
  1015. }
  1016. url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
  1017. }
  1018. return url;
  1019. }
  1020. class InterceptorManager {
  1021. constructor() {
  1022. this.handlers = [];
  1023. }
  1024. /**
  1025. * Add a new interceptor to the stack
  1026. *
  1027. * @param {Function} fulfilled The function to handle `then` for a `Promise`
  1028. * @param {Function} rejected The function to handle `reject` for a `Promise`
  1029. *
  1030. * @return {Number} An ID used to remove interceptor later
  1031. */
  1032. use(fulfilled, rejected, options) {
  1033. this.handlers.push({
  1034. fulfilled,
  1035. rejected,
  1036. synchronous: options ? options.synchronous : false,
  1037. runWhen: options ? options.runWhen : null
  1038. });
  1039. return this.handlers.length - 1;
  1040. }
  1041. /**
  1042. * Remove an interceptor from the stack
  1043. *
  1044. * @param {Number} id The ID that was returned by `use`
  1045. *
  1046. * @returns {Boolean} `true` if the interceptor was removed, `false` otherwise
  1047. */
  1048. eject(id) {
  1049. if (this.handlers[id]) {
  1050. this.handlers[id] = null;
  1051. }
  1052. }
  1053. /**
  1054. * Clear all interceptors from the stack
  1055. *
  1056. * @returns {void}
  1057. */
  1058. clear() {
  1059. if (this.handlers) {
  1060. this.handlers = [];
  1061. }
  1062. }
  1063. /**
  1064. * Iterate over all the registered interceptors
  1065. *
  1066. * This method is particularly useful for skipping over any
  1067. * interceptors that may have become `null` calling `eject`.
  1068. *
  1069. * @param {Function} fn The function to call for each interceptor
  1070. *
  1071. * @returns {void}
  1072. */
  1073. forEach(fn) {
  1074. utils$1.forEach(this.handlers, function forEachHandler(h) {
  1075. if (h !== null) {
  1076. fn(h);
  1077. }
  1078. });
  1079. }
  1080. }
  1081. var InterceptorManager$1 = InterceptorManager;
  1082. var transitionalDefaults = {
  1083. silentJSONParsing: true,
  1084. forcedJSONParsing: true,
  1085. clarifyTimeoutError: false
  1086. };
  1087. var URLSearchParams$1 = typeof URLSearchParams !== 'undefined' ? URLSearchParams : AxiosURLSearchParams;
  1088. var FormData$1 = typeof FormData !== 'undefined' ? FormData : null;
  1089. var Blob$1 = typeof Blob !== 'undefined' ? Blob : null;
  1090. var platform$1 = {
  1091. isBrowser: true,
  1092. classes: {
  1093. URLSearchParams: URLSearchParams$1,
  1094. FormData: FormData$1,
  1095. Blob: Blob$1
  1096. },
  1097. protocols: ['http', 'https', 'file', 'blob', 'url', 'data']
  1098. };
  1099. const hasBrowserEnv = typeof window !== 'undefined' && typeof document !== 'undefined';
  1100. const _navigator = typeof navigator === 'object' && navigator || undefined;
  1101. /**
  1102. * Determine if we're running in a standard browser environment
  1103. *
  1104. * This allows axios to run in a web worker, and react-native.
  1105. * Both environments support XMLHttpRequest, but not fully standard globals.
  1106. *
  1107. * web workers:
  1108. * typeof window -> undefined
  1109. * typeof document -> undefined
  1110. *
  1111. * react-native:
  1112. * navigator.product -> 'ReactNative'
  1113. * nativescript
  1114. * navigator.product -> 'NativeScript' or 'NS'
  1115. *
  1116. * @returns {boolean}
  1117. */
  1118. const hasStandardBrowserEnv = hasBrowserEnv &&
  1119. (!_navigator || ['ReactNative', 'NativeScript', 'NS'].indexOf(_navigator.product) < 0);
  1120. /**
  1121. * Determine if we're running in a standard browser webWorker environment
  1122. *
  1123. * Although the `isStandardBrowserEnv` method indicates that
  1124. * `allows axios to run in a web worker`, the WebWorker will still be
  1125. * filtered out due to its judgment standard
  1126. * `typeof window !== 'undefined' && typeof document !== 'undefined'`.
  1127. * This leads to a problem when axios post `FormData` in webWorker
  1128. */
  1129. const hasStandardBrowserWebWorkerEnv = (() => {
  1130. return (
  1131. typeof WorkerGlobalScope !== 'undefined' &&
  1132. // eslint-disable-next-line no-undef
  1133. self instanceof WorkerGlobalScope &&
  1134. typeof self.importScripts === 'function'
  1135. );
  1136. })();
  1137. const origin = hasBrowserEnv && window.location.href || 'http://localhost';
  1138. var utils = /*#__PURE__*/Object.freeze({
  1139. __proto__: null,
  1140. hasBrowserEnv: hasBrowserEnv,
  1141. hasStandardBrowserWebWorkerEnv: hasStandardBrowserWebWorkerEnv,
  1142. hasStandardBrowserEnv: hasStandardBrowserEnv,
  1143. navigator: _navigator,
  1144. origin: origin
  1145. });
  1146. var platform = {
  1147. ...utils,
  1148. ...platform$1
  1149. };
  1150. function toURLEncodedForm(data, options) {
  1151. return toFormData(data, new platform.classes.URLSearchParams(), Object.assign({
  1152. visitor: function(value, key, path, helpers) {
  1153. if (platform.isNode && utils$1.isBuffer(value)) {
  1154. this.append(key, value.toString('base64'));
  1155. return false;
  1156. }
  1157. return helpers.defaultVisitor.apply(this, arguments);
  1158. }
  1159. }, options));
  1160. }
  1161. /**
  1162. * It takes a string like `foo[x][y][z]` and returns an array like `['foo', 'x', 'y', 'z']
  1163. *
  1164. * @param {string} name - The name of the property to get.
  1165. *
  1166. * @returns An array of strings.
  1167. */
  1168. function parsePropPath(name) {
  1169. // foo[x][y][z]
  1170. // foo.x.y.z
  1171. // foo-x-y-z
  1172. // foo x y z
  1173. return utils$1.matchAll(/\w+|\[(\w*)]/g, name).map(match => {
  1174. return match[0] === '[]' ? '' : match[1] || match[0];
  1175. });
  1176. }
  1177. /**
  1178. * Convert an array to an object.
  1179. *
  1180. * @param {Array<any>} arr - The array to convert to an object.
  1181. *
  1182. * @returns An object with the same keys and values as the array.
  1183. */
  1184. function arrayToObject(arr) {
  1185. const obj = {};
  1186. const keys = Object.keys(arr);
  1187. let i;
  1188. const len = keys.length;
  1189. let key;
  1190. for (i = 0; i < len; i++) {
  1191. key = keys[i];
  1192. obj[key] = arr[key];
  1193. }
  1194. return obj;
  1195. }
  1196. /**
  1197. * It takes a FormData object and returns a JavaScript object
  1198. *
  1199. * @param {string} formData The FormData object to convert to JSON.
  1200. *
  1201. * @returns {Object<string, any> | null} The converted object.
  1202. */
  1203. function formDataToJSON(formData) {
  1204. function buildPath(path, value, target, index) {
  1205. let name = path[index++];
  1206. if (name === '__proto__') return true;
  1207. const isNumericKey = Number.isFinite(+name);
  1208. const isLast = index >= path.length;
  1209. name = !name && utils$1.isArray(target) ? target.length : name;
  1210. if (isLast) {
  1211. if (utils$1.hasOwnProp(target, name)) {
  1212. target[name] = [target[name], value];
  1213. } else {
  1214. target[name] = value;
  1215. }
  1216. return !isNumericKey;
  1217. }
  1218. if (!target[name] || !utils$1.isObject(target[name])) {
  1219. target[name] = [];
  1220. }
  1221. const result = buildPath(path, value, target[name], index);
  1222. if (result && utils$1.isArray(target[name])) {
  1223. target[name] = arrayToObject(target[name]);
  1224. }
  1225. return !isNumericKey;
  1226. }
  1227. if (utils$1.isFormData(formData) && utils$1.isFunction(formData.entries)) {
  1228. const obj = {};
  1229. utils$1.forEachEntry(formData, (name, value) => {
  1230. buildPath(parsePropPath(name), value, obj, 0);
  1231. });
  1232. return obj;
  1233. }
  1234. return null;
  1235. }
  1236. /**
  1237. * It takes a string, tries to parse it, and if it fails, it returns the stringified version
  1238. * of the input
  1239. *
  1240. * @param {any} rawValue - The value to be stringified.
  1241. * @param {Function} parser - A function that parses a string into a JavaScript object.
  1242. * @param {Function} encoder - A function that takes a value and returns a string.
  1243. *
  1244. * @returns {string} A stringified version of the rawValue.
  1245. */
  1246. function stringifySafely(rawValue, parser, encoder) {
  1247. if (utils$1.isString(rawValue)) {
  1248. try {
  1249. (parser || JSON.parse)(rawValue);
  1250. return utils$1.trim(rawValue);
  1251. } catch (e) {
  1252. if (e.name !== 'SyntaxError') {
  1253. throw e;
  1254. }
  1255. }
  1256. }
  1257. return (encoder || JSON.stringify)(rawValue);
  1258. }
  1259. const defaults = {
  1260. transitional: transitionalDefaults,
  1261. adapter: ['xhr', 'http', 'fetch'],
  1262. transformRequest: [function transformRequest(data, headers) {
  1263. const contentType = headers.getContentType() || '';
  1264. const hasJSONContentType = contentType.indexOf('application/json') > -1;
  1265. const isObjectPayload = utils$1.isObject(data);
  1266. if (isObjectPayload && utils$1.isHTMLForm(data)) {
  1267. data = new FormData(data);
  1268. }
  1269. const isFormData = utils$1.isFormData(data);
  1270. if (isFormData) {
  1271. return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
  1272. }
  1273. if (utils$1.isArrayBuffer(data) ||
  1274. utils$1.isBuffer(data) ||
  1275. utils$1.isStream(data) ||
  1276. utils$1.isFile(data) ||
  1277. utils$1.isBlob(data) ||
  1278. utils$1.isReadableStream(data)
  1279. ) {
  1280. return data;
  1281. }
  1282. if (utils$1.isArrayBufferView(data)) {
  1283. return data.buffer;
  1284. }
  1285. if (utils$1.isURLSearchParams(data)) {
  1286. headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
  1287. return data.toString();
  1288. }
  1289. let isFileList;
  1290. if (isObjectPayload) {
  1291. if (contentType.indexOf('application/x-www-form-urlencoded') > -1) {
  1292. return toURLEncodedForm(data, this.formSerializer).toString();
  1293. }
  1294. if ((isFileList = utils$1.isFileList(data)) || contentType.indexOf('multipart/form-data') > -1) {
  1295. const _FormData = this.env && this.env.FormData;
  1296. return toFormData(
  1297. isFileList ? {'files[]': data} : data,
  1298. _FormData && new _FormData(),
  1299. this.formSerializer
  1300. );
  1301. }
  1302. }
  1303. if (isObjectPayload || hasJSONContentType ) {
  1304. headers.setContentType('application/json', false);
  1305. return stringifySafely(data);
  1306. }
  1307. return data;
  1308. }],
  1309. transformResponse: [function transformResponse(data) {
  1310. const transitional = this.transitional || defaults.transitional;
  1311. const forcedJSONParsing = transitional && transitional.forcedJSONParsing;
  1312. const JSONRequested = this.responseType === 'json';
  1313. if (utils$1.isResponse(data) || utils$1.isReadableStream(data)) {
  1314. return data;
  1315. }
  1316. if (data && utils$1.isString(data) && ((forcedJSONParsing && !this.responseType) || JSONRequested)) {
  1317. const silentJSONParsing = transitional && transitional.silentJSONParsing;
  1318. const strictJSONParsing = !silentJSONParsing && JSONRequested;
  1319. try {
  1320. return JSON.parse(data);
  1321. } catch (e) {
  1322. if (strictJSONParsing) {
  1323. if (e.name === 'SyntaxError') {
  1324. throw AxiosError.from(e, AxiosError.ERR_BAD_RESPONSE, this, null, this.response);
  1325. }
  1326. throw e;
  1327. }
  1328. }
  1329. }
  1330. return data;
  1331. }],
  1332. /**
  1333. * A timeout in milliseconds to abort a request. If set to 0 (default) a
  1334. * timeout is not created.
  1335. */
  1336. timeout: 0,
  1337. xsrfCookieName: 'XSRF-TOKEN',
  1338. xsrfHeaderName: 'X-XSRF-TOKEN',
  1339. maxContentLength: -1,
  1340. maxBodyLength: -1,
  1341. env: {
  1342. FormData: platform.classes.FormData,
  1343. Blob: platform.classes.Blob
  1344. },
  1345. validateStatus: function validateStatus(status) {
  1346. return status >= 200 && status < 300;
  1347. },
  1348. headers: {
  1349. common: {
  1350. 'Accept': 'application/json, text/plain, */*',
  1351. 'Content-Type': undefined
  1352. }
  1353. }
  1354. };
  1355. utils$1.forEach(['delete', 'get', 'head', 'post', 'put', 'patch'], (method) => {
  1356. defaults.headers[method] = {};
  1357. });
  1358. var defaults$1 = defaults;
  1359. // RawAxiosHeaders whose duplicates are ignored by node
  1360. // c.f. https://nodejs.org/api/http.html#http_message_headers
  1361. const ignoreDuplicateOf = utils$1.toObjectSet([
  1362. 'age', 'authorization', 'content-length', 'content-type', 'etag',
  1363. 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',
  1364. 'last-modified', 'location', 'max-forwards', 'proxy-authorization',
  1365. 'referer', 'retry-after', 'user-agent'
  1366. ]);
  1367. /**
  1368. * Parse headers into an object
  1369. *
  1370. * ```
  1371. * Date: Wed, 27 Aug 2014 08:58:49 GMT
  1372. * Content-Type: application/json
  1373. * Connection: keep-alive
  1374. * Transfer-Encoding: chunked
  1375. * ```
  1376. *
  1377. * @param {String} rawHeaders Headers needing to be parsed
  1378. *
  1379. * @returns {Object} Headers parsed into an object
  1380. */
  1381. var parseHeaders = rawHeaders => {
  1382. const parsed = {};
  1383. let key;
  1384. let val;
  1385. let i;
  1386. rawHeaders && rawHeaders.split('\n').forEach(function parser(line) {
  1387. i = line.indexOf(':');
  1388. key = line.substring(0, i).trim().toLowerCase();
  1389. val = line.substring(i + 1).trim();
  1390. if (!key || (parsed[key] && ignoreDuplicateOf[key])) {
  1391. return;
  1392. }
  1393. if (key === 'set-cookie') {
  1394. if (parsed[key]) {
  1395. parsed[key].push(val);
  1396. } else {
  1397. parsed[key] = [val];
  1398. }
  1399. } else {
  1400. parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
  1401. }
  1402. });
  1403. return parsed;
  1404. };
  1405. const $internals = Symbol('internals');
  1406. function normalizeHeader(header) {
  1407. return header && String(header).trim().toLowerCase();
  1408. }
  1409. function normalizeValue(value) {
  1410. if (value === false || value == null) {
  1411. return value;
  1412. }
  1413. return utils$1.isArray(value) ? value.map(normalizeValue) : String(value);
  1414. }
  1415. function parseTokens(str) {
  1416. const tokens = Object.create(null);
  1417. const tokensRE = /([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;
  1418. let match;
  1419. while ((match = tokensRE.exec(str))) {
  1420. tokens[match[1]] = match[2];
  1421. }
  1422. return tokens;
  1423. }
  1424. const isValidHeaderName = (str) => /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(str.trim());
  1425. function matchHeaderValue(context, value, header, filter, isHeaderNameFilter) {
  1426. if (utils$1.isFunction(filter)) {
  1427. return filter.call(this, value, header);
  1428. }
  1429. if (isHeaderNameFilter) {
  1430. value = header;
  1431. }
  1432. if (!utils$1.isString(value)) return;
  1433. if (utils$1.isString(filter)) {
  1434. return value.indexOf(filter) !== -1;
  1435. }
  1436. if (utils$1.isRegExp(filter)) {
  1437. return filter.test(value);
  1438. }
  1439. }
  1440. function formatHeader(header) {
  1441. return header.trim()
  1442. .toLowerCase().replace(/([a-z\d])(\w*)/g, (w, char, str) => {
  1443. return char.toUpperCase() + str;
  1444. });
  1445. }
  1446. function buildAccessors(obj, header) {
  1447. const accessorName = utils$1.toCamelCase(' ' + header);
  1448. ['get', 'set', 'has'].forEach(methodName => {
  1449. Object.defineProperty(obj, methodName + accessorName, {
  1450. value: function(arg1, arg2, arg3) {
  1451. return this[methodName].call(this, header, arg1, arg2, arg3);
  1452. },
  1453. configurable: true
  1454. });
  1455. });
  1456. }
  1457. class AxiosHeaders {
  1458. constructor(headers) {
  1459. headers && this.set(headers);
  1460. }
  1461. set(header, valueOrRewrite, rewrite) {
  1462. const self = this;
  1463. function setHeader(_value, _header, _rewrite) {
  1464. const lHeader = normalizeHeader(_header);
  1465. if (!lHeader) {
  1466. throw new Error('header name must be a non-empty string');
  1467. }
  1468. const key = utils$1.findKey(self, lHeader);
  1469. if(!key || self[key] === undefined || _rewrite === true || (_rewrite === undefined && self[key] !== false)) {
  1470. self[key || _header] = normalizeValue(_value);
  1471. }
  1472. }
  1473. const setHeaders = (headers, _rewrite) =>
  1474. utils$1.forEach(headers, (_value, _header) => setHeader(_value, _header, _rewrite));
  1475. if (utils$1.isPlainObject(header) || header instanceof this.constructor) {
  1476. setHeaders(header, valueOrRewrite);
  1477. } else if(utils$1.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
  1478. setHeaders(parseHeaders(header), valueOrRewrite);
  1479. } else if (utils$1.isObject(header) && utils$1.isIterable(header)) {
  1480. let obj = {}, dest, key;
  1481. for (const entry of header) {
  1482. if (!utils$1.isArray(entry)) {
  1483. throw TypeError('Object iterator must return a key-value pair');
  1484. }
  1485. obj[key = entry[0]] = (dest = obj[key]) ?
  1486. (utils$1.isArray(dest) ? [...dest, entry[1]] : [dest, entry[1]]) : entry[1];
  1487. }
  1488. setHeaders(obj, valueOrRewrite);
  1489. } else {
  1490. header != null && setHeader(valueOrRewrite, header, rewrite);
  1491. }
  1492. return this;
  1493. }
  1494. get(header, parser) {
  1495. header = normalizeHeader(header);
  1496. if (header) {
  1497. const key = utils$1.findKey(this, header);
  1498. if (key) {
  1499. const value = this[key];
  1500. if (!parser) {
  1501. return value;
  1502. }
  1503. if (parser === true) {
  1504. return parseTokens(value);
  1505. }
  1506. if (utils$1.isFunction(parser)) {
  1507. return parser.call(this, value, key);
  1508. }
  1509. if (utils$1.isRegExp(parser)) {
  1510. return parser.exec(value);
  1511. }
  1512. throw new TypeError('parser must be boolean|regexp|function');
  1513. }
  1514. }
  1515. }
  1516. has(header, matcher) {
  1517. header = normalizeHeader(header);
  1518. if (header) {
  1519. const key = utils$1.findKey(this, header);
  1520. return !!(key && this[key] !== undefined && (!matcher || matchHeaderValue(this, this[key], key, matcher)));
  1521. }
  1522. return false;
  1523. }
  1524. delete(header, matcher) {
  1525. const self = this;
  1526. let deleted = false;
  1527. function deleteHeader(_header) {
  1528. _header = normalizeHeader(_header);
  1529. if (_header) {
  1530. const key = utils$1.findKey(self, _header);
  1531. if (key && (!matcher || matchHeaderValue(self, self[key], key, matcher))) {
  1532. delete self[key];
  1533. deleted = true;
  1534. }
  1535. }
  1536. }
  1537. if (utils$1.isArray(header)) {
  1538. header.forEach(deleteHeader);
  1539. } else {
  1540. deleteHeader(header);
  1541. }
  1542. return deleted;
  1543. }
  1544. clear(matcher) {
  1545. const keys = Object.keys(this);
  1546. let i = keys.length;
  1547. let deleted = false;
  1548. while (i--) {
  1549. const key = keys[i];
  1550. if(!matcher || matchHeaderValue(this, this[key], key, matcher, true)) {
  1551. delete this[key];
  1552. deleted = true;
  1553. }
  1554. }
  1555. return deleted;
  1556. }
  1557. normalize(format) {
  1558. const self = this;
  1559. const headers = {};
  1560. utils$1.forEach(this, (value, header) => {
  1561. const key = utils$1.findKey(headers, header);
  1562. if (key) {
  1563. self[key] = normalizeValue(value);
  1564. delete self[header];
  1565. return;
  1566. }
  1567. const normalized = format ? formatHeader(header) : String(header).trim();
  1568. if (normalized !== header) {
  1569. delete self[header];
  1570. }
  1571. self[normalized] = normalizeValue(value);
  1572. headers[normalized] = true;
  1573. });
  1574. return this;
  1575. }
  1576. concat(...targets) {
  1577. return this.constructor.concat(this, ...targets);
  1578. }
  1579. toJSON(asStrings) {
  1580. const obj = Object.create(null);
  1581. utils$1.forEach(this, (value, header) => {
  1582. value != null && value !== false && (obj[header] = asStrings && utils$1.isArray(value) ? value.join(', ') : value);
  1583. });
  1584. return obj;
  1585. }
  1586. [Symbol.iterator]() {
  1587. return Object.entries(this.toJSON())[Symbol.iterator]();
  1588. }
  1589. toString() {
  1590. return Object.entries(this.toJSON()).map(([header, value]) => header + ': ' + value).join('\n');
  1591. }
  1592. getSetCookie() {
  1593. return this.get("set-cookie") || [];
  1594. }
  1595. get [Symbol.toStringTag]() {
  1596. return 'AxiosHeaders';
  1597. }
  1598. static from(thing) {
  1599. return thing instanceof this ? thing : new this(thing);
  1600. }
  1601. static concat(first, ...targets) {
  1602. const computed = new this(first);
  1603. targets.forEach((target) => computed.set(target));
  1604. return computed;
  1605. }
  1606. static accessor(header) {
  1607. const internals = this[$internals] = (this[$internals] = {
  1608. accessors: {}
  1609. });
  1610. const accessors = internals.accessors;
  1611. const prototype = this.prototype;
  1612. function defineAccessor(_header) {
  1613. const lHeader = normalizeHeader(_header);
  1614. if (!accessors[lHeader]) {
  1615. buildAccessors(prototype, _header);
  1616. accessors[lHeader] = true;
  1617. }
  1618. }
  1619. utils$1.isArray(header) ? header.forEach(defineAccessor) : defineAccessor(header);
  1620. return this;
  1621. }
  1622. }
  1623. AxiosHeaders.accessor(['Content-Type', 'Content-Length', 'Accept', 'Accept-Encoding', 'User-Agent', 'Authorization']);
  1624. // reserved names hotfix
  1625. utils$1.reduceDescriptors(AxiosHeaders.prototype, ({value}, key) => {
  1626. let mapped = key[0].toUpperCase() + key.slice(1); // map `set` => `Set`
  1627. return {
  1628. get: () => value,
  1629. set(headerValue) {
  1630. this[mapped] = headerValue;
  1631. }
  1632. }
  1633. });
  1634. utils$1.freezeMethods(AxiosHeaders);
  1635. var AxiosHeaders$1 = AxiosHeaders;
  1636. /**
  1637. * Transform the data for a request or a response
  1638. *
  1639. * @param {Array|Function} fns A single function or Array of functions
  1640. * @param {?Object} response The response object
  1641. *
  1642. * @returns {*} The resulting transformed data
  1643. */
  1644. function transformData(fns, response) {
  1645. const config = this || defaults$1;
  1646. const context = response || config;
  1647. const headers = AxiosHeaders$1.from(context.headers);
  1648. let data = context.data;
  1649. utils$1.forEach(fns, function transform(fn) {
  1650. data = fn.call(config, data, headers.normalize(), response ? response.status : undefined);
  1651. });
  1652. headers.normalize();
  1653. return data;
  1654. }
  1655. function isCancel(value) {
  1656. return !!(value && value.__CANCEL__);
  1657. }
  1658. /**
  1659. * A `CanceledError` is an object that is thrown when an operation is canceled.
  1660. *
  1661. * @param {string=} message The message.
  1662. * @param {Object=} config The config.
  1663. * @param {Object=} request The request.
  1664. *
  1665. * @returns {CanceledError} The created error.
  1666. */
  1667. function CanceledError(message, config, request) {
  1668. // eslint-disable-next-line no-eq-null,eqeqeq
  1669. AxiosError.call(this, message == null ? 'canceled' : message, AxiosError.ERR_CANCELED, config, request);
  1670. this.name = 'CanceledError';
  1671. }
  1672. utils$1.inherits(CanceledError, AxiosError, {
  1673. __CANCEL__: true
  1674. });
  1675. /**
  1676. * Resolve or reject a Promise based on response status.
  1677. *
  1678. * @param {Function} resolve A function that resolves the promise.
  1679. * @param {Function} reject A function that rejects the promise.
  1680. * @param {object} response The response.
  1681. *
  1682. * @returns {object} The response.
  1683. */
  1684. function settle(resolve, reject, response) {
  1685. const validateStatus = response.config.validateStatus;
  1686. if (!response.status || !validateStatus || validateStatus(response.status)) {
  1687. resolve(response);
  1688. } else {
  1689. reject(new AxiosError(
  1690. 'Request failed with status code ' + response.status,
  1691. [AxiosError.ERR_BAD_REQUEST, AxiosError.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4],
  1692. response.config,
  1693. response.request,
  1694. response
  1695. ));
  1696. }
  1697. }
  1698. function parseProtocol(url) {
  1699. const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
  1700. return match && match[1] || '';
  1701. }
  1702. /**
  1703. * Calculate data maxRate
  1704. * @param {Number} [samplesCount= 10]
  1705. * @param {Number} [min= 1000]
  1706. * @returns {Function}
  1707. */
  1708. function speedometer(samplesCount, min) {
  1709. samplesCount = samplesCount || 10;
  1710. const bytes = new Array(samplesCount);
  1711. const timestamps = new Array(samplesCount);
  1712. let head = 0;
  1713. let tail = 0;
  1714. let firstSampleTS;
  1715. min = min !== undefined ? min : 1000;
  1716. return function push(chunkLength) {
  1717. const now = Date.now();
  1718. const startedAt = timestamps[tail];
  1719. if (!firstSampleTS) {
  1720. firstSampleTS = now;
  1721. }
  1722. bytes[head] = chunkLength;
  1723. timestamps[head] = now;
  1724. let i = tail;
  1725. let bytesCount = 0;
  1726. while (i !== head) {
  1727. bytesCount += bytes[i++];
  1728. i = i % samplesCount;
  1729. }
  1730. head = (head + 1) % samplesCount;
  1731. if (head === tail) {
  1732. tail = (tail + 1) % samplesCount;
  1733. }
  1734. if (now - firstSampleTS < min) {
  1735. return;
  1736. }
  1737. const passed = startedAt && now - startedAt;
  1738. return passed ? Math.round(bytesCount * 1000 / passed) : undefined;
  1739. };
  1740. }
  1741. /**
  1742. * Throttle decorator
  1743. * @param {Function} fn
  1744. * @param {Number} freq
  1745. * @return {Function}
  1746. */
  1747. function throttle(fn, freq) {
  1748. let timestamp = 0;
  1749. let threshold = 1000 / freq;
  1750. let lastArgs;
  1751. let timer;
  1752. const invoke = (args, now = Date.now()) => {
  1753. timestamp = now;
  1754. lastArgs = null;
  1755. if (timer) {
  1756. clearTimeout(timer);
  1757. timer = null;
  1758. }
  1759. fn.apply(null, args);
  1760. };
  1761. const throttled = (...args) => {
  1762. const now = Date.now();
  1763. const passed = now - timestamp;
  1764. if ( passed >= threshold) {
  1765. invoke(args, now);
  1766. } else {
  1767. lastArgs = args;
  1768. if (!timer) {
  1769. timer = setTimeout(() => {
  1770. timer = null;
  1771. invoke(lastArgs);
  1772. }, threshold - passed);
  1773. }
  1774. }
  1775. };
  1776. const flush = () => lastArgs && invoke(lastArgs);
  1777. return [throttled, flush];
  1778. }
  1779. const progressEventReducer = (listener, isDownloadStream, freq = 3) => {
  1780. let bytesNotified = 0;
  1781. const _speedometer = speedometer(50, 250);
  1782. return throttle(e => {
  1783. const loaded = e.loaded;
  1784. const total = e.lengthComputable ? e.total : undefined;
  1785. const progressBytes = loaded - bytesNotified;
  1786. const rate = _speedometer(progressBytes);
  1787. const inRange = loaded <= total;
  1788. bytesNotified = loaded;
  1789. const data = {
  1790. loaded,
  1791. total,
  1792. progress: total ? (loaded / total) : undefined,
  1793. bytes: progressBytes,
  1794. rate: rate ? rate : undefined,
  1795. estimated: rate && total && inRange ? (total - loaded) / rate : undefined,
  1796. event: e,
  1797. lengthComputable: total != null,
  1798. [isDownloadStream ? 'download' : 'upload']: true
  1799. };
  1800. listener(data);
  1801. }, freq);
  1802. };
  1803. const progressEventDecorator = (total, throttled) => {
  1804. const lengthComputable = total != null;
  1805. return [(loaded) => throttled[0]({
  1806. lengthComputable,
  1807. total,
  1808. loaded
  1809. }), throttled[1]];
  1810. };
  1811. const asyncDecorator = (fn) => (...args) => utils$1.asap(() => fn(...args));
  1812. var isURLSameOrigin = platform.hasStandardBrowserEnv ? ((origin, isMSIE) => (url) => {
  1813. url = new URL(url, platform.origin);
  1814. return (
  1815. origin.protocol === url.protocol &&
  1816. origin.host === url.host &&
  1817. (isMSIE || origin.port === url.port)
  1818. );
  1819. })(
  1820. new URL(platform.origin),
  1821. platform.navigator && /(msie|trident)/i.test(platform.navigator.userAgent)
  1822. ) : () => true;
  1823. var cookies = platform.hasStandardBrowserEnv ?
  1824. // Standard browser envs support document.cookie
  1825. {
  1826. write(name, value, expires, path, domain, secure) {
  1827. const cookie = [name + '=' + encodeURIComponent(value)];
  1828. utils$1.isNumber(expires) && cookie.push('expires=' + new Date(expires).toGMTString());
  1829. utils$1.isString(path) && cookie.push('path=' + path);
  1830. utils$1.isString(domain) && cookie.push('domain=' + domain);
  1831. secure === true && cookie.push('secure');
  1832. document.cookie = cookie.join('; ');
  1833. },
  1834. read(name) {
  1835. const match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
  1836. return (match ? decodeURIComponent(match[3]) : null);
  1837. },
  1838. remove(name) {
  1839. this.write(name, '', Date.now() - 86400000);
  1840. }
  1841. }
  1842. :
  1843. // Non-standard browser env (web workers, react-native) lack needed support.
  1844. {
  1845. write() {},
  1846. read() {
  1847. return null;
  1848. },
  1849. remove() {}
  1850. };
  1851. /**
  1852. * Determines whether the specified URL is absolute
  1853. *
  1854. * @param {string} url The URL to test
  1855. *
  1856. * @returns {boolean} True if the specified URL is absolute, otherwise false
  1857. */
  1858. function isAbsoluteURL(url) {
  1859. // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
  1860. // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
  1861. // by any combination of letters, digits, plus, period, or hyphen.
  1862. return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
  1863. }
  1864. /**
  1865. * Creates a new URL by combining the specified URLs
  1866. *
  1867. * @param {string} baseURL The base URL
  1868. * @param {string} relativeURL The relative URL
  1869. *
  1870. * @returns {string} The combined URL
  1871. */
  1872. function combineURLs(baseURL, relativeURL) {
  1873. return relativeURL
  1874. ? baseURL.replace(/\/?\/$/, '') + '/' + relativeURL.replace(/^\/+/, '')
  1875. : baseURL;
  1876. }
  1877. /**
  1878. * Creates a new URL by combining the baseURL with the requestedURL,
  1879. * only when the requestedURL is not already an absolute URL.
  1880. * If the requestURL is absolute, this function returns the requestedURL untouched.
  1881. *
  1882. * @param {string} baseURL The base URL
  1883. * @param {string} requestedURL Absolute or relative URL to combine
  1884. *
  1885. * @returns {string} The combined full path
  1886. */
  1887. function buildFullPath(baseURL, requestedURL, allowAbsoluteUrls) {
  1888. let isRelativeUrl = !isAbsoluteURL(requestedURL);
  1889. if (baseURL && (isRelativeUrl || allowAbsoluteUrls == false)) {
  1890. return combineURLs(baseURL, requestedURL);
  1891. }
  1892. return requestedURL;
  1893. }
  1894. const headersToObject = (thing) => thing instanceof AxiosHeaders$1 ? { ...thing } : thing;
  1895. /**
  1896. * Config-specific merge-function which creates a new config-object
  1897. * by merging two configuration objects together.
  1898. *
  1899. * @param {Object} config1
  1900. * @param {Object} config2
  1901. *
  1902. * @returns {Object} New object resulting from merging config2 to config1
  1903. */
  1904. function mergeConfig(config1, config2) {
  1905. // eslint-disable-next-line no-param-reassign
  1906. config2 = config2 || {};
  1907. const config = {};
  1908. function getMergedValue(target, source, prop, caseless) {
  1909. if (utils$1.isPlainObject(target) && utils$1.isPlainObject(source)) {
  1910. return utils$1.merge.call({caseless}, target, source);
  1911. } else if (utils$1.isPlainObject(source)) {
  1912. return utils$1.merge({}, source);
  1913. } else if (utils$1.isArray(source)) {
  1914. return source.slice();
  1915. }
  1916. return source;
  1917. }
  1918. // eslint-disable-next-line consistent-return
  1919. function mergeDeepProperties(a, b, prop , caseless) {
  1920. if (!utils$1.isUndefined(b)) {
  1921. return getMergedValue(a, b, prop , caseless);
  1922. } else if (!utils$1.isUndefined(a)) {
  1923. return getMergedValue(undefined, a, prop , caseless);
  1924. }
  1925. }
  1926. // eslint-disable-next-line consistent-return
  1927. function valueFromConfig2(a, b) {
  1928. if (!utils$1.isUndefined(b)) {
  1929. return getMergedValue(undefined, b);
  1930. }
  1931. }
  1932. // eslint-disable-next-line consistent-return
  1933. function defaultToConfig2(a, b) {
  1934. if (!utils$1.isUndefined(b)) {
  1935. return getMergedValue(undefined, b);
  1936. } else if (!utils$1.isUndefined(a)) {
  1937. return getMergedValue(undefined, a);
  1938. }
  1939. }
  1940. // eslint-disable-next-line consistent-return
  1941. function mergeDirectKeys(a, b, prop) {
  1942. if (prop in config2) {
  1943. return getMergedValue(a, b);
  1944. } else if (prop in config1) {
  1945. return getMergedValue(undefined, a);
  1946. }
  1947. }
  1948. const mergeMap = {
  1949. url: valueFromConfig2,
  1950. method: valueFromConfig2,
  1951. data: valueFromConfig2,
  1952. baseURL: defaultToConfig2,
  1953. transformRequest: defaultToConfig2,
  1954. transformResponse: defaultToConfig2,
  1955. paramsSerializer: defaultToConfig2,
  1956. timeout: defaultToConfig2,
  1957. timeoutMessage: defaultToConfig2,
  1958. withCredentials: defaultToConfig2,
  1959. withXSRFToken: defaultToConfig2,
  1960. adapter: defaultToConfig2,
  1961. responseType: defaultToConfig2,
  1962. xsrfCookieName: defaultToConfig2,
  1963. xsrfHeaderName: defaultToConfig2,
  1964. onUploadProgress: defaultToConfig2,
  1965. onDownloadProgress: defaultToConfig2,
  1966. decompress: defaultToConfig2,
  1967. maxContentLength: defaultToConfig2,
  1968. maxBodyLength: defaultToConfig2,
  1969. beforeRedirect: defaultToConfig2,
  1970. transport: defaultToConfig2,
  1971. httpAgent: defaultToConfig2,
  1972. httpsAgent: defaultToConfig2,
  1973. cancelToken: defaultToConfig2,
  1974. socketPath: defaultToConfig2,
  1975. responseEncoding: defaultToConfig2,
  1976. validateStatus: mergeDirectKeys,
  1977. headers: (a, b , prop) => mergeDeepProperties(headersToObject(a), headersToObject(b),prop, true)
  1978. };
  1979. utils$1.forEach(Object.keys(Object.assign({}, config1, config2)), function computeConfigValue(prop) {
  1980. const merge = mergeMap[prop] || mergeDeepProperties;
  1981. const configValue = merge(config1[prop], config2[prop], prop);
  1982. (utils$1.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
  1983. });
  1984. return config;
  1985. }
  1986. var resolveConfig = (config) => {
  1987. const newConfig = mergeConfig({}, config);
  1988. let {data, withXSRFToken, xsrfHeaderName, xsrfCookieName, headers, auth} = newConfig;
  1989. newConfig.headers = headers = AxiosHeaders$1.from(headers);
  1990. newConfig.url = buildURL(buildFullPath(newConfig.baseURL, newConfig.url, newConfig.allowAbsoluteUrls), config.params, config.paramsSerializer);
  1991. // HTTP basic authentication
  1992. if (auth) {
  1993. headers.set('Authorization', 'Basic ' +
  1994. btoa((auth.username || '') + ':' + (auth.password ? unescape(encodeURIComponent(auth.password)) : ''))
  1995. );
  1996. }
  1997. let contentType;
  1998. if (utils$1.isFormData(data)) {
  1999. if (platform.hasStandardBrowserEnv || platform.hasStandardBrowserWebWorkerEnv) {
  2000. headers.setContentType(undefined); // Let the browser set it
  2001. } else if ((contentType = headers.getContentType()) !== false) {
  2002. // fix semicolon duplication issue for ReactNative FormData implementation
  2003. const [type, ...tokens] = contentType ? contentType.split(';').map(token => token.trim()).filter(Boolean) : [];
  2004. headers.setContentType([type || 'multipart/form-data', ...tokens].join('; '));
  2005. }
  2006. }
  2007. // Add xsrf header
  2008. // This is only done if running in a standard browser environment.
  2009. // Specifically not if we're in a web worker, or react-native.
  2010. if (platform.hasStandardBrowserEnv) {
  2011. withXSRFToken && utils$1.isFunction(withXSRFToken) && (withXSRFToken = withXSRFToken(newConfig));
  2012. if (withXSRFToken || (withXSRFToken !== false && isURLSameOrigin(newConfig.url))) {
  2013. // Add xsrf header
  2014. const xsrfValue = xsrfHeaderName && xsrfCookieName && cookies.read(xsrfCookieName);
  2015. if (xsrfValue) {
  2016. headers.set(xsrfHeaderName, xsrfValue);
  2017. }
  2018. }
  2019. }
  2020. return newConfig;
  2021. };
  2022. const isXHRAdapterSupported = typeof XMLHttpRequest !== 'undefined';
  2023. var xhrAdapter = isXHRAdapterSupported && function (config) {
  2024. return new Promise(function dispatchXhrRequest(resolve, reject) {
  2025. const _config = resolveConfig(config);
  2026. let requestData = _config.data;
  2027. const requestHeaders = AxiosHeaders$1.from(_config.headers).normalize();
  2028. let {responseType, onUploadProgress, onDownloadProgress} = _config;
  2029. let onCanceled;
  2030. let uploadThrottled, downloadThrottled;
  2031. let flushUpload, flushDownload;
  2032. function done() {
  2033. flushUpload && flushUpload(); // flush events
  2034. flushDownload && flushDownload(); // flush events
  2035. _config.cancelToken && _config.cancelToken.unsubscribe(onCanceled);
  2036. _config.signal && _config.signal.removeEventListener('abort', onCanceled);
  2037. }
  2038. let request = new XMLHttpRequest();
  2039. request.open(_config.method.toUpperCase(), _config.url, true);
  2040. // Set the request timeout in MS
  2041. request.timeout = _config.timeout;
  2042. function onloadend() {
  2043. if (!request) {
  2044. return;
  2045. }
  2046. // Prepare the response
  2047. const responseHeaders = AxiosHeaders$1.from(
  2048. 'getAllResponseHeaders' in request && request.getAllResponseHeaders()
  2049. );
  2050. const responseData = !responseType || responseType === 'text' || responseType === 'json' ?
  2051. request.responseText : request.response;
  2052. const response = {
  2053. data: responseData,
  2054. status: request.status,
  2055. statusText: request.statusText,
  2056. headers: responseHeaders,
  2057. config,
  2058. request
  2059. };
  2060. settle(function _resolve(value) {
  2061. resolve(value);
  2062. done();
  2063. }, function _reject(err) {
  2064. reject(err);
  2065. done();
  2066. }, response);
  2067. // Clean up request
  2068. request = null;
  2069. }
  2070. if ('onloadend' in request) {
  2071. // Use onloadend if available
  2072. request.onloadend = onloadend;
  2073. } else {
  2074. // Listen for ready state to emulate onloadend
  2075. request.onreadystatechange = function handleLoad() {
  2076. if (!request || request.readyState !== 4) {
  2077. return;
  2078. }
  2079. // The request errored out and we didn't get a response, this will be
  2080. // handled by onerror instead
  2081. // With one exception: request that using file: protocol, most browsers
  2082. // will return status as 0 even though it's a successful request
  2083. if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
  2084. return;
  2085. }
  2086. // readystate handler is calling before onerror or ontimeout handlers,
  2087. // so we should call onloadend on the next 'tick'
  2088. setTimeout(onloadend);
  2089. };
  2090. }
  2091. // Handle browser request cancellation (as opposed to a manual cancellation)
  2092. request.onabort = function handleAbort() {
  2093. if (!request) {
  2094. return;
  2095. }
  2096. reject(new AxiosError('Request aborted', AxiosError.ECONNABORTED, config, request));
  2097. // Clean up request
  2098. request = null;
  2099. };
  2100. // Handle low level network errors
  2101. request.onerror = function handleError() {
  2102. // Real errors are hidden from us by the browser
  2103. // onerror should only fire if it's a network error
  2104. reject(new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request));
  2105. // Clean up request
  2106. request = null;
  2107. };
  2108. // Handle timeout
  2109. request.ontimeout = function handleTimeout() {
  2110. let timeoutErrorMessage = _config.timeout ? 'timeout of ' + _config.timeout + 'ms exceeded' : 'timeout exceeded';
  2111. const transitional = _config.transitional || transitionalDefaults;
  2112. if (_config.timeoutErrorMessage) {
  2113. timeoutErrorMessage = _config.timeoutErrorMessage;
  2114. }
  2115. reject(new AxiosError(
  2116. timeoutErrorMessage,
  2117. transitional.clarifyTimeoutError ? AxiosError.ETIMEDOUT : AxiosError.ECONNABORTED,
  2118. config,
  2119. request));
  2120. // Clean up request
  2121. request = null;
  2122. };
  2123. // Remove Content-Type if data is undefined
  2124. requestData === undefined && requestHeaders.setContentType(null);
  2125. // Add headers to the request
  2126. if ('setRequestHeader' in request) {
  2127. utils$1.forEach(requestHeaders.toJSON(), function setRequestHeader(val, key) {
  2128. request.setRequestHeader(key, val);
  2129. });
  2130. }
  2131. // Add withCredentials to request if needed
  2132. if (!utils$1.isUndefined(_config.withCredentials)) {
  2133. request.withCredentials = !!_config.withCredentials;
  2134. }
  2135. // Add responseType to request if needed
  2136. if (responseType && responseType !== 'json') {
  2137. request.responseType = _config.responseType;
  2138. }
  2139. // Handle progress if needed
  2140. if (onDownloadProgress) {
  2141. ([downloadThrottled, flushDownload] = progressEventReducer(onDownloadProgress, true));
  2142. request.addEventListener('progress', downloadThrottled);
  2143. }
  2144. // Not all browsers support upload events
  2145. if (onUploadProgress && request.upload) {
  2146. ([uploadThrottled, flushUpload] = progressEventReducer(onUploadProgress));
  2147. request.upload.addEventListener('progress', uploadThrottled);
  2148. request.upload.addEventListener('loadend', flushUpload);
  2149. }
  2150. if (_config.cancelToken || _config.signal) {
  2151. // Handle cancellation
  2152. // eslint-disable-next-line func-names
  2153. onCanceled = cancel => {
  2154. if (!request) {
  2155. return;
  2156. }
  2157. reject(!cancel || cancel.type ? new CanceledError(null, config, request) : cancel);
  2158. request.abort();
  2159. request = null;
  2160. };
  2161. _config.cancelToken && _config.cancelToken.subscribe(onCanceled);
  2162. if (_config.signal) {
  2163. _config.signal.aborted ? onCanceled() : _config.signal.addEventListener('abort', onCanceled);
  2164. }
  2165. }
  2166. const protocol = parseProtocol(_config.url);
  2167. if (protocol && platform.protocols.indexOf(protocol) === -1) {
  2168. reject(new AxiosError('Unsupported protocol ' + protocol + ':', AxiosError.ERR_BAD_REQUEST, config));
  2169. return;
  2170. }
  2171. // Send the request
  2172. request.send(requestData || null);
  2173. });
  2174. };
  2175. const composeSignals = (signals, timeout) => {
  2176. const {length} = (signals = signals ? signals.filter(Boolean) : []);
  2177. if (timeout || length) {
  2178. let controller = new AbortController();
  2179. let aborted;
  2180. const onabort = function (reason) {
  2181. if (!aborted) {
  2182. aborted = true;
  2183. unsubscribe();
  2184. const err = reason instanceof Error ? reason : this.reason;
  2185. controller.abort(err instanceof AxiosError ? err : new CanceledError(err instanceof Error ? err.message : err));
  2186. }
  2187. };
  2188. let timer = timeout && setTimeout(() => {
  2189. timer = null;
  2190. onabort(new AxiosError(`timeout ${timeout} of ms exceeded`, AxiosError.ETIMEDOUT));
  2191. }, timeout);
  2192. const unsubscribe = () => {
  2193. if (signals) {
  2194. timer && clearTimeout(timer);
  2195. timer = null;
  2196. signals.forEach(signal => {
  2197. signal.unsubscribe ? signal.unsubscribe(onabort) : signal.removeEventListener('abort', onabort);
  2198. });
  2199. signals = null;
  2200. }
  2201. };
  2202. signals.forEach((signal) => signal.addEventListener('abort', onabort));
  2203. const {signal} = controller;
  2204. signal.unsubscribe = () => utils$1.asap(unsubscribe);
  2205. return signal;
  2206. }
  2207. };
  2208. var composeSignals$1 = composeSignals;
  2209. const streamChunk = function* (chunk, chunkSize) {
  2210. let len = chunk.byteLength;
  2211. if (!chunkSize || len < chunkSize) {
  2212. yield chunk;
  2213. return;
  2214. }
  2215. let pos = 0;
  2216. let end;
  2217. while (pos < len) {
  2218. end = pos + chunkSize;
  2219. yield chunk.slice(pos, end);
  2220. pos = end;
  2221. }
  2222. };
  2223. const readBytes = async function* (iterable, chunkSize) {
  2224. for await (const chunk of readStream(iterable)) {
  2225. yield* streamChunk(chunk, chunkSize);
  2226. }
  2227. };
  2228. const readStream = async function* (stream) {
  2229. if (stream[Symbol.asyncIterator]) {
  2230. yield* stream;
  2231. return;
  2232. }
  2233. const reader = stream.getReader();
  2234. try {
  2235. for (;;) {
  2236. const {done, value} = await reader.read();
  2237. if (done) {
  2238. break;
  2239. }
  2240. yield value;
  2241. }
  2242. } finally {
  2243. await reader.cancel();
  2244. }
  2245. };
  2246. const trackStream = (stream, chunkSize, onProgress, onFinish) => {
  2247. const iterator = readBytes(stream, chunkSize);
  2248. let bytes = 0;
  2249. let done;
  2250. let _onFinish = (e) => {
  2251. if (!done) {
  2252. done = true;
  2253. onFinish && onFinish(e);
  2254. }
  2255. };
  2256. return new ReadableStream({
  2257. async pull(controller) {
  2258. try {
  2259. const {done, value} = await iterator.next();
  2260. if (done) {
  2261. _onFinish();
  2262. controller.close();
  2263. return;
  2264. }
  2265. let len = value.byteLength;
  2266. if (onProgress) {
  2267. let loadedBytes = bytes += len;
  2268. onProgress(loadedBytes);
  2269. }
  2270. controller.enqueue(new Uint8Array(value));
  2271. } catch (err) {
  2272. _onFinish(err);
  2273. throw err;
  2274. }
  2275. },
  2276. cancel(reason) {
  2277. _onFinish(reason);
  2278. return iterator.return();
  2279. }
  2280. }, {
  2281. highWaterMark: 2
  2282. })
  2283. };
  2284. const isFetchSupported = typeof fetch === 'function' && typeof Request === 'function' && typeof Response === 'function';
  2285. const isReadableStreamSupported = isFetchSupported && typeof ReadableStream === 'function';
  2286. // used only inside the fetch adapter
  2287. const encodeText = isFetchSupported && (typeof TextEncoder === 'function' ?
  2288. ((encoder) => (str) => encoder.encode(str))(new TextEncoder()) :
  2289. async (str) => new Uint8Array(await new Response(str).arrayBuffer())
  2290. );
  2291. const test = (fn, ...args) => {
  2292. try {
  2293. return !!fn(...args);
  2294. } catch (e) {
  2295. return false
  2296. }
  2297. };
  2298. const supportsRequestStream = isReadableStreamSupported && test(() => {
  2299. let duplexAccessed = false;
  2300. const hasContentType = new Request(platform.origin, {
  2301. body: new ReadableStream(),
  2302. method: 'POST',
  2303. get duplex() {
  2304. duplexAccessed = true;
  2305. return 'half';
  2306. },
  2307. }).headers.has('Content-Type');
  2308. return duplexAccessed && !hasContentType;
  2309. });
  2310. const DEFAULT_CHUNK_SIZE = 64 * 1024;
  2311. const supportsResponseStream = isReadableStreamSupported &&
  2312. test(() => utils$1.isReadableStream(new Response('').body));
  2313. const resolvers = {
  2314. stream: supportsResponseStream && ((res) => res.body)
  2315. };
  2316. isFetchSupported && (((res) => {
  2317. ['text', 'arrayBuffer', 'blob', 'formData', 'stream'].forEach(type => {
  2318. !resolvers[type] && (resolvers[type] = utils$1.isFunction(res[type]) ? (res) => res[type]() :
  2319. (_, config) => {
  2320. throw new AxiosError(`Response type '${type}' is not supported`, AxiosError.ERR_NOT_SUPPORT, config);
  2321. });
  2322. });
  2323. })(new Response));
  2324. const getBodyLength = async (body) => {
  2325. if (body == null) {
  2326. return 0;
  2327. }
  2328. if(utils$1.isBlob(body)) {
  2329. return body.size;
  2330. }
  2331. if(utils$1.isSpecCompliantForm(body)) {
  2332. const _request = new Request(platform.origin, {
  2333. method: 'POST',
  2334. body,
  2335. });
  2336. return (await _request.arrayBuffer()).byteLength;
  2337. }
  2338. if(utils$1.isArrayBufferView(body) || utils$1.isArrayBuffer(body)) {
  2339. return body.byteLength;
  2340. }
  2341. if(utils$1.isURLSearchParams(body)) {
  2342. body = body + '';
  2343. }
  2344. if(utils$1.isString(body)) {
  2345. return (await encodeText(body)).byteLength;
  2346. }
  2347. };
  2348. const resolveBodyLength = async (headers, body) => {
  2349. const length = utils$1.toFiniteNumber(headers.getContentLength());
  2350. return length == null ? getBodyLength(body) : length;
  2351. };
  2352. var fetchAdapter = isFetchSupported && (async (config) => {
  2353. let {
  2354. url,
  2355. method,
  2356. data,
  2357. signal,
  2358. cancelToken,
  2359. timeout,
  2360. onDownloadProgress,
  2361. onUploadProgress,
  2362. responseType,
  2363. headers,
  2364. withCredentials = 'same-origin',
  2365. fetchOptions
  2366. } = resolveConfig(config);
  2367. responseType = responseType ? (responseType + '').toLowerCase() : 'text';
  2368. let composedSignal = composeSignals$1([signal, cancelToken && cancelToken.toAbortSignal()], timeout);
  2369. let request;
  2370. const unsubscribe = composedSignal && composedSignal.unsubscribe && (() => {
  2371. composedSignal.unsubscribe();
  2372. });
  2373. let requestContentLength;
  2374. try {
  2375. if (
  2376. onUploadProgress && supportsRequestStream && method !== 'get' && method !== 'head' &&
  2377. (requestContentLength = await resolveBodyLength(headers, data)) !== 0
  2378. ) {
  2379. let _request = new Request(url, {
  2380. method: 'POST',
  2381. body: data,
  2382. duplex: "half"
  2383. });
  2384. let contentTypeHeader;
  2385. if (utils$1.isFormData(data) && (contentTypeHeader = _request.headers.get('content-type'))) {
  2386. headers.setContentType(contentTypeHeader);
  2387. }
  2388. if (_request.body) {
  2389. const [onProgress, flush] = progressEventDecorator(
  2390. requestContentLength,
  2391. progressEventReducer(asyncDecorator(onUploadProgress))
  2392. );
  2393. data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, onProgress, flush);
  2394. }
  2395. }
  2396. if (!utils$1.isString(withCredentials)) {
  2397. withCredentials = withCredentials ? 'include' : 'omit';
  2398. }
  2399. // Cloudflare Workers throws when credentials are defined
  2400. // see https://github.com/cloudflare/workerd/issues/902
  2401. const isCredentialsSupported = "credentials" in Request.prototype;
  2402. request = new Request(url, {
  2403. ...fetchOptions,
  2404. signal: composedSignal,
  2405. method: method.toUpperCase(),
  2406. headers: headers.normalize().toJSON(),
  2407. body: data,
  2408. duplex: "half",
  2409. credentials: isCredentialsSupported ? withCredentials : undefined
  2410. });
  2411. let response = await fetch(request, fetchOptions);
  2412. const isStreamResponse = supportsResponseStream && (responseType === 'stream' || responseType === 'response');
  2413. if (supportsResponseStream && (onDownloadProgress || (isStreamResponse && unsubscribe))) {
  2414. const options = {};
  2415. ['status', 'statusText', 'headers'].forEach(prop => {
  2416. options[prop] = response[prop];
  2417. });
  2418. const responseContentLength = utils$1.toFiniteNumber(response.headers.get('content-length'));
  2419. const [onProgress, flush] = onDownloadProgress && progressEventDecorator(
  2420. responseContentLength,
  2421. progressEventReducer(asyncDecorator(onDownloadProgress), true)
  2422. ) || [];
  2423. response = new Response(
  2424. trackStream(response.body, DEFAULT_CHUNK_SIZE, onProgress, () => {
  2425. flush && flush();
  2426. unsubscribe && unsubscribe();
  2427. }),
  2428. options
  2429. );
  2430. }
  2431. responseType = responseType || 'text';
  2432. let responseData = await resolvers[utils$1.findKey(resolvers, responseType) || 'text'](response, config);
  2433. !isStreamResponse && unsubscribe && unsubscribe();
  2434. return await new Promise((resolve, reject) => {
  2435. settle(resolve, reject, {
  2436. data: responseData,
  2437. headers: AxiosHeaders$1.from(response.headers),
  2438. status: response.status,
  2439. statusText: response.statusText,
  2440. config,
  2441. request
  2442. });
  2443. })
  2444. } catch (err) {
  2445. unsubscribe && unsubscribe();
  2446. if (err && err.name === 'TypeError' && /Load failed|fetch/i.test(err.message)) {
  2447. throw Object.assign(
  2448. new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request),
  2449. {
  2450. cause: err.cause || err
  2451. }
  2452. )
  2453. }
  2454. throw AxiosError.from(err, err && err.code, config, request);
  2455. }
  2456. });
  2457. const knownAdapters = {
  2458. http: httpAdapter,
  2459. xhr: xhrAdapter,
  2460. fetch: fetchAdapter
  2461. };
  2462. utils$1.forEach(knownAdapters, (fn, value) => {
  2463. if (fn) {
  2464. try {
  2465. Object.defineProperty(fn, 'name', {value});
  2466. } catch (e) {
  2467. // eslint-disable-next-line no-empty
  2468. }
  2469. Object.defineProperty(fn, 'adapterName', {value});
  2470. }
  2471. });
  2472. const renderReason = (reason) => `- ${reason}`;
  2473. const isResolvedHandle = (adapter) => utils$1.isFunction(adapter) || adapter === null || adapter === false;
  2474. var adapters = {
  2475. getAdapter: (adapters) => {
  2476. adapters = utils$1.isArray(adapters) ? adapters : [adapters];
  2477. const {length} = adapters;
  2478. let nameOrAdapter;
  2479. let adapter;
  2480. const rejectedReasons = {};
  2481. for (let i = 0; i < length; i++) {
  2482. nameOrAdapter = adapters[i];
  2483. let id;
  2484. adapter = nameOrAdapter;
  2485. if (!isResolvedHandle(nameOrAdapter)) {
  2486. adapter = knownAdapters[(id = String(nameOrAdapter)).toLowerCase()];
  2487. if (adapter === undefined) {
  2488. throw new AxiosError(`Unknown adapter '${id}'`);
  2489. }
  2490. }
  2491. if (adapter) {
  2492. break;
  2493. }
  2494. rejectedReasons[id || '#' + i] = adapter;
  2495. }
  2496. if (!adapter) {
  2497. const reasons = Object.entries(rejectedReasons)
  2498. .map(([id, state]) => `adapter ${id} ` +
  2499. (state === false ? 'is not supported by the environment' : 'is not available in the build')
  2500. );
  2501. let s = length ?
  2502. (reasons.length > 1 ? 'since :\n' + reasons.map(renderReason).join('\n') : ' ' + renderReason(reasons[0])) :
  2503. 'as no adapter specified';
  2504. throw new AxiosError(
  2505. `There is no suitable adapter to dispatch the request ` + s,
  2506. 'ERR_NOT_SUPPORT'
  2507. );
  2508. }
  2509. return adapter;
  2510. },
  2511. adapters: knownAdapters
  2512. };
  2513. /**
  2514. * Throws a `CanceledError` if cancellation has been requested.
  2515. *
  2516. * @param {Object} config The config that is to be used for the request
  2517. *
  2518. * @returns {void}
  2519. */
  2520. function throwIfCancellationRequested(config) {
  2521. if (config.cancelToken) {
  2522. config.cancelToken.throwIfRequested();
  2523. }
  2524. if (config.signal && config.signal.aborted) {
  2525. throw new CanceledError(null, config);
  2526. }
  2527. }
  2528. /**
  2529. * Dispatch a request to the server using the configured adapter.
  2530. *
  2531. * @param {object} config The config that is to be used for the request
  2532. *
  2533. * @returns {Promise} The Promise to be fulfilled
  2534. */
  2535. function dispatchRequest(config) {
  2536. throwIfCancellationRequested(config);
  2537. config.headers = AxiosHeaders$1.from(config.headers);
  2538. // Transform request data
  2539. config.data = transformData.call(
  2540. config,
  2541. config.transformRequest
  2542. );
  2543. if (['post', 'put', 'patch'].indexOf(config.method) !== -1) {
  2544. config.headers.setContentType('application/x-www-form-urlencoded', false);
  2545. }
  2546. const adapter = adapters.getAdapter(config.adapter || defaults$1.adapter);
  2547. return adapter(config).then(function onAdapterResolution(response) {
  2548. throwIfCancellationRequested(config);
  2549. // Transform response data
  2550. response.data = transformData.call(
  2551. config,
  2552. config.transformResponse,
  2553. response
  2554. );
  2555. response.headers = AxiosHeaders$1.from(response.headers);
  2556. return response;
  2557. }, function onAdapterRejection(reason) {
  2558. if (!isCancel(reason)) {
  2559. throwIfCancellationRequested(config);
  2560. // Transform response data
  2561. if (reason && reason.response) {
  2562. reason.response.data = transformData.call(
  2563. config,
  2564. config.transformResponse,
  2565. reason.response
  2566. );
  2567. reason.response.headers = AxiosHeaders$1.from(reason.response.headers);
  2568. }
  2569. }
  2570. return Promise.reject(reason);
  2571. });
  2572. }
  2573. const VERSION = "1.10.0";
  2574. const validators$1 = {};
  2575. // eslint-disable-next-line func-names
  2576. ['object', 'boolean', 'number', 'function', 'string', 'symbol'].forEach((type, i) => {
  2577. validators$1[type] = function validator(thing) {
  2578. return typeof thing === type || 'a' + (i < 1 ? 'n ' : ' ') + type;
  2579. };
  2580. });
  2581. const deprecatedWarnings = {};
  2582. /**
  2583. * Transitional option validator
  2584. *
  2585. * @param {function|boolean?} validator - set to false if the transitional option has been removed
  2586. * @param {string?} version - deprecated version / removed since version
  2587. * @param {string?} message - some message with additional info
  2588. *
  2589. * @returns {function}
  2590. */
  2591. validators$1.transitional = function transitional(validator, version, message) {
  2592. function formatMessage(opt, desc) {
  2593. return '[Axios v' + VERSION + '] Transitional option \'' + opt + '\'' + desc + (message ? '. ' + message : '');
  2594. }
  2595. // eslint-disable-next-line func-names
  2596. return (value, opt, opts) => {
  2597. if (validator === false) {
  2598. throw new AxiosError(
  2599. formatMessage(opt, ' has been removed' + (version ? ' in ' + version : '')),
  2600. AxiosError.ERR_DEPRECATED
  2601. );
  2602. }
  2603. if (version && !deprecatedWarnings[opt]) {
  2604. deprecatedWarnings[opt] = true;
  2605. // eslint-disable-next-line no-console
  2606. console.warn(
  2607. formatMessage(
  2608. opt,
  2609. ' has been deprecated since v' + version + ' and will be removed in the near future'
  2610. )
  2611. );
  2612. }
  2613. return validator ? validator(value, opt, opts) : true;
  2614. };
  2615. };
  2616. validators$1.spelling = function spelling(correctSpelling) {
  2617. return (value, opt) => {
  2618. // eslint-disable-next-line no-console
  2619. console.warn(`${opt} is likely a misspelling of ${correctSpelling}`);
  2620. return true;
  2621. }
  2622. };
  2623. /**
  2624. * Assert object's properties type
  2625. *
  2626. * @param {object} options
  2627. * @param {object} schema
  2628. * @param {boolean?} allowUnknown
  2629. *
  2630. * @returns {object}
  2631. */
  2632. function assertOptions(options, schema, allowUnknown) {
  2633. if (typeof options !== 'object') {
  2634. throw new AxiosError('options must be an object', AxiosError.ERR_BAD_OPTION_VALUE);
  2635. }
  2636. const keys = Object.keys(options);
  2637. let i = keys.length;
  2638. while (i-- > 0) {
  2639. const opt = keys[i];
  2640. const validator = schema[opt];
  2641. if (validator) {
  2642. const value = options[opt];
  2643. const result = value === undefined || validator(value, opt, options);
  2644. if (result !== true) {
  2645. throw new AxiosError('option ' + opt + ' must be ' + result, AxiosError.ERR_BAD_OPTION_VALUE);
  2646. }
  2647. continue;
  2648. }
  2649. if (allowUnknown !== true) {
  2650. throw new AxiosError('Unknown option ' + opt, AxiosError.ERR_BAD_OPTION);
  2651. }
  2652. }
  2653. }
  2654. var validator = {
  2655. assertOptions,
  2656. validators: validators$1
  2657. };
  2658. const validators = validator.validators;
  2659. /**
  2660. * Create a new instance of Axios
  2661. *
  2662. * @param {Object} instanceConfig The default config for the instance
  2663. *
  2664. * @return {Axios} A new instance of Axios
  2665. */
  2666. class Axios {
  2667. constructor(instanceConfig) {
  2668. this.defaults = instanceConfig || {};
  2669. this.interceptors = {
  2670. request: new InterceptorManager$1(),
  2671. response: new InterceptorManager$1()
  2672. };
  2673. }
  2674. /**
  2675. * Dispatch a request
  2676. *
  2677. * @param {String|Object} configOrUrl The config specific for this request (merged with this.defaults)
  2678. * @param {?Object} config
  2679. *
  2680. * @returns {Promise} The Promise to be fulfilled
  2681. */
  2682. async request(configOrUrl, config) {
  2683. try {
  2684. return await this._request(configOrUrl, config);
  2685. } catch (err) {
  2686. if (err instanceof Error) {
  2687. let dummy = {};
  2688. Error.captureStackTrace ? Error.captureStackTrace(dummy) : (dummy = new Error());
  2689. // slice off the Error: ... line
  2690. const stack = dummy.stack ? dummy.stack.replace(/^.+\n/, '') : '';
  2691. try {
  2692. if (!err.stack) {
  2693. err.stack = stack;
  2694. // match without the 2 top stack lines
  2695. } else if (stack && !String(err.stack).endsWith(stack.replace(/^.+\n.+\n/, ''))) {
  2696. err.stack += '\n' + stack;
  2697. }
  2698. } catch (e) {
  2699. // ignore the case where "stack" is an un-writable property
  2700. }
  2701. }
  2702. throw err;
  2703. }
  2704. }
  2705. _request(configOrUrl, config) {
  2706. /*eslint no-param-reassign:0*/
  2707. // Allow for axios('example/url'[, config]) a la fetch API
  2708. if (typeof configOrUrl === 'string') {
  2709. config = config || {};
  2710. config.url = configOrUrl;
  2711. } else {
  2712. config = configOrUrl || {};
  2713. }
  2714. config = mergeConfig(this.defaults, config);
  2715. const {transitional, paramsSerializer, headers} = config;
  2716. if (transitional !== undefined) {
  2717. validator.assertOptions(transitional, {
  2718. silentJSONParsing: validators.transitional(validators.boolean),
  2719. forcedJSONParsing: validators.transitional(validators.boolean),
  2720. clarifyTimeoutError: validators.transitional(validators.boolean)
  2721. }, false);
  2722. }
  2723. if (paramsSerializer != null) {
  2724. if (utils$1.isFunction(paramsSerializer)) {
  2725. config.paramsSerializer = {
  2726. serialize: paramsSerializer
  2727. };
  2728. } else {
  2729. validator.assertOptions(paramsSerializer, {
  2730. encode: validators.function,
  2731. serialize: validators.function
  2732. }, true);
  2733. }
  2734. }
  2735. // Set config.allowAbsoluteUrls
  2736. if (config.allowAbsoluteUrls !== undefined) ; else if (this.defaults.allowAbsoluteUrls !== undefined) {
  2737. config.allowAbsoluteUrls = this.defaults.allowAbsoluteUrls;
  2738. } else {
  2739. config.allowAbsoluteUrls = true;
  2740. }
  2741. validator.assertOptions(config, {
  2742. baseUrl: validators.spelling('baseURL'),
  2743. withXsrfToken: validators.spelling('withXSRFToken')
  2744. }, true);
  2745. // Set config.method
  2746. config.method = (config.method || this.defaults.method || 'get').toLowerCase();
  2747. // Flatten headers
  2748. let contextHeaders = headers && utils$1.merge(
  2749. headers.common,
  2750. headers[config.method]
  2751. );
  2752. headers && utils$1.forEach(
  2753. ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
  2754. (method) => {
  2755. delete headers[method];
  2756. }
  2757. );
  2758. config.headers = AxiosHeaders$1.concat(contextHeaders, headers);
  2759. // filter out skipped interceptors
  2760. const requestInterceptorChain = [];
  2761. let synchronousRequestInterceptors = true;
  2762. this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
  2763. if (typeof interceptor.runWhen === 'function' && interceptor.runWhen(config) === false) {
  2764. return;
  2765. }
  2766. synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
  2767. requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
  2768. });
  2769. const responseInterceptorChain = [];
  2770. this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
  2771. responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
  2772. });
  2773. let promise;
  2774. let i = 0;
  2775. let len;
  2776. if (!synchronousRequestInterceptors) {
  2777. const chain = [dispatchRequest.bind(this), undefined];
  2778. chain.unshift.apply(chain, requestInterceptorChain);
  2779. chain.push.apply(chain, responseInterceptorChain);
  2780. len = chain.length;
  2781. promise = Promise.resolve(config);
  2782. while (i < len) {
  2783. promise = promise.then(chain[i++], chain[i++]);
  2784. }
  2785. return promise;
  2786. }
  2787. len = requestInterceptorChain.length;
  2788. let newConfig = config;
  2789. i = 0;
  2790. while (i < len) {
  2791. const onFulfilled = requestInterceptorChain[i++];
  2792. const onRejected = requestInterceptorChain[i++];
  2793. try {
  2794. newConfig = onFulfilled(newConfig);
  2795. } catch (error) {
  2796. onRejected.call(this, error);
  2797. break;
  2798. }
  2799. }
  2800. try {
  2801. promise = dispatchRequest.call(this, newConfig);
  2802. } catch (error) {
  2803. return Promise.reject(error);
  2804. }
  2805. i = 0;
  2806. len = responseInterceptorChain.length;
  2807. while (i < len) {
  2808. promise = promise.then(responseInterceptorChain[i++], responseInterceptorChain[i++]);
  2809. }
  2810. return promise;
  2811. }
  2812. getUri(config) {
  2813. config = mergeConfig(this.defaults, config);
  2814. const fullPath = buildFullPath(config.baseURL, config.url, config.allowAbsoluteUrls);
  2815. return buildURL(fullPath, config.params, config.paramsSerializer);
  2816. }
  2817. }
  2818. // Provide aliases for supported request methods
  2819. utils$1.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
  2820. /*eslint func-names:0*/
  2821. Axios.prototype[method] = function(url, config) {
  2822. return this.request(mergeConfig(config || {}, {
  2823. method,
  2824. url,
  2825. data: (config || {}).data
  2826. }));
  2827. };
  2828. });
  2829. utils$1.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
  2830. /*eslint func-names:0*/
  2831. function generateHTTPMethod(isForm) {
  2832. return function httpMethod(url, data, config) {
  2833. return this.request(mergeConfig(config || {}, {
  2834. method,
  2835. headers: isForm ? {
  2836. 'Content-Type': 'multipart/form-data'
  2837. } : {},
  2838. url,
  2839. data
  2840. }));
  2841. };
  2842. }
  2843. Axios.prototype[method] = generateHTTPMethod();
  2844. Axios.prototype[method + 'Form'] = generateHTTPMethod(true);
  2845. });
  2846. var Axios$1 = Axios;
  2847. /**
  2848. * A `CancelToken` is an object that can be used to request cancellation of an operation.
  2849. *
  2850. * @param {Function} executor The executor function.
  2851. *
  2852. * @returns {CancelToken}
  2853. */
  2854. class CancelToken {
  2855. constructor(executor) {
  2856. if (typeof executor !== 'function') {
  2857. throw new TypeError('executor must be a function.');
  2858. }
  2859. let resolvePromise;
  2860. this.promise = new Promise(function promiseExecutor(resolve) {
  2861. resolvePromise = resolve;
  2862. });
  2863. const token = this;
  2864. // eslint-disable-next-line func-names
  2865. this.promise.then(cancel => {
  2866. if (!token._listeners) return;
  2867. let i = token._listeners.length;
  2868. while (i-- > 0) {
  2869. token._listeners[i](cancel);
  2870. }
  2871. token._listeners = null;
  2872. });
  2873. // eslint-disable-next-line func-names
  2874. this.promise.then = onfulfilled => {
  2875. let _resolve;
  2876. // eslint-disable-next-line func-names
  2877. const promise = new Promise(resolve => {
  2878. token.subscribe(resolve);
  2879. _resolve = resolve;
  2880. }).then(onfulfilled);
  2881. promise.cancel = function reject() {
  2882. token.unsubscribe(_resolve);
  2883. };
  2884. return promise;
  2885. };
  2886. executor(function cancel(message, config, request) {
  2887. if (token.reason) {
  2888. // Cancellation has already been requested
  2889. return;
  2890. }
  2891. token.reason = new CanceledError(message, config, request);
  2892. resolvePromise(token.reason);
  2893. });
  2894. }
  2895. /**
  2896. * Throws a `CanceledError` if cancellation has been requested.
  2897. */
  2898. throwIfRequested() {
  2899. if (this.reason) {
  2900. throw this.reason;
  2901. }
  2902. }
  2903. /**
  2904. * Subscribe to the cancel signal
  2905. */
  2906. subscribe(listener) {
  2907. if (this.reason) {
  2908. listener(this.reason);
  2909. return;
  2910. }
  2911. if (this._listeners) {
  2912. this._listeners.push(listener);
  2913. } else {
  2914. this._listeners = [listener];
  2915. }
  2916. }
  2917. /**
  2918. * Unsubscribe from the cancel signal
  2919. */
  2920. unsubscribe(listener) {
  2921. if (!this._listeners) {
  2922. return;
  2923. }
  2924. const index = this._listeners.indexOf(listener);
  2925. if (index !== -1) {
  2926. this._listeners.splice(index, 1);
  2927. }
  2928. }
  2929. toAbortSignal() {
  2930. const controller = new AbortController();
  2931. const abort = (err) => {
  2932. controller.abort(err);
  2933. };
  2934. this.subscribe(abort);
  2935. controller.signal.unsubscribe = () => this.unsubscribe(abort);
  2936. return controller.signal;
  2937. }
  2938. /**
  2939. * Returns an object that contains a new `CancelToken` and a function that, when called,
  2940. * cancels the `CancelToken`.
  2941. */
  2942. static source() {
  2943. let cancel;
  2944. const token = new CancelToken(function executor(c) {
  2945. cancel = c;
  2946. });
  2947. return {
  2948. token,
  2949. cancel
  2950. };
  2951. }
  2952. }
  2953. var CancelToken$1 = CancelToken;
  2954. /**
  2955. * Syntactic sugar for invoking a function and expanding an array for arguments.
  2956. *
  2957. * Common use case would be to use `Function.prototype.apply`.
  2958. *
  2959. * ```js
  2960. * function f(x, y, z) {}
  2961. * var args = [1, 2, 3];
  2962. * f.apply(null, args);
  2963. * ```
  2964. *
  2965. * With `spread` this example can be re-written.
  2966. *
  2967. * ```js
  2968. * spread(function(x, y, z) {})([1, 2, 3]);
  2969. * ```
  2970. *
  2971. * @param {Function} callback
  2972. *
  2973. * @returns {Function}
  2974. */
  2975. function spread(callback) {
  2976. return function wrap(arr) {
  2977. return callback.apply(null, arr);
  2978. };
  2979. }
  2980. /**
  2981. * Determines whether the payload is an error thrown by Axios
  2982. *
  2983. * @param {*} payload The value to test
  2984. *
  2985. * @returns {boolean} True if the payload is an error thrown by Axios, otherwise false
  2986. */
  2987. function isAxiosError(payload) {
  2988. return utils$1.isObject(payload) && (payload.isAxiosError === true);
  2989. }
  2990. const HttpStatusCode = {
  2991. Continue: 100,
  2992. SwitchingProtocols: 101,
  2993. Processing: 102,
  2994. EarlyHints: 103,
  2995. Ok: 200,
  2996. Created: 201,
  2997. Accepted: 202,
  2998. NonAuthoritativeInformation: 203,
  2999. NoContent: 204,
  3000. ResetContent: 205,
  3001. PartialContent: 206,
  3002. MultiStatus: 207,
  3003. AlreadyReported: 208,
  3004. ImUsed: 226,
  3005. MultipleChoices: 300,
  3006. MovedPermanently: 301,
  3007. Found: 302,
  3008. SeeOther: 303,
  3009. NotModified: 304,
  3010. UseProxy: 305,
  3011. Unused: 306,
  3012. TemporaryRedirect: 307,
  3013. PermanentRedirect: 308,
  3014. BadRequest: 400,
  3015. Unauthorized: 401,
  3016. PaymentRequired: 402,
  3017. Forbidden: 403,
  3018. NotFound: 404,
  3019. MethodNotAllowed: 405,
  3020. NotAcceptable: 406,
  3021. ProxyAuthenticationRequired: 407,
  3022. RequestTimeout: 408,
  3023. Conflict: 409,
  3024. Gone: 410,
  3025. LengthRequired: 411,
  3026. PreconditionFailed: 412,
  3027. PayloadTooLarge: 413,
  3028. UriTooLong: 414,
  3029. UnsupportedMediaType: 415,
  3030. RangeNotSatisfiable: 416,
  3031. ExpectationFailed: 417,
  3032. ImATeapot: 418,
  3033. MisdirectedRequest: 421,
  3034. UnprocessableEntity: 422,
  3035. Locked: 423,
  3036. FailedDependency: 424,
  3037. TooEarly: 425,
  3038. UpgradeRequired: 426,
  3039. PreconditionRequired: 428,
  3040. TooManyRequests: 429,
  3041. RequestHeaderFieldsTooLarge: 431,
  3042. UnavailableForLegalReasons: 451,
  3043. InternalServerError: 500,
  3044. NotImplemented: 501,
  3045. BadGateway: 502,
  3046. ServiceUnavailable: 503,
  3047. GatewayTimeout: 504,
  3048. HttpVersionNotSupported: 505,
  3049. VariantAlsoNegotiates: 506,
  3050. InsufficientStorage: 507,
  3051. LoopDetected: 508,
  3052. NotExtended: 510,
  3053. NetworkAuthenticationRequired: 511,
  3054. };
  3055. Object.entries(HttpStatusCode).forEach(([key, value]) => {
  3056. HttpStatusCode[value] = key;
  3057. });
  3058. var HttpStatusCode$1 = HttpStatusCode;
  3059. /**
  3060. * Create an instance of Axios
  3061. *
  3062. * @param {Object} defaultConfig The default config for the instance
  3063. *
  3064. * @returns {Axios} A new instance of Axios
  3065. */
  3066. function createInstance(defaultConfig) {
  3067. const context = new Axios$1(defaultConfig);
  3068. const instance = bind(Axios$1.prototype.request, context);
  3069. // Copy axios.prototype to instance
  3070. utils$1.extend(instance, Axios$1.prototype, context, {allOwnKeys: true});
  3071. // Copy context to instance
  3072. utils$1.extend(instance, context, null, {allOwnKeys: true});
  3073. // Factory for creating new instances
  3074. instance.create = function create(instanceConfig) {
  3075. return createInstance(mergeConfig(defaultConfig, instanceConfig));
  3076. };
  3077. return instance;
  3078. }
  3079. // Create the default instance to be exported
  3080. const axios = createInstance(defaults$1);
  3081. // Expose Axios class to allow class inheritance
  3082. axios.Axios = Axios$1;
  3083. // Expose Cancel & CancelToken
  3084. axios.CanceledError = CanceledError;
  3085. axios.CancelToken = CancelToken$1;
  3086. axios.isCancel = isCancel;
  3087. axios.VERSION = VERSION;
  3088. axios.toFormData = toFormData;
  3089. // Expose AxiosError class
  3090. axios.AxiosError = AxiosError;
  3091. // alias for CanceledError for backward compatibility
  3092. axios.Cancel = axios.CanceledError;
  3093. // Expose all/spread
  3094. axios.all = function all(promises) {
  3095. return Promise.all(promises);
  3096. };
  3097. axios.spread = spread;
  3098. // Expose isAxiosError
  3099. axios.isAxiosError = isAxiosError;
  3100. // Expose mergeConfig
  3101. axios.mergeConfig = mergeConfig;
  3102. axios.AxiosHeaders = AxiosHeaders$1;
  3103. axios.formToJSON = thing => formDataToJSON(utils$1.isHTMLForm(thing) ? new FormData(thing) : thing);
  3104. axios.getAdapter = adapters.getAdapter;
  3105. axios.HttpStatusCode = HttpStatusCode$1;
  3106. axios.default = axios;
  3107. module.exports = axios;
  3108. //# sourceMappingURL=axios.cjs.map