@neurosity/sdk 7.0.1 → 7.2.0

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.
Files changed (170) hide show
  1. package/dist/index.js +2155 -970
  2. package/dist/index.js.map +1 -1
  3. package/dist/index.mjs +2155 -970
  4. package/dist/index.mjs.map +1 -1
  5. package/dist/neurosity.iife.js +2155 -970
  6. package/dist/neurosity.iife.js.map +1 -1
  7. package/dist/neurosity.umd.js +2155 -970
  8. package/dist/neurosity.umd.js.map +1 -1
  9. package/dist/types/Neurosity.d.ts +102 -0
  10. package/dist/types/Neurosity.d.ts.map +1 -0
  11. package/dist/types/api/bluetooth/BluetoothClient.d.ts +77 -0
  12. package/dist/types/api/bluetooth/BluetoothClient.d.ts.map +1 -0
  13. package/dist/types/api/bluetooth/BluetoothTransport.d.ts +31 -0
  14. package/dist/types/api/bluetooth/BluetoothTransport.d.ts.map +1 -0
  15. package/dist/types/api/bluetooth/constants.d.ts +5 -0
  16. package/dist/types/api/bluetooth/constants.d.ts.map +1 -0
  17. package/dist/types/api/bluetooth/index.d.ts +6 -0
  18. package/dist/types/api/bluetooth/index.d.ts.map +1 -0
  19. package/dist/types/api/bluetooth/react-native/ReactNativeTransport.d.ts +73 -0
  20. package/dist/types/api/bluetooth/react-native/ReactNativeTransport.d.ts.map +1 -0
  21. package/dist/types/api/bluetooth/react-native/index.d.ts +3 -0
  22. package/dist/types/api/bluetooth/react-native/index.d.ts.map +1 -0
  23. package/dist/types/api/bluetooth/react-native/types/BleManagerTypes.d.ts +64 -0
  24. package/dist/types/api/bluetooth/react-native/types/BleManagerTypes.d.ts.map +1 -0
  25. package/dist/types/api/bluetooth/react-native/types/ReactNativeTypes.d.ts +41 -0
  26. package/dist/types/api/bluetooth/react-native/types/ReactNativeTypes.d.ts.map +1 -0
  27. package/dist/types/api/bluetooth/react-native/types/index.d.ts +3 -0
  28. package/dist/types/api/bluetooth/react-native/types/index.d.ts.map +1 -0
  29. package/dist/types/api/bluetooth/types/index.d.ts +21 -0
  30. package/dist/types/api/bluetooth/types/index.d.ts.map +1 -0
  31. package/dist/types/api/bluetooth/utils/binaryBufferToEpoch.d.ts +10 -0
  32. package/dist/types/api/bluetooth/utils/binaryBufferToEpoch.d.ts.map +1 -0
  33. package/dist/types/api/bluetooth/utils/create6DigitPin.d.ts +2 -0
  34. package/dist/types/api/bluetooth/utils/create6DigitPin.d.ts.map +1 -0
  35. package/dist/types/api/bluetooth/utils/csvBufferToEpoch.d.ts +6 -0
  36. package/dist/types/api/bluetooth/utils/csvBufferToEpoch.d.ts.map +1 -0
  37. package/dist/types/api/bluetooth/utils/decodeJSONChunks.d.ts +10 -0
  38. package/dist/types/api/bluetooth/utils/decodeJSONChunks.d.ts.map +1 -0
  39. package/dist/types/api/bluetooth/utils/osHasBluetoothSupport.d.ts +3 -0
  40. package/dist/types/api/bluetooth/utils/osHasBluetoothSupport.d.ts.map +1 -0
  41. package/dist/types/api/bluetooth/utils/stitch.d.ts +6 -0
  42. package/dist/types/api/bluetooth/utils/stitch.d.ts.map +1 -0
  43. package/dist/types/api/bluetooth/utils/textCodec.d.ts +11 -0
  44. package/dist/types/api/bluetooth/utils/textCodec.d.ts.map +1 -0
  45. package/dist/types/api/bluetooth/web/WebBluetoothTransport.d.ts +48 -0
  46. package/dist/types/api/bluetooth/web/WebBluetoothTransport.d.ts.map +1 -0
  47. package/dist/types/api/bluetooth/web/isMaybeWebWorkerContext.d.ts +2 -0
  48. package/dist/types/api/bluetooth/web/isMaybeWebWorkerContext.d.ts.map +1 -0
  49. package/dist/types/api/bluetooth/web/isWebBluetoothSupported.d.ts +2 -0
  50. package/dist/types/api/bluetooth/web/isWebBluetoothSupported.d.ts.map +1 -0
  51. package/dist/types/api/firebase/FirebaseApp.d.ts +13 -0
  52. package/dist/types/api/firebase/FirebaseApp.d.ts.map +1 -0
  53. package/dist/types/api/firebase/FirebaseDevice.d.ts +35 -0
  54. package/dist/types/api/firebase/FirebaseDevice.d.ts.map +1 -0
  55. package/dist/types/api/firebase/FirebaseUser.d.ts +50 -0
  56. package/dist/types/api/firebase/FirebaseUser.d.ts.map +1 -0
  57. package/dist/types/api/firebase/config.d.ts +9 -0
  58. package/dist/types/api/firebase/config.d.ts.map +1 -0
  59. package/dist/types/api/firebase/deviceStore.d.ts +24 -0
  60. package/dist/types/api/firebase/deviceStore.d.ts.map +1 -0
  61. package/dist/types/api/firebase/index.d.ts +4 -0
  62. package/dist/types/api/firebase/index.d.ts.map +1 -0
  63. package/dist/types/api/https/config.d.ts +2 -0
  64. package/dist/types/api/https/config.d.ts.map +1 -0
  65. package/dist/types/api/https/createOAuthURL.d.ts +4 -0
  66. package/dist/types/api/https/createOAuthURL.d.ts.map +1 -0
  67. package/dist/types/api/https/getOAuthToken.d.ts +4 -0
  68. package/dist/types/api/https/getOAuthToken.d.ts.map +1 -0
  69. package/dist/types/api/https/utils.d.ts +3 -0
  70. package/dist/types/api/https/utils.d.ts.map +1 -0
  71. package/dist/types/api/index.d.ts +74 -0
  72. package/dist/types/api/index.d.ts.map +1 -0
  73. package/dist/types/index.d.ts +4 -0
  74. package/dist/types/index.d.ts.map +1 -0
  75. package/dist/types/subscriptions/SubscriptionManager.d.ts +9 -0
  76. package/dist/types/subscriptions/SubscriptionManager.d.ts.map +1 -0
  77. package/dist/types/timesync/Timesync.d.ts +21 -0
  78. package/dist/types/timesync/Timesync.d.ts.map +1 -0
  79. package/dist/types/timesync/index.d.ts +2 -0
  80. package/dist/types/timesync/index.d.ts.map +1 -0
  81. package/dist/types/types/accelerometer.d.ts +12 -0
  82. package/dist/types/types/accelerometer.d.ts.map +1 -0
  83. package/dist/types/types/actions.d.ts +11 -0
  84. package/dist/types/types/actions.d.ts.map +1 -0
  85. package/dist/types/types/apiKey.d.ts +31 -0
  86. package/dist/types/types/apiKey.d.ts.map +1 -0
  87. package/dist/types/types/awareness.d.ts +2 -0
  88. package/dist/types/types/awareness.d.ts.map +1 -0
  89. package/dist/types/types/brainwaves.d.ts +40 -0
  90. package/dist/types/types/brainwaves.d.ts.map +1 -0
  91. package/dist/types/types/calm.d.ts +7 -0
  92. package/dist/types/types/calm.d.ts.map +1 -0
  93. package/dist/types/types/client.d.ts +20 -0
  94. package/dist/types/types/client.d.ts.map +1 -0
  95. package/dist/types/types/credentials.d.ts +16 -0
  96. package/dist/types/types/credentials.d.ts.map +1 -0
  97. package/dist/types/types/deviceInfo.d.ts +20 -0
  98. package/dist/types/types/deviceInfo.d.ts.map +1 -0
  99. package/dist/types/types/epoch.d.ts +10 -0
  100. package/dist/types/types/epoch.d.ts.map +1 -0
  101. package/dist/types/types/experiment.d.ts +10 -0
  102. package/dist/types/types/experiment.d.ts.map +1 -0
  103. package/dist/types/types/focus.d.ts +7 -0
  104. package/dist/types/types/focus.d.ts.map +1 -0
  105. package/dist/types/types/hapticEffects.d.ts +126 -0
  106. package/dist/types/types/hapticEffects.d.ts.map +1 -0
  107. package/dist/types/types/index.d.ts +27 -0
  108. package/dist/types/types/index.d.ts.map +1 -0
  109. package/dist/types/types/kinesis.d.ts +7 -0
  110. package/dist/types/types/kinesis.d.ts.map +1 -0
  111. package/dist/types/types/marker.d.ts +5 -0
  112. package/dist/types/types/marker.d.ts.map +1 -0
  113. package/dist/types/types/metrics.d.ts +13 -0
  114. package/dist/types/types/metrics.d.ts.map +1 -0
  115. package/dist/types/types/oauth.d.ts +21 -0
  116. package/dist/types/types/oauth.d.ts.map +1 -0
  117. package/dist/types/types/options.d.ts +25 -0
  118. package/dist/types/types/options.d.ts.map +1 -0
  119. package/dist/types/types/recording.d.ts +26 -0
  120. package/dist/types/types/recording.d.ts.map +1 -0
  121. package/dist/types/types/sample.d.ts +10 -0
  122. package/dist/types/types/sample.d.ts.map +1 -0
  123. package/dist/types/types/settings.d.ts +8 -0
  124. package/dist/types/types/settings.d.ts.map +1 -0
  125. package/dist/types/types/signalQuality.d.ts +9 -0
  126. package/dist/types/types/signalQuality.d.ts.map +1 -0
  127. package/dist/types/types/signalQualityV2.d.ts +14 -0
  128. package/dist/types/types/signalQualityV2.d.ts.map +1 -0
  129. package/dist/types/types/skill.d.ts +45 -0
  130. package/dist/types/types/skill.d.ts.map +1 -0
  131. package/dist/types/types/status.d.ts +21 -0
  132. package/dist/types/types/status.d.ts.map +1 -0
  133. package/dist/types/types/streaming.d.ts +10 -0
  134. package/dist/types/types/streaming.d.ts.map +1 -0
  135. package/dist/types/types/subscriptions.d.ts +15 -0
  136. package/dist/types/types/subscriptions.d.ts.map +1 -0
  137. package/dist/types/types/training.d.ts +14 -0
  138. package/dist/types/types/training.d.ts.map +1 -0
  139. package/dist/types/types/user.d.ts +10 -0
  140. package/dist/types/types/user.d.ts.map +1 -0
  141. package/dist/types/utils/errors.d.ts +6 -0
  142. package/dist/types/utils/errors.d.ts.map +1 -0
  143. package/dist/types/utils/filterInternalKeys.d.ts +4 -0
  144. package/dist/types/utils/filterInternalKeys.d.ts.map +1 -0
  145. package/dist/types/utils/hapticEffects.d.ts +124 -0
  146. package/dist/types/utils/hapticEffects.d.ts.map +1 -0
  147. package/dist/types/utils/heartbeat.d.ts +5 -0
  148. package/dist/types/utils/heartbeat.d.ts.map +1 -0
  149. package/dist/types/utils/index.d.ts +14 -0
  150. package/dist/types/utils/index.d.ts.map +1 -0
  151. package/dist/types/utils/is-node.d.ts +2 -0
  152. package/dist/types/utils/is-node.d.ts.map +1 -0
  153. package/dist/types/utils/metrics.d.ts +4 -0
  154. package/dist/types/utils/metrics.d.ts.map +1 -0
  155. package/dist/types/utils/permissions.d.ts +16 -0
  156. package/dist/types/utils/permissions.d.ts.map +1 -0
  157. package/dist/types/utils/pick.d.ts +2 -0
  158. package/dist/types/utils/pick.d.ts.map +1 -0
  159. package/dist/types/utils/pipes.d.ts +18 -0
  160. package/dist/types/utils/pipes.d.ts.map +1 -0
  161. package/dist/types/utils/platform.d.ts +31 -0
  162. package/dist/types/utils/platform.d.ts.map +1 -0
  163. package/dist/types/utils/subscription.d.ts +7 -0
  164. package/dist/types/utils/subscription.d.ts.map +1 -0
  165. package/dist/types/utils/transferDevice.d.ts +10 -0
  166. package/dist/types/utils/transferDevice.d.ts.map +1 -0
  167. package/dist/types/utils/whileOnline.d.ts +9 -0
  168. package/dist/types/utils/whileOnline.d.ts.map +1 -0
  169. package/package.json +13 -9
  170. package/dist/index.d.ts +0 -1067
@@ -139,7 +139,7 @@ var Neurosity = (function (exports) {
139
139
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
140
140
  };
141
141
 
142
- function isFunction$2(value) {
142
+ function isFunction$3(value) {
143
143
  return typeof value === 'function';
144
144
  }
145
145
 
@@ -207,7 +207,7 @@ var Neurosity = (function (exports) {
207
207
  }
208
208
  }
209
209
  var initialFinalizer = this.initialTeardown;
210
- if (isFunction$2(initialFinalizer)) {
210
+ if (isFunction$3(initialFinalizer)) {
211
211
  try {
212
212
  initialFinalizer();
213
213
  }
@@ -299,10 +299,10 @@ var Neurosity = (function (exports) {
299
299
  var EMPTY_SUBSCRIPTION = Subscription$1.EMPTY;
300
300
  function isSubscription(value) {
301
301
  return (value instanceof Subscription$1 ||
302
- (value && 'closed' in value && isFunction$2(value.remove) && isFunction$2(value.add) && isFunction$2(value.unsubscribe)));
302
+ (value && 'closed' in value && isFunction$3(value.remove) && isFunction$3(value.add) && isFunction$3(value.unsubscribe)));
303
303
  }
304
304
  function execFinalizer(finalizer) {
305
- if (isFunction$2(finalizer)) {
305
+ if (isFunction$3(finalizer)) {
306
306
  finalizer();
307
307
  }
308
308
  else {
@@ -457,7 +457,7 @@ var Neurosity = (function (exports) {
457
457
  function SafeSubscriber(observerOrNext, error, complete) {
458
458
  var _this = _super.call(this) || this;
459
459
  var partialObserver;
460
- if (isFunction$2(observerOrNext) || !observerOrNext) {
460
+ if (isFunction$3(observerOrNext) || !observerOrNext) {
461
461
  partialObserver = {
462
462
  next: (observerOrNext !== null && observerOrNext !== void 0 ? observerOrNext : undefined),
463
463
  error: error !== null && error !== void 0 ? error : undefined,
@@ -602,14 +602,14 @@ var Neurosity = (function (exports) {
602
602
  return (_a = promiseCtor !== null && promiseCtor !== void 0 ? promiseCtor : config$1.Promise) !== null && _a !== void 0 ? _a : Promise;
603
603
  }
604
604
  function isObserver(value) {
605
- return value && isFunction$2(value.next) && isFunction$2(value.error) && isFunction$2(value.complete);
605
+ return value && isFunction$3(value.next) && isFunction$3(value.error) && isFunction$3(value.complete);
606
606
  }
607
607
  function isSubscriber(value) {
608
608
  return (value && value instanceof Subscriber) || (isObserver(value) && isSubscription(value));
609
609
  }
610
610
 
611
611
  function hasLift(source) {
612
- return isFunction$2(source === null || source === void 0 ? void 0 : source.lift);
612
+ return isFunction$3(source === null || source === void 0 ? void 0 : source.lift);
613
613
  }
614
614
  function operate(init) {
615
615
  return function (source) {
@@ -1104,14 +1104,14 @@ var Neurosity = (function (exports) {
1104
1104
  var EMPTY = new Observable(function (subscriber) { return subscriber.complete(); });
1105
1105
 
1106
1106
  function isScheduler(value) {
1107
- return value && isFunction$2(value.schedule);
1107
+ return value && isFunction$3(value.schedule);
1108
1108
  }
1109
1109
 
1110
1110
  function last(arr) {
1111
1111
  return arr[arr.length - 1];
1112
1112
  }
1113
1113
  function popResultSelector(args) {
1114
- return isFunction$2(last(args)) ? args.pop() : undefined;
1114
+ return isFunction$3(last(args)) ? args.pop() : undefined;
1115
1115
  }
1116
1116
  function popScheduler(args) {
1117
1117
  return isScheduler(last(args)) ? args.pop() : undefined;
@@ -1123,15 +1123,15 @@ var Neurosity = (function (exports) {
1123
1123
  var isArrayLike = (function (x) { return x && typeof x.length === 'number' && typeof x !== 'function'; });
1124
1124
 
1125
1125
  function isPromise(value) {
1126
- return isFunction$2(value === null || value === void 0 ? void 0 : value.then);
1126
+ return isFunction$3(value === null || value === void 0 ? void 0 : value.then);
1127
1127
  }
1128
1128
 
1129
1129
  function isInteropObservable(input) {
1130
- return isFunction$2(input[observable]);
1130
+ return isFunction$3(input[observable]);
1131
1131
  }
1132
1132
 
1133
1133
  function isAsyncIterable(obj) {
1134
- return Symbol.asyncIterator && isFunction$2(obj === null || obj === void 0 ? void 0 : obj[Symbol.asyncIterator]);
1134
+ return Symbol.asyncIterator && isFunction$3(obj === null || obj === void 0 ? void 0 : obj[Symbol.asyncIterator]);
1135
1135
  }
1136
1136
 
1137
1137
  function createInvalidObservableTypeError(input) {
@@ -1144,10 +1144,10 @@ var Neurosity = (function (exports) {
1144
1144
  }
1145
1145
  return Symbol.iterator;
1146
1146
  }
1147
- var iterator = getSymbolIterator();
1147
+ var iterator$1 = getSymbolIterator();
1148
1148
 
1149
- function isIterable(input) {
1150
- return isFunction$2(input === null || input === void 0 ? void 0 : input[iterator]);
1149
+ function isIterable$1(input) {
1150
+ return isFunction$3(input === null || input === void 0 ? void 0 : input[iterator$1]);
1151
1151
  }
1152
1152
 
1153
1153
  function readableStreamLikeToAsyncGenerator(readableStream) {
@@ -1183,7 +1183,7 @@ var Neurosity = (function (exports) {
1183
1183
  });
1184
1184
  }
1185
1185
  function isReadableStreamLike(obj) {
1186
- return isFunction$2(obj === null || obj === void 0 ? void 0 : obj.getReader);
1186
+ return isFunction$3(obj === null || obj === void 0 ? void 0 : obj.getReader);
1187
1187
  }
1188
1188
 
1189
1189
  function innerFrom(input) {
@@ -1203,7 +1203,7 @@ var Neurosity = (function (exports) {
1203
1203
  if (isAsyncIterable(input)) {
1204
1204
  return fromAsyncIterable(input);
1205
1205
  }
1206
- if (isIterable(input)) {
1206
+ if (isIterable$1(input)) {
1207
1207
  return fromIterable(input);
1208
1208
  }
1209
1209
  if (isReadableStreamLike(input)) {
@@ -1215,7 +1215,7 @@ var Neurosity = (function (exports) {
1215
1215
  function fromInteropObservable(obj) {
1216
1216
  return new Observable(function (subscriber) {
1217
1217
  var obs = obj[observable]();
1218
- if (isFunction$2(obs.subscribe)) {
1218
+ if (isFunction$3(obs.subscribe)) {
1219
1219
  return obs.subscribe(subscriber);
1220
1220
  }
1221
1221
  throw new TypeError('Provided object does not correctly implement Symbol.observable');
@@ -1376,15 +1376,15 @@ var Neurosity = (function (exports) {
1376
1376
 
1377
1377
  function scheduleIterable(input, scheduler) {
1378
1378
  return new Observable(function (subscriber) {
1379
- var iterator$1;
1379
+ var iterator;
1380
1380
  executeSchedule(subscriber, scheduler, function () {
1381
- iterator$1 = input[iterator]();
1381
+ iterator = input[iterator$1]();
1382
1382
  executeSchedule(subscriber, scheduler, function () {
1383
1383
  var _a;
1384
1384
  var value;
1385
1385
  var done;
1386
1386
  try {
1387
- (_a = iterator$1.next(), value = _a.value, done = _a.done);
1387
+ (_a = iterator.next(), value = _a.value, done = _a.done);
1388
1388
  }
1389
1389
  catch (err) {
1390
1390
  subscriber.error(err);
@@ -1398,7 +1398,7 @@ var Neurosity = (function (exports) {
1398
1398
  }
1399
1399
  }, 0, true);
1400
1400
  });
1401
- return function () { return isFunction$2(iterator$1 === null || iterator$1 === void 0 ? void 0 : iterator$1.return) && iterator$1.return(); };
1401
+ return function () { return isFunction$3(iterator === null || iterator === void 0 ? void 0 : iterator.return) && iterator.return(); };
1402
1402
  });
1403
1403
  }
1404
1404
 
@@ -1441,7 +1441,7 @@ var Neurosity = (function (exports) {
1441
1441
  if (isAsyncIterable(input)) {
1442
1442
  return scheduleAsyncIterable(input, scheduler);
1443
1443
  }
1444
- if (isIterable(input)) {
1444
+ if (isIterable$1(input)) {
1445
1445
  return scheduleIterable(input, scheduler);
1446
1446
  }
1447
1447
  if (isReadableStreamLike(input)) {
@@ -1465,7 +1465,7 @@ var Neurosity = (function (exports) {
1465
1465
  }
1466
1466
 
1467
1467
  function throwError(errorOrErrorFactory, scheduler) {
1468
- var errorFactory = isFunction$2(errorOrErrorFactory) ? errorOrErrorFactory : function () { return errorOrErrorFactory; };
1468
+ var errorFactory = isFunction$3(errorOrErrorFactory) ? errorOrErrorFactory : function () { return errorOrErrorFactory; };
1469
1469
  var init = function (subscriber) { return subscriber.error(errorFactory()); };
1470
1470
  return new Observable(init);
1471
1471
  }
@@ -1656,7 +1656,7 @@ var Neurosity = (function (exports) {
1656
1656
 
1657
1657
  function mergeMap(project, resultSelector, concurrent) {
1658
1658
  if (concurrent === void 0) { concurrent = Infinity; }
1659
- if (isFunction$2(resultSelector)) {
1659
+ if (isFunction$3(resultSelector)) {
1660
1660
  return mergeMap(function (a, i) { return map$1(function (b, ii) { return resultSelector(a, b, i, ii); })(innerFrom(project(a, i))); }, concurrent);
1661
1661
  }
1662
1662
  else if (typeof resultSelector === 'number') {
@@ -1698,7 +1698,7 @@ var Neurosity = (function (exports) {
1698
1698
  return subscriber.next(e.length === 1 ? e[0] : e);
1699
1699
  };
1700
1700
  var retValue = addHandler(handler);
1701
- return isFunction$2(removeHandler) ? function () { return removeHandler(handler, retValue); } : undefined;
1701
+ return isFunction$3(removeHandler) ? function () { return removeHandler(handler, retValue); } : undefined;
1702
1702
  });
1703
1703
  }
1704
1704
 
@@ -1864,7 +1864,7 @@ var Neurosity = (function (exports) {
1864
1864
  }
1865
1865
 
1866
1866
  function concatMap(project, resultSelector) {
1867
- return isFunction$2(resultSelector) ? mergeMap(project, resultSelector, 1) : mergeMap(project, 1);
1867
+ return isFunction$3(resultSelector) ? mergeMap(project, resultSelector, 1) : mergeMap(project, 1);
1868
1868
  }
1869
1869
 
1870
1870
  function concat() {
@@ -2086,7 +2086,7 @@ var Neurosity = (function (exports) {
2086
2086
  }
2087
2087
 
2088
2088
  function tap(observerOrNext, error, complete) {
2089
- var tapObserver = isFunction$2(observerOrNext) || error || complete
2089
+ var tapObserver = isFunction$3(observerOrNext) || error || complete
2090
2090
  ?
2091
2091
  { next: observerOrNext, error: error, complete: complete }
2092
2092
  : observerOrNext;
@@ -2631,7 +2631,7 @@ var Neurosity = (function (exports) {
2631
2631
  * @returns the `globalThis` object for the given environment.
2632
2632
  * @public
2633
2633
  */
2634
- function getGlobal() {
2634
+ function getGlobal$1() {
2635
2635
  if (typeof self !== 'undefined') {
2636
2636
  return self;
2637
2637
  }
@@ -2660,7 +2660,7 @@ var Neurosity = (function (exports) {
2660
2660
  * See the License for the specific language governing permissions and
2661
2661
  * limitations under the License.
2662
2662
  */
2663
- const getDefaultsFromGlobal = () => getGlobal().__FIREBASE_DEFAULTS__;
2663
+ const getDefaultsFromGlobal = () => getGlobal$1().__FIREBASE_DEFAULTS__;
2664
2664
  /**
2665
2665
  * Attempt to read defaults from a JSON string provided to
2666
2666
  * process(.)env(.)__FIREBASE_DEFAULTS__ or a JSON file whose path is in
@@ -3130,7 +3130,7 @@ var Neurosity = (function (exports) {
3130
3130
  *
3131
3131
  * @return true if ReactNative environment is detected.
3132
3132
  */
3133
- function isReactNative() {
3133
+ function isReactNative$1() {
3134
3134
  return (typeof navigator === 'object' && navigator['product'] === 'ReactNative');
3135
3135
  }
3136
3136
  /** Detects Internet Explorer. */
@@ -9829,7 +9829,7 @@ var Neurosity = (function (exports) {
9829
9829
  if (isMobileCordova()) {
9830
9830
  stats['framework.cordova'] = 1;
9831
9831
  }
9832
- else if (isReactNative()) {
9832
+ else if (isReactNative$1()) {
9833
9833
  stats['framework.reactnative'] = 1;
9834
9834
  }
9835
9835
  this.reportStats(stats);
@@ -19390,7 +19390,7 @@ var Neurosity = (function (exports) {
19390
19390
  this.longDelay = longDelay;
19391
19391
  // Internal error when improperly initialized.
19392
19392
  debugAssert(longDelay > shortDelay, 'Short delay should be less than long delay!');
19393
- this.isMobile = isMobileCordova() || isReactNative();
19393
+ this.isMobile = isMobileCordova() || isReactNative$1();
19394
19394
  }
19395
19395
  get() {
19396
19396
  if (!_isOnline()) {
@@ -30523,8 +30523,9 @@ var Neurosity = (function (exports) {
30523
30523
  registerVersion(F, M, "esm2020");
30524
30524
  }();
30525
30525
 
30526
+ const productionApiKey = ["AIza", "SyB0TkZ83Fj0CIzn8AAmE-Osc92s3ER8hy8"].join("");
30526
30527
  const config = {
30527
- apiKey: "AIzaSyB0TkZ83Fj0CIzn8AAmE-Osc92s3ER8hy8",
30528
+ apiKey: productionApiKey,
30528
30529
  authDomain: "neurosity-device.firebaseapp.com",
30529
30530
  databaseURL: "https://neurosity-device.firebaseio.com",
30530
30531
  projectId: "neurosity-device",
@@ -31544,16 +31545,14 @@ var Neurosity = (function (exports) {
31544
31545
  this.firebaseUser.onUserClaimsChange().subscribe((userClaims) => {
31545
31546
  this.userClaims = userClaims;
31546
31547
  });
31547
- this.onDeviceChange().subscribe(async (device) => {
31548
+ this.onDeviceChange().subscribe((device) => {
31548
31549
  if (this.firebaseDevice) {
31549
- try {
31550
- await this.firebaseDevice.disconnect();
31551
- }
31552
- catch (error) {
31550
+ this.firebaseDevice.disconnect().catch((error) => {
31553
31551
  console.error("Error disconnecting from device", error);
31554
- }
31552
+ });
31555
31553
  }
31556
31554
  if (!device) {
31555
+ this.firebaseDevice = undefined;
31557
31556
  return;
31558
31557
  }
31559
31558
  this.firebaseDevice = new FirebaseDevice({
@@ -31840,6 +31839,7 @@ var Neurosity = (function (exports) {
31840
31839
  calm: "7d47617d-a60a-41d1-8df6-cfb78d02ffeb",
31841
31840
  accelerometer: "84501dee-8665-4073-b111-bdecd69fb489",
31842
31841
  signalQuality: "cf28ed0c-20cd-48ed-93c5-ee2fb265099a",
31842
+ signalQualityV2: "902ac5f3-ce59-4c11-94fa-437e89f90630",
31843
31843
  raw: "009cf0bb-b68d-4af1-a0e5-625f2eb964a6",
31844
31844
  rawUnfiltered: "5472432e-3313-4169-add8-6fcb29accb0e",
31845
31845
  psd: "d6684fb0-8518-40c0-8e88-4634e762435d",
@@ -31900,20 +31900,14 @@ var Neurosity = (function (exports) {
31900
31900
  const metrics = {
31901
31901
  kinesis,
31902
31902
  predictions: kinesis,
31903
- channelAnalysis: channelNames,
31904
31903
  signalQuality: channelNames,
31905
- status: {
31906
- state: {},
31907
- battery: {},
31908
- charging: {},
31909
- connected: {},
31910
- connectedSince: {},
31911
- connectedLast: {},
31912
- updatingProgress: {},
31913
- simulate: {},
31914
- ssid: {}
31904
+ signalQualityV2: {
31905
+ timestamp: {},
31906
+ overall: {},
31907
+ byChannel: {}
31915
31908
  },
31916
31909
  accelerometer: {
31910
+ timestamp: {},
31917
31911
  acceleration: {},
31918
31912
  inclination: {},
31919
31913
  orientation: {},
@@ -32351,6 +32345,13 @@ var Neurosity = (function (exports) {
32351
32345
  return new Error(`${prefix}You are trying to access data with an OAuth token or API key without access to the following scopes: ${requiredScopes.join(", ")}.`);
32352
32346
  }
32353
32347
 
32348
+ /**
32349
+ * Create a bound version of a function with a specified `this` context
32350
+ *
32351
+ * @param {Function} fn - The function to bind
32352
+ * @param {*} thisArg - The value to be passed as the `this` parameter
32353
+ * @returns {Function} A new function that will call the original function with the specified `this` context
32354
+ */
32354
32355
  function bind(fn, thisArg) {
32355
32356
  return function wrap() {
32356
32357
  return fn.apply(thisArg, arguments);
@@ -32359,29 +32360,30 @@ var Neurosity = (function (exports) {
32359
32360
 
32360
32361
  // utils is a library of generic helper functions non-specific to axios
32361
32362
 
32362
- const {toString} = Object.prototype;
32363
- const {getPrototypeOf} = Object;
32363
+ const { toString } = Object.prototype;
32364
+ const { getPrototypeOf } = Object;
32365
+ const { iterator, toStringTag } = Symbol;
32364
32366
 
32365
- const kindOf = (cache => thing => {
32366
- const str = toString.call(thing);
32367
- return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase());
32367
+ const kindOf = ((cache) => (thing) => {
32368
+ const str = toString.call(thing);
32369
+ return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase());
32368
32370
  })(Object.create(null));
32369
32371
 
32370
32372
  const kindOfTest = (type) => {
32371
32373
  type = type.toLowerCase();
32372
- return (thing) => kindOf(thing) === type
32374
+ return (thing) => kindOf(thing) === type;
32373
32375
  };
32374
32376
 
32375
- const typeOfTest = type => thing => typeof thing === type;
32377
+ const typeOfTest = (type) => (thing) => typeof thing === type;
32376
32378
 
32377
32379
  /**
32378
- * Determine if a value is an Array
32380
+ * Determine if a value is a non-null object
32379
32381
  *
32380
32382
  * @param {Object} val The value to test
32381
32383
  *
32382
32384
  * @returns {boolean} True if value is an Array, otherwise false
32383
32385
  */
32384
- const {isArray} = Array;
32386
+ const { isArray } = Array;
32385
32387
 
32386
32388
  /**
32387
32389
  * Determine if a value is undefined
@@ -32400,8 +32402,14 @@ var Neurosity = (function (exports) {
32400
32402
  * @returns {boolean} True if value is a Buffer, otherwise false
32401
32403
  */
32402
32404
  function isBuffer(val) {
32403
- return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor)
32404
- && isFunction$1(val.constructor.isBuffer) && val.constructor.isBuffer(val);
32405
+ return (
32406
+ val !== null &&
32407
+ !isUndefined(val) &&
32408
+ val.constructor !== null &&
32409
+ !isUndefined(val.constructor) &&
32410
+ isFunction$2(val.constructor.isBuffer) &&
32411
+ val.constructor.isBuffer(val)
32412
+ );
32405
32413
  }
32406
32414
 
32407
32415
  /**
@@ -32413,7 +32421,6 @@ var Neurosity = (function (exports) {
32413
32421
  */
32414
32422
  const isArrayBuffer = kindOfTest('ArrayBuffer');
32415
32423
 
32416
-
32417
32424
  /**
32418
32425
  * Determine if a value is a view on an ArrayBuffer
32419
32426
  *
@@ -32423,10 +32430,10 @@ var Neurosity = (function (exports) {
32423
32430
  */
32424
32431
  function isArrayBufferView(val) {
32425
32432
  let result;
32426
- if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {
32433
+ if (typeof ArrayBuffer !== 'undefined' && ArrayBuffer.isView) {
32427
32434
  result = ArrayBuffer.isView(val);
32428
32435
  } else {
32429
- result = (val) && (val.buffer) && (isArrayBuffer(val.buffer));
32436
+ result = val && val.buffer && isArrayBuffer(val.buffer);
32430
32437
  }
32431
32438
  return result;
32432
32439
  }
@@ -32446,7 +32453,7 @@ var Neurosity = (function (exports) {
32446
32453
  * @param {*} val The value to test
32447
32454
  * @returns {boolean} True if value is a Function, otherwise false
32448
32455
  */
32449
- const isFunction$1 = typeOfTest('function');
32456
+ const isFunction$2 = typeOfTest('function');
32450
32457
 
32451
32458
  /**
32452
32459
  * Determine if a value is a Number
@@ -32472,7 +32479,7 @@ var Neurosity = (function (exports) {
32472
32479
  * @param {*} thing The value to test
32473
32480
  * @returns {boolean} True if value is a Boolean, otherwise false
32474
32481
  */
32475
- const isBoolean = thing => thing === true || thing === false;
32482
+ const isBoolean = (thing) => thing === true || thing === false;
32476
32483
 
32477
32484
  /**
32478
32485
  * Determine if a value is a plain Object
@@ -32487,7 +32494,34 @@ var Neurosity = (function (exports) {
32487
32494
  }
32488
32495
 
32489
32496
  const prototype = getPrototypeOf(val);
32490
- return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(Symbol.toStringTag in val) && !(Symbol.iterator in val);
32497
+ return (
32498
+ (prototype === null ||
32499
+ prototype === Object.prototype ||
32500
+ Object.getPrototypeOf(prototype) === null) &&
32501
+ !(toStringTag in val) &&
32502
+ !(iterator in val)
32503
+ );
32504
+ };
32505
+
32506
+ /**
32507
+ * Determine if a value is an empty object (safely handles Buffers)
32508
+ *
32509
+ * @param {*} val The value to test
32510
+ *
32511
+ * @returns {boolean} True if value is an empty object, otherwise false
32512
+ */
32513
+ const isEmptyObject = (val) => {
32514
+ // Early return for non-objects or Buffers to prevent RangeError
32515
+ if (!isObject$1(val) || isBuffer(val)) {
32516
+ return false;
32517
+ }
32518
+
32519
+ try {
32520
+ return Object.keys(val).length === 0 && Object.getPrototypeOf(val) === Object.prototype;
32521
+ } catch (e) {
32522
+ // Fallback for any other objects that might cause RangeError with Object.keys()
32523
+ return false;
32524
+ }
32491
32525
  };
32492
32526
 
32493
32527
  /**
@@ -32508,6 +32542,31 @@ var Neurosity = (function (exports) {
32508
32542
  */
32509
32543
  const isFile = kindOfTest('File');
32510
32544
 
32545
+ /**
32546
+ * Determine if a value is a React Native Blob
32547
+ * React Native "blob": an object with a `uri` attribute. Optionally, it can
32548
+ * also have a `name` and `type` attribute to specify filename and content type
32549
+ *
32550
+ * @see https://github.com/facebook/react-native/blob/26684cf3adf4094eb6c405d345a75bf8c7c0bf88/Libraries/Network/FormData.js#L68-L71
32551
+ *
32552
+ * @param {*} value The value to test
32553
+ *
32554
+ * @returns {boolean} True if value is a React Native Blob, otherwise false
32555
+ */
32556
+ const isReactNativeBlob = (value) => {
32557
+ return !!(value && typeof value.uri !== 'undefined');
32558
+ };
32559
+
32560
+ /**
32561
+ * Determine if environment is React Native
32562
+ * ReactNative `FormData` has a non-standard `getParts()` method
32563
+ *
32564
+ * @param {*} formData The formData to test
32565
+ *
32566
+ * @returns {boolean} True if environment is React Native, otherwise false
32567
+ */
32568
+ const isReactNative = (formData) => formData && typeof formData.getParts !== 'undefined';
32569
+
32511
32570
  /**
32512
32571
  * Determine if a value is a Blob
32513
32572
  *
@@ -32533,7 +32592,7 @@ var Neurosity = (function (exports) {
32533
32592
  *
32534
32593
  * @returns {boolean} True if value is a Stream, otherwise false
32535
32594
  */
32536
- const isStream = (val) => isObject$1(val) && isFunction$1(val.pipe);
32595
+ const isStream = (val) => isObject$1(val) && isFunction$2(val.pipe);
32537
32596
 
32538
32597
  /**
32539
32598
  * Determine if a value is a FormData
@@ -32542,17 +32601,28 @@ var Neurosity = (function (exports) {
32542
32601
  *
32543
32602
  * @returns {boolean} True if value is an FormData, otherwise false
32544
32603
  */
32604
+ function getGlobal() {
32605
+ if (typeof globalThis !== 'undefined') return globalThis;
32606
+ if (typeof self !== 'undefined') return self;
32607
+ if (typeof window !== 'undefined') return window;
32608
+ if (typeof global !== 'undefined') return global;
32609
+ return {};
32610
+ }
32611
+
32612
+ const G = getGlobal();
32613
+ const FormDataCtor = typeof G.FormData !== 'undefined' ? G.FormData : undefined;
32614
+
32545
32615
  const isFormData = (thing) => {
32546
32616
  let kind;
32547
32617
  return thing && (
32548
- (typeof FormData === 'function' && thing instanceof FormData) || (
32549
- isFunction$1(thing.append) && (
32618
+ (FormDataCtor && thing instanceof FormDataCtor) || (
32619
+ isFunction$2(thing.append) && (
32550
32620
  (kind = kindOf(thing)) === 'formdata' ||
32551
32621
  // detect form-data instance
32552
- (kind === 'object' && isFunction$1(thing.toString) && thing.toString() === '[object FormData]')
32622
+ (kind === 'object' && isFunction$2(thing.toString) && thing.toString() === '[object FormData]')
32553
32623
  )
32554
32624
  )
32555
- )
32625
+ );
32556
32626
  };
32557
32627
 
32558
32628
  /**
@@ -32564,6 +32634,13 @@ var Neurosity = (function (exports) {
32564
32634
  */
32565
32635
  const isURLSearchParams = kindOfTest('URLSearchParams');
32566
32636
 
32637
+ const [isReadableStream, isRequest, isResponse, isHeaders] = [
32638
+ 'ReadableStream',
32639
+ 'Request',
32640
+ 'Response',
32641
+ 'Headers',
32642
+ ].map(kindOfTest);
32643
+
32567
32644
  /**
32568
32645
  * Trim excess whitespace off the beginning and end of a string
32569
32646
  *
@@ -32571,9 +32648,9 @@ var Neurosity = (function (exports) {
32571
32648
  *
32572
32649
  * @returns {String} The String freed of excess whitespace
32573
32650
  */
32574
- const trim = (str) => str.trim ?
32575
- str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
32576
-
32651
+ const trim = (str) => {
32652
+ return str.trim ? str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
32653
+ };
32577
32654
  /**
32578
32655
  * Iterate over an Array or an Object invoking a function for each item.
32579
32656
  *
@@ -32583,13 +32660,14 @@ var Neurosity = (function (exports) {
32583
32660
  * If 'obj' is an Object callback will be called passing
32584
32661
  * the value, key, and complete object for each property.
32585
32662
  *
32586
- * @param {Object|Array} obj The object to iterate
32663
+ * @param {Object|Array<unknown>} obj The object to iterate
32587
32664
  * @param {Function} fn The callback to invoke for each item
32588
32665
  *
32589
- * @param {Boolean} [allOwnKeys = false]
32666
+ * @param {Object} [options]
32667
+ * @param {Boolean} [options.allOwnKeys = false]
32590
32668
  * @returns {any}
32591
32669
  */
32592
- function forEach(obj, fn, {allOwnKeys = false} = {}) {
32670
+ function forEach(obj, fn, { allOwnKeys = false } = {}) {
32593
32671
  // Don't bother if no value provided
32594
32672
  if (obj === null || typeof obj === 'undefined') {
32595
32673
  return;
@@ -32610,6 +32688,11 @@ var Neurosity = (function (exports) {
32610
32688
  fn.call(null, obj[i], i, obj);
32611
32689
  }
32612
32690
  } else {
32691
+ // Buffer check
32692
+ if (isBuffer(obj)) {
32693
+ return;
32694
+ }
32695
+
32613
32696
  // Iterate over object keys
32614
32697
  const keys = allOwnKeys ? Object.getOwnPropertyNames(obj) : Object.keys(obj);
32615
32698
  const len = keys.length;
@@ -32622,7 +32705,19 @@ var Neurosity = (function (exports) {
32622
32705
  }
32623
32706
  }
32624
32707
 
32708
+ /**
32709
+ * Finds a key in an object, case-insensitive, returning the actual key name.
32710
+ * Returns null if the object is a Buffer or if no match is found.
32711
+ *
32712
+ * @param {Object} obj - The object to search.
32713
+ * @param {string} key - The key to find (case-insensitive).
32714
+ * @returns {?string} The actual key name if found, otherwise null.
32715
+ */
32625
32716
  function findKey(obj, key) {
32717
+ if (isBuffer(obj)) {
32718
+ return null;
32719
+ }
32720
+
32626
32721
  key = key.toLowerCase();
32627
32722
  const keys = Object.keys(obj);
32628
32723
  let i = keys.length;
@@ -32638,8 +32733,8 @@ var Neurosity = (function (exports) {
32638
32733
 
32639
32734
  const _global = (() => {
32640
32735
  /*eslint no-undef:0*/
32641
- if (typeof globalThis !== "undefined") return globalThis;
32642
- return typeof self !== "undefined" ? self : (typeof window !== 'undefined' ? window : global)
32736
+ if (typeof globalThis !== 'undefined') return globalThis;
32737
+ return typeof self !== 'undefined' ? self : typeof window !== 'undefined' ? window : global;
32643
32738
  })();
32644
32739
 
32645
32740
  const isContextDefined = (context) => !isUndefined(context) && context !== _global;
@@ -32654,7 +32749,7 @@ var Neurosity = (function (exports) {
32654
32749
  * Example:
32655
32750
  *
32656
32751
  * ```js
32657
- * var result = merge({foo: 123}, {foo: 456});
32752
+ * const result = merge({foo: 123}, {foo: 456});
32658
32753
  * console.log(result.foo); // outputs 456
32659
32754
  * ```
32660
32755
  *
@@ -32663,17 +32758,22 @@ var Neurosity = (function (exports) {
32663
32758
  * @returns {Object} Result of all merge properties
32664
32759
  */
32665
32760
  function merge(/* obj1, obj2, obj3, ... */) {
32666
- const {caseless} = isContextDefined(this) && this || {};
32761
+ const { caseless, skipUndefined } = (isContextDefined(this) && this) || {};
32667
32762
  const result = {};
32668
32763
  const assignValue = (val, key) => {
32669
- const targetKey = caseless && findKey(result, key) || key;
32764
+ // Skip dangerous property names to prevent prototype pollution
32765
+ if (key === '__proto__' || key === 'constructor' || key === 'prototype') {
32766
+ return;
32767
+ }
32768
+
32769
+ const targetKey = (caseless && findKey(result, key)) || key;
32670
32770
  if (isPlainObject(result[targetKey]) && isPlainObject(val)) {
32671
32771
  result[targetKey] = merge(result[targetKey], val);
32672
32772
  } else if (isPlainObject(val)) {
32673
32773
  result[targetKey] = merge({}, val);
32674
32774
  } else if (isArray(val)) {
32675
32775
  result[targetKey] = val.slice();
32676
- } else {
32776
+ } else if (!skipUndefined || !isUndefined(val)) {
32677
32777
  result[targetKey] = val;
32678
32778
  }
32679
32779
  };
@@ -32691,17 +32791,32 @@ var Neurosity = (function (exports) {
32691
32791
  * @param {Object} b The object to copy properties from
32692
32792
  * @param {Object} thisArg The object to bind function to
32693
32793
  *
32694
- * @param {Boolean} [allOwnKeys]
32794
+ * @param {Object} [options]
32795
+ * @param {Boolean} [options.allOwnKeys]
32695
32796
  * @returns {Object} The resulting value of object a
32696
32797
  */
32697
- const extend = (a, b, thisArg, {allOwnKeys}= {}) => {
32698
- forEach(b, (val, key) => {
32699
- if (thisArg && isFunction$1(val)) {
32700
- a[key] = bind(val, thisArg);
32701
- } else {
32702
- a[key] = val;
32703
- }
32704
- }, {allOwnKeys});
32798
+ const extend = (a, b, thisArg, { allOwnKeys } = {}) => {
32799
+ forEach(
32800
+ b,
32801
+ (val, key) => {
32802
+ if (thisArg && isFunction$2(val)) {
32803
+ Object.defineProperty(a, key, {
32804
+ value: bind(val, thisArg),
32805
+ writable: true,
32806
+ enumerable: true,
32807
+ configurable: true,
32808
+ });
32809
+ } else {
32810
+ Object.defineProperty(a, key, {
32811
+ value: val,
32812
+ writable: true,
32813
+ enumerable: true,
32814
+ configurable: true,
32815
+ });
32816
+ }
32817
+ },
32818
+ { allOwnKeys }
32819
+ );
32705
32820
  return a;
32706
32821
  };
32707
32822
 
@@ -32713,7 +32828,7 @@ var Neurosity = (function (exports) {
32713
32828
  * @returns {string} content value without BOM
32714
32829
  */
32715
32830
  const stripBOM = (content) => {
32716
- if (content.charCodeAt(0) === 0xFEFF) {
32831
+ if (content.charCodeAt(0) === 0xfeff) {
32717
32832
  content = content.slice(1);
32718
32833
  }
32719
32834
  return content;
@@ -32730,9 +32845,14 @@ var Neurosity = (function (exports) {
32730
32845
  */
32731
32846
  const inherits = (constructor, superConstructor, props, descriptors) => {
32732
32847
  constructor.prototype = Object.create(superConstructor.prototype, descriptors);
32733
- constructor.prototype.constructor = constructor;
32848
+ Object.defineProperty(constructor.prototype, 'constructor', {
32849
+ value: constructor,
32850
+ writable: true,
32851
+ enumerable: false,
32852
+ configurable: true,
32853
+ });
32734
32854
  Object.defineProperty(constructor, 'super', {
32735
- value: superConstructor.prototype
32855
+ value: superConstructor.prototype,
32736
32856
  });
32737
32857
  props && Object.assign(constructor.prototype, props);
32738
32858
  };
@@ -32791,7 +32911,6 @@ var Neurosity = (function (exports) {
32791
32911
  return lastIndex !== -1 && lastIndex === position;
32792
32912
  };
32793
32913
 
32794
-
32795
32914
  /**
32796
32915
  * Returns new array from array like object or null if failed
32797
32916
  *
@@ -32820,9 +32939,9 @@ var Neurosity = (function (exports) {
32820
32939
  * @returns {Array}
32821
32940
  */
32822
32941
  // eslint-disable-next-line func-names
32823
- const isTypedArray = (TypedArray => {
32942
+ const isTypedArray = ((TypedArray) => {
32824
32943
  // eslint-disable-next-line func-names
32825
- return thing => {
32944
+ return (thing) => {
32826
32945
  return TypedArray && thing instanceof TypedArray;
32827
32946
  };
32828
32947
  })(typeof Uint8Array !== 'undefined' && getPrototypeOf(Uint8Array));
@@ -32836,13 +32955,13 @@ var Neurosity = (function (exports) {
32836
32955
  * @returns {void}
32837
32956
  */
32838
32957
  const forEachEntry = (obj, fn) => {
32839
- const generator = obj && obj[Symbol.iterator];
32958
+ const generator = obj && obj[iterator];
32840
32959
 
32841
- const iterator = generator.call(obj);
32960
+ const _iterator = generator.call(obj);
32842
32961
 
32843
32962
  let result;
32844
32963
 
32845
- while ((result = iterator.next()) && !result.done) {
32964
+ while ((result = _iterator.next()) && !result.done) {
32846
32965
  const pair = result.value;
32847
32966
  fn.call(obj, pair[0], pair[1]);
32848
32967
  }
@@ -32870,16 +32989,18 @@ var Neurosity = (function (exports) {
32870
32989
  /* Checking if the kindOfTest function returns true when passed an HTMLFormElement. */
32871
32990
  const isHTMLForm = kindOfTest('HTMLFormElement');
32872
32991
 
32873
- const toCamelCase = str => {
32874
- return str.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,
32875
- function replacer(m, p1, p2) {
32876
- return p1.toUpperCase() + p2;
32877
- }
32878
- );
32992
+ const toCamelCase = (str) => {
32993
+ return str.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g, function replacer(m, p1, p2) {
32994
+ return p1.toUpperCase() + p2;
32995
+ });
32879
32996
  };
32880
32997
 
32881
32998
  /* Creating a function that will check if an object has a property. */
32882
- const hasOwnProperty = (({hasOwnProperty}) => (obj, prop) => hasOwnProperty.call(obj, prop))(Object.prototype);
32999
+ const hasOwnProperty = (
33000
+ ({ hasOwnProperty }) =>
33001
+ (obj, prop) =>
33002
+ hasOwnProperty.call(obj, prop)
33003
+ )(Object.prototype);
32883
33004
 
32884
33005
  /**
32885
33006
  * Determine if a value is a RegExp object
@@ -32912,13 +33033,13 @@ var Neurosity = (function (exports) {
32912
33033
  const freezeMethods = (obj) => {
32913
33034
  reduceDescriptors(obj, (descriptor, name) => {
32914
33035
  // skip restricted props in strict mode
32915
- if (isFunction$1(obj) && ['arguments', 'caller', 'callee'].indexOf(name) !== -1) {
33036
+ if (isFunction$2(obj) && ['arguments', 'caller', 'callee'].indexOf(name) !== -1) {
32916
33037
  return false;
32917
33038
  }
32918
33039
 
32919
33040
  const value = obj[name];
32920
33041
 
32921
- if (!isFunction$1(value)) return;
33042
+ if (!isFunction$2(value)) return;
32922
33043
 
32923
33044
  descriptor.enumerable = false;
32924
33045
 
@@ -32929,17 +33050,25 @@ var Neurosity = (function (exports) {
32929
33050
 
32930
33051
  if (!descriptor.set) {
32931
33052
  descriptor.set = () => {
32932
- throw Error('Can not rewrite read-only method \'' + name + '\'');
33053
+ throw Error("Can not rewrite read-only method '" + name + "'");
32933
33054
  };
32934
33055
  }
32935
33056
  });
32936
33057
  };
32937
33058
 
33059
+ /**
33060
+ * Converts an array or a delimited string into an object set with values as keys and true as values.
33061
+ * Useful for fast membership checks.
33062
+ *
33063
+ * @param {Array|string} arrayOrString - The array or string to convert.
33064
+ * @param {string} delimiter - The delimiter to use if input is a string.
33065
+ * @returns {Object} An object with keys from the array or string, values set to true.
33066
+ */
32938
33067
  const toObjectSet = (arrayOrString, delimiter) => {
32939
33068
  const obj = {};
32940
33069
 
32941
33070
  const define = (arr) => {
32942
- arr.forEach(value => {
33071
+ arr.forEach((value) => {
32943
33072
  obj[value] = true;
32944
33073
  });
32945
33074
  };
@@ -32952,28 +33081,7 @@ var Neurosity = (function (exports) {
32952
33081
  const noop = () => {};
32953
33082
 
32954
33083
  const toFiniteNumber = (value, defaultValue) => {
32955
- value = +value;
32956
- return Number.isFinite(value) ? value : defaultValue;
32957
- };
32958
-
32959
- const ALPHA = 'abcdefghijklmnopqrstuvwxyz';
32960
-
32961
- const DIGIT = '0123456789';
32962
-
32963
- const ALPHABET = {
32964
- DIGIT,
32965
- ALPHA,
32966
- ALPHA_DIGIT: ALPHA + ALPHA.toUpperCase() + DIGIT
32967
- };
32968
-
32969
- const generateString = (size = 16, alphabet = ALPHABET.ALPHA_DIGIT) => {
32970
- let str = '';
32971
- const {length} = alphabet;
32972
- while (size--) {
32973
- str += alphabet[Math.random() * length|0];
32974
- }
32975
-
32976
- return str;
33084
+ return value != null && Number.isFinite((value = +value)) ? value : defaultValue;
32977
33085
  };
32978
33086
 
32979
33087
  /**
@@ -32984,20 +33092,35 @@ var Neurosity = (function (exports) {
32984
33092
  * @returns {boolean}
32985
33093
  */
32986
33094
  function isSpecCompliantForm(thing) {
32987
- return !!(thing && isFunction$1(thing.append) && thing[Symbol.toStringTag] === 'FormData' && thing[Symbol.iterator]);
33095
+ return !!(
33096
+ thing &&
33097
+ isFunction$2(thing.append) &&
33098
+ thing[toStringTag] === 'FormData' &&
33099
+ thing[iterator]
33100
+ );
32988
33101
  }
32989
33102
 
33103
+ /**
33104
+ * Recursively converts an object to a JSON-compatible object, handling circular references and Buffers.
33105
+ *
33106
+ * @param {Object} obj - The object to convert.
33107
+ * @returns {Object} The JSON-compatible object.
33108
+ */
32990
33109
  const toJSONObject = (obj) => {
32991
33110
  const stack = new Array(10);
32992
33111
 
32993
33112
  const visit = (source, i) => {
32994
-
32995
33113
  if (isObject$1(source)) {
32996
33114
  if (stack.indexOf(source) >= 0) {
32997
33115
  return;
32998
33116
  }
32999
33117
 
33000
- if(!('toJSON' in source)) {
33118
+ //Buffer check
33119
+ if (isBuffer(source)) {
33120
+ return source;
33121
+ }
33122
+
33123
+ if (!('toJSON' in source)) {
33001
33124
  stack[i] = source;
33002
33125
  const target = isArray(source) ? [] : {};
33003
33126
 
@@ -33018,10 +33141,76 @@ var Neurosity = (function (exports) {
33018
33141
  return visit(obj, 0);
33019
33142
  };
33020
33143
 
33144
+ /**
33145
+ * Determines if a value is an async function.
33146
+ *
33147
+ * @param {*} thing - The value to test.
33148
+ * @returns {boolean} True if value is an async function, otherwise false.
33149
+ */
33021
33150
  const isAsyncFn = kindOfTest('AsyncFunction');
33022
33151
 
33152
+ /**
33153
+ * Determines if a value is thenable (has then and catch methods).
33154
+ *
33155
+ * @param {*} thing - The value to test.
33156
+ * @returns {boolean} True if value is thenable, otherwise false.
33157
+ */
33023
33158
  const isThenable = (thing) =>
33024
- thing && (isObject$1(thing) || isFunction$1(thing)) && isFunction$1(thing.then) && isFunction$1(thing.catch);
33159
+ thing &&
33160
+ (isObject$1(thing) || isFunction$2(thing)) &&
33161
+ isFunction$2(thing.then) &&
33162
+ isFunction$2(thing.catch);
33163
+
33164
+ // original code
33165
+ // https://github.com/DigitalBrainJS/AxiosPromise/blob/16deab13710ec09779922131f3fa5954320f83ab/lib/utils.js#L11-L34
33166
+
33167
+ /**
33168
+ * Provides a cross-platform setImmediate implementation.
33169
+ * Uses native setImmediate if available, otherwise falls back to postMessage or setTimeout.
33170
+ *
33171
+ * @param {boolean} setImmediateSupported - Whether setImmediate is supported.
33172
+ * @param {boolean} postMessageSupported - Whether postMessage is supported.
33173
+ * @returns {Function} A function to schedule a callback asynchronously.
33174
+ */
33175
+ const _setImmediate = ((setImmediateSupported, postMessageSupported) => {
33176
+ if (setImmediateSupported) {
33177
+ return setImmediate;
33178
+ }
33179
+
33180
+ return postMessageSupported
33181
+ ? ((token, callbacks) => {
33182
+ _global.addEventListener(
33183
+ 'message',
33184
+ ({ source, data }) => {
33185
+ if (source === _global && data === token) {
33186
+ callbacks.length && callbacks.shift()();
33187
+ }
33188
+ },
33189
+ false
33190
+ );
33191
+
33192
+ return (cb) => {
33193
+ callbacks.push(cb);
33194
+ _global.postMessage(token, '*');
33195
+ };
33196
+ })(`axios@${Math.random()}`, [])
33197
+ : (cb) => setTimeout(cb);
33198
+ })(typeof setImmediate === 'function', isFunction$2(_global.postMessage));
33199
+
33200
+ /**
33201
+ * Schedules a microtask or asynchronous callback as soon as possible.
33202
+ * Uses queueMicrotask if available, otherwise falls back to process.nextTick or _setImmediate.
33203
+ *
33204
+ * @type {Function}
33205
+ */
33206
+ const asap =
33207
+ typeof queueMicrotask !== 'undefined'
33208
+ ? queueMicrotask.bind(_global)
33209
+ : (typeof process !== 'undefined' && process.nextTick) || _setImmediate;
33210
+
33211
+ // *********************
33212
+
33213
+ const isIterable = (thing) => thing != null && isFunction$2(thing[iterator]);
33025
33214
 
33026
33215
  var utils$1 = {
33027
33216
  isArray,
@@ -33034,12 +33223,19 @@ var Neurosity = (function (exports) {
33034
33223
  isBoolean,
33035
33224
  isObject: isObject$1,
33036
33225
  isPlainObject,
33226
+ isEmptyObject,
33227
+ isReadableStream,
33228
+ isRequest,
33229
+ isResponse,
33230
+ isHeaders,
33037
33231
  isUndefined,
33038
33232
  isDate,
33039
33233
  isFile,
33234
+ isReactNativeBlob,
33235
+ isReactNative,
33040
33236
  isBlob,
33041
33237
  isRegExp,
33042
- isFunction: isFunction$1,
33238
+ isFunction: isFunction$2,
33043
33239
  isStream,
33044
33240
  isURLSearchParams,
33045
33241
  isTypedArray,
@@ -33069,44 +33265,66 @@ var Neurosity = (function (exports) {
33069
33265
  findKey,
33070
33266
  global: _global,
33071
33267
  isContextDefined,
33072
- ALPHABET,
33073
- generateString,
33074
33268
  isSpecCompliantForm,
33075
33269
  toJSONObject,
33076
33270
  isAsyncFn,
33077
- isThenable
33271
+ isThenable,
33272
+ setImmediate: _setImmediate,
33273
+ asap,
33274
+ isIterable,
33078
33275
  };
33079
33276
 
33080
- /**
33081
- * Create an Error with the specified message, config, error code, request and response.
33082
- *
33083
- * @param {string} message The error message.
33084
- * @param {string} [code] The error code (for example, 'ECONNABORTED').
33085
- * @param {Object} [config] The config.
33086
- * @param {Object} [request] The request.
33087
- * @param {Object} [response] The response.
33088
- *
33089
- * @returns {Error} The created error.
33090
- */
33091
- function AxiosError$1(message, code, config, request, response) {
33092
- Error.call(this);
33277
+ let AxiosError$1 = class AxiosError extends Error {
33278
+ static from(error, code, config, request, response, customProps) {
33279
+ const axiosError = new AxiosError(error.message, code || error.code, config, request, response);
33280
+ axiosError.cause = error;
33281
+ axiosError.name = error.name;
33093
33282
 
33094
- if (Error.captureStackTrace) {
33095
- Error.captureStackTrace(this, this.constructor);
33096
- } else {
33097
- this.stack = (new Error()).stack;
33283
+ // Preserve status from the original error if not already set from response
33284
+ if (error.status != null && axiosError.status == null) {
33285
+ axiosError.status = error.status;
33286
+ }
33287
+
33288
+ customProps && Object.assign(axiosError, customProps);
33289
+ return axiosError;
33098
33290
  }
33099
33291
 
33100
- this.message = message;
33101
- this.name = 'AxiosError';
33102
- code && (this.code = code);
33103
- config && (this.config = config);
33104
- request && (this.request = request);
33105
- response && (this.response = response);
33106
- }
33292
+ /**
33293
+ * Create an Error with the specified message, config, error code, request and response.
33294
+ *
33295
+ * @param {string} message The error message.
33296
+ * @param {string} [code] The error code (for example, 'ECONNABORTED').
33297
+ * @param {Object} [config] The config.
33298
+ * @param {Object} [request] The request.
33299
+ * @param {Object} [response] The response.
33300
+ *
33301
+ * @returns {Error} The created error.
33302
+ */
33303
+ constructor(message, code, config, request, response) {
33304
+ super(message);
33305
+
33306
+ // Make message enumerable to maintain backward compatibility
33307
+ // The native Error constructor sets message as non-enumerable,
33308
+ // but axios < v1.13.3 had it as enumerable
33309
+ Object.defineProperty(this, 'message', {
33310
+ value: message,
33311
+ enumerable: true,
33312
+ writable: true,
33313
+ configurable: true
33314
+ });
33315
+
33316
+ this.name = 'AxiosError';
33317
+ this.isAxiosError = true;
33318
+ code && (this.code = code);
33319
+ config && (this.config = config);
33320
+ request && (this.request = request);
33321
+ if (response) {
33322
+ this.response = response;
33323
+ this.status = response.status;
33324
+ }
33325
+ }
33107
33326
 
33108
- utils$1.inherits(AxiosError$1, Error, {
33109
- toJSON: function toJSON() {
33327
+ toJSON() {
33110
33328
  return {
33111
33329
  // Standard
33112
33330
  message: this.message,
@@ -33122,56 +33340,25 @@ var Neurosity = (function (exports) {
33122
33340
  // Axios
33123
33341
  config: utils$1.toJSONObject(this.config),
33124
33342
  code: this.code,
33125
- status: this.response && this.response.status ? this.response.status : null
33343
+ status: this.status,
33126
33344
  };
33127
33345
  }
33128
- });
33129
-
33130
- const prototype$1 = AxiosError$1.prototype;
33131
- const descriptors = {};
33132
-
33133
- [
33134
- 'ERR_BAD_OPTION_VALUE',
33135
- 'ERR_BAD_OPTION',
33136
- 'ECONNABORTED',
33137
- 'ETIMEDOUT',
33138
- 'ERR_NETWORK',
33139
- 'ERR_FR_TOO_MANY_REDIRECTS',
33140
- 'ERR_DEPRECATED',
33141
- 'ERR_BAD_RESPONSE',
33142
- 'ERR_BAD_REQUEST',
33143
- 'ERR_CANCELED',
33144
- 'ERR_NOT_SUPPORT',
33145
- 'ERR_INVALID_URL'
33146
- // eslint-disable-next-line func-names
33147
- ].forEach(code => {
33148
- descriptors[code] = {value: code};
33149
- });
33150
-
33151
- Object.defineProperties(AxiosError$1, descriptors);
33152
- Object.defineProperty(prototype$1, 'isAxiosError', {value: true});
33153
-
33154
- // eslint-disable-next-line func-names
33155
- AxiosError$1.from = (error, code, config, request, response, customProps) => {
33156
- const axiosError = Object.create(prototype$1);
33157
-
33158
- utils$1.toFlatObject(error, axiosError, function filter(obj) {
33159
- return obj !== Error.prototype;
33160
- }, prop => {
33161
- return prop !== 'isAxiosError';
33162
- });
33163
-
33164
- AxiosError$1.call(axiosError, error.message, code, config, request, response);
33165
-
33166
- axiosError.cause = error;
33167
-
33168
- axiosError.name = error.name;
33169
-
33170
- customProps && Object.assign(axiosError, customProps);
33171
-
33172
- return axiosError;
33173
33346
  };
33174
33347
 
33348
+ // This can be changed to static properties as soon as the parser options in .eslint.cjs are updated.
33349
+ AxiosError$1.ERR_BAD_OPTION_VALUE = 'ERR_BAD_OPTION_VALUE';
33350
+ AxiosError$1.ERR_BAD_OPTION = 'ERR_BAD_OPTION';
33351
+ AxiosError$1.ECONNABORTED = 'ECONNABORTED';
33352
+ AxiosError$1.ETIMEDOUT = 'ETIMEDOUT';
33353
+ AxiosError$1.ERR_NETWORK = 'ERR_NETWORK';
33354
+ AxiosError$1.ERR_FR_TOO_MANY_REDIRECTS = 'ERR_FR_TOO_MANY_REDIRECTS';
33355
+ AxiosError$1.ERR_DEPRECATED = 'ERR_DEPRECATED';
33356
+ AxiosError$1.ERR_BAD_RESPONSE = 'ERR_BAD_RESPONSE';
33357
+ AxiosError$1.ERR_BAD_REQUEST = 'ERR_BAD_REQUEST';
33358
+ AxiosError$1.ERR_CANCELED = 'ERR_CANCELED';
33359
+ AxiosError$1.ERR_NOT_SUPPORT = 'ERR_NOT_SUPPORT';
33360
+ AxiosError$1.ERR_INVALID_URL = 'ERR_INVALID_URL';
33361
+
33175
33362
  // eslint-disable-next-line strict
33176
33363
  var httpAdapter = null;
33177
33364
 
@@ -33208,11 +33395,14 @@ var Neurosity = (function (exports) {
33208
33395
  */
33209
33396
  function renderKey(path, key, dots) {
33210
33397
  if (!path) return key;
33211
- return path.concat(key).map(function each(token, i) {
33212
- // eslint-disable-next-line no-param-reassign
33213
- token = removeBrackets(token);
33214
- return !dots && i ? '[' + token + ']' : token;
33215
- }).join(dots ? '.' : '');
33398
+ return path
33399
+ .concat(key)
33400
+ .map(function each(token, i) {
33401
+ // eslint-disable-next-line no-param-reassign
33402
+ token = removeBrackets(token);
33403
+ return !dots && i ? '[' + token + ']' : token;
33404
+ })
33405
+ .join(dots ? '.' : '');
33216
33406
  }
33217
33407
 
33218
33408
  /**
@@ -33262,21 +33452,26 @@ var Neurosity = (function (exports) {
33262
33452
  formData = formData || new (FormData)();
33263
33453
 
33264
33454
  // eslint-disable-next-line no-param-reassign
33265
- options = utils$1.toFlatObject(options, {
33266
- metaTokens: true,
33267
- dots: false,
33268
- indexes: false
33269
- }, false, function defined(option, source) {
33270
- // eslint-disable-next-line no-eq-null,eqeqeq
33271
- return !utils$1.isUndefined(source[option]);
33272
- });
33455
+ options = utils$1.toFlatObject(
33456
+ options,
33457
+ {
33458
+ metaTokens: true,
33459
+ dots: false,
33460
+ indexes: false,
33461
+ },
33462
+ false,
33463
+ function defined(option, source) {
33464
+ // eslint-disable-next-line no-eq-null,eqeqeq
33465
+ return !utils$1.isUndefined(source[option]);
33466
+ }
33467
+ );
33273
33468
 
33274
33469
  const metaTokens = options.metaTokens;
33275
33470
  // eslint-disable-next-line no-use-before-define
33276
33471
  const visitor = options.visitor || defaultVisitor;
33277
33472
  const dots = options.dots;
33278
33473
  const indexes = options.indexes;
33279
- const _Blob = options.Blob || typeof Blob !== 'undefined' && Blob;
33474
+ const _Blob = options.Blob || (typeof Blob !== 'undefined' && Blob);
33280
33475
  const useBlob = _Blob && utils$1.isSpecCompliantForm(formData);
33281
33476
 
33282
33477
  if (!utils$1.isFunction(visitor)) {
@@ -33290,6 +33485,10 @@ var Neurosity = (function (exports) {
33290
33485
  return value.toISOString();
33291
33486
  }
33292
33487
 
33488
+ if (utils$1.isBoolean(value)) {
33489
+ return value.toString();
33490
+ }
33491
+
33293
33492
  if (!useBlob && utils$1.isBlob(value)) {
33294
33493
  throw new AxiosError$1('Blob is not supported. Use a Buffer instead.');
33295
33494
  }
@@ -33314,6 +33513,11 @@ var Neurosity = (function (exports) {
33314
33513
  function defaultVisitor(value, key, path) {
33315
33514
  let arr = value;
33316
33515
 
33516
+ if (utils$1.isReactNative(formData) && utils$1.isReactNativeBlob(value)) {
33517
+ formData.append(renderKey(path, key, dots), convertValue(value));
33518
+ return false;
33519
+ }
33520
+
33317
33521
  if (value && !path && typeof value === 'object') {
33318
33522
  if (utils$1.endsWith(key, '{}')) {
33319
33523
  // eslint-disable-next-line no-param-reassign
@@ -33322,17 +33526,22 @@ var Neurosity = (function (exports) {
33322
33526
  value = JSON.stringify(value);
33323
33527
  } else if (
33324
33528
  (utils$1.isArray(value) && isFlatArray(value)) ||
33325
- ((utils$1.isFileList(value) || utils$1.endsWith(key, '[]')) && (arr = utils$1.toArray(value))
33326
- )) {
33529
+ ((utils$1.isFileList(value) || utils$1.endsWith(key, '[]')) && (arr = utils$1.toArray(value)))
33530
+ ) {
33327
33531
  // eslint-disable-next-line no-param-reassign
33328
33532
  key = removeBrackets(key);
33329
33533
 
33330
33534
  arr.forEach(function each(el, index) {
33331
- !(utils$1.isUndefined(el) || el === null) && formData.append(
33332
- // eslint-disable-next-line no-nested-ternary
33333
- indexes === true ? renderKey([key], index, dots) : (indexes === null ? key : key + '[]'),
33334
- convertValue(el)
33335
- );
33535
+ !(utils$1.isUndefined(el) || el === null) &&
33536
+ formData.append(
33537
+ // eslint-disable-next-line no-nested-ternary
33538
+ indexes === true
33539
+ ? renderKey([key], index, dots)
33540
+ : indexes === null
33541
+ ? key
33542
+ : key + '[]',
33543
+ convertValue(el)
33544
+ );
33336
33545
  });
33337
33546
  return false;
33338
33547
  }
@@ -33352,7 +33561,7 @@ var Neurosity = (function (exports) {
33352
33561
  const exposedHelpers = Object.assign(predicates, {
33353
33562
  defaultVisitor,
33354
33563
  convertValue,
33355
- isVisitable
33564
+ isVisitable,
33356
33565
  });
33357
33566
 
33358
33567
  function build(value, path) {
@@ -33365,9 +33574,9 @@ var Neurosity = (function (exports) {
33365
33574
  stack.push(value);
33366
33575
 
33367
33576
  utils$1.forEach(value, function each(el, key) {
33368
- const result = !(utils$1.isUndefined(el) || el === null) && visitor.call(
33369
- formData, el, utils$1.isString(key) ? key.trim() : key, path, exposedHelpers
33370
- );
33577
+ const result =
33578
+ !(utils$1.isUndefined(el) || el === null) &&
33579
+ visitor.call(formData, el, utils$1.isString(key) ? key.trim() : key, path, exposedHelpers);
33371
33580
 
33372
33581
  if (result === true) {
33373
33582
  build(el, path ? path.concat(key) : [key]);
@@ -33402,7 +33611,7 @@ var Neurosity = (function (exports) {
33402
33611
  ')': '%29',
33403
33612
  '~': '%7E',
33404
33613
  '%20': '+',
33405
- '%00': '\x00'
33614
+ '%00': '\x00',
33406
33615
  };
33407
33616
  return encodeURIComponent(str).replace(/[!'()~]|%20|%00/g, function replacer(match) {
33408
33617
  return charMap[match];
@@ -33430,31 +33639,33 @@ var Neurosity = (function (exports) {
33430
33639
  };
33431
33640
 
33432
33641
  prototype.toString = function toString(encoder) {
33433
- const _encode = encoder ? function(value) {
33434
- return encoder.call(this, value, encode$1);
33435
- } : encode$1;
33642
+ const _encode = encoder
33643
+ ? function (value) {
33644
+ return encoder.call(this, value, encode$1);
33645
+ }
33646
+ : encode$1;
33436
33647
 
33437
- return this._pairs.map(function each(pair) {
33438
- return _encode(pair[0]) + '=' + _encode(pair[1]);
33439
- }, '').join('&');
33648
+ return this._pairs
33649
+ .map(function each(pair) {
33650
+ return _encode(pair[0]) + '=' + _encode(pair[1]);
33651
+ }, '')
33652
+ .join('&');
33440
33653
  };
33441
33654
 
33442
33655
  /**
33443
- * It replaces all instances of the characters `:`, `$`, `,`, `+`, `[`, and `]` with their
33444
- * URI encoded counterparts
33656
+ * It replaces URL-encoded forms of `:`, `$`, `,`, and spaces with
33657
+ * their plain counterparts (`:`, `$`, `,`, `+`).
33445
33658
  *
33446
33659
  * @param {string} val The value to be encoded.
33447
33660
  *
33448
33661
  * @returns {string} The encoded value.
33449
33662
  */
33450
33663
  function encode(val) {
33451
- return encodeURIComponent(val).
33452
- replace(/%3A/gi, ':').
33453
- replace(/%24/g, '$').
33454
- replace(/%2C/gi, ',').
33455
- replace(/%20/g, '+').
33456
- replace(/%5B/gi, '[').
33457
- replace(/%5D/gi, ']');
33664
+ return encodeURIComponent(val)
33665
+ .replace(/%3A/gi, ':')
33666
+ .replace(/%24/g, '$')
33667
+ .replace(/%2C/gi, ',')
33668
+ .replace(/%20/g, '+');
33458
33669
  }
33459
33670
 
33460
33671
  /**
@@ -33462,32 +33673,37 @@ var Neurosity = (function (exports) {
33462
33673
  *
33463
33674
  * @param {string} url The base of the url (e.g., http://www.google.com)
33464
33675
  * @param {object} [params] The params to be appended
33465
- * @param {?object} options
33676
+ * @param {?(object|Function)} options
33466
33677
  *
33467
33678
  * @returns {string} The formatted url
33468
33679
  */
33469
33680
  function buildURL(url, params, options) {
33470
- /*eslint no-param-reassign:0*/
33471
33681
  if (!params) {
33472
33682
  return url;
33473
33683
  }
33474
-
33475
- const _encode = options && options.encode || encode;
33476
33684
 
33477
- const serializeFn = options && options.serialize;
33685
+ const _encode = (options && options.encode) || encode;
33686
+
33687
+ const _options = utils$1.isFunction(options)
33688
+ ? {
33689
+ serialize: options,
33690
+ }
33691
+ : options;
33692
+
33693
+ const serializeFn = _options && _options.serialize;
33478
33694
 
33479
33695
  let serializedParams;
33480
33696
 
33481
33697
  if (serializeFn) {
33482
- serializedParams = serializeFn(params, options);
33698
+ serializedParams = serializeFn(params, _options);
33483
33699
  } else {
33484
- serializedParams = utils$1.isURLSearchParams(params) ?
33485
- params.toString() :
33486
- new AxiosURLSearchParams(params, options).toString(_encode);
33700
+ serializedParams = utils$1.isURLSearchParams(params)
33701
+ ? params.toString()
33702
+ : new AxiosURLSearchParams(params, _options).toString(_encode);
33487
33703
  }
33488
33704
 
33489
33705
  if (serializedParams) {
33490
- const hashmarkIndex = url.indexOf("#");
33706
+ const hashmarkIndex = url.indexOf('#');
33491
33707
 
33492
33708
  if (hashmarkIndex !== -1) {
33493
33709
  url = url.slice(0, hashmarkIndex);
@@ -33508,6 +33724,7 @@ var Neurosity = (function (exports) {
33508
33724
  *
33509
33725
  * @param {Function} fulfilled The function to handle `then` for a `Promise`
33510
33726
  * @param {Function} rejected The function to handle `reject` for a `Promise`
33727
+ * @param {Object} options The options for the interceptor, synchronous and runWhen
33511
33728
  *
33512
33729
  * @return {Number} An ID used to remove interceptor later
33513
33730
  */
@@ -33516,7 +33733,7 @@ var Neurosity = (function (exports) {
33516
33733
  fulfilled,
33517
33734
  rejected,
33518
33735
  synchronous: options ? options.synchronous : false,
33519
- runWhen: options ? options.runWhen : null
33736
+ runWhen: options ? options.runWhen : null,
33520
33737
  });
33521
33738
  return this.handlers.length - 1;
33522
33739
  }
@@ -33526,7 +33743,7 @@ var Neurosity = (function (exports) {
33526
33743
  *
33527
33744
  * @param {Number} id The ID that was returned by `use`
33528
33745
  *
33529
- * @returns {Boolean} `true` if the interceptor was removed, `false` otherwise
33746
+ * @returns {void}
33530
33747
  */
33531
33748
  eject(id) {
33532
33749
  if (this.handlers[id]) {
@@ -33567,7 +33784,8 @@ var Neurosity = (function (exports) {
33567
33784
  var transitionalDefaults = {
33568
33785
  silentJSONParsing: true,
33569
33786
  forcedJSONParsing: true,
33570
- clarifyTimeoutError: false
33787
+ clarifyTimeoutError: false,
33788
+ legacyInterceptorReqResOrdering: true,
33571
33789
  };
33572
33790
 
33573
33791
  var URLSearchParams$1 = typeof URLSearchParams !== 'undefined' ? URLSearchParams : AxiosURLSearchParams;
@@ -33581,13 +33799,15 @@ var Neurosity = (function (exports) {
33581
33799
  classes: {
33582
33800
  URLSearchParams: URLSearchParams$1,
33583
33801
  FormData: FormData$1,
33584
- Blob: Blob$1
33802
+ Blob: Blob$1,
33585
33803
  },
33586
- protocols: ['http', 'https', 'file', 'blob', 'url', 'data']
33804
+ protocols: ['http', 'https', 'file', 'blob', 'url', 'data'],
33587
33805
  };
33588
33806
 
33589
33807
  const hasBrowserEnv = typeof window !== 'undefined' && typeof document !== 'undefined';
33590
33808
 
33809
+ const _navigator = (typeof navigator === 'object' && navigator) || undefined;
33810
+
33591
33811
  /**
33592
33812
  * Determine if we're running in a standard browser environment
33593
33813
  *
@@ -33605,10 +33825,9 @@ var Neurosity = (function (exports) {
33605
33825
  *
33606
33826
  * @returns {boolean}
33607
33827
  */
33608
- const hasStandardBrowserEnv = (
33609
- (product) => {
33610
- return hasBrowserEnv && ['ReactNative', 'NativeScript', 'NS'].indexOf(product) < 0
33611
- })(typeof navigator !== 'undefined' && navigator.product);
33828
+ const hasStandardBrowserEnv =
33829
+ hasBrowserEnv &&
33830
+ (!_navigator || ['ReactNative', 'NativeScript', 'NS'].indexOf(_navigator.product) < 0);
33612
33831
 
33613
33832
  /**
33614
33833
  * Determine if we're running in a standard browser webWorker environment
@@ -33628,29 +33847,34 @@ var Neurosity = (function (exports) {
33628
33847
  );
33629
33848
  })();
33630
33849
 
33850
+ const origin = (hasBrowserEnv && window.location.href) || 'http://localhost';
33851
+
33631
33852
  var utils = /*#__PURE__*/Object.freeze({
33632
33853
  __proto__: null,
33633
33854
  hasBrowserEnv: hasBrowserEnv,
33634
33855
  hasStandardBrowserEnv: hasStandardBrowserEnv,
33635
- hasStandardBrowserWebWorkerEnv: hasStandardBrowserWebWorkerEnv
33856
+ hasStandardBrowserWebWorkerEnv: hasStandardBrowserWebWorkerEnv,
33857
+ navigator: _navigator,
33858
+ origin: origin
33636
33859
  });
33637
33860
 
33638
33861
  var platform = {
33639
33862
  ...utils,
33640
- ...platform$1
33863
+ ...platform$1,
33641
33864
  };
33642
33865
 
33643
33866
  function toURLEncodedForm(data, options) {
33644
- return toFormData$1(data, new platform.classes.URLSearchParams(), Object.assign({
33645
- visitor: function(value, key, path, helpers) {
33867
+ return toFormData$1(data, new platform.classes.URLSearchParams(), {
33868
+ visitor: function (value, key, path, helpers) {
33646
33869
  if (platform.isNode && utils$1.isBuffer(value)) {
33647
33870
  this.append(key, value.toString('base64'));
33648
33871
  return false;
33649
33872
  }
33650
33873
 
33651
33874
  return helpers.defaultVisitor.apply(this, arguments);
33652
- }
33653
- }, options));
33875
+ },
33876
+ ...options,
33877
+ });
33654
33878
  }
33655
33879
 
33656
33880
  /**
@@ -33665,7 +33889,7 @@ var Neurosity = (function (exports) {
33665
33889
  // foo.x.y.z
33666
33890
  // foo-x-y-z
33667
33891
  // foo x y z
33668
- return utils$1.matchAll(/\w+|\[(\w*)]/g, name).map(match => {
33892
+ return utils$1.matchAll(/\w+|\[(\w*)]/g, name).map((match) => {
33669
33893
  return match[0] === '[]' ? '' : match[1] || match[0];
33670
33894
  });
33671
33895
  }
@@ -33700,6 +33924,9 @@ var Neurosity = (function (exports) {
33700
33924
  function formDataToJSON(formData) {
33701
33925
  function buildPath(path, value, target, index) {
33702
33926
  let name = path[index++];
33927
+
33928
+ if (name === '__proto__') return true;
33929
+
33703
33930
  const isNumericKey = Number.isFinite(+name);
33704
33931
  const isLast = index >= path.length;
33705
33932
  name = !name && utils$1.isArray(target) ? target.length : name;
@@ -33766,94 +33993,107 @@ var Neurosity = (function (exports) {
33766
33993
  }
33767
33994
 
33768
33995
  const defaults = {
33769
-
33770
33996
  transitional: transitionalDefaults,
33771
33997
 
33772
- adapter: ['xhr', 'http'],
33998
+ adapter: ['xhr', 'http', 'fetch'],
33773
33999
 
33774
- transformRequest: [function transformRequest(data, headers) {
33775
- const contentType = headers.getContentType() || '';
33776
- const hasJSONContentType = contentType.indexOf('application/json') > -1;
33777
- const isObjectPayload = utils$1.isObject(data);
34000
+ transformRequest: [
34001
+ function transformRequest(data, headers) {
34002
+ const contentType = headers.getContentType() || '';
34003
+ const hasJSONContentType = contentType.indexOf('application/json') > -1;
34004
+ const isObjectPayload = utils$1.isObject(data);
33778
34005
 
33779
- if (isObjectPayload && utils$1.isHTMLForm(data)) {
33780
- data = new FormData(data);
33781
- }
34006
+ if (isObjectPayload && utils$1.isHTMLForm(data)) {
34007
+ data = new FormData(data);
34008
+ }
34009
+
34010
+ const isFormData = utils$1.isFormData(data);
33782
34011
 
33783
- const isFormData = utils$1.isFormData(data);
34012
+ if (isFormData) {
34013
+ return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
34014
+ }
33784
34015
 
33785
- if (isFormData) {
33786
- if (!hasJSONContentType) {
34016
+ if (
34017
+ utils$1.isArrayBuffer(data) ||
34018
+ utils$1.isBuffer(data) ||
34019
+ utils$1.isStream(data) ||
34020
+ utils$1.isFile(data) ||
34021
+ utils$1.isBlob(data) ||
34022
+ utils$1.isReadableStream(data)
34023
+ ) {
33787
34024
  return data;
33788
34025
  }
33789
- return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
33790
- }
34026
+ if (utils$1.isArrayBufferView(data)) {
34027
+ return data.buffer;
34028
+ }
34029
+ if (utils$1.isURLSearchParams(data)) {
34030
+ headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
34031
+ return data.toString();
34032
+ }
33791
34033
 
33792
- if (utils$1.isArrayBuffer(data) ||
33793
- utils$1.isBuffer(data) ||
33794
- utils$1.isStream(data) ||
33795
- utils$1.isFile(data) ||
33796
- utils$1.isBlob(data)
33797
- ) {
33798
- return data;
33799
- }
33800
- if (utils$1.isArrayBufferView(data)) {
33801
- return data.buffer;
33802
- }
33803
- if (utils$1.isURLSearchParams(data)) {
33804
- headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
33805
- return data.toString();
33806
- }
34034
+ let isFileList;
33807
34035
 
33808
- let isFileList;
34036
+ if (isObjectPayload) {
34037
+ if (contentType.indexOf('application/x-www-form-urlencoded') > -1) {
34038
+ return toURLEncodedForm(data, this.formSerializer).toString();
34039
+ }
33809
34040
 
33810
- if (isObjectPayload) {
33811
- if (contentType.indexOf('application/x-www-form-urlencoded') > -1) {
33812
- return toURLEncodedForm(data, this.formSerializer).toString();
33813
- }
34041
+ if (
34042
+ (isFileList = utils$1.isFileList(data)) ||
34043
+ contentType.indexOf('multipart/form-data') > -1
34044
+ ) {
34045
+ const _FormData = this.env && this.env.FormData;
33814
34046
 
33815
- if ((isFileList = utils$1.isFileList(data)) || contentType.indexOf('multipart/form-data') > -1) {
33816
- const _FormData = this.env && this.env.FormData;
34047
+ return toFormData$1(
34048
+ isFileList ? { 'files[]': data } : data,
34049
+ _FormData && new _FormData(),
34050
+ this.formSerializer
34051
+ );
34052
+ }
34053
+ }
33817
34054
 
33818
- return toFormData$1(
33819
- isFileList ? {'files[]': data} : data,
33820
- _FormData && new _FormData(),
33821
- this.formSerializer
33822
- );
34055
+ if (isObjectPayload || hasJSONContentType) {
34056
+ headers.setContentType('application/json', false);
34057
+ return stringifySafely(data);
33823
34058
  }
33824
- }
33825
34059
 
33826
- if (isObjectPayload || hasJSONContentType ) {
33827
- headers.setContentType('application/json', false);
33828
- return stringifySafely(data);
33829
- }
34060
+ return data;
34061
+ },
34062
+ ],
33830
34063
 
33831
- return data;
33832
- }],
34064
+ transformResponse: [
34065
+ function transformResponse(data) {
34066
+ const transitional = this.transitional || defaults.transitional;
34067
+ const forcedJSONParsing = transitional && transitional.forcedJSONParsing;
34068
+ const JSONRequested = this.responseType === 'json';
33833
34069
 
33834
- transformResponse: [function transformResponse(data) {
33835
- const transitional = this.transitional || defaults.transitional;
33836
- const forcedJSONParsing = transitional && transitional.forcedJSONParsing;
33837
- const JSONRequested = this.responseType === 'json';
34070
+ if (utils$1.isResponse(data) || utils$1.isReadableStream(data)) {
34071
+ return data;
34072
+ }
33838
34073
 
33839
- if (data && utils$1.isString(data) && ((forcedJSONParsing && !this.responseType) || JSONRequested)) {
33840
- const silentJSONParsing = transitional && transitional.silentJSONParsing;
33841
- const strictJSONParsing = !silentJSONParsing && JSONRequested;
34074
+ if (
34075
+ data &&
34076
+ utils$1.isString(data) &&
34077
+ ((forcedJSONParsing && !this.responseType) || JSONRequested)
34078
+ ) {
34079
+ const silentJSONParsing = transitional && transitional.silentJSONParsing;
34080
+ const strictJSONParsing = !silentJSONParsing && JSONRequested;
33842
34081
 
33843
- try {
33844
- return JSON.parse(data);
33845
- } catch (e) {
33846
- if (strictJSONParsing) {
33847
- if (e.name === 'SyntaxError') {
33848
- throw AxiosError$1.from(e, AxiosError$1.ERR_BAD_RESPONSE, this, null, this.response);
34082
+ try {
34083
+ return JSON.parse(data, this.parseReviver);
34084
+ } catch (e) {
34085
+ if (strictJSONParsing) {
34086
+ if (e.name === 'SyntaxError') {
34087
+ throw AxiosError$1.from(e, AxiosError$1.ERR_BAD_RESPONSE, this, null, this.response);
34088
+ }
34089
+ throw e;
33849
34090
  }
33850
- throw e;
33851
34091
  }
33852
34092
  }
33853
- }
33854
34093
 
33855
- return data;
33856
- }],
34094
+ return data;
34095
+ },
34096
+ ],
33857
34097
 
33858
34098
  /**
33859
34099
  * A timeout in milliseconds to abort a request. If set to 0 (default) a
@@ -33869,7 +34109,7 @@ var Neurosity = (function (exports) {
33869
34109
 
33870
34110
  env: {
33871
34111
  FormData: platform.classes.FormData,
33872
- Blob: platform.classes.Blob
34112
+ Blob: platform.classes.Blob,
33873
34113
  },
33874
34114
 
33875
34115
  validateStatus: function validateStatus(status) {
@@ -33878,10 +34118,10 @@ var Neurosity = (function (exports) {
33878
34118
 
33879
34119
  headers: {
33880
34120
  common: {
33881
- 'Accept': 'application/json, text/plain, */*',
33882
- 'Content-Type': undefined
33883
- }
33884
- }
34121
+ Accept: 'application/json, text/plain, */*',
34122
+ 'Content-Type': undefined,
34123
+ },
34124
+ },
33885
34125
  };
33886
34126
 
33887
34127
  utils$1.forEach(['delete', 'get', 'head', 'post', 'put', 'patch'], (method) => {
@@ -33891,10 +34131,23 @@ var Neurosity = (function (exports) {
33891
34131
  // RawAxiosHeaders whose duplicates are ignored by node
33892
34132
  // c.f. https://nodejs.org/api/http.html#http_message_headers
33893
34133
  const ignoreDuplicateOf = utils$1.toObjectSet([
33894
- 'age', 'authorization', 'content-length', 'content-type', 'etag',
33895
- 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',
33896
- 'last-modified', 'location', 'max-forwards', 'proxy-authorization',
33897
- 'referer', 'retry-after', 'user-agent'
34134
+ 'age',
34135
+ 'authorization',
34136
+ 'content-length',
34137
+ 'content-type',
34138
+ 'etag',
34139
+ 'expires',
34140
+ 'from',
34141
+ 'host',
34142
+ 'if-modified-since',
34143
+ 'if-unmodified-since',
34144
+ 'last-modified',
34145
+ 'location',
34146
+ 'max-forwards',
34147
+ 'proxy-authorization',
34148
+ 'referer',
34149
+ 'retry-after',
34150
+ 'user-agent',
33898
34151
  ]);
33899
34152
 
33900
34153
  /**
@@ -33911,47 +34164,81 @@ var Neurosity = (function (exports) {
33911
34164
  *
33912
34165
  * @returns {Object} Headers parsed into an object
33913
34166
  */
33914
- var parseHeaders = rawHeaders => {
34167
+ var parseHeaders = (rawHeaders) => {
33915
34168
  const parsed = {};
33916
34169
  let key;
33917
34170
  let val;
33918
34171
  let i;
33919
34172
 
33920
- rawHeaders && rawHeaders.split('\n').forEach(function parser(line) {
33921
- i = line.indexOf(':');
33922
- key = line.substring(0, i).trim().toLowerCase();
33923
- val = line.substring(i + 1).trim();
34173
+ rawHeaders &&
34174
+ rawHeaders.split('\n').forEach(function parser(line) {
34175
+ i = line.indexOf(':');
34176
+ key = line.substring(0, i).trim().toLowerCase();
34177
+ val = line.substring(i + 1).trim();
33924
34178
 
33925
- if (!key || (parsed[key] && ignoreDuplicateOf[key])) {
33926
- return;
33927
- }
34179
+ if (!key || (parsed[key] && ignoreDuplicateOf[key])) {
34180
+ return;
34181
+ }
33928
34182
 
33929
- if (key === 'set-cookie') {
33930
- if (parsed[key]) {
33931
- parsed[key].push(val);
34183
+ if (key === 'set-cookie') {
34184
+ if (parsed[key]) {
34185
+ parsed[key].push(val);
34186
+ } else {
34187
+ parsed[key] = [val];
34188
+ }
33932
34189
  } else {
33933
- parsed[key] = [val];
34190
+ parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
33934
34191
  }
33935
- } else {
33936
- parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
33937
- }
33938
- });
34192
+ });
33939
34193
 
33940
34194
  return parsed;
33941
34195
  };
33942
34196
 
33943
34197
  const $internals = Symbol('internals');
33944
34198
 
34199
+ const isValidHeaderValue = (value) => !/[\r\n]/.test(value);
34200
+
34201
+ function assertValidHeaderValue(value, header) {
34202
+ if (value === false || value == null) {
34203
+ return;
34204
+ }
34205
+
34206
+ if (utils$1.isArray(value)) {
34207
+ value.forEach((v) => assertValidHeaderValue(v, header));
34208
+ return;
34209
+ }
34210
+
34211
+ if (!isValidHeaderValue(String(value))) {
34212
+ throw new Error(`Invalid character in header content ["${header}"]`);
34213
+ }
34214
+ }
34215
+
33945
34216
  function normalizeHeader(header) {
33946
34217
  return header && String(header).trim().toLowerCase();
33947
34218
  }
33948
34219
 
34220
+ function stripTrailingCRLF(str) {
34221
+ let end = str.length;
34222
+
34223
+ while (end > 0) {
34224
+ const charCode = str.charCodeAt(end - 1);
34225
+
34226
+ if (charCode !== 10 && charCode !== 13) {
34227
+ break;
34228
+ }
34229
+
34230
+ end -= 1;
34231
+ }
34232
+
34233
+ return end === str.length ? str : str.slice(0, end);
34234
+ }
34235
+
33949
34236
  function normalizeValue(value) {
33950
34237
  if (value === false || value == null) {
33951
34238
  return value;
33952
34239
  }
33953
34240
 
33954
- return utils$1.isArray(value) ? value.map(normalizeValue) : String(value);
34241
+ return utils$1.isArray(value) ? value.map(normalizeValue) : stripTrailingCRLF(String(value));
33955
34242
  }
33956
34243
 
33957
34244
  function parseTokens(str) {
@@ -33989,8 +34276,10 @@ var Neurosity = (function (exports) {
33989
34276
  }
33990
34277
 
33991
34278
  function formatHeader(header) {
33992
- return header.trim()
33993
- .toLowerCase().replace(/([a-z\d])(\w*)/g, (w, char, str) => {
34279
+ return header
34280
+ .trim()
34281
+ .toLowerCase()
34282
+ .replace(/([a-z\d])(\w*)/g, (w, char, str) => {
33994
34283
  return char.toUpperCase() + str;
33995
34284
  });
33996
34285
  }
@@ -33998,12 +34287,12 @@ var Neurosity = (function (exports) {
33998
34287
  function buildAccessors(obj, header) {
33999
34288
  const accessorName = utils$1.toCamelCase(' ' + header);
34000
34289
 
34001
- ['get', 'set', 'has'].forEach(methodName => {
34290
+ ['get', 'set', 'has'].forEach((methodName) => {
34002
34291
  Object.defineProperty(obj, methodName + accessorName, {
34003
- value: function(arg1, arg2, arg3) {
34292
+ value: function (arg1, arg2, arg3) {
34004
34293
  return this[methodName].call(this, header, arg1, arg2, arg3);
34005
34294
  },
34006
- configurable: true
34295
+ configurable: true,
34007
34296
  });
34008
34297
  });
34009
34298
  }
@@ -34025,7 +34314,13 @@ var Neurosity = (function (exports) {
34025
34314
 
34026
34315
  const key = utils$1.findKey(self, lHeader);
34027
34316
 
34028
- if(!key || self[key] === undefined || _rewrite === true || (_rewrite === undefined && self[key] !== false)) {
34317
+ if (
34318
+ !key ||
34319
+ self[key] === undefined ||
34320
+ _rewrite === true ||
34321
+ (_rewrite === undefined && self[key] !== false)
34322
+ ) {
34323
+ assertValidHeaderValue(_value, _header);
34029
34324
  self[key || _header] = normalizeValue(_value);
34030
34325
  }
34031
34326
  }
@@ -34035,8 +34330,25 @@ var Neurosity = (function (exports) {
34035
34330
 
34036
34331
  if (utils$1.isPlainObject(header) || header instanceof this.constructor) {
34037
34332
  setHeaders(header, valueOrRewrite);
34038
- } else if(utils$1.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
34333
+ } else if (utils$1.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
34039
34334
  setHeaders(parseHeaders(header), valueOrRewrite);
34335
+ } else if (utils$1.isObject(header) && utils$1.isIterable(header)) {
34336
+ let obj = {},
34337
+ dest,
34338
+ key;
34339
+ for (const entry of header) {
34340
+ if (!utils$1.isArray(entry)) {
34341
+ throw TypeError('Object iterator must return a key-value pair');
34342
+ }
34343
+
34344
+ obj[(key = entry[0])] = (dest = obj[key])
34345
+ ? utils$1.isArray(dest)
34346
+ ? [...dest, entry[1]]
34347
+ : [dest, entry[1]]
34348
+ : entry[1];
34349
+ }
34350
+
34351
+ setHeaders(obj, valueOrRewrite);
34040
34352
  } else {
34041
34353
  header != null && setHeader(valueOrRewrite, header, rewrite);
34042
34354
  }
@@ -34080,7 +34392,11 @@ var Neurosity = (function (exports) {
34080
34392
  if (header) {
34081
34393
  const key = utils$1.findKey(this, header);
34082
34394
 
34083
- return !!(key && this[key] !== undefined && (!matcher || matchHeaderValue(this, this[key], key, matcher)));
34395
+ return !!(
34396
+ key &&
34397
+ this[key] !== undefined &&
34398
+ (!matcher || matchHeaderValue(this, this[key], key, matcher))
34399
+ );
34084
34400
  }
34085
34401
 
34086
34402
  return false;
@@ -34120,7 +34436,7 @@ var Neurosity = (function (exports) {
34120
34436
 
34121
34437
  while (i--) {
34122
34438
  const key = keys[i];
34123
- if(!matcher || matchHeaderValue(this, this[key], key, matcher, true)) {
34439
+ if (!matcher || matchHeaderValue(this, this[key], key, matcher, true)) {
34124
34440
  delete this[key];
34125
34441
  deleted = true;
34126
34442
  }
@@ -34164,7 +34480,9 @@ var Neurosity = (function (exports) {
34164
34480
  const obj = Object.create(null);
34165
34481
 
34166
34482
  utils$1.forEach(this, (value, header) => {
34167
- value != null && value !== false && (obj[header] = asStrings && utils$1.isArray(value) ? value.join(', ') : value);
34483
+ value != null &&
34484
+ value !== false &&
34485
+ (obj[header] = asStrings && utils$1.isArray(value) ? value.join(', ') : value);
34168
34486
  });
34169
34487
 
34170
34488
  return obj;
@@ -34175,7 +34493,13 @@ var Neurosity = (function (exports) {
34175
34493
  }
34176
34494
 
34177
34495
  toString() {
34178
- return Object.entries(this.toJSON()).map(([header, value]) => header + ': ' + value).join('\n');
34496
+ return Object.entries(this.toJSON())
34497
+ .map(([header, value]) => header + ': ' + value)
34498
+ .join('\n');
34499
+ }
34500
+
34501
+ getSetCookie() {
34502
+ return this.get('set-cookie') || [];
34179
34503
  }
34180
34504
 
34181
34505
  get [Symbol.toStringTag]() {
@@ -34195,9 +34519,12 @@ var Neurosity = (function (exports) {
34195
34519
  }
34196
34520
 
34197
34521
  static accessor(header) {
34198
- const internals = this[$internals] = (this[$internals] = {
34199
- accessors: {}
34200
- });
34522
+ const internals =
34523
+ (this[$internals] =
34524
+ this[$internals] =
34525
+ {
34526
+ accessors: {},
34527
+ });
34201
34528
 
34202
34529
  const accessors = internals.accessors;
34203
34530
  const prototype = this.prototype;
@@ -34217,17 +34544,24 @@ var Neurosity = (function (exports) {
34217
34544
  }
34218
34545
  };
34219
34546
 
34220
- AxiosHeaders$1.accessor(['Content-Type', 'Content-Length', 'Accept', 'Accept-Encoding', 'User-Agent', 'Authorization']);
34547
+ AxiosHeaders$1.accessor([
34548
+ 'Content-Type',
34549
+ 'Content-Length',
34550
+ 'Accept',
34551
+ 'Accept-Encoding',
34552
+ 'User-Agent',
34553
+ 'Authorization',
34554
+ ]);
34221
34555
 
34222
34556
  // reserved names hotfix
34223
- utils$1.reduceDescriptors(AxiosHeaders$1.prototype, ({value}, key) => {
34557
+ utils$1.reduceDescriptors(AxiosHeaders$1.prototype, ({ value }, key) => {
34224
34558
  let mapped = key[0].toUpperCase() + key.slice(1); // map `set` => `Set`
34225
34559
  return {
34226
34560
  get: () => value,
34227
34561
  set(headerValue) {
34228
34562
  this[mapped] = headerValue;
34229
- }
34230
- }
34563
+ },
34564
+ };
34231
34565
  });
34232
34566
 
34233
34567
  utils$1.freezeMethods(AxiosHeaders$1);
@@ -34259,24 +34593,22 @@ var Neurosity = (function (exports) {
34259
34593
  return !!(value && value.__CANCEL__);
34260
34594
  }
34261
34595
 
34262
- /**
34263
- * A `CanceledError` is an object that is thrown when an operation is canceled.
34264
- *
34265
- * @param {string=} message The message.
34266
- * @param {Object=} config The config.
34267
- * @param {Object=} request The request.
34268
- *
34269
- * @returns {CanceledError} The created error.
34270
- */
34271
- function CanceledError$1(message, config, request) {
34272
- // eslint-disable-next-line no-eq-null,eqeqeq
34273
- AxiosError$1.call(this, message == null ? 'canceled' : message, AxiosError$1.ERR_CANCELED, config, request);
34274
- this.name = 'CanceledError';
34275
- }
34276
-
34277
- utils$1.inherits(CanceledError$1, AxiosError$1, {
34278
- __CANCEL__: true
34279
- });
34596
+ let CanceledError$1 = class CanceledError extends AxiosError$1 {
34597
+ /**
34598
+ * A `CanceledError` is an object that is thrown when an operation is canceled.
34599
+ *
34600
+ * @param {string=} message The message.
34601
+ * @param {Object=} config The config.
34602
+ * @param {Object=} request The request.
34603
+ *
34604
+ * @returns {CanceledError} The created error.
34605
+ */
34606
+ constructor(message, config, request) {
34607
+ super(message == null ? 'canceled' : message, AxiosError$1.ERR_CANCELED, config, request);
34608
+ this.name = 'CanceledError';
34609
+ this.__CANCEL__ = true;
34610
+ }
34611
+ };
34280
34612
 
34281
34613
  /**
34282
34614
  * Resolve or reject a Promise based on response status.
@@ -34292,166 +34624,23 @@ var Neurosity = (function (exports) {
34292
34624
  if (!response.status || !validateStatus || validateStatus(response.status)) {
34293
34625
  resolve(response);
34294
34626
  } else {
34295
- reject(new AxiosError$1(
34296
- 'Request failed with status code ' + response.status,
34297
- [AxiosError$1.ERR_BAD_REQUEST, AxiosError$1.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4],
34298
- response.config,
34299
- response.request,
34300
- response
34301
- ));
34302
- }
34303
- }
34304
-
34305
- var cookies = platform.hasStandardBrowserEnv ?
34306
-
34307
- // Standard browser envs support document.cookie
34308
- {
34309
- write(name, value, expires, path, domain, secure) {
34310
- const cookie = [name + '=' + encodeURIComponent(value)];
34311
-
34312
- utils$1.isNumber(expires) && cookie.push('expires=' + new Date(expires).toGMTString());
34313
-
34314
- utils$1.isString(path) && cookie.push('path=' + path);
34315
-
34316
- utils$1.isString(domain) && cookie.push('domain=' + domain);
34317
-
34318
- secure === true && cookie.push('secure');
34319
-
34320
- document.cookie = cookie.join('; ');
34321
- },
34322
-
34323
- read(name) {
34324
- const match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
34325
- return (match ? decodeURIComponent(match[3]) : null);
34326
- },
34327
-
34328
- remove(name) {
34329
- this.write(name, '', Date.now() - 86400000);
34330
- }
34331
- }
34332
-
34333
- :
34334
-
34335
- // Non-standard browser env (web workers, react-native) lack needed support.
34336
- {
34337
- write() {},
34338
- read() {
34339
- return null;
34340
- },
34341
- remove() {}
34342
- };
34343
-
34344
- /**
34345
- * Determines whether the specified URL is absolute
34346
- *
34347
- * @param {string} url The URL to test
34348
- *
34349
- * @returns {boolean} True if the specified URL is absolute, otherwise false
34350
- */
34351
- function isAbsoluteURL(url) {
34352
- // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
34353
- // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
34354
- // by any combination of letters, digits, plus, period, or hyphen.
34355
- return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
34356
- }
34357
-
34358
- /**
34359
- * Creates a new URL by combining the specified URLs
34360
- *
34361
- * @param {string} baseURL The base URL
34362
- * @param {string} relativeURL The relative URL
34363
- *
34364
- * @returns {string} The combined URL
34365
- */
34366
- function combineURLs(baseURL, relativeURL) {
34367
- return relativeURL
34368
- ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '')
34369
- : baseURL;
34370
- }
34371
-
34372
- /**
34373
- * Creates a new URL by combining the baseURL with the requestedURL,
34374
- * only when the requestedURL is not already an absolute URL.
34375
- * If the requestURL is absolute, this function returns the requestedURL untouched.
34376
- *
34377
- * @param {string} baseURL The base URL
34378
- * @param {string} requestedURL Absolute or relative URL to combine
34379
- *
34380
- * @returns {string} The combined full path
34381
- */
34382
- function buildFullPath(baseURL, requestedURL) {
34383
- if (baseURL && !isAbsoluteURL(requestedURL)) {
34384
- return combineURLs(baseURL, requestedURL);
34627
+ reject(
34628
+ new AxiosError$1(
34629
+ 'Request failed with status code ' + response.status,
34630
+ [AxiosError$1.ERR_BAD_REQUEST, AxiosError$1.ERR_BAD_RESPONSE][
34631
+ Math.floor(response.status / 100) - 4
34632
+ ],
34633
+ response.config,
34634
+ response.request,
34635
+ response
34636
+ )
34637
+ );
34385
34638
  }
34386
- return requestedURL;
34387
34639
  }
34388
34640
 
34389
- var isURLSameOrigin = platform.hasStandardBrowserEnv ?
34390
-
34391
- // Standard browser envs have full support of the APIs needed to test
34392
- // whether the request URL is of the same origin as current location.
34393
- (function standardBrowserEnv() {
34394
- const msie = /(msie|trident)/i.test(navigator.userAgent);
34395
- const urlParsingNode = document.createElement('a');
34396
- let originURL;
34397
-
34398
- /**
34399
- * Parse a URL to discover its components
34400
- *
34401
- * @param {String} url The URL to be parsed
34402
- * @returns {Object}
34403
- */
34404
- function resolveURL(url) {
34405
- let href = url;
34406
-
34407
- if (msie) {
34408
- // IE needs attribute set twice to normalize properties
34409
- urlParsingNode.setAttribute('href', href);
34410
- href = urlParsingNode.href;
34411
- }
34412
-
34413
- urlParsingNode.setAttribute('href', href);
34414
-
34415
- // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
34416
- return {
34417
- href: urlParsingNode.href,
34418
- protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
34419
- host: urlParsingNode.host,
34420
- search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
34421
- hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
34422
- hostname: urlParsingNode.hostname,
34423
- port: urlParsingNode.port,
34424
- pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
34425
- urlParsingNode.pathname :
34426
- '/' + urlParsingNode.pathname
34427
- };
34428
- }
34429
-
34430
- originURL = resolveURL(window.location.href);
34431
-
34432
- /**
34433
- * Determine if a URL shares the same origin as the current location
34434
- *
34435
- * @param {String} requestURL The URL to test
34436
- * @returns {boolean} True if URL shares the same origin, otherwise false
34437
- */
34438
- return function isURLSameOrigin(requestURL) {
34439
- const parsed = (utils$1.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
34440
- return (parsed.protocol === originURL.protocol &&
34441
- parsed.host === originURL.host);
34442
- };
34443
- })() :
34444
-
34445
- // Non standard browser envs (web workers, react-native) lack needed support.
34446
- (function nonStandardBrowserEnv() {
34447
- return function isURLSameOrigin() {
34448
- return true;
34449
- };
34450
- })();
34451
-
34452
34641
  function parseProtocol(url) {
34453
34642
  const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
34454
- return match && match[1] || '';
34643
+ return (match && match[1]) || '';
34455
34644
  }
34456
34645
 
34457
34646
  /**
@@ -34502,15 +34691,58 @@ var Neurosity = (function (exports) {
34502
34691
 
34503
34692
  const passed = startedAt && now - startedAt;
34504
34693
 
34505
- return passed ? Math.round(bytesCount * 1000 / passed) : undefined;
34694
+ return passed ? Math.round((bytesCount * 1000) / passed) : undefined;
34506
34695
  };
34507
34696
  }
34508
34697
 
34509
- function progressEventReducer(listener, isDownloadStream) {
34698
+ /**
34699
+ * Throttle decorator
34700
+ * @param {Function} fn
34701
+ * @param {Number} freq
34702
+ * @return {Function}
34703
+ */
34704
+ function throttle(fn, freq) {
34705
+ let timestamp = 0;
34706
+ let threshold = 1000 / freq;
34707
+ let lastArgs;
34708
+ let timer;
34709
+
34710
+ const invoke = (args, now = Date.now()) => {
34711
+ timestamp = now;
34712
+ lastArgs = null;
34713
+ if (timer) {
34714
+ clearTimeout(timer);
34715
+ timer = null;
34716
+ }
34717
+ fn(...args);
34718
+ };
34719
+
34720
+ const throttled = (...args) => {
34721
+ const now = Date.now();
34722
+ const passed = now - timestamp;
34723
+ if (passed >= threshold) {
34724
+ invoke(args, now);
34725
+ } else {
34726
+ lastArgs = args;
34727
+ if (!timer) {
34728
+ timer = setTimeout(() => {
34729
+ timer = null;
34730
+ invoke(lastArgs);
34731
+ }, threshold - passed);
34732
+ }
34733
+ }
34734
+ };
34735
+
34736
+ const flush = () => lastArgs && invoke(lastArgs);
34737
+
34738
+ return [throttled, flush];
34739
+ }
34740
+
34741
+ const progressEventReducer = (listener, isDownloadStream, freq = 3) => {
34510
34742
  let bytesNotified = 0;
34511
34743
  const _speedometer = speedometer(50, 250);
34512
34744
 
34513
- return e => {
34745
+ return throttle((e) => {
34514
34746
  const loaded = e.loaded;
34515
34747
  const total = e.lengthComputable ? e.total : undefined;
34516
34748
  const progressBytes = loaded - bytesNotified;
@@ -34522,306 +34754,1113 @@ var Neurosity = (function (exports) {
34522
34754
  const data = {
34523
34755
  loaded,
34524
34756
  total,
34525
- progress: total ? (loaded / total) : undefined,
34757
+ progress: total ? loaded / total : undefined,
34526
34758
  bytes: progressBytes,
34527
34759
  rate: rate ? rate : undefined,
34528
34760
  estimated: rate && total && inRange ? (total - loaded) / rate : undefined,
34529
- event: e
34761
+ event: e,
34762
+ lengthComputable: total != null,
34763
+ [isDownloadStream ? 'download' : 'upload']: true,
34530
34764
  };
34531
34765
 
34532
- data[isDownloadStream ? 'download' : 'upload'] = true;
34533
-
34534
34766
  listener(data);
34767
+ }, freq);
34768
+ };
34769
+
34770
+ const progressEventDecorator = (total, throttled) => {
34771
+ const lengthComputable = total != null;
34772
+
34773
+ return [
34774
+ (loaded) =>
34775
+ throttled[0]({
34776
+ lengthComputable,
34777
+ total,
34778
+ loaded,
34779
+ }),
34780
+ throttled[1],
34781
+ ];
34782
+ };
34783
+
34784
+ const asyncDecorator =
34785
+ (fn) =>
34786
+ (...args) =>
34787
+ utils$1.asap(() => fn(...args));
34788
+
34789
+ var isURLSameOrigin = platform.hasStandardBrowserEnv
34790
+ ? ((origin, isMSIE) => (url) => {
34791
+ url = new URL(url, platform.origin);
34792
+
34793
+ return (
34794
+ origin.protocol === url.protocol &&
34795
+ origin.host === url.host &&
34796
+ (isMSIE || origin.port === url.port)
34797
+ );
34798
+ })(
34799
+ new URL(platform.origin),
34800
+ platform.navigator && /(msie|trident)/i.test(platform.navigator.userAgent)
34801
+ )
34802
+ : () => true;
34803
+
34804
+ var cookies = platform.hasStandardBrowserEnv
34805
+ ? // Standard browser envs support document.cookie
34806
+ {
34807
+ write(name, value, expires, path, domain, secure, sameSite) {
34808
+ if (typeof document === 'undefined') return;
34809
+
34810
+ const cookie = [`${name}=${encodeURIComponent(value)}`];
34811
+
34812
+ if (utils$1.isNumber(expires)) {
34813
+ cookie.push(`expires=${new Date(expires).toUTCString()}`);
34814
+ }
34815
+ if (utils$1.isString(path)) {
34816
+ cookie.push(`path=${path}`);
34817
+ }
34818
+ if (utils$1.isString(domain)) {
34819
+ cookie.push(`domain=${domain}`);
34820
+ }
34821
+ if (secure === true) {
34822
+ cookie.push('secure');
34823
+ }
34824
+ if (utils$1.isString(sameSite)) {
34825
+ cookie.push(`SameSite=${sameSite}`);
34826
+ }
34827
+
34828
+ document.cookie = cookie.join('; ');
34829
+ },
34830
+
34831
+ read(name) {
34832
+ if (typeof document === 'undefined') return null;
34833
+ const match = document.cookie.match(new RegExp('(?:^|; )' + name + '=([^;]*)'));
34834
+ return match ? decodeURIComponent(match[1]) : null;
34835
+ },
34836
+
34837
+ remove(name) {
34838
+ this.write(name, '', Date.now() - 86400000, '/');
34839
+ },
34840
+ }
34841
+ : // Non-standard browser env (web workers, react-native) lack needed support.
34842
+ {
34843
+ write() {},
34844
+ read() {
34845
+ return null;
34846
+ },
34847
+ remove() {},
34848
+ };
34849
+
34850
+ /**
34851
+ * Determines whether the specified URL is absolute
34852
+ *
34853
+ * @param {string} url The URL to test
34854
+ *
34855
+ * @returns {boolean} True if the specified URL is absolute, otherwise false
34856
+ */
34857
+ function isAbsoluteURL(url) {
34858
+ // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
34859
+ // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
34860
+ // by any combination of letters, digits, plus, period, or hyphen.
34861
+ if (typeof url !== 'string') {
34862
+ return false;
34863
+ }
34864
+
34865
+ return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
34866
+ }
34867
+
34868
+ /**
34869
+ * Creates a new URL by combining the specified URLs
34870
+ *
34871
+ * @param {string} baseURL The base URL
34872
+ * @param {string} relativeURL The relative URL
34873
+ *
34874
+ * @returns {string} The combined URL
34875
+ */
34876
+ function combineURLs(baseURL, relativeURL) {
34877
+ return relativeURL
34878
+ ? baseURL.replace(/\/?\/$/, '') + '/' + relativeURL.replace(/^\/+/, '')
34879
+ : baseURL;
34880
+ }
34881
+
34882
+ /**
34883
+ * Creates a new URL by combining the baseURL with the requestedURL,
34884
+ * only when the requestedURL is not already an absolute URL.
34885
+ * If the requestURL is absolute, this function returns the requestedURL untouched.
34886
+ *
34887
+ * @param {string} baseURL The base URL
34888
+ * @param {string} requestedURL Absolute or relative URL to combine
34889
+ *
34890
+ * @returns {string} The combined full path
34891
+ */
34892
+ function buildFullPath(baseURL, requestedURL, allowAbsoluteUrls) {
34893
+ let isRelativeUrl = !isAbsoluteURL(requestedURL);
34894
+ if (baseURL && (isRelativeUrl || allowAbsoluteUrls == false)) {
34895
+ return combineURLs(baseURL, requestedURL);
34896
+ }
34897
+ return requestedURL;
34898
+ }
34899
+
34900
+ const headersToObject = (thing) => (thing instanceof AxiosHeaders$1 ? { ...thing } : thing);
34901
+
34902
+ /**
34903
+ * Config-specific merge-function which creates a new config-object
34904
+ * by merging two configuration objects together.
34905
+ *
34906
+ * @param {Object} config1
34907
+ * @param {Object} config2
34908
+ *
34909
+ * @returns {Object} New object resulting from merging config2 to config1
34910
+ */
34911
+ function mergeConfig$1(config1, config2) {
34912
+ // eslint-disable-next-line no-param-reassign
34913
+ config2 = config2 || {};
34914
+ const config = {};
34915
+
34916
+ function getMergedValue(target, source, prop, caseless) {
34917
+ if (utils$1.isPlainObject(target) && utils$1.isPlainObject(source)) {
34918
+ return utils$1.merge.call({ caseless }, target, source);
34919
+ } else if (utils$1.isPlainObject(source)) {
34920
+ return utils$1.merge({}, source);
34921
+ } else if (utils$1.isArray(source)) {
34922
+ return source.slice();
34923
+ }
34924
+ return source;
34925
+ }
34926
+
34927
+ function mergeDeepProperties(a, b, prop, caseless) {
34928
+ if (!utils$1.isUndefined(b)) {
34929
+ return getMergedValue(a, b, prop, caseless);
34930
+ } else if (!utils$1.isUndefined(a)) {
34931
+ return getMergedValue(undefined, a, prop, caseless);
34932
+ }
34933
+ }
34934
+
34935
+ // eslint-disable-next-line consistent-return
34936
+ function valueFromConfig2(a, b) {
34937
+ if (!utils$1.isUndefined(b)) {
34938
+ return getMergedValue(undefined, b);
34939
+ }
34940
+ }
34941
+
34942
+ // eslint-disable-next-line consistent-return
34943
+ function defaultToConfig2(a, b) {
34944
+ if (!utils$1.isUndefined(b)) {
34945
+ return getMergedValue(undefined, b);
34946
+ } else if (!utils$1.isUndefined(a)) {
34947
+ return getMergedValue(undefined, a);
34948
+ }
34949
+ }
34950
+
34951
+ // eslint-disable-next-line consistent-return
34952
+ function mergeDirectKeys(a, b, prop) {
34953
+ if (prop in config2) {
34954
+ return getMergedValue(a, b);
34955
+ } else if (prop in config1) {
34956
+ return getMergedValue(undefined, a);
34957
+ }
34958
+ }
34959
+
34960
+ const mergeMap = {
34961
+ url: valueFromConfig2,
34962
+ method: valueFromConfig2,
34963
+ data: valueFromConfig2,
34964
+ baseURL: defaultToConfig2,
34965
+ transformRequest: defaultToConfig2,
34966
+ transformResponse: defaultToConfig2,
34967
+ paramsSerializer: defaultToConfig2,
34968
+ timeout: defaultToConfig2,
34969
+ timeoutMessage: defaultToConfig2,
34970
+ withCredentials: defaultToConfig2,
34971
+ withXSRFToken: defaultToConfig2,
34972
+ adapter: defaultToConfig2,
34973
+ responseType: defaultToConfig2,
34974
+ xsrfCookieName: defaultToConfig2,
34975
+ xsrfHeaderName: defaultToConfig2,
34976
+ onUploadProgress: defaultToConfig2,
34977
+ onDownloadProgress: defaultToConfig2,
34978
+ decompress: defaultToConfig2,
34979
+ maxContentLength: defaultToConfig2,
34980
+ maxBodyLength: defaultToConfig2,
34981
+ beforeRedirect: defaultToConfig2,
34982
+ transport: defaultToConfig2,
34983
+ httpAgent: defaultToConfig2,
34984
+ httpsAgent: defaultToConfig2,
34985
+ cancelToken: defaultToConfig2,
34986
+ socketPath: defaultToConfig2,
34987
+ responseEncoding: defaultToConfig2,
34988
+ validateStatus: mergeDirectKeys,
34989
+ headers: (a, b, prop) =>
34990
+ mergeDeepProperties(headersToObject(a), headersToObject(b), prop, true),
34535
34991
  };
34992
+
34993
+ utils$1.forEach(Object.keys({ ...config1, ...config2 }), function computeConfigValue(prop) {
34994
+ if (prop === '__proto__' || prop === 'constructor' || prop === 'prototype') return;
34995
+ const merge = utils$1.hasOwnProp(mergeMap, prop) ? mergeMap[prop] : mergeDeepProperties;
34996
+ const configValue = merge(config1[prop], config2[prop], prop);
34997
+ (utils$1.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
34998
+ });
34999
+
35000
+ return config;
34536
35001
  }
34537
35002
 
34538
- const isXHRAdapterSupported = typeof XMLHttpRequest !== 'undefined';
35003
+ var resolveConfig = (config) => {
35004
+ const newConfig = mergeConfig$1({}, config);
34539
35005
 
34540
- var xhrAdapter = isXHRAdapterSupported && function (config) {
34541
- return new Promise(function dispatchXhrRequest(resolve, reject) {
34542
- let requestData = config.data;
34543
- const requestHeaders = AxiosHeaders$1.from(config.headers).normalize();
34544
- let {responseType, withXSRFToken} = config;
34545
- let onCanceled;
34546
- function done() {
34547
- if (config.cancelToken) {
34548
- config.cancelToken.unsubscribe(onCanceled);
34549
- }
35006
+ let { data, withXSRFToken, xsrfHeaderName, xsrfCookieName, headers, auth } = newConfig;
34550
35007
 
34551
- if (config.signal) {
34552
- config.signal.removeEventListener('abort', onCanceled);
34553
- }
35008
+ newConfig.headers = headers = AxiosHeaders$1.from(headers);
35009
+
35010
+ newConfig.url = buildURL(
35011
+ buildFullPath(newConfig.baseURL, newConfig.url, newConfig.allowAbsoluteUrls),
35012
+ config.params,
35013
+ config.paramsSerializer
35014
+ );
35015
+
35016
+ // HTTP basic authentication
35017
+ if (auth) {
35018
+ headers.set(
35019
+ 'Authorization',
35020
+ 'Basic ' +
35021
+ btoa(
35022
+ (auth.username || '') +
35023
+ ':' +
35024
+ (auth.password ? unescape(encodeURIComponent(auth.password)) : '')
35025
+ )
35026
+ );
35027
+ }
35028
+
35029
+ if (utils$1.isFormData(data)) {
35030
+ if (platform.hasStandardBrowserEnv || platform.hasStandardBrowserWebWorkerEnv) {
35031
+ headers.setContentType(undefined); // browser handles it
35032
+ } else if (utils$1.isFunction(data.getHeaders)) {
35033
+ // Node.js FormData (like form-data package)
35034
+ const formHeaders = data.getHeaders();
35035
+ // Only set safe headers to avoid overwriting security headers
35036
+ const allowedHeaders = ['content-type', 'content-length'];
35037
+ Object.entries(formHeaders).forEach(([key, val]) => {
35038
+ if (allowedHeaders.includes(key.toLowerCase())) {
35039
+ headers.set(key, val);
35040
+ }
35041
+ });
34554
35042
  }
35043
+ }
35044
+
35045
+ // Add xsrf header
35046
+ // This is only done if running in a standard browser environment.
35047
+ // Specifically not if we're in a web worker, or react-native.
34555
35048
 
34556
- let contentType;
35049
+ if (platform.hasStandardBrowserEnv) {
35050
+ withXSRFToken && utils$1.isFunction(withXSRFToken) && (withXSRFToken = withXSRFToken(newConfig));
34557
35051
 
34558
- if (utils$1.isFormData(requestData)) {
34559
- if (platform.hasStandardBrowserEnv || platform.hasStandardBrowserWebWorkerEnv) {
34560
- requestHeaders.setContentType(false); // Let the browser set it
34561
- } else if ((contentType = requestHeaders.getContentType()) !== false) {
34562
- // fix semicolon duplication issue for ReactNative FormData implementation
34563
- const [type, ...tokens] = contentType ? contentType.split(';').map(token => token.trim()).filter(Boolean) : [];
34564
- requestHeaders.setContentType([type || 'multipart/form-data', ...tokens].join('; '));
35052
+ if (withXSRFToken || (withXSRFToken !== false && isURLSameOrigin(newConfig.url))) {
35053
+ // Add xsrf header
35054
+ const xsrfValue = xsrfHeaderName && xsrfCookieName && cookies.read(xsrfCookieName);
35055
+
35056
+ if (xsrfValue) {
35057
+ headers.set(xsrfHeaderName, xsrfValue);
34565
35058
  }
34566
35059
  }
35060
+ }
34567
35061
 
34568
- let request = new XMLHttpRequest();
35062
+ return newConfig;
35063
+ };
34569
35064
 
34570
- // HTTP basic authentication
34571
- if (config.auth) {
34572
- const username = config.auth.username || '';
34573
- const password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : '';
34574
- requestHeaders.set('Authorization', 'Basic ' + btoa(username + ':' + password));
34575
- }
35065
+ const isXHRAdapterSupported = typeof XMLHttpRequest !== 'undefined';
34576
35066
 
34577
- const fullPath = buildFullPath(config.baseURL, config.url);
35067
+ var xhrAdapter = isXHRAdapterSupported &&
35068
+ function (config) {
35069
+ return new Promise(function dispatchXhrRequest(resolve, reject) {
35070
+ const _config = resolveConfig(config);
35071
+ let requestData = _config.data;
35072
+ const requestHeaders = AxiosHeaders$1.from(_config.headers).normalize();
35073
+ let { responseType, onUploadProgress, onDownloadProgress } = _config;
35074
+ let onCanceled;
35075
+ let uploadThrottled, downloadThrottled;
35076
+ let flushUpload, flushDownload;
34578
35077
 
34579
- request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true);
35078
+ function done() {
35079
+ flushUpload && flushUpload(); // flush events
35080
+ flushDownload && flushDownload(); // flush events
34580
35081
 
34581
- // Set the request timeout in MS
34582
- request.timeout = config.timeout;
35082
+ _config.cancelToken && _config.cancelToken.unsubscribe(onCanceled);
34583
35083
 
34584
- function onloadend() {
34585
- if (!request) {
34586
- return;
35084
+ _config.signal && _config.signal.removeEventListener('abort', onCanceled);
34587
35085
  }
34588
- // Prepare the response
34589
- const responseHeaders = AxiosHeaders$1.from(
34590
- 'getAllResponseHeaders' in request && request.getAllResponseHeaders()
34591
- );
34592
- const responseData = !responseType || responseType === 'text' || responseType === 'json' ?
34593
- request.responseText : request.response;
34594
- const response = {
34595
- data: responseData,
34596
- status: request.status,
34597
- statusText: request.statusText,
34598
- headers: responseHeaders,
34599
- config,
34600
- request
34601
- };
34602
35086
 
34603
- settle(function _resolve(value) {
34604
- resolve(value);
34605
- done();
34606
- }, function _reject(err) {
34607
- reject(err);
34608
- done();
34609
- }, response);
35087
+ let request = new XMLHttpRequest();
34610
35088
 
34611
- // Clean up request
34612
- request = null;
34613
- }
35089
+ request.open(_config.method.toUpperCase(), _config.url, true);
34614
35090
 
34615
- if ('onloadend' in request) {
34616
- // Use onloadend if available
34617
- request.onloadend = onloadend;
34618
- } else {
34619
- // Listen for ready state to emulate onloadend
34620
- request.onreadystatechange = function handleLoad() {
34621
- if (!request || request.readyState !== 4) {
35091
+ // Set the request timeout in MS
35092
+ request.timeout = _config.timeout;
35093
+
35094
+ function onloadend() {
35095
+ if (!request) {
34622
35096
  return;
34623
35097
  }
35098
+ // Prepare the response
35099
+ const responseHeaders = AxiosHeaders$1.from(
35100
+ 'getAllResponseHeaders' in request && request.getAllResponseHeaders()
35101
+ );
35102
+ const responseData =
35103
+ !responseType || responseType === 'text' || responseType === 'json'
35104
+ ? request.responseText
35105
+ : request.response;
35106
+ const response = {
35107
+ data: responseData,
35108
+ status: request.status,
35109
+ statusText: request.statusText,
35110
+ headers: responseHeaders,
35111
+ config,
35112
+ request,
35113
+ };
35114
+
35115
+ settle(
35116
+ function _resolve(value) {
35117
+ resolve(value);
35118
+ done();
35119
+ },
35120
+ function _reject(err) {
35121
+ reject(err);
35122
+ done();
35123
+ },
35124
+ response
35125
+ );
35126
+
35127
+ // Clean up request
35128
+ request = null;
35129
+ }
34624
35130
 
34625
- // The request errored out and we didn't get a response, this will be
34626
- // handled by onerror instead
34627
- // With one exception: request that using file: protocol, most browsers
34628
- // will return status as 0 even though it's a successful request
34629
- if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
35131
+ if ('onloadend' in request) {
35132
+ // Use onloadend if available
35133
+ request.onloadend = onloadend;
35134
+ } else {
35135
+ // Listen for ready state to emulate onloadend
35136
+ request.onreadystatechange = function handleLoad() {
35137
+ if (!request || request.readyState !== 4) {
35138
+ return;
35139
+ }
35140
+
35141
+ // The request errored out and we didn't get a response, this will be
35142
+ // handled by onerror instead
35143
+ // With one exception: request that using file: protocol, most browsers
35144
+ // will return status as 0 even though it's a successful request
35145
+ if (
35146
+ request.status === 0 &&
35147
+ !(request.responseURL && request.responseURL.indexOf('file:') === 0)
35148
+ ) {
35149
+ return;
35150
+ }
35151
+ // readystate handler is calling before onerror or ontimeout handlers,
35152
+ // so we should call onloadend on the next 'tick'
35153
+ setTimeout(onloadend);
35154
+ };
35155
+ }
35156
+
35157
+ // Handle browser request cancellation (as opposed to a manual cancellation)
35158
+ request.onabort = function handleAbort() {
35159
+ if (!request) {
34630
35160
  return;
34631
35161
  }
34632
- // readystate handler is calling before onerror or ontimeout handlers,
34633
- // so we should call onloadend on the next 'tick'
34634
- setTimeout(onloadend);
35162
+
35163
+ reject(new AxiosError$1('Request aborted', AxiosError$1.ECONNABORTED, config, request));
35164
+
35165
+ // Clean up request
35166
+ request = null;
35167
+ };
35168
+
35169
+ // Handle low level network errors
35170
+ request.onerror = function handleError(event) {
35171
+ // Browsers deliver a ProgressEvent in XHR onerror
35172
+ // (message may be empty; when present, surface it)
35173
+ // See https://developer.mozilla.org/docs/Web/API/XMLHttpRequest/error_event
35174
+ const msg = event && event.message ? event.message : 'Network Error';
35175
+ const err = new AxiosError$1(msg, AxiosError$1.ERR_NETWORK, config, request);
35176
+ // attach the underlying event for consumers who want details
35177
+ err.event = event || null;
35178
+ reject(err);
35179
+ request = null;
34635
35180
  };
34636
- }
34637
35181
 
34638
- // Handle browser request cancellation (as opposed to a manual cancellation)
34639
- request.onabort = function handleAbort() {
34640
- if (!request) {
35182
+ // Handle timeout
35183
+ request.ontimeout = function handleTimeout() {
35184
+ let timeoutErrorMessage = _config.timeout
35185
+ ? 'timeout of ' + _config.timeout + 'ms exceeded'
35186
+ : 'timeout exceeded';
35187
+ const transitional = _config.transitional || transitionalDefaults;
35188
+ if (_config.timeoutErrorMessage) {
35189
+ timeoutErrorMessage = _config.timeoutErrorMessage;
35190
+ }
35191
+ reject(
35192
+ new AxiosError$1(
35193
+ timeoutErrorMessage,
35194
+ transitional.clarifyTimeoutError ? AxiosError$1.ETIMEDOUT : AxiosError$1.ECONNABORTED,
35195
+ config,
35196
+ request
35197
+ )
35198
+ );
35199
+
35200
+ // Clean up request
35201
+ request = null;
35202
+ };
35203
+
35204
+ // Remove Content-Type if data is undefined
35205
+ requestData === undefined && requestHeaders.setContentType(null);
35206
+
35207
+ // Add headers to the request
35208
+ if ('setRequestHeader' in request) {
35209
+ utils$1.forEach(requestHeaders.toJSON(), function setRequestHeader(val, key) {
35210
+ request.setRequestHeader(key, val);
35211
+ });
35212
+ }
35213
+
35214
+ // Add withCredentials to request if needed
35215
+ if (!utils$1.isUndefined(_config.withCredentials)) {
35216
+ request.withCredentials = !!_config.withCredentials;
35217
+ }
35218
+
35219
+ // Add responseType to request if needed
35220
+ if (responseType && responseType !== 'json') {
35221
+ request.responseType = _config.responseType;
35222
+ }
35223
+
35224
+ // Handle progress if needed
35225
+ if (onDownloadProgress) {
35226
+ [downloadThrottled, flushDownload] = progressEventReducer(onDownloadProgress, true);
35227
+ request.addEventListener('progress', downloadThrottled);
35228
+ }
35229
+
35230
+ // Not all browsers support upload events
35231
+ if (onUploadProgress && request.upload) {
35232
+ [uploadThrottled, flushUpload] = progressEventReducer(onUploadProgress);
35233
+
35234
+ request.upload.addEventListener('progress', uploadThrottled);
35235
+
35236
+ request.upload.addEventListener('loadend', flushUpload);
35237
+ }
35238
+
35239
+ if (_config.cancelToken || _config.signal) {
35240
+ // Handle cancellation
35241
+ // eslint-disable-next-line func-names
35242
+ onCanceled = (cancel) => {
35243
+ if (!request) {
35244
+ return;
35245
+ }
35246
+ reject(!cancel || cancel.type ? new CanceledError$1(null, config, request) : cancel);
35247
+ request.abort();
35248
+ request = null;
35249
+ };
35250
+
35251
+ _config.cancelToken && _config.cancelToken.subscribe(onCanceled);
35252
+ if (_config.signal) {
35253
+ _config.signal.aborted
35254
+ ? onCanceled()
35255
+ : _config.signal.addEventListener('abort', onCanceled);
35256
+ }
35257
+ }
35258
+
35259
+ const protocol = parseProtocol(_config.url);
35260
+
35261
+ if (protocol && platform.protocols.indexOf(protocol) === -1) {
35262
+ reject(
35263
+ new AxiosError$1(
35264
+ 'Unsupported protocol ' + protocol + ':',
35265
+ AxiosError$1.ERR_BAD_REQUEST,
35266
+ config
35267
+ )
35268
+ );
34641
35269
  return;
34642
35270
  }
34643
35271
 
34644
- reject(new AxiosError$1('Request aborted', AxiosError$1.ECONNABORTED, config, request));
35272
+ // Send the request
35273
+ request.send(requestData || null);
35274
+ });
35275
+ };
34645
35276
 
34646
- // Clean up request
34647
- request = null;
34648
- };
35277
+ const composeSignals = (signals, timeout) => {
35278
+ const { length } = (signals = signals ? signals.filter(Boolean) : []);
35279
+
35280
+ if (timeout || length) {
35281
+ let controller = new AbortController();
34649
35282
 
34650
- // Handle low level network errors
34651
- request.onerror = function handleError() {
34652
- // Real errors are hidden from us by the browser
34653
- // onerror should only fire if it's a network error
34654
- reject(new AxiosError$1('Network Error', AxiosError$1.ERR_NETWORK, config, request));
35283
+ let aborted;
34655
35284
 
34656
- // Clean up request
34657
- request = null;
35285
+ const onabort = function (reason) {
35286
+ if (!aborted) {
35287
+ aborted = true;
35288
+ unsubscribe();
35289
+ const err = reason instanceof Error ? reason : this.reason;
35290
+ controller.abort(
35291
+ err instanceof AxiosError$1
35292
+ ? err
35293
+ : new CanceledError$1(err instanceof Error ? err.message : err)
35294
+ );
35295
+ }
34658
35296
  };
34659
35297
 
34660
- // Handle timeout
34661
- request.ontimeout = function handleTimeout() {
34662
- let timeoutErrorMessage = config.timeout ? 'timeout of ' + config.timeout + 'ms exceeded' : 'timeout exceeded';
34663
- const transitional = config.transitional || transitionalDefaults;
34664
- if (config.timeoutErrorMessage) {
34665
- timeoutErrorMessage = config.timeoutErrorMessage;
35298
+ let timer =
35299
+ timeout &&
35300
+ setTimeout(() => {
35301
+ timer = null;
35302
+ onabort(new AxiosError$1(`timeout of ${timeout}ms exceeded`, AxiosError$1.ETIMEDOUT));
35303
+ }, timeout);
35304
+
35305
+ const unsubscribe = () => {
35306
+ if (signals) {
35307
+ timer && clearTimeout(timer);
35308
+ timer = null;
35309
+ signals.forEach((signal) => {
35310
+ signal.unsubscribe
35311
+ ? signal.unsubscribe(onabort)
35312
+ : signal.removeEventListener('abort', onabort);
35313
+ });
35314
+ signals = null;
34666
35315
  }
34667
- reject(new AxiosError$1(
34668
- timeoutErrorMessage,
34669
- transitional.clarifyTimeoutError ? AxiosError$1.ETIMEDOUT : AxiosError$1.ECONNABORTED,
34670
- config,
34671
- request));
34672
-
34673
- // Clean up request
34674
- request = null;
34675
35316
  };
34676
35317
 
34677
- // Add xsrf header
34678
- // This is only done if running in a standard browser environment.
34679
- // Specifically not if we're in a web worker, or react-native.
34680
- if(platform.hasStandardBrowserEnv) {
34681
- withXSRFToken && utils$1.isFunction(withXSRFToken) && (withXSRFToken = withXSRFToken(config));
35318
+ signals.forEach((signal) => signal.addEventListener('abort', onabort));
34682
35319
 
34683
- if (withXSRFToken || (withXSRFToken !== false && isURLSameOrigin(fullPath))) {
34684
- // Add xsrf header
34685
- const xsrfValue = config.xsrfHeaderName && config.xsrfCookieName && cookies.read(config.xsrfCookieName);
35320
+ const { signal } = controller;
34686
35321
 
34687
- if (xsrfValue) {
34688
- requestHeaders.set(config.xsrfHeaderName, xsrfValue);
34689
- }
35322
+ signal.unsubscribe = () => utils$1.asap(unsubscribe);
35323
+
35324
+ return signal;
35325
+ }
35326
+ };
35327
+
35328
+ const streamChunk = function* (chunk, chunkSize) {
35329
+ let len = chunk.byteLength;
35330
+
35331
+ if (len < chunkSize) {
35332
+ yield chunk;
35333
+ return;
35334
+ }
35335
+
35336
+ let pos = 0;
35337
+ let end;
35338
+
35339
+ while (pos < len) {
35340
+ end = pos + chunkSize;
35341
+ yield chunk.slice(pos, end);
35342
+ pos = end;
35343
+ }
35344
+ };
35345
+
35346
+ const readBytes = async function* (iterable, chunkSize) {
35347
+ for await (const chunk of readStream(iterable)) {
35348
+ yield* streamChunk(chunk, chunkSize);
35349
+ }
35350
+ };
35351
+
35352
+ const readStream = async function* (stream) {
35353
+ if (stream[Symbol.asyncIterator]) {
35354
+ yield* stream;
35355
+ return;
35356
+ }
35357
+
35358
+ const reader = stream.getReader();
35359
+ try {
35360
+ for (;;) {
35361
+ const { done, value } = await reader.read();
35362
+ if (done) {
35363
+ break;
34690
35364
  }
35365
+ yield value;
34691
35366
  }
35367
+ } finally {
35368
+ await reader.cancel();
35369
+ }
35370
+ };
35371
+
35372
+ const trackStream = (stream, chunkSize, onProgress, onFinish) => {
35373
+ const iterator = readBytes(stream, chunkSize);
35374
+
35375
+ let bytes = 0;
35376
+ let done;
35377
+ let _onFinish = (e) => {
35378
+ if (!done) {
35379
+ done = true;
35380
+ onFinish && onFinish(e);
35381
+ }
35382
+ };
35383
+
35384
+ return new ReadableStream(
35385
+ {
35386
+ async pull(controller) {
35387
+ try {
35388
+ const { done, value } = await iterator.next();
35389
+
35390
+ if (done) {
35391
+ _onFinish();
35392
+ controller.close();
35393
+ return;
35394
+ }
35395
+
35396
+ let len = value.byteLength;
35397
+ if (onProgress) {
35398
+ let loadedBytes = (bytes += len);
35399
+ onProgress(loadedBytes);
35400
+ }
35401
+ controller.enqueue(new Uint8Array(value));
35402
+ } catch (err) {
35403
+ _onFinish(err);
35404
+ throw err;
35405
+ }
35406
+ },
35407
+ cancel(reason) {
35408
+ _onFinish(reason);
35409
+ return iterator.return();
35410
+ },
35411
+ },
35412
+ {
35413
+ highWaterMark: 2,
35414
+ }
35415
+ );
35416
+ };
35417
+
35418
+ const DEFAULT_CHUNK_SIZE = 64 * 1024;
35419
+
35420
+ const { isFunction: isFunction$1 } = utils$1;
35421
+
35422
+ const globalFetchAPI = (({ Request, Response }) => ({
35423
+ Request,
35424
+ Response,
35425
+ }))(utils$1.global);
35426
+
35427
+ const { ReadableStream: ReadableStream$1, TextEncoder: TextEncoder$1 } = utils$1.global;
35428
+
35429
+ const test = (fn, ...args) => {
35430
+ try {
35431
+ return !!fn(...args);
35432
+ } catch (e) {
35433
+ return false;
35434
+ }
35435
+ };
35436
+
35437
+ const factory = (env) => {
35438
+ env = utils$1.merge.call(
35439
+ {
35440
+ skipUndefined: true,
35441
+ },
35442
+ globalFetchAPI,
35443
+ env
35444
+ );
35445
+
35446
+ const { fetch: envFetch, Request, Response } = env;
35447
+ const isFetchSupported = envFetch ? isFunction$1(envFetch) : typeof fetch === 'function';
35448
+ const isRequestSupported = isFunction$1(Request);
35449
+ const isResponseSupported = isFunction$1(Response);
35450
+
35451
+ if (!isFetchSupported) {
35452
+ return false;
35453
+ }
35454
+
35455
+ const isReadableStreamSupported = isFetchSupported && isFunction$1(ReadableStream$1);
35456
+
35457
+ const encodeText =
35458
+ isFetchSupported &&
35459
+ (typeof TextEncoder$1 === 'function'
35460
+ ? (
35461
+ (encoder) => (str) =>
35462
+ encoder.encode(str)
35463
+ )(new TextEncoder$1())
35464
+ : async (str) => new Uint8Array(await new Request(str).arrayBuffer()));
35465
+
35466
+ const supportsRequestStream =
35467
+ isRequestSupported &&
35468
+ isReadableStreamSupported &&
35469
+ test(() => {
35470
+ let duplexAccessed = false;
35471
+
35472
+ const body = new ReadableStream$1();
35473
+
35474
+ const hasContentType = new Request(platform.origin, {
35475
+ body,
35476
+ method: 'POST',
35477
+ get duplex() {
35478
+ duplexAccessed = true;
35479
+ return 'half';
35480
+ },
35481
+ }).headers.has('Content-Type');
35482
+
35483
+ body.cancel();
35484
+
35485
+ return duplexAccessed && !hasContentType;
35486
+ });
35487
+
35488
+ const supportsResponseStream =
35489
+ isResponseSupported &&
35490
+ isReadableStreamSupported &&
35491
+ test(() => utils$1.isReadableStream(new Response('').body));
34692
35492
 
34693
- // Remove Content-Type if data is undefined
34694
- requestData === undefined && requestHeaders.setContentType(null);
35493
+ const resolvers = {
35494
+ stream: supportsResponseStream && ((res) => res.body),
35495
+ };
35496
+
35497
+ isFetchSupported &&
35498
+ (() => {
35499
+ ['text', 'arrayBuffer', 'blob', 'formData', 'stream'].forEach((type) => {
35500
+ !resolvers[type] &&
35501
+ (resolvers[type] = (res, config) => {
35502
+ let method = res && res[type];
35503
+
35504
+ if (method) {
35505
+ return method.call(res);
35506
+ }
34695
35507
 
34696
- // Add headers to the request
34697
- if ('setRequestHeader' in request) {
34698
- utils$1.forEach(requestHeaders.toJSON(), function setRequestHeader(val, key) {
34699
- request.setRequestHeader(key, val);
35508
+ throw new AxiosError$1(
35509
+ `Response type '${type}' is not supported`,
35510
+ AxiosError$1.ERR_NOT_SUPPORT,
35511
+ config
35512
+ );
35513
+ });
34700
35514
  });
35515
+ })();
35516
+
35517
+ const getBodyLength = async (body) => {
35518
+ if (body == null) {
35519
+ return 0;
34701
35520
  }
34702
35521
 
34703
- // Add withCredentials to request if needed
34704
- if (!utils$1.isUndefined(config.withCredentials)) {
34705
- request.withCredentials = !!config.withCredentials;
35522
+ if (utils$1.isBlob(body)) {
35523
+ return body.size;
34706
35524
  }
34707
35525
 
34708
- // Add responseType to request if needed
34709
- if (responseType && responseType !== 'json') {
34710
- request.responseType = config.responseType;
35526
+ if (utils$1.isSpecCompliantForm(body)) {
35527
+ const _request = new Request(platform.origin, {
35528
+ method: 'POST',
35529
+ body,
35530
+ });
35531
+ return (await _request.arrayBuffer()).byteLength;
34711
35532
  }
34712
35533
 
34713
- // Handle progress if needed
34714
- if (typeof config.onDownloadProgress === 'function') {
34715
- request.addEventListener('progress', progressEventReducer(config.onDownloadProgress, true));
35534
+ if (utils$1.isArrayBufferView(body) || utils$1.isArrayBuffer(body)) {
35535
+ return body.byteLength;
34716
35536
  }
34717
35537
 
34718
- // Not all browsers support upload events
34719
- if (typeof config.onUploadProgress === 'function' && request.upload) {
34720
- request.upload.addEventListener('progress', progressEventReducer(config.onUploadProgress));
35538
+ if (utils$1.isURLSearchParams(body)) {
35539
+ body = body + '';
34721
35540
  }
34722
35541
 
34723
- if (config.cancelToken || config.signal) {
34724
- // Handle cancellation
34725
- // eslint-disable-next-line func-names
34726
- onCanceled = cancel => {
34727
- if (!request) {
34728
- return;
35542
+ if (utils$1.isString(body)) {
35543
+ return (await encodeText(body)).byteLength;
35544
+ }
35545
+ };
35546
+
35547
+ const resolveBodyLength = async (headers, body) => {
35548
+ const length = utils$1.toFiniteNumber(headers.getContentLength());
35549
+
35550
+ return length == null ? getBodyLength(body) : length;
35551
+ };
35552
+
35553
+ return async (config) => {
35554
+ let {
35555
+ url,
35556
+ method,
35557
+ data,
35558
+ signal,
35559
+ cancelToken,
35560
+ timeout,
35561
+ onDownloadProgress,
35562
+ onUploadProgress,
35563
+ responseType,
35564
+ headers,
35565
+ withCredentials = 'same-origin',
35566
+ fetchOptions,
35567
+ } = resolveConfig(config);
35568
+
35569
+ let _fetch = envFetch || fetch;
35570
+
35571
+ responseType = responseType ? (responseType + '').toLowerCase() : 'text';
35572
+
35573
+ let composedSignal = composeSignals(
35574
+ [signal, cancelToken && cancelToken.toAbortSignal()],
35575
+ timeout
35576
+ );
35577
+
35578
+ let request = null;
35579
+
35580
+ const unsubscribe =
35581
+ composedSignal &&
35582
+ composedSignal.unsubscribe &&
35583
+ (() => {
35584
+ composedSignal.unsubscribe();
35585
+ });
35586
+
35587
+ let requestContentLength;
35588
+
35589
+ try {
35590
+ if (
35591
+ onUploadProgress &&
35592
+ supportsRequestStream &&
35593
+ method !== 'get' &&
35594
+ method !== 'head' &&
35595
+ (requestContentLength = await resolveBodyLength(headers, data)) !== 0
35596
+ ) {
35597
+ let _request = new Request(url, {
35598
+ method: 'POST',
35599
+ body: data,
35600
+ duplex: 'half',
35601
+ });
35602
+
35603
+ let contentTypeHeader;
35604
+
35605
+ if (utils$1.isFormData(data) && (contentTypeHeader = _request.headers.get('content-type'))) {
35606
+ headers.setContentType(contentTypeHeader);
34729
35607
  }
34730
- reject(!cancel || cancel.type ? new CanceledError$1(null, config, request) : cancel);
34731
- request.abort();
34732
- request = null;
35608
+
35609
+ if (_request.body) {
35610
+ const [onProgress, flush] = progressEventDecorator(
35611
+ requestContentLength,
35612
+ progressEventReducer(asyncDecorator(onUploadProgress))
35613
+ );
35614
+
35615
+ data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, onProgress, flush);
35616
+ }
35617
+ }
35618
+
35619
+ if (!utils$1.isString(withCredentials)) {
35620
+ withCredentials = withCredentials ? 'include' : 'omit';
35621
+ }
35622
+
35623
+ // Cloudflare Workers throws when credentials are defined
35624
+ // see https://github.com/cloudflare/workerd/issues/902
35625
+ const isCredentialsSupported = isRequestSupported && 'credentials' in Request.prototype;
35626
+
35627
+ const resolvedOptions = {
35628
+ ...fetchOptions,
35629
+ signal: composedSignal,
35630
+ method: method.toUpperCase(),
35631
+ headers: headers.normalize().toJSON(),
35632
+ body: data,
35633
+ duplex: 'half',
35634
+ credentials: isCredentialsSupported ? withCredentials : undefined,
34733
35635
  };
34734
35636
 
34735
- config.cancelToken && config.cancelToken.subscribe(onCanceled);
34736
- if (config.signal) {
34737
- config.signal.aborted ? onCanceled() : config.signal.addEventListener('abort', onCanceled);
35637
+ request = isRequestSupported && new Request(url, resolvedOptions);
35638
+
35639
+ let response = await (isRequestSupported
35640
+ ? _fetch(request, fetchOptions)
35641
+ : _fetch(url, resolvedOptions));
35642
+
35643
+ const isStreamResponse =
35644
+ supportsResponseStream && (responseType === 'stream' || responseType === 'response');
35645
+
35646
+ if (supportsResponseStream && (onDownloadProgress || (isStreamResponse && unsubscribe))) {
35647
+ const options = {};
35648
+
35649
+ ['status', 'statusText', 'headers'].forEach((prop) => {
35650
+ options[prop] = response[prop];
35651
+ });
35652
+
35653
+ const responseContentLength = utils$1.toFiniteNumber(response.headers.get('content-length'));
35654
+
35655
+ const [onProgress, flush] =
35656
+ (onDownloadProgress &&
35657
+ progressEventDecorator(
35658
+ responseContentLength,
35659
+ progressEventReducer(asyncDecorator(onDownloadProgress), true)
35660
+ )) ||
35661
+ [];
35662
+
35663
+ response = new Response(
35664
+ trackStream(response.body, DEFAULT_CHUNK_SIZE, onProgress, () => {
35665
+ flush && flush();
35666
+ unsubscribe && unsubscribe();
35667
+ }),
35668
+ options
35669
+ );
34738
35670
  }
34739
- }
34740
35671
 
34741
- const protocol = parseProtocol(fullPath);
35672
+ responseType = responseType || 'text';
34742
35673
 
34743
- if (protocol && platform.protocols.indexOf(protocol) === -1) {
34744
- reject(new AxiosError$1('Unsupported protocol ' + protocol + ':', AxiosError$1.ERR_BAD_REQUEST, config));
34745
- return;
35674
+ let responseData = await resolvers[utils$1.findKey(resolvers, responseType) || 'text'](
35675
+ response,
35676
+ config
35677
+ );
35678
+
35679
+ !isStreamResponse && unsubscribe && unsubscribe();
35680
+
35681
+ return await new Promise((resolve, reject) => {
35682
+ settle(resolve, reject, {
35683
+ data: responseData,
35684
+ headers: AxiosHeaders$1.from(response.headers),
35685
+ status: response.status,
35686
+ statusText: response.statusText,
35687
+ config,
35688
+ request,
35689
+ });
35690
+ });
35691
+ } catch (err) {
35692
+ unsubscribe && unsubscribe();
35693
+
35694
+ if (err && err.name === 'TypeError' && /Load failed|fetch/i.test(err.message)) {
35695
+ throw Object.assign(
35696
+ new AxiosError$1(
35697
+ 'Network Error',
35698
+ AxiosError$1.ERR_NETWORK,
35699
+ config,
35700
+ request,
35701
+ err && err.response
35702
+ ),
35703
+ {
35704
+ cause: err.cause || err,
35705
+ }
35706
+ );
35707
+ }
35708
+
35709
+ throw AxiosError$1.from(err, err && err.code, config, request, err && err.response);
34746
35710
  }
35711
+ };
35712
+ };
34747
35713
 
35714
+ const seedCache = new Map();
34748
35715
 
34749
- // Send the request
34750
- request.send(requestData || null);
34751
- });
35716
+ const getFetch = (config) => {
35717
+ let env = (config && config.env) || {};
35718
+ const { fetch, Request, Response } = env;
35719
+ const seeds = [Request, Response, fetch];
35720
+
35721
+ let len = seeds.length,
35722
+ i = len,
35723
+ seed,
35724
+ target,
35725
+ map = seedCache;
35726
+
35727
+ while (i--) {
35728
+ seed = seeds[i];
35729
+ target = map.get(seed);
35730
+
35731
+ target === undefined && map.set(seed, (target = i ? new Map() : factory(env)));
35732
+
35733
+ map = target;
35734
+ }
35735
+
35736
+ return target;
34752
35737
  };
34753
35738
 
35739
+ getFetch();
35740
+
35741
+ /**
35742
+ * Known adapters mapping.
35743
+ * Provides environment-specific adapters for Axios:
35744
+ * - `http` for Node.js
35745
+ * - `xhr` for browsers
35746
+ * - `fetch` for fetch API-based requests
35747
+ *
35748
+ * @type {Object<string, Function|Object>}
35749
+ */
34754
35750
  const knownAdapters = {
34755
35751
  http: httpAdapter,
34756
- xhr: xhrAdapter
35752
+ xhr: xhrAdapter,
35753
+ fetch: {
35754
+ get: getFetch,
35755
+ },
34757
35756
  };
34758
35757
 
35758
+ // Assign adapter names for easier debugging and identification
34759
35759
  utils$1.forEach(knownAdapters, (fn, value) => {
34760
35760
  if (fn) {
34761
35761
  try {
34762
- Object.defineProperty(fn, 'name', {value});
35762
+ Object.defineProperty(fn, 'name', { value });
34763
35763
  } catch (e) {
34764
35764
  // eslint-disable-next-line no-empty
34765
35765
  }
34766
- Object.defineProperty(fn, 'adapterName', {value});
35766
+ Object.defineProperty(fn, 'adapterName', { value });
34767
35767
  }
34768
35768
  });
34769
35769
 
35770
+ /**
35771
+ * Render a rejection reason string for unknown or unsupported adapters
35772
+ *
35773
+ * @param {string} reason
35774
+ * @returns {string}
35775
+ */
34770
35776
  const renderReason = (reason) => `- ${reason}`;
34771
35777
 
34772
- const isResolvedHandle = (adapter) => utils$1.isFunction(adapter) || adapter === null || adapter === false;
35778
+ /**
35779
+ * Check if the adapter is resolved (function, null, or false)
35780
+ *
35781
+ * @param {Function|null|false} adapter
35782
+ * @returns {boolean}
35783
+ */
35784
+ const isResolvedHandle = (adapter) =>
35785
+ utils$1.isFunction(adapter) || adapter === null || adapter === false;
34773
35786
 
34774
- var adapters = {
34775
- getAdapter: (adapters) => {
34776
- adapters = utils$1.isArray(adapters) ? adapters : [adapters];
35787
+ /**
35788
+ * Get the first suitable adapter from the provided list.
35789
+ * Tries each adapter in order until a supported one is found.
35790
+ * Throws an AxiosError if no adapter is suitable.
35791
+ *
35792
+ * @param {Array<string|Function>|string|Function} adapters - Adapter(s) by name or function.
35793
+ * @param {Object} config - Axios request configuration
35794
+ * @throws {AxiosError} If no suitable adapter is available
35795
+ * @returns {Function} The resolved adapter function
35796
+ */
35797
+ function getAdapter$1(adapters, config) {
35798
+ adapters = utils$1.isArray(adapters) ? adapters : [adapters];
34777
35799
 
34778
- const {length} = adapters;
34779
- let nameOrAdapter;
34780
- let adapter;
35800
+ const { length } = adapters;
35801
+ let nameOrAdapter;
35802
+ let adapter;
34781
35803
 
34782
- const rejectedReasons = {};
35804
+ const rejectedReasons = {};
34783
35805
 
34784
- for (let i = 0; i < length; i++) {
34785
- nameOrAdapter = adapters[i];
34786
- let id;
35806
+ for (let i = 0; i < length; i++) {
35807
+ nameOrAdapter = adapters[i];
35808
+ let id;
34787
35809
 
34788
- adapter = nameOrAdapter;
35810
+ adapter = nameOrAdapter;
34789
35811
 
34790
- if (!isResolvedHandle(nameOrAdapter)) {
34791
- adapter = knownAdapters[(id = String(nameOrAdapter)).toLowerCase()];
35812
+ if (!isResolvedHandle(nameOrAdapter)) {
35813
+ adapter = knownAdapters[(id = String(nameOrAdapter)).toLowerCase()];
34792
35814
 
34793
- if (adapter === undefined) {
34794
- throw new AxiosError$1(`Unknown adapter '${id}'`);
34795
- }
34796
- }
34797
-
34798
- if (adapter) {
34799
- break;
35815
+ if (adapter === undefined) {
35816
+ throw new AxiosError$1(`Unknown adapter '${id}'`);
34800
35817
  }
35818
+ }
34801
35819
 
34802
- rejectedReasons[id || '#' + i] = adapter;
35820
+ if (adapter && (utils$1.isFunction(adapter) || (adapter = adapter.get(config)))) {
35821
+ break;
34803
35822
  }
34804
35823
 
34805
- if (!adapter) {
35824
+ rejectedReasons[id || '#' + i] = adapter;
35825
+ }
34806
35826
 
34807
- const reasons = Object.entries(rejectedReasons)
34808
- .map(([id, state]) => `adapter ${id} ` +
34809
- (state === false ? 'is not supported by the environment' : 'is not available in the build')
34810
- );
35827
+ if (!adapter) {
35828
+ const reasons = Object.entries(rejectedReasons).map(
35829
+ ([id, state]) =>
35830
+ `adapter ${id} ` +
35831
+ (state === false ? 'is not supported by the environment' : 'is not available in the build')
35832
+ );
34811
35833
 
34812
- let s = length ?
34813
- (reasons.length > 1 ? 'since :\n' + reasons.map(renderReason).join('\n') : ' ' + renderReason(reasons[0])) :
34814
- 'as no adapter specified';
35834
+ let s = length
35835
+ ? reasons.length > 1
35836
+ ? 'since :\n' + reasons.map(renderReason).join('\n')
35837
+ : ' ' + renderReason(reasons[0])
35838
+ : 'as no adapter specified';
34815
35839
 
34816
- throw new AxiosError$1(
34817
- `There is no suitable adapter to dispatch the request ` + s,
34818
- 'ERR_NOT_SUPPORT'
34819
- );
34820
- }
35840
+ throw new AxiosError$1(
35841
+ `There is no suitable adapter to dispatch the request ` + s,
35842
+ 'ERR_NOT_SUPPORT'
35843
+ );
35844
+ }
34821
35845
 
34822
- return adapter;
34823
- },
34824
- adapters: knownAdapters
35846
+ return adapter;
35847
+ }
35848
+
35849
+ /**
35850
+ * Exports Axios adapters and utility to resolve an adapter
35851
+ */
35852
+ var adapters = {
35853
+ /**
35854
+ * Resolve an adapter from a list of adapter names or functions.
35855
+ * @type {Function}
35856
+ */
35857
+ getAdapter: getAdapter$1,
35858
+
35859
+ /**
35860
+ * Exposes all known adapters
35861
+ * @type {Object<string, Function|Object>}
35862
+ */
35863
+ adapters: knownAdapters,
34825
35864
  };
34826
35865
 
34827
35866
  /**
@@ -34854,152 +35893,46 @@ var Neurosity = (function (exports) {
34854
35893
  config.headers = AxiosHeaders$1.from(config.headers);
34855
35894
 
34856
35895
  // Transform request data
34857
- config.data = transformData.call(
34858
- config,
34859
- config.transformRequest
34860
- );
35896
+ config.data = transformData.call(config, config.transformRequest);
34861
35897
 
34862
35898
  if (['post', 'put', 'patch'].indexOf(config.method) !== -1) {
34863
35899
  config.headers.setContentType('application/x-www-form-urlencoded', false);
34864
35900
  }
34865
35901
 
34866
- const adapter = adapters.getAdapter(config.adapter || defaults.adapter);
34867
-
34868
- return adapter(config).then(function onAdapterResolution(response) {
34869
- throwIfCancellationRequested(config);
34870
-
34871
- // Transform response data
34872
- response.data = transformData.call(
34873
- config,
34874
- config.transformResponse,
34875
- response
34876
- );
35902
+ const adapter = adapters.getAdapter(config.adapter || defaults.adapter, config);
34877
35903
 
34878
- response.headers = AxiosHeaders$1.from(response.headers);
34879
-
34880
- return response;
34881
- }, function onAdapterRejection(reason) {
34882
- if (!isCancel$1(reason)) {
35904
+ return adapter(config).then(
35905
+ function onAdapterResolution(response) {
34883
35906
  throwIfCancellationRequested(config);
34884
35907
 
34885
35908
  // Transform response data
34886
- if (reason && reason.response) {
34887
- reason.response.data = transformData.call(
34888
- config,
34889
- config.transformResponse,
34890
- reason.response
34891
- );
34892
- reason.response.headers = AxiosHeaders$1.from(reason.response.headers);
34893
- }
34894
- }
35909
+ response.data = transformData.call(config, config.transformResponse, response);
34895
35910
 
34896
- return Promise.reject(reason);
34897
- });
34898
- }
34899
-
34900
- const headersToObject = (thing) => thing instanceof AxiosHeaders$1 ? thing.toJSON() : thing;
35911
+ response.headers = AxiosHeaders$1.from(response.headers);
34901
35912
 
34902
- /**
34903
- * Config-specific merge-function which creates a new config-object
34904
- * by merging two configuration objects together.
34905
- *
34906
- * @param {Object} config1
34907
- * @param {Object} config2
34908
- *
34909
- * @returns {Object} New object resulting from merging config2 to config1
34910
- */
34911
- function mergeConfig$1(config1, config2) {
34912
- // eslint-disable-next-line no-param-reassign
34913
- config2 = config2 || {};
34914
- const config = {};
34915
-
34916
- function getMergedValue(target, source, caseless) {
34917
- if (utils$1.isPlainObject(target) && utils$1.isPlainObject(source)) {
34918
- return utils$1.merge.call({caseless}, target, source);
34919
- } else if (utils$1.isPlainObject(source)) {
34920
- return utils$1.merge({}, source);
34921
- } else if (utils$1.isArray(source)) {
34922
- return source.slice();
34923
- }
34924
- return source;
34925
- }
34926
-
34927
- // eslint-disable-next-line consistent-return
34928
- function mergeDeepProperties(a, b, caseless) {
34929
- if (!utils$1.isUndefined(b)) {
34930
- return getMergedValue(a, b, caseless);
34931
- } else if (!utils$1.isUndefined(a)) {
34932
- return getMergedValue(undefined, a, caseless);
34933
- }
34934
- }
34935
-
34936
- // eslint-disable-next-line consistent-return
34937
- function valueFromConfig2(a, b) {
34938
- if (!utils$1.isUndefined(b)) {
34939
- return getMergedValue(undefined, b);
34940
- }
34941
- }
34942
-
34943
- // eslint-disable-next-line consistent-return
34944
- function defaultToConfig2(a, b) {
34945
- if (!utils$1.isUndefined(b)) {
34946
- return getMergedValue(undefined, b);
34947
- } else if (!utils$1.isUndefined(a)) {
34948
- return getMergedValue(undefined, a);
34949
- }
34950
- }
35913
+ return response;
35914
+ },
35915
+ function onAdapterRejection(reason) {
35916
+ if (!isCancel$1(reason)) {
35917
+ throwIfCancellationRequested(config);
35918
+
35919
+ // Transform response data
35920
+ if (reason && reason.response) {
35921
+ reason.response.data = transformData.call(
35922
+ config,
35923
+ config.transformResponse,
35924
+ reason.response
35925
+ );
35926
+ reason.response.headers = AxiosHeaders$1.from(reason.response.headers);
35927
+ }
35928
+ }
34951
35929
 
34952
- // eslint-disable-next-line consistent-return
34953
- function mergeDirectKeys(a, b, prop) {
34954
- if (prop in config2) {
34955
- return getMergedValue(a, b);
34956
- } else if (prop in config1) {
34957
- return getMergedValue(undefined, a);
35930
+ return Promise.reject(reason);
34958
35931
  }
34959
- }
34960
-
34961
- const mergeMap = {
34962
- url: valueFromConfig2,
34963
- method: valueFromConfig2,
34964
- data: valueFromConfig2,
34965
- baseURL: defaultToConfig2,
34966
- transformRequest: defaultToConfig2,
34967
- transformResponse: defaultToConfig2,
34968
- paramsSerializer: defaultToConfig2,
34969
- timeout: defaultToConfig2,
34970
- timeoutMessage: defaultToConfig2,
34971
- withCredentials: defaultToConfig2,
34972
- withXSRFToken: defaultToConfig2,
34973
- adapter: defaultToConfig2,
34974
- responseType: defaultToConfig2,
34975
- xsrfCookieName: defaultToConfig2,
34976
- xsrfHeaderName: defaultToConfig2,
34977
- onUploadProgress: defaultToConfig2,
34978
- onDownloadProgress: defaultToConfig2,
34979
- decompress: defaultToConfig2,
34980
- maxContentLength: defaultToConfig2,
34981
- maxBodyLength: defaultToConfig2,
34982
- beforeRedirect: defaultToConfig2,
34983
- transport: defaultToConfig2,
34984
- httpAgent: defaultToConfig2,
34985
- httpsAgent: defaultToConfig2,
34986
- cancelToken: defaultToConfig2,
34987
- socketPath: defaultToConfig2,
34988
- responseEncoding: defaultToConfig2,
34989
- validateStatus: mergeDirectKeys,
34990
- headers: (a, b) => mergeDeepProperties(headersToObject(a), headersToObject(b), true)
34991
- };
34992
-
34993
- utils$1.forEach(Object.keys(Object.assign({}, config1, config2)), function computeConfigValue(prop) {
34994
- const merge = mergeMap[prop] || mergeDeepProperties;
34995
- const configValue = merge(config1[prop], config2[prop], prop);
34996
- (utils$1.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
34997
- });
34998
-
34999
- return config;
35932
+ );
35000
35933
  }
35001
35934
 
35002
- const VERSION$1 = "1.6.2";
35935
+ const VERSION$1 = "1.15.0";
35003
35936
 
35004
35937
  const validators$1 = {};
35005
35938
 
@@ -35023,7 +35956,15 @@ var Neurosity = (function (exports) {
35023
35956
  */
35024
35957
  validators$1.transitional = function transitional(validator, version, message) {
35025
35958
  function formatMessage(opt, desc) {
35026
- return '[Axios v' + VERSION$1 + '] Transitional option \'' + opt + '\'' + desc + (message ? '. ' + message : '');
35959
+ return (
35960
+ '[Axios v' +
35961
+ VERSION$1 +
35962
+ "] Transitional option '" +
35963
+ opt +
35964
+ "'" +
35965
+ desc +
35966
+ (message ? '. ' + message : '')
35967
+ );
35027
35968
  }
35028
35969
 
35029
35970
  // eslint-disable-next-line func-names
@@ -35050,6 +35991,14 @@ var Neurosity = (function (exports) {
35050
35991
  };
35051
35992
  };
35052
35993
 
35994
+ validators$1.spelling = function spelling(correctSpelling) {
35995
+ return (value, opt) => {
35996
+ // eslint-disable-next-line no-console
35997
+ console.warn(`${opt} is likely a misspelling of ${correctSpelling}`);
35998
+ return true;
35999
+ };
36000
+ };
36001
+
35053
36002
  /**
35054
36003
  * Assert object's properties type
35055
36004
  *
@@ -35073,7 +36022,10 @@ var Neurosity = (function (exports) {
35073
36022
  const value = options[opt];
35074
36023
  const result = value === undefined || validator(value, opt, options);
35075
36024
  if (result !== true) {
35076
- throw new AxiosError$1('option ' + opt + ' must be ' + result, AxiosError$1.ERR_BAD_OPTION_VALUE);
36025
+ throw new AxiosError$1(
36026
+ 'option ' + opt + ' must be ' + result,
36027
+ AxiosError$1.ERR_BAD_OPTION_VALUE
36028
+ );
35077
36029
  }
35078
36030
  continue;
35079
36031
  }
@@ -35085,7 +36037,7 @@ var Neurosity = (function (exports) {
35085
36037
 
35086
36038
  var validator = {
35087
36039
  assertOptions,
35088
- validators: validators$1
36040
+ validators: validators$1,
35089
36041
  };
35090
36042
 
35091
36043
  const validators = validator.validators;
@@ -35099,10 +36051,10 @@ var Neurosity = (function (exports) {
35099
36051
  */
35100
36052
  let Axios$1 = class Axios {
35101
36053
  constructor(instanceConfig) {
35102
- this.defaults = instanceConfig;
36054
+ this.defaults = instanceConfig || {};
35103
36055
  this.interceptors = {
35104
36056
  request: new InterceptorManager(),
35105
- response: new InterceptorManager()
36057
+ response: new InterceptorManager(),
35106
36058
  };
35107
36059
  }
35108
36060
 
@@ -35114,7 +36066,50 @@ var Neurosity = (function (exports) {
35114
36066
  *
35115
36067
  * @returns {Promise} The Promise to be fulfilled
35116
36068
  */
35117
- request(configOrUrl, config) {
36069
+ async request(configOrUrl, config) {
36070
+ try {
36071
+ return await this._request(configOrUrl, config);
36072
+ } catch (err) {
36073
+ if (err instanceof Error) {
36074
+ let dummy = {};
36075
+
36076
+ Error.captureStackTrace ? Error.captureStackTrace(dummy) : (dummy = new Error());
36077
+
36078
+ // slice off the Error: ... line
36079
+ const stack = (() => {
36080
+ if (!dummy.stack) {
36081
+ return '';
36082
+ }
36083
+
36084
+ const firstNewlineIndex = dummy.stack.indexOf('\n');
36085
+
36086
+ return firstNewlineIndex === -1 ? '' : dummy.stack.slice(firstNewlineIndex + 1);
36087
+ })();
36088
+ try {
36089
+ if (!err.stack) {
36090
+ err.stack = stack;
36091
+ // match without the 2 top stack lines
36092
+ } else if (stack) {
36093
+ const firstNewlineIndex = stack.indexOf('\n');
36094
+ const secondNewlineIndex =
36095
+ firstNewlineIndex === -1 ? -1 : stack.indexOf('\n', firstNewlineIndex + 1);
36096
+ const stackWithoutTwoTopLines =
36097
+ secondNewlineIndex === -1 ? '' : stack.slice(secondNewlineIndex + 1);
36098
+
36099
+ if (!String(err.stack).endsWith(stackWithoutTwoTopLines)) {
36100
+ err.stack += '\n' + stack;
36101
+ }
36102
+ }
36103
+ } catch (e) {
36104
+ // ignore the case where "stack" is an un-writable property
36105
+ }
36106
+ }
36107
+
36108
+ throw err;
36109
+ }
36110
+ }
36111
+
36112
+ _request(configOrUrl, config) {
35118
36113
  /*eslint no-param-reassign:0*/
35119
36114
  // Allow for axios('example/url'[, config]) a la fetch API
35120
36115
  if (typeof configOrUrl === 'string') {
@@ -35126,44 +36121,64 @@ var Neurosity = (function (exports) {
35126
36121
 
35127
36122
  config = mergeConfig$1(this.defaults, config);
35128
36123
 
35129
- const {transitional, paramsSerializer, headers} = config;
36124
+ const { transitional, paramsSerializer, headers } = config;
35130
36125
 
35131
36126
  if (transitional !== undefined) {
35132
- validator.assertOptions(transitional, {
35133
- silentJSONParsing: validators.transitional(validators.boolean),
35134
- forcedJSONParsing: validators.transitional(validators.boolean),
35135
- clarifyTimeoutError: validators.transitional(validators.boolean)
35136
- }, false);
36127
+ validator.assertOptions(
36128
+ transitional,
36129
+ {
36130
+ silentJSONParsing: validators.transitional(validators.boolean),
36131
+ forcedJSONParsing: validators.transitional(validators.boolean),
36132
+ clarifyTimeoutError: validators.transitional(validators.boolean),
36133
+ legacyInterceptorReqResOrdering: validators.transitional(validators.boolean),
36134
+ },
36135
+ false
36136
+ );
35137
36137
  }
35138
36138
 
35139
36139
  if (paramsSerializer != null) {
35140
36140
  if (utils$1.isFunction(paramsSerializer)) {
35141
36141
  config.paramsSerializer = {
35142
- serialize: paramsSerializer
36142
+ serialize: paramsSerializer,
35143
36143
  };
35144
36144
  } else {
35145
- validator.assertOptions(paramsSerializer, {
35146
- encode: validators.function,
35147
- serialize: validators.function
35148
- }, true);
36145
+ validator.assertOptions(
36146
+ paramsSerializer,
36147
+ {
36148
+ encode: validators.function,
36149
+ serialize: validators.function,
36150
+ },
36151
+ true
36152
+ );
35149
36153
  }
35150
36154
  }
35151
36155
 
36156
+ // Set config.allowAbsoluteUrls
36157
+ if (config.allowAbsoluteUrls !== undefined) ; else if (this.defaults.allowAbsoluteUrls !== undefined) {
36158
+ config.allowAbsoluteUrls = this.defaults.allowAbsoluteUrls;
36159
+ } else {
36160
+ config.allowAbsoluteUrls = true;
36161
+ }
36162
+
36163
+ validator.assertOptions(
36164
+ config,
36165
+ {
36166
+ baseUrl: validators.spelling('baseURL'),
36167
+ withXsrfToken: validators.spelling('withXSRFToken'),
36168
+ },
36169
+ true
36170
+ );
36171
+
35152
36172
  // Set config.method
35153
36173
  config.method = (config.method || this.defaults.method || 'get').toLowerCase();
35154
36174
 
35155
36175
  // Flatten headers
35156
- let contextHeaders = headers && utils$1.merge(
35157
- headers.common,
35158
- headers[config.method]
35159
- );
36176
+ let contextHeaders = headers && utils$1.merge(headers.common, headers[config.method]);
35160
36177
 
35161
- headers && utils$1.forEach(
35162
- ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
35163
- (method) => {
36178
+ headers &&
36179
+ utils$1.forEach(['delete', 'get', 'head', 'post', 'put', 'patch', 'common'], (method) => {
35164
36180
  delete headers[method];
35165
- }
35166
- );
36181
+ });
35167
36182
 
35168
36183
  config.headers = AxiosHeaders$1.concat(contextHeaders, headers);
35169
36184
 
@@ -35177,7 +36192,15 @@ var Neurosity = (function (exports) {
35177
36192
 
35178
36193
  synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
35179
36194
 
35180
- requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
36195
+ const transitional = config.transitional || transitionalDefaults;
36196
+ const legacyInterceptorReqResOrdering =
36197
+ transitional && transitional.legacyInterceptorReqResOrdering;
36198
+
36199
+ if (legacyInterceptorReqResOrdering) {
36200
+ requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
36201
+ } else {
36202
+ requestInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
36203
+ }
35181
36204
  });
35182
36205
 
35183
36206
  const responseInterceptorChain = [];
@@ -35191,8 +36214,8 @@ var Neurosity = (function (exports) {
35191
36214
 
35192
36215
  if (!synchronousRequestInterceptors) {
35193
36216
  const chain = [dispatchRequest.bind(this), undefined];
35194
- chain.unshift.apply(chain, requestInterceptorChain);
35195
- chain.push.apply(chain, responseInterceptorChain);
36217
+ chain.unshift(...requestInterceptorChain);
36218
+ chain.push(...responseInterceptorChain);
35196
36219
  len = chain.length;
35197
36220
 
35198
36221
  promise = Promise.resolve(config);
@@ -35208,8 +36231,6 @@ var Neurosity = (function (exports) {
35208
36231
 
35209
36232
  let newConfig = config;
35210
36233
 
35211
- i = 0;
35212
-
35213
36234
  while (i < len) {
35214
36235
  const onFulfilled = requestInterceptorChain[i++];
35215
36236
  const onRejected = requestInterceptorChain[i++];
@@ -35239,7 +36260,7 @@ var Neurosity = (function (exports) {
35239
36260
 
35240
36261
  getUri(config) {
35241
36262
  config = mergeConfig$1(this.defaults, config);
35242
- const fullPath = buildFullPath(config.baseURL, config.url);
36263
+ const fullPath = buildFullPath(config.baseURL, config.url, config.allowAbsoluteUrls);
35243
36264
  return buildURL(fullPath, config.params, config.paramsSerializer);
35244
36265
  }
35245
36266
  };
@@ -35247,28 +36268,32 @@ var Neurosity = (function (exports) {
35247
36268
  // Provide aliases for supported request methods
35248
36269
  utils$1.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
35249
36270
  /*eslint func-names:0*/
35250
- Axios$1.prototype[method] = function(url, config) {
35251
- return this.request(mergeConfig$1(config || {}, {
35252
- method,
35253
- url,
35254
- data: (config || {}).data
35255
- }));
36271
+ Axios$1.prototype[method] = function (url, config) {
36272
+ return this.request(
36273
+ mergeConfig$1(config || {}, {
36274
+ method,
36275
+ url,
36276
+ data: (config || {}).data,
36277
+ })
36278
+ );
35256
36279
  };
35257
36280
  });
35258
36281
 
35259
36282
  utils$1.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
35260
- /*eslint func-names:0*/
35261
-
35262
36283
  function generateHTTPMethod(isForm) {
35263
36284
  return function httpMethod(url, data, config) {
35264
- return this.request(mergeConfig$1(config || {}, {
35265
- method,
35266
- headers: isForm ? {
35267
- 'Content-Type': 'multipart/form-data'
35268
- } : {},
35269
- url,
35270
- data
35271
- }));
36285
+ return this.request(
36286
+ mergeConfig$1(config || {}, {
36287
+ method,
36288
+ headers: isForm
36289
+ ? {
36290
+ 'Content-Type': 'multipart/form-data',
36291
+ }
36292
+ : {},
36293
+ url,
36294
+ data,
36295
+ })
36296
+ );
35272
36297
  };
35273
36298
  }
35274
36299
 
@@ -35299,7 +36324,7 @@ var Neurosity = (function (exports) {
35299
36324
  const token = this;
35300
36325
 
35301
36326
  // eslint-disable-next-line func-names
35302
- this.promise.then(cancel => {
36327
+ this.promise.then((cancel) => {
35303
36328
  if (!token._listeners) return;
35304
36329
 
35305
36330
  let i = token._listeners.length;
@@ -35311,10 +36336,10 @@ var Neurosity = (function (exports) {
35311
36336
  });
35312
36337
 
35313
36338
  // eslint-disable-next-line func-names
35314
- this.promise.then = onfulfilled => {
36339
+ this.promise.then = (onfulfilled) => {
35315
36340
  let _resolve;
35316
36341
  // eslint-disable-next-line func-names
35317
- const promise = new Promise(resolve => {
36342
+ const promise = new Promise((resolve) => {
35318
36343
  token.subscribe(resolve);
35319
36344
  _resolve = resolve;
35320
36345
  }).then(onfulfilled);
@@ -35377,6 +36402,20 @@ var Neurosity = (function (exports) {
35377
36402
  }
35378
36403
  }
35379
36404
 
36405
+ toAbortSignal() {
36406
+ const controller = new AbortController();
36407
+
36408
+ const abort = (err) => {
36409
+ controller.abort(err);
36410
+ };
36411
+
36412
+ this.subscribe(abort);
36413
+
36414
+ controller.signal.unsubscribe = () => this.unsubscribe(abort);
36415
+
36416
+ return controller.signal;
36417
+ }
36418
+
35380
36419
  /**
35381
36420
  * Returns an object that contains a new `CancelToken` and a function that, when called,
35382
36421
  * cancels the `CancelToken`.
@@ -35388,7 +36427,7 @@ var Neurosity = (function (exports) {
35388
36427
  });
35389
36428
  return {
35390
36429
  token,
35391
- cancel
36430
+ cancel,
35392
36431
  };
35393
36432
  }
35394
36433
  };
@@ -35400,7 +36439,7 @@ var Neurosity = (function (exports) {
35400
36439
  *
35401
36440
  * ```js
35402
36441
  * function f(x, y, z) {}
35403
- * var args = [1, 2, 3];
36442
+ * const args = [1, 2, 3];
35404
36443
  * f.apply(null, args);
35405
36444
  * ```
35406
36445
  *
@@ -35428,7 +36467,7 @@ var Neurosity = (function (exports) {
35428
36467
  * @returns {boolean} True if the payload is an error thrown by Axios, otherwise false
35429
36468
  */
35430
36469
  function isAxiosError$1(payload) {
35431
- return utils$1.isObject(payload) && (payload.isAxiosError === true);
36470
+ return utils$1.isObject(payload) && payload.isAxiosError === true;
35432
36471
  }
35433
36472
 
35434
36473
  const HttpStatusCode$1 = {
@@ -35495,6 +36534,12 @@ var Neurosity = (function (exports) {
35495
36534
  LoopDetected: 508,
35496
36535
  NotExtended: 510,
35497
36536
  NetworkAuthenticationRequired: 511,
36537
+ WebServerIsDown: 521,
36538
+ ConnectionTimedOut: 522,
36539
+ OriginIsUnreachable: 523,
36540
+ TimeoutOccurred: 524,
36541
+ SslHandshakeFailed: 525,
36542
+ InvalidSslCertificate: 526,
35498
36543
  };
35499
36544
 
35500
36545
  Object.entries(HttpStatusCode$1).forEach(([key, value]) => {
@@ -35513,10 +36558,10 @@ var Neurosity = (function (exports) {
35513
36558
  const instance = bind(Axios$1.prototype.request, context);
35514
36559
 
35515
36560
  // Copy axios.prototype to instance
35516
- utils$1.extend(instance, Axios$1.prototype, context, {allOwnKeys: true});
36561
+ utils$1.extend(instance, Axios$1.prototype, context, { allOwnKeys: true });
35517
36562
 
35518
36563
  // Copy context to instance
35519
- utils$1.extend(instance, context, null, {allOwnKeys: true});
36564
+ utils$1.extend(instance, context, null, { allOwnKeys: true });
35520
36565
 
35521
36566
  // Factory for creating new instances
35522
36567
  instance.create = function create(instanceConfig) {
@@ -35560,7 +36605,7 @@ var Neurosity = (function (exports) {
35560
36605
 
35561
36606
  axios.AxiosHeaders = AxiosHeaders$1;
35562
36607
 
35563
- axios.formToJSON = thing => formDataToJSON(utils$1.isHTMLForm(thing) ? new FormData(thing) : thing);
36608
+ axios.formToJSON = (thing) => formDataToJSON(utils$1.isHTMLForm(thing) ? new FormData(thing) : thing);
35564
36609
 
35565
36610
  axios.getAdapter = adapters.getAdapter;
35566
36611
 
@@ -35587,7 +36632,7 @@ var Neurosity = (function (exports) {
35587
36632
  HttpStatusCode,
35588
36633
  formToJSON,
35589
36634
  getAdapter,
35590
- mergeConfig
36635
+ mergeConfig,
35591
36636
  } = axios;
35592
36637
 
35593
36638
  const prodFunctionsBaseUrl = "https://us-central1-neurosity-device.cloudfunctions.net";
@@ -35979,7 +37024,7 @@ var Neurosity = (function (exports) {
35979
37024
  function requireBuffer () {
35980
37025
  if (hasRequiredBuffer) return buffer;
35981
37026
  hasRequiredBuffer = 1;
35982
- (function (exports) {
37027
+ (function (exports$1) {
35983
37028
 
35984
37029
  const base64 = requireBase64Js();
35985
37030
  const ieee754 = requireIeee754();
@@ -35988,12 +37033,12 @@ var Neurosity = (function (exports) {
35988
37033
  ? Symbol['for']('nodejs.util.inspect.custom') // eslint-disable-line dot-notation
35989
37034
  : null;
35990
37035
 
35991
- exports.Buffer = Buffer;
35992
- exports.SlowBuffer = SlowBuffer;
35993
- exports.INSPECT_MAX_BYTES = 50;
37036
+ exports$1.Buffer = Buffer;
37037
+ exports$1.SlowBuffer = SlowBuffer;
37038
+ exports$1.INSPECT_MAX_BYTES = 50;
35994
37039
 
35995
37040
  const K_MAX_LENGTH = 0x7fffffff;
35996
- exports.kMaxLength = K_MAX_LENGTH;
37041
+ exports$1.kMaxLength = K_MAX_LENGTH;
35997
37042
 
35998
37043
  /**
35999
37044
  * If `Buffer.TYPED_ARRAY_SUPPORT`:
@@ -36589,7 +37634,7 @@ var Neurosity = (function (exports) {
36589
37634
 
36590
37635
  Buffer.prototype.inspect = function inspect () {
36591
37636
  let str = '';
36592
- const max = exports.INSPECT_MAX_BYTES;
37637
+ const max = exports$1.INSPECT_MAX_BYTES;
36593
37638
  str = this.toString('hex', 0, max).replace(/(.{2})/g, '$1 ').trim();
36594
37639
  if (this.length > max) str += ' ... ';
36595
37640
  return '<Buffer ' + str + '>'
@@ -39014,6 +40059,7 @@ var Neurosity = (function (exports) {
39014
40059
  this._brainwavesPowerByBand$ =
39015
40060
  this._subscribeWhileAuthenticated("powerByBand");
39016
40061
  this._signalQuality$ = this._subscribeWhileAuthenticated("signalQuality");
40062
+ this._signalQualityV2$ = this._subscribeWhileAuthenticated("signalQualityV2");
39017
40063
  this._status$ = this._subscribeWhileAuthenticated("status");
39018
40064
  this._settings$ = this._subscribeWhileAuthenticated("settings");
39019
40065
  this._wifiNearbyNetworks$ =
@@ -39150,6 +40196,9 @@ var Neurosity = (function (exports) {
39150
40196
  signalQuality() {
39151
40197
  return this._signalQuality$;
39152
40198
  }
40199
+ signalQualityV2() {
40200
+ return this._signalQualityV2$;
40201
+ }
39153
40202
  async addMarker(label) {
39154
40203
  await this.dispatchAction({
39155
40204
  action: "marker",
@@ -39312,20 +40361,20 @@ var Neurosity = (function (exports) {
39312
40361
  function requireRe () {
39313
40362
  if (hasRequiredRe) return re.exports;
39314
40363
  hasRequiredRe = 1;
39315
- (function (module, exports) {
40364
+ (function (module, exports$1) {
39316
40365
  const {
39317
40366
  MAX_SAFE_COMPONENT_LENGTH,
39318
40367
  MAX_SAFE_BUILD_LENGTH,
39319
40368
  MAX_LENGTH,
39320
40369
  } = requireConstants();
39321
40370
  const debug = requireDebug();
39322
- exports = module.exports = {};
40371
+ exports$1 = module.exports = {};
39323
40372
 
39324
40373
  // The actual regexps go on exports.re
39325
- const re = exports.re = [];
39326
- const safeRe = exports.safeRe = [];
39327
- const src = exports.src = [];
39328
- const t = exports.t = {};
40374
+ const re = exports$1.re = [];
40375
+ const safeRe = exports$1.safeRe = [];
40376
+ const src = exports$1.src = [];
40377
+ const t = exports$1.t = {};
39329
40378
  let R = 0;
39330
40379
 
39331
40380
  const LETTERDASHNUMBER = '[a-zA-Z0-9-]';
@@ -39486,7 +40535,7 @@ var Neurosity = (function (exports) {
39486
40535
  createToken('LONETILDE', '(?:~>?)');
39487
40536
 
39488
40537
  createToken('TILDETRIM', `(\\s*)${src[t.LONETILDE]}\\s+`, true);
39489
- exports.tildeTrimReplace = '$1~';
40538
+ exports$1.tildeTrimReplace = '$1~';
39490
40539
 
39491
40540
  createToken('TILDE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`);
39492
40541
  createToken('TILDELOOSE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`);
@@ -39496,7 +40545,7 @@ var Neurosity = (function (exports) {
39496
40545
  createToken('LONECARET', '(?:\\^)');
39497
40546
 
39498
40547
  createToken('CARETTRIM', `(\\s*)${src[t.LONECARET]}\\s+`, true);
39499
- exports.caretTrimReplace = '$1^';
40548
+ exports$1.caretTrimReplace = '$1^';
39500
40549
 
39501
40550
  createToken('CARET', `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`);
39502
40551
  createToken('CARETLOOSE', `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`);
@@ -39509,7 +40558,7 @@ var Neurosity = (function (exports) {
39509
40558
  // it modifies, so that `> 1.2.3` ==> `>1.2.3`
39510
40559
  createToken('COMPARATORTRIM', `(\\s*)${src[t.GTLT]
39511
40560
  }\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, true);
39512
- exports.comparatorTrimReplace = '$1$2$3';
40561
+ exports$1.comparatorTrimReplace = '$1$2$3';
39513
40562
 
39514
40563
  // Something like `1.2.3 - 1.2.4`
39515
40564
  // Note that these all use the loose form, because they'll be
@@ -40291,6 +41340,127 @@ var Neurosity = (function (exports) {
40291
41340
  bluetooth: () => this.bluetoothClient.brainwaves(label)
40292
41341
  });
40293
41342
  }
41343
+ async record(options) {
41344
+ var _a;
41345
+ if (!(await this.cloudClient.didSelectDevice())) {
41346
+ return Promise.reject(mustSelectDevice);
41347
+ }
41348
+ const [hasOAuthError, OAuthError] = validateScopeBasedPermissionForAction(this.cloudClient.userClaims, {
41349
+ command: "brainwaves",
41350
+ action: "record"});
41351
+ if (hasOAuthError) {
41352
+ return Promise.reject(OAuthError);
41353
+ }
41354
+ if (!options.label) {
41355
+ return Promise.reject(new Error(`${prefix}A label is required for record.`));
41356
+ }
41357
+ if (!options.duration || options.duration <= 0) {
41358
+ return Promise.reject(new Error(`${prefix}A positive duration is required for record.`));
41359
+ }
41360
+ const MAX_DURATION = 30 * 60 * 1000;
41361
+ if (options.duration > MAX_DURATION) {
41362
+ return Promise.reject(new Error(`${prefix}Duration ${options.duration}ms exceeds maximum of ${MAX_DURATION}ms (30 minutes).`));
41363
+ }
41364
+ const response = await this.dispatchAction({
41365
+ command: "brainwaves",
41366
+ action: "record",
41367
+ message: {
41368
+ name: options.name || options.label,
41369
+ label: options.label,
41370
+ duration: options.duration,
41371
+ experimentId: options.experimentId || "sdk-recording"
41372
+ },
41373
+ responseRequired: true,
41374
+ responseTimeout: options.duration + 90000
41375
+ });
41376
+ return (_a = response === null || response === void 0 ? void 0 : response.message) !== null && _a !== void 0 ? _a : response;
41377
+ }
41378
+ async startRecording(options) {
41379
+ var _a;
41380
+ if (!(await this.cloudClient.didSelectDevice())) {
41381
+ return Promise.reject(mustSelectDevice);
41382
+ }
41383
+ const [hasOAuthError, OAuthError] = validateScopeBasedPermissionForAction(this.cloudClient.userClaims, {
41384
+ command: "brainwaves",
41385
+ action: "startRecording"});
41386
+ if (hasOAuthError) {
41387
+ return Promise.reject(OAuthError);
41388
+ }
41389
+ if (!options.label) {
41390
+ return Promise.reject(new Error(`${prefix}A label is required for startRecording.`));
41391
+ }
41392
+ if (!options.maxDuration || options.maxDuration <= 0) {
41393
+ return Promise.reject(new Error(`${prefix}A positive maxDuration is required for startRecording.`));
41394
+ }
41395
+ const MAX_DURATION = 30 * 60 * 1000;
41396
+ if (options.maxDuration > MAX_DURATION) {
41397
+ return Promise.reject(new Error(`${prefix}Duration ${options.maxDuration}ms exceeds maximum of ${MAX_DURATION}ms (30 minutes).`));
41398
+ }
41399
+ const response = await this.dispatchAction({
41400
+ command: "brainwaves",
41401
+ action: "startRecording",
41402
+ message: {
41403
+ name: options.name || options.label,
41404
+ label: options.label,
41405
+ maxDuration: options.maxDuration,
41406
+ experimentId: options.experimentId || "sdk-recording"
41407
+ },
41408
+ responseRequired: true,
41409
+ responseTimeout: options.maxDuration + 10000
41410
+ });
41411
+ const startResponse = (_a = response === null || response === void 0 ? void 0 : response.message) !== null && _a !== void 0 ? _a : response;
41412
+ if (!(startResponse === null || startResponse === void 0 ? void 0 : startResponse.ok)) {
41413
+ return Promise.reject(new Error(`${prefix}Failed to start recording: ${(startResponse === null || startResponse === void 0 ? void 0 : startResponse.error) || "unknown error"}`));
41414
+ }
41415
+ const { cancel: cancelAction, complete: completeAction } = startResponse;
41416
+ const startTime = Date.now();
41417
+ let stopped = false;
41418
+ let resolveResult;
41419
+ const resultPromise = new Promise((resolve) => {
41420
+ resolveResult = resolve;
41421
+ });
41422
+ const elapsedSubscribers = new Set();
41423
+ const elapsed$ = new Observable((subscriber) => {
41424
+ elapsedSubscribers.add(subscriber);
41425
+ const timer = setInterval(() => {
41426
+ subscriber.next(Date.now() - startTime);
41427
+ }, 1000);
41428
+ return () => {
41429
+ clearInterval(timer);
41430
+ elapsedSubscribers.delete(subscriber);
41431
+ };
41432
+ });
41433
+ const completeAllElapsed = () => {
41434
+ for (const sub of elapsedSubscribers) {
41435
+ sub.complete();
41436
+ }
41437
+ };
41438
+ const stop = async () => {
41439
+ var _a, _b;
41440
+ if (stopped)
41441
+ return resultPromise;
41442
+ stopped = true;
41443
+ completeAllElapsed();
41444
+ const stopResponse = await this.dispatchAction(completeAction);
41445
+ const result = (_b = (_a = stopResponse === null || stopResponse === void 0 ? void 0 : stopResponse.message) !== null && _a !== void 0 ? _a : stopResponse) !== null && _b !== void 0 ? _b : { ok: true };
41446
+ resolveResult(result);
41447
+ return result;
41448
+ };
41449
+ const cancel = async () => {
41450
+ if (stopped)
41451
+ return;
41452
+ stopped = true;
41453
+ completeAllElapsed();
41454
+ await this.dispatchAction(cancelAction);
41455
+ resolveResult({ ok: false, error: "cancelled" });
41456
+ };
41457
+ return {
41458
+ elapsed$,
41459
+ stop,
41460
+ cancel,
41461
+ result: resultPromise
41462
+ };
41463
+ }
40294
41464
  calm() {
40295
41465
  const [hasOAuthError, OAuthError] = validateScopeBasedPermissionForFunctionName(this.cloudClient.userClaims, "calm");
40296
41466
  if (hasOAuthError) {
@@ -40320,6 +41490,21 @@ var Neurosity = (function (exports) {
40320
41490
  bluetooth: () => this.bluetoothClient.signalQuality()
40321
41491
  });
40322
41492
  }
41493
+ signalQualityV2() {
41494
+ const metric = "signalQualityV2";
41495
+ const [hasOAuthError, OAuthError] = validateScopeBasedPermissionForFunctionName(this.cloudClient.userClaims, "signalQuality");
41496
+ if (hasOAuthError) {
41497
+ return throwError(() => OAuthError);
41498
+ }
41499
+ return this._withStreamingModeObservable({
41500
+ wifi: () => getCloudMetric(this._getCloudMetricDependencies(), {
41501
+ metric,
41502
+ labels: getLabels(metric),
41503
+ atomic: true
41504
+ }),
41505
+ bluetooth: () => this.bluetoothClient.signalQualityV2()
41506
+ });
41507
+ }
40323
41508
  settings() {
40324
41509
  const [hasOAuthError, OAuthError] = validateScopeBasedPermissionForFunctionName(this.cloudClient.userClaims, "settings");
40325
41510
  if (hasOAuthError) {