@punks/backend-entity-manager 0.0.218 → 0.0.220

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cjs/index.js CHANGED
@@ -18,11 +18,24 @@ var s3RequestPresigner = require('@aws-sdk/s3-request-presigner');
18
18
  var clientSes = require('@aws-sdk/client-ses');
19
19
  var require$$2 = require('fs');
20
20
  var mail = require('@sendgrid/mail');
21
+ var require$$1 = require('http');
22
+ var require$$2$1 = require('https');
23
+ var require$$0 = require('url');
24
+ var require$$3 = require('stream');
25
+ var require$$4 = require('assert');
26
+ var require$$8 = require('zlib');
27
+ var client = require('@sanity/client');
21
28
  var clientSecretsManager = require('@aws-sdk/client-secrets-manager');
22
29
 
23
30
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
24
31
 
25
32
  var require$$2__default = /*#__PURE__*/_interopDefaultLegacy(require$$2);
33
+ var require$$1__default = /*#__PURE__*/_interopDefaultLegacy(require$$1);
34
+ var require$$2__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$2$1);
35
+ var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0);
36
+ var require$$3__default = /*#__PURE__*/_interopDefaultLegacy(require$$3);
37
+ var require$$4__default = /*#__PURE__*/_interopDefaultLegacy(require$$4);
38
+ var require$$8__default = /*#__PURE__*/_interopDefaultLegacy(require$$8);
26
39
 
27
40
  exports.BucketItemType = void 0;
28
41
  (function (BucketItemType) {
@@ -2828,12 +2841,18 @@ class QueryClauseBuilder {
2828
2841
  if (!!filter?.eq) {
2829
2842
  clauses.push(typeorm.Equal(filter.eq));
2830
2843
  }
2844
+ if (!!filter?.ieq) {
2845
+ clauses.push(typeorm.ILike(filter.eq));
2846
+ }
2831
2847
  if (!!filter?.like) {
2832
2848
  clauses.push(typeorm.Like(filter.like.replaceAll("*", "%")));
2833
2849
  }
2834
2850
  if (!!filter?.ne) {
2835
2851
  clauses.push(typeorm.Not(typeorm.Equal(filter.ne)));
2836
2852
  }
2853
+ if (!!filter?.ine) {
2854
+ clauses.push(typeorm.Not(typeorm.ILike(filter.ine)));
2855
+ }
2837
2856
  if (!!filter?.notIn) {
2838
2857
  clauses.push(typeorm.Not(typeorm.In(filter.notIn)));
2839
2858
  }
@@ -23096,7 +23115,7 @@ AuthenticationMiddleware = __decorate([
23096
23115
  ], AuthenticationMiddleware);
23097
23116
 
23098
23117
  var AuthenticationModule_1;
23099
- const ModuleData$5 = {
23118
+ const ModuleData$6 = {
23100
23119
  imports: [exports.EntityManagerModule, jwt.JwtModule],
23101
23120
  providers: [
23102
23121
  AuthenticationServicesResolver,
@@ -23113,7 +23132,7 @@ exports.AuthenticationModule = AuthenticationModule_1 = class AuthenticationModu
23113
23132
  authSettings.initialize(input);
23114
23133
  return {
23115
23134
  module: AuthenticationModule_1,
23116
- ...ModuleData$5,
23135
+ ...ModuleData$6,
23117
23136
  };
23118
23137
  }
23119
23138
  configure(consumer) {
@@ -23126,7 +23145,7 @@ exports.AuthenticationModule = AuthenticationModule_1 = class AuthenticationModu
23126
23145
  };
23127
23146
  exports.AuthenticationModule = AuthenticationModule_1 = __decorate([
23128
23147
  common.Module({
23129
- ...ModuleData$5,
23148
+ ...ModuleData$6,
23130
23149
  })
23131
23150
  ], exports.AuthenticationModule);
23132
23151
 
@@ -23583,7 +23602,7 @@ AwsS3FileProvider = __decorate([
23583
23602
  ], AwsS3FileProvider);
23584
23603
 
23585
23604
  var AwsBucketModule_1;
23586
- const ModuleData$4 = {
23605
+ const ModuleData$5 = {
23587
23606
  providers: [exports.AwsS3BucketProvider, AwsS3FileProvider],
23588
23607
  };
23589
23608
  exports.AwsBucketModule = AwsBucketModule_1 = class AwsBucketModule {
@@ -23591,13 +23610,13 @@ exports.AwsBucketModule = AwsBucketModule_1 = class AwsBucketModule {
23591
23610
  awsBucketSettings.initialize(input);
23592
23611
  return {
23593
23612
  module: AwsBucketModule_1,
23594
- ...ModuleData$4,
23613
+ ...ModuleData$5,
23595
23614
  };
23596
23615
  }
23597
23616
  };
23598
23617
  exports.AwsBucketModule = AwsBucketModule_1 = __decorate([
23599
23618
  common.Module({
23600
- ...ModuleData$4,
23619
+ ...ModuleData$5,
23601
23620
  })
23602
23621
  ], exports.AwsBucketModule);
23603
23622
 
@@ -23745,16 +23764,16 @@ var handlebars_runtime = {exports: {}};
23745
23764
 
23746
23765
  var base$1 = {};
23747
23766
 
23748
- var utils = {};
23767
+ var utils$g = {};
23749
23768
 
23750
- utils.__esModule = true;
23751
- utils.extend = extend;
23752
- utils.indexOf = indexOf;
23753
- utils.escapeExpression = escapeExpression;
23754
- utils.isEmpty = isEmpty;
23755
- utils.createFrame = createFrame;
23756
- utils.blockParams = blockParams;
23757
- utils.appendContextPath = appendContextPath;
23769
+ utils$g.__esModule = true;
23770
+ utils$g.extend = extend$1;
23771
+ utils$g.indexOf = indexOf;
23772
+ utils$g.escapeExpression = escapeExpression;
23773
+ utils$g.isEmpty = isEmpty;
23774
+ utils$g.createFrame = createFrame;
23775
+ utils$g.blockParams = blockParams;
23776
+ utils$g.appendContextPath = appendContextPath;
23758
23777
  var escape = {
23759
23778
  '&': '&',
23760
23779
  '<': '&lt;',
@@ -23772,7 +23791,7 @@ function escapeChar(chr) {
23772
23791
  return escape[chr];
23773
23792
  }
23774
23793
 
23775
- function extend(obj /* , ...source */) {
23794
+ function extend$1(obj /* , ...source */) {
23776
23795
  for (var i = 1; i < arguments.length; i++) {
23777
23796
  for (var key in arguments[i]) {
23778
23797
  if (Object.prototype.hasOwnProperty.call(arguments[i], key)) {
@@ -23784,32 +23803,32 @@ function extend(obj /* , ...source */) {
23784
23803
  return obj;
23785
23804
  }
23786
23805
 
23787
- var toString = Object.prototype.toString;
23806
+ var toString$1 = Object.prototype.toString;
23788
23807
 
23789
- utils.toString = toString;
23808
+ utils$g.toString = toString$1;
23790
23809
  // Sourced from lodash
23791
23810
  // https://github.com/bestiejs/lodash/blob/master/LICENSE.txt
23792
23811
  /* eslint-disable func-style */
23793
- var isFunction = function isFunction(value) {
23812
+ var isFunction$2 = function isFunction(value) {
23794
23813
  return typeof value === 'function';
23795
23814
  };
23796
23815
  // fallback for older versions of Chrome and Safari
23797
23816
  /* istanbul ignore next */
23798
- if (isFunction(/x/)) {
23799
- utils.isFunction = isFunction = function (value) {
23800
- return typeof value === 'function' && toString.call(value) === '[object Function]';
23817
+ if (isFunction$2(/x/)) {
23818
+ utils$g.isFunction = isFunction$2 = function (value) {
23819
+ return typeof value === 'function' && toString$1.call(value) === '[object Function]';
23801
23820
  };
23802
23821
  }
23803
- utils.isFunction = isFunction;
23822
+ utils$g.isFunction = isFunction$2;
23804
23823
 
23805
23824
  /* eslint-enable func-style */
23806
23825
 
23807
23826
  /* istanbul ignore next */
23808
- var isArray = Array.isArray || function (value) {
23809
- return value && typeof value === 'object' ? toString.call(value) === '[object Array]' : false;
23827
+ var isArray$1 = Array.isArray || function (value) {
23828
+ return value && typeof value === 'object' ? toString$1.call(value) === '[object Array]' : false;
23810
23829
  };
23811
23830
 
23812
- utils.isArray = isArray;
23831
+ utils$g.isArray = isArray$1;
23813
23832
  // Older IE versions do not directly support indexOf so we must implement our own, sadly.
23814
23833
 
23815
23834
  function indexOf(array, value) {
@@ -23847,7 +23866,7 @@ function escapeExpression(string) {
23847
23866
  function isEmpty(value) {
23848
23867
  if (!value && value !== 0) {
23849
23868
  return true;
23850
- } else if (isArray(value) && value.length === 0) {
23869
+ } else if (isArray$1(value) && value.length === 0) {
23851
23870
  return true;
23852
23871
  } else {
23853
23872
  return false;
@@ -23855,7 +23874,7 @@ function isEmpty(value) {
23855
23874
  }
23856
23875
 
23857
23876
  function createFrame(object) {
23858
- var frame = extend({}, object);
23877
+ var frame = extend$1({}, object);
23859
23878
  frame._parent = object;
23860
23879
  return frame;
23861
23880
  }
@@ -23945,7 +23964,7 @@ var blockHelperMissing = {exports: {}};
23945
23964
 
23946
23965
  exports.__esModule = true;
23947
23966
 
23948
- var _utils = utils;
23967
+ var _utils = utils$g;
23949
23968
 
23950
23969
  exports['default'] = function (instance) {
23951
23970
  instance.registerHelper('blockHelperMissing', function (context, options) {
@@ -23991,7 +24010,7 @@ exports.__esModule = true;
23991
24010
 
23992
24011
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
23993
24012
 
23994
- var _utils = utils;
24013
+ var _utils = utils$g;
23995
24014
 
23996
24015
  var _exception = exception.exports;
23997
24016
 
@@ -24128,7 +24147,7 @@ exports.__esModule = true;
24128
24147
 
24129
24148
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
24130
24149
 
24131
- var _utils = utils;
24150
+ var _utils = utils$g;
24132
24151
 
24133
24152
  var _exception = exception.exports;
24134
24153
 
@@ -24228,7 +24247,7 @@ exports.__esModule = true;
24228
24247
 
24229
24248
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
24230
24249
 
24231
- var _utils = utils;
24250
+ var _utils = utils$g;
24232
24251
 
24233
24252
  var _exception = exception.exports;
24234
24253
 
@@ -24328,7 +24347,7 @@ var inline = {exports: {}};
24328
24347
 
24329
24348
  exports.__esModule = true;
24330
24349
 
24331
- var _utils = utils;
24350
+ var _utils = utils$g;
24332
24351
 
24333
24352
  exports['default'] = function (instance) {
24334
24353
  instance.registerDecorator('inline', function (fn, props, container, options) {
@@ -24375,7 +24394,7 @@ var logger$1 = {exports: {}};
24375
24394
 
24376
24395
  exports.__esModule = true;
24377
24396
 
24378
- var _utils = utils;
24397
+ var _utils = utils$g;
24379
24398
 
24380
24399
  var logger = {
24381
24400
  methodMap: ['debug', 'info', 'warn', 'error'],
@@ -24427,7 +24446,7 @@ var createNewLookupObject$1 = {};
24427
24446
  createNewLookupObject$1.__esModule = true;
24428
24447
  createNewLookupObject$1.createNewLookupObject = createNewLookupObject;
24429
24448
 
24430
- var _utils$4 = utils;
24449
+ var _utils$4 = utils$g;
24431
24450
 
24432
24451
  /**
24433
24452
  * Create a new object with "null"-prototype to avoid truthy results on prototype properties.
@@ -24521,7 +24540,7 @@ base$1.HandlebarsEnvironment = HandlebarsEnvironment;
24521
24540
 
24522
24541
  function _interopRequireDefault$5(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
24523
24542
 
24524
- var _utils$3 = utils;
24543
+ var _utils$3 = utils$g;
24525
24544
 
24526
24545
  var _exception$3 = exception.exports;
24527
24546
 
@@ -24537,8 +24556,8 @@ var _logger2 = _interopRequireDefault$5(_logger);
24537
24556
 
24538
24557
  var _internalProtoAccess$1 = protoAccess;
24539
24558
 
24540
- var VERSION = '4.7.7';
24541
- base$1.VERSION = VERSION;
24559
+ var VERSION$2 = '4.7.7';
24560
+ base$1.VERSION = VERSION$2;
24542
24561
  var COMPILER_REVISION = 8;
24543
24562
  base$1.COMPILER_REVISION = COMPILER_REVISION;
24544
24563
  var LAST_COMPATIBLE_COMPILER_REVISION = 7;
@@ -24674,7 +24693,7 @@ runtime.template = template;
24674
24693
  runtime.wrapProgram = wrapProgram;
24675
24694
  runtime.resolvePartial = resolvePartial;
24676
24695
  runtime.invokePartial = invokePartial;
24677
- runtime.noop = noop;
24696
+ runtime.noop = noop$1;
24678
24697
  // istanbul ignore next
24679
24698
 
24680
24699
  function _interopRequireDefault$4(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
@@ -24683,7 +24702,7 @@ function _interopRequireDefault$4(obj) { return obj && obj.__esModule ? obj : {
24683
24702
 
24684
24703
  function _interopRequireWildcard$1(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
24685
24704
 
24686
- var _utils$2 = utils;
24705
+ var _utils$2 = utils$g;
24687
24706
 
24688
24707
  var Utils = _interopRequireWildcard$1(_utils$2);
24689
24708
 
@@ -24972,7 +24991,7 @@ function invokePartial(partial, context, options) {
24972
24991
  }
24973
24992
 
24974
24993
  var partialBlock = undefined;
24975
- if (options.fn && options.fn !== noop) {
24994
+ if (options.fn && options.fn !== noop$1) {
24976
24995
  (function () {
24977
24996
  options.data = _base.createFrame(options.data);
24978
24997
  // Wrapper function to get access to currentPartialBlock from the closure
@@ -25003,7 +25022,7 @@ function invokePartial(partial, context, options) {
25003
25022
  }
25004
25023
  }
25005
25024
 
25006
- function noop() {
25025
+ function noop$1() {
25007
25026
  return '';
25008
25027
  }
25009
25028
 
@@ -25087,7 +25106,7 @@ var _handlebarsException = exception.exports;
25087
25106
 
25088
25107
  var _handlebarsException2 = _interopRequireDefault(_handlebarsException);
25089
25108
 
25090
- var _handlebarsUtils = utils;
25109
+ var _handlebarsUtils = utils$g;
25091
25110
 
25092
25111
  var Utils = _interopRequireWildcard(_handlebarsUtils);
25093
25112
 
@@ -26461,7 +26480,7 @@ var _helpers = helpers;
26461
26480
 
26462
26481
  var Helpers = _interopRequireWildcard(_helpers);
26463
26482
 
26464
- var _utils$1 = utils;
26483
+ var _utils$1 = utils$g;
26465
26484
 
26466
26485
  base.parser = _parser2['default'];
26467
26486
 
@@ -26509,7 +26528,7 @@ var _exception = exception.exports;
26509
26528
 
26510
26529
  var _exception2 = _interopRequireDefault$1(_exception);
26511
26530
 
26512
- var _utils = utils;
26531
+ var _utils = utils$g;
26513
26532
 
26514
26533
  var _ast = ast.exports;
26515
26534
 
@@ -27069,7 +27088,7 @@ var codeGen = {exports: {}};
27069
27088
 
27070
27089
  exports.__esModule = true;
27071
27090
 
27072
- var _utils = utils;
27091
+ var _utils = utils$g;
27073
27092
 
27074
27093
  var SourceNode = undefined;
27075
27094
 
@@ -27247,7 +27266,7 @@ var _exception = exception.exports;
27247
27266
 
27248
27267
  var _exception2 = _interopRequireDefault(_exception);
27249
27268
 
27250
- var _utils = utils;
27269
+ var _utils = utils$g;
27251
27270
 
27252
27271
  var _codeGen = codeGen.exports;
27253
27272
 
@@ -28741,7 +28760,7 @@ AwsSesEmailProvider = __decorate([
28741
28760
  ], AwsSesEmailProvider);
28742
28761
 
28743
28762
  var AwsEmailModule_1;
28744
- const ModuleData$3 = {
28763
+ const ModuleData$4 = {
28745
28764
  providers: [AwsSesEmailProvider],
28746
28765
  };
28747
28766
  exports.AwsEmailModule = AwsEmailModule_1 = class AwsEmailModule {
@@ -28749,13 +28768,13 @@ exports.AwsEmailModule = AwsEmailModule_1 = class AwsEmailModule {
28749
28768
  awsSesSettings.initialize(input);
28750
28769
  return {
28751
28770
  module: AwsEmailModule_1,
28752
- ...ModuleData$3,
28771
+ ...ModuleData$4,
28753
28772
  };
28754
28773
  }
28755
28774
  };
28756
28775
  exports.AwsEmailModule = AwsEmailModule_1 = __decorate([
28757
28776
  common.Module({
28758
- ...ModuleData$3,
28777
+ ...ModuleData$4,
28759
28778
  })
28760
28779
  ], exports.AwsEmailModule);
28761
28780
 
@@ -28908,7 +28927,7 @@ SendgridEmailProvider = __decorate([
28908
28927
  ], SendgridEmailProvider);
28909
28928
 
28910
28929
  var SendgridEmailModule_1;
28911
- const ModuleData$2 = {
28930
+ const ModuleData$3 = {
28912
28931
  imports: [exports.EntityManagerModule],
28913
28932
  providers: [SendgridEmailProvider],
28914
28933
  };
@@ -28917,13 +28936,13 @@ exports.SendgridEmailModule = SendgridEmailModule_1 = class SendgridEmailModule
28917
28936
  sendgridSettings.initialize(input);
28918
28937
  return {
28919
28938
  module: SendgridEmailModule_1,
28920
- ...ModuleData$2,
28939
+ ...ModuleData$3,
28921
28940
  };
28922
28941
  }
28923
28942
  };
28924
28943
  exports.SendgridEmailModule = SendgridEmailModule_1 = __decorate([
28925
28944
  common.Module({
28926
- ...ModuleData$2,
28945
+ ...ModuleData$3,
28927
28946
  })
28928
28947
  ], exports.SendgridEmailModule);
28929
28948
 
@@ -28970,10 +28989,10 @@ const createClient$1 = (settings) => new clientS3.S3Client({
28970
28989
  }
28971
28990
  : undefined,
28972
28991
  });
28973
- const buildRef = (bucket, path) => {
28992
+ const buildRef$1 = (bucket, path) => {
28974
28993
  return `s3://${bucket}/${path}`;
28975
28994
  };
28976
- const parseRef = (ref) => {
28995
+ const parseRef$1 = (ref) => {
28977
28996
  const parts = ref.split("/");
28978
28997
  return {
28979
28998
  bucket: parts[2],
@@ -28988,7 +29007,7 @@ exports.AwsS3MediaProvider = class AwsS3MediaProvider {
28988
29007
  return "awsS3";
28989
29008
  }
28990
29009
  getFileName(input) {
28991
- const parsedRef = parseRef(input.ref);
29010
+ const parsedRef = parseRef$1(input.ref);
28992
29011
  return parsedRef.path.split("/").pop() ?? "";
28993
29012
  }
28994
29013
  async mediaUpload(input) {
@@ -29003,7 +29022,7 @@ exports.AwsS3MediaProvider = class AwsS3MediaProvider {
29003
29022
  ACL: "public-read",
29004
29023
  }));
29005
29024
  return {
29006
- ref: buildRef(bucket, path),
29025
+ ref: buildRef$1(bucket, path),
29007
29026
  };
29008
29027
  }
29009
29028
  catch (e) {
@@ -29012,7 +29031,7 @@ exports.AwsS3MediaProvider = class AwsS3MediaProvider {
29012
29031
  }
29013
29032
  async mediaDelete(input) {
29014
29033
  try {
29015
- const parsedRef = parseRef(input.ref);
29034
+ const parsedRef = parseRef$1(input.ref);
29016
29035
  await this.client.send(new clientS3.DeleteObjectCommand({
29017
29036
  Bucket: parsedRef.bucket,
29018
29037
  Key: parsedRef.path,
@@ -29024,7 +29043,7 @@ exports.AwsS3MediaProvider = class AwsS3MediaProvider {
29024
29043
  }
29025
29044
  async mediaDownload(input) {
29026
29045
  try {
29027
- const parsedRef = parseRef(input.ref);
29046
+ const parsedRef = parseRef$1(input.ref);
29028
29047
  const result = await this.client.send(new clientS3.GetObjectCommand({
29029
29048
  Bucket: parsedRef.bucket,
29030
29049
  Key: parsedRef.path,
@@ -29050,7 +29069,7 @@ exports.AwsS3MediaProvider = __decorate([
29050
29069
  ], exports.AwsS3MediaProvider);
29051
29070
 
29052
29071
  var AwsS3MediaModule_1;
29053
- const ModuleData$1 = {
29072
+ const ModuleData$2 = {
29054
29073
  providers: [exports.AwsS3MediaProvider],
29055
29074
  };
29056
29075
  exports.AwsS3MediaModule = AwsS3MediaModule_1 = class AwsS3MediaModule {
@@ -29058,16 +29077,2980 @@ exports.AwsS3MediaModule = AwsS3MediaModule_1 = class AwsS3MediaModule {
29058
29077
  awsMediaSettings.initialize(input);
29059
29078
  return {
29060
29079
  module: AwsS3MediaModule_1,
29061
- ...ModuleData$1,
29080
+ ...ModuleData$2,
29062
29081
  };
29063
29082
  }
29064
29083
  };
29065
29084
  exports.AwsS3MediaModule = AwsS3MediaModule_1 = __decorate([
29066
29085
  common.Module({
29067
- ...ModuleData$1,
29086
+ ...ModuleData$2,
29068
29087
  })
29069
29088
  ], exports.AwsS3MediaModule);
29070
29089
 
29090
+ class SanityMediaError extends Error {
29091
+ constructor(message) {
29092
+ super(message);
29093
+ this.name = "SanityMediaError";
29094
+ }
29095
+ }
29096
+
29097
+ var axios$2 = {exports: {}};
29098
+
29099
+ var bind$2 = function bind(fn, thisArg) {
29100
+ return function wrap() {
29101
+ var args = new Array(arguments.length);
29102
+ for (var i = 0; i < args.length; i++) {
29103
+ args[i] = arguments[i];
29104
+ }
29105
+ return fn.apply(thisArg, args);
29106
+ };
29107
+ };
29108
+
29109
+ var bind$1 = bind$2;
29110
+
29111
+ // utils is a library of generic helper functions non-specific to axios
29112
+
29113
+ var toString = Object.prototype.toString;
29114
+
29115
+ /**
29116
+ * Determine if a value is an Array
29117
+ *
29118
+ * @param {Object} val The value to test
29119
+ * @returns {boolean} True if value is an Array, otherwise false
29120
+ */
29121
+ function isArray(val) {
29122
+ return Array.isArray(val);
29123
+ }
29124
+
29125
+ /**
29126
+ * Determine if a value is undefined
29127
+ *
29128
+ * @param {Object} val The value to test
29129
+ * @returns {boolean} True if the value is undefined, otherwise false
29130
+ */
29131
+ function isUndefined(val) {
29132
+ return typeof val === 'undefined';
29133
+ }
29134
+
29135
+ /**
29136
+ * Determine if a value is a Buffer
29137
+ *
29138
+ * @param {Object} val The value to test
29139
+ * @returns {boolean} True if value is a Buffer, otherwise false
29140
+ */
29141
+ function isBuffer$1(val) {
29142
+ return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor)
29143
+ && typeof val.constructor.isBuffer === 'function' && val.constructor.isBuffer(val);
29144
+ }
29145
+
29146
+ /**
29147
+ * Determine if a value is an ArrayBuffer
29148
+ *
29149
+ * @param {Object} val The value to test
29150
+ * @returns {boolean} True if value is an ArrayBuffer, otherwise false
29151
+ */
29152
+ function isArrayBuffer(val) {
29153
+ return toString.call(val) === '[object ArrayBuffer]';
29154
+ }
29155
+
29156
+ /**
29157
+ * Determine if a value is a FormData
29158
+ *
29159
+ * @param {Object} val The value to test
29160
+ * @returns {boolean} True if value is an FormData, otherwise false
29161
+ */
29162
+ function isFormData(val) {
29163
+ return toString.call(val) === '[object FormData]';
29164
+ }
29165
+
29166
+ /**
29167
+ * Determine if a value is a view on an ArrayBuffer
29168
+ *
29169
+ * @param {Object} val The value to test
29170
+ * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false
29171
+ */
29172
+ function isArrayBufferView(val) {
29173
+ var result;
29174
+ if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {
29175
+ result = ArrayBuffer.isView(val);
29176
+ } else {
29177
+ result = (val) && (val.buffer) && (isArrayBuffer(val.buffer));
29178
+ }
29179
+ return result;
29180
+ }
29181
+
29182
+ /**
29183
+ * Determine if a value is a String
29184
+ *
29185
+ * @param {Object} val The value to test
29186
+ * @returns {boolean} True if value is a String, otherwise false
29187
+ */
29188
+ function isString$1(val) {
29189
+ return typeof val === 'string';
29190
+ }
29191
+
29192
+ /**
29193
+ * Determine if a value is a Number
29194
+ *
29195
+ * @param {Object} val The value to test
29196
+ * @returns {boolean} True if value is a Number, otherwise false
29197
+ */
29198
+ function isNumber(val) {
29199
+ return typeof val === 'number';
29200
+ }
29201
+
29202
+ /**
29203
+ * Determine if a value is an Object
29204
+ *
29205
+ * @param {Object} val The value to test
29206
+ * @returns {boolean} True if value is an Object, otherwise false
29207
+ */
29208
+ function isObject(val) {
29209
+ return val !== null && typeof val === 'object';
29210
+ }
29211
+
29212
+ /**
29213
+ * Determine if a value is a plain Object
29214
+ *
29215
+ * @param {Object} val The value to test
29216
+ * @return {boolean} True if value is a plain Object, otherwise false
29217
+ */
29218
+ function isPlainObject(val) {
29219
+ if (toString.call(val) !== '[object Object]') {
29220
+ return false;
29221
+ }
29222
+
29223
+ var prototype = Object.getPrototypeOf(val);
29224
+ return prototype === null || prototype === Object.prototype;
29225
+ }
29226
+
29227
+ /**
29228
+ * Determine if a value is a Date
29229
+ *
29230
+ * @param {Object} val The value to test
29231
+ * @returns {boolean} True if value is a Date, otherwise false
29232
+ */
29233
+ function isDate(val) {
29234
+ return toString.call(val) === '[object Date]';
29235
+ }
29236
+
29237
+ /**
29238
+ * Determine if a value is a File
29239
+ *
29240
+ * @param {Object} val The value to test
29241
+ * @returns {boolean} True if value is a File, otherwise false
29242
+ */
29243
+ function isFile(val) {
29244
+ return toString.call(val) === '[object File]';
29245
+ }
29246
+
29247
+ /**
29248
+ * Determine if a value is a Blob
29249
+ *
29250
+ * @param {Object} val The value to test
29251
+ * @returns {boolean} True if value is a Blob, otherwise false
29252
+ */
29253
+ function isBlob(val) {
29254
+ return toString.call(val) === '[object Blob]';
29255
+ }
29256
+
29257
+ /**
29258
+ * Determine if a value is a Function
29259
+ *
29260
+ * @param {Object} val The value to test
29261
+ * @returns {boolean} True if value is a Function, otherwise false
29262
+ */
29263
+ function isFunction$1(val) {
29264
+ return toString.call(val) === '[object Function]';
29265
+ }
29266
+
29267
+ /**
29268
+ * Determine if a value is a Stream
29269
+ *
29270
+ * @param {Object} val The value to test
29271
+ * @returns {boolean} True if value is a Stream, otherwise false
29272
+ */
29273
+ function isStream(val) {
29274
+ return isObject(val) && isFunction$1(val.pipe);
29275
+ }
29276
+
29277
+ /**
29278
+ * Determine if a value is a URLSearchParams object
29279
+ *
29280
+ * @param {Object} val The value to test
29281
+ * @returns {boolean} True if value is a URLSearchParams object, otherwise false
29282
+ */
29283
+ function isURLSearchParams(val) {
29284
+ return toString.call(val) === '[object URLSearchParams]';
29285
+ }
29286
+
29287
+ /**
29288
+ * Trim excess whitespace off the beginning and end of a string
29289
+ *
29290
+ * @param {String} str The String to trim
29291
+ * @returns {String} The String freed of excess whitespace
29292
+ */
29293
+ function trim(str) {
29294
+ return str.trim ? str.trim() : str.replace(/^\s+|\s+$/g, '');
29295
+ }
29296
+
29297
+ /**
29298
+ * Determine if we're running in a standard browser environment
29299
+ *
29300
+ * This allows axios to run in a web worker, and react-native.
29301
+ * Both environments support XMLHttpRequest, but not fully standard globals.
29302
+ *
29303
+ * web workers:
29304
+ * typeof window -> undefined
29305
+ * typeof document -> undefined
29306
+ *
29307
+ * react-native:
29308
+ * navigator.product -> 'ReactNative'
29309
+ * nativescript
29310
+ * navigator.product -> 'NativeScript' or 'NS'
29311
+ */
29312
+ function isStandardBrowserEnv() {
29313
+ if (typeof navigator !== 'undefined' && (navigator.product === 'ReactNative' ||
29314
+ navigator.product === 'NativeScript' ||
29315
+ navigator.product === 'NS')) {
29316
+ return false;
29317
+ }
29318
+ return (
29319
+ typeof window !== 'undefined' &&
29320
+ typeof document !== 'undefined'
29321
+ );
29322
+ }
29323
+
29324
+ /**
29325
+ * Iterate over an Array or an Object invoking a function for each item.
29326
+ *
29327
+ * If `obj` is an Array callback will be called passing
29328
+ * the value, index, and complete array for each item.
29329
+ *
29330
+ * If 'obj' is an Object callback will be called passing
29331
+ * the value, key, and complete object for each property.
29332
+ *
29333
+ * @param {Object|Array} obj The object to iterate
29334
+ * @param {Function} fn The callback to invoke for each item
29335
+ */
29336
+ function forEach(obj, fn) {
29337
+ // Don't bother if no value provided
29338
+ if (obj === null || typeof obj === 'undefined') {
29339
+ return;
29340
+ }
29341
+
29342
+ // Force an array if not already something iterable
29343
+ if (typeof obj !== 'object') {
29344
+ /*eslint no-param-reassign:0*/
29345
+ obj = [obj];
29346
+ }
29347
+
29348
+ if (isArray(obj)) {
29349
+ // Iterate over array values
29350
+ for (var i = 0, l = obj.length; i < l; i++) {
29351
+ fn.call(null, obj[i], i, obj);
29352
+ }
29353
+ } else {
29354
+ // Iterate over object keys
29355
+ for (var key in obj) {
29356
+ if (Object.prototype.hasOwnProperty.call(obj, key)) {
29357
+ fn.call(null, obj[key], key, obj);
29358
+ }
29359
+ }
29360
+ }
29361
+ }
29362
+
29363
+ /**
29364
+ * Accepts varargs expecting each argument to be an object, then
29365
+ * immutably merges the properties of each object and returns result.
29366
+ *
29367
+ * When multiple objects contain the same key the later object in
29368
+ * the arguments list will take precedence.
29369
+ *
29370
+ * Example:
29371
+ *
29372
+ * ```js
29373
+ * var result = merge({foo: 123}, {foo: 456});
29374
+ * console.log(result.foo); // outputs 456
29375
+ * ```
29376
+ *
29377
+ * @param {Object} obj1 Object to merge
29378
+ * @returns {Object} Result of all merge properties
29379
+ */
29380
+ function merge(/* obj1, obj2, obj3, ... */) {
29381
+ var result = {};
29382
+ function assignValue(val, key) {
29383
+ if (isPlainObject(result[key]) && isPlainObject(val)) {
29384
+ result[key] = merge(result[key], val);
29385
+ } else if (isPlainObject(val)) {
29386
+ result[key] = merge({}, val);
29387
+ } else if (isArray(val)) {
29388
+ result[key] = val.slice();
29389
+ } else {
29390
+ result[key] = val;
29391
+ }
29392
+ }
29393
+
29394
+ for (var i = 0, l = arguments.length; i < l; i++) {
29395
+ forEach(arguments[i], assignValue);
29396
+ }
29397
+ return result;
29398
+ }
29399
+
29400
+ /**
29401
+ * Extends object a by mutably adding to it the properties of object b.
29402
+ *
29403
+ * @param {Object} a The object to be extended
29404
+ * @param {Object} b The object to copy properties from
29405
+ * @param {Object} thisArg The object to bind function to
29406
+ * @return {Object} The resulting value of object a
29407
+ */
29408
+ function extend(a, b, thisArg) {
29409
+ forEach(b, function assignValue(val, key) {
29410
+ if (thisArg && typeof val === 'function') {
29411
+ a[key] = bind$1(val, thisArg);
29412
+ } else {
29413
+ a[key] = val;
29414
+ }
29415
+ });
29416
+ return a;
29417
+ }
29418
+
29419
+ /**
29420
+ * Remove byte order marker. This catches EF BB BF (the UTF-8 BOM)
29421
+ *
29422
+ * @param {string} content with BOM
29423
+ * @return {string} content value without BOM
29424
+ */
29425
+ function stripBOM(content) {
29426
+ if (content.charCodeAt(0) === 0xFEFF) {
29427
+ content = content.slice(1);
29428
+ }
29429
+ return content;
29430
+ }
29431
+
29432
+ var utils$f = {
29433
+ isArray: isArray,
29434
+ isArrayBuffer: isArrayBuffer,
29435
+ isBuffer: isBuffer$1,
29436
+ isFormData: isFormData,
29437
+ isArrayBufferView: isArrayBufferView,
29438
+ isString: isString$1,
29439
+ isNumber: isNumber,
29440
+ isObject: isObject,
29441
+ isPlainObject: isPlainObject,
29442
+ isUndefined: isUndefined,
29443
+ isDate: isDate,
29444
+ isFile: isFile,
29445
+ isBlob: isBlob,
29446
+ isFunction: isFunction$1,
29447
+ isStream: isStream,
29448
+ isURLSearchParams: isURLSearchParams,
29449
+ isStandardBrowserEnv: isStandardBrowserEnv,
29450
+ forEach: forEach,
29451
+ merge: merge,
29452
+ extend: extend,
29453
+ trim: trim,
29454
+ stripBOM: stripBOM
29455
+ };
29456
+
29457
+ var utils$e = utils$f;
29458
+
29459
+ function encode(val) {
29460
+ return encodeURIComponent(val).
29461
+ replace(/%3A/gi, ':').
29462
+ replace(/%24/g, '$').
29463
+ replace(/%2C/gi, ',').
29464
+ replace(/%20/g, '+').
29465
+ replace(/%5B/gi, '[').
29466
+ replace(/%5D/gi, ']');
29467
+ }
29468
+
29469
+ /**
29470
+ * Build a URL by appending params to the end
29471
+ *
29472
+ * @param {string} url The base of the url (e.g., http://www.google.com)
29473
+ * @param {object} [params] The params to be appended
29474
+ * @returns {string} The formatted url
29475
+ */
29476
+ var buildURL$3 = function buildURL(url, params, paramsSerializer) {
29477
+ /*eslint no-param-reassign:0*/
29478
+ if (!params) {
29479
+ return url;
29480
+ }
29481
+
29482
+ var serializedParams;
29483
+ if (paramsSerializer) {
29484
+ serializedParams = paramsSerializer(params);
29485
+ } else if (utils$e.isURLSearchParams(params)) {
29486
+ serializedParams = params.toString();
29487
+ } else {
29488
+ var parts = [];
29489
+
29490
+ utils$e.forEach(params, function serialize(val, key) {
29491
+ if (val === null || typeof val === 'undefined') {
29492
+ return;
29493
+ }
29494
+
29495
+ if (utils$e.isArray(val)) {
29496
+ key = key + '[]';
29497
+ } else {
29498
+ val = [val];
29499
+ }
29500
+
29501
+ utils$e.forEach(val, function parseValue(v) {
29502
+ if (utils$e.isDate(v)) {
29503
+ v = v.toISOString();
29504
+ } else if (utils$e.isObject(v)) {
29505
+ v = JSON.stringify(v);
29506
+ }
29507
+ parts.push(encode(key) + '=' + encode(v));
29508
+ });
29509
+ });
29510
+
29511
+ serializedParams = parts.join('&');
29512
+ }
29513
+
29514
+ if (serializedParams) {
29515
+ var hashmarkIndex = url.indexOf('#');
29516
+ if (hashmarkIndex !== -1) {
29517
+ url = url.slice(0, hashmarkIndex);
29518
+ }
29519
+
29520
+ url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
29521
+ }
29522
+
29523
+ return url;
29524
+ };
29525
+
29526
+ var utils$d = utils$f;
29527
+
29528
+ function InterceptorManager$1() {
29529
+ this.handlers = [];
29530
+ }
29531
+
29532
+ /**
29533
+ * Add a new interceptor to the stack
29534
+ *
29535
+ * @param {Function} fulfilled The function to handle `then` for a `Promise`
29536
+ * @param {Function} rejected The function to handle `reject` for a `Promise`
29537
+ *
29538
+ * @return {Number} An ID used to remove interceptor later
29539
+ */
29540
+ InterceptorManager$1.prototype.use = function use(fulfilled, rejected, options) {
29541
+ this.handlers.push({
29542
+ fulfilled: fulfilled,
29543
+ rejected: rejected,
29544
+ synchronous: options ? options.synchronous : false,
29545
+ runWhen: options ? options.runWhen : null
29546
+ });
29547
+ return this.handlers.length - 1;
29548
+ };
29549
+
29550
+ /**
29551
+ * Remove an interceptor from the stack
29552
+ *
29553
+ * @param {Number} id The ID that was returned by `use`
29554
+ */
29555
+ InterceptorManager$1.prototype.eject = function eject(id) {
29556
+ if (this.handlers[id]) {
29557
+ this.handlers[id] = null;
29558
+ }
29559
+ };
29560
+
29561
+ /**
29562
+ * Iterate over all the registered interceptors
29563
+ *
29564
+ * This method is particularly useful for skipping over any
29565
+ * interceptors that may have become `null` calling `eject`.
29566
+ *
29567
+ * @param {Function} fn The function to call for each interceptor
29568
+ */
29569
+ InterceptorManager$1.prototype.forEach = function forEach(fn) {
29570
+ utils$d.forEach(this.handlers, function forEachHandler(h) {
29571
+ if (h !== null) {
29572
+ fn(h);
29573
+ }
29574
+ });
29575
+ };
29576
+
29577
+ var InterceptorManager_1 = InterceptorManager$1;
29578
+
29579
+ var utils$c = utils$f;
29580
+
29581
+ var normalizeHeaderName$1 = function normalizeHeaderName(headers, normalizedName) {
29582
+ utils$c.forEach(headers, function processHeader(value, name) {
29583
+ if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) {
29584
+ headers[normalizedName] = value;
29585
+ delete headers[name];
29586
+ }
29587
+ });
29588
+ };
29589
+
29590
+ /**
29591
+ * Update an Error with the specified config, error code, and response.
29592
+ *
29593
+ * @param {Error} error The error to update.
29594
+ * @param {Object} config The config.
29595
+ * @param {string} [code] The error code (for example, 'ECONNABORTED').
29596
+ * @param {Object} [request] The request.
29597
+ * @param {Object} [response] The response.
29598
+ * @returns {Error} The error.
29599
+ */
29600
+ var enhanceError$3 = function enhanceError(error, config, code, request, response) {
29601
+ error.config = config;
29602
+ if (code) {
29603
+ error.code = code;
29604
+ }
29605
+
29606
+ error.request = request;
29607
+ error.response = response;
29608
+ error.isAxiosError = true;
29609
+
29610
+ error.toJSON = function toJSON() {
29611
+ return {
29612
+ // Standard
29613
+ message: this.message,
29614
+ name: this.name,
29615
+ // Microsoft
29616
+ description: this.description,
29617
+ number: this.number,
29618
+ // Mozilla
29619
+ fileName: this.fileName,
29620
+ lineNumber: this.lineNumber,
29621
+ columnNumber: this.columnNumber,
29622
+ stack: this.stack,
29623
+ // Axios
29624
+ config: this.config,
29625
+ code: this.code,
29626
+ status: this.response && this.response.status ? this.response.status : null
29627
+ };
29628
+ };
29629
+ return error;
29630
+ };
29631
+
29632
+ var transitional = {
29633
+ silentJSONParsing: true,
29634
+ forcedJSONParsing: true,
29635
+ clarifyTimeoutError: false
29636
+ };
29637
+
29638
+ var enhanceError$2 = enhanceError$3;
29639
+
29640
+ /**
29641
+ * Create an Error with the specified message, config, error code, request and response.
29642
+ *
29643
+ * @param {string} message The error message.
29644
+ * @param {Object} config The config.
29645
+ * @param {string} [code] The error code (for example, 'ECONNABORTED').
29646
+ * @param {Object} [request] The request.
29647
+ * @param {Object} [response] The response.
29648
+ * @returns {Error} The created error.
29649
+ */
29650
+ var createError$3 = function createError(message, config, code, request, response) {
29651
+ var error = new Error(message);
29652
+ return enhanceError$2(error, config, code, request, response);
29653
+ };
29654
+
29655
+ var createError$2 = createError$3;
29656
+
29657
+ /**
29658
+ * Resolve or reject a Promise based on response status.
29659
+ *
29660
+ * @param {Function} resolve A function that resolves the promise.
29661
+ * @param {Function} reject A function that rejects the promise.
29662
+ * @param {object} response The response.
29663
+ */
29664
+ var settle$2 = function settle(resolve, reject, response) {
29665
+ var validateStatus = response.config.validateStatus;
29666
+ if (!response.status || !validateStatus || validateStatus(response.status)) {
29667
+ resolve(response);
29668
+ } else {
29669
+ reject(createError$2(
29670
+ 'Request failed with status code ' + response.status,
29671
+ response.config,
29672
+ null,
29673
+ response.request,
29674
+ response
29675
+ ));
29676
+ }
29677
+ };
29678
+
29679
+ var utils$b = utils$f;
29680
+
29681
+ var cookies$1 = (
29682
+ utils$b.isStandardBrowserEnv() ?
29683
+
29684
+ // Standard browser envs support document.cookie
29685
+ (function standardBrowserEnv() {
29686
+ return {
29687
+ write: function write(name, value, expires, path, domain, secure) {
29688
+ var cookie = [];
29689
+ cookie.push(name + '=' + encodeURIComponent(value));
29690
+
29691
+ if (utils$b.isNumber(expires)) {
29692
+ cookie.push('expires=' + new Date(expires).toGMTString());
29693
+ }
29694
+
29695
+ if (utils$b.isString(path)) {
29696
+ cookie.push('path=' + path);
29697
+ }
29698
+
29699
+ if (utils$b.isString(domain)) {
29700
+ cookie.push('domain=' + domain);
29701
+ }
29702
+
29703
+ if (secure === true) {
29704
+ cookie.push('secure');
29705
+ }
29706
+
29707
+ document.cookie = cookie.join('; ');
29708
+ },
29709
+
29710
+ read: function read(name) {
29711
+ var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
29712
+ return (match ? decodeURIComponent(match[3]) : null);
29713
+ },
29714
+
29715
+ remove: function remove(name) {
29716
+ this.write(name, '', Date.now() - 86400000);
29717
+ }
29718
+ };
29719
+ })() :
29720
+
29721
+ // Non standard browser env (web workers, react-native) lack needed support.
29722
+ (function nonStandardBrowserEnv() {
29723
+ return {
29724
+ write: function write() {},
29725
+ read: function read() { return null; },
29726
+ remove: function remove() {}
29727
+ };
29728
+ })()
29729
+ );
29730
+
29731
+ /**
29732
+ * Determines whether the specified URL is absolute
29733
+ *
29734
+ * @param {string} url The URL to test
29735
+ * @returns {boolean} True if the specified URL is absolute, otherwise false
29736
+ */
29737
+ var isAbsoluteURL$1 = function isAbsoluteURL(url) {
29738
+ // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
29739
+ // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
29740
+ // by any combination of letters, digits, plus, period, or hyphen.
29741
+ return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
29742
+ };
29743
+
29744
+ /**
29745
+ * Creates a new URL by combining the specified URLs
29746
+ *
29747
+ * @param {string} baseURL The base URL
29748
+ * @param {string} relativeURL The relative URL
29749
+ * @returns {string} The combined URL
29750
+ */
29751
+ var combineURLs$1 = function combineURLs(baseURL, relativeURL) {
29752
+ return relativeURL
29753
+ ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '')
29754
+ : baseURL;
29755
+ };
29756
+
29757
+ var isAbsoluteURL = isAbsoluteURL$1;
29758
+ var combineURLs = combineURLs$1;
29759
+
29760
+ /**
29761
+ * Creates a new URL by combining the baseURL with the requestedURL,
29762
+ * only when the requestedURL is not already an absolute URL.
29763
+ * If the requestURL is absolute, this function returns the requestedURL untouched.
29764
+ *
29765
+ * @param {string} baseURL The base URL
29766
+ * @param {string} requestedURL Absolute or relative URL to combine
29767
+ * @returns {string} The combined full path
29768
+ */
29769
+ var buildFullPath$2 = function buildFullPath(baseURL, requestedURL) {
29770
+ if (baseURL && !isAbsoluteURL(requestedURL)) {
29771
+ return combineURLs(baseURL, requestedURL);
29772
+ }
29773
+ return requestedURL;
29774
+ };
29775
+
29776
+ var utils$a = utils$f;
29777
+
29778
+ // Headers whose duplicates are ignored by node
29779
+ // c.f. https://nodejs.org/api/http.html#http_message_headers
29780
+ var ignoreDuplicateOf = [
29781
+ 'age', 'authorization', 'content-length', 'content-type', 'etag',
29782
+ 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',
29783
+ 'last-modified', 'location', 'max-forwards', 'proxy-authorization',
29784
+ 'referer', 'retry-after', 'user-agent'
29785
+ ];
29786
+
29787
+ /**
29788
+ * Parse headers into an object
29789
+ *
29790
+ * ```
29791
+ * Date: Wed, 27 Aug 2014 08:58:49 GMT
29792
+ * Content-Type: application/json
29793
+ * Connection: keep-alive
29794
+ * Transfer-Encoding: chunked
29795
+ * ```
29796
+ *
29797
+ * @param {String} headers Headers needing to be parsed
29798
+ * @returns {Object} Headers parsed into an object
29799
+ */
29800
+ var parseHeaders$1 = function parseHeaders(headers) {
29801
+ var parsed = {};
29802
+ var key;
29803
+ var val;
29804
+ var i;
29805
+
29806
+ if (!headers) { return parsed; }
29807
+
29808
+ utils$a.forEach(headers.split('\n'), function parser(line) {
29809
+ i = line.indexOf(':');
29810
+ key = utils$a.trim(line.substr(0, i)).toLowerCase();
29811
+ val = utils$a.trim(line.substr(i + 1));
29812
+
29813
+ if (key) {
29814
+ if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) {
29815
+ return;
29816
+ }
29817
+ if (key === 'set-cookie') {
29818
+ parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]);
29819
+ } else {
29820
+ parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
29821
+ }
29822
+ }
29823
+ });
29824
+
29825
+ return parsed;
29826
+ };
29827
+
29828
+ var utils$9 = utils$f;
29829
+
29830
+ var isURLSameOrigin$1 = (
29831
+ utils$9.isStandardBrowserEnv() ?
29832
+
29833
+ // Standard browser envs have full support of the APIs needed to test
29834
+ // whether the request URL is of the same origin as current location.
29835
+ (function standardBrowserEnv() {
29836
+ var msie = /(msie|trident)/i.test(navigator.userAgent);
29837
+ var urlParsingNode = document.createElement('a');
29838
+ var originURL;
29839
+
29840
+ /**
29841
+ * Parse a URL to discover it's components
29842
+ *
29843
+ * @param {String} url The URL to be parsed
29844
+ * @returns {Object}
29845
+ */
29846
+ function resolveURL(url) {
29847
+ var href = url;
29848
+
29849
+ if (msie) {
29850
+ // IE needs attribute set twice to normalize properties
29851
+ urlParsingNode.setAttribute('href', href);
29852
+ href = urlParsingNode.href;
29853
+ }
29854
+
29855
+ urlParsingNode.setAttribute('href', href);
29856
+
29857
+ // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
29858
+ return {
29859
+ href: urlParsingNode.href,
29860
+ protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
29861
+ host: urlParsingNode.host,
29862
+ search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
29863
+ hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
29864
+ hostname: urlParsingNode.hostname,
29865
+ port: urlParsingNode.port,
29866
+ pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
29867
+ urlParsingNode.pathname :
29868
+ '/' + urlParsingNode.pathname
29869
+ };
29870
+ }
29871
+
29872
+ originURL = resolveURL(window.location.href);
29873
+
29874
+ /**
29875
+ * Determine if a URL shares the same origin as the current location
29876
+ *
29877
+ * @param {String} requestURL The URL to test
29878
+ * @returns {boolean} True if URL shares the same origin, otherwise false
29879
+ */
29880
+ return function isURLSameOrigin(requestURL) {
29881
+ var parsed = (utils$9.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
29882
+ return (parsed.protocol === originURL.protocol &&
29883
+ parsed.host === originURL.host);
29884
+ };
29885
+ })() :
29886
+
29887
+ // Non standard browser envs (web workers, react-native) lack needed support.
29888
+ (function nonStandardBrowserEnv() {
29889
+ return function isURLSameOrigin() {
29890
+ return true;
29891
+ };
29892
+ })()
29893
+ );
29894
+
29895
+ /**
29896
+ * A `Cancel` is an object that is thrown when an operation is canceled.
29897
+ *
29898
+ * @class
29899
+ * @param {string=} message The message.
29900
+ */
29901
+ function Cancel$4(message) {
29902
+ this.message = message;
29903
+ }
29904
+
29905
+ Cancel$4.prototype.toString = function toString() {
29906
+ return 'Cancel' + (this.message ? ': ' + this.message : '');
29907
+ };
29908
+
29909
+ Cancel$4.prototype.__CANCEL__ = true;
29910
+
29911
+ var Cancel_1 = Cancel$4;
29912
+
29913
+ var utils$8 = utils$f;
29914
+ var settle$1 = settle$2;
29915
+ var cookies = cookies$1;
29916
+ var buildURL$2 = buildURL$3;
29917
+ var buildFullPath$1 = buildFullPath$2;
29918
+ var parseHeaders = parseHeaders$1;
29919
+ var isURLSameOrigin = isURLSameOrigin$1;
29920
+ var createError$1 = createError$3;
29921
+ var transitionalDefaults$2 = transitional;
29922
+ var Cancel$3 = Cancel_1;
29923
+
29924
+ var xhr = function xhrAdapter(config) {
29925
+ return new Promise(function dispatchXhrRequest(resolve, reject) {
29926
+ var requestData = config.data;
29927
+ var requestHeaders = config.headers;
29928
+ var responseType = config.responseType;
29929
+ var onCanceled;
29930
+ function done() {
29931
+ if (config.cancelToken) {
29932
+ config.cancelToken.unsubscribe(onCanceled);
29933
+ }
29934
+
29935
+ if (config.signal) {
29936
+ config.signal.removeEventListener('abort', onCanceled);
29937
+ }
29938
+ }
29939
+
29940
+ if (utils$8.isFormData(requestData)) {
29941
+ delete requestHeaders['Content-Type']; // Let the browser set it
29942
+ }
29943
+
29944
+ var request = new XMLHttpRequest();
29945
+
29946
+ // HTTP basic authentication
29947
+ if (config.auth) {
29948
+ var username = config.auth.username || '';
29949
+ var password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : '';
29950
+ requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password);
29951
+ }
29952
+
29953
+ var fullPath = buildFullPath$1(config.baseURL, config.url);
29954
+ request.open(config.method.toUpperCase(), buildURL$2(fullPath, config.params, config.paramsSerializer), true);
29955
+
29956
+ // Set the request timeout in MS
29957
+ request.timeout = config.timeout;
29958
+
29959
+ function onloadend() {
29960
+ if (!request) {
29961
+ return;
29962
+ }
29963
+ // Prepare the response
29964
+ var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null;
29965
+ var responseData = !responseType || responseType === 'text' || responseType === 'json' ?
29966
+ request.responseText : request.response;
29967
+ var response = {
29968
+ data: responseData,
29969
+ status: request.status,
29970
+ statusText: request.statusText,
29971
+ headers: responseHeaders,
29972
+ config: config,
29973
+ request: request
29974
+ };
29975
+
29976
+ settle$1(function _resolve(value) {
29977
+ resolve(value);
29978
+ done();
29979
+ }, function _reject(err) {
29980
+ reject(err);
29981
+ done();
29982
+ }, response);
29983
+
29984
+ // Clean up request
29985
+ request = null;
29986
+ }
29987
+
29988
+ if ('onloadend' in request) {
29989
+ // Use onloadend if available
29990
+ request.onloadend = onloadend;
29991
+ } else {
29992
+ // Listen for ready state to emulate onloadend
29993
+ request.onreadystatechange = function handleLoad() {
29994
+ if (!request || request.readyState !== 4) {
29995
+ return;
29996
+ }
29997
+
29998
+ // The request errored out and we didn't get a response, this will be
29999
+ // handled by onerror instead
30000
+ // With one exception: request that using file: protocol, most browsers
30001
+ // will return status as 0 even though it's a successful request
30002
+ if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
30003
+ return;
30004
+ }
30005
+ // readystate handler is calling before onerror or ontimeout handlers,
30006
+ // so we should call onloadend on the next 'tick'
30007
+ setTimeout(onloadend);
30008
+ };
30009
+ }
30010
+
30011
+ // Handle browser request cancellation (as opposed to a manual cancellation)
30012
+ request.onabort = function handleAbort() {
30013
+ if (!request) {
30014
+ return;
30015
+ }
30016
+
30017
+ reject(createError$1('Request aborted', config, 'ECONNABORTED', request));
30018
+
30019
+ // Clean up request
30020
+ request = null;
30021
+ };
30022
+
30023
+ // Handle low level network errors
30024
+ request.onerror = function handleError() {
30025
+ // Real errors are hidden from us by the browser
30026
+ // onerror should only fire if it's a network error
30027
+ reject(createError$1('Network Error', config, null, request));
30028
+
30029
+ // Clean up request
30030
+ request = null;
30031
+ };
30032
+
30033
+ // Handle timeout
30034
+ request.ontimeout = function handleTimeout() {
30035
+ var timeoutErrorMessage = config.timeout ? 'timeout of ' + config.timeout + 'ms exceeded' : 'timeout exceeded';
30036
+ var transitional = config.transitional || transitionalDefaults$2;
30037
+ if (config.timeoutErrorMessage) {
30038
+ timeoutErrorMessage = config.timeoutErrorMessage;
30039
+ }
30040
+ reject(createError$1(
30041
+ timeoutErrorMessage,
30042
+ config,
30043
+ transitional.clarifyTimeoutError ? 'ETIMEDOUT' : 'ECONNABORTED',
30044
+ request));
30045
+
30046
+ // Clean up request
30047
+ request = null;
30048
+ };
30049
+
30050
+ // Add xsrf header
30051
+ // This is only done if running in a standard browser environment.
30052
+ // Specifically not if we're in a web worker, or react-native.
30053
+ if (utils$8.isStandardBrowserEnv()) {
30054
+ // Add xsrf header
30055
+ var xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath)) && config.xsrfCookieName ?
30056
+ cookies.read(config.xsrfCookieName) :
30057
+ undefined;
30058
+
30059
+ if (xsrfValue) {
30060
+ requestHeaders[config.xsrfHeaderName] = xsrfValue;
30061
+ }
30062
+ }
30063
+
30064
+ // Add headers to the request
30065
+ if ('setRequestHeader' in request) {
30066
+ utils$8.forEach(requestHeaders, function setRequestHeader(val, key) {
30067
+ if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') {
30068
+ // Remove Content-Type if data is undefined
30069
+ delete requestHeaders[key];
30070
+ } else {
30071
+ // Otherwise add header to the request
30072
+ request.setRequestHeader(key, val);
30073
+ }
30074
+ });
30075
+ }
30076
+
30077
+ // Add withCredentials to request if needed
30078
+ if (!utils$8.isUndefined(config.withCredentials)) {
30079
+ request.withCredentials = !!config.withCredentials;
30080
+ }
30081
+
30082
+ // Add responseType to request if needed
30083
+ if (responseType && responseType !== 'json') {
30084
+ request.responseType = config.responseType;
30085
+ }
30086
+
30087
+ // Handle progress if needed
30088
+ if (typeof config.onDownloadProgress === 'function') {
30089
+ request.addEventListener('progress', config.onDownloadProgress);
30090
+ }
30091
+
30092
+ // Not all browsers support upload events
30093
+ if (typeof config.onUploadProgress === 'function' && request.upload) {
30094
+ request.upload.addEventListener('progress', config.onUploadProgress);
30095
+ }
30096
+
30097
+ if (config.cancelToken || config.signal) {
30098
+ // Handle cancellation
30099
+ // eslint-disable-next-line func-names
30100
+ onCanceled = function(cancel) {
30101
+ if (!request) {
30102
+ return;
30103
+ }
30104
+ reject(!cancel || (cancel && cancel.type) ? new Cancel$3('canceled') : cancel);
30105
+ request.abort();
30106
+ request = null;
30107
+ };
30108
+
30109
+ config.cancelToken && config.cancelToken.subscribe(onCanceled);
30110
+ if (config.signal) {
30111
+ config.signal.aborted ? onCanceled() : config.signal.addEventListener('abort', onCanceled);
30112
+ }
30113
+ }
30114
+
30115
+ if (!requestData) {
30116
+ requestData = null;
30117
+ }
30118
+
30119
+ // Send the request
30120
+ request.send(requestData);
30121
+ });
30122
+ };
30123
+
30124
+ var followRedirects = {exports: {}};
30125
+
30126
+ var debug$1;
30127
+
30128
+ var debug_1 = function () {
30129
+ if (!debug$1) {
30130
+ try {
30131
+ /* eslint global-require: off */
30132
+ debug$1 = require("debug")("follow-redirects");
30133
+ }
30134
+ catch (error) { /* */ }
30135
+ if (typeof debug$1 !== "function") {
30136
+ debug$1 = function () { /* */ };
30137
+ }
30138
+ }
30139
+ debug$1.apply(null, arguments);
30140
+ };
30141
+
30142
+ var url$1 = require$$0__default["default"];
30143
+ var URL = url$1.URL;
30144
+ var http$1 = require$$1__default["default"];
30145
+ var https$1 = require$$2__default$1["default"];
30146
+ var Writable = require$$3__default["default"].Writable;
30147
+ var assert = require$$4__default["default"];
30148
+ var debug = debug_1;
30149
+
30150
+ // Create handlers that pass events from native requests
30151
+ var events = ["abort", "aborted", "connect", "error", "socket", "timeout"];
30152
+ var eventHandlers = Object.create(null);
30153
+ events.forEach(function (event) {
30154
+ eventHandlers[event] = function (arg1, arg2, arg3) {
30155
+ this._redirectable.emit(event, arg1, arg2, arg3);
30156
+ };
30157
+ });
30158
+
30159
+ var InvalidUrlError = createErrorType(
30160
+ "ERR_INVALID_URL",
30161
+ "Invalid URL",
30162
+ TypeError
30163
+ );
30164
+ // Error types with codes
30165
+ var RedirectionError = createErrorType(
30166
+ "ERR_FR_REDIRECTION_FAILURE",
30167
+ "Redirected request failed"
30168
+ );
30169
+ var TooManyRedirectsError = createErrorType(
30170
+ "ERR_FR_TOO_MANY_REDIRECTS",
30171
+ "Maximum number of redirects exceeded"
30172
+ );
30173
+ var MaxBodyLengthExceededError = createErrorType(
30174
+ "ERR_FR_MAX_BODY_LENGTH_EXCEEDED",
30175
+ "Request body larger than maxBodyLength limit"
30176
+ );
30177
+ var WriteAfterEndError = createErrorType(
30178
+ "ERR_STREAM_WRITE_AFTER_END",
30179
+ "write after end"
30180
+ );
30181
+
30182
+ // An HTTP(S) request that can be redirected
30183
+ function RedirectableRequest(options, responseCallback) {
30184
+ // Initialize the request
30185
+ Writable.call(this);
30186
+ this._sanitizeOptions(options);
30187
+ this._options = options;
30188
+ this._ended = false;
30189
+ this._ending = false;
30190
+ this._redirectCount = 0;
30191
+ this._redirects = [];
30192
+ this._requestBodyLength = 0;
30193
+ this._requestBodyBuffers = [];
30194
+
30195
+ // Attach a callback if passed
30196
+ if (responseCallback) {
30197
+ this.on("response", responseCallback);
30198
+ }
30199
+
30200
+ // React to responses of native requests
30201
+ var self = this;
30202
+ this._onNativeResponse = function (response) {
30203
+ self._processResponse(response);
30204
+ };
30205
+
30206
+ // Perform the first request
30207
+ this._performRequest();
30208
+ }
30209
+ RedirectableRequest.prototype = Object.create(Writable.prototype);
30210
+
30211
+ RedirectableRequest.prototype.abort = function () {
30212
+ abortRequest(this._currentRequest);
30213
+ this.emit("abort");
30214
+ };
30215
+
30216
+ // Writes buffered data to the current native request
30217
+ RedirectableRequest.prototype.write = function (data, encoding, callback) {
30218
+ // Writing is not allowed if end has been called
30219
+ if (this._ending) {
30220
+ throw new WriteAfterEndError();
30221
+ }
30222
+
30223
+ // Validate input and shift parameters if necessary
30224
+ if (!isString(data) && !isBuffer(data)) {
30225
+ throw new TypeError("data should be a string, Buffer or Uint8Array");
30226
+ }
30227
+ if (isFunction(encoding)) {
30228
+ callback = encoding;
30229
+ encoding = null;
30230
+ }
30231
+
30232
+ // Ignore empty buffers, since writing them doesn't invoke the callback
30233
+ // https://github.com/nodejs/node/issues/22066
30234
+ if (data.length === 0) {
30235
+ if (callback) {
30236
+ callback();
30237
+ }
30238
+ return;
30239
+ }
30240
+ // Only write when we don't exceed the maximum body length
30241
+ if (this._requestBodyLength + data.length <= this._options.maxBodyLength) {
30242
+ this._requestBodyLength += data.length;
30243
+ this._requestBodyBuffers.push({ data: data, encoding: encoding });
30244
+ this._currentRequest.write(data, encoding, callback);
30245
+ }
30246
+ // Error when we exceed the maximum body length
30247
+ else {
30248
+ this.emit("error", new MaxBodyLengthExceededError());
30249
+ this.abort();
30250
+ }
30251
+ };
30252
+
30253
+ // Ends the current native request
30254
+ RedirectableRequest.prototype.end = function (data, encoding, callback) {
30255
+ // Shift parameters if necessary
30256
+ if (isFunction(data)) {
30257
+ callback = data;
30258
+ data = encoding = null;
30259
+ }
30260
+ else if (isFunction(encoding)) {
30261
+ callback = encoding;
30262
+ encoding = null;
30263
+ }
30264
+
30265
+ // Write data if needed and end
30266
+ if (!data) {
30267
+ this._ended = this._ending = true;
30268
+ this._currentRequest.end(null, null, callback);
30269
+ }
30270
+ else {
30271
+ var self = this;
30272
+ var currentRequest = this._currentRequest;
30273
+ this.write(data, encoding, function () {
30274
+ self._ended = true;
30275
+ currentRequest.end(null, null, callback);
30276
+ });
30277
+ this._ending = true;
30278
+ }
30279
+ };
30280
+
30281
+ // Sets a header value on the current native request
30282
+ RedirectableRequest.prototype.setHeader = function (name, value) {
30283
+ this._options.headers[name] = value;
30284
+ this._currentRequest.setHeader(name, value);
30285
+ };
30286
+
30287
+ // Clears a header value on the current native request
30288
+ RedirectableRequest.prototype.removeHeader = function (name) {
30289
+ delete this._options.headers[name];
30290
+ this._currentRequest.removeHeader(name);
30291
+ };
30292
+
30293
+ // Global timeout for all underlying requests
30294
+ RedirectableRequest.prototype.setTimeout = function (msecs, callback) {
30295
+ var self = this;
30296
+
30297
+ // Destroys the socket on timeout
30298
+ function destroyOnTimeout(socket) {
30299
+ socket.setTimeout(msecs);
30300
+ socket.removeListener("timeout", socket.destroy);
30301
+ socket.addListener("timeout", socket.destroy);
30302
+ }
30303
+
30304
+ // Sets up a timer to trigger a timeout event
30305
+ function startTimer(socket) {
30306
+ if (self._timeout) {
30307
+ clearTimeout(self._timeout);
30308
+ }
30309
+ self._timeout = setTimeout(function () {
30310
+ self.emit("timeout");
30311
+ clearTimer();
30312
+ }, msecs);
30313
+ destroyOnTimeout(socket);
30314
+ }
30315
+
30316
+ // Stops a timeout from triggering
30317
+ function clearTimer() {
30318
+ // Clear the timeout
30319
+ if (self._timeout) {
30320
+ clearTimeout(self._timeout);
30321
+ self._timeout = null;
30322
+ }
30323
+
30324
+ // Clean up all attached listeners
30325
+ self.removeListener("abort", clearTimer);
30326
+ self.removeListener("error", clearTimer);
30327
+ self.removeListener("response", clearTimer);
30328
+ if (callback) {
30329
+ self.removeListener("timeout", callback);
30330
+ }
30331
+ if (!self.socket) {
30332
+ self._currentRequest.removeListener("socket", startTimer);
30333
+ }
30334
+ }
30335
+
30336
+ // Attach callback if passed
30337
+ if (callback) {
30338
+ this.on("timeout", callback);
30339
+ }
30340
+
30341
+ // Start the timer if or when the socket is opened
30342
+ if (this.socket) {
30343
+ startTimer(this.socket);
30344
+ }
30345
+ else {
30346
+ this._currentRequest.once("socket", startTimer);
30347
+ }
30348
+
30349
+ // Clean up on events
30350
+ this.on("socket", destroyOnTimeout);
30351
+ this.on("abort", clearTimer);
30352
+ this.on("error", clearTimer);
30353
+ this.on("response", clearTimer);
30354
+
30355
+ return this;
30356
+ };
30357
+
30358
+ // Proxy all other public ClientRequest methods
30359
+ [
30360
+ "flushHeaders", "getHeader",
30361
+ "setNoDelay", "setSocketKeepAlive",
30362
+ ].forEach(function (method) {
30363
+ RedirectableRequest.prototype[method] = function (a, b) {
30364
+ return this._currentRequest[method](a, b);
30365
+ };
30366
+ });
30367
+
30368
+ // Proxy all public ClientRequest properties
30369
+ ["aborted", "connection", "socket"].forEach(function (property) {
30370
+ Object.defineProperty(RedirectableRequest.prototype, property, {
30371
+ get: function () { return this._currentRequest[property]; },
30372
+ });
30373
+ });
30374
+
30375
+ RedirectableRequest.prototype._sanitizeOptions = function (options) {
30376
+ // Ensure headers are always present
30377
+ if (!options.headers) {
30378
+ options.headers = {};
30379
+ }
30380
+
30381
+ // Since http.request treats host as an alias of hostname,
30382
+ // but the url module interprets host as hostname plus port,
30383
+ // eliminate the host property to avoid confusion.
30384
+ if (options.host) {
30385
+ // Use hostname if set, because it has precedence
30386
+ if (!options.hostname) {
30387
+ options.hostname = options.host;
30388
+ }
30389
+ delete options.host;
30390
+ }
30391
+
30392
+ // Complete the URL object when necessary
30393
+ if (!options.pathname && options.path) {
30394
+ var searchPos = options.path.indexOf("?");
30395
+ if (searchPos < 0) {
30396
+ options.pathname = options.path;
30397
+ }
30398
+ else {
30399
+ options.pathname = options.path.substring(0, searchPos);
30400
+ options.search = options.path.substring(searchPos);
30401
+ }
30402
+ }
30403
+ };
30404
+
30405
+
30406
+ // Executes the next native request (initial or redirect)
30407
+ RedirectableRequest.prototype._performRequest = function () {
30408
+ // Load the native protocol
30409
+ var protocol = this._options.protocol;
30410
+ var nativeProtocol = this._options.nativeProtocols[protocol];
30411
+ if (!nativeProtocol) {
30412
+ this.emit("error", new TypeError("Unsupported protocol " + protocol));
30413
+ return;
30414
+ }
30415
+
30416
+ // If specified, use the agent corresponding to the protocol
30417
+ // (HTTP and HTTPS use different types of agents)
30418
+ if (this._options.agents) {
30419
+ var scheme = protocol.slice(0, -1);
30420
+ this._options.agent = this._options.agents[scheme];
30421
+ }
30422
+
30423
+ // Create the native request and set up its event handlers
30424
+ var request = this._currentRequest =
30425
+ nativeProtocol.request(this._options, this._onNativeResponse);
30426
+ request._redirectable = this;
30427
+ for (var event of events) {
30428
+ request.on(event, eventHandlers[event]);
30429
+ }
30430
+
30431
+ // RFC7230§5.3.1: When making a request directly to an origin server, […]
30432
+ // a client MUST send only the absolute path […] as the request-target.
30433
+ this._currentUrl = /^\//.test(this._options.path) ?
30434
+ url$1.format(this._options) :
30435
+ // When making a request to a proxy, […]
30436
+ // a client MUST send the target URI in absolute-form […].
30437
+ this._options.path;
30438
+
30439
+ // End a redirected request
30440
+ // (The first request must be ended explicitly with RedirectableRequest#end)
30441
+ if (this._isRedirect) {
30442
+ // Write the request entity and end
30443
+ var i = 0;
30444
+ var self = this;
30445
+ var buffers = this._requestBodyBuffers;
30446
+ (function writeNext(error) {
30447
+ // Only write if this request has not been redirected yet
30448
+ /* istanbul ignore else */
30449
+ if (request === self._currentRequest) {
30450
+ // Report any write errors
30451
+ /* istanbul ignore if */
30452
+ if (error) {
30453
+ self.emit("error", error);
30454
+ }
30455
+ // Write the next buffer if there are still left
30456
+ else if (i < buffers.length) {
30457
+ var buffer = buffers[i++];
30458
+ /* istanbul ignore else */
30459
+ if (!request.finished) {
30460
+ request.write(buffer.data, buffer.encoding, writeNext);
30461
+ }
30462
+ }
30463
+ // End the request if `end` has been called on us
30464
+ else if (self._ended) {
30465
+ request.end();
30466
+ }
30467
+ }
30468
+ }());
30469
+ }
30470
+ };
30471
+
30472
+ // Processes a response from the current native request
30473
+ RedirectableRequest.prototype._processResponse = function (response) {
30474
+ // Store the redirected response
30475
+ var statusCode = response.statusCode;
30476
+ if (this._options.trackRedirects) {
30477
+ this._redirects.push({
30478
+ url: this._currentUrl,
30479
+ headers: response.headers,
30480
+ statusCode: statusCode,
30481
+ });
30482
+ }
30483
+
30484
+ // RFC7231§6.4: The 3xx (Redirection) class of status code indicates
30485
+ // that further action needs to be taken by the user agent in order to
30486
+ // fulfill the request. If a Location header field is provided,
30487
+ // the user agent MAY automatically redirect its request to the URI
30488
+ // referenced by the Location field value,
30489
+ // even if the specific status code is not understood.
30490
+
30491
+ // If the response is not a redirect; return it as-is
30492
+ var location = response.headers.location;
30493
+ if (!location || this._options.followRedirects === false ||
30494
+ statusCode < 300 || statusCode >= 400) {
30495
+ response.responseUrl = this._currentUrl;
30496
+ response.redirects = this._redirects;
30497
+ this.emit("response", response);
30498
+
30499
+ // Clean up
30500
+ this._requestBodyBuffers = [];
30501
+ return;
30502
+ }
30503
+
30504
+ // The response is a redirect, so abort the current request
30505
+ abortRequest(this._currentRequest);
30506
+ // Discard the remainder of the response to avoid waiting for data
30507
+ response.destroy();
30508
+
30509
+ // RFC7231§6.4: A client SHOULD detect and intervene
30510
+ // in cyclical redirections (i.e., "infinite" redirection loops).
30511
+ if (++this._redirectCount > this._options.maxRedirects) {
30512
+ this.emit("error", new TooManyRedirectsError());
30513
+ return;
30514
+ }
30515
+
30516
+ // Store the request headers if applicable
30517
+ var requestHeaders;
30518
+ var beforeRedirect = this._options.beforeRedirect;
30519
+ if (beforeRedirect) {
30520
+ requestHeaders = Object.assign({
30521
+ // The Host header was set by nativeProtocol.request
30522
+ Host: response.req.getHeader("host"),
30523
+ }, this._options.headers);
30524
+ }
30525
+
30526
+ // RFC7231§6.4: Automatic redirection needs to done with
30527
+ // care for methods not known to be safe, […]
30528
+ // RFC7231§6.4.2–3: For historical reasons, a user agent MAY change
30529
+ // the request method from POST to GET for the subsequent request.
30530
+ var method = this._options.method;
30531
+ if ((statusCode === 301 || statusCode === 302) && this._options.method === "POST" ||
30532
+ // RFC7231§6.4.4: The 303 (See Other) status code indicates that
30533
+ // the server is redirecting the user agent to a different resource […]
30534
+ // A user agent can perform a retrieval request targeting that URI
30535
+ // (a GET or HEAD request if using HTTP) […]
30536
+ (statusCode === 303) && !/^(?:GET|HEAD)$/.test(this._options.method)) {
30537
+ this._options.method = "GET";
30538
+ // Drop a possible entity and headers related to it
30539
+ this._requestBodyBuffers = [];
30540
+ removeMatchingHeaders(/^content-/i, this._options.headers);
30541
+ }
30542
+
30543
+ // Drop the Host header, as the redirect might lead to a different host
30544
+ var currentHostHeader = removeMatchingHeaders(/^host$/i, this._options.headers);
30545
+
30546
+ // If the redirect is relative, carry over the host of the last request
30547
+ var currentUrlParts = url$1.parse(this._currentUrl);
30548
+ var currentHost = currentHostHeader || currentUrlParts.host;
30549
+ var currentUrl = /^\w+:/.test(location) ? this._currentUrl :
30550
+ url$1.format(Object.assign(currentUrlParts, { host: currentHost }));
30551
+
30552
+ // Determine the URL of the redirection
30553
+ var redirectUrl;
30554
+ try {
30555
+ redirectUrl = url$1.resolve(currentUrl, location);
30556
+ }
30557
+ catch (cause) {
30558
+ this.emit("error", new RedirectionError({ cause: cause }));
30559
+ return;
30560
+ }
30561
+
30562
+ // Create the redirected request
30563
+ debug("redirecting to", redirectUrl);
30564
+ this._isRedirect = true;
30565
+ var redirectUrlParts = url$1.parse(redirectUrl);
30566
+ Object.assign(this._options, redirectUrlParts);
30567
+
30568
+ // Drop confidential headers when redirecting to a less secure protocol
30569
+ // or to a different domain that is not a superdomain
30570
+ if (redirectUrlParts.protocol !== currentUrlParts.protocol &&
30571
+ redirectUrlParts.protocol !== "https:" ||
30572
+ redirectUrlParts.host !== currentHost &&
30573
+ !isSubdomain(redirectUrlParts.host, currentHost)) {
30574
+ removeMatchingHeaders(/^(?:authorization|cookie)$/i, this._options.headers);
30575
+ }
30576
+
30577
+ // Evaluate the beforeRedirect callback
30578
+ if (isFunction(beforeRedirect)) {
30579
+ var responseDetails = {
30580
+ headers: response.headers,
30581
+ statusCode: statusCode,
30582
+ };
30583
+ var requestDetails = {
30584
+ url: currentUrl,
30585
+ method: method,
30586
+ headers: requestHeaders,
30587
+ };
30588
+ try {
30589
+ beforeRedirect(this._options, responseDetails, requestDetails);
30590
+ }
30591
+ catch (err) {
30592
+ this.emit("error", err);
30593
+ return;
30594
+ }
30595
+ this._sanitizeOptions(this._options);
30596
+ }
30597
+
30598
+ // Perform the redirected request
30599
+ try {
30600
+ this._performRequest();
30601
+ }
30602
+ catch (cause) {
30603
+ this.emit("error", new RedirectionError({ cause: cause }));
30604
+ }
30605
+ };
30606
+
30607
+ // Wraps the key/value object of protocols with redirect functionality
30608
+ function wrap(protocols) {
30609
+ // Default settings
30610
+ var exports = {
30611
+ maxRedirects: 21,
30612
+ maxBodyLength: 10 * 1024 * 1024,
30613
+ };
30614
+
30615
+ // Wrap each protocol
30616
+ var nativeProtocols = {};
30617
+ Object.keys(protocols).forEach(function (scheme) {
30618
+ var protocol = scheme + ":";
30619
+ var nativeProtocol = nativeProtocols[protocol] = protocols[scheme];
30620
+ var wrappedProtocol = exports[scheme] = Object.create(nativeProtocol);
30621
+
30622
+ // Executes a request, following redirects
30623
+ function request(input, options, callback) {
30624
+ // Parse parameters
30625
+ if (isString(input)) {
30626
+ var parsed;
30627
+ try {
30628
+ parsed = urlToOptions(new URL(input));
30629
+ }
30630
+ catch (err) {
30631
+ /* istanbul ignore next */
30632
+ parsed = url$1.parse(input);
30633
+ }
30634
+ if (!isString(parsed.protocol)) {
30635
+ throw new InvalidUrlError({ input });
30636
+ }
30637
+ input = parsed;
30638
+ }
30639
+ else if (URL && (input instanceof URL)) {
30640
+ input = urlToOptions(input);
30641
+ }
30642
+ else {
30643
+ callback = options;
30644
+ options = input;
30645
+ input = { protocol: protocol };
30646
+ }
30647
+ if (isFunction(options)) {
30648
+ callback = options;
30649
+ options = null;
30650
+ }
30651
+
30652
+ // Set defaults
30653
+ options = Object.assign({
30654
+ maxRedirects: exports.maxRedirects,
30655
+ maxBodyLength: exports.maxBodyLength,
30656
+ }, input, options);
30657
+ options.nativeProtocols = nativeProtocols;
30658
+ if (!isString(options.host) && !isString(options.hostname)) {
30659
+ options.hostname = "::1";
30660
+ }
30661
+
30662
+ assert.equal(options.protocol, protocol, "protocol mismatch");
30663
+ debug("options", options);
30664
+ return new RedirectableRequest(options, callback);
30665
+ }
30666
+
30667
+ // Executes a GET request, following redirects
30668
+ function get(input, options, callback) {
30669
+ var wrappedRequest = wrappedProtocol.request(input, options, callback);
30670
+ wrappedRequest.end();
30671
+ return wrappedRequest;
30672
+ }
30673
+
30674
+ // Expose the properties on the wrapped protocol
30675
+ Object.defineProperties(wrappedProtocol, {
30676
+ request: { value: request, configurable: true, enumerable: true, writable: true },
30677
+ get: { value: get, configurable: true, enumerable: true, writable: true },
30678
+ });
30679
+ });
30680
+ return exports;
30681
+ }
30682
+
30683
+ /* istanbul ignore next */
30684
+ function noop() { /* empty */ }
30685
+
30686
+ // from https://github.com/nodejs/node/blob/master/lib/internal/url.js
30687
+ function urlToOptions(urlObject) {
30688
+ var options = {
30689
+ protocol: urlObject.protocol,
30690
+ hostname: urlObject.hostname.startsWith("[") ?
30691
+ /* istanbul ignore next */
30692
+ urlObject.hostname.slice(1, -1) :
30693
+ urlObject.hostname,
30694
+ hash: urlObject.hash,
30695
+ search: urlObject.search,
30696
+ pathname: urlObject.pathname,
30697
+ path: urlObject.pathname + urlObject.search,
30698
+ href: urlObject.href,
30699
+ };
30700
+ if (urlObject.port !== "") {
30701
+ options.port = Number(urlObject.port);
30702
+ }
30703
+ return options;
30704
+ }
30705
+
30706
+ function removeMatchingHeaders(regex, headers) {
30707
+ var lastValue;
30708
+ for (var header in headers) {
30709
+ if (regex.test(header)) {
30710
+ lastValue = headers[header];
30711
+ delete headers[header];
30712
+ }
30713
+ }
30714
+ return (lastValue === null || typeof lastValue === "undefined") ?
30715
+ undefined : String(lastValue).trim();
30716
+ }
30717
+
30718
+ function createErrorType(code, message, baseClass) {
30719
+ // Create constructor
30720
+ function CustomError(properties) {
30721
+ Error.captureStackTrace(this, this.constructor);
30722
+ Object.assign(this, properties || {});
30723
+ this.code = code;
30724
+ this.message = this.cause ? message + ": " + this.cause.message : message;
30725
+ }
30726
+
30727
+ // Attach constructor and set default properties
30728
+ CustomError.prototype = new (baseClass || Error)();
30729
+ CustomError.prototype.constructor = CustomError;
30730
+ CustomError.prototype.name = "Error [" + code + "]";
30731
+ return CustomError;
30732
+ }
30733
+
30734
+ function abortRequest(request) {
30735
+ for (var event of events) {
30736
+ request.removeListener(event, eventHandlers[event]);
30737
+ }
30738
+ request.on("error", noop);
30739
+ request.abort();
30740
+ }
30741
+
30742
+ function isSubdomain(subdomain, domain) {
30743
+ assert(isString(subdomain) && isString(domain));
30744
+ var dot = subdomain.length - domain.length - 1;
30745
+ return dot > 0 && subdomain[dot] === "." && subdomain.endsWith(domain);
30746
+ }
30747
+
30748
+ function isString(value) {
30749
+ return typeof value === "string" || value instanceof String;
30750
+ }
30751
+
30752
+ function isFunction(value) {
30753
+ return typeof value === "function";
30754
+ }
30755
+
30756
+ function isBuffer(value) {
30757
+ return typeof value === "object" && ("length" in value);
30758
+ }
30759
+
30760
+ // Exports
30761
+ followRedirects.exports = wrap({ http: http$1, https: https$1 });
30762
+ followRedirects.exports.wrap = wrap;
30763
+
30764
+ var data = {
30765
+ "version": "0.26.1"
30766
+ };
30767
+
30768
+ var utils$7 = utils$f;
30769
+ var settle = settle$2;
30770
+ var buildFullPath = buildFullPath$2;
30771
+ var buildURL$1 = buildURL$3;
30772
+ var http = require$$1__default["default"];
30773
+ var https = require$$2__default$1["default"];
30774
+ var httpFollow = followRedirects.exports.http;
30775
+ var httpsFollow = followRedirects.exports.https;
30776
+ var url = require$$0__default["default"];
30777
+ var zlib = require$$8__default["default"];
30778
+ var VERSION$1 = data.version;
30779
+ var createError = createError$3;
30780
+ var enhanceError$1 = enhanceError$3;
30781
+ var transitionalDefaults$1 = transitional;
30782
+ var Cancel$2 = Cancel_1;
30783
+
30784
+ var isHttps = /https:?/;
30785
+
30786
+ /**
30787
+ *
30788
+ * @param {http.ClientRequestArgs} options
30789
+ * @param {AxiosProxyConfig} proxy
30790
+ * @param {string} location
30791
+ */
30792
+ function setProxy(options, proxy, location) {
30793
+ options.hostname = proxy.host;
30794
+ options.host = proxy.host;
30795
+ options.port = proxy.port;
30796
+ options.path = location;
30797
+
30798
+ // Basic proxy authorization
30799
+ if (proxy.auth) {
30800
+ var base64 = Buffer.from(proxy.auth.username + ':' + proxy.auth.password, 'utf8').toString('base64');
30801
+ options.headers['Proxy-Authorization'] = 'Basic ' + base64;
30802
+ }
30803
+
30804
+ // If a proxy is used, any redirects must also pass through the proxy
30805
+ options.beforeRedirect = function beforeRedirect(redirection) {
30806
+ redirection.headers.host = redirection.host;
30807
+ setProxy(redirection, proxy, redirection.href);
30808
+ };
30809
+ }
30810
+
30811
+ /*eslint consistent-return:0*/
30812
+ var http_1 = function httpAdapter(config) {
30813
+ return new Promise(function dispatchHttpRequest(resolvePromise, rejectPromise) {
30814
+ var onCanceled;
30815
+ function done() {
30816
+ if (config.cancelToken) {
30817
+ config.cancelToken.unsubscribe(onCanceled);
30818
+ }
30819
+
30820
+ if (config.signal) {
30821
+ config.signal.removeEventListener('abort', onCanceled);
30822
+ }
30823
+ }
30824
+ var resolve = function resolve(value) {
30825
+ done();
30826
+ resolvePromise(value);
30827
+ };
30828
+ var rejected = false;
30829
+ var reject = function reject(value) {
30830
+ done();
30831
+ rejected = true;
30832
+ rejectPromise(value);
30833
+ };
30834
+ var data = config.data;
30835
+ var headers = config.headers;
30836
+ var headerNames = {};
30837
+
30838
+ Object.keys(headers).forEach(function storeLowerName(name) {
30839
+ headerNames[name.toLowerCase()] = name;
30840
+ });
30841
+
30842
+ // Set User-Agent (required by some servers)
30843
+ // See https://github.com/axios/axios/issues/69
30844
+ if ('user-agent' in headerNames) {
30845
+ // User-Agent is specified; handle case where no UA header is desired
30846
+ if (!headers[headerNames['user-agent']]) {
30847
+ delete headers[headerNames['user-agent']];
30848
+ }
30849
+ // Otherwise, use specified value
30850
+ } else {
30851
+ // Only set header if it hasn't been set in config
30852
+ headers['User-Agent'] = 'axios/' + VERSION$1;
30853
+ }
30854
+
30855
+ if (data && !utils$7.isStream(data)) {
30856
+ if (Buffer.isBuffer(data)) ; else if (utils$7.isArrayBuffer(data)) {
30857
+ data = Buffer.from(new Uint8Array(data));
30858
+ } else if (utils$7.isString(data)) {
30859
+ data = Buffer.from(data, 'utf-8');
30860
+ } else {
30861
+ return reject(createError(
30862
+ 'Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream',
30863
+ config
30864
+ ));
30865
+ }
30866
+
30867
+ if (config.maxBodyLength > -1 && data.length > config.maxBodyLength) {
30868
+ return reject(createError('Request body larger than maxBodyLength limit', config));
30869
+ }
30870
+
30871
+ // Add Content-Length header if data exists
30872
+ if (!headerNames['content-length']) {
30873
+ headers['Content-Length'] = data.length;
30874
+ }
30875
+ }
30876
+
30877
+ // HTTP basic authentication
30878
+ var auth = undefined;
30879
+ if (config.auth) {
30880
+ var username = config.auth.username || '';
30881
+ var password = config.auth.password || '';
30882
+ auth = username + ':' + password;
30883
+ }
30884
+
30885
+ // Parse url
30886
+ var fullPath = buildFullPath(config.baseURL, config.url);
30887
+ var parsed = url.parse(fullPath);
30888
+ var protocol = parsed.protocol || 'http:';
30889
+
30890
+ if (!auth && parsed.auth) {
30891
+ var urlAuth = parsed.auth.split(':');
30892
+ var urlUsername = urlAuth[0] || '';
30893
+ var urlPassword = urlAuth[1] || '';
30894
+ auth = urlUsername + ':' + urlPassword;
30895
+ }
30896
+
30897
+ if (auth && headerNames.authorization) {
30898
+ delete headers[headerNames.authorization];
30899
+ }
30900
+
30901
+ var isHttpsRequest = isHttps.test(protocol);
30902
+ var agent = isHttpsRequest ? config.httpsAgent : config.httpAgent;
30903
+
30904
+ try {
30905
+ buildURL$1(parsed.path, config.params, config.paramsSerializer).replace(/^\?/, '');
30906
+ } catch (err) {
30907
+ var customErr = new Error(err.message);
30908
+ customErr.config = config;
30909
+ customErr.url = config.url;
30910
+ customErr.exists = true;
30911
+ reject(customErr);
30912
+ }
30913
+
30914
+ var options = {
30915
+ path: buildURL$1(parsed.path, config.params, config.paramsSerializer).replace(/^\?/, ''),
30916
+ method: config.method.toUpperCase(),
30917
+ headers: headers,
30918
+ agent: agent,
30919
+ agents: { http: config.httpAgent, https: config.httpsAgent },
30920
+ auth: auth
30921
+ };
30922
+
30923
+ if (config.socketPath) {
30924
+ options.socketPath = config.socketPath;
30925
+ } else {
30926
+ options.hostname = parsed.hostname;
30927
+ options.port = parsed.port;
30928
+ }
30929
+
30930
+ var proxy = config.proxy;
30931
+ if (!proxy && proxy !== false) {
30932
+ var proxyEnv = protocol.slice(0, -1) + '_proxy';
30933
+ var proxyUrl = process.env[proxyEnv] || process.env[proxyEnv.toUpperCase()];
30934
+ if (proxyUrl) {
30935
+ var parsedProxyUrl = url.parse(proxyUrl);
30936
+ var noProxyEnv = process.env.no_proxy || process.env.NO_PROXY;
30937
+ var shouldProxy = true;
30938
+
30939
+ if (noProxyEnv) {
30940
+ var noProxy = noProxyEnv.split(',').map(function trim(s) {
30941
+ return s.trim();
30942
+ });
30943
+
30944
+ shouldProxy = !noProxy.some(function proxyMatch(proxyElement) {
30945
+ if (!proxyElement) {
30946
+ return false;
30947
+ }
30948
+ if (proxyElement === '*') {
30949
+ return true;
30950
+ }
30951
+ if (proxyElement[0] === '.' &&
30952
+ parsed.hostname.substr(parsed.hostname.length - proxyElement.length) === proxyElement) {
30953
+ return true;
30954
+ }
30955
+
30956
+ return parsed.hostname === proxyElement;
30957
+ });
30958
+ }
30959
+
30960
+ if (shouldProxy) {
30961
+ proxy = {
30962
+ host: parsedProxyUrl.hostname,
30963
+ port: parsedProxyUrl.port,
30964
+ protocol: parsedProxyUrl.protocol
30965
+ };
30966
+
30967
+ if (parsedProxyUrl.auth) {
30968
+ var proxyUrlAuth = parsedProxyUrl.auth.split(':');
30969
+ proxy.auth = {
30970
+ username: proxyUrlAuth[0],
30971
+ password: proxyUrlAuth[1]
30972
+ };
30973
+ }
30974
+ }
30975
+ }
30976
+ }
30977
+
30978
+ if (proxy) {
30979
+ options.headers.host = parsed.hostname + (parsed.port ? ':' + parsed.port : '');
30980
+ setProxy(options, proxy, protocol + '//' + parsed.hostname + (parsed.port ? ':' + parsed.port : '') + options.path);
30981
+ }
30982
+
30983
+ var transport;
30984
+ var isHttpsProxy = isHttpsRequest && (proxy ? isHttps.test(proxy.protocol) : true);
30985
+ if (config.transport) {
30986
+ transport = config.transport;
30987
+ } else if (config.maxRedirects === 0) {
30988
+ transport = isHttpsProxy ? https : http;
30989
+ } else {
30990
+ if (config.maxRedirects) {
30991
+ options.maxRedirects = config.maxRedirects;
30992
+ }
30993
+ transport = isHttpsProxy ? httpsFollow : httpFollow;
30994
+ }
30995
+
30996
+ if (config.maxBodyLength > -1) {
30997
+ options.maxBodyLength = config.maxBodyLength;
30998
+ }
30999
+
31000
+ if (config.insecureHTTPParser) {
31001
+ options.insecureHTTPParser = config.insecureHTTPParser;
31002
+ }
31003
+
31004
+ // Create the request
31005
+ var req = transport.request(options, function handleResponse(res) {
31006
+ if (req.aborted) return;
31007
+
31008
+ // uncompress the response body transparently if required
31009
+ var stream = res;
31010
+
31011
+ // return the last request in case of redirects
31012
+ var lastRequest = res.req || req;
31013
+
31014
+
31015
+ // if no content, is HEAD request or decompress disabled we should not decompress
31016
+ if (res.statusCode !== 204 && lastRequest.method !== 'HEAD' && config.decompress !== false) {
31017
+ switch (res.headers['content-encoding']) {
31018
+ /*eslint default-case:0*/
31019
+ case 'gzip':
31020
+ case 'compress':
31021
+ case 'deflate':
31022
+ // add the unzipper to the body stream processing pipeline
31023
+ stream = stream.pipe(zlib.createUnzip());
31024
+
31025
+ // remove the content-encoding in order to not confuse downstream operations
31026
+ delete res.headers['content-encoding'];
31027
+ break;
31028
+ }
31029
+ }
31030
+
31031
+ var response = {
31032
+ status: res.statusCode,
31033
+ statusText: res.statusMessage,
31034
+ headers: res.headers,
31035
+ config: config,
31036
+ request: lastRequest
31037
+ };
31038
+
31039
+ if (config.responseType === 'stream') {
31040
+ response.data = stream;
31041
+ settle(resolve, reject, response);
31042
+ } else {
31043
+ var responseBuffer = [];
31044
+ var totalResponseBytes = 0;
31045
+ stream.on('data', function handleStreamData(chunk) {
31046
+ responseBuffer.push(chunk);
31047
+ totalResponseBytes += chunk.length;
31048
+
31049
+ // make sure the content length is not over the maxContentLength if specified
31050
+ if (config.maxContentLength > -1 && totalResponseBytes > config.maxContentLength) {
31051
+ // stream.destoy() emit aborted event before calling reject() on Node.js v16
31052
+ rejected = true;
31053
+ stream.destroy();
31054
+ reject(createError('maxContentLength size of ' + config.maxContentLength + ' exceeded',
31055
+ config, null, lastRequest));
31056
+ }
31057
+ });
31058
+
31059
+ stream.on('aborted', function handlerStreamAborted() {
31060
+ if (rejected) {
31061
+ return;
31062
+ }
31063
+ stream.destroy();
31064
+ reject(createError('error request aborted', config, 'ERR_REQUEST_ABORTED', lastRequest));
31065
+ });
31066
+
31067
+ stream.on('error', function handleStreamError(err) {
31068
+ if (req.aborted) return;
31069
+ reject(enhanceError$1(err, config, null, lastRequest));
31070
+ });
31071
+
31072
+ stream.on('end', function handleStreamEnd() {
31073
+ try {
31074
+ var responseData = responseBuffer.length === 1 ? responseBuffer[0] : Buffer.concat(responseBuffer);
31075
+ if (config.responseType !== 'arraybuffer') {
31076
+ responseData = responseData.toString(config.responseEncoding);
31077
+ if (!config.responseEncoding || config.responseEncoding === 'utf8') {
31078
+ responseData = utils$7.stripBOM(responseData);
31079
+ }
31080
+ }
31081
+ response.data = responseData;
31082
+ } catch (err) {
31083
+ reject(enhanceError$1(err, config, err.code, response.request, response));
31084
+ }
31085
+ settle(resolve, reject, response);
31086
+ });
31087
+ }
31088
+ });
31089
+
31090
+ // Handle errors
31091
+ req.on('error', function handleRequestError(err) {
31092
+ if (req.aborted && err.code !== 'ERR_FR_TOO_MANY_REDIRECTS') return;
31093
+ reject(enhanceError$1(err, config, null, req));
31094
+ });
31095
+
31096
+ // set tcp keep alive to prevent drop connection by peer
31097
+ req.on('socket', function handleRequestSocket(socket) {
31098
+ // default interval of sending ack packet is 1 minute
31099
+ socket.setKeepAlive(true, 1000 * 60);
31100
+ });
31101
+
31102
+ // Handle request timeout
31103
+ if (config.timeout) {
31104
+ // This is forcing a int timeout to avoid problems if the `req` interface doesn't handle other types.
31105
+ var timeout = parseInt(config.timeout, 10);
31106
+
31107
+ if (isNaN(timeout)) {
31108
+ reject(createError(
31109
+ 'error trying to parse `config.timeout` to int',
31110
+ config,
31111
+ 'ERR_PARSE_TIMEOUT',
31112
+ req
31113
+ ));
31114
+
31115
+ return;
31116
+ }
31117
+
31118
+ // Sometime, the response will be very slow, and does not respond, the connect event will be block by event loop system.
31119
+ // And timer callback will be fired, and abort() will be invoked before connection, then get "socket hang up" and code ECONNRESET.
31120
+ // At this time, if we have a large number of request, nodejs will hang up some socket on background. and the number will up and up.
31121
+ // And then these socket which be hang up will devoring CPU little by little.
31122
+ // ClientRequest.setTimeout will be fired on the specify milliseconds, and can make sure that abort() will be fired after connect.
31123
+ req.setTimeout(timeout, function handleRequestTimeout() {
31124
+ req.abort();
31125
+ var timeoutErrorMessage = '';
31126
+ if (config.timeoutErrorMessage) {
31127
+ timeoutErrorMessage = config.timeoutErrorMessage;
31128
+ } else {
31129
+ timeoutErrorMessage = 'timeout of ' + config.timeout + 'ms exceeded';
31130
+ }
31131
+ var transitional = config.transitional || transitionalDefaults$1;
31132
+ reject(createError(
31133
+ timeoutErrorMessage,
31134
+ config,
31135
+ transitional.clarifyTimeoutError ? 'ETIMEDOUT' : 'ECONNABORTED',
31136
+ req
31137
+ ));
31138
+ });
31139
+ }
31140
+
31141
+ if (config.cancelToken || config.signal) {
31142
+ // Handle cancellation
31143
+ // eslint-disable-next-line func-names
31144
+ onCanceled = function(cancel) {
31145
+ if (req.aborted) return;
31146
+
31147
+ req.abort();
31148
+ reject(!cancel || (cancel && cancel.type) ? new Cancel$2('canceled') : cancel);
31149
+ };
31150
+
31151
+ config.cancelToken && config.cancelToken.subscribe(onCanceled);
31152
+ if (config.signal) {
31153
+ config.signal.aborted ? onCanceled() : config.signal.addEventListener('abort', onCanceled);
31154
+ }
31155
+ }
31156
+
31157
+
31158
+ // Send the request
31159
+ if (utils$7.isStream(data)) {
31160
+ data.on('error', function handleStreamError(err) {
31161
+ reject(enhanceError$1(err, config, null, req));
31162
+ }).pipe(req);
31163
+ } else {
31164
+ req.end(data);
31165
+ }
31166
+ });
31167
+ };
31168
+
31169
+ var utils$6 = utils$f;
31170
+ var normalizeHeaderName = normalizeHeaderName$1;
31171
+ var enhanceError = enhanceError$3;
31172
+ var transitionalDefaults = transitional;
31173
+
31174
+ var DEFAULT_CONTENT_TYPE = {
31175
+ 'Content-Type': 'application/x-www-form-urlencoded'
31176
+ };
31177
+
31178
+ function setContentTypeIfUnset(headers, value) {
31179
+ if (!utils$6.isUndefined(headers) && utils$6.isUndefined(headers['Content-Type'])) {
31180
+ headers['Content-Type'] = value;
31181
+ }
31182
+ }
31183
+
31184
+ function getDefaultAdapter() {
31185
+ var adapter;
31186
+ if (typeof XMLHttpRequest !== 'undefined') {
31187
+ // For browsers use XHR adapter
31188
+ adapter = xhr;
31189
+ } else if (typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]') {
31190
+ // For node use HTTP adapter
31191
+ adapter = http_1;
31192
+ }
31193
+ return adapter;
31194
+ }
31195
+
31196
+ function stringifySafely(rawValue, parser, encoder) {
31197
+ if (utils$6.isString(rawValue)) {
31198
+ try {
31199
+ (parser || JSON.parse)(rawValue);
31200
+ return utils$6.trim(rawValue);
31201
+ } catch (e) {
31202
+ if (e.name !== 'SyntaxError') {
31203
+ throw e;
31204
+ }
31205
+ }
31206
+ }
31207
+
31208
+ return (encoder || JSON.stringify)(rawValue);
31209
+ }
31210
+
31211
+ var defaults$3 = {
31212
+
31213
+ transitional: transitionalDefaults,
31214
+
31215
+ adapter: getDefaultAdapter(),
31216
+
31217
+ transformRequest: [function transformRequest(data, headers) {
31218
+ normalizeHeaderName(headers, 'Accept');
31219
+ normalizeHeaderName(headers, 'Content-Type');
31220
+
31221
+ if (utils$6.isFormData(data) ||
31222
+ utils$6.isArrayBuffer(data) ||
31223
+ utils$6.isBuffer(data) ||
31224
+ utils$6.isStream(data) ||
31225
+ utils$6.isFile(data) ||
31226
+ utils$6.isBlob(data)
31227
+ ) {
31228
+ return data;
31229
+ }
31230
+ if (utils$6.isArrayBufferView(data)) {
31231
+ return data.buffer;
31232
+ }
31233
+ if (utils$6.isURLSearchParams(data)) {
31234
+ setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8');
31235
+ return data.toString();
31236
+ }
31237
+ if (utils$6.isObject(data) || (headers && headers['Content-Type'] === 'application/json')) {
31238
+ setContentTypeIfUnset(headers, 'application/json');
31239
+ return stringifySafely(data);
31240
+ }
31241
+ return data;
31242
+ }],
31243
+
31244
+ transformResponse: [function transformResponse(data) {
31245
+ var transitional = this.transitional || defaults$3.transitional;
31246
+ var silentJSONParsing = transitional && transitional.silentJSONParsing;
31247
+ var forcedJSONParsing = transitional && transitional.forcedJSONParsing;
31248
+ var strictJSONParsing = !silentJSONParsing && this.responseType === 'json';
31249
+
31250
+ if (strictJSONParsing || (forcedJSONParsing && utils$6.isString(data) && data.length)) {
31251
+ try {
31252
+ return JSON.parse(data);
31253
+ } catch (e) {
31254
+ if (strictJSONParsing) {
31255
+ if (e.name === 'SyntaxError') {
31256
+ throw enhanceError(e, this, 'E_JSON_PARSE');
31257
+ }
31258
+ throw e;
31259
+ }
31260
+ }
31261
+ }
31262
+
31263
+ return data;
31264
+ }],
31265
+
31266
+ /**
31267
+ * A timeout in milliseconds to abort a request. If set to 0 (default) a
31268
+ * timeout is not created.
31269
+ */
31270
+ timeout: 0,
31271
+
31272
+ xsrfCookieName: 'XSRF-TOKEN',
31273
+ xsrfHeaderName: 'X-XSRF-TOKEN',
31274
+
31275
+ maxContentLength: -1,
31276
+ maxBodyLength: -1,
31277
+
31278
+ validateStatus: function validateStatus(status) {
31279
+ return status >= 200 && status < 300;
31280
+ },
31281
+
31282
+ headers: {
31283
+ common: {
31284
+ 'Accept': 'application/json, text/plain, */*'
31285
+ }
31286
+ }
31287
+ };
31288
+
31289
+ utils$6.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
31290
+ defaults$3.headers[method] = {};
31291
+ });
31292
+
31293
+ utils$6.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
31294
+ defaults$3.headers[method] = utils$6.merge(DEFAULT_CONTENT_TYPE);
31295
+ });
31296
+
31297
+ var defaults_1 = defaults$3;
31298
+
31299
+ var utils$5 = utils$f;
31300
+ var defaults$2 = defaults_1;
31301
+
31302
+ /**
31303
+ * Transform the data for a request or a response
31304
+ *
31305
+ * @param {Object|String} data The data to be transformed
31306
+ * @param {Array} headers The headers for the request or response
31307
+ * @param {Array|Function} fns A single function or Array of functions
31308
+ * @returns {*} The resulting transformed data
31309
+ */
31310
+ var transformData$1 = function transformData(data, headers, fns) {
31311
+ var context = this || defaults$2;
31312
+ /*eslint no-param-reassign:0*/
31313
+ utils$5.forEach(fns, function transform(fn) {
31314
+ data = fn.call(context, data, headers);
31315
+ });
31316
+
31317
+ return data;
31318
+ };
31319
+
31320
+ var isCancel$1 = function isCancel(value) {
31321
+ return !!(value && value.__CANCEL__);
31322
+ };
31323
+
31324
+ var utils$4 = utils$f;
31325
+ var transformData = transformData$1;
31326
+ var isCancel = isCancel$1;
31327
+ var defaults$1 = defaults_1;
31328
+ var Cancel$1 = Cancel_1;
31329
+
31330
+ /**
31331
+ * Throws a `Cancel` if cancellation has been requested.
31332
+ */
31333
+ function throwIfCancellationRequested(config) {
31334
+ if (config.cancelToken) {
31335
+ config.cancelToken.throwIfRequested();
31336
+ }
31337
+
31338
+ if (config.signal && config.signal.aborted) {
31339
+ throw new Cancel$1('canceled');
31340
+ }
31341
+ }
31342
+
31343
+ /**
31344
+ * Dispatch a request to the server using the configured adapter.
31345
+ *
31346
+ * @param {object} config The config that is to be used for the request
31347
+ * @returns {Promise} The Promise to be fulfilled
31348
+ */
31349
+ var dispatchRequest$1 = function dispatchRequest(config) {
31350
+ throwIfCancellationRequested(config);
31351
+
31352
+ // Ensure headers exist
31353
+ config.headers = config.headers || {};
31354
+
31355
+ // Transform request data
31356
+ config.data = transformData.call(
31357
+ config,
31358
+ config.data,
31359
+ config.headers,
31360
+ config.transformRequest
31361
+ );
31362
+
31363
+ // Flatten headers
31364
+ config.headers = utils$4.merge(
31365
+ config.headers.common || {},
31366
+ config.headers[config.method] || {},
31367
+ config.headers
31368
+ );
31369
+
31370
+ utils$4.forEach(
31371
+ ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
31372
+ function cleanHeaderConfig(method) {
31373
+ delete config.headers[method];
31374
+ }
31375
+ );
31376
+
31377
+ var adapter = config.adapter || defaults$1.adapter;
31378
+
31379
+ return adapter(config).then(function onAdapterResolution(response) {
31380
+ throwIfCancellationRequested(config);
31381
+
31382
+ // Transform response data
31383
+ response.data = transformData.call(
31384
+ config,
31385
+ response.data,
31386
+ response.headers,
31387
+ config.transformResponse
31388
+ );
31389
+
31390
+ return response;
31391
+ }, function onAdapterRejection(reason) {
31392
+ if (!isCancel(reason)) {
31393
+ throwIfCancellationRequested(config);
31394
+
31395
+ // Transform response data
31396
+ if (reason && reason.response) {
31397
+ reason.response.data = transformData.call(
31398
+ config,
31399
+ reason.response.data,
31400
+ reason.response.headers,
31401
+ config.transformResponse
31402
+ );
31403
+ }
31404
+ }
31405
+
31406
+ return Promise.reject(reason);
31407
+ });
31408
+ };
31409
+
31410
+ var utils$3 = utils$f;
31411
+
31412
+ /**
31413
+ * Config-specific merge-function which creates a new config-object
31414
+ * by merging two configuration objects together.
31415
+ *
31416
+ * @param {Object} config1
31417
+ * @param {Object} config2
31418
+ * @returns {Object} New object resulting from merging config2 to config1
31419
+ */
31420
+ var mergeConfig$2 = function mergeConfig(config1, config2) {
31421
+ // eslint-disable-next-line no-param-reassign
31422
+ config2 = config2 || {};
31423
+ var config = {};
31424
+
31425
+ function getMergedValue(target, source) {
31426
+ if (utils$3.isPlainObject(target) && utils$3.isPlainObject(source)) {
31427
+ return utils$3.merge(target, source);
31428
+ } else if (utils$3.isPlainObject(source)) {
31429
+ return utils$3.merge({}, source);
31430
+ } else if (utils$3.isArray(source)) {
31431
+ return source.slice();
31432
+ }
31433
+ return source;
31434
+ }
31435
+
31436
+ // eslint-disable-next-line consistent-return
31437
+ function mergeDeepProperties(prop) {
31438
+ if (!utils$3.isUndefined(config2[prop])) {
31439
+ return getMergedValue(config1[prop], config2[prop]);
31440
+ } else if (!utils$3.isUndefined(config1[prop])) {
31441
+ return getMergedValue(undefined, config1[prop]);
31442
+ }
31443
+ }
31444
+
31445
+ // eslint-disable-next-line consistent-return
31446
+ function valueFromConfig2(prop) {
31447
+ if (!utils$3.isUndefined(config2[prop])) {
31448
+ return getMergedValue(undefined, config2[prop]);
31449
+ }
31450
+ }
31451
+
31452
+ // eslint-disable-next-line consistent-return
31453
+ function defaultToConfig2(prop) {
31454
+ if (!utils$3.isUndefined(config2[prop])) {
31455
+ return getMergedValue(undefined, config2[prop]);
31456
+ } else if (!utils$3.isUndefined(config1[prop])) {
31457
+ return getMergedValue(undefined, config1[prop]);
31458
+ }
31459
+ }
31460
+
31461
+ // eslint-disable-next-line consistent-return
31462
+ function mergeDirectKeys(prop) {
31463
+ if (prop in config2) {
31464
+ return getMergedValue(config1[prop], config2[prop]);
31465
+ } else if (prop in config1) {
31466
+ return getMergedValue(undefined, config1[prop]);
31467
+ }
31468
+ }
31469
+
31470
+ var mergeMap = {
31471
+ 'url': valueFromConfig2,
31472
+ 'method': valueFromConfig2,
31473
+ 'data': valueFromConfig2,
31474
+ 'baseURL': defaultToConfig2,
31475
+ 'transformRequest': defaultToConfig2,
31476
+ 'transformResponse': defaultToConfig2,
31477
+ 'paramsSerializer': defaultToConfig2,
31478
+ 'timeout': defaultToConfig2,
31479
+ 'timeoutMessage': defaultToConfig2,
31480
+ 'withCredentials': defaultToConfig2,
31481
+ 'adapter': defaultToConfig2,
31482
+ 'responseType': defaultToConfig2,
31483
+ 'xsrfCookieName': defaultToConfig2,
31484
+ 'xsrfHeaderName': defaultToConfig2,
31485
+ 'onUploadProgress': defaultToConfig2,
31486
+ 'onDownloadProgress': defaultToConfig2,
31487
+ 'decompress': defaultToConfig2,
31488
+ 'maxContentLength': defaultToConfig2,
31489
+ 'maxBodyLength': defaultToConfig2,
31490
+ 'transport': defaultToConfig2,
31491
+ 'httpAgent': defaultToConfig2,
31492
+ 'httpsAgent': defaultToConfig2,
31493
+ 'cancelToken': defaultToConfig2,
31494
+ 'socketPath': defaultToConfig2,
31495
+ 'responseEncoding': defaultToConfig2,
31496
+ 'validateStatus': mergeDirectKeys
31497
+ };
31498
+
31499
+ utils$3.forEach(Object.keys(config1).concat(Object.keys(config2)), function computeConfigValue(prop) {
31500
+ var merge = mergeMap[prop] || mergeDeepProperties;
31501
+ var configValue = merge(prop);
31502
+ (utils$3.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
31503
+ });
31504
+
31505
+ return config;
31506
+ };
31507
+
31508
+ var VERSION = data.version;
31509
+
31510
+ var validators$1 = {};
31511
+
31512
+ // eslint-disable-next-line func-names
31513
+ ['object', 'boolean', 'number', 'function', 'string', 'symbol'].forEach(function(type, i) {
31514
+ validators$1[type] = function validator(thing) {
31515
+ return typeof thing === type || 'a' + (i < 1 ? 'n ' : ' ') + type;
31516
+ };
31517
+ });
31518
+
31519
+ var deprecatedWarnings = {};
31520
+
31521
+ /**
31522
+ * Transitional option validator
31523
+ * @param {function|boolean?} validator - set to false if the transitional option has been removed
31524
+ * @param {string?} version - deprecated version / removed since version
31525
+ * @param {string?} message - some message with additional info
31526
+ * @returns {function}
31527
+ */
31528
+ validators$1.transitional = function transitional(validator, version, message) {
31529
+ function formatMessage(opt, desc) {
31530
+ return '[Axios v' + VERSION + '] Transitional option \'' + opt + '\'' + desc + (message ? '. ' + message : '');
31531
+ }
31532
+
31533
+ // eslint-disable-next-line func-names
31534
+ return function(value, opt, opts) {
31535
+ if (validator === false) {
31536
+ throw new Error(formatMessage(opt, ' has been removed' + (version ? ' in ' + version : '')));
31537
+ }
31538
+
31539
+ if (version && !deprecatedWarnings[opt]) {
31540
+ deprecatedWarnings[opt] = true;
31541
+ // eslint-disable-next-line no-console
31542
+ console.warn(
31543
+ formatMessage(
31544
+ opt,
31545
+ ' has been deprecated since v' + version + ' and will be removed in the near future'
31546
+ )
31547
+ );
31548
+ }
31549
+
31550
+ return validator ? validator(value, opt, opts) : true;
31551
+ };
31552
+ };
31553
+
31554
+ /**
31555
+ * Assert object's properties type
31556
+ * @param {object} options
31557
+ * @param {object} schema
31558
+ * @param {boolean?} allowUnknown
31559
+ */
31560
+
31561
+ function assertOptions(options, schema, allowUnknown) {
31562
+ if (typeof options !== 'object') {
31563
+ throw new TypeError('options must be an object');
31564
+ }
31565
+ var keys = Object.keys(options);
31566
+ var i = keys.length;
31567
+ while (i-- > 0) {
31568
+ var opt = keys[i];
31569
+ var validator = schema[opt];
31570
+ if (validator) {
31571
+ var value = options[opt];
31572
+ var result = value === undefined || validator(value, opt, options);
31573
+ if (result !== true) {
31574
+ throw new TypeError('option ' + opt + ' must be ' + result);
31575
+ }
31576
+ continue;
31577
+ }
31578
+ if (allowUnknown !== true) {
31579
+ throw Error('Unknown option ' + opt);
31580
+ }
31581
+ }
31582
+ }
31583
+
31584
+ var validator$1 = {
31585
+ assertOptions: assertOptions,
31586
+ validators: validators$1
31587
+ };
31588
+
31589
+ var utils$2 = utils$f;
31590
+ var buildURL = buildURL$3;
31591
+ var InterceptorManager = InterceptorManager_1;
31592
+ var dispatchRequest = dispatchRequest$1;
31593
+ var mergeConfig$1 = mergeConfig$2;
31594
+ var validator = validator$1;
31595
+
31596
+ var validators = validator.validators;
31597
+ /**
31598
+ * Create a new instance of Axios
31599
+ *
31600
+ * @param {Object} instanceConfig The default config for the instance
31601
+ */
31602
+ function Axios$1(instanceConfig) {
31603
+ this.defaults = instanceConfig;
31604
+ this.interceptors = {
31605
+ request: new InterceptorManager(),
31606
+ response: new InterceptorManager()
31607
+ };
31608
+ }
31609
+
31610
+ /**
31611
+ * Dispatch a request
31612
+ *
31613
+ * @param {Object} config The config specific for this request (merged with this.defaults)
31614
+ */
31615
+ Axios$1.prototype.request = function request(configOrUrl, config) {
31616
+ /*eslint no-param-reassign:0*/
31617
+ // Allow for axios('example/url'[, config]) a la fetch API
31618
+ if (typeof configOrUrl === 'string') {
31619
+ config = config || {};
31620
+ config.url = configOrUrl;
31621
+ } else {
31622
+ config = configOrUrl || {};
31623
+ }
31624
+
31625
+ config = mergeConfig$1(this.defaults, config);
31626
+
31627
+ // Set config.method
31628
+ if (config.method) {
31629
+ config.method = config.method.toLowerCase();
31630
+ } else if (this.defaults.method) {
31631
+ config.method = this.defaults.method.toLowerCase();
31632
+ } else {
31633
+ config.method = 'get';
31634
+ }
31635
+
31636
+ var transitional = config.transitional;
31637
+
31638
+ if (transitional !== undefined) {
31639
+ validator.assertOptions(transitional, {
31640
+ silentJSONParsing: validators.transitional(validators.boolean),
31641
+ forcedJSONParsing: validators.transitional(validators.boolean),
31642
+ clarifyTimeoutError: validators.transitional(validators.boolean)
31643
+ }, false);
31644
+ }
31645
+
31646
+ // filter out skipped interceptors
31647
+ var requestInterceptorChain = [];
31648
+ var synchronousRequestInterceptors = true;
31649
+ this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
31650
+ if (typeof interceptor.runWhen === 'function' && interceptor.runWhen(config) === false) {
31651
+ return;
31652
+ }
31653
+
31654
+ synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
31655
+
31656
+ requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
31657
+ });
31658
+
31659
+ var responseInterceptorChain = [];
31660
+ this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
31661
+ responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
31662
+ });
31663
+
31664
+ var promise;
31665
+
31666
+ if (!synchronousRequestInterceptors) {
31667
+ var chain = [dispatchRequest, undefined];
31668
+
31669
+ Array.prototype.unshift.apply(chain, requestInterceptorChain);
31670
+ chain = chain.concat(responseInterceptorChain);
31671
+
31672
+ promise = Promise.resolve(config);
31673
+ while (chain.length) {
31674
+ promise = promise.then(chain.shift(), chain.shift());
31675
+ }
31676
+
31677
+ return promise;
31678
+ }
31679
+
31680
+
31681
+ var newConfig = config;
31682
+ while (requestInterceptorChain.length) {
31683
+ var onFulfilled = requestInterceptorChain.shift();
31684
+ var onRejected = requestInterceptorChain.shift();
31685
+ try {
31686
+ newConfig = onFulfilled(newConfig);
31687
+ } catch (error) {
31688
+ onRejected(error);
31689
+ break;
31690
+ }
31691
+ }
31692
+
31693
+ try {
31694
+ promise = dispatchRequest(newConfig);
31695
+ } catch (error) {
31696
+ return Promise.reject(error);
31697
+ }
31698
+
31699
+ while (responseInterceptorChain.length) {
31700
+ promise = promise.then(responseInterceptorChain.shift(), responseInterceptorChain.shift());
31701
+ }
31702
+
31703
+ return promise;
31704
+ };
31705
+
31706
+ Axios$1.prototype.getUri = function getUri(config) {
31707
+ config = mergeConfig$1(this.defaults, config);
31708
+ return buildURL(config.url, config.params, config.paramsSerializer).replace(/^\?/, '');
31709
+ };
31710
+
31711
+ // Provide aliases for supported request methods
31712
+ utils$2.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
31713
+ /*eslint func-names:0*/
31714
+ Axios$1.prototype[method] = function(url, config) {
31715
+ return this.request(mergeConfig$1(config || {}, {
31716
+ method: method,
31717
+ url: url,
31718
+ data: (config || {}).data
31719
+ }));
31720
+ };
31721
+ });
31722
+
31723
+ utils$2.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
31724
+ /*eslint func-names:0*/
31725
+ Axios$1.prototype[method] = function(url, data, config) {
31726
+ return this.request(mergeConfig$1(config || {}, {
31727
+ method: method,
31728
+ url: url,
31729
+ data: data
31730
+ }));
31731
+ };
31732
+ });
31733
+
31734
+ var Axios_1 = Axios$1;
31735
+
31736
+ var Cancel = Cancel_1;
31737
+
31738
+ /**
31739
+ * A `CancelToken` is an object that can be used to request cancellation of an operation.
31740
+ *
31741
+ * @class
31742
+ * @param {Function} executor The executor function.
31743
+ */
31744
+ function CancelToken(executor) {
31745
+ if (typeof executor !== 'function') {
31746
+ throw new TypeError('executor must be a function.');
31747
+ }
31748
+
31749
+ var resolvePromise;
31750
+
31751
+ this.promise = new Promise(function promiseExecutor(resolve) {
31752
+ resolvePromise = resolve;
31753
+ });
31754
+
31755
+ var token = this;
31756
+
31757
+ // eslint-disable-next-line func-names
31758
+ this.promise.then(function(cancel) {
31759
+ if (!token._listeners) return;
31760
+
31761
+ var i;
31762
+ var l = token._listeners.length;
31763
+
31764
+ for (i = 0; i < l; i++) {
31765
+ token._listeners[i](cancel);
31766
+ }
31767
+ token._listeners = null;
31768
+ });
31769
+
31770
+ // eslint-disable-next-line func-names
31771
+ this.promise.then = function(onfulfilled) {
31772
+ var _resolve;
31773
+ // eslint-disable-next-line func-names
31774
+ var promise = new Promise(function(resolve) {
31775
+ token.subscribe(resolve);
31776
+ _resolve = resolve;
31777
+ }).then(onfulfilled);
31778
+
31779
+ promise.cancel = function reject() {
31780
+ token.unsubscribe(_resolve);
31781
+ };
31782
+
31783
+ return promise;
31784
+ };
31785
+
31786
+ executor(function cancel(message) {
31787
+ if (token.reason) {
31788
+ // Cancellation has already been requested
31789
+ return;
31790
+ }
31791
+
31792
+ token.reason = new Cancel(message);
31793
+ resolvePromise(token.reason);
31794
+ });
31795
+ }
31796
+
31797
+ /**
31798
+ * Throws a `Cancel` if cancellation has been requested.
31799
+ */
31800
+ CancelToken.prototype.throwIfRequested = function throwIfRequested() {
31801
+ if (this.reason) {
31802
+ throw this.reason;
31803
+ }
31804
+ };
31805
+
31806
+ /**
31807
+ * Subscribe to the cancel signal
31808
+ */
31809
+
31810
+ CancelToken.prototype.subscribe = function subscribe(listener) {
31811
+ if (this.reason) {
31812
+ listener(this.reason);
31813
+ return;
31814
+ }
31815
+
31816
+ if (this._listeners) {
31817
+ this._listeners.push(listener);
31818
+ } else {
31819
+ this._listeners = [listener];
31820
+ }
31821
+ };
31822
+
31823
+ /**
31824
+ * Unsubscribe from the cancel signal
31825
+ */
31826
+
31827
+ CancelToken.prototype.unsubscribe = function unsubscribe(listener) {
31828
+ if (!this._listeners) {
31829
+ return;
31830
+ }
31831
+ var index = this._listeners.indexOf(listener);
31832
+ if (index !== -1) {
31833
+ this._listeners.splice(index, 1);
31834
+ }
31835
+ };
31836
+
31837
+ /**
31838
+ * Returns an object that contains a new `CancelToken` and a function that, when called,
31839
+ * cancels the `CancelToken`.
31840
+ */
31841
+ CancelToken.source = function source() {
31842
+ var cancel;
31843
+ var token = new CancelToken(function executor(c) {
31844
+ cancel = c;
31845
+ });
31846
+ return {
31847
+ token: token,
31848
+ cancel: cancel
31849
+ };
31850
+ };
31851
+
31852
+ var CancelToken_1 = CancelToken;
31853
+
31854
+ /**
31855
+ * Syntactic sugar for invoking a function and expanding an array for arguments.
31856
+ *
31857
+ * Common use case would be to use `Function.prototype.apply`.
31858
+ *
31859
+ * ```js
31860
+ * function f(x, y, z) {}
31861
+ * var args = [1, 2, 3];
31862
+ * f.apply(null, args);
31863
+ * ```
31864
+ *
31865
+ * With `spread` this example can be re-written.
31866
+ *
31867
+ * ```js
31868
+ * spread(function(x, y, z) {})([1, 2, 3]);
31869
+ * ```
31870
+ *
31871
+ * @param {Function} callback
31872
+ * @returns {Function}
31873
+ */
31874
+ var spread = function spread(callback) {
31875
+ return function wrap(arr) {
31876
+ return callback.apply(null, arr);
31877
+ };
31878
+ };
31879
+
31880
+ var utils$1 = utils$f;
31881
+
31882
+ /**
31883
+ * Determines whether the payload is an error thrown by Axios
31884
+ *
31885
+ * @param {*} payload The value to test
31886
+ * @returns {boolean} True if the payload is an error thrown by Axios, otherwise false
31887
+ */
31888
+ var isAxiosError = function isAxiosError(payload) {
31889
+ return utils$1.isObject(payload) && (payload.isAxiosError === true);
31890
+ };
31891
+
31892
+ var utils = utils$f;
31893
+ var bind = bind$2;
31894
+ var Axios = Axios_1;
31895
+ var mergeConfig = mergeConfig$2;
31896
+ var defaults = defaults_1;
31897
+
31898
+ /**
31899
+ * Create an instance of Axios
31900
+ *
31901
+ * @param {Object} defaultConfig The default config for the instance
31902
+ * @return {Axios} A new instance of Axios
31903
+ */
31904
+ function createInstance(defaultConfig) {
31905
+ var context = new Axios(defaultConfig);
31906
+ var instance = bind(Axios.prototype.request, context);
31907
+
31908
+ // Copy axios.prototype to instance
31909
+ utils.extend(instance, Axios.prototype, context);
31910
+
31911
+ // Copy context to instance
31912
+ utils.extend(instance, context);
31913
+
31914
+ // Factory for creating new instances
31915
+ instance.create = function create(instanceConfig) {
31916
+ return createInstance(mergeConfig(defaultConfig, instanceConfig));
31917
+ };
31918
+
31919
+ return instance;
31920
+ }
31921
+
31922
+ // Create the default instance to be exported
31923
+ var axios$1 = createInstance(defaults);
31924
+
31925
+ // Expose Axios class to allow class inheritance
31926
+ axios$1.Axios = Axios;
31927
+
31928
+ // Expose Cancel & CancelToken
31929
+ axios$1.Cancel = Cancel_1;
31930
+ axios$1.CancelToken = CancelToken_1;
31931
+ axios$1.isCancel = isCancel$1;
31932
+ axios$1.VERSION = data.version;
31933
+
31934
+ // Expose all/spread
31935
+ axios$1.all = function all(promises) {
31936
+ return Promise.all(promises);
31937
+ };
31938
+ axios$1.spread = spread;
31939
+
31940
+ // Expose isAxiosError
31941
+ axios$1.isAxiosError = isAxiosError;
31942
+
31943
+ axios$2.exports = axios$1;
31944
+
31945
+ // Allow use of default import syntax in TypeScript
31946
+ axios$2.exports.default = axios$1;
31947
+
31948
+ var axios = axios$2.exports;
31949
+
31950
+ const sanityMediaSettings = new AppInMemorySettings();
31951
+
31952
+ const buildRef = ({ dataset, projectId, id, }) => {
31953
+ return `sanity://${projectId}/${dataset}/${id}`;
31954
+ };
31955
+ const parseRef = (ref) => {
31956
+ const parts = ref.split("/");
31957
+ return {
31958
+ projectId: parts[2],
31959
+ dataset: parts[3],
31960
+ id: parts.slice(4).join("/"),
31961
+ };
31962
+ };
31963
+ const isImage = (contentType) => {
31964
+ return contentType.startsWith("image/");
31965
+ };
31966
+ const buildFolderTag = (folderId) => {
31967
+ return folderId ? `folder:${folderId}` : "folder:root";
31968
+ };
31969
+ exports.SanityMediaProvider = class SanityMediaProvider {
31970
+ constructor() {
31971
+ this.client = client.createClient({
31972
+ projectId: sanityMediaSettings.value.projectId,
31973
+ dataset: sanityMediaSettings.value.dataset,
31974
+ token: sanityMediaSettings.value.token,
31975
+ apiVersion: sanityMediaSettings.value.apiVersion,
31976
+ });
31977
+ }
31978
+ getProviderId() {
31979
+ return "sanity";
31980
+ }
31981
+ getFileName(input) {
31982
+ const parsedRef = parseRef(input.ref);
31983
+ return parsedRef.id.replace("_", ".");
31984
+ }
31985
+ async mediaUpload(input) {
31986
+ try {
31987
+ const asses = await this.client.assets.upload(input.contentType && isImage(input.contentType) ? "image" : "file", input.content, {
31988
+ contentType: input.contentType,
31989
+ filename: input.fileName,
31990
+ tag: buildFolderTag(input.folderId),
31991
+ });
31992
+ return {
31993
+ ref: buildRef({
31994
+ dataset: sanityMediaSettings.value.dataset,
31995
+ projectId: sanityMediaSettings.value.projectId,
31996
+ id: asses._id,
31997
+ }),
31998
+ };
31999
+ }
32000
+ catch (e) {
32001
+ throw new SanityMediaError(`SanityMediaProvider | mediaUpload | ${input.fileName} | Error -> ${e.message}`);
32002
+ }
32003
+ }
32004
+ async mediaDelete(input) {
32005
+ try {
32006
+ const parsedRef = parseRef(input.ref);
32007
+ await this.client.delete(parsedRef.id);
32008
+ }
32009
+ catch (e) {
32010
+ throw new SanityMediaError(`SanityMediaProvider | mediaDelete | ${input.ref} | Error -> ${e.message}`);
32011
+ }
32012
+ }
32013
+ async mediaDownload(input) {
32014
+ try {
32015
+ const parsedRef = parseRef(input.ref);
32016
+ const asset = await this.client.getDocument(parsedRef.id);
32017
+ if (!asset) {
32018
+ throw new Error(`Asset not found id: ${parsedRef.id}`);
32019
+ }
32020
+ const response = await axios.get(asset.url, {
32021
+ responseType: "arraybuffer",
32022
+ });
32023
+ return Buffer.from(response.data, "binary");
32024
+ }
32025
+ catch (e) {
32026
+ throw new SanityMediaError(`SanityMediaProvider | mediaDownload | ${input.ref} | Error -> ${e.message}`);
32027
+ }
32028
+ }
32029
+ };
32030
+ exports.SanityMediaProvider = __decorate([
32031
+ WpMediaProvider("sanity"),
32032
+ __metadata("design:paramtypes", [])
32033
+ ], exports.SanityMediaProvider);
32034
+
32035
+ var SanityMediaModule_1;
32036
+ const ModuleData$1 = {
32037
+ providers: [exports.SanityMediaProvider],
32038
+ };
32039
+ exports.SanityMediaModule = SanityMediaModule_1 = class SanityMediaModule {
32040
+ static forRoot(input) {
32041
+ sanityMediaSettings.initialize(input);
32042
+ return {
32043
+ module: SanityMediaModule_1,
32044
+ ...ModuleData$1,
32045
+ };
32046
+ }
32047
+ };
32048
+ exports.SanityMediaModule = SanityMediaModule_1 = __decorate([
32049
+ common.Module({
32050
+ ...ModuleData$1,
32051
+ })
32052
+ ], exports.SanityMediaModule);
32053
+
29071
32054
  exports.InMemoryMediaProvider = class InMemoryMediaProvider {
29072
32055
  constructor() {
29073
32056
  this.provider = new exports.InMemoryBucketProvider();
@@ -29347,6 +32330,7 @@ exports.PlatformEvents = PlatformEvents;
29347
32330
  exports.Public = Public;
29348
32331
  exports.QueryBuilderBase = QueryBuilderBase;
29349
32332
  exports.Roles = Roles;
32333
+ exports.SanityMediaError = SanityMediaError;
29350
32334
  exports.SendgridEmailTemplate = SendgridEmailTemplate;
29351
32335
  exports.TypeOrmQueryBuilder = TypeOrmQueryBuilder;
29352
32336
  exports.TypeOrmRepository = TypeOrmRepository;