8cc2f90d32b566fe7e8a7ee94cd0e29d9fae89c513950d524e81e9526d226c9125e522f6611a88ba47d104f9bef1f4a93199e7a4bd3ad04c622e3c84e6a845 63 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369
  1. // axios v0.28.1 Copyright (c) 2024 Matt Zabriskie
  2. var bind = function bind(fn, thisArg) {
  3. return function wrap() {
  4. return fn.apply(thisArg, arguments);
  5. };
  6. };
  7. // utils is a library of generic helper functions non-specific to axios
  8. var toString = Object.prototype.toString;
  9. // eslint-disable-next-line func-names
  10. var kindOf = (function(cache) {
  11. // eslint-disable-next-line func-names
  12. return function(thing) {
  13. var str = toString.call(thing);
  14. return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase());
  15. };
  16. })(Object.create(null));
  17. function kindOfTest(type) {
  18. type = type.toLowerCase();
  19. return function isKindOf(thing) {
  20. return kindOf(thing) === type;
  21. };
  22. }
  23. /**
  24. * Determine if a value is an Array
  25. *
  26. * @param {Object} val The value to test
  27. * @returns {boolean} True if value is an Array, otherwise false
  28. */
  29. function isArray(val) {
  30. return Array.isArray(val);
  31. }
  32. /**
  33. * Determine if a value is undefined
  34. *
  35. * @param {Object} val The value to test
  36. * @returns {boolean} True if the value is undefined, otherwise false
  37. */
  38. function isUndefined(val) {
  39. return typeof val === 'undefined';
  40. }
  41. /**
  42. * Determine if a value is a Buffer
  43. *
  44. * @param {Object} val The value to test
  45. * @returns {boolean} True if value is a Buffer, otherwise false
  46. */
  47. function isBuffer(val) {
  48. return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor)
  49. && typeof val.constructor.isBuffer === 'function' && val.constructor.isBuffer(val);
  50. }
  51. /**
  52. * Determine if a value is an ArrayBuffer
  53. *
  54. * @function
  55. * @param {Object} val The value to test
  56. * @returns {boolean} True if value is an ArrayBuffer, otherwise false
  57. */
  58. var isArrayBuffer = kindOfTest('ArrayBuffer');
  59. /**
  60. * Determine if a value is a view on an ArrayBuffer
  61. *
  62. * @param {Object} val The value to test
  63. * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false
  64. */
  65. function isArrayBufferView(val) {
  66. var result;
  67. if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {
  68. result = ArrayBuffer.isView(val);
  69. } else {
  70. result = (val) && (val.buffer) && (isArrayBuffer(val.buffer));
  71. }
  72. return result;
  73. }
  74. /**
  75. * Determine if a value is a String
  76. *
  77. * @param {Object} val The value to test
  78. * @returns {boolean} True if value is a String, otherwise false
  79. */
  80. function isString(val) {
  81. return typeof val === 'string';
  82. }
  83. /**
  84. * Determine if a value is a Number
  85. *
  86. * @param {Object} val The value to test
  87. * @returns {boolean} True if value is a Number, otherwise false
  88. */
  89. function isNumber(val) {
  90. return typeof val === 'number';
  91. }
  92. /**
  93. * Determine if a value is an Object
  94. *
  95. * @param {Object} val The value to test
  96. * @returns {boolean} True if value is an Object, otherwise false
  97. */
  98. function isObject(val) {
  99. return val !== null && typeof val === 'object';
  100. }
  101. /**
  102. * Determine if a value is a plain Object
  103. *
  104. * @param {Object} val The value to test
  105. * @return {boolean} True if value is a plain Object, otherwise false
  106. */
  107. function isPlainObject(val) {
  108. if (kindOf(val) !== 'object') {
  109. return false;
  110. }
  111. var prototype = Object.getPrototypeOf(val);
  112. return prototype === null || prototype === Object.prototype;
  113. }
  114. /**
  115. * Determine if a value is a empty Object
  116. *
  117. * @param {Object} val The value to test
  118. * @return {boolean} True if value is a empty Object, otherwise false
  119. */
  120. function isEmptyObject(val) {
  121. return val && Object.keys(val).length === 0 && Object.getPrototypeOf(val) === Object.prototype;
  122. }
  123. /**
  124. * Determine if a value is a Date
  125. *
  126. * @function
  127. * @param {Object} val The value to test
  128. * @returns {boolean} True if value is a Date, otherwise false
  129. */
  130. var isDate = kindOfTest('Date');
  131. /**
  132. * Determine if a value is a File
  133. *
  134. * @function
  135. * @param {Object} val The value to test
  136. * @returns {boolean} True if value is a File, otherwise false
  137. */
  138. var isFile = kindOfTest('File');
  139. /**
  140. * Determine if a value is a Blob
  141. *
  142. * @function
  143. * @param {Object} val The value to test
  144. * @returns {boolean} True if value is a Blob, otherwise false
  145. */
  146. var isBlob = kindOfTest('Blob');
  147. /**
  148. * Determine if a value is a FileList
  149. *
  150. * @function
  151. * @param {Object} val The value to test
  152. * @returns {boolean} True if value is a File, otherwise false
  153. */
  154. var isFileList = kindOfTest('FileList');
  155. /**
  156. * Determine if a value is a Function
  157. *
  158. * @param {Object} val The value to test
  159. * @returns {boolean} True if value is a Function, otherwise false
  160. */
  161. function isFunction(val) {
  162. return toString.call(val) === '[object Function]';
  163. }
  164. /**
  165. * Determine if a value is a Stream
  166. *
  167. * @param {Object} val The value to test
  168. * @returns {boolean} True if value is a Stream, otherwise false
  169. */
  170. function isStream(val) {
  171. return isObject(val) && isFunction(val.pipe);
  172. }
  173. /**
  174. * Determine if a value is a FormData
  175. *
  176. * @param {Object} thing The value to test
  177. * @returns {boolean} True if value is an FormData, otherwise false
  178. */
  179. function isFormData(thing) {
  180. var pattern = '[object FormData]';
  181. return thing && (
  182. (typeof FormData === 'function' && thing instanceof FormData) ||
  183. toString.call(thing) === pattern ||
  184. (isFunction(thing.toString) && thing.toString() === pattern)
  185. );
  186. }
  187. /**
  188. * Determine if a value is a URLSearchParams object
  189. * @function
  190. * @param {Object} val The value to test
  191. * @returns {boolean} True if value is a URLSearchParams object, otherwise false
  192. */
  193. var isURLSearchParams = kindOfTest('URLSearchParams');
  194. /**
  195. * Trim excess whitespace off the beginning and end of a string
  196. *
  197. * @param {String} str The String to trim
  198. * @returns {String} The String freed of excess whitespace
  199. */
  200. function trim(str) {
  201. return str.trim ? str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
  202. }
  203. /**
  204. * Determine if we're running in a standard browser environment
  205. *
  206. * This allows axios to run in a web worker, and react-native.
  207. * Both environments support XMLHttpRequest, but not fully standard globals.
  208. *
  209. * web workers:
  210. * typeof window -> undefined
  211. * typeof document -> undefined
  212. *
  213. * react-native:
  214. * navigator.product -> 'ReactNative'
  215. * nativescript
  216. * navigator.product -> 'NativeScript' or 'NS'
  217. */
  218. function isStandardBrowserEnv() {
  219. var product;
  220. if (typeof navigator !== 'undefined' && (
  221. (product = navigator.product) === 'ReactNative' ||
  222. product === 'NativeScript' ||
  223. product === 'NS')
  224. ) {
  225. return false;
  226. }
  227. return typeof window !== 'undefined' && typeof document !== 'undefined';
  228. }
  229. /**
  230. * Iterate over an Array or an Object invoking a function for each item.
  231. *
  232. * If `obj` is an Array callback will be called passing
  233. * the value, index, and complete array for each item.
  234. *
  235. * If 'obj' is an Object callback will be called passing
  236. * the value, key, and complete object for each property.
  237. *
  238. * @param {Object|Array} obj The object to iterate
  239. * @param {Function} fn The callback to invoke for each item
  240. */
  241. function forEach(obj, fn) {
  242. // Don't bother if no value provided
  243. if (obj === null || typeof obj === 'undefined') {
  244. return;
  245. }
  246. // Force an array if not already something iterable
  247. if (typeof obj !== 'object') {
  248. /*eslint no-param-reassign:0*/
  249. obj = [obj];
  250. }
  251. if (isArray(obj)) {
  252. // Iterate over array values
  253. for (var i = 0, l = obj.length; i < l; i++) {
  254. fn.call(null, obj[i], i, obj);
  255. }
  256. } else {
  257. // Iterate over object keys
  258. for (var key in obj) {
  259. if (Object.prototype.hasOwnProperty.call(obj, key)) {
  260. fn.call(null, obj[key], key, obj);
  261. }
  262. }
  263. }
  264. }
  265. /**
  266. * Accepts varargs expecting each argument to be an object, then
  267. * immutably merges the properties of each object and returns result.
  268. *
  269. * When multiple objects contain the same key the later object in
  270. * the arguments list will take precedence.
  271. *
  272. * Example:
  273. *
  274. * ```js
  275. * var result = merge({foo: 123}, {foo: 456});
  276. * console.log(result.foo); // outputs 456
  277. * ```
  278. *
  279. * @param {Object} obj1 Object to merge
  280. * @returns {Object} Result of all merge properties
  281. */
  282. function merge(/* obj1, obj2, obj3, ... */) {
  283. var result = {};
  284. function assignValue(val, key) {
  285. if (isPlainObject(result[key]) && isPlainObject(val)) {
  286. result[key] = merge(result[key], val);
  287. } else if (isPlainObject(val)) {
  288. result[key] = merge({}, val);
  289. } else if (isArray(val)) {
  290. result[key] = val.slice();
  291. } else {
  292. result[key] = val;
  293. }
  294. }
  295. for (var i = 0, l = arguments.length; i < l; i++) {
  296. forEach(arguments[i], assignValue);
  297. }
  298. return result;
  299. }
  300. /**
  301. * Extends object a by mutably adding to it the properties of object b.
  302. *
  303. * @param {Object} a The object to be extended
  304. * @param {Object} b The object to copy properties from
  305. * @param {Object} thisArg The object to bind function to
  306. * @return {Object} The resulting value of object a
  307. */
  308. function extend(a, b, thisArg) {
  309. forEach(b, function assignValue(val, key) {
  310. if (thisArg && typeof val === 'function') {
  311. a[key] = bind(val, thisArg);
  312. } else {
  313. a[key] = val;
  314. }
  315. });
  316. return a;
  317. }
  318. /**
  319. * Remove byte order marker. This catches EF BB BF (the UTF-8 BOM)
  320. *
  321. * @param {string} content with BOM
  322. * @return {string} content value without BOM
  323. */
  324. function stripBOM(content) {
  325. if (content.charCodeAt(0) === 0xFEFF) {
  326. content = content.slice(1);
  327. }
  328. return content;
  329. }
  330. /**
  331. * Inherit the prototype methods from one constructor into another
  332. * @param {function} constructor
  333. * @param {function} superConstructor
  334. * @param {object} [props]
  335. * @param {object} [descriptors]
  336. */
  337. function inherits(constructor, superConstructor, props, descriptors) {
  338. constructor.prototype = Object.create(superConstructor.prototype, descriptors);
  339. constructor.prototype.constructor = constructor;
  340. props && Object.assign(constructor.prototype, props);
  341. }
  342. /**
  343. * Resolve object with deep prototype chain to a flat object
  344. * @param {Object} sourceObj source object
  345. * @param {Object} [destObj]
  346. * @param {Function|Boolean} [filter]
  347. * @param {Function} [propFilter]
  348. * @returns {Object}
  349. */
  350. function toFlatObject(sourceObj, destObj, filter, propFilter) {
  351. var props;
  352. var i;
  353. var prop;
  354. var merged = {};
  355. destObj = destObj || {};
  356. // eslint-disable-next-line no-eq-null,eqeqeq
  357. if (sourceObj == null) return destObj;
  358. do {
  359. props = Object.getOwnPropertyNames(sourceObj);
  360. i = props.length;
  361. while (i-- > 0) {
  362. prop = props[i];
  363. if ((!propFilter || propFilter(prop, sourceObj, destObj)) && !merged[prop]) {
  364. destObj[prop] = sourceObj[prop];
  365. merged[prop] = true;
  366. }
  367. }
  368. sourceObj = filter !== false && Object.getPrototypeOf(sourceObj);
  369. } while (sourceObj && (!filter || filter(sourceObj, destObj)) && sourceObj !== Object.prototype);
  370. return destObj;
  371. }
  372. /*
  373. * determines whether a string ends with the characters of a specified string
  374. * @param {String} str
  375. * @param {String} searchString
  376. * @param {Number} [position= 0]
  377. * @returns {boolean}
  378. */
  379. function endsWith(str, searchString, position) {
  380. str = String(str);
  381. if (position === undefined || position > str.length) {
  382. position = str.length;
  383. }
  384. position -= searchString.length;
  385. var lastIndex = str.indexOf(searchString, position);
  386. return lastIndex !== -1 && lastIndex === position;
  387. }
  388. /**
  389. * Returns new array from array like object or null if failed
  390. * @param {*} [thing]
  391. * @returns {?Array}
  392. */
  393. function toArray(thing) {
  394. if (!thing) return null;
  395. if (isArray(thing)) return thing;
  396. var i = thing.length;
  397. if (!isNumber(i)) return null;
  398. var arr = new Array(i);
  399. while (i-- > 0) {
  400. arr[i] = thing[i];
  401. }
  402. return arr;
  403. }
  404. // eslint-disable-next-line func-names
  405. var isTypedArray = (function(TypedArray) {
  406. // eslint-disable-next-line func-names
  407. return function(thing) {
  408. return TypedArray && thing instanceof TypedArray;
  409. };
  410. })(typeof Uint8Array !== 'undefined' && Object.getPrototypeOf(Uint8Array));
  411. function forEachEntry(obj, fn) {
  412. var generator = obj && obj[Symbol.iterator];
  413. var iterator = generator.call(obj);
  414. var result;
  415. while ((result = iterator.next()) && !result.done) {
  416. var pair = result.value;
  417. fn.call(obj, pair[0], pair[1]);
  418. }
  419. }
  420. function matchAll(regExp, str) {
  421. var matches;
  422. var arr = [];
  423. while ((matches = regExp.exec(str)) !== null) {
  424. arr.push(matches);
  425. }
  426. return arr;
  427. }
  428. var isHTMLForm = kindOfTest('HTMLFormElement');
  429. var hasOwnProperty = (function resolver(_hasOwnProperty) {
  430. return function(obj, prop) {
  431. return _hasOwnProperty.call(obj, prop);
  432. };
  433. })(Object.prototype.hasOwnProperty);
  434. var utils = {
  435. isArray: isArray,
  436. isArrayBuffer: isArrayBuffer,
  437. isBuffer: isBuffer,
  438. isFormData: isFormData,
  439. isArrayBufferView: isArrayBufferView,
  440. isString: isString,
  441. isNumber: isNumber,
  442. isObject: isObject,
  443. isPlainObject: isPlainObject,
  444. isEmptyObject: isEmptyObject,
  445. isUndefined: isUndefined,
  446. isDate: isDate,
  447. isFile: isFile,
  448. isBlob: isBlob,
  449. isFunction: isFunction,
  450. isStream: isStream,
  451. isURLSearchParams: isURLSearchParams,
  452. isStandardBrowserEnv: isStandardBrowserEnv,
  453. forEach: forEach,
  454. merge: merge,
  455. extend: extend,
  456. trim: trim,
  457. stripBOM: stripBOM,
  458. inherits: inherits,
  459. toFlatObject: toFlatObject,
  460. kindOf: kindOf,
  461. kindOfTest: kindOfTest,
  462. endsWith: endsWith,
  463. toArray: toArray,
  464. isTypedArray: isTypedArray,
  465. isFileList: isFileList,
  466. forEachEntry: forEachEntry,
  467. matchAll: matchAll,
  468. isHTMLForm: isHTMLForm,
  469. hasOwnProperty: hasOwnProperty
  470. };
  471. /**
  472. * Create an Error with the specified message, config, error code, request and response.
  473. *
  474. * @param {string} message The error message.
  475. * @param {string} [code] The error code (for example, 'ECONNABORTED').
  476. * @param {Object} [config] The config.
  477. * @param {Object} [request] The request.
  478. * @param {Object} [response] The response.
  479. * @returns {Error} The created error.
  480. */
  481. function AxiosError(message, code, config, request, response) {
  482. Error.call(this);
  483. if (Error.captureStackTrace) {
  484. Error.captureStackTrace(this, this.constructor);
  485. } else {
  486. this.stack = (new Error()).stack;
  487. }
  488. this.message = message;
  489. this.name = 'AxiosError';
  490. code && (this.code = code);
  491. config && (this.config = config);
  492. request && (this.request = request);
  493. response && (this.response = response);
  494. }
  495. utils.inherits(AxiosError, Error, {
  496. toJSON: function toJSON() {
  497. return {
  498. // Standard
  499. message: this.message,
  500. name: this.name,
  501. // Microsoft
  502. description: this.description,
  503. number: this.number,
  504. // Mozilla
  505. fileName: this.fileName,
  506. lineNumber: this.lineNumber,
  507. columnNumber: this.columnNumber,
  508. stack: this.stack,
  509. // Axios
  510. config: this.config,
  511. code: this.code,
  512. status: this.response && this.response.status ? this.response.status : null
  513. };
  514. }
  515. });
  516. var prototype$1 = AxiosError.prototype;
  517. var descriptors = {};
  518. [
  519. 'ERR_BAD_OPTION_VALUE',
  520. 'ERR_BAD_OPTION',
  521. 'ECONNABORTED',
  522. 'ETIMEDOUT',
  523. 'ERR_NETWORK',
  524. 'ERR_FR_TOO_MANY_REDIRECTS',
  525. 'ERR_DEPRECATED',
  526. 'ERR_BAD_RESPONSE',
  527. 'ERR_BAD_REQUEST',
  528. 'ERR_CANCELED',
  529. 'ERR_NOT_SUPPORT',
  530. 'ERR_INVALID_URL'
  531. // eslint-disable-next-line func-names
  532. ].forEach(function(code) {
  533. descriptors[code] = {value: code};
  534. });
  535. Object.defineProperties(AxiosError, descriptors);
  536. Object.defineProperty(prototype$1, 'isAxiosError', {value: true});
  537. // eslint-disable-next-line func-names
  538. AxiosError.from = function(error, code, config, request, response, customProps) {
  539. var axiosError = Object.create(prototype$1);
  540. utils.toFlatObject(error, axiosError, function filter(obj) {
  541. return obj !== Error.prototype;
  542. });
  543. AxiosError.call(axiosError, error.message, code, config, request, response);
  544. axiosError.cause = error;
  545. axiosError.name = error.name;
  546. customProps && Object.assign(axiosError, customProps);
  547. return axiosError;
  548. };
  549. var AxiosError_1 = AxiosError;
  550. /* eslint-env browser */
  551. var browser$1 = typeof self == 'object' ? self.FormData : window.FormData;
  552. // eslint-disable-next-line strict
  553. var FormData$1 = browser$1;
  554. function isVisitable(thing) {
  555. return utils.isPlainObject(thing) || utils.isArray(thing);
  556. }
  557. function removeBrackets(key) {
  558. return utils.endsWith(key, '[]') ? key.slice(0, -2) : key;
  559. }
  560. function renderKey(path, key, dots) {
  561. if (!path) return key;
  562. return path.concat(key).map(function each(token, i) {
  563. // eslint-disable-next-line no-param-reassign
  564. token = removeBrackets(token);
  565. return !dots && i ? '[' + token + ']' : token;
  566. }).join(dots ? '.' : '');
  567. }
  568. function isFlatArray(arr) {
  569. return utils.isArray(arr) && !arr.some(isVisitable);
  570. }
  571. var predicates = utils.toFlatObject(utils, {}, null, function filter(prop) {
  572. return /^is[A-Z]/.test(prop);
  573. });
  574. function isSpecCompliant(thing) {
  575. return thing && utils.isFunction(thing.append) && thing[Symbol.toStringTag] === 'FormData' && thing[Symbol.iterator];
  576. }
  577. /**
  578. * Convert a data object to FormData
  579. * @param {Object} obj
  580. * @param {?Object} [formData]
  581. * @param {?Object} [options]
  582. * @param {Function} [options.visitor]
  583. * @param {Boolean} [options.metaTokens = true]
  584. * @param {Boolean} [options.dots = false]
  585. * @param {?Boolean} [options.indexes = false]
  586. * @returns {Object}
  587. **/
  588. function toFormData(obj, formData, options) {
  589. if (!utils.isObject(obj)) {
  590. throw new TypeError('target must be an object');
  591. }
  592. // eslint-disable-next-line no-param-reassign
  593. formData = formData || new (FormData$1 || FormData)();
  594. // eslint-disable-next-line no-param-reassign
  595. options = utils.toFlatObject(options, {
  596. metaTokens: true,
  597. dots: false,
  598. indexes: false
  599. }, false, function defined(option, source) {
  600. // eslint-disable-next-line no-eq-null,eqeqeq
  601. return !utils.isUndefined(source[option]);
  602. });
  603. var metaTokens = options.metaTokens;
  604. // eslint-disable-next-line no-use-before-define
  605. var visitor = options.visitor || defaultVisitor;
  606. var dots = options.dots;
  607. var indexes = options.indexes;
  608. var _Blob = options.Blob || typeof Blob !== 'undefined' && Blob;
  609. var useBlob = _Blob && isSpecCompliant(formData);
  610. if (!utils.isFunction(visitor)) {
  611. throw new TypeError('visitor must be a function');
  612. }
  613. function convertValue(value) {
  614. if (value === null) return '';
  615. if (utils.isDate(value)) {
  616. return value.toISOString();
  617. }
  618. if (!useBlob && utils.isBlob(value)) {
  619. throw new AxiosError_1('Blob is not supported. Use a Buffer instead.');
  620. }
  621. if (utils.isArrayBuffer(value) || utils.isTypedArray(value)) {
  622. return useBlob && typeof Blob === 'function' ? new Blob([value]) : Buffer.from(value);
  623. }
  624. return value;
  625. }
  626. /**
  627. *
  628. * @param {*} value
  629. * @param {String|Number} key
  630. * @param {Array<String|Number>} path
  631. * @this {FormData}
  632. * @returns {boolean} return true to visit the each prop of the value recursively
  633. */
  634. function defaultVisitor(value, key, path) {
  635. var arr = value;
  636. if (value && !path && typeof value === 'object') {
  637. if (utils.endsWith(key, '{}')) {
  638. // eslint-disable-next-line no-param-reassign
  639. key = metaTokens ? key : key.slice(0, -2);
  640. // eslint-disable-next-line no-param-reassign
  641. value = JSON.stringify(value);
  642. } else if (
  643. (utils.isArray(value) && isFlatArray(value)) ||
  644. (utils.isFileList(value) || utils.endsWith(key, '[]') && (arr = utils.toArray(value))
  645. )) {
  646. // eslint-disable-next-line no-param-reassign
  647. key = removeBrackets(key);
  648. arr.forEach(function each(el, index) {
  649. !utils.isUndefined(el) && formData.append(
  650. // eslint-disable-next-line no-nested-ternary
  651. indexes === true ? renderKey([key], index, dots) : (indexes === null ? key : key + '[]'),
  652. convertValue(el)
  653. );
  654. });
  655. return false;
  656. }
  657. }
  658. if (isVisitable(value)) {
  659. return true;
  660. }
  661. formData.append(renderKey(path, key, dots), convertValue(value));
  662. return false;
  663. }
  664. var stack = [];
  665. var exposedHelpers = Object.assign(predicates, {
  666. defaultVisitor: defaultVisitor,
  667. convertValue: convertValue,
  668. isVisitable: isVisitable
  669. });
  670. function build(value, path) {
  671. if (utils.isUndefined(value)) return;
  672. if (stack.indexOf(value) !== -1) {
  673. throw Error('Circular reference detected in ' + path.join('.'));
  674. }
  675. stack.push(value);
  676. utils.forEach(value, function each(el, key) {
  677. var result = !utils.isUndefined(el) && visitor.call(
  678. formData, el, utils.isString(key) ? key.trim() : key, path, exposedHelpers
  679. );
  680. if (result === true) {
  681. build(el, path ? path.concat(key) : [key]);
  682. }
  683. });
  684. stack.pop();
  685. }
  686. if (!utils.isObject(obj)) {
  687. throw new TypeError('data must be an object');
  688. }
  689. build(obj);
  690. return formData;
  691. }
  692. var toFormData_1 = toFormData;
  693. function encode$1(str) {
  694. var charMap = {
  695. '!': '%21',
  696. "'": '%27',
  697. '(': '%28',
  698. ')': '%29',
  699. '~': '%7E',
  700. '%20': '+',
  701. '%00': '\x00'
  702. };
  703. return encodeURIComponent(str).replace(/[!'\(\)~]|%20|%00/g, function replacer(match) {
  704. return charMap[match];
  705. });
  706. }
  707. function AxiosURLSearchParams(params, options) {
  708. this._pairs = [];
  709. params && toFormData_1(params, this, options);
  710. }
  711. var prototype = AxiosURLSearchParams.prototype;
  712. prototype.append = function append(name, value) {
  713. this._pairs.push([name, value]);
  714. };
  715. prototype.toString = function toString(encoder) {
  716. var _encode = encoder ? function(value) {
  717. return encoder.call(this, value, encode$1);
  718. } : encode$1;
  719. return this._pairs.map(function each(pair) {
  720. return _encode(pair[0]) + '=' + _encode(pair[1]);
  721. }, '').join('&');
  722. };
  723. var AxiosURLSearchParams_1 = AxiosURLSearchParams;
  724. function encode(val) {
  725. return encodeURIComponent(val).
  726. replace(/%3A/gi, ':').
  727. replace(/%24/g, '$').
  728. replace(/%2C/gi, ',').
  729. replace(/%20/g, '+').
  730. replace(/%5B/gi, '[').
  731. replace(/%5D/gi, ']');
  732. }
  733. /**
  734. * Build a URL by appending params to the end
  735. *
  736. * @param {string} url The base of the url (e.g., http://www.google.com)
  737. * @param {object} [params] The params to be appended
  738. * @param {?object} options
  739. * @returns {string} The formatted url
  740. */
  741. var buildURL = function buildURL(url, params, options) {
  742. /*eslint no-param-reassign:0*/
  743. if (!params) {
  744. return url;
  745. }
  746. var hashmarkIndex = url.indexOf('#');
  747. if (hashmarkIndex !== -1) {
  748. url = url.slice(0, hashmarkIndex);
  749. }
  750. var _encode = options && options.encode || encode;
  751. var serializeFn = options && options.serialize;
  752. var serializedParams;
  753. if (serializeFn) {
  754. serializedParams = serializeFn(params, options);
  755. } else {
  756. serializedParams = utils.isURLSearchParams(params) ?
  757. params.toString() :
  758. new AxiosURLSearchParams_1(params, options).toString(_encode);
  759. }
  760. if (serializedParams) {
  761. url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
  762. }
  763. return url;
  764. };
  765. function InterceptorManager() {
  766. this.handlers = [];
  767. }
  768. /**
  769. * Add a new interceptor to the stack
  770. *
  771. * @param {Function} fulfilled The function to handle `then` for a `Promise`
  772. * @param {Function} rejected The function to handle `reject` for a `Promise`
  773. *
  774. * @return {Number} An ID used to remove interceptor later
  775. */
  776. InterceptorManager.prototype.use = function use(fulfilled, rejected, options) {
  777. this.handlers.push({
  778. fulfilled: fulfilled,
  779. rejected: rejected,
  780. synchronous: options ? options.synchronous : false,
  781. runWhen: options ? options.runWhen : null
  782. });
  783. return this.handlers.length - 1;
  784. };
  785. /**
  786. * Remove an interceptor from the stack
  787. *
  788. * @param {Number} id The ID that was returned by `use`
  789. */
  790. InterceptorManager.prototype.eject = function eject(id) {
  791. if (this.handlers[id]) {
  792. this.handlers[id] = null;
  793. }
  794. };
  795. /**
  796. * Clear all interceptors from the stack
  797. */
  798. InterceptorManager.prototype.clear = function clear() {
  799. if (this.handlers) {
  800. this.handlers = [];
  801. }
  802. };
  803. /**
  804. * Iterate over all the registered interceptors
  805. *
  806. * This method is particularly useful for skipping over any
  807. * interceptors that may have become `null` calling `eject`.
  808. *
  809. * @param {Function} fn The function to call for each interceptor
  810. */
  811. InterceptorManager.prototype.forEach = function forEach(fn) {
  812. utils.forEach(this.handlers, function forEachHandler(h) {
  813. if (h !== null) {
  814. fn(h);
  815. }
  816. });
  817. };
  818. var InterceptorManager_1 = InterceptorManager;
  819. var normalizeHeaderName = function normalizeHeaderName(headers, normalizedName) {
  820. utils.forEach(headers, function processHeader(value, name) {
  821. if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) {
  822. headers[normalizedName] = value;
  823. delete headers[name];
  824. }
  825. });
  826. };
  827. var transitional = {
  828. silentJSONParsing: true,
  829. forcedJSONParsing: true,
  830. clarifyTimeoutError: false
  831. };
  832. var URLSearchParams_1 = typeof URLSearchParams !== 'undefined' ? URLSearchParams : AxiosURLSearchParams_1;
  833. var FormData_1 = FormData;
  834. var browser = {
  835. isBrowser: true,
  836. classes: {
  837. URLSearchParams: URLSearchParams_1,
  838. FormData: FormData_1,
  839. Blob: Blob
  840. },
  841. protocols: ['http', 'https', 'file', 'blob', 'url', 'data']
  842. };
  843. var platform = browser;
  844. var toURLEncodedForm = function toURLEncodedForm(data, options) {
  845. return toFormData_1(data, new platform.classes.URLSearchParams(), Object.assign({
  846. visitor: function(value, key, path, helpers) {
  847. if (platform.isNode && utils.isBuffer(value)) {
  848. this.append(key, value.toString('base64'));
  849. return false;
  850. }
  851. return helpers.defaultVisitor.apply(this, arguments);
  852. }
  853. }, options));
  854. };
  855. function parsePropPath(name) {
  856. // foo[x][y][z]
  857. // foo.x.y.z
  858. // foo-x-y-z
  859. // foo x y z
  860. return utils.matchAll(/\w+|\[(\w*)]/g, name).map(function(match) {
  861. return match[0] === '[]' ? '' : match[1] || match[0];
  862. });
  863. }
  864. function arrayToObject(arr) {
  865. var obj = {};
  866. var keys = Object.keys(arr);
  867. var i;
  868. var len = keys.length;
  869. var key;
  870. for (i = 0; i < len; i++) {
  871. key = keys[i];
  872. obj[key] = arr[key];
  873. }
  874. return obj;
  875. }
  876. function formDataToJSON(formData) {
  877. function buildPath(path, value, target, index) {
  878. var name = path[index++];
  879. var isNumericKey = Number.isFinite(+name);
  880. var isLast = index >= path.length;
  881. name = !name && utils.isArray(target) ? target.length : name;
  882. if (isLast) {
  883. if (utils.hasOwnProperty(target, name)) {
  884. target[name] = [target[name], value];
  885. } else {
  886. target[name] = value;
  887. }
  888. return !isNumericKey;
  889. }
  890. if (!target[name] || !utils.isObject(target[name])) {
  891. target[name] = [];
  892. }
  893. var result = buildPath(path, value, target[name], index);
  894. if (result && utils.isArray(target[name])) {
  895. target[name] = arrayToObject(target[name]);
  896. }
  897. return !isNumericKey;
  898. }
  899. if (utils.isFormData(formData) && utils.isFunction(formData.entries)) {
  900. var obj = {};
  901. utils.forEachEntry(formData, function(name, value) {
  902. buildPath(parsePropPath(name), value, obj, 0);
  903. });
  904. return obj;
  905. }
  906. return null;
  907. }
  908. var formDataToJSON_1 = formDataToJSON;
  909. /**
  910. * Resolve or reject a Promise based on response status.
  911. *
  912. * @param {Function} resolve A function that resolves the promise.
  913. * @param {Function} reject A function that rejects the promise.
  914. * @param {object} response The response.
  915. */
  916. var settle = function settle(resolve, reject, response) {
  917. var validateStatus = response.config.validateStatus;
  918. if (!response.status || !validateStatus || validateStatus(response.status)) {
  919. resolve(response);
  920. } else {
  921. reject(new AxiosError_1(
  922. 'Request failed with status code ' + response.status,
  923. [AxiosError_1.ERR_BAD_REQUEST, AxiosError_1.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4],
  924. response.config,
  925. response.request,
  926. response
  927. ));
  928. }
  929. };
  930. var cookies = (
  931. utils.isStandardBrowserEnv() ?
  932. // Standard browser envs support document.cookie
  933. (function standardBrowserEnv() {
  934. return {
  935. write: function write(name, value, expires, path, domain, secure) {
  936. var cookie = [];
  937. cookie.push(name + '=' + encodeURIComponent(value));
  938. if (utils.isNumber(expires)) {
  939. cookie.push('expires=' + new Date(expires).toGMTString());
  940. }
  941. if (utils.isString(path)) {
  942. cookie.push('path=' + path);
  943. }
  944. if (utils.isString(domain)) {
  945. cookie.push('domain=' + domain);
  946. }
  947. if (secure === true) {
  948. cookie.push('secure');
  949. }
  950. document.cookie = cookie.join('; ');
  951. },
  952. read: function read(name) {
  953. var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
  954. return (match ? decodeURIComponent(match[3]) : null);
  955. },
  956. remove: function remove(name) {
  957. this.write(name, '', Date.now() - 86400000);
  958. }
  959. };
  960. })() :
  961. // Non standard browser env (web workers, react-native) lack needed support.
  962. (function nonStandardBrowserEnv() {
  963. return {
  964. write: function write() {},
  965. read: function read() { return null; },
  966. remove: function remove() {}
  967. };
  968. })()
  969. );
  970. /**
  971. * Determines whether the specified URL is absolute
  972. *
  973. * @param {string} url The URL to test
  974. * @returns {boolean} True if the specified URL is absolute, otherwise false
  975. */
  976. var isAbsoluteURL = function isAbsoluteURL(url) {
  977. // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
  978. // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
  979. // by any combination of letters, digits, plus, period, or hyphen.
  980. return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
  981. };
  982. /**
  983. * Creates a new URL by combining the specified URLs
  984. *
  985. * @param {string} baseURL The base URL
  986. * @param {string} relativeURL The relative URL
  987. * @returns {string} The combined URL
  988. */
  989. var combineURLs = function combineURLs(baseURL, relativeURL) {
  990. return relativeURL
  991. ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '')
  992. : baseURL;
  993. };
  994. /**
  995. * Creates a new URL by combining the baseURL with the requestedURL,
  996. * only when the requestedURL is not already an absolute URL.
  997. * If the requestURL is absolute, this function returns the requestedURL untouched.
  998. *
  999. * @param {string} baseURL The base URL
  1000. * @param {string} requestedURL Absolute or relative URL to combine
  1001. * @returns {string} The combined full path
  1002. */
  1003. var buildFullPath = function buildFullPath(baseURL, requestedURL) {
  1004. if (baseURL && !isAbsoluteURL(requestedURL)) {
  1005. return combineURLs(baseURL, requestedURL);
  1006. }
  1007. return requestedURL;
  1008. };
  1009. // Headers whose duplicates are ignored by node
  1010. // c.f. https://nodejs.org/api/http.html#http_message_headers
  1011. var ignoreDuplicateOf = [
  1012. 'age', 'authorization', 'content-length', 'content-type', 'etag',
  1013. 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',
  1014. 'last-modified', 'location', 'max-forwards', 'proxy-authorization',
  1015. 'referer', 'retry-after', 'user-agent'
  1016. ];
  1017. /**
  1018. * Parse headers into an object
  1019. *
  1020. * ```
  1021. * Date: Wed, 27 Aug 2014 08:58:49 GMT
  1022. * Content-Type: application/json
  1023. * Connection: keep-alive
  1024. * Transfer-Encoding: chunked
  1025. * ```
  1026. *
  1027. * @param {String} headers Headers needing to be parsed
  1028. * @returns {Object} Headers parsed into an object
  1029. */
  1030. var parseHeaders = function parseHeaders(headers) {
  1031. var parsed = {};
  1032. var key;
  1033. var val;
  1034. var i;
  1035. if (!headers) { return parsed; }
  1036. utils.forEach(headers.split('\n'), function parser(line) {
  1037. i = line.indexOf(':');
  1038. key = utils.trim(line.slice(0, i)).toLowerCase();
  1039. val = utils.trim(line.slice(i + 1));
  1040. if (key) {
  1041. if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) {
  1042. return;
  1043. }
  1044. if (key === 'set-cookie') {
  1045. parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]);
  1046. } else {
  1047. parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
  1048. }
  1049. }
  1050. });
  1051. return parsed;
  1052. };
  1053. var isURLSameOrigin = (
  1054. utils.isStandardBrowserEnv() ?
  1055. // Standard browser envs have full support of the APIs needed to test
  1056. // whether the request URL is of the same origin as current location.
  1057. (function standardBrowserEnv() {
  1058. var msie = /(msie|trident)/i.test(navigator.userAgent);
  1059. var urlParsingNode = document.createElement('a');
  1060. var originURL;
  1061. /**
  1062. * Parse a URL to discover it's components
  1063. *
  1064. * @param {String} url The URL to be parsed
  1065. * @returns {Object}
  1066. */
  1067. function resolveURL(url) {
  1068. var href = url;
  1069. if (msie) {
  1070. // IE needs attribute set twice to normalize properties
  1071. urlParsingNode.setAttribute('href', href);
  1072. href = urlParsingNode.href;
  1073. }
  1074. urlParsingNode.setAttribute('href', href);
  1075. // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
  1076. return {
  1077. href: urlParsingNode.href,
  1078. protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
  1079. host: urlParsingNode.host,
  1080. search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
  1081. hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
  1082. hostname: urlParsingNode.hostname,
  1083. port: urlParsingNode.port,
  1084. pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
  1085. urlParsingNode.pathname :
  1086. '/' + urlParsingNode.pathname
  1087. };
  1088. }
  1089. originURL = resolveURL(window.location.href);
  1090. /**
  1091. * Determine if a URL shares the same origin as the current location
  1092. *
  1093. * @param {String} requestURL The URL to test
  1094. * @returns {boolean} True if URL shares the same origin, otherwise false
  1095. */
  1096. return function isURLSameOrigin(requestURL) {
  1097. var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
  1098. return (parsed.protocol === originURL.protocol &&
  1099. parsed.host === originURL.host);
  1100. };
  1101. })() :
  1102. // Non standard browser envs (web workers, react-native) lack needed support.
  1103. (function nonStandardBrowserEnv() {
  1104. return function isURLSameOrigin() {
  1105. return true;
  1106. };
  1107. })()
  1108. );
  1109. /**
  1110. * A `CanceledError` is an object that is thrown when an operation is canceled.
  1111. *
  1112. * @class
  1113. * @param {string=} message The message.
  1114. * @param {Object=} config The config.
  1115. * @param {Object=} request The request.
  1116. */
  1117. function CanceledError(message, config, request) {
  1118. // eslint-disable-next-line no-eq-null,eqeqeq
  1119. AxiosError_1.call(this, message == null ? 'canceled' : message, AxiosError_1.ERR_CANCELED, config, request);
  1120. this.name = 'CanceledError';
  1121. }
  1122. utils.inherits(CanceledError, AxiosError_1, {
  1123. __CANCEL__: true
  1124. });
  1125. var CanceledError_1 = CanceledError;
  1126. var parseProtocol = function parseProtocol(url) {
  1127. var match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
  1128. return match && match[1] || '';
  1129. };
  1130. var xhr = function xhrAdapter(config) {
  1131. return new Promise(function dispatchXhrRequest(resolve, reject) {
  1132. var requestData = config.data;
  1133. var requestHeaders = config.headers;
  1134. var responseType = config.responseType;
  1135. var withXSRFToken = config.withXSRFToken;
  1136. var onCanceled;
  1137. function done() {
  1138. if (config.cancelToken) {
  1139. config.cancelToken.unsubscribe(onCanceled);
  1140. }
  1141. if (config.signal) {
  1142. config.signal.removeEventListener('abort', onCanceled);
  1143. }
  1144. }
  1145. if (utils.isFormData(requestData) && utils.isStandardBrowserEnv()) {
  1146. delete requestHeaders['Content-Type']; // Let the browser set it
  1147. }
  1148. var request = new XMLHttpRequest();
  1149. // HTTP basic authentication
  1150. if (config.auth) {
  1151. var username = config.auth.username || '';
  1152. var password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : '';
  1153. requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password);
  1154. }
  1155. var fullPath = buildFullPath(config.baseURL, config.url);
  1156. request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true);
  1157. // Set the request timeout in MS
  1158. request.timeout = config.timeout;
  1159. function onloadend() {
  1160. if (!request) {
  1161. return;
  1162. }
  1163. // Prepare the response
  1164. var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null;
  1165. var responseData = !responseType || responseType === 'text' || responseType === 'json' ?
  1166. request.responseText : request.response;
  1167. var response = {
  1168. data: responseData,
  1169. status: request.status,
  1170. statusText: request.statusText,
  1171. headers: responseHeaders,
  1172. config: config,
  1173. request: request
  1174. };
  1175. settle(function _resolve(value) {
  1176. resolve(value);
  1177. done();
  1178. }, function _reject(err) {
  1179. reject(err);
  1180. done();
  1181. }, response);
  1182. // Clean up request
  1183. request = null;
  1184. }
  1185. if ('onloadend' in request) {
  1186. // Use onloadend if available
  1187. request.onloadend = onloadend;
  1188. } else {
  1189. // Listen for ready state to emulate onloadend
  1190. request.onreadystatechange = function handleLoad() {
  1191. if (!request || request.readyState !== 4) {
  1192. return;
  1193. }
  1194. // The request errored out and we didn't get a response, this will be
  1195. // handled by onerror instead
  1196. // With one exception: request that using file: protocol, most browsers
  1197. // will return status as 0 even though it's a successful request
  1198. if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
  1199. return;
  1200. }
  1201. // readystate handler is calling before onerror or ontimeout handlers,
  1202. // so we should call onloadend on the next 'tick'
  1203. setTimeout(onloadend);
  1204. };
  1205. }
  1206. // Handle browser request cancellation (as opposed to a manual cancellation)
  1207. request.onabort = function handleAbort() {
  1208. if (!request) {
  1209. return;
  1210. }
  1211. reject(new AxiosError_1('Request aborted', AxiosError_1.ECONNABORTED, config, request));
  1212. // Clean up request
  1213. request = null;
  1214. };
  1215. // Handle low level network errors
  1216. request.onerror = function handleError() {
  1217. // Real errors are hidden from us by the browser
  1218. // onerror should only fire if it's a network error
  1219. reject(new AxiosError_1('Network Error', AxiosError_1.ERR_NETWORK, config, request));
  1220. // Clean up request
  1221. request = null;
  1222. };
  1223. // Handle timeout
  1224. request.ontimeout = function handleTimeout() {
  1225. var timeoutErrorMessage = config.timeout ? 'timeout of ' + config.timeout + 'ms exceeded' : 'timeout exceeded';
  1226. var transitional$1 = config.transitional || transitional;
  1227. if (config.timeoutErrorMessage) {
  1228. timeoutErrorMessage = config.timeoutErrorMessage;
  1229. }
  1230. reject(new AxiosError_1(
  1231. timeoutErrorMessage,
  1232. transitional$1.clarifyTimeoutError ? AxiosError_1.ETIMEDOUT : AxiosError_1.ECONNABORTED,
  1233. config,
  1234. request));
  1235. // Clean up request
  1236. request = null;
  1237. };
  1238. // Add xsrf header
  1239. // This is only done if running in a standard browser environment.
  1240. // Specifically not if we're in a web worker, or react-native.
  1241. if (utils.isStandardBrowserEnv()) {
  1242. // Add xsrf header
  1243. withXSRFToken && utils.isFunction(withXSRFToken) && (withXSRFToken = withXSRFToken(config));
  1244. if (withXSRFToken || (withXSRFToken !== false && isURLSameOrigin(fullPath))) {
  1245. // Add xsrf header
  1246. var xsrfValue = config.xsrfHeaderName && config.xsrfCookieName && cookies.read(config.xsrfCookieName);
  1247. if (xsrfValue) {
  1248. requestHeaders[config.xsrfHeaderName] = xsrfValue;
  1249. }
  1250. }
  1251. }
  1252. // Add headers to the request
  1253. if ('setRequestHeader' in request) {
  1254. utils.forEach(requestHeaders, function setRequestHeader(val, key) {
  1255. if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') {
  1256. // Remove Content-Type if data is undefined
  1257. delete requestHeaders[key];
  1258. } else {
  1259. // Otherwise add header to the request
  1260. request.setRequestHeader(key, val);
  1261. }
  1262. });
  1263. }
  1264. // Add withCredentials to request if needed
  1265. if (!utils.isUndefined(config.withCredentials)) {
  1266. request.withCredentials = !!config.withCredentials;
  1267. }
  1268. // Add responseType to request if needed
  1269. if (responseType && responseType !== 'json') {
  1270. request.responseType = config.responseType;
  1271. }
  1272. // Handle progress if needed
  1273. if (typeof config.onDownloadProgress === 'function') {
  1274. request.addEventListener('progress', config.onDownloadProgress);
  1275. }
  1276. // Not all browsers support upload events
  1277. if (typeof config.onUploadProgress === 'function' && request.upload) {
  1278. request.upload.addEventListener('progress', config.onUploadProgress);
  1279. }
  1280. if (config.cancelToken || config.signal) {
  1281. // Handle cancellation
  1282. // eslint-disable-next-line func-names
  1283. onCanceled = function(cancel) {
  1284. if (!request) {
  1285. return;
  1286. }
  1287. reject(!cancel || cancel.type ? new CanceledError_1(null, config, request) : cancel);
  1288. request.abort();
  1289. request = null;
  1290. };
  1291. config.cancelToken && config.cancelToken.subscribe(onCanceled);
  1292. if (config.signal) {
  1293. config.signal.aborted ? onCanceled() : config.signal.addEventListener('abort', onCanceled);
  1294. }
  1295. }
  1296. // false, 0 (zero number), and '' (empty string) are valid JSON values
  1297. if (!requestData && requestData !== false && requestData !== 0 && requestData !== '') {
  1298. requestData = null;
  1299. }
  1300. var protocol = parseProtocol(fullPath);
  1301. if (protocol && platform.protocols.indexOf(protocol) === -1) {
  1302. reject(new AxiosError_1('Unsupported protocol ' + protocol + ':', AxiosError_1.ERR_BAD_REQUEST, config));
  1303. return;
  1304. }
  1305. // Send the request
  1306. request.send(requestData);
  1307. });
  1308. };
  1309. var DEFAULT_CONTENT_TYPE = {
  1310. 'Content-Type': 'application/x-www-form-urlencoded'
  1311. };
  1312. function setContentTypeIfUnset(headers, value) {
  1313. if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) {
  1314. headers['Content-Type'] = value;
  1315. }
  1316. }
  1317. function getDefaultAdapter() {
  1318. var adapter;
  1319. if (typeof XMLHttpRequest !== 'undefined') {
  1320. // For browsers use XHR adapter
  1321. adapter = xhr;
  1322. } else if (typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]') {
  1323. // For node use HTTP adapter
  1324. adapter = xhr;
  1325. }
  1326. return adapter;
  1327. }
  1328. function stringifySafely(rawValue, parser, encoder) {
  1329. if (utils.isString(rawValue)) {
  1330. try {
  1331. (parser || JSON.parse)(rawValue);
  1332. return utils.trim(rawValue);
  1333. } catch (e) {
  1334. if (e.name !== 'SyntaxError') {
  1335. throw e;
  1336. }
  1337. }
  1338. }
  1339. return (encoder || JSON.stringify)(rawValue);
  1340. }
  1341. var defaults = {
  1342. transitional: transitional,
  1343. adapter: getDefaultAdapter(),
  1344. transformRequest: [function transformRequest(data, headers) {
  1345. normalizeHeaderName(headers, 'Accept');
  1346. normalizeHeaderName(headers, 'Content-Type');
  1347. var contentType = headers && headers['Content-Type'] || '';
  1348. var hasJSONContentType = contentType.indexOf('application/json') > -1;
  1349. var isObjectPayload = utils.isObject(data);
  1350. if (isObjectPayload && utils.isHTMLForm(data)) {
  1351. data = new FormData(data);
  1352. }
  1353. var isFormData = utils.isFormData(data);
  1354. if (isFormData) {
  1355. return hasJSONContentType ? JSON.stringify(formDataToJSON_1(data)) : data;
  1356. }
  1357. if (utils.isArrayBuffer(data) ||
  1358. utils.isBuffer(data) ||
  1359. utils.isStream(data) ||
  1360. utils.isFile(data) ||
  1361. utils.isBlob(data)
  1362. ) {
  1363. return data;
  1364. }
  1365. if (utils.isArrayBufferView(data)) {
  1366. return data.buffer;
  1367. }
  1368. if (utils.isURLSearchParams(data)) {
  1369. setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8');
  1370. return data.toString();
  1371. }
  1372. var isFileList;
  1373. if (isObjectPayload) {
  1374. if (contentType.indexOf('application/x-www-form-urlencoded') !== -1) {
  1375. return toURLEncodedForm(data, this.formSerializer).toString();
  1376. }
  1377. if ((isFileList = utils.isFileList(data)) || contentType.indexOf('multipart/form-data') > -1) {
  1378. var _FormData = this.env && this.env.FormData;
  1379. return toFormData_1(
  1380. isFileList ? {'files[]': data} : data,
  1381. _FormData && new _FormData(),
  1382. this.formSerializer
  1383. );
  1384. }
  1385. }
  1386. if (isObjectPayload || hasJSONContentType ) {
  1387. setContentTypeIfUnset(headers, 'application/json');
  1388. return stringifySafely(data);
  1389. }
  1390. return data;
  1391. }],
  1392. transformResponse: [function transformResponse(data) {
  1393. var transitional = this.transitional || defaults.transitional;
  1394. var forcedJSONParsing = transitional && transitional.forcedJSONParsing;
  1395. var JSONRequested = this.responseType === 'json';
  1396. if (data && utils.isString(data) && ((forcedJSONParsing && !this.responseType) || JSONRequested)) {
  1397. var silentJSONParsing = transitional && transitional.silentJSONParsing;
  1398. var strictJSONParsing = !silentJSONParsing && JSONRequested;
  1399. try {
  1400. return JSON.parse(data);
  1401. } catch (e) {
  1402. if (strictJSONParsing) {
  1403. if (e.name === 'SyntaxError') {
  1404. throw AxiosError_1.from(e, AxiosError_1.ERR_BAD_RESPONSE, this, null, this.response);
  1405. }
  1406. throw e;
  1407. }
  1408. }
  1409. }
  1410. return data;
  1411. }],
  1412. /**
  1413. * A timeout in milliseconds to abort a request. If set to 0 (default) a
  1414. * timeout is not created.
  1415. */
  1416. timeout: 0,
  1417. xsrfCookieName: 'XSRF-TOKEN',
  1418. xsrfHeaderName: 'X-XSRF-TOKEN',
  1419. maxContentLength: -1,
  1420. maxBodyLength: -1,
  1421. env: {
  1422. FormData: platform.classes.FormData,
  1423. Blob: platform.classes.Blob
  1424. },
  1425. validateStatus: function validateStatus(status) {
  1426. return status >= 200 && status < 300;
  1427. },
  1428. headers: {
  1429. common: {
  1430. 'Accept': 'application/json, text/plain, */*'
  1431. }
  1432. }
  1433. };
  1434. utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
  1435. defaults.headers[method] = {};
  1436. });
  1437. utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
  1438. defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
  1439. });
  1440. var defaults_1 = defaults;
  1441. /**
  1442. * Transform the data for a request or a response
  1443. *
  1444. * @param {Object|String} data The data to be transformed
  1445. * @param {Array} headers The headers for the request or response
  1446. * @param {Number} status HTTP status code
  1447. * @param {Array|Function} fns A single function or Array of functions
  1448. * @returns {*} The resulting transformed data
  1449. */
  1450. var transformData = function transformData(data, headers, status, fns) {
  1451. var context = this || defaults_1;
  1452. /*eslint no-param-reassign:0*/
  1453. utils.forEach(fns, function transform(fn) {
  1454. data = fn.call(context, data, headers, status);
  1455. });
  1456. return data;
  1457. };
  1458. var isCancel = function isCancel(value) {
  1459. return !!(value && value.__CANCEL__);
  1460. };
  1461. /**
  1462. * Throws a `CanceledError` if cancellation has been requested.
  1463. */
  1464. function throwIfCancellationRequested(config) {
  1465. if (config.cancelToken) {
  1466. config.cancelToken.throwIfRequested();
  1467. }
  1468. if (config.signal && config.signal.aborted) {
  1469. throw new CanceledError_1();
  1470. }
  1471. }
  1472. /**
  1473. * Dispatch a request to the server using the configured adapter.
  1474. *
  1475. * @param {object} config The config that is to be used for the request
  1476. * @returns {Promise} The Promise to be fulfilled
  1477. */
  1478. var dispatchRequest = function dispatchRequest(config) {
  1479. throwIfCancellationRequested(config);
  1480. // Ensure headers exist
  1481. config.headers = config.headers || {};
  1482. // Transform request data
  1483. config.data = transformData.call(
  1484. config,
  1485. config.data,
  1486. config.headers,
  1487. null,
  1488. config.transformRequest
  1489. );
  1490. normalizeHeaderName(config.headers, 'Accept');
  1491. normalizeHeaderName(config.headers, 'Content-Type');
  1492. // Flatten headers
  1493. config.headers = utils.merge(
  1494. config.headers.common || {},
  1495. config.headers[config.method] || {},
  1496. config.headers
  1497. );
  1498. utils.forEach(
  1499. ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
  1500. function cleanHeaderConfig(method) {
  1501. delete config.headers[method];
  1502. }
  1503. );
  1504. var adapter = config.adapter || defaults_1.adapter;
  1505. return adapter(config).then(function onAdapterResolution(response) {
  1506. throwIfCancellationRequested(config);
  1507. // Transform response data
  1508. response.data = transformData.call(
  1509. config,
  1510. response.data,
  1511. response.headers,
  1512. response.status,
  1513. config.transformResponse
  1514. );
  1515. return response;
  1516. }, function onAdapterRejection(reason) {
  1517. if (!isCancel(reason)) {
  1518. throwIfCancellationRequested(config);
  1519. // Transform response data
  1520. if (reason && reason.response) {
  1521. reason.response.data = transformData.call(
  1522. config,
  1523. reason.response.data,
  1524. reason.response.headers,
  1525. reason.response.status,
  1526. config.transformResponse
  1527. );
  1528. }
  1529. }
  1530. return Promise.reject(reason);
  1531. });
  1532. };
  1533. /**
  1534. * Config-specific merge-function which creates a new config-object
  1535. * by merging two configuration objects together.
  1536. *
  1537. * @param {Object} config1
  1538. * @param {Object} config2
  1539. * @returns {Object} New object resulting from merging config2 to config1
  1540. */
  1541. var mergeConfig = function mergeConfig(config1, config2) {
  1542. // eslint-disable-next-line no-param-reassign
  1543. config2 = config2 || {};
  1544. var config = {};
  1545. function getMergedValue(target, source) {
  1546. if (utils.isPlainObject(target) && utils.isPlainObject(source)) {
  1547. return utils.merge(target, source);
  1548. } else if (utils.isEmptyObject(source)) {
  1549. return utils.merge({}, target);
  1550. } else if (utils.isPlainObject(source)) {
  1551. return utils.merge({}, source);
  1552. } else if (utils.isArray(source)) {
  1553. return source.slice();
  1554. }
  1555. return source;
  1556. }
  1557. // eslint-disable-next-line consistent-return
  1558. function mergeDeepProperties(prop) {
  1559. if (!utils.isUndefined(config2[prop])) {
  1560. return getMergedValue(config1[prop], config2[prop]);
  1561. } else if (!utils.isUndefined(config1[prop])) {
  1562. return getMergedValue(undefined, config1[prop]);
  1563. }
  1564. }
  1565. // eslint-disable-next-line consistent-return
  1566. function valueFromConfig2(prop) {
  1567. if (!utils.isUndefined(config2[prop])) {
  1568. return getMergedValue(undefined, config2[prop]);
  1569. }
  1570. }
  1571. // eslint-disable-next-line consistent-return
  1572. function defaultToConfig2(prop) {
  1573. if (!utils.isUndefined(config2[prop])) {
  1574. return getMergedValue(undefined, config2[prop]);
  1575. } else if (!utils.isUndefined(config1[prop])) {
  1576. return getMergedValue(undefined, config1[prop]);
  1577. }
  1578. }
  1579. // eslint-disable-next-line consistent-return
  1580. function mergeDirectKeys(prop) {
  1581. if (prop in config2) {
  1582. return getMergedValue(config1[prop], config2[prop]);
  1583. } else if (prop in config1) {
  1584. return getMergedValue(undefined, config1[prop]);
  1585. }
  1586. }
  1587. var mergeMap = {
  1588. 'url': valueFromConfig2,
  1589. 'method': valueFromConfig2,
  1590. 'data': valueFromConfig2,
  1591. 'baseURL': defaultToConfig2,
  1592. 'transformRequest': defaultToConfig2,
  1593. 'transformResponse': defaultToConfig2,
  1594. 'paramsSerializer': defaultToConfig2,
  1595. 'timeout': defaultToConfig2,
  1596. 'timeoutMessage': defaultToConfig2,
  1597. 'withCredentials': defaultToConfig2,
  1598. 'withXSRFToken': defaultToConfig2,
  1599. 'adapter': defaultToConfig2,
  1600. 'responseType': defaultToConfig2,
  1601. 'xsrfCookieName': defaultToConfig2,
  1602. 'xsrfHeaderName': defaultToConfig2,
  1603. 'onUploadProgress': defaultToConfig2,
  1604. 'onDownloadProgress': defaultToConfig2,
  1605. 'decompress': defaultToConfig2,
  1606. 'maxContentLength': defaultToConfig2,
  1607. 'maxBodyLength': defaultToConfig2,
  1608. 'beforeRedirect': defaultToConfig2,
  1609. 'transport': defaultToConfig2,
  1610. 'httpAgent': defaultToConfig2,
  1611. 'httpsAgent': defaultToConfig2,
  1612. 'cancelToken': defaultToConfig2,
  1613. 'socketPath': defaultToConfig2,
  1614. 'responseEncoding': defaultToConfig2,
  1615. 'validateStatus': mergeDirectKeys
  1616. };
  1617. utils.forEach(Object.keys(config1).concat(Object.keys(config2)), function computeConfigValue(prop) {
  1618. var merge = mergeMap[prop] || mergeDeepProperties;
  1619. var configValue = merge(prop);
  1620. (utils.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
  1621. });
  1622. return config;
  1623. };
  1624. var data = {
  1625. "version": "0.28.1"
  1626. };
  1627. var VERSION = data.version;
  1628. var validators$1 = {};
  1629. // eslint-disable-next-line func-names
  1630. ['object', 'boolean', 'number', 'function', 'string', 'symbol'].forEach(function(type, i) {
  1631. validators$1[type] = function validator(thing) {
  1632. return typeof thing === type || 'a' + (i < 1 ? 'n ' : ' ') + type;
  1633. };
  1634. });
  1635. var deprecatedWarnings = {};
  1636. /**
  1637. * Transitional option validator
  1638. * @param {function|boolean?} validator - set to false if the transitional option has been removed
  1639. * @param {string?} version - deprecated version / removed since version
  1640. * @param {string?} message - some message with additional info
  1641. * @returns {function}
  1642. */
  1643. validators$1.transitional = function transitional(validator, version, message) {
  1644. function formatMessage(opt, desc) {
  1645. return '[Axios v' + VERSION + '] Transitional option \'' + opt + '\'' + desc + (message ? '. ' + message : '');
  1646. }
  1647. // eslint-disable-next-line func-names
  1648. return function(value, opt, opts) {
  1649. if (validator === false) {
  1650. throw new AxiosError_1(
  1651. formatMessage(opt, ' has been removed' + (version ? ' in ' + version : '')),
  1652. AxiosError_1.ERR_DEPRECATED
  1653. );
  1654. }
  1655. if (version && !deprecatedWarnings[opt]) {
  1656. deprecatedWarnings[opt] = true;
  1657. // eslint-disable-next-line no-console
  1658. console.warn(
  1659. formatMessage(
  1660. opt,
  1661. ' has been deprecated since v' + version + ' and will be removed in the near future'
  1662. )
  1663. );
  1664. }
  1665. return validator ? validator(value, opt, opts) : true;
  1666. };
  1667. };
  1668. /**
  1669. * Assert object's properties type
  1670. * @param {object} options
  1671. * @param {object} schema
  1672. * @param {boolean?} allowUnknown
  1673. */
  1674. function assertOptions(options, schema, allowUnknown) {
  1675. if (typeof options !== 'object') {
  1676. throw new AxiosError_1('options must be an object', AxiosError_1.ERR_BAD_OPTION_VALUE);
  1677. }
  1678. var keys = Object.keys(options);
  1679. var i = keys.length;
  1680. while (i-- > 0) {
  1681. var opt = keys[i];
  1682. var validator = schema[opt];
  1683. if (validator) {
  1684. var value = options[opt];
  1685. var result = value === undefined || validator(value, opt, options);
  1686. if (result !== true) {
  1687. throw new AxiosError_1('option ' + opt + ' must be ' + result, AxiosError_1.ERR_BAD_OPTION_VALUE);
  1688. }
  1689. continue;
  1690. }
  1691. if (allowUnknown !== true) {
  1692. throw new AxiosError_1('Unknown option ' + opt, AxiosError_1.ERR_BAD_OPTION);
  1693. }
  1694. }
  1695. }
  1696. var validator = {
  1697. assertOptions: assertOptions,
  1698. validators: validators$1
  1699. };
  1700. var validators = validator.validators;
  1701. /**
  1702. * Create a new instance of Axios
  1703. *
  1704. * @param {Object} instanceConfig The default config for the instance
  1705. */
  1706. function Axios(instanceConfig) {
  1707. this.defaults = instanceConfig;
  1708. this.interceptors = {
  1709. request: new InterceptorManager_1(),
  1710. response: new InterceptorManager_1()
  1711. };
  1712. }
  1713. /**
  1714. * Dispatch a request
  1715. *
  1716. * @param {String|Object} configOrUrl The config specific for this request (merged with this.defaults)
  1717. * @param {?Object} config
  1718. */
  1719. Axios.prototype.request = function request(configOrUrl, config) {
  1720. /*eslint no-param-reassign:0*/
  1721. // Allow for axios('example/url'[, config]) a la fetch API
  1722. if (typeof configOrUrl === 'string') {
  1723. config = config || {};
  1724. config.url = configOrUrl;
  1725. } else {
  1726. config = configOrUrl || {};
  1727. }
  1728. config = mergeConfig(this.defaults, config);
  1729. // Set config.method
  1730. if (config.method) {
  1731. config.method = config.method.toLowerCase();
  1732. } else if (this.defaults.method) {
  1733. config.method = this.defaults.method.toLowerCase();
  1734. } else {
  1735. config.method = 'get';
  1736. }
  1737. var transitional = config.transitional;
  1738. if (transitional !== undefined) {
  1739. validator.assertOptions(transitional, {
  1740. silentJSONParsing: validators.transitional(validators.boolean),
  1741. forcedJSONParsing: validators.transitional(validators.boolean),
  1742. clarifyTimeoutError: validators.transitional(validators.boolean)
  1743. }, false);
  1744. }
  1745. var paramsSerializer = config.paramsSerializer;
  1746. if (paramsSerializer !== undefined) {
  1747. validator.assertOptions(paramsSerializer, {
  1748. encode: validators.function,
  1749. serialize: validators.function
  1750. }, true);
  1751. }
  1752. utils.isFunction(paramsSerializer) && (config.paramsSerializer = {serialize: paramsSerializer});
  1753. // filter out skipped interceptors
  1754. var requestInterceptorChain = [];
  1755. var synchronousRequestInterceptors = true;
  1756. this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
  1757. if (typeof interceptor.runWhen === 'function' && interceptor.runWhen(config) === false) {
  1758. return;
  1759. }
  1760. synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
  1761. requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
  1762. });
  1763. var responseInterceptorChain = [];
  1764. this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
  1765. responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
  1766. });
  1767. var promise;
  1768. if (!synchronousRequestInterceptors) {
  1769. var chain = [dispatchRequest, undefined];
  1770. Array.prototype.unshift.apply(chain, requestInterceptorChain);
  1771. chain = chain.concat(responseInterceptorChain);
  1772. promise = Promise.resolve(config);
  1773. while (chain.length) {
  1774. promise = promise.then(chain.shift(), chain.shift());
  1775. }
  1776. return promise;
  1777. }
  1778. var newConfig = config;
  1779. while (requestInterceptorChain.length) {
  1780. var onFulfilled = requestInterceptorChain.shift();
  1781. var onRejected = requestInterceptorChain.shift();
  1782. try {
  1783. newConfig = onFulfilled(newConfig);
  1784. } catch (error) {
  1785. onRejected(error);
  1786. break;
  1787. }
  1788. }
  1789. try {
  1790. promise = dispatchRequest(newConfig);
  1791. } catch (error) {
  1792. return Promise.reject(error);
  1793. }
  1794. while (responseInterceptorChain.length) {
  1795. promise = promise.then(responseInterceptorChain.shift(), responseInterceptorChain.shift());
  1796. }
  1797. return promise;
  1798. };
  1799. Axios.prototype.getUri = function getUri(config) {
  1800. config = mergeConfig(this.defaults, config);
  1801. var fullPath = buildFullPath(config.baseURL, config.url);
  1802. return buildURL(fullPath, config.params, config.paramsSerializer);
  1803. };
  1804. // Provide aliases for supported request methods
  1805. utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
  1806. /*eslint func-names:0*/
  1807. Axios.prototype[method] = function(url, config) {
  1808. return this.request(mergeConfig(config || {}, {
  1809. method: method,
  1810. url: url,
  1811. data: (config || {}).data
  1812. }));
  1813. };
  1814. });
  1815. utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
  1816. /*eslint func-names:0*/
  1817. function generateHTTPMethod(isForm) {
  1818. return function httpMethod(url, data, config) {
  1819. return this.request(mergeConfig(config || {}, {
  1820. method: method,
  1821. headers: isForm ? {
  1822. 'Content-Type': 'multipart/form-data'
  1823. } : {},
  1824. url: url,
  1825. data: data
  1826. }));
  1827. };
  1828. }
  1829. Axios.prototype[method] = generateHTTPMethod();
  1830. Axios.prototype[method + 'Form'] = generateHTTPMethod(true);
  1831. });
  1832. var Axios_1 = Axios;
  1833. /**
  1834. * A `CancelToken` is an object that can be used to request cancellation of an operation.
  1835. *
  1836. * @class
  1837. * @param {Function} executor The executor function.
  1838. */
  1839. function CancelToken(executor) {
  1840. if (typeof executor !== 'function') {
  1841. throw new TypeError('executor must be a function.');
  1842. }
  1843. var resolvePromise;
  1844. this.promise = new Promise(function promiseExecutor(resolve) {
  1845. resolvePromise = resolve;
  1846. });
  1847. var token = this;
  1848. // eslint-disable-next-line func-names
  1849. this.promise.then(function(cancel) {
  1850. if (!token._listeners) return;
  1851. var i = token._listeners.length;
  1852. while (i-- > 0) {
  1853. token._listeners[i](cancel);
  1854. }
  1855. token._listeners = null;
  1856. });
  1857. // eslint-disable-next-line func-names
  1858. this.promise.then = function(onfulfilled) {
  1859. var _resolve;
  1860. // eslint-disable-next-line func-names
  1861. var promise = new Promise(function(resolve) {
  1862. token.subscribe(resolve);
  1863. _resolve = resolve;
  1864. }).then(onfulfilled);
  1865. promise.cancel = function reject() {
  1866. token.unsubscribe(_resolve);
  1867. };
  1868. return promise;
  1869. };
  1870. executor(function cancel(message, config, request) {
  1871. if (token.reason) {
  1872. // Cancellation has already been requested
  1873. return;
  1874. }
  1875. token.reason = new CanceledError_1(message, config, request);
  1876. resolvePromise(token.reason);
  1877. });
  1878. }
  1879. /**
  1880. * Throws a `CanceledError` if cancellation has been requested.
  1881. */
  1882. CancelToken.prototype.throwIfRequested = function throwIfRequested() {
  1883. if (this.reason) {
  1884. throw this.reason;
  1885. }
  1886. };
  1887. /**
  1888. * Subscribe to the cancel signal
  1889. */
  1890. CancelToken.prototype.subscribe = function subscribe(listener) {
  1891. if (this.reason) {
  1892. listener(this.reason);
  1893. return;
  1894. }
  1895. if (this._listeners) {
  1896. this._listeners.push(listener);
  1897. } else {
  1898. this._listeners = [listener];
  1899. }
  1900. };
  1901. /**
  1902. * Unsubscribe from the cancel signal
  1903. */
  1904. CancelToken.prototype.unsubscribe = function unsubscribe(listener) {
  1905. if (!this._listeners) {
  1906. return;
  1907. }
  1908. var index = this._listeners.indexOf(listener);
  1909. if (index !== -1) {
  1910. this._listeners.splice(index, 1);
  1911. }
  1912. };
  1913. /**
  1914. * Returns an object that contains a new `CancelToken` and a function that, when called,
  1915. * cancels the `CancelToken`.
  1916. */
  1917. CancelToken.source = function source() {
  1918. var cancel;
  1919. var token = new CancelToken(function executor(c) {
  1920. cancel = c;
  1921. });
  1922. return {
  1923. token: token,
  1924. cancel: cancel
  1925. };
  1926. };
  1927. var CancelToken_1 = CancelToken;
  1928. /**
  1929. * Syntactic sugar for invoking a function and expanding an array for arguments.
  1930. *
  1931. * Common use case would be to use `Function.prototype.apply`.
  1932. *
  1933. * ```js
  1934. * function f(x, y, z) {}
  1935. * var args = [1, 2, 3];
  1936. * f.apply(null, args);
  1937. * ```
  1938. *
  1939. * With `spread` this example can be re-written.
  1940. *
  1941. * ```js
  1942. * spread(function(x, y, z) {})([1, 2, 3]);
  1943. * ```
  1944. *
  1945. * @param {Function} callback
  1946. * @returns {Function}
  1947. */
  1948. var spread = function spread(callback) {
  1949. return function wrap(arr) {
  1950. return callback.apply(null, arr);
  1951. };
  1952. };
  1953. /**
  1954. * Determines whether the payload is an error thrown by Axios
  1955. *
  1956. * @param {*} payload The value to test
  1957. * @returns {boolean} True if the payload is an error thrown by Axios, otherwise false
  1958. */
  1959. var isAxiosError = function isAxiosError(payload) {
  1960. return utils.isObject(payload) && (payload.isAxiosError === true);
  1961. };
  1962. /**
  1963. * Create an instance of Axios
  1964. *
  1965. * @param {Object} defaultConfig The default config for the instance
  1966. * @return {Axios} A new instance of Axios
  1967. */
  1968. function createInstance(defaultConfig) {
  1969. var context = new Axios_1(defaultConfig);
  1970. var instance = bind(Axios_1.prototype.request, context);
  1971. // Copy axios.prototype to instance
  1972. utils.extend(instance, Axios_1.prototype, context);
  1973. // Copy context to instance
  1974. utils.extend(instance, context);
  1975. // Factory for creating new instances
  1976. instance.create = function create(instanceConfig) {
  1977. return createInstance(mergeConfig(defaultConfig, instanceConfig));
  1978. };
  1979. return instance;
  1980. }
  1981. // Create the default instance to be exported
  1982. var axios = createInstance(defaults_1);
  1983. // Expose Axios class to allow class inheritance
  1984. axios.Axios = Axios_1;
  1985. // Expose Cancel & CancelToken
  1986. axios.CanceledError = CanceledError_1;
  1987. axios.CancelToken = CancelToken_1;
  1988. axios.isCancel = isCancel;
  1989. axios.VERSION = data.version;
  1990. axios.toFormData = toFormData_1;
  1991. // Expose AxiosError class
  1992. axios.AxiosError = AxiosError_1;
  1993. // alias for CanceledError for backward compatibility
  1994. axios.Cancel = axios.CanceledError;
  1995. // Expose all/spread
  1996. axios.all = function all(promises) {
  1997. return Promise.all(promises);
  1998. };
  1999. axios.spread = spread;
  2000. // Expose isAxiosError
  2001. axios.isAxiosError = isAxiosError;
  2002. axios.formToJSON = function(thing) {
  2003. return formDataToJSON_1(utils.isHTMLForm(thing) ? new FormData(thing) : thing);
  2004. };
  2005. var axios_1 = axios;
  2006. // Allow use of default import syntax in TypeScript
  2007. var _default = axios;
  2008. axios_1.default = _default;
  2009. export { axios_1 as default };
  2010. //# sourceMappingURL=axios.js.map