@odynn/awayz-flights 0.3.2 → 0.3.4

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.
@@ -1,102 +1,102 @@
1
- import { jsx as r, jsxs as e, Fragment as E } from "react/jsx-runtime";
2
- import I, { useState as F, useMemo as L } from "react";
3
- import { g as y, E as c, F as R, a as B } from "../../FlightItinerary-COx1k-zp.js";
4
- import { DEFAULT_AIRLINE_PROGRAM as M, getFlightNumber as $, getLogoPath as x, getAirlineProgram as j } from "../../utils/flightUtils.js";
1
+ import { jsx as e, jsxs as r, Fragment as $ } from "react/jsx-runtime";
2
+ import x, { useState as S, useMemo as j } from "react";
3
+ import { g as O, E as c, F as H, a as U } from "../../FlightItinerary-COx1k-zp.js";
4
+ import { DEFAULT_AIRLINE_PROGRAM as _, getFlightNumber as z, getLogoPath as G, getAirlineProgram as V } from "../../utils/flightUtils.js";
5
5
  import { h } from "../../moment-BGjjqtLQ.js";
6
- import { g as H } from "../../index-D0Heof44.js";
6
+ import { g as q } from "../../index-D0Heof44.js";
7
7
  import "../../arrayExtensions-DFLvtO8l.js";
8
8
  import { EPaymentType as m } from "../../enums/EPaymentType.js";
9
- import { CashValue as C, EInvalidAmountDisplayOption as U } from "@odynn/awayz-core";
10
- import { isSameDayFlight as _ } from "../../utils/flightDateUtils.js";
11
- import '../../assets/FlightResult.css';function z(i) {
9
+ import { CashValue as P, EInvalidAmountDisplayOption as J } from "@odynn/awayz-core";
10
+ import { isSameDayFlight as K } from "../../utils/flightDateUtils.js";
11
+ import '../../assets/FlightResult.css';function Q(i) {
12
12
  if (!i || isNaN(i) || i < 0) return "N/A";
13
13
  let o = i == null ? void 0 : i.toString().split(".")[0];
14
14
  return o == null ? void 0 : o.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
15
15
  }
16
- const ii = ({ details: i, onClick: o }) => {
17
- var u;
18
- const [d, D] = F(!1), n = i.origin, t = i.destination, f = i.flightDetails, N = !i.paymentOptions || i.paymentOptions.length === 1, [S, O] = F(M), P = async () => {
19
- const a = await j(i.airlineProgram);
20
- O(a);
21
- }, { flightNumbers: p, airlines: T } = L(() => {
16
+ const ni = ({ details: i, onClick: o }) => {
17
+ var u, v, F, y, C;
18
+ const [d, T] = S(!1), n = i.origin, t = i.destination, f = i.flightDetails, N = i.paymentOptions || [], k = N.filter((a) => a.cash).length === 1, A = N.filter((a) => a.points).length === 1, [b, w] = S(_), E = async () => {
19
+ const a = await V(i.airlineProgram);
20
+ w(a);
21
+ }, { flightNumbers: p, airlines: I } = j(() => {
22
22
  const a = [], s = [];
23
- return i.flightDetails.slices.forEach((b) => {
24
- b.segments.forEach((l) => {
25
- const v = $(l);
26
- a.includes(v) || a.push(v);
23
+ return i.flightDetails.slices.forEach((B) => {
24
+ B.segments.forEach((l) => {
25
+ const D = z(l);
26
+ a.includes(D) || a.push(D);
27
27
  const g = l.operatingCarrierFlightNumber ? l.operatingCarrier : l.marketingCarrier;
28
- s.some((w) => w.airline === g.name) || s.push({
29
- logo: x(g.iataCode),
28
+ s.some((M) => M.airline === g.name) || s.push({
29
+ logo: G(g.iataCode),
30
30
  airline: g.name
31
31
  });
32
32
  });
33
- }), P(), { flightNumbers: a, airlines: s };
34
- }, [i.flightDetails.slices]), k = () => {
33
+ }), E(), { flightNumbers: a, airlines: s };
34
+ }, [i.flightDetails.slices]), L = () => {
35
35
  i.cash > 0 ? o(i, m.CASH) : o(i, m.POINTS);
36
- }, A = !_(
36
+ }, R = !K(
37
37
  i.departureTime,
38
38
  i.arrivalTime
39
39
  );
40
- return /* @__PURE__ */ r("div", { className: "flight-result", onClick: k, children: /* @__PURE__ */ e("div", { className: "content", children: [
41
- /* @__PURE__ */ r("div", { className: "flight-info", children: /* @__PURE__ */ e("div", { className: "flight-locations", children: [
42
- /* @__PURE__ */ r("div", { className: "airlines", children: T.map((a, s) => /* @__PURE__ */ r(I.Fragment, { children: /* @__PURE__ */ e("div", { className: "tip", children: [
43
- /* @__PURE__ */ r("img", { src: a.logo, alt: a.airline }),
44
- /* @__PURE__ */ r("span", { className: "right", children: a.airline })
40
+ return /* @__PURE__ */ e("div", { className: "flight-result", onClick: L, children: /* @__PURE__ */ r("div", { className: "content", children: [
41
+ /* @__PURE__ */ e("div", { className: "flight-info", children: /* @__PURE__ */ r("div", { className: "flight-locations", children: [
42
+ /* @__PURE__ */ e("div", { className: "airlines", children: I.map((a, s) => /* @__PURE__ */ e(x.Fragment, { children: /* @__PURE__ */ r("div", { className: "tip", children: [
43
+ /* @__PURE__ */ e("img", { src: a.logo, alt: a.airline }),
44
+ /* @__PURE__ */ e("span", { className: "right", children: a.airline })
45
45
  ] }, s) }, s)) }),
46
- /* @__PURE__ */ e("div", { className: "flight-location", children: [
47
- /* @__PURE__ */ e("p", { className: "show-desktop", children: [
46
+ /* @__PURE__ */ r("div", { className: "flight-location", children: [
47
+ /* @__PURE__ */ r("p", { className: "show-desktop", children: [
48
48
  n.city,
49
49
  ",",
50
- y(n.country)
50
+ O(n.country)
51
51
  ] }),
52
- /* @__PURE__ */ r("p", { className: "show-desktop", children: h(i.departureTime).format(
52
+ /* @__PURE__ */ e("p", { className: "show-desktop", children: h(i.departureTime).format(
53
53
  c.FlightShortDate
54
54
  ) }),
55
- /* @__PURE__ */ r("p", { className: "show-mobile", children: n.airportCode }),
56
- /* @__PURE__ */ r("p", { className: "show-mobile", children: h(i.departureTime).format(c.FlightTime) })
55
+ /* @__PURE__ */ e("p", { className: "show-mobile", children: n.airportCode }),
56
+ /* @__PURE__ */ e("p", { className: "show-mobile", children: h(i.departureTime).format(c.FlightTime) })
57
57
  ] }),
58
- /* @__PURE__ */ e("div", { className: "flight-duration", children: [
59
- /* @__PURE__ */ r("span", { className: "line" }),
60
- /* @__PURE__ */ e("p", { children: [
61
- H(f.slices[0].duration),
58
+ /* @__PURE__ */ r("div", { className: "flight-duration", children: [
59
+ /* @__PURE__ */ e("span", { className: "line" }),
60
+ /* @__PURE__ */ r("p", { children: [
61
+ q(f.slices[0].duration),
62
62
  " ",
63
63
  " - ",
64
64
  i.numberOfStops > 0 ? `${i.numberOfStops} Stop${i.numberOfStops > 1 ? "s" : ""}` : "Direct"
65
65
  ] }),
66
- /* @__PURE__ */ r("span", { className: "line" })
66
+ /* @__PURE__ */ e("span", { className: "line" })
67
67
  ] }),
68
- /* @__PURE__ */ e("div", { children: [
69
- /* @__PURE__ */ e("p", { className: "show-desktop", children: [
68
+ /* @__PURE__ */ r("div", { children: [
69
+ /* @__PURE__ */ r("p", { className: "show-desktop", children: [
70
70
  t.city,
71
71
  ", ",
72
- y(t.country)
72
+ O(t.country)
73
73
  ] }),
74
- /* @__PURE__ */ e("p", { className: "show-desktop", children: [
74
+ /* @__PURE__ */ r("p", { className: "show-desktop", children: [
75
75
  h(i.arrivalTime).format(
76
76
  c.FlightShortDate
77
77
  ),
78
78
  " "
79
79
  ] }),
80
- /* @__PURE__ */ r("p", { className: "show-mobile", children: t.airportCode }),
81
- /* @__PURE__ */ r("p", { className: "show-mobile", children: h(i.arrivalTime).format(c.FlightTime) })
80
+ /* @__PURE__ */ e("p", { className: "show-mobile", children: t.airportCode }),
81
+ /* @__PURE__ */ e("p", { className: "show-mobile", children: h(i.arrivalTime).format(c.FlightTime) })
82
82
  ] })
83
83
  ] }) }),
84
- /* @__PURE__ */ e("div", { className: "flight-footer", children: [
85
- /* @__PURE__ */ e("div", { className: "flight-detail-container", children: [
86
- /* @__PURE__ */ e(
84
+ /* @__PURE__ */ r("div", { className: "flight-footer", children: [
85
+ /* @__PURE__ */ r("div", { className: "flight-detail-container", children: [
86
+ /* @__PURE__ */ r(
87
87
  "div",
88
88
  {
89
89
  className: "flight-detail",
90
90
  onClick: (a) => {
91
- a.stopPropagation(), D(!d);
91
+ a.stopPropagation(), T(!d);
92
92
  },
93
93
  children: [
94
- /* @__PURE__ */ r("p", { children: "Aircraft" }),
95
- /* @__PURE__ */ e("p", { className: "chevron-text", children: [
96
- /* @__PURE__ */ r(R, {}),
97
- /* @__PURE__ */ e("span", { children: [
94
+ /* @__PURE__ */ e("p", { children: "Aircraft" }),
95
+ /* @__PURE__ */ r("p", { className: "chevron-text", children: [
96
+ /* @__PURE__ */ e(H, {}),
97
+ /* @__PURE__ */ r("span", { children: [
98
98
  p[0],
99
- p.length > 1 && /* @__PURE__ */ e("sup", { children: [
99
+ p.length > 1 && /* @__PURE__ */ r("sup", { children: [
100
100
  "+",
101
101
  p.length - 1
102
102
  ] })
@@ -105,13 +105,13 @@ const ii = ({ details: i, onClick: o }) => {
105
105
  ]
106
106
  }
107
107
  ),
108
- i.cabinClass && /* @__PURE__ */ e("div", { className: "flight-detail", children: [
109
- /* @__PURE__ */ r("p", { children: "Class" }),
110
- /* @__PURE__ */ r("p", { children: i.cabinClass })
108
+ i.cabinClass && /* @__PURE__ */ r("div", { className: "flight-detail", children: [
109
+ /* @__PURE__ */ e("p", { children: "Class" }),
110
+ /* @__PURE__ */ e("p", { children: i.cabinClass })
111
111
  ] })
112
112
  ] }),
113
- /* @__PURE__ */ e("div", { className: "booking-options", children: [
114
- i.cash > 0 && /* @__PURE__ */ e(
113
+ /* @__PURE__ */ r("div", { className: "booking-options", children: [
114
+ i.cash > 0 && /* @__PURE__ */ r(
115
115
  "div",
116
116
  {
117
117
  className: "cash-value",
@@ -119,11 +119,11 @@ const ii = ({ details: i, onClick: o }) => {
119
119
  a.stopPropagation(), o(i, m.CASH);
120
120
  },
121
121
  children: [
122
- /* @__PURE__ */ r("img", { src: i.airlineLogo }),
123
- /* @__PURE__ */ e("div", { children: [
124
- /* @__PURE__ */ r("label", { children: N ? "Book For" : "From" }),
125
- /* @__PURE__ */ r(
126
- C,
122
+ /* @__PURE__ */ e("img", { src: i.airlineLogo }),
123
+ /* @__PURE__ */ r("div", { children: [
124
+ /* @__PURE__ */ e("label", { children: k ? "Book For" : "From" }),
125
+ /* @__PURE__ */ e(
126
+ P,
127
127
  {
128
128
  amount: i.cash,
129
129
  currency: i.currency
@@ -133,7 +133,7 @@ const ii = ({ details: i, onClick: o }) => {
133
133
  ]
134
134
  }
135
135
  ),
136
- i.points > 0 && /* @__PURE__ */ e(
136
+ i.points > 0 && /* @__PURE__ */ r(
137
137
  "div",
138
138
  {
139
139
  className: "points-value",
@@ -141,20 +141,20 @@ const ii = ({ details: i, onClick: o }) => {
141
141
  a.stopPropagation(), o(i, m.POINTS);
142
142
  },
143
143
  children: [
144
- /* @__PURE__ */ r("img", { src: S.programLogo }),
145
- /* @__PURE__ */ e("div", { children: [
146
- /* @__PURE__ */ r("label", { children: N ? "Book For" : "From" }),
147
- /* @__PURE__ */ e("p", { children: [
148
- `${z(i.points)} miles`,
149
- ((u = i.cashFee) == null ? void 0 : u.amount) > 0 && /* @__PURE__ */ e(E, { children: [
144
+ /* @__PURE__ */ e("img", { src: b.programLogo }),
145
+ /* @__PURE__ */ r("div", { children: [
146
+ /* @__PURE__ */ e("label", { children: A ? "Book For" : "From" }),
147
+ /* @__PURE__ */ r("p", { children: [
148
+ `${Q(i.points)} miles`,
149
+ ((u = i.cashFee) == null ? void 0 : u.amount) > 0 && /* @__PURE__ */ r($, { children: [
150
150
  " + ",
151
- /* @__PURE__ */ r(
152
- C,
151
+ /* @__PURE__ */ e(
152
+ P,
153
153
  {
154
- amount: i.cashFee.amount,
155
- currency: i.cashFee.currency,
154
+ amount: (F = (v = i.paymentOptions[0]) == null ? void 0 : v.cashFee) == null ? void 0 : F.amount,
155
+ currency: (C = (y = i.paymentOptions[0]) == null ? void 0 : y.cashFee) == null ? void 0 : C.currency,
156
156
  customDisplay: "No fee",
157
- zeroDisplayOption: U.CUSTOM
157
+ zeroDisplayOption: J.CUSTOM
158
158
  }
159
159
  )
160
160
  ] })
@@ -165,17 +165,17 @@ const ii = ({ details: i, onClick: o }) => {
165
165
  )
166
166
  ] })
167
167
  ] }),
168
- /* @__PURE__ */ r("div", { className: `flight-details ${d ? "is-open" : ""}`, children: /* @__PURE__ */ r("div", { className: "inner", children: /* @__PURE__ */ r(
169
- B,
168
+ /* @__PURE__ */ e("div", { className: `flight-details ${d ? "is-open" : ""}`, children: /* @__PURE__ */ e("div", { className: "inner", children: /* @__PURE__ */ e(
169
+ U,
170
170
  {
171
171
  itinerary: f.slices[0].segments,
172
172
  origin: n,
173
173
  destination: t,
174
- isMultiDayFlight: A
174
+ isMultiDayFlight: R
175
175
  }
176
176
  ) }) })
177
177
  ] }) });
178
178
  };
179
179
  export {
180
- ii as FlightResult
180
+ ni as FlightResult
181
181
  };
@@ -23,8 +23,8 @@ function se(e) {
23
23
  let a = 0;
24
24
  for (; o < u; ) {
25
25
  s && (n[o] === 10 && (a = ++o), s = !1);
26
- let l = -1;
27
- for (; o < u && l === -1; ++o)
26
+ let d = -1;
27
+ for (; o < u && d === -1; ++o)
28
28
  switch (n[o]) {
29
29
  case 58:
30
30
  r === -1 && (r = o - a);
@@ -32,12 +32,12 @@ function se(e) {
32
32
  case 13:
33
33
  s = !0;
34
34
  case 10:
35
- l = o;
35
+ d = o;
36
36
  break;
37
37
  }
38
- if (l === -1)
38
+ if (d === -1)
39
39
  break;
40
- e(n.subarray(a, l), r), a = o, r = -1;
40
+ e(n.subarray(a, d), r), a = o, r = -1;
41
41
  }
42
42
  a === u ? n = void 0 : a !== 0 && (n = n.subarray(a), o -= a);
43
43
  };
@@ -49,21 +49,21 @@ function ae(e, n, o) {
49
49
  if (c.length === 0)
50
50
  o == null || o(r), r = Y();
51
51
  else if (u > 0) {
52
- const a = s.decode(c.subarray(0, u)), l = u + (c[u + 1] === 32 ? 2 : 1), b = s.decode(c.subarray(l));
52
+ const a = s.decode(c.subarray(0, u)), d = u + (c[u + 1] === 32 ? 2 : 1), g = s.decode(c.subarray(d));
53
53
  switch (a) {
54
54
  case "data":
55
55
  r.data = r.data ? r.data + `
56
- ` + b : b;
56
+ ` + g : g;
57
57
  break;
58
58
  case "event":
59
- r.event = b;
59
+ r.event = g;
60
60
  break;
61
61
  case "id":
62
- e(r.id = b);
62
+ e(r.id = g);
63
63
  break;
64
64
  case "retry":
65
- const g = parseInt(b, 10);
66
- isNaN(g) || n(r.retry = g);
65
+ const m = parseInt(g, 10);
66
+ isNaN(m) || n(r.retry = m);
67
67
  break;
68
68
  }
69
69
  }
@@ -90,36 +90,36 @@ var ue = function(e, n) {
90
90
  return o;
91
91
  };
92
92
  const G = "text/event-stream", ce = 1e3, W = "last-event-id";
93
- function de(e, n) {
94
- var { signal: o, headers: r, onopen: s, onmessage: E, onclose: c, onerror: u, openWhenHidden: a, fetch: l } = n, b = ue(n, ["signal", "headers", "onopen", "onmessage", "onclose", "onerror", "openWhenHidden", "fetch"]);
95
- return new Promise((g, _) => {
93
+ function le(e, n) {
94
+ var { signal: o, headers: r, onopen: s, onmessage: E, onclose: c, onerror: u, openWhenHidden: a, fetch: d } = n, g = ue(n, ["signal", "headers", "onopen", "onmessage", "onclose", "onerror", "openWhenHidden", "fetch"]);
95
+ return new Promise((m, _) => {
96
96
  const p = Object.assign({}, r);
97
97
  p.accept || (p.accept = G);
98
- let m;
98
+ let S;
99
99
  function R() {
100
- m.abort(), document.hidden || v();
100
+ S.abort(), document.hidden || v();
101
101
  }
102
102
  a || document.addEventListener("visibilitychange", R);
103
103
  let A = ce, I = 0;
104
104
  function T() {
105
- document.removeEventListener("visibilitychange", R), window.clearTimeout(I), m.abort();
105
+ document.removeEventListener("visibilitychange", R), window.clearTimeout(I), S.abort();
106
106
  }
107
107
  o == null || o.addEventListener("abort", () => {
108
- T(), g();
108
+ T(), m();
109
109
  });
110
- const P = l ?? window.fetch, q = s ?? le;
110
+ const P = d ?? window.fetch, q = s ?? de;
111
111
  async function v() {
112
112
  var w;
113
- m = new AbortController();
113
+ S = new AbortController();
114
114
  try {
115
- const C = await P(e, Object.assign(Object.assign({}, b), { headers: p, signal: m.signal }));
115
+ const C = await P(e, Object.assign(Object.assign({}, g), { headers: p, signal: S.signal }));
116
116
  await q(C), await oe(C.body, se(ae((h) => {
117
117
  h ? p[W] = h : delete p[W];
118
118
  }, (h) => {
119
119
  A = h;
120
- }, E))), c == null || c(), T(), g();
120
+ }, E))), c == null || c(), T(), m();
121
121
  } catch (C) {
122
- if (!m.signal.aborted)
122
+ if (!S.signal.aborted)
123
123
  try {
124
124
  const h = (w = u == null ? void 0 : u(C)) !== null && w !== void 0 ? w : A;
125
125
  window.clearTimeout(I), I = window.setTimeout(v, h);
@@ -131,7 +131,7 @@ function de(e, n) {
131
131
  v();
132
132
  });
133
133
  }
134
- function le(e) {
134
+ function de(e) {
135
135
  const n = e.headers.get("content-type");
136
136
  if (!(n != null && n.startsWith(G)))
137
137
  throw new Error(`Expected content-type to be ${G}, Actual: ${n}`);
@@ -147,18 +147,18 @@ const fe = 3 * 60 * 1e3, V = (e) => {
147
147
  throw new Error("Return date is required for round-trip flights.");
148
148
  }, ve = () => {
149
149
  const { token: e, config: n } = ne(), [o, r] = H(""), [s, E] = H([]), [c, u] = H(!1), a = J(null), {
150
- inboundResults: l,
151
- outboundResults: b,
152
- setInboundResults: g,
150
+ inboundResults: d,
151
+ outboundResults: g,
152
+ setInboundResults: m,
153
153
  setOutboundResults: _,
154
154
  partialOfferRequestId: p,
155
- setPartialOfferRequestId: m
155
+ setPartialOfferRequestId: S
156
156
  } = te(), R = ({
157
157
  data: t,
158
158
  inbound: f
159
159
  }) => {
160
- const d = Z(t);
161
- return (f ? g : _)(Q(d)), d;
160
+ const l = Z(t);
161
+ return (f ? m : _)(Q(l)), l;
162
162
  }, {
163
163
  mutate: A,
164
164
  status: I,
@@ -166,7 +166,7 @@ const fe = 3 * 60 * 1e3, V = (e) => {
166
166
  } = k({
167
167
  mutationFn: async (t) => {
168
168
  V(t);
169
- const d = {
169
+ const l = {
170
170
  passengers: Array.from(
171
171
  { length: t.passengers ?? z },
172
172
  () => ({ type: "adult" })
@@ -177,7 +177,7 @@ const fe = 3 * 60 * 1e3, V = (e) => {
177
177
  };
178
178
  if (t.flightType === $.ONE_WAY) {
179
179
  const i = await D.cashOnlySearch({
180
- ...d,
180
+ ...l,
181
181
  departure_date: t.departureDate
182
182
  });
183
183
  return {
@@ -186,7 +186,7 @@ const fe = 3 * 60 * 1e3, V = (e) => {
186
186
  };
187
187
  } else {
188
188
  const i = await D.roundTripOutboundSearch({
189
- ...d,
189
+ ...l,
190
190
  departure_date: t.departureDate,
191
191
  return_date: t.returnDate
192
192
  });
@@ -198,12 +198,12 @@ const fe = 3 * 60 * 1e3, V = (e) => {
198
198
  }
199
199
  },
200
200
  onSuccess: (t) => {
201
- const { success: f, data: d, partialOfferRequestId: i } = t;
201
+ const { success: f, data: l, partialOfferRequestId: i } = t;
202
202
  if (!f) {
203
203
  console.log("oh lol, it didn't work");
204
204
  return;
205
205
  }
206
- R({ data: d }), i && m(i);
206
+ R({ data: l }), i && S(i);
207
207
  },
208
208
  onError: (t) => {
209
209
  console.error("Error in outbound flight search:", t);
@@ -225,9 +225,9 @@ const fe = 3 * 60 * 1e3, V = (e) => {
225
225
  });
226
226
  },
227
227
  onSuccess: (t) => {
228
- const { success: f, data: d } = t;
228
+ const { success: f, data: l } = t;
229
229
  f && R({
230
- data: d.offers,
230
+ data: l.offers,
231
231
  inbound: !0
232
232
  });
233
233
  },
@@ -252,9 +252,9 @@ const fe = 3 * 60 * 1e3, V = (e) => {
252
252
  });
253
253
  },
254
254
  onSuccess: (t) => {
255
- const { success: f, data: d } = t;
255
+ const { success: f, data: l } = t;
256
256
  if (!f) return;
257
- const i = d.offers;
257
+ const i = l.offers;
258
258
  E(B(i));
259
259
  },
260
260
  onError: (t) => {
@@ -266,7 +266,7 @@ const fe = 3 * 60 * 1e3, V = (e) => {
266
266
  }), j = async (t) => {
267
267
  var x;
268
268
  u(!0);
269
- const f = t.paymentType === F.CASH_AND_MILES ? ['"cash"', '"points"'] : ['"points"'], d = ee({
269
+ const f = t.paymentType === F.CASH_AND_MILES ? ['"cash"', '"points"'] : ['"points"'], l = ee({
270
270
  originCode: t.origin,
271
271
  destinationCode: t.destination,
272
272
  departureDate: t.departureDate,
@@ -276,8 +276,8 @@ const fe = 3 * 60 * 1e3, V = (e) => {
276
276
  });
277
277
  let i = [], M = 0;
278
278
  U = new AbortController(), a.current = setTimeout(() => {
279
- S();
280
- }, (((x = n == null ? void 0 : n.flightsConfig) == null ? void 0 : x.streamTimeoutTotalSeconds) || fe) * 1e3), de(re() + d, {
279
+ O();
280
+ }, (((x = n == null ? void 0 : n.flightsConfig) == null ? void 0 : x.streamTimeoutTotalSeconds) || fe) * 1e3), le(re() + l, {
281
281
  headers: {
282
282
  "Content-Type": "application/json",
283
283
  Authorization: e || "",
@@ -287,29 +287,27 @@ const fe = 3 * 60 * 1e3, V = (e) => {
287
287
  signal: U.signal,
288
288
  onmessage(N) {
289
289
  try {
290
- const O = B(JSON.parse(N.data));
291
- if (O.success === !1)
290
+ const b = B(JSON.parse(N.data));
291
+ if (b.success === !1)
292
292
  return;
293
- if (O.close === !0) {
294
- S();
293
+ if (b.close === !0) {
294
+ O();
295
295
  return;
296
296
  }
297
- O.flights && (M = 0, i = [...i, ...O.flights], R({
298
- data: i
299
- })), O.ping && (M++, M >= n.flightsConfig.streamTimeoutPingCount && S());
300
- } catch (O) {
301
- console.error("Error parsing message:", O), S();
297
+ b.status === 200 && b.flights && b.flights.length > 0 && (M = 0, i = [...i, ...b.flights], R({ data: i })), b.ping && (M++, M >= n.flightsConfig.streamTimeoutPingCount && O());
298
+ } catch (b) {
299
+ console.error("Error parsing message:", b), O();
302
300
  }
303
301
  },
304
302
  onerror(N) {
305
- throw console.error("EventSource error:", N), S(), N;
303
+ throw console.error("EventSource error:", N), O(), N;
306
304
  },
307
305
  onclose() {
308
- S();
306
+ O();
309
307
  },
310
308
  keepalive: !1
311
309
  });
312
- }, S = () => {
310
+ }, O = () => {
313
311
  U.abort(), a.current && (clearTimeout(a.current), a.current = null), u(!1), L.invalidateQueries({ queryKey: [y.SEARCH_LIMIT] });
314
312
  };
315
313
  return {
@@ -329,8 +327,8 @@ const fe = 3 * 60 * 1e3, V = (e) => {
329
327
  inboundError: v,
330
328
  roundTripFaresError: h,
331
329
  // Results
332
- outboundResults: b,
333
- inboundResults: l,
330
+ outboundResults: g,
331
+ inboundResults: d,
334
332
  roundTripFares: s,
335
333
  // Mutation triggers
336
334
  /**
@@ -340,7 +338,7 @@ const fe = 3 * 60 * 1e3, V = (e) => {
340
338
  * @param {ISearchFlightArgs} args - The search arguments
341
339
  */
342
340
  searchOutboundFlights: async (t) => {
343
- switch (V(t), _([]), S(), t.paymentType) {
341
+ switch (V(t), _([]), O(), t.paymentType) {
344
342
  default:
345
343
  case F.CASH_AND_MILES:
346
344
  j(t);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@odynn/awayz-flights",
3
- "version": "0.3.2",
3
+ "version": "0.3.4",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"
@@ -64,7 +64,7 @@
64
64
  },
65
65
  "dependencies": {
66
66
  "@microsoft/fetch-event-source": "^2.0.1",
67
- "@odynn/awayz-core": "^0.3.9",
67
+ "@odynn/awayz-core": "^0.3.14",
68
68
  "@tanstack/react-query": "^5.67.1",
69
69
  "country-code-lookup": "^0.1.3"
70
70
  }