@reservamos/browser-analytics 1.0.7 → 1.0.9

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.
@@ -89,8 +89,8 @@ const ZodParsedType = util.arrayToEnum([
89
89
  "set"
90
90
  ]);
91
91
  const getParsedType = (data) => {
92
- const t = typeof data;
93
- switch (t) {
92
+ const t2 = typeof data;
93
+ switch (t2) {
94
94
  case "undefined":
95
95
  return ZodParsedType.undefined;
96
96
  case "string":
@@ -3922,25 +3922,25 @@ const customEventSchema = z.record(
3922
3922
  );
3923
3923
  const eventNameSchema = z.string().min(1, "Event name is required");
3924
3924
  var __assign = function() {
3925
- __assign = Object.assign || function __assign2(t) {
3925
+ __assign = Object.assign || function __assign2(t2) {
3926
3926
  for (var s2, i = 1, n = arguments.length; i < n; i++) {
3927
3927
  s2 = arguments[i];
3928
- for (var p2 in s2) if (Object.prototype.hasOwnProperty.call(s2, p2)) t[p2] = s2[p2];
3928
+ for (var p2 in s2) if (Object.prototype.hasOwnProperty.call(s2, p2)) t2[p2] = s2[p2];
3929
3929
  }
3930
- return t;
3930
+ return t2;
3931
3931
  };
3932
3932
  return __assign.apply(this, arguments);
3933
3933
  };
3934
3934
  function __rest$1(s2, e) {
3935
- var t = {};
3935
+ var t2 = {};
3936
3936
  for (var p2 in s2) if (Object.prototype.hasOwnProperty.call(s2, p2) && e.indexOf(p2) < 0)
3937
- t[p2] = s2[p2];
3937
+ t2[p2] = s2[p2];
3938
3938
  if (s2 != null && typeof Object.getOwnPropertySymbols === "function")
3939
3939
  for (var i = 0, p2 = Object.getOwnPropertySymbols(s2); i < p2.length; i++) {
3940
3940
  if (e.indexOf(p2[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s2, p2[i]))
3941
- t[p2[i]] = s2[p2[i]];
3941
+ t2[p2[i]] = s2[p2[i]];
3942
3942
  }
3943
- return t;
3943
+ return t2;
3944
3944
  }
3945
3945
  function __awaiter$1(thisArg, _arguments, P2, generator) {
3946
3946
  function adopt(value) {
@@ -3982,46 +3982,46 @@ typeof SuppressedError === "function" ? SuppressedError : function(error, suppre
3982
3982
  var e = new Error(message);
3983
3983
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
3984
3984
  };
3985
- function r(e, t) {
3986
- return function(e2, t2) {
3987
- return Object.prototype.hasOwnProperty.call(e2, t2);
3988
- }(e, t) ? e[t] : void 0;
3985
+ function r$1(e, t2) {
3986
+ return function(e2, t3) {
3987
+ return Object.prototype.hasOwnProperty.call(e2, t3);
3988
+ }(e, t2) ? e[t2] : void 0;
3989
3989
  }
3990
- function o(e, t, n, r2) {
3991
- var o2, i = document, a2 = "securitypolicyviolation", u2 = function(t2) {
3992
- var n2 = new URL(e, location.href), r3 = t2.blockedURI;
3993
- r3 !== n2.href && r3 !== n2.protocol.slice(0, -1) && r3 !== n2.origin || (o2 = t2, R2());
3990
+ function o(e, t2, n, r2) {
3991
+ var o2, i = document, a2 = "securitypolicyviolation", u2 = function(t3) {
3992
+ var n2 = new URL(e, location.href), r3 = t3.blockedURI;
3993
+ r3 !== n2.href && r3 !== n2.protocol.slice(0, -1) && r3 !== n2.origin || (o2 = t3, R2());
3994
3994
  };
3995
3995
  i.addEventListener(a2, u2);
3996
3996
  var R2 = function() {
3997
3997
  return i.removeEventListener(a2, u2);
3998
3998
  };
3999
- return Promise.resolve().then(t).then(function(e2) {
3999
+ return Promise.resolve().then(t2).then(function(e2) {
4000
4000
  return R2(), e2;
4001
4001
  }, function(e2) {
4002
4002
  return new Promise(function(e3) {
4003
- var t2 = new MessageChannel();
4004
- t2.port1.onmessage = function() {
4003
+ var t3 = new MessageChannel();
4004
+ t3.port1.onmessage = function() {
4005
4005
  return e3();
4006
- }, t2.port2.postMessage(null);
4006
+ }, t3.port2.postMessage(null);
4007
4007
  }).then(function() {
4008
4008
  if (R2(), o2) return n(o2);
4009
4009
  throw e2;
4010
4010
  });
4011
4011
  });
4012
4012
  }
4013
- var i$1 = { default: "endpoint" }, a = { default: "tlsEndpoint" }, u = "Client timeout", R = "Network connection error", c = "Network request aborted", s = "Response cannot be parsed", f = "Blocked by CSP", l = "The endpoint parameter is not a valid URL";
4013
+ var i$1 = { default: "endpoint" }, a = { default: "tlsEndpoint" }, u = "Client timeout", R = "Network connection error", c = "Network request aborted", s$1 = "Response cannot be parsed", f$1 = "Blocked by CSP", l = "The endpoint parameter is not a valid URL";
4014
4014
  function E(e) {
4015
- for (var t = "", n = 0; n < e.length; ++n) if (n > 0) {
4015
+ for (var t2 = "", n = 0; n < e.length; ++n) if (n > 0) {
4016
4016
  var r2 = e[n].toLowerCase();
4017
- r2 !== e[n] ? t += " ".concat(r2) : t += e[n];
4018
- } else t += e[n].toUpperCase();
4019
- return t;
4020
- }
4021
- var d = /* @__PURE__ */ E("WrongRegion"), p = /* @__PURE__ */ E("SubscriptionNotActive"), v = /* @__PURE__ */ E("UnsupportedVersion"), _$1 = /* @__PURE__ */ E("InstallationMethodRestricted"), O = /* @__PURE__ */ E("HostnameRestricted"), h = /* @__PURE__ */ E("IntegrationFailed"), I = "API key required", N = "API key not found", T = "API key expired", m = "Request cannot be parsed", w = "Request failed", A = "Request failed to process", P = "Too many requests, rate limit exceeded", y = "Not available for this origin", D = "Not available with restricted header", S = I, g = N, L = T, U = "3.11.1", b = "Failed to load the JS script of the agent", C = "9319";
4022
- function M(t, n) {
4023
- var r2, o2, i, a2, u2, R2, c2 = [], s2 = (r2 = function(t2) {
4024
- var n2 = __spreadArray([], t2, true);
4017
+ r2 !== e[n] ? t2 += " ".concat(r2) : t2 += e[n];
4018
+ } else t2 += e[n].toUpperCase();
4019
+ return t2;
4020
+ }
4021
+ var d = /* @__PURE__ */ E("WrongRegion"), p = /* @__PURE__ */ E("SubscriptionNotActive"), v = /* @__PURE__ */ E("UnsupportedVersion"), _$1 = /* @__PURE__ */ E("InstallationMethodRestricted"), O = /* @__PURE__ */ E("HostnameRestricted"), h = /* @__PURE__ */ E("IntegrationFailed"), I = "API key required", N = "API key not found", T = "API key expired", m$1 = "Request cannot be parsed", w$1 = "Request failed", A = "Request failed to process", P = "Too many requests, rate limit exceeded", y = "Not available for this origin", D = "Not available with restricted header", S = I, g = N, L = T, U = "3.11.1", b = "Failed to load the JS script of the agent", C = "9319";
4022
+ function M(t2, n) {
4023
+ var r2, o2, i, a2, u2, R2, c2 = [], s2 = (r2 = function(t3) {
4024
+ var n2 = __spreadArray([], t3, true);
4025
4025
  return { current: function() {
4026
4026
  return n2[0];
4027
4027
  }, postpone: function() {
@@ -4030,11 +4030,11 @@ function M(t, n) {
4030
4030
  }, exclude: function() {
4031
4031
  n2.shift();
4032
4032
  } };
4033
- }(t), a2 = 100, u2 = 3e3, R2 = 0, o2 = function() {
4033
+ }(t2), a2 = 100, u2 = 3e3, R2 = 0, o2 = function() {
4034
4034
  return Math.random() * Math.min(u2, a2 * Math.pow(2, R2++));
4035
- }, i = /* @__PURE__ */ new Set(), [r2.current(), function(e, t2) {
4036
- var n2, a3 = t2 instanceof Error ? t2.message : "";
4037
- if (a3 === f || a3 === l) r2.exclude(), n2 = 0;
4035
+ }, i = /* @__PURE__ */ new Set(), [r2.current(), function(e, t3) {
4036
+ var n2, a3 = t3 instanceof Error ? t3.message : "";
4037
+ if (a3 === f$1 || a3 === l) r2.exclude(), n2 = 0;
4038
4038
  else if (a3 === C) r2.exclude();
4039
4039
  else if (a3 === b) {
4040
4040
  var u3 = Date.now() - e.getTime() < 50, R3 = r2.current();
@@ -4045,14 +4045,14 @@ function M(t, n) {
4045
4045
  }]), E2 = s2[0], d2 = s2[1];
4046
4046
  if (void 0 === E2) return Promise.reject(new TypeError("The list of script URL patterns is empty"));
4047
4047
  var p2 = function(e) {
4048
- var t2 = /* @__PURE__ */ new Date(), r3 = function(n2) {
4049
- return c2.push({ url: e, startedAt: t2, finishedAt: /* @__PURE__ */ new Date(), error: n2 });
4048
+ var t3 = /* @__PURE__ */ new Date(), r3 = function(n2) {
4049
+ return c2.push({ url: e, startedAt: t3, finishedAt: /* @__PURE__ */ new Date(), error: n2 });
4050
4050
  }, o3 = n(e);
4051
4051
  return o3.then(function() {
4052
4052
  return r3();
4053
4053
  }, r3), o3.catch(function(e2) {
4054
4054
  if (c2.length >= 5) throw e2;
4055
- var n2 = d2(t2, e2);
4055
+ var n2 = d2(t3, e2);
4056
4056
  if (!n2) throw e2;
4057
4057
  var r4, o4 = n2[0], i2 = n2[1];
4058
4058
  return (r4 = i2, new Promise(function(e3) {
@@ -4070,26 +4070,26 @@ var K = "https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js", B
4070
4070
  function F(e) {
4071
4071
  var o2;
4072
4072
  e.scriptUrlPattern;
4073
- var i = e.token, a2 = e.apiKey, u2 = void 0 === a2 ? i : a2, R2 = __rest$1(e, ["scriptUrlPattern", "token", "apiKey"]), c2 = null !== (o2 = r(e, "scriptUrlPattern")) && void 0 !== o2 ? o2 : K, s2 = function() {
4074
- var e2 = [], t = function() {
4073
+ var i = e.token, a2 = e.apiKey, u2 = void 0 === a2 ? i : a2, R2 = __rest$1(e, ["scriptUrlPattern", "token", "apiKey"]), c2 = null !== (o2 = r$1(e, "scriptUrlPattern")) && void 0 !== o2 ? o2 : K, s2 = function() {
4074
+ var e2 = [], t2 = function() {
4075
4075
  e2.push({ time: /* @__PURE__ */ new Date(), state: document.visibilityState });
4076
- }, n = function(e3, t2, n2, r2) {
4077
- return e3.addEventListener(t2, n2, r2), function() {
4078
- return e3.removeEventListener(t2, n2, r2);
4076
+ }, n = function(e3, t3, n2, r2) {
4077
+ return e3.addEventListener(t3, n2, r2), function() {
4078
+ return e3.removeEventListener(t3, n2, r2);
4079
4079
  };
4080
- }(document, "visibilitychange", t);
4081
- return t(), [e2, n];
4080
+ }(document, "visibilitychange", t2);
4081
+ return t2(), [e2, n];
4082
4082
  }(), f2 = s2[0], l2 = s2[1];
4083
4083
  return Promise.resolve().then(function() {
4084
4084
  if (!u2 || "string" != typeof u2) throw new Error(I);
4085
- var e2 = function(e3, t) {
4085
+ var e2 = function(e3, t2) {
4086
4086
  return (Array.isArray(e3) ? e3 : [e3]).map(function(e4) {
4087
- return function(e5, t2) {
4087
+ return function(e5, t3) {
4088
4088
  var n = encodeURIComponent;
4089
4089
  return e5.replace(/<[^<>]+>/g, function(e6) {
4090
- return "<version>" === e6 ? "3" : "<apiKey>" === e6 ? n(t2) : "<loaderVersion>" === e6 ? n(U) : e6;
4090
+ return "<version>" === e6 ? "3" : "<apiKey>" === e6 ? n(t3) : "<loaderVersion>" === e6 ? n(U) : e6;
4091
4091
  });
4092
- }(String(e4), t);
4092
+ }(String(e4), t2);
4093
4093
  });
4094
4094
  }(c2, u2);
4095
4095
  return M(e2, V);
@@ -4099,20 +4099,20 @@ function F(e) {
4099
4099
  return e3;
4100
4100
  }(e2);
4101
4101
  }).then(function(e2) {
4102
- var t = e2[0], r2 = e2[1];
4103
- return l2(), t.load(__assign(__assign({}, R2), { ldi: { attempts: r2, visibilityStates: f2 } }));
4102
+ var t2 = e2[0], r2 = e2[1];
4103
+ return l2(), t2.load(__assign(__assign({}, R2), { ldi: { attempts: r2, visibilityStates: f2 } }));
4104
4104
  });
4105
4105
  }
4106
4106
  function V(e) {
4107
4107
  return o(e, function() {
4108
4108
  return function(e2) {
4109
- return new Promise(function(t, n) {
4109
+ return new Promise(function(t2, n) {
4110
4110
  if (function(e3) {
4111
4111
  if (URL.prototype) try {
4112
4112
  return new URL(e3, location.href), false;
4113
- } catch (t2) {
4114
- if (t2 instanceof Error && "TypeError" === t2.name) return true;
4115
- throw t2;
4113
+ } catch (t3) {
4114
+ if (t3 instanceof Error && "TypeError" === t3.name) return true;
4115
+ throw t3;
4116
4116
  }
4117
4117
  }(e2)) throw new Error(l);
4118
4118
  var r2 = document.createElement("script"), o2 = function() {
@@ -4120,38 +4120,38 @@ function V(e) {
4120
4120
  return null === (e3 = r2.parentNode) || void 0 === e3 ? void 0 : e3.removeChild(r2);
4121
4121
  }, i = document.head || document.getElementsByTagName("head")[0];
4122
4122
  r2.onload = function() {
4123
- o2(), t();
4123
+ o2(), t2();
4124
4124
  }, r2.onerror = function() {
4125
4125
  o2(), n(new Error(b));
4126
4126
  }, r2.async = true, r2.src = e2, i.appendChild(r2);
4127
4127
  });
4128
4128
  }(e);
4129
4129
  }, function() {
4130
- throw new Error(f);
4130
+ throw new Error(f$1);
4131
4131
  }).then(k);
4132
4132
  }
4133
4133
  function k() {
4134
- var e = window, t = "__fpjs_p_l_b", n = e[t];
4135
- if (function(e2, t2) {
4136
- var n2, r2 = null === (n2 = Object.getOwnPropertyDescriptor) || void 0 === n2 ? void 0 : n2.call(Object, e2, t2);
4137
- (null == r2 ? void 0 : r2.configurable) ? delete e2[t2] : r2 && !r2.writable || (e2[t2] = void 0);
4138
- }(e, t), "function" != typeof (null == n ? void 0 : n.load)) throw new Error(C);
4134
+ var e = window, t2 = "__fpjs_p_l_b", n = e[t2];
4135
+ if (function(e2, t3) {
4136
+ var n2, r2 = null === (n2 = Object.getOwnPropertyDescriptor) || void 0 === n2 ? void 0 : n2.call(Object, e2, t3);
4137
+ (null == r2 ? void 0 : r2.configurable) ? delete e2[t3] : r2 && !r2.writable || (e2[t3] = void 0);
4138
+ }(e, t2), "function" != typeof (null == n ? void 0 : n.load)) throw new Error(C);
4139
4139
  return n;
4140
4140
  }
4141
- var G = { load: F, defaultScriptUrlPattern: B, ERROR_SCRIPT_LOAD_FAIL: b, ERROR_API_KEY_EXPIRED: T, ERROR_API_KEY_INVALID: N, ERROR_API_KEY_MISSING: I, ERROR_BAD_REQUEST_FORMAT: m, ERROR_BAD_RESPONSE_FORMAT: s, ERROR_CLIENT_TIMEOUT: u, ERROR_CSP_BLOCK: f, ERROR_FORBIDDEN_ENDPOINT: O, ERROR_FORBIDDEN_HEADER: D, ERROR_FORBIDDEN_ORIGIN: y, ERROR_GENERAL_SERVER_FAILURE: w, ERROR_INSTALLATION_METHOD_RESTRICTED: _$1, ERROR_INTEGRATION_FAILURE: h, ERROR_INVALID_ENDPOINT: l, ERROR_NETWORK_ABORT: c, ERROR_NETWORK_CONNECTION: R, ERROR_RATE_LIMIT: P, ERROR_SERVER_TIMEOUT: A, ERROR_SUBSCRIPTION_NOT_ACTIVE: p, ERROR_TOKEN_EXPIRED: L, ERROR_TOKEN_INVALID: g, ERROR_TOKEN_MISSING: S, ERROR_UNSUPPORTED_VERSION: v, ERROR_WRONG_REGION: d, defaultEndpoint: i$1, defaultTlsEndpoint: a };
4141
+ var G = { load: F, defaultScriptUrlPattern: B, ERROR_SCRIPT_LOAD_FAIL: b, ERROR_API_KEY_EXPIRED: T, ERROR_API_KEY_INVALID: N, ERROR_API_KEY_MISSING: I, ERROR_BAD_REQUEST_FORMAT: m$1, ERROR_BAD_RESPONSE_FORMAT: s$1, ERROR_CLIENT_TIMEOUT: u, ERROR_CSP_BLOCK: f$1, ERROR_FORBIDDEN_ENDPOINT: O, ERROR_FORBIDDEN_HEADER: D, ERROR_FORBIDDEN_ORIGIN: y, ERROR_GENERAL_SERVER_FAILURE: w$1, ERROR_INSTALLATION_METHOD_RESTRICTED: _$1, ERROR_INTEGRATION_FAILURE: h, ERROR_INVALID_ENDPOINT: l, ERROR_NETWORK_ABORT: c, ERROR_NETWORK_CONNECTION: R, ERROR_RATE_LIMIT: P, ERROR_SERVER_TIMEOUT: A, ERROR_SUBSCRIPTION_NOT_ACTIVE: p, ERROR_TOKEN_EXPIRED: L, ERROR_TOKEN_INVALID: g, ERROR_TOKEN_MISSING: S, ERROR_UNSUPPORTED_VERSION: v, ERROR_WRONG_REGION: d, defaultEndpoint: i$1, defaultTlsEndpoint: a };
4142
4142
  const FingerprintJSPro = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4143
4143
  __proto__: null,
4144
4144
  ERROR_API_KEY_EXPIRED: T,
4145
4145
  ERROR_API_KEY_INVALID: N,
4146
4146
  ERROR_API_KEY_MISSING: I,
4147
- ERROR_BAD_REQUEST_FORMAT: m,
4148
- ERROR_BAD_RESPONSE_FORMAT: s,
4147
+ ERROR_BAD_REQUEST_FORMAT: m$1,
4148
+ ERROR_BAD_RESPONSE_FORMAT: s$1,
4149
4149
  ERROR_CLIENT_TIMEOUT: u,
4150
- ERROR_CSP_BLOCK: f,
4150
+ ERROR_CSP_BLOCK: f$1,
4151
4151
  ERROR_FORBIDDEN_ENDPOINT: O,
4152
4152
  ERROR_FORBIDDEN_HEADER: D,
4153
4153
  ERROR_FORBIDDEN_ORIGIN: y,
4154
- ERROR_GENERAL_SERVER_FAILURE: w,
4154
+ ERROR_GENERAL_SERVER_FAILURE: w$1,
4155
4155
  ERROR_INSTALLATION_METHOD_RESTRICTED: _$1,
4156
4156
  ERROR_INTEGRATION_FAILURE: h,
4157
4157
  ERROR_INVALID_ENDPOINT: l,
@@ -4366,7 +4366,7 @@ var CacheLocation;
4366
4366
  CacheLocation2["SessionStorage"] = "sessionstorage";
4367
4367
  CacheLocation2["NoCache"] = "nocache";
4368
4368
  })(CacheLocation || (CacheLocation = {}));
4369
- var version = "1.3.2";
4369
+ var version$1 = "1.3.2";
4370
4370
  const cacheLocationBuilders = {
4371
4371
  [CacheLocation.Memory]: () => new InMemoryCache().enclosedCache,
4372
4372
  [CacheLocation.LocalStorage]: (prefix) => new LocalStorageCache(prefix),
@@ -4445,7 +4445,7 @@ class FpjsClient {
4445
4445
  const loadOptions = Object.assign(Object.assign(Object.assign({}, this.loadOptions), passedLoadOptions), { integrationInfo: [
4446
4446
  ...((_a = this.loadOptions) === null || _a === void 0 ? void 0 : _a.integrationInfo) || [],
4447
4447
  ...(passedLoadOptions === null || passedLoadOptions === void 0 ? void 0 : passedLoadOptions.integrationInfo) || [],
4448
- `fingerprintjs-pro-spa/${version}`
4448
+ `fingerprintjs-pro-spa/${version$1}`
4449
4449
  ] });
4450
4450
  if (!this.agentPromise) {
4451
4451
  const agentLoader = (_b = this.customAgent) !== null && _b !== void 0 ? _b : FingerprintJSPro;
@@ -4619,2493 +4619,116 @@ const fingerprintService = {
4619
4619
  isFingerprintReady,
4620
4620
  getCachedFingerprint
4621
4621
  };
4622
- var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
4623
- var jsApiClient = { exports: {} };
4624
- (function(module, exports) {
4625
- (function webpackUniversalModuleDefinition(root, factory) {
4626
- module.exports = factory();
4627
- })(typeof self !== "undefined" ? self : commonjsGlobal, function() {
4628
- return (
4629
- /******/
4630
- function(modules) {
4631
- var installedModules = {};
4632
- function __webpack_require__(moduleId) {
4633
- if (installedModules[moduleId]) {
4634
- return installedModules[moduleId].exports;
4635
- }
4636
- var module2 = installedModules[moduleId] = {
4637
- /******/
4638
- i: moduleId,
4639
- /******/
4640
- l: false,
4641
- /******/
4642
- exports: {}
4643
- /******/
4644
- };
4645
- modules[moduleId].call(module2.exports, module2, module2.exports, __webpack_require__);
4646
- module2.l = true;
4647
- return module2.exports;
4648
- }
4649
- __webpack_require__.m = modules;
4650
- __webpack_require__.c = installedModules;
4651
- __webpack_require__.d = function(exports2, name, getter) {
4652
- if (!__webpack_require__.o(exports2, name)) {
4653
- Object.defineProperty(exports2, name, {
4654
- /******/
4655
- configurable: false,
4656
- /******/
4657
- enumerable: true,
4658
- /******/
4659
- get: getter
4660
- /******/
4661
- });
4662
- }
4663
- };
4664
- __webpack_require__.n = function(module2) {
4665
- var getter = module2 && module2.__esModule ? (
4666
- /******/
4667
- function getDefault() {
4668
- return module2["default"];
4669
- }
4670
- ) : (
4671
- /******/
4672
- function getModuleExports() {
4673
- return module2;
4674
- }
4675
- );
4676
- __webpack_require__.d(getter, "a", getter);
4677
- return getter;
4678
- };
4679
- __webpack_require__.o = function(object, property) {
4680
- return Object.prototype.hasOwnProperty.call(object, property);
4681
- };
4682
- __webpack_require__.p = "";
4683
- return __webpack_require__(__webpack_require__.s = 3);
4684
- }([
4685
- /* 0 */
4686
- /***/
4687
- function(module2, exports2, __webpack_require__) {
4688
- Object.defineProperty(exports2, "__esModule", {
4689
- value: true
4690
- });
4691
- var _extends = Object.assign || function(target) {
4692
- for (var i = 1; i < arguments.length; i++) {
4693
- var source = arguments[i];
4694
- for (var key in source) {
4695
- if (Object.prototype.hasOwnProperty.call(source, key)) {
4696
- target[key] = source[key];
4697
- }
4698
- }
4699
- }
4700
- return target;
4701
- };
4702
- exports2.post = post;
4703
- exports2.get = get;
4704
- exports2.put = put;
4705
- exports2.deleteMethod = deleteMethod;
4706
- exports2.poll = poll;
4707
- var _config = __webpack_require__(1);
4708
- var _config2 = _interopRequireDefault(_config);
4709
- var _request = __webpack_require__(2);
4710
- var request = _interopRequireWildcard(_request);
4711
- var _Poll = __webpack_require__(9);
4712
- var _Poll2 = _interopRequireDefault(_Poll);
4713
- function _interopRequireWildcard(obj) {
4714
- if (obj && obj.__esModule) {
4715
- return obj;
4716
- } else {
4717
- var newObj = {};
4718
- if (obj != null) {
4719
- for (var key in obj) {
4720
- if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key];
4721
- }
4722
- }
4723
- newObj.default = obj;
4724
- return newObj;
4725
- }
4726
- }
4727
- function _interopRequireDefault(obj) {
4728
- return obj && obj.__esModule ? obj : { default: obj };
4729
- }
4730
- function _toConsumableArray(arr) {
4731
- if (Array.isArray(arr)) {
4732
- for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) {
4733
- arr2[i] = arr[i];
4734
- }
4735
- return arr2;
4736
- } else {
4737
- return Array.from(arr);
4738
- }
4739
- }
4740
- var headerOptions = { apiKey: _config2.default.apiKey };
4741
- function serializeQueryParams(options) {
4742
- var ignore = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : [];
4743
- if (!options) {
4744
- return "";
4745
- }
4746
- var ignoreList = [null, void 0, ""].concat(_toConsumableArray(ignore));
4747
- var optionList = [];
4748
- Object.keys(options).forEach(function(key) {
4749
- var value = options[key];
4750
- if (!ignoreList.includes(value)) {
4751
- optionList.push(key + "=" + value);
4752
- }
4753
- });
4754
- return optionList.length ? "?" + optionList.join("&") : "";
4755
- }
4756
- function buildUrl(_ref) {
4757
- var endpoint = _ref.endpoint, _ref$apiVersion = _ref.apiVersion, apiVersion = _ref$apiVersion === void 0 ? _config2.default.version : _ref$apiVersion, queryParams = _ref.queryParams, apiType = _ref.apiType;
4758
- if (apiType === "core") {
4759
- return _config2.default.coreUrl + "/" + _config2.default.coreVersion + "/" + endpoint + serializeQueryParams(queryParams);
4760
- }
4761
- var apiUrl = /search|redirect|places/.test(endpoint) ? _config2.default.searchUrl : _config2.default.purchaseUrl;
4762
- return apiUrl + "/" + apiVersion + "/" + endpoint + serializeQueryParams(queryParams);
4763
- }
4764
- function post(endpoint, payload) {
4765
- var _ref2 = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}, apiVersion = _ref2.apiVersion, apiType = _ref2.apiType;
4766
- var url = buildUrl({ endpoint, apiVersion, apiType });
4767
- return request.post(url, payload, headerOptions);
4768
- }
4769
- function get(endpoint) {
4770
- var _ref3 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, apiVersion = _ref3.apiVersion, queryParams = _ref3.queryParams, apiType = _ref3.apiType;
4771
- var url = buildUrl({ endpoint, apiVersion, queryParams, apiType });
4772
- return request.get(url, headerOptions);
4773
- }
4774
- function put(endpoint, payload) {
4775
- var _ref4 = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}, apiVersion = _ref4.apiVersion, apiType = _ref4.apiType;
4776
- var url = buildUrl({ endpoint, apiVersion, apiType });
4777
- return request.put(url, payload, headerOptions);
4778
- }
4779
- function deleteMethod(endpoint) {
4780
- var _ref5 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, apiVersion = _ref5.apiVersion;
4781
- _ref5.queryParams;
4782
- var apiType = _ref5.apiType;
4783
- var url = buildUrl({ endpoint, apiVersion, apiType });
4784
- return request.deleteMethod(url, headerOptions);
4785
- }
4786
- function poll(endpoint, eachCall) {
4787
- var options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
4788
- var apiVersion = arguments[3];
4789
- var apiType = arguments[4];
4790
- var url = buildUrl({ endpoint, apiVersion, apiType });
4791
- var pollOptions = _extends({ url, eachCall }, options);
4792
- return new _Poll2.default(pollOptions);
4793
- }
4794
- },
4795
- /* 1 */
4796
- /***/
4797
- function(module2, exports2, __webpack_require__) {
4798
- Object.defineProperty(exports2, "__esModule", {
4799
- value: true
4800
- });
4801
- exports2.setConfig = setConfig;
4802
- exports2.setUserAuthToken = setUserAuthToken;
4803
- var configRoots = {
4804
- sandbox: {
4805
- search: "https://search.resertravel.com/api",
4806
- purchase: "https://purchases.resertravel.com/api",
4807
- core: ""
4808
- },
4809
- production: {
4810
- search: "https://search.reservamos.mx/api",
4811
- purchase: "https://compras.reservamos.mx/api",
4812
- core: ""
4813
- }
4814
- };
4815
- var defaultEnv = "sandbox";
4816
- var defaultVersion = "v2";
4817
- var defaultCoreVersion = "v1";
4818
- var defaultConfig = {
4819
- env: defaultEnv,
4820
- headers: {},
4821
- searchUrl: configRoots[defaultEnv].search,
4822
- purchaseUrl: configRoots[defaultEnv].purchase,
4823
- coreUrl: configRoots[defaultEnv].core,
4824
- version: defaultVersion,
4825
- coreVersion: defaultCoreVersion,
4826
- apiKey: void 0,
4827
- userAuthToken: void 0,
4828
- withCredentials: false
4829
- };
4830
- var config = exports2.config = Object.assign({}, defaultConfig);
4831
- function setConfig() {
4832
- var userConfig = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
4833
- if (userConfig.env !== void 0) {
4834
- userConfig.searchUrl = configRoots[userConfig.env].search;
4835
- userConfig.purchaseUrl = configRoots[userConfig.env].purchase;
4836
- userConfig.coreUrl = configRoots[userConfig.env].core;
4837
- userConfig.coreVersion = configRoots[userConfig.env].coreVersion;
4838
- }
4839
- return Object.assign(config, userConfig);
4840
- }
4841
- function setUserAuthToken(userAuthToken) {
4842
- return Object.assign(config, { userAuthToken });
4843
- }
4844
- exports2.default = config;
4845
- },
4846
- /* 2 */
4847
- /***/
4848
- function(module2, exports2, __webpack_require__) {
4849
- Object.defineProperty(exports2, "__esModule", {
4850
- value: true
4851
- });
4852
- var _extends = Object.assign || function(target) {
4853
- for (var i = 1; i < arguments.length; i++) {
4854
- var source = arguments[i];
4855
- for (var key in source) {
4856
- if (Object.prototype.hasOwnProperty.call(source, key)) {
4857
- target[key] = source[key];
4858
- }
4859
- }
4860
- }
4861
- return target;
4862
- };
4863
- exports2.post = post;
4864
- exports2.get = get;
4865
- exports2.put = put;
4866
- exports2.deleteMethod = deleteMethod;
4867
- var _config = __webpack_require__(1);
4868
- var _config2 = _interopRequireDefault(_config);
4869
- var _NetworkError = __webpack_require__(7);
4870
- var _NetworkError2 = _interopRequireDefault(_NetworkError);
4871
- var _errorTypes = __webpack_require__(8);
4872
- var _errorTypes2 = _interopRequireDefault(_errorTypes);
4873
- function _interopRequireDefault(obj) {
4874
- return obj && obj.__esModule ? obj : { default: obj };
4875
- }
4876
- function _defineProperty(obj, key, value) {
4877
- if (key in obj) {
4878
- Object.defineProperty(obj, key, { value, enumerable: true, configurable: true, writable: true });
4879
- } else {
4880
- obj[key] = value;
4881
- }
4882
- return obj;
4883
- }
4884
- function checkStatus(response) {
4885
- var handledErrors = [404, 422, 500];
4886
- var body = response.json();
4887
- if (response.ok) {
4888
- return body;
4889
- } else if (handledErrors.includes(response.status)) {
4890
- switch (response.status) {
4891
- case 404:
4892
- throw new _NetworkError2.default(100, "Not found");
4893
- case 422:
4894
- return body;
4895
- case 500:
4896
- throw new _NetworkError2.default(101, "Server error");
4897
- default:
4898
- throw new _NetworkError2.default();
4899
- }
4900
- } else {
4901
- throw new _NetworkError2.default(response.status, response.statusText);
4902
- }
4903
- }
4904
- function handleErrors(response) {
4905
- if (response.errors instanceof Array) {
4906
- var _ref = response.errors[0] || {}, _ref$code = _ref.code, code = _ref$code === void 0 ? -100 : _ref$code, _ref$message = _ref.message, message = _ref$message === void 0 ? "Unknown error" : _ref$message;
4907
- var knownError = (0, _errorTypes2.default)(message)[code];
4908
- if (knownError) {
4909
- throw new _NetworkError2.default(knownError.code, knownError.message);
4910
- } else {
4911
- throw new _NetworkError2.default(code, message);
4912
- }
4913
- } else {
4914
- return response;
4915
- }
4916
- }
4917
- function buildHeaders() {
4918
- for (var _len = arguments.length, sources = Array(_len), _key = 0; _key < _len; _key++) {
4919
- sources[_key] = arguments[_key];
4920
- }
4921
- var keys = Object.keys(Object.assign.apply(Object, [{}].concat(sources)));
4922
- var headers = keys.reduce(function(result, key) {
4923
- return _extends({}, result, _defineProperty({}, key, sources.map(function(source) {
4924
- return key in source && source[key];
4925
- }).filter(Boolean)));
4926
- }, {});
4927
- return new Headers(headers);
4928
- }
4929
- function fetchJson(url) {
4930
- var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
4931
- var headerOptions = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
4932
- var onRequestError = arguments[3];
4933
- var apiKey = _config2.default.apiKey, withCredentials = _config2.default.withCredentials, userAuthToken = _config2.default.userAuthToken, defaultHeaders = _config2.default.headers;
4934
- var headers = {
4935
- "Accept": "application/json",
4936
- "Authorization": "Token token=" + (headerOptions.apiKey || apiKey),
4937
- "Content-Type": "application/json"
4938
- };
4939
- if (userAuthToken) {
4940
- headers.Authorization = "Token " + (headerOptions.apiKey || apiKey) + ", Bearer " + userAuthToken;
4941
- }
4942
- options.headers = buildHeaders(defaultHeaders, headers);
4943
- options.credentials = withCredentials ? "include" : "omit";
4944
- if (typeof options.body !== "string") {
4945
- options.body = JSON.stringify(options.body);
4946
- }
4947
- return fetch(url, options).then(checkStatus).then(handleErrors).catch(onRequestError);
4948
- }
4949
- function post(url, payload) {
4950
- var headerOptions = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
4951
- return fetchJson(url, {
4952
- method: "POST",
4953
- body: JSON.stringify(payload)
4954
- }, headerOptions);
4955
- }
4956
- function get(url) {
4957
- var headerOptions = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
4958
- var onRequestError = arguments[2];
4959
- return fetchJson(url, headerOptions, {}, onRequestError);
4960
- }
4961
- function put(url, payload) {
4962
- var headerOptions = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
4963
- return fetchJson(url, {
4964
- method: "PUT",
4965
- body: JSON.stringify(payload)
4966
- }, headerOptions);
4967
- }
4968
- function deleteMethod(url) {
4969
- var headerOptions = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
4970
- return fetchJson(url, {
4971
- method: "DELETE"
4972
- }, headerOptions);
4973
- }
4974
- },
4975
- /* 3 */
4976
- /***/
4977
- function(module2, exports2, __webpack_require__) {
4978
- __webpack_require__(4);
4979
- __webpack_require__(5);
4980
- module2.exports = __webpack_require__(6);
4981
- },
4982
- /* 4 */
4983
- /***/
4984
- function(module2, exports2) {
4985
- if (typeof Object.assign !== "function") {
4986
- Object.assign = function(target, varArgs) {
4987
- if (target == null) {
4988
- throw new TypeError("Cannot convert undefined or null to object");
4989
- }
4990
- var to = Object(target);
4991
- for (var index = 1; index < arguments.length; index++) {
4992
- var nextSource = arguments[index];
4993
- if (nextSource != null) {
4994
- for (var nextKey in nextSource) {
4995
- if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) {
4996
- to[nextKey] = nextSource[nextKey];
4997
- }
4998
- }
4999
- }
5000
- }
5001
- return to;
5002
- };
5003
- }
5004
- },
5005
- /* 5 */
5006
- /***/
5007
- function(module2, exports2) {
5008
- (function(self2) {
5009
- if (self2.fetch) {
5010
- return;
5011
- }
5012
- var support = {
5013
- searchParams: "URLSearchParams" in self2,
5014
- iterable: "Symbol" in self2 && "iterator" in Symbol,
5015
- blob: "FileReader" in self2 && "Blob" in self2 && function() {
5016
- try {
5017
- new Blob();
5018
- return true;
5019
- } catch (e) {
5020
- return false;
5021
- }
5022
- }(),
5023
- formData: "FormData" in self2,
5024
- arrayBuffer: "ArrayBuffer" in self2
5025
- };
5026
- if (support.arrayBuffer) {
5027
- var viewClasses = [
5028
- "[object Int8Array]",
5029
- "[object Uint8Array]",
5030
- "[object Uint8ClampedArray]",
5031
- "[object Int16Array]",
5032
- "[object Uint16Array]",
5033
- "[object Int32Array]",
5034
- "[object Uint32Array]",
5035
- "[object Float32Array]",
5036
- "[object Float64Array]"
5037
- ];
5038
- var isDataView = function(obj) {
5039
- return obj && DataView.prototype.isPrototypeOf(obj);
5040
- };
5041
- var isArrayBufferView = ArrayBuffer.isView || function(obj) {
5042
- return obj && viewClasses.indexOf(Object.prototype.toString.call(obj)) > -1;
5043
- };
5044
- }
5045
- function normalizeName(name) {
5046
- if (typeof name !== "string") {
5047
- name = String(name);
5048
- }
5049
- if (/[^a-z0-9\-#$%&'*+.\^_`|~]/i.test(name)) {
5050
- throw new TypeError("Invalid character in header field name");
5051
- }
5052
- return name.toLowerCase();
5053
- }
5054
- function normalizeValue(value) {
5055
- if (typeof value !== "string") {
5056
- value = String(value);
5057
- }
5058
- return value;
5059
- }
5060
- function iteratorFor(items) {
5061
- var iterator = {
5062
- next: function() {
5063
- var value = items.shift();
5064
- return { done: value === void 0, value };
5065
- }
5066
- };
5067
- if (support.iterable) {
5068
- iterator[Symbol.iterator] = function() {
5069
- return iterator;
5070
- };
5071
- }
5072
- return iterator;
5073
- }
5074
- function Headers2(headers) {
5075
- this.map = {};
5076
- if (headers instanceof Headers2) {
5077
- headers.forEach(function(value, name) {
5078
- this.append(name, value);
5079
- }, this);
5080
- } else if (Array.isArray(headers)) {
5081
- headers.forEach(function(header) {
5082
- this.append(header[0], header[1]);
5083
- }, this);
5084
- } else if (headers) {
5085
- Object.getOwnPropertyNames(headers).forEach(function(name) {
5086
- this.append(name, headers[name]);
5087
- }, this);
5088
- }
5089
- }
5090
- Headers2.prototype.append = function(name, value) {
5091
- name = normalizeName(name);
5092
- value = normalizeValue(value);
5093
- var oldValue = this.map[name];
5094
- this.map[name] = oldValue ? oldValue + "," + value : value;
5095
- };
5096
- Headers2.prototype["delete"] = function(name) {
5097
- delete this.map[normalizeName(name)];
5098
- };
5099
- Headers2.prototype.get = function(name) {
5100
- name = normalizeName(name);
5101
- return this.has(name) ? this.map[name] : null;
5102
- };
5103
- Headers2.prototype.has = function(name) {
5104
- return this.map.hasOwnProperty(normalizeName(name));
5105
- };
5106
- Headers2.prototype.set = function(name, value) {
5107
- this.map[normalizeName(name)] = normalizeValue(value);
5108
- };
5109
- Headers2.prototype.forEach = function(callback, thisArg) {
5110
- for (var name in this.map) {
5111
- if (this.map.hasOwnProperty(name)) {
5112
- callback.call(thisArg, this.map[name], name, this);
5113
- }
5114
- }
5115
- };
5116
- Headers2.prototype.keys = function() {
5117
- var items = [];
5118
- this.forEach(function(value, name) {
5119
- items.push(name);
5120
- });
5121
- return iteratorFor(items);
5122
- };
5123
- Headers2.prototype.values = function() {
5124
- var items = [];
5125
- this.forEach(function(value) {
5126
- items.push(value);
5127
- });
5128
- return iteratorFor(items);
5129
- };
5130
- Headers2.prototype.entries = function() {
5131
- var items = [];
5132
- this.forEach(function(value, name) {
5133
- items.push([name, value]);
5134
- });
5135
- return iteratorFor(items);
5136
- };
5137
- if (support.iterable) {
5138
- Headers2.prototype[Symbol.iterator] = Headers2.prototype.entries;
5139
- }
5140
- function consumed(body) {
5141
- if (body.bodyUsed) {
5142
- return Promise.reject(new TypeError("Already read"));
5143
- }
5144
- body.bodyUsed = true;
5145
- }
5146
- function fileReaderReady(reader) {
5147
- return new Promise(function(resolve, reject) {
5148
- reader.onload = function() {
5149
- resolve(reader.result);
5150
- };
5151
- reader.onerror = function() {
5152
- reject(reader.error);
5153
- };
5154
- });
5155
- }
5156
- function readBlobAsArrayBuffer(blob) {
5157
- var reader = new FileReader();
5158
- var promise = fileReaderReady(reader);
5159
- reader.readAsArrayBuffer(blob);
5160
- return promise;
5161
- }
5162
- function readBlobAsText(blob) {
5163
- var reader = new FileReader();
5164
- var promise = fileReaderReady(reader);
5165
- reader.readAsText(blob);
5166
- return promise;
5167
- }
5168
- function readArrayBufferAsText(buf) {
5169
- var view = new Uint8Array(buf);
5170
- var chars2 = new Array(view.length);
5171
- for (var i = 0; i < view.length; i++) {
5172
- chars2[i] = String.fromCharCode(view[i]);
5173
- }
5174
- return chars2.join("");
5175
- }
5176
- function bufferClone(buf) {
5177
- if (buf.slice) {
5178
- return buf.slice(0);
5179
- } else {
5180
- var view = new Uint8Array(buf.byteLength);
5181
- view.set(new Uint8Array(buf));
5182
- return view.buffer;
5183
- }
5184
- }
5185
- function Body() {
5186
- this.bodyUsed = false;
5187
- this._initBody = function(body) {
5188
- this._bodyInit = body;
5189
- if (!body) {
5190
- this._bodyText = "";
5191
- } else if (typeof body === "string") {
5192
- this._bodyText = body;
5193
- } else if (support.blob && Blob.prototype.isPrototypeOf(body)) {
5194
- this._bodyBlob = body;
5195
- } else if (support.formData && FormData.prototype.isPrototypeOf(body)) {
5196
- this._bodyFormData = body;
5197
- } else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) {
5198
- this._bodyText = body.toString();
5199
- } else if (support.arrayBuffer && support.blob && isDataView(body)) {
5200
- this._bodyArrayBuffer = bufferClone(body.buffer);
5201
- this._bodyInit = new Blob([this._bodyArrayBuffer]);
5202
- } else if (support.arrayBuffer && (ArrayBuffer.prototype.isPrototypeOf(body) || isArrayBufferView(body))) {
5203
- this._bodyArrayBuffer = bufferClone(body);
5204
- } else {
5205
- throw new Error("unsupported BodyInit type");
5206
- }
5207
- if (!this.headers.get("content-type")) {
5208
- if (typeof body === "string") {
5209
- this.headers.set("content-type", "text/plain;charset=UTF-8");
5210
- } else if (this._bodyBlob && this._bodyBlob.type) {
5211
- this.headers.set("content-type", this._bodyBlob.type);
5212
- } else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) {
5213
- this.headers.set("content-type", "application/x-www-form-urlencoded;charset=UTF-8");
5214
- }
5215
- }
5216
- };
5217
- if (support.blob) {
5218
- this.blob = function() {
5219
- var rejected = consumed(this);
5220
- if (rejected) {
5221
- return rejected;
5222
- }
5223
- if (this._bodyBlob) {
5224
- return Promise.resolve(this._bodyBlob);
5225
- } else if (this._bodyArrayBuffer) {
5226
- return Promise.resolve(new Blob([this._bodyArrayBuffer]));
5227
- } else if (this._bodyFormData) {
5228
- throw new Error("could not read FormData body as blob");
5229
- } else {
5230
- return Promise.resolve(new Blob([this._bodyText]));
5231
- }
5232
- };
5233
- this.arrayBuffer = function() {
5234
- if (this._bodyArrayBuffer) {
5235
- return consumed(this) || Promise.resolve(this._bodyArrayBuffer);
5236
- } else {
5237
- return this.blob().then(readBlobAsArrayBuffer);
5238
- }
5239
- };
5240
- }
5241
- this.text = function() {
5242
- var rejected = consumed(this);
5243
- if (rejected) {
5244
- return rejected;
5245
- }
5246
- if (this._bodyBlob) {
5247
- return readBlobAsText(this._bodyBlob);
5248
- } else if (this._bodyArrayBuffer) {
5249
- return Promise.resolve(readArrayBufferAsText(this._bodyArrayBuffer));
5250
- } else if (this._bodyFormData) {
5251
- throw new Error("could not read FormData body as text");
5252
- } else {
5253
- return Promise.resolve(this._bodyText);
5254
- }
5255
- };
5256
- if (support.formData) {
5257
- this.formData = function() {
5258
- return this.text().then(decode);
5259
- };
5260
- }
5261
- this.json = function() {
5262
- return this.text().then(JSON.parse);
5263
- };
5264
- return this;
5265
- }
5266
- var methods = ["DELETE", "GET", "HEAD", "OPTIONS", "POST", "PUT"];
5267
- function normalizeMethod(method) {
5268
- var upcased = method.toUpperCase();
5269
- return methods.indexOf(upcased) > -1 ? upcased : method;
5270
- }
5271
- function Request(input, options) {
5272
- options = options || {};
5273
- var body = options.body;
5274
- if (input instanceof Request) {
5275
- if (input.bodyUsed) {
5276
- throw new TypeError("Already read");
5277
- }
5278
- this.url = input.url;
5279
- this.credentials = input.credentials;
5280
- if (!options.headers) {
5281
- this.headers = new Headers2(input.headers);
5282
- }
5283
- this.method = input.method;
5284
- this.mode = input.mode;
5285
- if (!body && input._bodyInit != null) {
5286
- body = input._bodyInit;
5287
- input.bodyUsed = true;
5288
- }
5289
- } else {
5290
- this.url = String(input);
5291
- }
5292
- this.credentials = options.credentials || this.credentials || "omit";
5293
- if (options.headers || !this.headers) {
5294
- this.headers = new Headers2(options.headers);
5295
- }
5296
- this.method = normalizeMethod(options.method || this.method || "GET");
5297
- this.mode = options.mode || this.mode || null;
5298
- this.referrer = null;
5299
- if ((this.method === "GET" || this.method === "HEAD") && body) {
5300
- throw new TypeError("Body not allowed for GET or HEAD requests");
5301
- }
5302
- this._initBody(body);
5303
- }
5304
- Request.prototype.clone = function() {
5305
- return new Request(this, { body: this._bodyInit });
5306
- };
5307
- function decode(body) {
5308
- var form = new FormData();
5309
- body.trim().split("&").forEach(function(bytes) {
5310
- if (bytes) {
5311
- var split = bytes.split("=");
5312
- var name = split.shift().replace(/\+/g, " ");
5313
- var value = split.join("=").replace(/\+/g, " ");
5314
- form.append(decodeURIComponent(name), decodeURIComponent(value));
5315
- }
5316
- });
5317
- return form;
5318
- }
5319
- function parseHeaders(rawHeaders) {
5320
- var headers = new Headers2();
5321
- var preProcessedHeaders = rawHeaders.replace(/\r?\n[\t ]+/g, " ");
5322
- preProcessedHeaders.split(/\r?\n/).forEach(function(line) {
5323
- var parts = line.split(":");
5324
- var key = parts.shift().trim();
5325
- if (key) {
5326
- var value = parts.join(":").trim();
5327
- headers.append(key, value);
5328
- }
5329
- });
5330
- return headers;
5331
- }
5332
- Body.call(Request.prototype);
5333
- function Response2(bodyInit, options) {
5334
- if (!options) {
5335
- options = {};
5336
- }
5337
- this.type = "default";
5338
- this.status = options.status === void 0 ? 200 : options.status;
5339
- this.ok = this.status >= 200 && this.status < 300;
5340
- this.statusText = "statusText" in options ? options.statusText : "OK";
5341
- this.headers = new Headers2(options.headers);
5342
- this.url = options.url || "";
5343
- this._initBody(bodyInit);
5344
- }
5345
- Body.call(Response2.prototype);
5346
- Response2.prototype.clone = function() {
5347
- return new Response2(this._bodyInit, {
5348
- status: this.status,
5349
- statusText: this.statusText,
5350
- headers: new Headers2(this.headers),
5351
- url: this.url
5352
- });
5353
- };
5354
- Response2.error = function() {
5355
- var response = new Response2(null, { status: 0, statusText: "" });
5356
- response.type = "error";
5357
- return response;
5358
- };
5359
- var redirectStatuses = [301, 302, 303, 307, 308];
5360
- Response2.redirect = function(url, status) {
5361
- if (redirectStatuses.indexOf(status) === -1) {
5362
- throw new RangeError("Invalid status code");
5363
- }
5364
- return new Response2(null, { status, headers: { location: url } });
5365
- };
5366
- self2.Headers = Headers2;
5367
- self2.Request = Request;
5368
- self2.Response = Response2;
5369
- self2.fetch = function(input, init2) {
5370
- return new Promise(function(resolve, reject) {
5371
- var request = new Request(input, init2);
5372
- var xhr = new XMLHttpRequest();
5373
- xhr.onload = function() {
5374
- var options = {
5375
- status: xhr.status,
5376
- statusText: xhr.statusText,
5377
- headers: parseHeaders(xhr.getAllResponseHeaders() || "")
5378
- };
5379
- options.url = "responseURL" in xhr ? xhr.responseURL : options.headers.get("X-Request-URL");
5380
- var body = "response" in xhr ? xhr.response : xhr.responseText;
5381
- resolve(new Response2(body, options));
5382
- };
5383
- xhr.onerror = function() {
5384
- reject(new TypeError("Network request failed"));
5385
- };
5386
- xhr.ontimeout = function() {
5387
- reject(new TypeError("Network request failed"));
5388
- };
5389
- xhr.open(request.method, request.url, true);
5390
- if (request.credentials === "include") {
5391
- xhr.withCredentials = true;
5392
- } else if (request.credentials === "omit") {
5393
- xhr.withCredentials = false;
5394
- }
5395
- if ("responseType" in xhr && support.blob) {
5396
- xhr.responseType = "blob";
5397
- }
5398
- request.headers.forEach(function(value, name) {
5399
- xhr.setRequestHeader(name, value);
5400
- });
5401
- xhr.send(typeof request._bodyInit === "undefined" ? null : request._bodyInit);
5402
- });
5403
- };
5404
- self2.fetch.polyfill = true;
5405
- })(typeof self !== "undefined" ? self : this);
5406
- },
5407
- /* 6 */
5408
- /***/
5409
- function(module2, exports2, __webpack_require__) {
5410
- Object.defineProperty(exports2, "__esModule", {
5411
- value: true
5412
- });
5413
- exports2.core = exports2.adyen = exports2.exchange = exports2.priceAlert = exports2.users = exports2.quotes = exports2.redirect = exports2.utils = exports2.purchase = exports2.trip = exports2.search = exports2.collections = exports2.session = exports2.apiRequest = exports2.setUserAuthToken = exports2.setConfig = void 0;
5414
- var _config = __webpack_require__(1);
5415
- var _apiRequest = __webpack_require__(0);
5416
- var apiRequest = _interopRequireWildcard(_apiRequest);
5417
- var _session = __webpack_require__(10);
5418
- var session = _interopRequireWildcard(_session);
5419
- var _collections = __webpack_require__(11);
5420
- var collections = _interopRequireWildcard(_collections);
5421
- var _search = __webpack_require__(12);
5422
- var search = _interopRequireWildcard(_search);
5423
- var _trip = __webpack_require__(13);
5424
- var trip = _interopRequireWildcard(_trip);
5425
- var _purchase = __webpack_require__(14);
5426
- var purchase = _interopRequireWildcard(_purchase);
5427
- var _utils = __webpack_require__(17);
5428
- var utils = _interopRequireWildcard(_utils);
5429
- var _redirect = __webpack_require__(19);
5430
- var redirect = _interopRequireWildcard(_redirect);
5431
- var _quotes = __webpack_require__(20);
5432
- var quotes = _interopRequireWildcard(_quotes);
5433
- var _users = __webpack_require__(21);
5434
- var users = _interopRequireWildcard(_users);
5435
- var _priceAlert = __webpack_require__(22);
5436
- var priceAlert = _interopRequireWildcard(_priceAlert);
5437
- var _exchange = __webpack_require__(23);
5438
- var exchange = _interopRequireWildcard(_exchange);
5439
- var _adyen = __webpack_require__(24);
5440
- var adyen = _interopRequireWildcard(_adyen);
5441
- var _core = __webpack_require__(25);
5442
- var core = _interopRequireWildcard(_core);
5443
- function _interopRequireWildcard(obj) {
5444
- if (obj && obj.__esModule) {
5445
- return obj;
5446
- } else {
5447
- var newObj = {};
5448
- if (obj != null) {
5449
- for (var key in obj) {
5450
- if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key];
5451
- }
5452
- }
5453
- newObj.default = obj;
5454
- return newObj;
5455
- }
5456
- }
5457
- exports2.setConfig = _config.setConfig;
5458
- exports2.setUserAuthToken = _config.setUserAuthToken;
5459
- exports2.apiRequest = apiRequest;
5460
- exports2.session = session;
5461
- exports2.collections = collections;
5462
- exports2.search = search;
5463
- exports2.trip = trip;
5464
- exports2.purchase = purchase;
5465
- exports2.utils = utils;
5466
- exports2.redirect = redirect;
5467
- exports2.quotes = quotes;
5468
- exports2.users = users;
5469
- exports2.priceAlert = priceAlert;
5470
- exports2.exchange = exchange;
5471
- exports2.adyen = adyen;
5472
- exports2.core = core;
5473
- },
5474
- /* 7 */
5475
- /***/
5476
- function(module2, exports2, __webpack_require__) {
5477
- Object.defineProperty(exports2, "__esModule", {
5478
- value: true
5479
- });
5480
- function _classCallCheck(instance, Constructor) {
5481
- if (!(instance instanceof Constructor)) {
5482
- throw new TypeError("Cannot call a class as a function");
5483
- }
5484
- }
5485
- function _possibleConstructorReturn(self2, call) {
5486
- if (!self2) {
5487
- throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
5488
- }
5489
- return call && (typeof call === "object" || typeof call === "function") ? call : self2;
5490
- }
5491
- function _inherits(subClass, superClass) {
5492
- if (typeof superClass !== "function" && superClass !== null) {
5493
- throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
5494
- }
5495
- subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } });
5496
- if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
5497
- }
5498
- var NetworkError = function(_Error) {
5499
- _inherits(NetworkError2, _Error);
5500
- function NetworkError2() {
5501
- var code = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : -100;
5502
- var message = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "Unknown error";
5503
- _classCallCheck(this, NetworkError2);
5504
- var _this = _possibleConstructorReturn(this, (NetworkError2.__proto__ || Object.getPrototypeOf(NetworkError2)).call(this, message));
5505
- _this.code = code;
5506
- _this.stack = new Error().stack;
5507
- return _this;
5508
- }
5509
- return NetworkError2;
5510
- }(Error);
5511
- exports2.default = NetworkError;
5512
- },
5513
- /* 8 */
5514
- /***/
5515
- function(module2, exports2, __webpack_require__) {
5516
- Object.defineProperty(exports2, "__esModule", {
5517
- value: true
5518
- });
5519
- var _extends = Object.assign || function(target) {
5520
- for (var i = 1; i < arguments.length; i++) {
5521
- var source = arguments[i];
5522
- for (var key in source) {
5523
- if (Object.prototype.hasOwnProperty.call(source, key)) {
5524
- target[key] = source[key];
5525
- }
5526
- }
5527
- }
5528
- return target;
5529
- };
5530
- var authorizationErrors = {
5531
- // UNAUTHORIZED
5532
- 1: {
5533
- code: 200,
5534
- message: "Operación no autorizada"
5535
- }
5536
- };
5537
- var generalErrors = {
5538
- // INCORRECT_PARAMS
5539
- 3: {
5540
- code: 300,
5541
- message: "Parámetros incorrectos"
5542
- },
5543
- // INCORRECT_DATE
5544
- 7: {
5545
- code: 301,
5546
- message: "Fecha inválida"
5547
- }
5548
- };
5549
- var tripErrors = {
5550
- // NONEXISTENT_TRIP
5551
- 10: {
5552
- code: 400,
5553
- message: "No existe el viaje"
5554
- },
5555
- // journey_key_not_found
5556
- 20: {
5557
- code: 60,
5558
- message: "No se encontró el viaje"
5559
- },
5560
- // sold_out_fare_code
5561
- 21: {
5562
- code: 60,
5563
- message: "Tarifa no disponible"
5564
- },
5565
- // unavailable_fare_code
5566
- 22: {
5567
- code: 60,
5568
- message: "Tarifa no disponible"
5569
- }
5570
- };
5571
- var discountCodeErrors = function discountCodeErrors2(message) {
5572
- return {
5573
- // INVALID_DISCOUNT
5574
- 11: {
5575
- code: 500,
5576
- message
5577
- },
5578
- //EXPIRED_DISCOUNT
5579
- 12: {
5580
- code: 501,
5581
- message
5582
- }
5583
- };
5584
- };
5585
- var ticketErrors = {
5586
- // unavailable_student
5587
- 23: {
5588
- code: 60,
5589
- message: "Estudiante no disponible"
5590
- },
5591
- // unavailable_teacher
5592
- 24: {
5593
- code: 60,
5594
- message: "Profesor no disponible"
5595
- },
5596
- // unavailable_minor
5597
- 25: {
5598
- code: 60,
5599
- message: "Menor no disponible"
5600
- },
5601
- // unavailable_special
5602
- 26: {
5603
- code: 60,
5604
- message: "Capacidades diferentes no disponible"
5605
- },
5606
- // unavailable_older
5607
- 27: {
5608
- code: 60,
5609
- message: "INSEN no disponible"
5610
- },
5611
- // unavailable_general
5612
- 28: {
5613
- code: 60,
5614
- message: "General no disponible"
5615
- },
5616
- // unavailable_unknown
5617
- 29: {
5618
- code: 60,
5619
- message: "Error desconocido"
5620
- }
5621
- };
5622
- var exchange = function exchange2(message) {
5623
- return {
5624
- 30: {
5625
- code: 30,
5626
- message
5627
- }
5628
- };
5629
- };
5630
- var paymentErrors = {
5631
- 50: {
5632
- code: 50,
5633
- message: "Unknow Error"
5634
- }
5635
- };
5636
- var apiErrors = exports2.apiErrors = function apiErrors2(message) {
5637
- return _extends({}, authorizationErrors, generalErrors, tripErrors, discountCodeErrors(message), ticketErrors, paymentErrors, exchange(message));
5638
- };
5639
- exports2.default = apiErrors;
5640
- },
5641
- /* 9 */
5642
- /***/
5643
- function(module2, exports2, __webpack_require__) {
5644
- Object.defineProperty(exports2, "__esModule", {
5645
- value: true
5646
- });
5647
- var _createClass = /* @__PURE__ */ function() {
5648
- function defineProperties(target, props) {
5649
- for (var i = 0; i < props.length; i++) {
5650
- var descriptor = props[i];
5651
- descriptor.enumerable = descriptor.enumerable || false;
5652
- descriptor.configurable = true;
5653
- if ("value" in descriptor) descriptor.writable = true;
5654
- Object.defineProperty(target, descriptor.key, descriptor);
5655
- }
5656
- }
5657
- return function(Constructor, protoProps, staticProps) {
5658
- if (protoProps) defineProperties(Constructor.prototype, protoProps);
5659
- if (staticProps) defineProperties(Constructor, staticProps);
5660
- return Constructor;
5661
- };
5662
- }();
5663
- var _request = __webpack_require__(2);
5664
- var request = _interopRequireWildcard(_request);
5665
- function _interopRequireWildcard(obj) {
5666
- if (obj && obj.__esModule) {
5667
- return obj;
5668
- } else {
5669
- var newObj = {};
5670
- if (obj != null) {
5671
- for (var key in obj) {
5672
- if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key];
5673
- }
5674
- }
5675
- newObj.default = obj;
5676
- return newObj;
5677
- }
5678
- }
5679
- function _classCallCheck(instance, Constructor) {
5680
- if (!(instance instanceof Constructor)) {
5681
- throw new TypeError("Cannot call a class as a function");
5682
- }
5683
- }
5684
- var Poll = function() {
5685
- function Poll2(_ref) {
5686
- var url = _ref.url, watch = _ref.watch, expect = _ref.expect, _ref$maxRetries = _ref.maxRetries, maxRetries = _ref$maxRetries === void 0 ? 30 : _ref$maxRetries, _ref$interval = _ref.interval, interval = _ref$interval === void 0 ? 2e3 : _ref$interval, _ref$eachCall = _ref.eachCall, eachCall = _ref$eachCall === void 0 ? null : _ref$eachCall;
5687
- _classCallCheck(this, Poll2);
5688
- this.url = url;
5689
- this.watch = watch;
5690
- this.expect = expect instanceof Array ? expect : [expect];
5691
- this.interval = interval;
5692
- this.maxRetries = maxRetries;
5693
- this.eachCall = eachCall && eachCall.bind(this);
5694
- this.aborted = false;
5695
- this.timers = [];
5696
- this.execute = this.execute.bind(this);
5697
- this.executeEachCall = this.executeEachCall.bind(this);
5698
- }
5699
- _createClass(Poll2, [{
5700
- key: "start",
5701
- value: function start() {
5702
- return this.execute(this.maxRetries);
5703
- }
5704
- }, {
5705
- key: "abort",
5706
- value: function abort() {
5707
- this.aborted = true;
5708
- }
5709
- }, {
5710
- key: "execute",
5711
- value: function execute(retries) {
5712
- var _this = this;
5713
- var onRequestSuccess = function onRequestSuccess2(payload) {
5714
- if (_this.expect.includes(payload[_this.watch]) || retries === 1 || _this.aborted) {
5715
- var status = payload[_this.watch];
5716
- if (retries === 1) {
5717
- status = "retries_exceeded";
5718
- } else if (_this.aborted) {
5719
- status = "aborted";
5720
- }
5721
- _this.timers.forEach(clearInterval);
5722
- _this.executeEachCall(status, payload);
5723
- } else if (payload[_this.watch] === "failed") {
5724
- _this.timers.forEach(clearInterval);
5725
- _this.executeEachCall("failed", payload);
5726
- } else {
5727
- _this.executeEachCall("pending", payload);
5728
- var timer = window.setTimeout(_this.execute, _this.interval, retries - 1);
5729
- _this.timers.push(timer);
5730
- }
5731
- };
5732
- var onRequestError = function onRequestError2(err) {
5733
- return _this.executeEachCall("error", err);
5734
- };
5735
- return request.get(this.url, {}, onRequestError).then(onRequestSuccess);
5736
- }
5737
- }, {
5738
- key: "executeEachCall",
5739
- value: function executeEachCall(status, payload) {
5740
- if (this.eachCall instanceof Function) {
5741
- if (this.eachCall({ status, payload })) {
5742
- this.abort();
5743
- }
5744
- }
5745
- }
5746
- }]);
5747
- return Poll2;
5748
- }();
5749
- exports2.default = Poll;
5750
- },
5751
- /* 10 */
5752
- /***/
5753
- function(module2, exports2, __webpack_require__) {
5754
- Object.defineProperty(exports2, "__esModule", {
5755
- value: true
5756
- });
5757
- exports2.get = get;
5758
- exports2.agency = agency;
5759
- var _apiRequest = __webpack_require__(0);
5760
- var apiRequest = _interopRequireWildcard(_apiRequest);
5761
- function _interopRequireWildcard(obj) {
5762
- if (obj && obj.__esModule) {
5763
- return obj;
5764
- } else {
5765
- var newObj = {};
5766
- if (obj != null) {
5767
- for (var key in obj) {
5768
- if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key];
5769
- }
5770
- }
5771
- newObj.default = obj;
5772
- return newObj;
5773
- }
5774
- }
5775
- function get() {
5776
- return new Promise(function(resolve, reject) {
5777
- apiRequest.get("session", { apiVersion: "v1" }).then(function(session) {
5778
- return resolve(session);
5779
- }).catch(function(_ref) {
5780
- var _ref$code = _ref.code, code = _ref$code === void 0 ? -100 : _ref$code, _ref$message = _ref.message, message = _ref$message === void 0 ? "Unknown error" : _ref$message;
5781
- return reject({ code, message });
5782
- });
5783
- });
5784
- }
5785
- function agency() {
5786
- return new Promise(function(resolve, reject) {
5787
- apiRequest.get("get_agency").then(function(agency2) {
5788
- return resolve(agency2);
5789
- }).catch(function(_ref2) {
5790
- var _ref2$code = _ref2.code, code = _ref2$code === void 0 ? -100 : _ref2$code, _ref2$message = _ref2.message, message = _ref2$message === void 0 ? "Unknown error" : _ref2$message;
5791
- return reject({ code, message });
5792
- });
5793
- });
5794
- }
5795
- },
5796
- /* 11 */
5797
- /***/
5798
- function(module2, exports2, __webpack_require__) {
5799
- Object.defineProperty(exports2, "__esModule", {
5800
- value: true
5801
- });
5802
- exports2.getCountries = getCountries;
5803
- exports2.getPlaces = getPlaces;
5804
- var _apiRequest = __webpack_require__(0);
5805
- var apiRequest = _interopRequireWildcard(_apiRequest);
5806
- function _interopRequireWildcard(obj) {
5807
- if (obj && obj.__esModule) {
5808
- return obj;
5809
- } else {
5810
- var newObj = {};
5811
- if (obj != null) {
5812
- for (var key in obj) {
5813
- if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key];
5814
- }
5815
- }
5816
- newObj.default = obj;
5817
- return newObj;
5818
- }
5819
- }
5820
- function getCountries() {
5821
- var options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
5822
- var _options$prefetch = options.prefetch, prefetch = _options$prefetch === void 0 ? true : _options$prefetch, _options$q = options.q, q = _options$q === void 0 ? "" : _options$q;
5823
- var queryParams = { prefetch, q };
5824
- return new Promise(function(resolve, reject) {
5825
- apiRequest.get("countries", { queryParams }).then(function(countries) {
5826
- return resolve(countries);
5827
- }).catch(function(_ref) {
5828
- var _ref$code = _ref.code, code = _ref$code === void 0 ? -100 : _ref$code, _ref$message = _ref.message, message = _ref$message === void 0 ? "Unknown error" : _ref$message;
5829
- return reject({ code, message });
5830
- });
5831
- });
5832
- }
5833
- function getPlaces(q, from) {
5834
- var queryParams = !q ? { prefetch: true } : { q, from };
5835
- return new Promise(function(resolve, reject) {
5836
- apiRequest.get("places", { queryParams }).then(function(places) {
5837
- return resolve(places);
5838
- }).catch(function(_ref2) {
5839
- var _ref2$code = _ref2.code, code = _ref2$code === void 0 ? -100 : _ref2$code, _ref2$message = _ref2.message, message = _ref2$message === void 0 ? "Unknown error" : _ref2$message;
5840
- return reject({ code, message });
5841
- });
5842
- });
5843
- }
5844
- },
5845
- /* 12 */
5846
- /***/
5847
- function(module2, exports2, __webpack_require__) {
5848
- Object.defineProperty(exports2, "__esModule", {
5849
- value: true
5850
- });
5851
- var _slicedToArray = /* @__PURE__ */ function() {
5852
- function sliceIterator(arr, i) {
5853
- var _arr = [];
5854
- var _n = true;
5855
- var _d = false;
5856
- var _e = void 0;
5857
- try {
5858
- for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
5859
- _arr.push(_s.value);
5860
- if (i && _arr.length === i) break;
5861
- }
5862
- } catch (err) {
5863
- _d = true;
5864
- _e = err;
5865
- } finally {
5866
- try {
5867
- if (!_n && _i["return"]) _i["return"]();
5868
- } finally {
5869
- if (_d) throw _e;
5870
- }
5871
- }
5872
- return _arr;
5873
- }
5874
- return function(arr, i) {
5875
- if (Array.isArray(arr)) {
5876
- return arr;
5877
- } else if (Symbol.iterator in Object(arr)) {
5878
- return sliceIterator(arr, i);
5879
- } else {
5880
- throw new TypeError("Invalid attempt to destructure non-iterable instance");
5881
- }
5882
- };
5883
- }();
5884
- var _extends = Object.assign || function(target) {
5885
- for (var i = 1; i < arguments.length; i++) {
5886
- var source = arguments[i];
5887
- for (var key in source) {
5888
- if (Object.prototype.hasOwnProperty.call(source, key)) {
5889
- target[key] = source[key];
5890
- }
5891
- }
5892
- }
5893
- return target;
5894
- };
5895
- exports2.create = create;
5896
- exports2.stopSearch = stopSearch;
5897
- exports2.stopAllSearches = stopAllSearches;
5898
- exports2.get = get;
5899
- exports2.validateExternalCoupon = validateExternalCoupon;
5900
- exports2.walletSearchDiscount = walletSearchDiscount;
5901
- var _apiRequest = __webpack_require__(0);
5902
- var apiRequest = _interopRequireWildcard(_apiRequest);
5903
- function _interopRequireWildcard(obj) {
5904
- if (obj && obj.__esModule) {
5905
- return obj;
5906
- } else {
5907
- var newObj = {};
5908
- if (obj != null) {
5909
- for (var key in obj) {
5910
- if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key];
5911
- }
5912
- }
5913
- newObj.default = obj;
5914
- return newObj;
5915
- }
5916
- }
5917
- var currentPolls = {};
5918
- function startPolls(payload, polling) {
5919
- var _payload$search = payload.search, id = _payload$search.id, typeOfTransport = _payload$search.type_of_transport;
5920
- var bus = typeOfTransport.bus, flights = typeOfTransport.flights, mix = typeOfTransport.mix;
5921
- var _polling$initBuses = polling.initBuses, initBuses = _polling$initBuses === void 0 ? true : _polling$initBuses, _polling$initFlights = polling.initFlights, initFlights = _polling$initFlights === void 0 ? true : _polling$initFlights, _polling$initRides = polling.initRides, initRides = _polling$initRides === void 0 ? false : _polling$initRides, _polling$initMix = polling.initMix, initMix = _polling$initMix === void 0 ? true : _polling$initMix, onReceiveBuses = polling.onReceiveBuses, onReceiveFlights = polling.onReceiveFlights, onReceiveRides = polling.onReceiveRides, onReceiveMixed = polling.onReceiveMixed;
5922
- var pollOptions = _extends({
5923
- watch: "state",
5924
- expect: "finished"
5925
- }, polling.options || {});
5926
- var polls = [];
5927
- if (bus && bus.active && initBuses) {
5928
- var poll = apiRequest.poll("search/" + id + "?type=bus", onReceiveBuses, pollOptions);
5929
- poll.start();
5930
- polls.push(poll);
5931
- } else if (onReceiveBuses) {
5932
- onReceiveBuses({ status: "deactivated" });
5933
- }
5934
- if (flights && flights.active && initFlights) {
5935
- var _poll = apiRequest.poll("search/" + id + "?type=plane", onReceiveFlights, pollOptions);
5936
- _poll.start();
5937
- polls.push(_poll);
5938
- } else if (onReceiveFlights) {
5939
- onReceiveFlights({ status: "deactivated" });
5940
- }
5941
- if (mix && mix.active && initMix) {
5942
- var _poll2 = apiRequest.poll("search/" + id + "?type=mix", onReceiveMixed, pollOptions);
5943
- _poll2.start();
5944
- polls.push(_poll2);
5945
- } else if (onReceiveMixed) {
5946
- onReceiveMixed({ status: "deactivated" });
5947
- }
5948
- if (initRides) {
5949
- var _poll3 = apiRequest.poll("search/" + id + "?type=car", onReceiveRides, pollOptions);
5950
- _poll3.start();
5951
- polls.push(_poll3);
5952
- }
5953
- currentPolls[id] = polls;
5954
- return payload;
5955
- }
5956
- function create(params, polling) {
5957
- var onCreateSuccess = function onCreateSuccess2(search) {
5958
- return startPolls(search, polling);
5959
- };
5960
- return apiRequest.post("search", params).then(onCreateSuccess);
5961
- }
5962
- function stopSearch(searchId) {
5963
- if (!currentPolls || !searchId || !currentPolls[searchId]) {
5964
- return false;
5965
- }
5966
- currentPolls[searchId].forEach(function(p2) {
5967
- return p2.abort();
5968
- });
5969
- Reflect.deleteProperty(currentPolls, searchId);
5970
- return true;
5971
- }
5972
- function stopAllSearches() {
5973
- if (!currentPolls) {
5974
- return false;
5975
- }
5976
- Object.entries(currentPolls).forEach(function(_ref) {
5977
- var _ref2 = _slicedToArray(_ref, 2);
5978
- _ref2[0];
5979
- var polls = _ref2[1];
5980
- return polls.forEach(function(p2) {
5981
- return p2.abort();
5982
- });
5983
- });
5984
- currentPolls = {};
5985
- return true;
5986
- }
5987
- function get(id, polling) {
5988
- return new Promise(function(resolve, reject) {
5989
- apiRequest.get("search/" + id + "/info").then(function(search) {
5990
- return resolve(startPolls(search, polling));
5991
- }).catch(function(_ref3) {
5992
- var _ref3$code = _ref3.code, code = _ref3$code === void 0 ? -100 : _ref3$code, _ref3$message = _ref3.message, message = _ref3$message === void 0 ? "Unknown error" : _ref3$message;
5993
- return reject({ code, message });
5994
- });
5995
- });
5996
- }
5997
- function validateExternalCoupon(couponCode) {
5998
- var params = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
5999
- var query = new URLSearchParams(params).toString();
6000
- var queryParams = query ? "?" + query : "";
6001
- return new Promise(function(resolve, reject) {
6002
- apiRequest.get("search/discounts/validate_external_coupon/" + couponCode + queryParams).then(function(response) {
6003
- return resolve(response);
6004
- }).catch(function(_ref4) {
6005
- var _ref4$code = _ref4.code, code = _ref4$code === void 0 ? -100 : _ref4$code, _ref4$message = _ref4.message, message = _ref4$message === void 0 ? "Unknown error" : _ref4$message;
6006
- return reject({ code, message });
6007
- });
6008
- });
6009
- }
6010
- function walletSearchDiscount(wallet) {
6011
- var params = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
6012
- var query = new URLSearchParams(params).toString();
6013
- var queryParams = query ? "?" + query : "";
6014
- return new Promise(function(resolve, reject) {
6015
- apiRequest.get(wallet + "/discounts" + queryParams).then(function(response) {
6016
- return resolve(response);
6017
- }).catch(function(_ref5) {
6018
- var _ref5$code = _ref5.code, code = _ref5$code === void 0 ? -100 : _ref5$code, _ref5$message = _ref5.message, message = _ref5$message === void 0 ? "Unknown error" : _ref5$message;
6019
- return reject({ code, message });
6020
- });
6021
- });
6022
- }
6023
- },
6024
- /* 13 */
6025
- /***/
6026
- function(module2, exports2, __webpack_require__) {
6027
- Object.defineProperty(exports2, "__esModule", {
6028
- value: true
6029
- });
6030
- var _extends = Object.assign || function(target) {
6031
- for (var i = 1; i < arguments.length; i++) {
6032
- var source = arguments[i];
6033
- for (var key in source) {
6034
- if (Object.prototype.hasOwnProperty.call(source, key)) {
6035
- target[key] = source[key];
6036
- }
6037
- }
6038
- }
6039
- return target;
6040
- };
6041
- exports2.get = get;
6042
- exports2.getWithBus = getWithBus;
6043
- var _apiRequest = __webpack_require__(0);
6044
- var apiRequest = _interopRequireWildcard(_apiRequest);
6045
- function _interopRequireWildcard(obj) {
6046
- if (obj && obj.__esModule) {
6047
- return obj;
6048
- } else {
6049
- var newObj = {};
6050
- if (obj != null) {
6051
- for (var key in obj) {
6052
- if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key];
6053
- }
6054
- }
6055
- newObj.default = obj;
6056
- return newObj;
6057
- }
6058
- }
6059
- function startPoll(slug, payload, polling) {
6060
- var id = payload.id;
6061
- var _polling$init = polling.init, init2 = _polling$init === void 0 ? true : _polling$init, _polling$options = polling.options, options = _polling$options === void 0 ? {} : _polling$options, onReceiveTrip = polling.onReceiveTrip;
6062
- var pollOptions = _extends({
6063
- watch: "state",
6064
- expect: "finished"
6065
- }, options);
6066
- var poll = void 0;
6067
- var startedPoll = void 0;
6068
- if (init2) {
6069
- poll = apiRequest.poll("trips/" + slug + "/details_requests/" + id, onReceiveTrip, pollOptions);
6070
- startedPoll = poll.start();
6071
- }
6072
- return {
6073
- payload,
6074
- polls: {
6075
- trip: startedPoll,
6076
- abort: function abort() {
6077
- return poll.abort();
6078
- }
6079
- }
6080
- };
6081
- }
6082
- function encodePassengers(passengers) {
6083
- var encoded = [];
6084
- Object.keys(passengers).forEach(function(key) {
6085
- var quantity = passengers[key];
6086
- if (quantity) {
6087
- encoded.push(key + "=" + quantity);
6088
- }
6089
- });
6090
- return encoded.join("&");
6091
- }
6092
- function get(id) {
6093
- var passengers = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
6094
- return new Promise(function(resolve, reject) {
6095
- apiRequest.get("trips/" + id + "?" + encodePassengers(passengers)).then(function(trip) {
6096
- return resolve(trip);
6097
- }).catch(function(_ref) {
6098
- var _ref$code = _ref.code, code = _ref$code === void 0 ? -100 : _ref$code, _ref$message = _ref.message, message = _ref$message === void 0 ? "Unknown error" : _ref$message;
6099
- return reject({ code, message });
6100
- });
6101
- });
6102
- }
6103
- function getWithBus(id) {
6104
- var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
6105
- var polling = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
6106
- var postPayload = _extends({
6107
- with_pricing: true
6108
- }, options);
6109
- return new Promise(function(resolve, reject) {
6110
- apiRequest.post("trips/" + id + "/details_requests", postPayload).then(function(trip) {
6111
- return resolve(startPoll(id, trip, polling));
6112
- }).catch(function(_ref2) {
6113
- var _ref2$code = _ref2.code, code = _ref2$code === void 0 ? -100 : _ref2$code, _ref2$message = _ref2.message, message = _ref2$message === void 0 ? "Unknown error" : _ref2$message;
6114
- return reject({ code, message });
6115
- });
6116
- });
6117
- }
6118
- },
6119
- /* 14 */
6120
- /***/
6121
- function(module2, exports2, __webpack_require__) {
6122
- Object.defineProperty(exports2, "__esModule", {
6123
- value: true
6124
- });
6125
- exports2.startTicketsPoll = void 0;
6126
- var _extends = Object.assign || function(target) {
6127
- for (var i = 1; i < arguments.length; i++) {
6128
- var source = arguments[i];
6129
- for (var key in source) {
6130
- if (Object.prototype.hasOwnProperty.call(source, key)) {
6131
- target[key] = source[key];
6132
- }
6133
- }
6134
- }
6135
- return target;
6136
- };
6137
- exports2.startPurchasePoll = startPurchasePoll;
6138
- exports2.create = create;
6139
- exports2.get = get;
6140
- exports2.update = update;
6141
- exports2.createPassengers = createPassengers;
6142
- exports2.updatePassengers = updatePassengers;
6143
- exports2.deletePassenger = deletePassenger;
6144
- exports2.createTickets = createTickets;
6145
- exports2.applyDiscountCode = applyDiscountCode;
6146
- exports2.removeDiscountCode = removeDiscountCode;
6147
- exports2.createPayment = createPayment;
6148
- exports2.getPayment = getPayment;
6149
- exports2.sendEmail = sendEmail;
6150
- exports2.confirmPaypalPayment = confirmPaypalPayment;
6151
- exports2.updateWallet = updateWallet;
6152
- exports2.verifyPhoneNumber = verifyPhoneNumber;
6153
- exports2.verifySmsCode = verifySmsCode;
6154
- exports2.unlockSeats = unlockSeats;
6155
- exports2.generateOTP = generateOTP;
6156
- exports2.validateOTP = validateOTP;
6157
- exports2.membershipDiscountPayment = membershipDiscountPayment;
6158
- exports2.membershipDiscountPaymentDelete = membershipDiscountPaymentDelete;
6159
- exports2.downloadTickets = downloadTickets;
6160
- exports2.downloadPurchasesHistory = downloadPurchasesHistory;
6161
- exports2.increaseExpiration = increaseExpiration;
6162
- var _apiRequest = __webpack_require__(0);
6163
- var apiRequest = _interopRequireWildcard(_apiRequest);
6164
- var _payment = __webpack_require__(15);
6165
- var _tickets = __webpack_require__(16);
6166
- function _interopRequireWildcard(obj) {
6167
- if (obj && obj.__esModule) {
6168
- return obj;
6169
- } else {
6170
- var newObj = {};
6171
- if (obj != null) {
6172
- for (var key in obj) {
6173
- if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key];
6174
- }
6175
- }
6176
- newObj.default = obj;
6177
- return newObj;
6178
- }
6179
- }
6180
- var PURCHASE = "purchases";
6181
- var WALLET = "wallet_movements";
6182
- var WALLET_CANCEL = "cancel";
6183
- var PASSENGER_REQUESTS = "passenger_requests";
6184
- var PASSENGER_REQUESTS_UPDATE = PASSENGER_REQUESTS + "/update";
6185
- var TICKET_REQUESTS = "ticket_requests";
6186
- var TICKET_RESEND = "tickets/resend";
6187
- var DISCOUNTS = "discounts";
6188
- var CANCEL = "cancel";
6189
- var PAYMENT_DISCOUNT = "payment_discounts";
6190
- var PAYMENTS = "payments";
6191
- var PURCHASES_HISTORY = "purchase_history/search";
6192
- var EXTEND_EXPIRE_AT = "session-extension";
6193
- function startPurchasePoll(token, polling) {
6194
- var _polling$init = polling.init, init2 = _polling$init === void 0 ? true : _polling$init, onReceivePurchase = polling.onReceivePurchase;
6195
- var endpoint = "purchases/" + token;
6196
- var pollOptions = _extends({
6197
- watch: "state",
6198
- expect: ["completed"]
6199
- }, polling.options || {});
6200
- var poll = void 0;
6201
- var startedPoll = void 0;
6202
- if (init2) {
6203
- poll = apiRequest.poll(endpoint, onReceivePurchase, pollOptions);
6204
- startedPoll = poll.start();
6205
- }
6206
- return {
6207
- polls: {
6208
- payment: startedPoll,
6209
- abort: function abort() {
6210
- return poll.abort();
6211
- }
6212
- }
6213
- };
6214
- }
6215
- function create(params) {
6216
- return new Promise(function(resolve, reject) {
6217
- apiRequest.post(PURCHASE, params).then(function(purchase) {
6218
- return resolve(purchase);
6219
- }).catch(function(_ref) {
6220
- var _ref$code = _ref.code, code = _ref$code === void 0 ? -100 : _ref$code, _ref$message = _ref.message, message = _ref$message === void 0 ? "Unknown error" : _ref$message;
6221
- return reject({ code, message });
6222
- });
6223
- });
6224
- }
6225
- function get(id, queryParams, polling) {
6226
- if (polling) {
6227
- return startPurchasePoll(id, polling);
6228
- }
6229
- return new Promise(function(resolve, reject) {
6230
- apiRequest.get(PURCHASE + "/" + id, { queryParams }).then(function(purchase) {
6231
- return resolve(purchase);
6232
- }).catch(function(_ref2) {
6233
- var _ref2$code = _ref2.code, code = _ref2$code === void 0 ? -100 : _ref2$code, _ref2$message = _ref2.message, message = _ref2$message === void 0 ? "Unknown error" : _ref2$message;
6234
- return reject({ code, message });
6235
- });
6236
- });
6237
- }
6238
- function update(id, params) {
6239
- return new Promise(function(resolve, reject) {
6240
- apiRequest.put(PURCHASE + "/" + id, params).then(function(purchase) {
6241
- return resolve(purchase);
6242
- }).catch(function(_ref3) {
6243
- var _ref3$code = _ref3.code, code = _ref3$code === void 0 ? -100 : _ref3$code, _ref3$message = _ref3.message, message = _ref3$message === void 0 ? "Unknown error" : _ref3$message;
6244
- return reject({ code, message });
6245
- });
6246
- });
6247
- }
6248
- function createPassengers(id, passengers) {
6249
- return new Promise(function(resolve, reject) {
6250
- apiRequest.post(PURCHASE + "/" + id + "/" + PASSENGER_REQUESTS, { passengers }).then(function(passengers2) {
6251
- return resolve(passengers2);
6252
- }).catch(function(_ref4) {
6253
- var _ref4$code = _ref4.code, code = _ref4$code === void 0 ? -100 : _ref4$code, _ref4$message = _ref4.message, message = _ref4$message === void 0 ? "Unknown error" : _ref4$message;
6254
- return reject({ code, message });
6255
- });
6256
- });
6257
- }
6258
- function updatePassengers(id, passengers) {
6259
- return new Promise(function(resolve, reject) {
6260
- apiRequest.put(PURCHASE + "/" + id + "/" + PASSENGER_REQUESTS_UPDATE, { passengers }).then(function(passengers2) {
6261
- return resolve(passengers2);
6262
- }).catch(function(_ref5) {
6263
- var _ref5$code = _ref5.code, code = _ref5$code === void 0 ? -100 : _ref5$code, _ref5$message = _ref5.message, message = _ref5$message === void 0 ? "Unknown error" : _ref5$message;
6264
- return reject({ code, message });
6265
- });
6266
- });
6267
- }
6268
- function deletePassenger(id, passengerId) {
6269
- return new Promise(function(resolve, reject) {
6270
- apiRequest.deleteMethod(PURCHASE + "/" + id + "/" + PASSENGER_REQUESTS + "/" + passengerId).then(function(response) {
6271
- return resolve(response);
6272
- }).catch(function(_ref6) {
6273
- var _ref6$code = _ref6.code, code = _ref6$code === void 0 ? -100 : _ref6$code, _ref6$message = _ref6.message, message = _ref6$message === void 0 ? "Unknown error" : _ref6$message;
6274
- return reject({ code, message });
6275
- });
6276
- });
6277
- }
6278
- function createTickets(id, params) {
6279
- var polling = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
6280
- return new Promise(function(resolve, reject) {
6281
- apiRequest.post(PURCHASE + "/" + id + "/" + TICKET_REQUESTS, params).then(function(tickets) {
6282
- return resolve((0, _tickets.startTicketsPoll)(id, tickets, polling));
6283
- }).catch(function(_ref7) {
6284
- var _ref7$code = _ref7.code, code = _ref7$code === void 0 ? -100 : _ref7$code, _ref7$message = _ref7.message, message = _ref7$message === void 0 ? "Unknown error" : _ref7$message;
6285
- return reject({ code, message });
6286
- });
6287
- });
6288
- }
6289
- function applyDiscountCode(id, code) {
6290
- return new Promise(function(resolve, reject) {
6291
- apiRequest.post(PURCHASE + "/" + id + "/" + DISCOUNTS, { code }, { apiVersion: "v2" }).then(function() {
6292
- return get(id);
6293
- }).then(function(purchase) {
6294
- return resolve(purchase);
6295
- }).catch(function(_ref8) {
6296
- var _ref8$code = _ref8.code, code2 = _ref8$code === void 0 ? -100 : _ref8$code, _ref8$message = _ref8.message, message = _ref8$message === void 0 ? "Unknown error" : _ref8$message;
6297
- return reject({ code: code2, message });
6298
- });
6299
- });
6300
- }
6301
- function removeDiscountCode(id) {
6302
- return new Promise(function(resolve, reject) {
6303
- apiRequest.post(PURCHASE + "/" + id + "/" + DISCOUNTS + "/" + CANCEL, { apiVersion: "v2" }).then(function() {
6304
- return get(id);
6305
- }).then(function(purchase) {
6306
- return resolve(purchase);
6307
- }).catch(function(_ref9) {
6308
- var _ref9$code = _ref9.code, code = _ref9$code === void 0 ? -100 : _ref9$code, _ref9$message = _ref9.message, message = _ref9$message === void 0 ? "Unknown error" : _ref9$message;
6309
- return reject({ code, message });
6310
- });
6311
- });
6312
- }
6313
- function createPayment(id, params) {
6314
- var polling = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
6315
- return new Promise(function(resolve, reject) {
6316
- apiRequest.post(PURCHASE + "/" + id + "/" + PAYMENTS, params).then(function(payment) {
6317
- return resolve((0, _payment.startPaymentPoll)(id, payment, polling));
6318
- }).catch(function(_ref10) {
6319
- var _ref10$code = _ref10.code, code = _ref10$code === void 0 ? -100 : _ref10$code, _ref10$message = _ref10.message, message = _ref10$message === void 0 ? "Unknown error" : _ref10$message;
6320
- return reject({ code, message });
6321
- });
6322
- });
6323
- }
6324
- function getPayment(purchaseToken, paymentId, polling) {
6325
- if (polling) {
6326
- return (0, _payment.startPaymentPoll)(purchaseToken, { id: paymentId }, polling);
6327
- }
6328
- return new Promise(function(resolve, reject) {
6329
- apiRequest.get(PURCHASE + "/" + purchaseToken + "/" + PAYMENTS + "/" + paymentId).then(function(payment) {
6330
- return resolve(payment);
6331
- }).catch(function(_ref11) {
6332
- var _ref11$code = _ref11.code, code = _ref11$code === void 0 ? -100 : _ref11$code, _ref11$message = _ref11.message, message = _ref11$message === void 0 ? "Unknown error" : _ref11$message;
6333
- return reject({ code, message });
6334
- });
6335
- });
6336
- }
6337
- function sendEmail(token, email) {
6338
- var queryParams = { email };
6339
- return new Promise(function(resolve, reject) {
6340
- apiRequest.get(PURCHASE + "/" + token + "/" + TICKET_RESEND, { queryParams }).then(function() {
6341
- return resolve();
6342
- }).catch(function(_ref12) {
6343
- var _ref12$code = _ref12.code, code = _ref12$code === void 0 ? -100 : _ref12$code, _ref12$message = _ref12.message, message = _ref12$message === void 0 ? "Unknown error" : _ref12$message;
6344
- reject({ code, message });
6345
- });
6346
- });
6347
- }
6348
- function confirmPaypalPayment(purchaseToken, paymentId) {
6349
- var polling = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
6350
- return new Promise(function(resolve, reject) {
6351
- apiRequest.put(PURCHASE + "/" + purchaseToken + "/" + PAYMENTS + "/" + paymentId + "/confirm.json").then(function(payload) {
6352
- resolve((0, _payment.startPaymentPoll)(purchaseToken, { id: paymentId }, polling));
6353
- }).catch(function(_ref13) {
6354
- var _ref13$code = _ref13.code, code = _ref13$code === void 0 ? -100 : _ref13$code, _ref13$message = _ref13.message, message = _ref13$message === void 0 ? "Unknown error" : _ref13$message;
6355
- reject({ code, message });
6356
- });
6357
- });
6358
- }
6359
- function updateWallet(purchaseToken, using) {
6360
- var params = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
6361
- var baseUrl = PURCHASE + "/" + purchaseToken + "/" + WALLET;
6362
- var url = using ? baseUrl : baseUrl + "/" + WALLET_CANCEL;
6363
- return apiRequest.post(url, params).then(function() {
6364
- return get(purchaseToken);
6365
- });
6366
- }
6367
- function verifyPhoneNumber(purchaseToken, paymentId, params) {
6368
- return apiRequest.put(PURCHASE + "/" + purchaseToken + "/" + PAYMENTS + "/" + paymentId + "/send_verification", params);
6369
- }
6370
- function verifySmsCode(purchaseToken, paymentId, code) {
6371
- return apiRequest.post(PURCHASE + "/" + purchaseToken + "/" + PAYMENTS + "/" + paymentId + "/verify_code", {
6372
- code
6373
- });
6374
- }
6375
- function unlockSeats(purchaseToken) {
6376
- return new Promise(function(resolve, reject) {
6377
- apiRequest.post(PURCHASE + "/" + purchaseToken + "/unlock_seats").then(function(response) {
6378
- return resolve(response);
6379
- }).catch(function(_ref14) {
6380
- var _ref14$code = _ref14.code, code = _ref14$code === void 0 ? -100 : _ref14$code, _ref14$message = _ref14.message, message = _ref14$message === void 0 ? "Unknown error" : _ref14$message;
6381
- return reject({ code, message });
6382
- });
6383
- });
6384
- }
6385
- function generateOTP(path, payload) {
6386
- return new Promise(function(resolve, reject) {
6387
- apiRequest.post(path + "/otp-generate", payload).then(function() {
6388
- return resolve();
6389
- }).catch(function(_ref15) {
6390
- var _ref15$code = _ref15.code, code = _ref15$code === void 0 ? -100 : _ref15$code, _ref15$message = _ref15.message, message = _ref15$message === void 0 ? "Unknown error" : _ref15$message;
6391
- return reject({ code, message });
6392
- });
6393
- });
6394
- }
6395
- function validateOTP(path, otp) {
6396
- return new Promise(function(resolve, reject) {
6397
- var payload = { otp };
6398
- apiRequest.post(path + "/otp-validate", payload).then(function() {
6399
- return resolve();
6400
- }).catch(function(_ref16) {
6401
- var _ref16$code = _ref16.code, code = _ref16$code === void 0 ? -100 : _ref16$code, _ref16$message = _ref16.message, message = _ref16$message === void 0 ? "Unknown error" : _ref16$message;
6402
- return reject({ code, message });
6403
- });
6404
- });
6405
- }
6406
- function membershipDiscountPayment(token, payload) {
6407
- return new Promise(function(resolve, reject) {
6408
- apiRequest.post(PURCHASE + "/" + token + "/" + PAYMENT_DISCOUNT, payload).then(function() {
6409
- return resolve();
6410
- }).catch(function(_ref17) {
6411
- var _ref17$code = _ref17.code, code = _ref17$code === void 0 ? -100 : _ref17$code, _ref17$message = _ref17.message, message = _ref17$message === void 0 ? "Unknown error" : _ref17$message;
6412
- return reject({ code, message });
6413
- });
6414
- });
6415
- }
6416
- function membershipDiscountPaymentDelete(token) {
6417
- return new Promise(function(resolve, reject) {
6418
- apiRequest.deleteMethod(PURCHASE + "/" + token + "/" + PAYMENT_DISCOUNT).then(function() {
6419
- return resolve();
6420
- }).catch(function(_ref18) {
6421
- var _ref18$code = _ref18.code, code = _ref18$code === void 0 ? -100 : _ref18$code, _ref18$message = _ref18.message, message = _ref18$message === void 0 ? "Unknown error" : _ref18$message;
6422
- return reject({ code, message });
6423
- });
6424
- });
6425
- }
6426
- function downloadTickets(payload) {
6427
- return new Promise(function(resolve, reject) {
6428
- apiRequest.post("tickets/pdf", payload).then(function(ticketResponse) {
6429
- return resolve(ticketResponse);
6430
- }).catch(function(_ref19) {
6431
- var _ref19$code = _ref19.code, code = _ref19$code === void 0 ? -100 : _ref19$code, _ref19$message = _ref19.message, message = _ref19$message === void 0 ? "Unknown error" : _ref19$message;
6432
- return reject({ code, message });
6433
- });
6434
- });
6435
- }
6436
- function downloadPurchasesHistory(payload) {
6437
- return new Promise(function(resolve, reject) {
6438
- apiRequest.post(PURCHASES_HISTORY, payload).then(function(history) {
6439
- return resolve(history);
6440
- }).catch(function(_ref20) {
6441
- var _ref20$code = _ref20.code, code = _ref20$code === void 0 ? -100 : _ref20$code, _ref20$message = _ref20.message, message = _ref20$message === void 0 ? "Unknown error" : _ref20$message;
6442
- return reject({ code, message });
6443
- });
6444
- });
6445
- }
6446
- function increaseExpiration(token) {
6447
- return new Promise(function(resolve, reject) {
6448
- apiRequest.post(PURCHASE + "/" + token + "/" + EXTEND_EXPIRE_AT).then(function(response) {
6449
- return resolve(response);
6450
- }).catch(function(_ref21) {
6451
- var _ref21$code = _ref21.code, code = _ref21$code === void 0 ? -100 : _ref21$code, _ref21$message = _ref21.message, message = _ref21$message === void 0 ? "Unknown error" : _ref21$message;
6452
- return reject({ code, message });
6453
- });
6454
- });
6455
- }
6456
- exports2.startTicketsPoll = _tickets.startTicketsPoll;
6457
- },
6458
- /* 15 */
6459
- /***/
6460
- function(module2, exports2, __webpack_require__) {
6461
- Object.defineProperty(exports2, "__esModule", {
6462
- value: true
6463
- });
6464
- var _extends = Object.assign || function(target) {
6465
- for (var i = 1; i < arguments.length; i++) {
6466
- var source = arguments[i];
6467
- for (var key in source) {
6468
- if (Object.prototype.hasOwnProperty.call(source, key)) {
6469
- target[key] = source[key];
6470
- }
6471
- }
6472
- }
6473
- return target;
6474
- };
6475
- exports2.startPaymentPoll = startPaymentPoll;
6476
- var _apiRequest = __webpack_require__(0);
6477
- var apiRequest = _interopRequireWildcard(_apiRequest);
6478
- function _interopRequireWildcard(obj) {
6479
- if (obj && obj.__esModule) {
6480
- return obj;
6481
- } else {
6482
- var newObj = {};
6483
- if (obj != null) {
6484
- for (var key in obj) {
6485
- if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key];
6486
- }
6487
- }
6488
- newObj.default = obj;
6489
- return newObj;
6490
- }
6491
- }
6492
- var paymentFailed = function paymentFailed2(_ref) {
6493
- var payload = _ref.payload;
6494
- return ["suspicious", "failed", "rejected"].includes(payload.status);
6495
- };
6496
- function checkPaymentPayload(onReceivePayment) {
6497
- return function(pollResponse) {
6498
- var _pollResponse$payload = pollResponse.payload, using3dsecure = _pollResponse$payload.using_3d_secure, needsVerification = _pollResponse$payload.needs_verification;
6499
- if (onReceivePayment) {
6500
- onReceivePayment(pollResponse);
6501
- }
6502
- return paymentFailed(pollResponse) || using3dsecure || needsVerification;
6503
- };
6504
- }
6505
- function startPaymentPoll(token, payload, polling) {
6506
- var id = payload.id;
6507
- var _polling$init = polling.init, init2 = _polling$init === void 0 ? true : _polling$init, onReceivePayment = polling.onReceivePayment;
6508
- var endpoint = "purchases/" + token + "/payments/" + id;
6509
- var pollOptions = _extends({
6510
- watch: "purchase_state",
6511
- expect: ["completed", "pending"]
6512
- }, polling.options || {});
6513
- var poll = void 0;
6514
- var startedPoll = void 0;
6515
- if (init2) {
6516
- poll = apiRequest.poll(endpoint, checkPaymentPayload(onReceivePayment), pollOptions);
6517
- startedPoll = poll.start();
6518
- }
6519
- return {
6520
- payload,
6521
- polls: {
6522
- payment: startedPoll,
6523
- abort: function abort() {
6524
- return poll.abort();
6525
- }
6526
- }
6527
- };
6528
- }
6529
- },
6530
- /* 16 */
6531
- /***/
6532
- function(module2, exports2, __webpack_require__) {
6533
- Object.defineProperty(exports2, "__esModule", {
6534
- value: true
6535
- });
6536
- var _extends = Object.assign || function(target) {
6537
- for (var i = 1; i < arguments.length; i++) {
6538
- var source = arguments[i];
6539
- for (var key in source) {
6540
- if (Object.prototype.hasOwnProperty.call(source, key)) {
6541
- target[key] = source[key];
6542
- }
6543
- }
6544
- }
6545
- return target;
6546
- };
6547
- exports2.startTicketsPoll = startTicketsPoll;
6548
- var _apiRequest = __webpack_require__(0);
6549
- var apiRequest = _interopRequireWildcard(_apiRequest);
6550
- function _interopRequireWildcard(obj) {
6551
- if (obj && obj.__esModule) {
6552
- return obj;
6553
- } else {
6554
- var newObj = {};
6555
- if (obj != null) {
6556
- for (var key in obj) {
6557
- if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key];
6558
- }
6559
- }
6560
- newObj.default = obj;
6561
- return newObj;
6562
- }
6563
- }
6564
- function startTicketsPoll(token, payload, polling) {
6565
- var id = payload.id;
6566
- var _polling$init = polling.init, init2 = _polling$init === void 0 ? true : _polling$init, onReceiveTickets = polling.onReceiveTickets;
6567
- var endpoint = "purchases/" + token + "/ticket_requests/" + id;
6568
- var pollOptions = _extends({
6569
- watch: "state",
6570
- expect: "finished"
6571
- }, polling.options || {});
6572
- var poll = void 0;
6573
- var startedPoll = void 0;
6574
- if (init2) {
6575
- poll = apiRequest.poll(endpoint, onReceiveTickets, pollOptions);
6576
- startedPoll = poll.start();
6577
- }
6578
- return {
6579
- payload,
6580
- polls: {
6581
- tickets: startedPoll,
6582
- abort: function abort() {
6583
- return poll.abort();
6584
- }
6585
- }
6586
- };
6587
- }
6588
- },
6589
- /* 17 */
6590
- /***/
6591
- function(module2, exports2, __webpack_require__) {
6592
- Object.defineProperty(exports2, "__esModule", {
6593
- value: true
6594
- });
6595
- var _seatFinder = __webpack_require__(18);
6596
- Object.defineProperty(exports2, "findSeats", {
6597
- enumerable: true,
6598
- get: function get() {
6599
- return _seatFinder.findSeats;
6600
- }
6601
- });
6602
- },
6603
- /* 18 */
6604
- /***/
6605
- function(module2, exports2, __webpack_require__) {
6606
- Object.defineProperty(exports2, "__esModule", {
6607
- value: true
6608
- });
6609
- var _slicedToArray = /* @__PURE__ */ function() {
6610
- function sliceIterator(arr, i) {
6611
- var _arr = [];
6612
- var _n = true;
6613
- var _d = false;
6614
- var _e = void 0;
6615
- try {
6616
- for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
6617
- _arr.push(_s.value);
6618
- if (i && _arr.length === i) break;
6619
- }
6620
- } catch (err) {
6621
- _d = true;
6622
- _e = err;
6623
- } finally {
6624
- try {
6625
- if (!_n && _i["return"]) _i["return"]();
6626
- } finally {
6627
- if (_d) throw _e;
6628
- }
6629
- }
6630
- return _arr;
6631
- }
6632
- return function(arr, i) {
6633
- if (Array.isArray(arr)) {
6634
- return arr;
6635
- } else if (Symbol.iterator in Object(arr)) {
6636
- return sliceIterator(arr, i);
6637
- } else {
6638
- throw new TypeError("Invalid attempt to destructure non-iterable instance");
6639
- }
6640
- };
6641
- }();
6642
- exports2.findSeats = findSeats;
6643
- function hasAvailableSeats(rowSeats) {
6644
- var count = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 1;
6645
- var except = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : [];
6646
- var availableSeats = rowSeats.filter(function(seat) {
6647
- return !(seat.occupied || except.includes(seat.number));
6648
- });
6649
- return availableSeats.length >= count;
6650
- }
6651
- function findAvailableSeats(n, deck) {
6652
- var selectedSeats = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : [];
6653
- var pending = arguments[3];
6654
- var rowCount = deck.length;
6655
- var selectedCount = selectedSeats.length;
6656
- var newDeck = deck;
6657
- var newSeats = void 0;
6658
- if (typeof pending === "undefined") {
6659
- pending = n - selectedCount;
6660
- }
6661
- if (!pending) {
6662
- return selectedSeats;
6663
- }
6664
- for (var i = 0; i < rowCount; i++) {
6665
- var rowSeats = deck[i].filter(function(busSpace) {
6666
- return ["seat", "seat_tv"].includes(busSpace.category);
6667
- });
6668
- newSeats = findAvailableAdjecentSeats(pending, rowSeats, selectedSeats);
6669
- if (newSeats.length === pending) {
6670
- newDeck = deck.slice(i);
6671
- newDeck = newDeck.concat(deck.slice(0, i));
6672
- selectedSeats = selectedSeats.concat(newSeats);
6673
- selectedCount = selectedSeats.length;
6674
- break;
6675
- }
6676
- }
6677
- if (!newSeats.length) {
6678
- pending -= 1;
6679
- } else {
6680
- pending = n - selectedCount;
6681
- }
6682
- return findAvailableSeats(n, newDeck, selectedSeats, pending);
6683
- }
6684
- function findAvailableAdjecentSeats(n, rowSeats) {
6685
- var except = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : [];
6686
- var adjecent = [];
6687
- var hasEnoughSeats = false;
6688
- if (!hasAvailableSeats(rowSeats, n, except)) {
6689
- return adjecent;
6690
- }
6691
- for (var i = rowSeats.length - 1; i >= 0; i--) {
6692
- var seat = rowSeats[i];
6693
- if (seat.occupied) {
6694
- adjecent = [];
6695
- } else {
6696
- adjecent.push(seat.number);
6697
- }
6698
- if (adjecent.length === n) {
6699
- hasEnoughSeats = true;
6700
- break;
6701
- }
6702
- }
6703
- if (hasEnoughSeats) {
6704
- return adjecent;
6705
- } else {
6706
- return [];
6707
- }
6708
- }
6709
- function findSeats(n, layout) {
6710
- var _layout = _slicedToArray(layout, 2), firstDeck = _layout[0], secondDeck = _layout[1];
6711
- var firstDeckSeats = findAvailableSeats(n, firstDeck);
6712
- var selectedSeats = [];
6713
- if (firstDeckSeats.length < n && secondDeck) {
6714
- var secondDeckSeats = findAvailableSeats(n, secondDeck);
6715
- if (secondDeckSeats.length < n) {
6716
- selectedSeats = firstDeckSeats.concat(secondDeckSeats).slice(0, n);
6717
- } else {
6718
- selectedSeats = secondDeckSeats;
6719
- }
6720
- } else {
6721
- selectedSeats = firstDeckSeats;
6722
- }
6723
- return selectedSeats.length ? selectedSeats : null;
6724
- }
6725
- },
6726
- /* 19 */
6727
- /***/
6728
- function(module2, exports2, __webpack_require__) {
6729
- Object.defineProperty(exports2, "__esModule", {
6730
- value: true
6731
- });
6732
- exports2.get = get;
6733
- var _apiRequest = __webpack_require__(0);
6734
- var apiRequest = _interopRequireWildcard(_apiRequest);
6735
- function _interopRequireWildcard(obj) {
6736
- if (obj && obj.__esModule) {
6737
- return obj;
6738
- } else {
6739
- var newObj = {};
6740
- if (obj != null) {
6741
- for (var key in obj) {
6742
- if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key];
6743
- }
6744
- }
6745
- newObj.default = obj;
6746
- return newObj;
6747
- }
6748
- }
6749
- function get(queryParams) {
6750
- return new Promise(function(resolve, reject) {
6751
- apiRequest.get("redirect", { apiVersion: "v2", queryParams }).then(function(response) {
6752
- return resolve(response);
6753
- }).catch(function(_ref) {
6754
- var _ref$code = _ref.code, code = _ref$code === void 0 ? -100 : _ref$code, _ref$message = _ref.message, message = _ref$message === void 0 ? "Unknown error" : _ref$message;
6755
- return reject({ code, message });
6756
- });
6757
- });
6758
- }
6759
- },
6760
- /* 20 */
6761
- /***/
6762
- function(module2, exports2, __webpack_require__) {
6763
- Object.defineProperty(exports2, "__esModule", {
6764
- value: true
6765
- });
6766
- exports2.get = get;
6767
- var _apiRequest = __webpack_require__(0);
6768
- var apiRequest = _interopRequireWildcard(_apiRequest);
6769
- function _interopRequireWildcard(obj) {
6770
- if (obj && obj.__esModule) {
6771
- return obj;
6772
- } else {
6773
- var newObj = {};
6774
- if (obj != null) {
6775
- for (var key in obj) {
6776
- if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key];
6777
- }
6778
- }
6779
- newObj.default = obj;
6780
- return newObj;
6781
- }
6782
- }
6783
- function get(queryParams) {
6784
- return new Promise(function(resolve, reject) {
6785
- apiRequest.get("quotes", { queryParams }).then(function(quotes) {
6786
- return resolve(quotes);
6787
- }).catch(function(_ref) {
6788
- var _ref$code = _ref.code, code = _ref$code === void 0 ? -100 : _ref$code, _ref$message = _ref.message, message = _ref$message === void 0 ? "Unknown error" : _ref$message;
6789
- return reject({ code, message });
6790
- });
6791
- });
6792
- }
6793
- },
6794
- /* 21 */
6795
- /***/
6796
- function(module2, exports2, __webpack_require__) {
6797
- Object.defineProperty(exports2, "__esModule", {
6798
- value: true
6799
- });
6800
- exports2.getUser = getUser;
6801
- exports2.getCreditCards = getCreditCards;
6802
- var _apiRequest = __webpack_require__(0);
6803
- var apiRequest = _interopRequireWildcard(_apiRequest);
6804
- var _config = __webpack_require__(1);
6805
- var _config2 = _interopRequireDefault(_config);
6806
- function _interopRequireDefault(obj) {
6807
- return obj && obj.__esModule ? obj : { default: obj };
6808
- }
6809
- function _interopRequireWildcard(obj) {
6810
- if (obj && obj.__esModule) {
6811
- return obj;
6812
- } else {
6813
- var newObj = {};
6814
- if (obj != null) {
6815
- for (var key in obj) {
6816
- if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key];
6817
- }
6818
- }
6819
- newObj.default = obj;
6820
- return newObj;
6821
- }
6822
- }
6823
- var USERS = "users";
6824
- var USERS_PROFILE = USERS + "/profile.json";
6825
- var USERS_CREDIT_CARDS = USERS + "/list_cards.json";
6826
- function getUser() {
6827
- if (!_config2.default.userAuthToken) return null;
6828
- return apiRequest.get(USERS_PROFILE);
6829
- }
6830
- function getCreditCards() {
6831
- if (!_config2.default.userAuthToken) return null;
6832
- return apiRequest.get(USERS_CREDIT_CARDS);
6833
- }
6834
- },
6835
- /* 22 */
6836
- /***/
6837
- function(module2, exports2, __webpack_require__) {
6838
- Object.defineProperty(exports2, "__esModule", {
6839
- value: true
6840
- });
6841
- exports2.createPriceAlert = createPriceAlert;
6842
- exports2.deletePriceAlert = deletePriceAlert;
6843
- var _apiRequest = __webpack_require__(0);
6844
- var apiRequest = _interopRequireWildcard(_apiRequest);
6845
- function _interopRequireWildcard(obj) {
6846
- if (obj && obj.__esModule) {
6847
- return obj;
6848
- } else {
6849
- var newObj = {};
6850
- if (obj != null) {
6851
- for (var key in obj) {
6852
- if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key];
6853
- }
6854
- }
6855
- newObj.default = obj;
6856
- return newObj;
6857
- }
6858
- }
6859
- var PRICE_ALERTS = "price_alerts";
6860
- var CANCEL = "cancel.json";
6861
- function createPriceAlert(alertData) {
6862
- return apiRequest.post(PRICE_ALERTS + ".json", alertData);
6863
- }
6864
- function deletePriceAlert(id) {
6865
- return apiRequest.get(PRICE_ALERTS + "/" + id + "/" + CANCEL);
6866
- }
6867
- },
6868
- /* 23 */
6869
- /***/
6870
- function(module2, exports2, __webpack_require__) {
6871
- Object.defineProperty(exports2, "__esModule", {
6872
- value: true
6873
- });
6874
- var _extends = Object.assign || function(target) {
6875
- for (var i = 1; i < arguments.length; i++) {
6876
- var source = arguments[i];
6877
- for (var key in source) {
6878
- if (Object.prototype.hasOwnProperty.call(source, key)) {
6879
- target[key] = source[key];
6880
- }
6881
- }
6882
- }
6883
- return target;
6884
- };
6885
- exports2.validate = validate;
6886
- exports2.cancelTicket = cancelTicket;
6887
- exports2.getCancelledTicketStatusPoll = getCancelledTicketStatusPoll;
6888
- var _apiRequest = __webpack_require__(0);
6889
- var apiRequest = _interopRequireWildcard(_apiRequest);
6890
- function _interopRequireWildcard(obj) {
6891
- if (obj && obj.__esModule) {
6892
- return obj;
6893
- } else {
6894
- var newObj = {};
6895
- if (obj != null) {
6896
- for (var key in obj) {
6897
- if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key];
6898
- }
6899
- }
6900
- newObj.default = obj;
6901
- return newObj;
6902
- }
6903
- }
6904
- var EXCHANGE = "exchanges";
6905
- function validate(operationNumber, nit, origin2, destination, recaptchaToken, email, document2) {
6906
- var payload = _extends({}, email && { email }, document2 && { document: document2 }, {
6907
- operation_number: operationNumber
6908
- }, nit && { nit }, origin2 && { origin: origin2 }, destination && { destination }, recaptchaToken && { recaptcha_token: recaptchaToken });
6909
- return new Promise(function(resolve, reject) {
6910
- apiRequest.post(EXCHANGE + "/validate", payload).then(function(validation) {
6911
- return resolve(validation);
6912
- }).catch(function(_ref) {
6913
- var _ref$code = _ref.code, code = _ref$code === void 0 ? -100 : _ref$code, _ref$message = _ref.message, message = _ref$message === void 0 ? "Unknown error" : _ref$message;
6914
- return reject({ code, message });
6915
- });
6916
- });
6917
- }
6918
- function cancelTicket(token, operationNumberArray) {
6919
- var payload = {
6920
- operation_number: operationNumberArray
6921
- };
6922
- return new Promise(function(resolve, reject) {
6923
- apiRequest.post("purchases/" + token + "/cancellations", payload).then(function(response) {
6924
- return resolve(response);
6925
- }).catch(function(_ref2) {
6926
- var _ref2$code = _ref2.code, code = _ref2$code === void 0 ? -100 : _ref2$code, _ref2$message = _ref2.message, message = _ref2$message === void 0 ? "Unknown error" : _ref2$message;
6927
- return reject({ code, message });
6928
- });
6929
- });
6930
- }
6931
- function getCancelledTicketStatusPoll(token, idCancellation, polling) {
6932
- var id = idCancellation;
6933
- var _polling$init = polling.init, init2 = _polling$init === void 0 ? true : _polling$init, onGetCancelStatus = polling.onGetCancelStatus;
6934
- var endpoint = "purchases/" + token + "/cancellations/" + id;
6935
- var pollOptions = _extends({
6936
- watch: "status",
6937
- expect: "success"
6938
- }, polling.options || {});
6939
- var poll = void 0;
6940
- var startedPoll = void 0;
6941
- if (init2) {
6942
- poll = apiRequest.poll(endpoint, onGetCancelStatus, pollOptions);
6943
- startedPoll = poll.start();
6944
- }
6945
- return {
6946
- payload: idCancellation,
6947
- polls: {
6948
- data: startedPoll,
6949
- abort: function abort() {
6950
- return poll.abort();
6951
- }
6952
- }
6953
- };
6954
- }
6955
- },
6956
- /* 24 */
6957
- /***/
6958
- function(module2, exports2, __webpack_require__) {
6959
- Object.defineProperty(exports2, "__esModule", {
6960
- value: true
6961
- });
6962
- exports2.paymentCards = paymentCards;
6963
- exports2.deleteCard = deleteCard;
6964
- var _apiRequest = __webpack_require__(0);
6965
- var apiRequest = _interopRequireWildcard(_apiRequest);
6966
- function _interopRequireWildcard(obj) {
6967
- if (obj && obj.__esModule) {
6968
- return obj;
6969
- } else {
6970
- var newObj = {};
6971
- if (obj != null) {
6972
- for (var key in obj) {
6973
- if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key];
6974
- }
6975
- }
6976
- newObj.default = obj;
6977
- return newObj;
6978
- }
6979
- }
6980
- function paymentCards(params) {
6981
- return new Promise(function(resolve, reject) {
6982
- apiRequest.post("adyen/payment_cards", params).then(function(creditCards) {
6983
- return resolve(creditCards);
6984
- }).catch(function(_ref) {
6985
- var _ref$code = _ref.code, code = _ref$code === void 0 ? -100 : _ref$code, _ref$message = _ref.message, message = _ref$message === void 0 ? "Unknown error" : _ref$message;
6986
- return reject({ code, message });
6987
- });
6988
- });
6989
- }
6990
- function deleteCard(params) {
6991
- return new Promise(function(resolve, reject) {
6992
- apiRequest.post("adyen/delete_payment_card", params).then(function(response) {
6993
- return resolve(response);
6994
- }).catch(function(_ref2) {
6995
- var _ref2$code = _ref2.code, code = _ref2$code === void 0 ? -100 : _ref2$code, _ref2$message = _ref2.message, message = _ref2$message === void 0 ? "Unknown error" : _ref2$message;
6996
- return reject({ code, message });
6997
- });
6998
- });
6999
- }
7000
- },
7001
- /* 25 */
7002
- /***/
7003
- function(module2, exports2, __webpack_require__) {
7004
- Object.defineProperty(exports2, "__esModule", {
7005
- value: true
7006
- });
7007
- exports2.getRecommendedTrips = getRecommendedTrips;
7008
- exports2.createTripPriceAlerts = createTripPriceAlerts;
7009
- exports2.updateTripPriceAlerts = updateTripPriceAlerts;
7010
- exports2.deleteTripPriceAlerts = deleteTripPriceAlerts;
7011
- exports2.createAnonymousProfile = createAnonymousProfile2;
7012
- var _apiRequest = __webpack_require__(0);
7013
- var apiRequest = _interopRequireWildcard(_apiRequest);
7014
- function _interopRequireWildcard(obj) {
7015
- if (obj && obj.__esModule) {
7016
- return obj;
7017
- } else {
7018
- var newObj = {};
7019
- if (obj != null) {
7020
- for (var key in obj) {
7021
- if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key];
7022
- }
7023
- }
7024
- newObj.default = obj;
7025
- return newObj;
7026
- }
7027
- }
7028
- var TRIP_PRICE_ALERTS = "trip_price_alerts";
7029
- var ANONYMOUS_PROFILE = "anonymous_profiles/identify";
7030
- function getRecommendedTrips(_ref) {
7031
- var searchId = _ref.searchId, userIdentifier = _ref.userIdentifier;
7032
- return new Promise(function(resolve, reject) {
7033
- apiRequest.get("trip_recommendations/" + searchId + "/" + userIdentifier, { apiType: "core" }).then(function(response) {
7034
- return resolve(response);
7035
- }).catch(function(_ref2) {
7036
- var _ref2$code = _ref2.code, code = _ref2$code === void 0 ? -100 : _ref2$code, _ref2$message = _ref2.message, message = _ref2$message === void 0 ? "Unknown error" : _ref2$message;
7037
- return reject({ code, message });
7038
- });
7039
- });
7040
- }
7041
- function createTripPriceAlerts(payload) {
7042
- return new Promise(function(resolve, reject) {
7043
- apiRequest.post("" + TRIP_PRICE_ALERTS, payload).then(function(response) {
7044
- return resolve(response);
7045
- }).catch(function(_ref3) {
7046
- var _ref3$code = _ref3.code, code = _ref3$code === void 0 ? -100 : _ref3$code, _ref3$message = _ref3.message, message = _ref3$message === void 0 ? "Unknow error" : _ref3$message;
7047
- return reject({ code, message });
7048
- });
7049
- });
7050
- }
7051
- function updateTripPriceAlerts(priceAlertId, payload) {
7052
- return new Promise(function(resolve, reject) {
7053
- apiRequest.put(TRIP_PRICE_ALERTS + "/" + priceAlertId, payload).then(function(response) {
7054
- return resolve(response);
7055
- }).catch(function(_ref4) {
7056
- var _ref4$code = _ref4.code, code = _ref4$code === void 0 ? -100 : _ref4$code, _ref4$message = _ref4.message, message = _ref4$message === void 0 ? "Unknow error" : _ref4$message;
7057
- return reject({ code, message });
7058
- });
7059
- });
7060
- }
7061
- function deleteTripPriceAlerts(priceAlertId) {
7062
- return new Promise(function(resolve, reject) {
7063
- apiRequest.deleteMethod(TRIP_PRICE_ALERTS + "/" + priceAlertId).then(function() {
7064
- return resolve({ code: 200, message: "Trip Price Alert deleted" });
7065
- }).catch(function(_ref5) {
7066
- var _ref5$code = _ref5.code, code = _ref5$code === void 0 ? -100 : _ref5$code, _ref5$message = _ref5.message, message = _ref5$message === void 0 ? "Unknow error" : _ref5$message;
7067
- return reject({ code, message });
7068
- });
7069
- });
7070
- }
7071
- function createAnonymousProfile2(payload) {
7072
- return new Promise(function(resolve, reject) {
7073
- apiRequest.post(ANONYMOUS_PROFILE, payload, { apiType: "core" }).then(function(response) {
7074
- return resolve(response);
7075
- }).catch(function(_ref6) {
7076
- var _ref6$code = _ref6.code, code = _ref6$code === void 0 ? -100 : _ref6$code, _ref6$message = _ref6.message, message = _ref6$message === void 0 ? "Unknow error" : _ref6$message;
7077
- return reject({ code, message });
7078
- });
7079
- });
7080
- }
7081
- }
7082
- /******/
7083
- ])
7084
- );
7085
- });
7086
- })(jsApiClient);
7087
- var jsApiClientExports = jsApiClient.exports;
4622
+ function w({
4623
+ apiName: f2,
4624
+ defaultApiVersion: c2
4625
+ }) {
4626
+ let t2, o2 = {
4627
+ "Content-Type": "application/json"
4628
+ }, n;
4629
+ function l2(e) {
4630
+ t2 = e.baseUrl, o2 = {
4631
+ ...o2,
4632
+ ...e.defaultHeaders || {}
4633
+ };
4634
+ }
4635
+ function p2(e) {
4636
+ n = e;
4637
+ }
4638
+ function u2() {
4639
+ if (!t2)
4640
+ throw new Error(`Base URL is not set for ${f2} API.`);
4641
+ }
4642
+ const h2 = { body: {} };
4643
+ async function y2(e, s2 = h2) {
4644
+ u2();
4645
+ const { body: r2, headers: a2 = {}, apiVersion: i = c2 } = s2, d2 = `${t2}/${i}/${e}`, b2 = {
4646
+ ...o2,
4647
+ ...a2,
4648
+ ...n ? { Authorization: n } : {}
4649
+ };
4650
+ return (await fetch(d2, {
4651
+ method: "POST",
4652
+ body: JSON.stringify(r2),
4653
+ headers: b2
4654
+ })).json();
4655
+ }
4656
+ async function $(e, s2 = {}) {
4657
+ u2();
4658
+ const { headers: r2 = {}, apiVersion: a2 = c2 } = s2, i = `${t2}/${a2}/${e}`;
4659
+ return (await fetch(i, { headers: r2 })).json();
4660
+ }
4661
+ return {
4662
+ get: $,
4663
+ post: y2,
4664
+ setAuthorizationHeader: p2,
4665
+ setConfig: l2
4666
+ };
4667
+ }
4668
+ const t$1 = w({
4669
+ apiName: "Core",
4670
+ defaultApiVersion: "v1"
4671
+ });
4672
+ async function t(o2) {
4673
+ const { data: e } = await t$1.post(
4674
+ "anonymous_profiles/identify",
4675
+ {
4676
+ body: o2
4677
+ }
4678
+ );
4679
+ return e;
4680
+ }
4681
+ const s = {
4682
+ createAnonymousProfile: t
4683
+ };
4684
+ function r({
4685
+ searchId: e,
4686
+ userIdentifier: t2
4687
+ }) {
4688
+ return t$1.get(
4689
+ `trip_recommendations/${e}/${t2}`
4690
+ );
4691
+ }
4692
+ const m = {
4693
+ getRecommendedTrips: r
4694
+ };
4695
+ const f = {
4696
+ setConfig: t$1.setConfig,
4697
+ recommendations: m,
4698
+ profiles: s
4699
+ };
4700
+ let environment;
7088
4701
  const origin = window.location.origin;
7089
4702
  const coreAPIConfig = {
7090
4703
  sandbox: {
7091
- coreUrl: "https://datalake-api-dev.reservamossaas.com/api",
7092
- coreVersion: "v1",
7093
- headers: {
7094
- Origin: origin
7095
- },
7096
- coreApiKey: "Bearer 753bf0710dc920a84236d42241d4f487"
4704
+ baseUrl: "https://datalake-api-dev.reservamossaas.com/api",
4705
+ defaultHeaders: {
4706
+ Origin: origin,
4707
+ Authorization: "Bearer 753bf0710dc920a84236d42241d4f487"
4708
+ }
7097
4709
  },
7098
4710
  prod: {
7099
- coreUrl: "https://data-lake.reservamossaas.com/api",
7100
- coreVersion: "v1",
7101
- headers: {
7102
- Origin: origin
7103
- },
7104
- coreApiKey: "Bearer 753bf0710dc920a84236d42241d4f487"
4711
+ baseUrl: "https://data-lake.reservamossaas.com/api",
4712
+ defaultHeaders: {
4713
+ Origin: origin,
4714
+ Authorization: "Bearer 753bf0710dc920a84236d42241d4f487"
4715
+ }
7105
4716
  }
7106
4717
  };
4718
+ function setEnvironment(env) {
4719
+ environment = env;
4720
+ }
4721
+ function getCoreAPIConfig() {
4722
+ if (!environment) {
4723
+ throw new Error(
4724
+ "Unable to get core API config, environment not set. Use configService.setEnvironment(environment) to set the environment."
4725
+ );
4726
+ }
4727
+ return coreAPIConfig[environment];
4728
+ }
7107
4729
  const configService = {
7108
- coreAPIConfig
4730
+ setEnvironment,
4731
+ getCoreAPIConfig
7109
4732
  };
7110
4733
  var NodeType;
7111
4734
  (function(NodeType2) {
@@ -10107,15 +7730,15 @@ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
10107
7730
  PERFORMANCE OF THIS SOFTWARE.
10108
7731
  ***************************************************************************** */
10109
7732
  function __rest(s2, e) {
10110
- var t = {};
7733
+ var t2 = {};
10111
7734
  for (var p2 in s2) if (Object.prototype.hasOwnProperty.call(s2, p2) && e.indexOf(p2) < 0)
10112
- t[p2] = s2[p2];
7735
+ t2[p2] = s2[p2];
10113
7736
  if (s2 != null && typeof Object.getOwnPropertySymbols === "function")
10114
7737
  for (var i = 0, p2 = Object.getOwnPropertySymbols(s2); i < p2.length; i++) {
10115
7738
  if (e.indexOf(p2[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s2, p2[i]))
10116
- t[p2[i]] = s2[p2[i]];
7739
+ t2[p2[i]] = s2[p2[i]];
10117
7740
  }
10118
- return t;
7741
+ return t2;
10119
7742
  }
10120
7743
  function __awaiter(thisArg, _arguments, P2, generator) {
10121
7744
  function adopt(value) {
@@ -15507,6 +13130,7 @@ function loadNoop(_src, onload) {
15507
13130
  onload();
15508
13131
  }
15509
13132
  var mixpanel = init_as_module(loadNoop);
13133
+ const version = "1.0.9";
15510
13134
  const MIXPANEL_DISTINCT_ID_CACHE_KEY = "mp_distinct_id";
15511
13135
  function init$2(mixpanelToken, debug = false, proxyUrl) {
15512
13136
  return new Promise((resolve) => {
@@ -15538,7 +13162,7 @@ function track(eventName, properties) {
15538
13162
  if (!isReady()) {
15539
13163
  return;
15540
13164
  }
15541
- mixpanel.track(eventName, properties);
13165
+ mixpanel.track(eventName, { ...properties, "Reservamos Version": version });
15542
13166
  }
15543
13167
  const getMixpanelDistinctId = () => {
15544
13168
  const cachedId = localStorage.getItem(MIXPANEL_DISTINCT_ID_CACHE_KEY);
@@ -15911,7 +13535,6 @@ const validatorService = {
15911
13535
  function onLoaded() {
15912
13536
  window.dispatchEvent(new CustomEvent("Tracker Ready"));
15913
13537
  }
15914
- let apiConfig = null;
15915
13538
  async function init$1(config) {
15916
13539
  validatorService.parseInitProps(config);
15917
13540
  const {
@@ -15932,17 +13555,13 @@ async function init$1(config) {
15932
13555
  } catch (error) {
15933
13556
  console.error("Error initializing identification service:", error);
15934
13557
  }
15935
- const environment = isSandbox ? "sandbox" : "prod";
15936
- apiConfig = configService.coreAPIConfig[environment];
15937
- jsApiClientExports.setConfig(apiConfig);
13558
+ configService.setEnvironment(isSandbox ? "sandbox" : "prod");
13559
+ f.setConfig(configService.getCoreAPIConfig());
15938
13560
  onLoaded();
15939
13561
  }
15940
13562
  function isTrackerReady() {
15941
13563
  return mixpanelService.isReady();
15942
13564
  }
15943
- function getApiConfig() {
15944
- return apiConfig;
15945
- }
15946
13565
  let currentCoordinates = null;
15947
13566
  function init() {
15948
13567
  return new Promise((resolve) => {
@@ -16015,37 +13634,26 @@ function flattenEventData(data) {
16015
13634
  return flattenedData;
16016
13635
  }, {});
16017
13636
  }
16018
- function trackEventTracked(eventName, from) {
16019
- mixpanelService.track("Event Tracked", {
16020
- "Event Name": eventName,
16021
- "From": from
16022
- });
16023
- }
16024
- function trackEventError(eventName, error) {
16025
- try {
16026
- tryTrackEvent("Track Event Error", async () => {
13637
+ function trackEventError(eventName, error, payload) {
13638
+ tryTrackEvent(async () => {
13639
+ try {
16027
13640
  mixpanelService.track("Track Event Error", {
16028
13641
  "Failed Event Name": eventName,
16029
13642
  "Error Message": (error == null ? void 0 : error.message) ?? "Failed to track event",
16030
- "Validation Errors": (error == null ? void 0 : error.errors) || []
13643
+ "Validation Errors": (error == null ? void 0 : error.errors) || [],
13644
+ "Event Payload": payload
16031
13645
  });
16032
- });
16033
- } catch (trackingError) {
16034
- console.error("Failed to track error event:", trackingError);
16035
- }
13646
+ } catch (trackingError) {
13647
+ console.error("Failed to track error event:", trackingError);
13648
+ }
13649
+ });
16036
13650
  }
16037
- async function tryTrackEvent(eventName, trackEventCallback) {
13651
+ async function tryTrackEvent(trackEventCallback) {
16038
13652
  if (mixpanelService.isReady()) {
16039
13653
  await trackEventCallback();
16040
- trackEventTracked(eventName, "Mixpanel Ready");
16041
13654
  } else {
16042
13655
  window.addEventListener("Tracker Ready", async () => {
16043
- try {
16044
- await trackEventCallback();
16045
- trackEventTracked(eventName, "Mixpanel Ready Listener");
16046
- } catch (error) {
16047
- trackEventError(eventName, error);
16048
- }
13656
+ await trackEventCallback();
16049
13657
  });
16050
13658
  }
16051
13659
  }
@@ -16078,7 +13686,7 @@ async function trackEvent(eventName, eventProperties, meta = {}) {
16078
13686
  mixpanelService.track(eventName, properties);
16079
13687
  } catch (error) {
16080
13688
  console.error(`Error tracking event '${eventName}':`, error);
16081
- trackEventError(eventName, error);
13689
+ trackEventError(eventName, error, eventProperties);
16082
13690
  }
16083
13691
  }
16084
13692
  function extractTrackingParams() {
@@ -16103,7 +13711,7 @@ function trackCustomEvent(eventName, eventData = {}, meta = {}) {
16103
13711
  trackEvent(eventName, eventData, meta);
16104
13712
  } catch (error) {
16105
13713
  console.error("Error trackCustomEvent:", error);
16106
- trackEventError(eventName, error);
13714
+ trackEventError(eventName, error, eventData);
16107
13715
  }
16108
13716
  }
16109
13717
  const CreateAnonymousProfileSchema = z.object({
@@ -16158,8 +13766,7 @@ async function createAnonymousProfile(payload) {
16158
13766
  identifiers.push({ key: "fingerprint", value: userFingerprintId });
16159
13767
  if (distinctId) identifiers.push({ key: "distinct_id", value: distinctId });
16160
13768
  const dataPayload = getAnonymousProfilePayload(payload, identifiers);
16161
- const result = await jsApiClientExports.core.createAnonymousProfile(dataPayload);
16162
- return result.data;
13769
+ return await f.profiles.createAnonymousProfile(dataPayload);
16163
13770
  } catch (error) {
16164
13771
  console.error("Could not create anonymous profile:", error);
16165
13772
  return void 0;
@@ -16186,8 +13793,8 @@ function mapProperties(properties) {
16186
13793
  return { ...parsedProperties, ...additionalProperties };
16187
13794
  }
16188
13795
  const identifyWithLocation = async (userId, properties) => {
13796
+ var _a, _b;
16189
13797
  try {
16190
- const apiConfig2 = getApiConfig();
16191
13798
  const coordinates = geolocationService.getCoordinates();
16192
13799
  if (!coordinates) {
16193
13800
  return;
@@ -16200,12 +13807,13 @@ const identifyWithLocation = async (userId, properties) => {
16200
13807
  properties.name = `${properties.firstName} ${properties.lastName}`;
16201
13808
  delete properties.firstName;
16202
13809
  delete properties.lastName;
16203
- fetch(`${apiConfig2 == null ? void 0 : apiConfig2.coreUrl}/${apiConfig2 == null ? void 0 : apiConfig2.coreVersion}/datalake/identify`, {
13810
+ const coreApiConfig = configService.getCoreAPIConfig();
13811
+ fetch(`${coreApiConfig.baseUrl}/v1/datalake/identify`, {
16204
13812
  method: "POST",
16205
13813
  headers: {
16206
13814
  "Content-Type": "application/json",
16207
- "Authorization": (apiConfig2 == null ? void 0 : apiConfig2.coreApiKey) || "",
16208
- ...(apiConfig2 == null ? void 0 : apiConfig2.headers) || {}
13815
+ "Authorization": ((_a = coreApiConfig.defaultHeaders) == null ? void 0 : _a.Authorization) || "",
13816
+ "Origin": ((_b = coreApiConfig.defaultHeaders) == null ? void 0 : _b.Origin) || ""
16209
13817
  },
16210
13818
  body: JSON.stringify({
16211
13819
  profile_params: {
@@ -16219,8 +13827,8 @@ const identifyWithLocation = async (userId, properties) => {
16219
13827
  }
16220
13828
  };
16221
13829
  async function identify(userId, properties = {}) {
16222
- try {
16223
- tryTrackEvent("Identify", async () => {
13830
+ tryTrackEvent(async () => {
13831
+ try {
16224
13832
  validatorService.parseIdentifyProps(properties);
16225
13833
  if (!userId) {
16226
13834
  console.error("User ID is required for identification.");
@@ -16236,13 +13844,13 @@ async function identify(userId, properties = {}) {
16236
13844
  if (fingerprint) {
16237
13845
  mixpanelService.attachProperty(FINGERPRINT_PROPERTY, fingerprint);
16238
13846
  }
16239
- });
16240
- } catch (error) {
16241
- console.error("Error identifying user", error);
16242
- trackEventError("Identify", error);
16243
- } finally {
16244
- identifyWithLocation(userId, properties);
16245
- }
13847
+ } catch (error) {
13848
+ console.error("Error identifying user", error);
13849
+ trackEventError("Identify", error, { userId, properties });
13850
+ } finally {
13851
+ identifyWithLocation(userId, properties);
13852
+ }
13853
+ });
16246
13854
  }
16247
13855
  const EVENT_NAME = "Purchase Canceled";
16248
13856
  function trackPurchaseCanceled(eventData, meta = {}) {