@rebilly/instruments 9.47.0 → 9.47.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -3374,6 +3374,7 @@ const isFormData = (thing) => {
3374
3374
  kind === "object" && isFunction(thing.toString) && thing.toString() === "[object FormData]"));
3375
3375
  };
3376
3376
  const isURLSearchParams = kindOfTest("URLSearchParams");
3377
+ const [isReadableStream, isRequest, isResponse, isHeaders] = ["ReadableStream", "Request", "Response", "Headers"].map(kindOfTest);
3377
3378
  const trim = (str) => str.trim ? str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "");
3378
3379
  function forEach(obj, fn, { allOwnKeys = false } = {}) {
3379
3380
  if (obj === null || typeof obj === "undefined") {
@@ -3583,8 +3584,7 @@ const toObjectSet = (arrayOrString, delimiter) => {
3583
3584
  const noop = () => {
3584
3585
  };
3585
3586
  const toFiniteNumber = (value, defaultValue) => {
3586
- value = +value;
3587
- return Number.isFinite(value) ? value : defaultValue;
3587
+ return value != null && Number.isFinite(value = +value) ? value : defaultValue;
3588
3588
  };
3589
3589
  const ALPHA = "abcdefghijklmnopqrstuvwxyz";
3590
3590
  const DIGIT = "0123456789";
@@ -3639,6 +3639,10 @@ const utils$1 = {
3639
3639
  isBoolean,
3640
3640
  isObject: isObject$1,
3641
3641
  isPlainObject,
3642
+ isReadableStream,
3643
+ isRequest,
3644
+ isResponse,
3645
+ isHeaders,
3642
3646
  isUndefined,
3643
3647
  isDate,
3644
3648
  isFile,
@@ -4004,11 +4008,13 @@ const hasStandardBrowserWebWorkerEnv = (() => {
4004
4008
  return typeof WorkerGlobalScope !== "undefined" && // eslint-disable-next-line no-undef
4005
4009
  self instanceof WorkerGlobalScope && typeof self.importScripts === "function";
4006
4010
  })();
4011
+ const origin = hasBrowserEnv && window.location.href || "http://localhost";
4007
4012
  const utils = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4008
4013
  __proto__: null,
4009
4014
  hasBrowserEnv,
4010
4015
  hasStandardBrowserEnv,
4011
- hasStandardBrowserWebWorkerEnv
4016
+ hasStandardBrowserWebWorkerEnv,
4017
+ origin
4012
4018
  }, Symbol.toStringTag, { value: "Module" }));
4013
4019
  const platform = {
4014
4020
  ...utils,
@@ -4091,7 +4097,7 @@ function stringifySafely(rawValue, parser, encoder) {
4091
4097
  }
4092
4098
  const defaults$1 = {
4093
4099
  transitional: transitionalDefaults,
4094
- adapter: ["xhr", "http"],
4100
+ adapter: ["xhr", "http", "fetch"],
4095
4101
  transformRequest: [function transformRequest(data, headers) {
4096
4102
  const contentType = headers.getContentType() || "";
4097
4103
  const hasJSONContentType = contentType.indexOf("application/json") > -1;
@@ -4103,7 +4109,7 @@ const defaults$1 = {
4103
4109
  if (isFormData2) {
4104
4110
  return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
4105
4111
  }
4106
- if (utils$1.isArrayBuffer(data) || utils$1.isBuffer(data) || utils$1.isStream(data) || utils$1.isFile(data) || utils$1.isBlob(data)) {
4112
+ if (utils$1.isArrayBuffer(data) || utils$1.isBuffer(data) || utils$1.isStream(data) || utils$1.isFile(data) || utils$1.isBlob(data) || utils$1.isReadableStream(data)) {
4107
4113
  return data;
4108
4114
  }
4109
4115
  if (utils$1.isArrayBufferView(data)) {
@@ -4137,6 +4143,9 @@ const defaults$1 = {
4137
4143
  const transitional2 = this.transitional || defaults$1.transitional;
4138
4144
  const forcedJSONParsing = transitional2 && transitional2.forcedJSONParsing;
4139
4145
  const JSONRequested = this.responseType === "json";
4146
+ if (utils$1.isResponse(data) || utils$1.isReadableStream(data)) {
4147
+ return data;
4148
+ }
4140
4149
  if (data && utils$1.isString(data) && (forcedJSONParsing && !this.responseType || JSONRequested)) {
4141
4150
  const silentJSONParsing = transitional2 && transitional2.silentJSONParsing;
4142
4151
  const strictJSONParsing = !silentJSONParsing && JSONRequested;
@@ -4296,6 +4305,10 @@ class AxiosHeaders {
4296
4305
  setHeaders(header, valueOrRewrite);
4297
4306
  } else if (utils$1.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
4298
4307
  setHeaders(parseHeaders(header), valueOrRewrite);
4308
+ } else if (utils$1.isHeaders(header)) {
4309
+ for (const [key, value] of header.entries()) {
4310
+ setHeader(value, key, rewrite);
4311
+ }
4299
4312
  } else {
4300
4313
  header != null && setHeader(valueOrRewrite, header, rewrite);
4301
4314
  }
@@ -4474,88 +4487,6 @@ function settle(resolve2, reject, response) {
4474
4487
  ));
4475
4488
  }
4476
4489
  }
4477
- const cookies = platform.hasStandardBrowserEnv ? (
4478
- // Standard browser envs support document.cookie
4479
- {
4480
- write(name, value, expires, path, domain, secure) {
4481
- const cookie = [name + "=" + encodeURIComponent(value)];
4482
- utils$1.isNumber(expires) && cookie.push("expires=" + new Date(expires).toGMTString());
4483
- utils$1.isString(path) && cookie.push("path=" + path);
4484
- utils$1.isString(domain) && cookie.push("domain=" + domain);
4485
- secure === true && cookie.push("secure");
4486
- document.cookie = cookie.join("; ");
4487
- },
4488
- read(name) {
4489
- const match = document.cookie.match(new RegExp("(^|;\\s*)(" + name + ")=([^;]*)"));
4490
- return match ? decodeURIComponent(match[3]) : null;
4491
- },
4492
- remove(name) {
4493
- this.write(name, "", Date.now() - 864e5);
4494
- }
4495
- }
4496
- ) : (
4497
- // Non-standard browser env (web workers, react-native) lack needed support.
4498
- {
4499
- write() {
4500
- },
4501
- read() {
4502
- return null;
4503
- },
4504
- remove() {
4505
- }
4506
- }
4507
- );
4508
- function isAbsoluteURL(url) {
4509
- return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
4510
- }
4511
- function combineURLs(baseURL, relativeURL) {
4512
- return relativeURL ? baseURL.replace(/\/?\/$/, "") + "/" + relativeURL.replace(/^\/+/, "") : baseURL;
4513
- }
4514
- function buildFullPath(baseURL, requestedURL) {
4515
- if (baseURL && !isAbsoluteURL(requestedURL)) {
4516
- return combineURLs(baseURL, requestedURL);
4517
- }
4518
- return requestedURL;
4519
- }
4520
- const isURLSameOrigin = platform.hasStandardBrowserEnv ? (
4521
- // Standard browser envs have full support of the APIs needed to test
4522
- // whether the request URL is of the same origin as current location.
4523
- function standardBrowserEnv() {
4524
- const msie = /(msie|trident)/i.test(navigator.userAgent);
4525
- const urlParsingNode = document.createElement("a");
4526
- let originURL;
4527
- function resolveURL(url) {
4528
- let href = url;
4529
- if (msie) {
4530
- urlParsingNode.setAttribute("href", href);
4531
- href = urlParsingNode.href;
4532
- }
4533
- urlParsingNode.setAttribute("href", href);
4534
- return {
4535
- href: urlParsingNode.href,
4536
- protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, "") : "",
4537
- host: urlParsingNode.host,
4538
- search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, "") : "",
4539
- hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, "") : "",
4540
- hostname: urlParsingNode.hostname,
4541
- port: urlParsingNode.port,
4542
- pathname: urlParsingNode.pathname.charAt(0) === "/" ? urlParsingNode.pathname : "/" + urlParsingNode.pathname
4543
- };
4544
- }
4545
- originURL = resolveURL(window.location.href);
4546
- return function isURLSameOrigin2(requestURL) {
4547
- const parsed = utils$1.isString(requestURL) ? resolveURL(requestURL) : requestURL;
4548
- return parsed.protocol === originURL.protocol && parsed.host === originURL.host;
4549
- };
4550
- }()
4551
- ) : (
4552
- // Non standard browser envs (web workers, react-native) lack needed support.
4553
- /* @__PURE__ */ function nonStandardBrowserEnv() {
4554
- return function isURLSameOrigin2() {
4555
- return true;
4556
- };
4557
- }()
4558
- );
4559
4490
  function parseProtocol(url) {
4560
4491
  const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
4561
4492
  return match && match[1] || "";
@@ -4593,10 +4524,34 @@ function speedometer(samplesCount, min) {
4593
4524
  return passed ? Math.round(bytesCount * 1e3 / passed) : void 0;
4594
4525
  };
4595
4526
  }
4596
- function progressEventReducer(listener, isDownloadStream) {
4527
+ function throttle(fn, freq) {
4528
+ let timestamp = 0;
4529
+ const threshold = 1e3 / freq;
4530
+ let timer = null;
4531
+ return function throttled() {
4532
+ const force = this === true;
4533
+ const now = Date.now();
4534
+ if (force || now - timestamp > threshold) {
4535
+ if (timer) {
4536
+ clearTimeout(timer);
4537
+ timer = null;
4538
+ }
4539
+ timestamp = now;
4540
+ return fn.apply(null, arguments);
4541
+ }
4542
+ if (!timer) {
4543
+ timer = setTimeout(() => {
4544
+ timer = null;
4545
+ timestamp = Date.now();
4546
+ return fn.apply(null, arguments);
4547
+ }, threshold - (now - timestamp));
4548
+ }
4549
+ };
4550
+ }
4551
+ const progressEventReducer = (listener, isDownloadStream, freq = 3) => {
4597
4552
  let bytesNotified = 0;
4598
4553
  const _speedometer = speedometer(50, 250);
4599
- return (e2) => {
4554
+ return throttle((e2) => {
4600
4555
  const loaded = e2.loaded;
4601
4556
  const total = e2.lengthComputable ? e2.total : void 0;
4602
4557
  const progressBytes = loaded - bytesNotified;
@@ -4610,45 +4565,223 @@ function progressEventReducer(listener, isDownloadStream) {
4610
4565
  bytes: progressBytes,
4611
4566
  rate: rate ? rate : void 0,
4612
4567
  estimated: rate && total && inRange ? (total - loaded) / rate : void 0,
4613
- event: e2
4568
+ event: e2,
4569
+ lengthComputable: total != null
4614
4570
  };
4615
4571
  data[isDownloadStream ? "download" : "upload"] = true;
4616
4572
  listener(data);
4573
+ }, freq);
4574
+ };
4575
+ const isURLSameOrigin = platform.hasStandardBrowserEnv ? (
4576
+ // Standard browser envs have full support of the APIs needed to test
4577
+ // whether the request URL is of the same origin as current location.
4578
+ function standardBrowserEnv() {
4579
+ const msie = /(msie|trident)/i.test(navigator.userAgent);
4580
+ const urlParsingNode = document.createElement("a");
4581
+ let originURL;
4582
+ function resolveURL(url) {
4583
+ let href = url;
4584
+ if (msie) {
4585
+ urlParsingNode.setAttribute("href", href);
4586
+ href = urlParsingNode.href;
4587
+ }
4588
+ urlParsingNode.setAttribute("href", href);
4589
+ return {
4590
+ href: urlParsingNode.href,
4591
+ protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, "") : "",
4592
+ host: urlParsingNode.host,
4593
+ search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, "") : "",
4594
+ hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, "") : "",
4595
+ hostname: urlParsingNode.hostname,
4596
+ port: urlParsingNode.port,
4597
+ pathname: urlParsingNode.pathname.charAt(0) === "/" ? urlParsingNode.pathname : "/" + urlParsingNode.pathname
4598
+ };
4599
+ }
4600
+ originURL = resolveURL(window.location.href);
4601
+ return function isURLSameOrigin2(requestURL) {
4602
+ const parsed = utils$1.isString(requestURL) ? resolveURL(requestURL) : requestURL;
4603
+ return parsed.protocol === originURL.protocol && parsed.host === originURL.host;
4604
+ };
4605
+ }()
4606
+ ) : (
4607
+ // Non standard browser envs (web workers, react-native) lack needed support.
4608
+ /* @__PURE__ */ function nonStandardBrowserEnv() {
4609
+ return function isURLSameOrigin2() {
4610
+ return true;
4611
+ };
4612
+ }()
4613
+ );
4614
+ const cookies = platform.hasStandardBrowserEnv ? (
4615
+ // Standard browser envs support document.cookie
4616
+ {
4617
+ write(name, value, expires, path, domain, secure) {
4618
+ const cookie = [name + "=" + encodeURIComponent(value)];
4619
+ utils$1.isNumber(expires) && cookie.push("expires=" + new Date(expires).toGMTString());
4620
+ utils$1.isString(path) && cookie.push("path=" + path);
4621
+ utils$1.isString(domain) && cookie.push("domain=" + domain);
4622
+ secure === true && cookie.push("secure");
4623
+ document.cookie = cookie.join("; ");
4624
+ },
4625
+ read(name) {
4626
+ const match = document.cookie.match(new RegExp("(^|;\\s*)(" + name + ")=([^;]*)"));
4627
+ return match ? decodeURIComponent(match[3]) : null;
4628
+ },
4629
+ remove(name) {
4630
+ this.write(name, "", Date.now() - 864e5);
4631
+ }
4632
+ }
4633
+ ) : (
4634
+ // Non-standard browser env (web workers, react-native) lack needed support.
4635
+ {
4636
+ write() {
4637
+ },
4638
+ read() {
4639
+ return null;
4640
+ },
4641
+ remove() {
4642
+ }
4643
+ }
4644
+ );
4645
+ function isAbsoluteURL(url) {
4646
+ return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
4647
+ }
4648
+ function combineURLs(baseURL, relativeURL) {
4649
+ return relativeURL ? baseURL.replace(/\/?\/$/, "") + "/" + relativeURL.replace(/^\/+/, "") : baseURL;
4650
+ }
4651
+ function buildFullPath(baseURL, requestedURL) {
4652
+ if (baseURL && !isAbsoluteURL(requestedURL)) {
4653
+ return combineURLs(baseURL, requestedURL);
4654
+ }
4655
+ return requestedURL;
4656
+ }
4657
+ const headersToObject = (thing) => thing instanceof AxiosHeaders$1 ? { ...thing } : thing;
4658
+ function mergeConfig(config1, config2) {
4659
+ config2 = config2 || {};
4660
+ const config = {};
4661
+ function getMergedValue(target, source, caseless) {
4662
+ if (utils$1.isPlainObject(target) && utils$1.isPlainObject(source)) {
4663
+ return utils$1.merge.call({ caseless }, target, source);
4664
+ } else if (utils$1.isPlainObject(source)) {
4665
+ return utils$1.merge({}, source);
4666
+ } else if (utils$1.isArray(source)) {
4667
+ return source.slice();
4668
+ }
4669
+ return source;
4670
+ }
4671
+ function mergeDeepProperties(a, b2, caseless) {
4672
+ if (!utils$1.isUndefined(b2)) {
4673
+ return getMergedValue(a, b2, caseless);
4674
+ } else if (!utils$1.isUndefined(a)) {
4675
+ return getMergedValue(void 0, a, caseless);
4676
+ }
4677
+ }
4678
+ function valueFromConfig2(a, b2) {
4679
+ if (!utils$1.isUndefined(b2)) {
4680
+ return getMergedValue(void 0, b2);
4681
+ }
4682
+ }
4683
+ function defaultToConfig2(a, b2) {
4684
+ if (!utils$1.isUndefined(b2)) {
4685
+ return getMergedValue(void 0, b2);
4686
+ } else if (!utils$1.isUndefined(a)) {
4687
+ return getMergedValue(void 0, a);
4688
+ }
4689
+ }
4690
+ function mergeDirectKeys(a, b2, prop) {
4691
+ if (prop in config2) {
4692
+ return getMergedValue(a, b2);
4693
+ } else if (prop in config1) {
4694
+ return getMergedValue(void 0, a);
4695
+ }
4696
+ }
4697
+ const mergeMap = {
4698
+ url: valueFromConfig2,
4699
+ method: valueFromConfig2,
4700
+ data: valueFromConfig2,
4701
+ baseURL: defaultToConfig2,
4702
+ transformRequest: defaultToConfig2,
4703
+ transformResponse: defaultToConfig2,
4704
+ paramsSerializer: defaultToConfig2,
4705
+ timeout: defaultToConfig2,
4706
+ timeoutMessage: defaultToConfig2,
4707
+ withCredentials: defaultToConfig2,
4708
+ withXSRFToken: defaultToConfig2,
4709
+ adapter: defaultToConfig2,
4710
+ responseType: defaultToConfig2,
4711
+ xsrfCookieName: defaultToConfig2,
4712
+ xsrfHeaderName: defaultToConfig2,
4713
+ onUploadProgress: defaultToConfig2,
4714
+ onDownloadProgress: defaultToConfig2,
4715
+ decompress: defaultToConfig2,
4716
+ maxContentLength: defaultToConfig2,
4717
+ maxBodyLength: defaultToConfig2,
4718
+ beforeRedirect: defaultToConfig2,
4719
+ transport: defaultToConfig2,
4720
+ httpAgent: defaultToConfig2,
4721
+ httpsAgent: defaultToConfig2,
4722
+ cancelToken: defaultToConfig2,
4723
+ socketPath: defaultToConfig2,
4724
+ responseEncoding: defaultToConfig2,
4725
+ validateStatus: mergeDirectKeys,
4726
+ headers: (a, b2) => mergeDeepProperties(headersToObject(a), headersToObject(b2), true)
4617
4727
  };
4728
+ utils$1.forEach(Object.keys(Object.assign({}, config1, config2)), function computeConfigValue(prop) {
4729
+ const merge2 = mergeMap[prop] || mergeDeepProperties;
4730
+ const configValue = merge2(config1[prop], config2[prop], prop);
4731
+ utils$1.isUndefined(configValue) && merge2 !== mergeDirectKeys || (config[prop] = configValue);
4732
+ });
4733
+ return config;
4618
4734
  }
4735
+ const resolveConfig = (config) => {
4736
+ const newConfig = mergeConfig({}, config);
4737
+ let { data, withXSRFToken, xsrfHeaderName, xsrfCookieName, headers, auth } = newConfig;
4738
+ newConfig.headers = headers = AxiosHeaders$1.from(headers);
4739
+ newConfig.url = buildURL(buildFullPath(newConfig.baseURL, newConfig.url), config.params, config.paramsSerializer);
4740
+ if (auth) {
4741
+ headers.set(
4742
+ "Authorization",
4743
+ "Basic " + btoa((auth.username || "") + ":" + (auth.password ? unescape(encodeURIComponent(auth.password)) : ""))
4744
+ );
4745
+ }
4746
+ let contentType;
4747
+ if (utils$1.isFormData(data)) {
4748
+ if (platform.hasStandardBrowserEnv || platform.hasStandardBrowserWebWorkerEnv) {
4749
+ headers.setContentType(void 0);
4750
+ } else if ((contentType = headers.getContentType()) !== false) {
4751
+ const [type2, ...tokens] = contentType ? contentType.split(";").map((token) => token.trim()).filter(Boolean) : [];
4752
+ headers.setContentType([type2 || "multipart/form-data", ...tokens].join("; "));
4753
+ }
4754
+ }
4755
+ if (platform.hasStandardBrowserEnv) {
4756
+ withXSRFToken && utils$1.isFunction(withXSRFToken) && (withXSRFToken = withXSRFToken(newConfig));
4757
+ if (withXSRFToken || withXSRFToken !== false && isURLSameOrigin(newConfig.url)) {
4758
+ const xsrfValue = xsrfHeaderName && xsrfCookieName && cookies.read(xsrfCookieName);
4759
+ if (xsrfValue) {
4760
+ headers.set(xsrfHeaderName, xsrfValue);
4761
+ }
4762
+ }
4763
+ }
4764
+ return newConfig;
4765
+ };
4619
4766
  const isXHRAdapterSupported = typeof XMLHttpRequest !== "undefined";
4620
4767
  const xhrAdapter = isXHRAdapterSupported && function(config) {
4621
4768
  return new Promise(function dispatchXhrRequest(resolve2, reject) {
4622
- let requestData = config.data;
4623
- const requestHeaders = AxiosHeaders$1.from(config.headers).normalize();
4624
- let { responseType, withXSRFToken } = config;
4769
+ const _config = resolveConfig(config);
4770
+ let requestData = _config.data;
4771
+ const requestHeaders = AxiosHeaders$1.from(_config.headers).normalize();
4772
+ let { responseType } = _config;
4625
4773
  let onCanceled;
4626
4774
  function done() {
4627
- if (config.cancelToken) {
4628
- config.cancelToken.unsubscribe(onCanceled);
4775
+ if (_config.cancelToken) {
4776
+ _config.cancelToken.unsubscribe(onCanceled);
4629
4777
  }
4630
- if (config.signal) {
4631
- config.signal.removeEventListener("abort", onCanceled);
4632
- }
4633
- }
4634
- let contentType;
4635
- if (utils$1.isFormData(requestData)) {
4636
- if (platform.hasStandardBrowserEnv || platform.hasStandardBrowserWebWorkerEnv) {
4637
- requestHeaders.setContentType(false);
4638
- } else if ((contentType = requestHeaders.getContentType()) !== false) {
4639
- const [type2, ...tokens] = contentType ? contentType.split(";").map((token) => token.trim()).filter(Boolean) : [];
4640
- requestHeaders.setContentType([type2 || "multipart/form-data", ...tokens].join("; "));
4778
+ if (_config.signal) {
4779
+ _config.signal.removeEventListener("abort", onCanceled);
4641
4780
  }
4642
4781
  }
4643
4782
  let request = new XMLHttpRequest();
4644
- if (config.auth) {
4645
- const username = config.auth.username || "";
4646
- const password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : "";
4647
- requestHeaders.set("Authorization", "Basic " + btoa(username + ":" + password));
4648
- }
4649
- const fullPath = buildFullPath(config.baseURL, config.url);
4650
- request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true);
4651
- request.timeout = config.timeout;
4783
+ request.open(_config.method.toUpperCase(), _config.url, true);
4784
+ request.timeout = _config.timeout;
4652
4785
  function onloadend() {
4653
4786
  if (!request) {
4654
4787
  return;
@@ -4691,55 +4824,46 @@ const xhrAdapter = isXHRAdapterSupported && function(config) {
4691
4824
  if (!request) {
4692
4825
  return;
4693
4826
  }
4694
- reject(new AxiosError("Request aborted", AxiosError.ECONNABORTED, config, request));
4827
+ reject(new AxiosError("Request aborted", AxiosError.ECONNABORTED, _config, request));
4695
4828
  request = null;
4696
4829
  };
4697
4830
  request.onerror = function handleError() {
4698
- reject(new AxiosError("Network Error", AxiosError.ERR_NETWORK, config, request));
4831
+ reject(new AxiosError("Network Error", AxiosError.ERR_NETWORK, _config, request));
4699
4832
  request = null;
4700
4833
  };
4701
4834
  request.ontimeout = function handleTimeout() {
4702
- let timeoutErrorMessage = config.timeout ? "timeout of " + config.timeout + "ms exceeded" : "timeout exceeded";
4703
- const transitional2 = config.transitional || transitionalDefaults;
4704
- if (config.timeoutErrorMessage) {
4705
- timeoutErrorMessage = config.timeoutErrorMessage;
4835
+ let timeoutErrorMessage = _config.timeout ? "timeout of " + _config.timeout + "ms exceeded" : "timeout exceeded";
4836
+ const transitional2 = _config.transitional || transitionalDefaults;
4837
+ if (_config.timeoutErrorMessage) {
4838
+ timeoutErrorMessage = _config.timeoutErrorMessage;
4706
4839
  }
4707
4840
  reject(new AxiosError(
4708
4841
  timeoutErrorMessage,
4709
4842
  transitional2.clarifyTimeoutError ? AxiosError.ETIMEDOUT : AxiosError.ECONNABORTED,
4710
- config,
4843
+ _config,
4711
4844
  request
4712
4845
  ));
4713
4846
  request = null;
4714
4847
  };
4715
- if (platform.hasStandardBrowserEnv) {
4716
- withXSRFToken && utils$1.isFunction(withXSRFToken) && (withXSRFToken = withXSRFToken(config));
4717
- if (withXSRFToken || withXSRFToken !== false && isURLSameOrigin(fullPath)) {
4718
- const xsrfValue = config.xsrfHeaderName && config.xsrfCookieName && cookies.read(config.xsrfCookieName);
4719
- if (xsrfValue) {
4720
- requestHeaders.set(config.xsrfHeaderName, xsrfValue);
4721
- }
4722
- }
4723
- }
4724
4848
  requestData === void 0 && requestHeaders.setContentType(null);
4725
4849
  if ("setRequestHeader" in request) {
4726
4850
  utils$1.forEach(requestHeaders.toJSON(), function setRequestHeader(val, key) {
4727
4851
  request.setRequestHeader(key, val);
4728
4852
  });
4729
4853
  }
4730
- if (!utils$1.isUndefined(config.withCredentials)) {
4731
- request.withCredentials = !!config.withCredentials;
4854
+ if (!utils$1.isUndefined(_config.withCredentials)) {
4855
+ request.withCredentials = !!_config.withCredentials;
4732
4856
  }
4733
4857
  if (responseType && responseType !== "json") {
4734
- request.responseType = config.responseType;
4858
+ request.responseType = _config.responseType;
4735
4859
  }
4736
- if (typeof config.onDownloadProgress === "function") {
4737
- request.addEventListener("progress", progressEventReducer(config.onDownloadProgress, true));
4860
+ if (typeof _config.onDownloadProgress === "function") {
4861
+ request.addEventListener("progress", progressEventReducer(_config.onDownloadProgress, true));
4738
4862
  }
4739
- if (typeof config.onUploadProgress === "function" && request.upload) {
4740
- request.upload.addEventListener("progress", progressEventReducer(config.onUploadProgress));
4863
+ if (typeof _config.onUploadProgress === "function" && request.upload) {
4864
+ request.upload.addEventListener("progress", progressEventReducer(_config.onUploadProgress));
4741
4865
  }
4742
- if (config.cancelToken || config.signal) {
4866
+ if (_config.cancelToken || _config.signal) {
4743
4867
  onCanceled = (cancel) => {
4744
4868
  if (!request) {
4745
4869
  return;
@@ -4748,12 +4872,12 @@ const xhrAdapter = isXHRAdapterSupported && function(config) {
4748
4872
  request.abort();
4749
4873
  request = null;
4750
4874
  };
4751
- config.cancelToken && config.cancelToken.subscribe(onCanceled);
4752
- if (config.signal) {
4753
- config.signal.aborted ? onCanceled() : config.signal.addEventListener("abort", onCanceled);
4875
+ _config.cancelToken && _config.cancelToken.subscribe(onCanceled);
4876
+ if (_config.signal) {
4877
+ _config.signal.aborted ? onCanceled() : _config.signal.addEventListener("abort", onCanceled);
4754
4878
  }
4755
4879
  }
4756
- const protocol = parseProtocol(fullPath);
4880
+ const protocol = parseProtocol(_config.url);
4757
4881
  if (protocol && platform.protocols.indexOf(protocol) === -1) {
4758
4882
  reject(new AxiosError("Unsupported protocol " + protocol + ":", AxiosError.ERR_BAD_REQUEST, config));
4759
4883
  return;
@@ -4761,9 +4885,247 @@ const xhrAdapter = isXHRAdapterSupported && function(config) {
4761
4885
  request.send(requestData || null);
4762
4886
  });
4763
4887
  };
4888
+ const composeSignals = (signals, timeout) => {
4889
+ let controller = new AbortController();
4890
+ let aborted;
4891
+ const onabort = function(cancel) {
4892
+ if (!aborted) {
4893
+ aborted = true;
4894
+ unsubscribe();
4895
+ const err = cancel instanceof Error ? cancel : this.reason;
4896
+ controller.abort(err instanceof AxiosError ? err : new CanceledError(err instanceof Error ? err.message : err));
4897
+ }
4898
+ };
4899
+ let timer = timeout && setTimeout(() => {
4900
+ onabort(new AxiosError(`timeout ${timeout} of ms exceeded`, AxiosError.ETIMEDOUT));
4901
+ }, timeout);
4902
+ const unsubscribe = () => {
4903
+ if (signals) {
4904
+ timer && clearTimeout(timer);
4905
+ timer = null;
4906
+ signals.forEach((signal2) => {
4907
+ signal2 && (signal2.removeEventListener ? signal2.removeEventListener("abort", onabort) : signal2.unsubscribe(onabort));
4908
+ });
4909
+ signals = null;
4910
+ }
4911
+ };
4912
+ signals.forEach((signal2) => signal2 && signal2.addEventListener && signal2.addEventListener("abort", onabort));
4913
+ const { signal } = controller;
4914
+ signal.unsubscribe = unsubscribe;
4915
+ return [signal, () => {
4916
+ timer && clearTimeout(timer);
4917
+ timer = null;
4918
+ }];
4919
+ };
4920
+ const streamChunk = function* (chunk, chunkSize) {
4921
+ let len = chunk.byteLength;
4922
+ if (!chunkSize || len < chunkSize) {
4923
+ yield chunk;
4924
+ return;
4925
+ }
4926
+ let pos = 0;
4927
+ let end;
4928
+ while (pos < len) {
4929
+ end = pos + chunkSize;
4930
+ yield chunk.slice(pos, end);
4931
+ pos = end;
4932
+ }
4933
+ };
4934
+ const readBytes = async function* (iterable, chunkSize, encode2) {
4935
+ for await (const chunk of iterable) {
4936
+ yield* streamChunk(ArrayBuffer.isView(chunk) ? chunk : await encode2(String(chunk)), chunkSize);
4937
+ }
4938
+ };
4939
+ const trackStream = (stream, chunkSize, onProgress, onFinish, encode2) => {
4940
+ const iterator = readBytes(stream, chunkSize, encode2);
4941
+ let bytes = 0;
4942
+ return new ReadableStream({
4943
+ type: "bytes",
4944
+ async pull(controller) {
4945
+ const { done, value } = await iterator.next();
4946
+ if (done) {
4947
+ controller.close();
4948
+ onFinish();
4949
+ return;
4950
+ }
4951
+ let len = value.byteLength;
4952
+ onProgress && onProgress(bytes += len);
4953
+ controller.enqueue(new Uint8Array(value));
4954
+ },
4955
+ cancel(reason) {
4956
+ onFinish(reason);
4957
+ return iterator.return();
4958
+ }
4959
+ }, {
4960
+ highWaterMark: 2
4961
+ });
4962
+ };
4963
+ const fetchProgressDecorator = (total, fn) => {
4964
+ const lengthComputable = total != null;
4965
+ return (loaded) => setTimeout(() => fn({
4966
+ lengthComputable,
4967
+ total,
4968
+ loaded
4969
+ }));
4970
+ };
4971
+ const isFetchSupported = typeof fetch !== "undefined";
4972
+ const isReadableStreamSupported = isFetchSupported && typeof ReadableStream !== "undefined";
4973
+ const encodeText = isFetchSupported && (typeof TextEncoder !== "undefined" ? /* @__PURE__ */ ((encoder) => (str) => encoder.encode(str))(new TextEncoder()) : async (str) => new Uint8Array(await new Response(str).arrayBuffer()));
4974
+ const supportsRequestStream = isReadableStreamSupported && (() => {
4975
+ let duplexAccessed = false;
4976
+ const hasContentType = new Request(platform.origin, {
4977
+ body: new ReadableStream(),
4978
+ method: "POST",
4979
+ get duplex() {
4980
+ duplexAccessed = true;
4981
+ return "half";
4982
+ }
4983
+ }).headers.has("Content-Type");
4984
+ return duplexAccessed && !hasContentType;
4985
+ })();
4986
+ const DEFAULT_CHUNK_SIZE = 64 * 1024;
4987
+ const supportsResponseStream = isReadableStreamSupported && !!(() => {
4988
+ try {
4989
+ return utils$1.isReadableStream(new Response("").body);
4990
+ } catch (err) {
4991
+ }
4992
+ })();
4993
+ const resolvers = {
4994
+ stream: supportsResponseStream && ((res) => res.body)
4995
+ };
4996
+ isFetchSupported && ((res) => {
4997
+ ["text", "arrayBuffer", "blob", "formData", "stream"].forEach((type2) => {
4998
+ !resolvers[type2] && (resolvers[type2] = utils$1.isFunction(res[type2]) ? (res2) => res2[type2]() : (_2, config) => {
4999
+ throw new AxiosError(`Response type '${type2}' is not supported`, AxiosError.ERR_NOT_SUPPORT, config);
5000
+ });
5001
+ });
5002
+ })(new Response());
5003
+ const getBodyLength = async (body) => {
5004
+ if (body == null) {
5005
+ return 0;
5006
+ }
5007
+ if (utils$1.isBlob(body)) {
5008
+ return body.size;
5009
+ }
5010
+ if (utils$1.isSpecCompliantForm(body)) {
5011
+ return (await new Request(body).arrayBuffer()).byteLength;
5012
+ }
5013
+ if (utils$1.isArrayBufferView(body)) {
5014
+ return body.byteLength;
5015
+ }
5016
+ if (utils$1.isURLSearchParams(body)) {
5017
+ body = body + "";
5018
+ }
5019
+ if (utils$1.isString(body)) {
5020
+ return (await encodeText(body)).byteLength;
5021
+ }
5022
+ };
5023
+ const resolveBodyLength = async (headers, body) => {
5024
+ const length = utils$1.toFiniteNumber(headers.getContentLength());
5025
+ return length == null ? getBodyLength(body) : length;
5026
+ };
5027
+ const fetchAdapter = isFetchSupported && (async (config) => {
5028
+ let {
5029
+ url,
5030
+ method,
5031
+ data,
5032
+ signal,
5033
+ cancelToken,
5034
+ timeout,
5035
+ onDownloadProgress,
5036
+ onUploadProgress,
5037
+ responseType,
5038
+ headers,
5039
+ withCredentials = "same-origin",
5040
+ fetchOptions
5041
+ } = resolveConfig(config);
5042
+ responseType = responseType ? (responseType + "").toLowerCase() : "text";
5043
+ let [composedSignal, stopTimeout] = signal || cancelToken || timeout ? composeSignals([signal, cancelToken], timeout) : [];
5044
+ let finished, request;
5045
+ const onFinish = () => {
5046
+ !finished && setTimeout(() => {
5047
+ composedSignal && composedSignal.unsubscribe();
5048
+ });
5049
+ finished = true;
5050
+ };
5051
+ let requestContentLength;
5052
+ try {
5053
+ if (onUploadProgress && supportsRequestStream && method !== "get" && method !== "head" && (requestContentLength = await resolveBodyLength(headers, data)) !== 0) {
5054
+ let _request = new Request(url, {
5055
+ method: "POST",
5056
+ body: data,
5057
+ duplex: "half"
5058
+ });
5059
+ let contentTypeHeader;
5060
+ if (utils$1.isFormData(data) && (contentTypeHeader = _request.headers.get("content-type"))) {
5061
+ headers.setContentType(contentTypeHeader);
5062
+ }
5063
+ if (_request.body) {
5064
+ data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, fetchProgressDecorator(
5065
+ requestContentLength,
5066
+ progressEventReducer(onUploadProgress)
5067
+ ), null, encodeText);
5068
+ }
5069
+ }
5070
+ if (!utils$1.isString(withCredentials)) {
5071
+ withCredentials = withCredentials ? "cors" : "omit";
5072
+ }
5073
+ request = new Request(url, {
5074
+ ...fetchOptions,
5075
+ signal: composedSignal,
5076
+ method: method.toUpperCase(),
5077
+ headers: headers.normalize().toJSON(),
5078
+ body: data,
5079
+ duplex: "half",
5080
+ withCredentials
5081
+ });
5082
+ let response = await fetch(request);
5083
+ const isStreamResponse = supportsResponseStream && (responseType === "stream" || responseType === "response");
5084
+ if (supportsResponseStream && (onDownloadProgress || isStreamResponse)) {
5085
+ const options = {};
5086
+ ["status", "statusText", "headers"].forEach((prop) => {
5087
+ options[prop] = response[prop];
5088
+ });
5089
+ const responseContentLength = utils$1.toFiniteNumber(response.headers.get("content-length"));
5090
+ response = new Response(
5091
+ trackStream(response.body, DEFAULT_CHUNK_SIZE, onDownloadProgress && fetchProgressDecorator(
5092
+ responseContentLength,
5093
+ progressEventReducer(onDownloadProgress, true)
5094
+ ), isStreamResponse && onFinish, encodeText),
5095
+ options
5096
+ );
5097
+ }
5098
+ responseType = responseType || "text";
5099
+ let responseData = await resolvers[utils$1.findKey(resolvers, responseType) || "text"](response, config);
5100
+ !isStreamResponse && onFinish();
5101
+ stopTimeout && stopTimeout();
5102
+ return await new Promise((resolve2, reject) => {
5103
+ settle(resolve2, reject, {
5104
+ data: responseData,
5105
+ headers: AxiosHeaders$1.from(response.headers),
5106
+ status: response.status,
5107
+ statusText: response.statusText,
5108
+ config,
5109
+ request
5110
+ });
5111
+ });
5112
+ } catch (err) {
5113
+ onFinish();
5114
+ if (err && err.name === "TypeError" && /fetch/i.test(err.message)) {
5115
+ throw Object.assign(
5116
+ new AxiosError("Network Error", AxiosError.ERR_NETWORK, config, request),
5117
+ {
5118
+ cause: err.cause || err
5119
+ }
5120
+ );
5121
+ }
5122
+ throw AxiosError.from(err, err && err.code, config, request);
5123
+ }
5124
+ });
4764
5125
  const knownAdapters = {
4765
5126
  http: httpAdapter,
4766
- xhr: xhrAdapter
5127
+ xhr: xhrAdapter,
5128
+ fetch: fetchAdapter
4767
5129
  };
4768
5130
  utils$1.forEach(knownAdapters, (fn, value) => {
4769
5131
  if (fn) {
@@ -4855,85 +5217,7 @@ function dispatchRequest(config) {
4855
5217
  return Promise.reject(reason);
4856
5218
  });
4857
5219
  }
4858
- const headersToObject = (thing) => thing instanceof AxiosHeaders$1 ? { ...thing } : thing;
4859
- function mergeConfig(config1, config2) {
4860
- config2 = config2 || {};
4861
- const config = {};
4862
- function getMergedValue(target, source, caseless) {
4863
- if (utils$1.isPlainObject(target) && utils$1.isPlainObject(source)) {
4864
- return utils$1.merge.call({ caseless }, target, source);
4865
- } else if (utils$1.isPlainObject(source)) {
4866
- return utils$1.merge({}, source);
4867
- } else if (utils$1.isArray(source)) {
4868
- return source.slice();
4869
- }
4870
- return source;
4871
- }
4872
- function mergeDeepProperties(a, b2, caseless) {
4873
- if (!utils$1.isUndefined(b2)) {
4874
- return getMergedValue(a, b2, caseless);
4875
- } else if (!utils$1.isUndefined(a)) {
4876
- return getMergedValue(void 0, a, caseless);
4877
- }
4878
- }
4879
- function valueFromConfig2(a, b2) {
4880
- if (!utils$1.isUndefined(b2)) {
4881
- return getMergedValue(void 0, b2);
4882
- }
4883
- }
4884
- function defaultToConfig2(a, b2) {
4885
- if (!utils$1.isUndefined(b2)) {
4886
- return getMergedValue(void 0, b2);
4887
- } else if (!utils$1.isUndefined(a)) {
4888
- return getMergedValue(void 0, a);
4889
- }
4890
- }
4891
- function mergeDirectKeys(a, b2, prop) {
4892
- if (prop in config2) {
4893
- return getMergedValue(a, b2);
4894
- } else if (prop in config1) {
4895
- return getMergedValue(void 0, a);
4896
- }
4897
- }
4898
- const mergeMap = {
4899
- url: valueFromConfig2,
4900
- method: valueFromConfig2,
4901
- data: valueFromConfig2,
4902
- baseURL: defaultToConfig2,
4903
- transformRequest: defaultToConfig2,
4904
- transformResponse: defaultToConfig2,
4905
- paramsSerializer: defaultToConfig2,
4906
- timeout: defaultToConfig2,
4907
- timeoutMessage: defaultToConfig2,
4908
- withCredentials: defaultToConfig2,
4909
- withXSRFToken: defaultToConfig2,
4910
- adapter: defaultToConfig2,
4911
- responseType: defaultToConfig2,
4912
- xsrfCookieName: defaultToConfig2,
4913
- xsrfHeaderName: defaultToConfig2,
4914
- onUploadProgress: defaultToConfig2,
4915
- onDownloadProgress: defaultToConfig2,
4916
- decompress: defaultToConfig2,
4917
- maxContentLength: defaultToConfig2,
4918
- maxBodyLength: defaultToConfig2,
4919
- beforeRedirect: defaultToConfig2,
4920
- transport: defaultToConfig2,
4921
- httpAgent: defaultToConfig2,
4922
- httpsAgent: defaultToConfig2,
4923
- cancelToken: defaultToConfig2,
4924
- socketPath: defaultToConfig2,
4925
- responseEncoding: defaultToConfig2,
4926
- validateStatus: mergeDirectKeys,
4927
- headers: (a, b2) => mergeDeepProperties(headersToObject(a), headersToObject(b2), true)
4928
- };
4929
- utils$1.forEach(Object.keys(Object.assign({}, config1, config2)), function computeConfigValue(prop) {
4930
- const merge2 = mergeMap[prop] || mergeDeepProperties;
4931
- const configValue = merge2(config1[prop], config2[prop], prop);
4932
- utils$1.isUndefined(configValue) && merge2 !== mergeDirectKeys || (config[prop] = configValue);
4933
- });
4934
- return config;
4935
- }
4936
- const VERSION = "1.6.8";
5220
+ const VERSION = "1.7.1";
4937
5221
  const validators$1 = {};
4938
5222
  ["object", "boolean", "number", "function", "string", "symbol"].forEach((type2, i) => {
4939
5223
  validators$1[type2] = function validator2(thing) {
@@ -5015,10 +5299,13 @@ class Axios {
5015
5299
  let dummy;
5016
5300
  Error.captureStackTrace ? Error.captureStackTrace(dummy = {}) : dummy = new Error();
5017
5301
  const stack = dummy.stack ? dummy.stack.replace(/^.+\n/, "") : "";
5018
- if (!err.stack) {
5019
- err.stack = stack;
5020
- } else if (stack && !String(err.stack).endsWith(stack.replace(/^.+\n.+\n/, ""))) {
5021
- err.stack += "\n" + stack;
5302
+ try {
5303
+ if (!err.stack) {
5304
+ err.stack = stack;
5305
+ } else if (stack && !String(err.stack).endsWith(stack.replace(/^.+\n.+\n/, ""))) {
5306
+ err.stack += "\n" + stack;
5307
+ }
5308
+ } catch (e2) {
5022
5309
  }
5023
5310
  }
5024
5311
  throw err;
@@ -16277,11 +16564,11 @@ const collectedProperties = [
16277
16564
  ];
16278
16565
  const prefix = /utm_/g;
16279
16566
  const getLeadSourceData = () => {
16280
- const { href, origin, pathname, search } = window.location;
16567
+ const { href, origin: origin2, pathname, search } = window.location;
16281
16568
  const leadSource = {
16282
16569
  // Large query parameters including JWTs will cause issues, so make sure we dont
16283
16570
  // use anything longer than 255 characters.
16284
- path: href.length <= 255 ? href : `${origin}${pathname}`
16571
+ path: href.length <= 255 ? href : `${origin2}${pathname}`
16285
16572
  };
16286
16573
  const query = search.replace("?", "");
16287
16574
  return query.split("&").map((field) => field.split("=")).filter((field) => {
@@ -16864,38 +17151,6 @@ function generateDigitalWallet({ expressMethods = [] }) {
16864
17151
  });
16865
17152
  return output;
16866
17153
  }
16867
- async function mountAmountSelector() {
16868
- var _a, _b, _c;
16869
- if (state.data.money) {
16870
- state.data.money.amount = null;
16871
- state.data.money.currency = null;
16872
- state.updateModel();
16873
- }
16874
- const iframe = iframes.form;
16875
- if (!iframe) {
16876
- await mountForm();
16877
- }
16878
- const modelSafeState = state.toModel();
16879
- const model = {
16880
- options: modelSafeState.options,
16881
- data: modelSafeState.data
16882
- };
16883
- (_a = iframe.component) == null ? void 0 : _a.call("route", {
16884
- name: "amount-selector"
16885
- });
16886
- (_b = iframe.component) == null ? void 0 : _b.call("update", model);
16887
- (_c = iframe == null ? void 0 : iframe.component) == null ? void 0 : _c.on("confirm-amount", async (data) => {
16888
- const { amount, currency } = data;
16889
- state.data.money = {
16890
- amount,
16891
- currency
16892
- };
16893
- const readyToPayUpdated = await fetchReadyToPay();
16894
- state.data.readyToPay = readyToPayUpdated;
16895
- state.updateModel();
16896
- mountMethodSelector();
16897
- });
16898
- }
16899
17154
  async function createDeposit({
16900
17155
  data
16901
17156
  }) {
@@ -16945,38 +17200,6 @@ function hideExtraUI() {
16945
17200
  }
16946
17201
  }
16947
17202
  }
16948
- const backToAmountElement = () => {
16949
- const template = `
16950
- <div class="rebilly-instruments-confirmation-go-back-link" style="display: inline-block;margin-bottom: var(--rebilly-spacingM);margin-left: calc(var(--rebilly-spacingXs) * -1);">
16951
- <a
16952
- class="rebilly-instruments-link has-icon-left"
16953
- style="display: inline-flex;color: var(--rebilly-colorPrimary);cursor: pointer;"
16954
- >
16955
- <svg
16956
- class="rebilly-instruments-icon"
16957
- style="margin-right: var(--rebilly-spacingXs);fill: var(--rebilly-colorPrimary)"
16958
- viewBox="0 0 24 24"
16959
- xmlns="http://www.w3.org/2000/svg"
16960
- >
16961
- <path
16962
- d="M6.2929 11.2929l5-5c.3905-.3905 1.0237-.3905 1.4142 0 .3905.3905.3905 1.0237 0 1.4142L9.4142 11H17c.5523 0 1 .4477 1 1s-.4477 1-1 1H9.4142l3.293 3.2929c.3904.3905.3904 1.0237 0 1.4142-.3906.3905-1.0238.3905-1.4143 0l-5-5A.9969.9969 0 016 12c0-.2761.112-.5261.2929-.7071z"
16963
- fill-rule="nonzero"
16964
- />
16965
- </svg>
16966
- <span data-rebilly-i18n="deposit.goBack"></span>
16967
- </a>
16968
- </div>
16969
- `;
16970
- const rootDiv = document.createElement("div");
16971
- rootDiv.setAttribute("data-rebilly-instruments", "deposit-back");
16972
- rootDiv.innerHTML += template;
16973
- const link = rootDiv.querySelector(".rebilly-instruments-link");
16974
- link.addEventListener("click", () => {
16975
- hideExtraUI();
16976
- mountAmountSelector();
16977
- });
16978
- return rootDiv;
16979
- };
16980
17203
  const expressMethodsElement = ({ expressMethods }) => {
16981
17204
  const rootDiv = document.createElement("div");
16982
17205
  rootDiv.classList.add("rebilly-instruments-method-selector");
@@ -17002,18 +17225,10 @@ const expressMethodsElement = ({ expressMethods }) => {
17002
17225
  return rootDiv;
17003
17226
  };
17004
17227
  async function mountMethodSelector() {
17005
- var _a, _b, _c, _d, _e2, _f, _g, _h;
17228
+ var _a, _b, _c, _d, _e2, _f, _g;
17006
17229
  const contentEl = getElement("content");
17007
17230
  const formEl = getElement("form");
17008
17231
  const { expressMethods, methods } = getPaymentMethods();
17009
- if ((_a = state.options) == null ? void 0 : _a.deposit) {
17010
- const existingDepositBackElement = getElement("deposit-back");
17011
- if (existingDepositBackElement) {
17012
- existingDepositBackElement.style.height = "auto";
17013
- } else {
17014
- contentEl.insertBefore(backToAmountElement(), formEl);
17015
- }
17016
- }
17017
17232
  if (expressMethods.length) {
17018
17233
  const existingExpressMethodElement = getElement("express-methods");
17019
17234
  if (existingExpressMethodElement) {
@@ -17035,7 +17250,7 @@ async function mountMethodSelector() {
17035
17250
  });
17036
17251
  }
17037
17252
  }
17038
- if ((_c = (_b = state.options) == null ? void 0 : _b.bumpOffer) == null ? void 0 : _c.length) {
17253
+ if ((_b = (_a = state.options) == null ? void 0 : _a.bumpOffer) == null ? void 0 : _b.length) {
17039
17254
  const existingExpressMethodElement = getElement("bump-offer");
17040
17255
  if (existingExpressMethodElement) {
17041
17256
  existingExpressMethodElement.style.height = "auto";
@@ -17058,12 +17273,12 @@ async function mountMethodSelector() {
17058
17273
  options: modelSafeState.options,
17059
17274
  data: modelSafeState.data
17060
17275
  };
17061
- (_d = iframe == null ? void 0 : iframe.component) == null ? void 0 : _d.call("route", {
17276
+ (_c = iframe == null ? void 0 : iframe.component) == null ? void 0 : _c.call("route", {
17062
17277
  name: "method-switch"
17063
17278
  });
17064
- (_e2 = iframe == null ? void 0 : iframe.component) == null ? void 0 : _e2.call("update", model);
17065
- if (!((_g = (_f = iframe == null ? void 0 : iframe.component) == null ? void 0 : _f.events) == null ? void 0 : _g["restart-payment-flow"])) {
17066
- (_h = iframe == null ? void 0 : iframe.component) == null ? void 0 : _h.on("restart-payment-flow", async (payload) => {
17279
+ (_d = iframe == null ? void 0 : iframe.component) == null ? void 0 : _d.call("update", model);
17280
+ if (!((_f = (_e2 = iframe == null ? void 0 : iframe.component) == null ? void 0 : _e2.events) == null ? void 0 : _f["restart-payment-flow"])) {
17281
+ (_g = iframe == null ? void 0 : iframe.component) == null ? void 0 : _g.on("restart-payment-flow", async (payload) => {
17067
17282
  if (payload == null ? void 0 : payload.createNewDeposit) {
17068
17283
  const transaction = await createDeposit({
17069
17284
  data: {
@@ -17093,6 +17308,49 @@ async function mountMethodSelector() {
17093
17308
  }
17094
17309
  state.translate.translateItems();
17095
17310
  }
17311
+ async function mountAmountSelector() {
17312
+ var _a, _b, _c;
17313
+ if (state.data.money) {
17314
+ state.data.money.amount = null;
17315
+ state.data.money.currency = null;
17316
+ state.updateModel();
17317
+ }
17318
+ const iframe = iframes.form;
17319
+ if (!iframe) {
17320
+ await mountForm();
17321
+ }
17322
+ const modelSafeState = state.toModel();
17323
+ const model = {
17324
+ options: modelSafeState.options,
17325
+ data: modelSafeState.data
17326
+ };
17327
+ (_a = iframe.component) == null ? void 0 : _a.call("route", {
17328
+ name: "amount-selector"
17329
+ });
17330
+ (_b = iframe.component) == null ? void 0 : _b.call("update", model);
17331
+ (_c = iframe == null ? void 0 : iframe.component) == null ? void 0 : _c.on("confirm-amount", async (data) => {
17332
+ const { amount, currency } = data;
17333
+ const { depositRequestId } = state.options.deposit;
17334
+ state.data.money = {
17335
+ amount,
17336
+ currency
17337
+ };
17338
+ const transaction = await createDeposit({
17339
+ data: {
17340
+ depositRequestId,
17341
+ amount
17342
+ }
17343
+ });
17344
+ if (transaction) {
17345
+ state.data.transaction = transaction;
17346
+ state.options.transactionId = transaction.id;
17347
+ }
17348
+ const readyToPayUpdated = await fetchReadyToPay();
17349
+ state.data.readyToPay = readyToPayUpdated;
17350
+ state.updateModel();
17351
+ mountMethodSelector();
17352
+ });
17353
+ }
17096
17354
  const baseMethodSelectorHTML = () => `
17097
17355
  <div data-rebilly-instruments="content" class="rebilly-instruments-content">
17098
17356
  <div data-rebilly-instruments="content-error" id="rebilly-instruments-error"></div>