@odynn/awayz-flights 0.3.9 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  import { jsxs as a, jsx as c, Fragment as E } from "react/jsx-runtime";
2
2
  import h, { useMemo as q } from "react";
3
3
  import { h as P } from "./moment-BGjjqtLQ.js";
4
- import { a as $, b as z, d as k, D as J } from "./index-D0Heof44.js";
4
+ import { c as $, a as z, b as k, D as J } from "./index-7zRjF0bU.js";
5
5
  import { l as Q } from "./arrayExtensions-DFLvtO8l.js";
6
6
  import './assets/FlightItinerary.css';const X = (e) => e ? e.charAt(0).toUpperCase() + e.slice(1).toLowerCase() : "", S = (e) => {
7
7
  var t;
@@ -0,0 +1,188 @@
1
+ import { jsx as e, jsxs as a, Fragment as H } from "react/jsx-runtime";
2
+ import U, { useState as T, useMemo as _ } from "react";
3
+ import { g as k, E as c, F as z, a as G } from "./FlightItinerary-VggJiPkC.js";
4
+ import { DEFAULT_AIRLINE_PROGRAM as V, getFlightNumber as q, getLogoPath as J, getAirlineProgram as K } from "./utils/flightUtils.js";
5
+ import { h } from "./moment-BGjjqtLQ.js";
6
+ import { g as Q } from "./index-7zRjF0bU.js";
7
+ import "./arrayExtensions-DFLvtO8l.js";
8
+ import { EPaymentType as m } from "./enums/EPaymentType.js";
9
+ import { CashValue as A, EInvalidAmountDisplayOption as W } from "@odynn/awayz-core";
10
+ import { isSameDayFlight as X } from "./utils/flightDateUtils.js";
11
+ import './assets/FlightResult.css';function Y(i) {
12
+ if (!i || isNaN(i) || i < 0) return "N/A";
13
+ let o = i == null ? void 0 : i.toString().split(".")[0];
14
+ return o == null ? void 0 : o.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
15
+ }
16
+ const ci = ({ details: i, onClick: o }) => {
17
+ var u, v, F, y, C, D, S, O;
18
+ const [d, b] = T(!1), n = i.origin, t = i.destination, f = i.flightDetails, N = i.paymentOptions || [], w = N.filter((r) => r.points === -1).length === 1, E = N.filter((r) => r.points > -1).length === 1, [I, L] = T(V), R = async () => {
19
+ const r = await K(i.airlineProgram);
20
+ L(r);
21
+ }, { flightNumbers: p, airlines: B } = _(() => {
22
+ const r = [], s = [];
23
+ return i.flightDetails.slices.forEach((x) => {
24
+ x.segments.forEach((l) => {
25
+ const P = q(l);
26
+ r.includes(P) || r.push(P);
27
+ const g = l.operatingCarrierFlightNumber ? l.operatingCarrier : l.marketingCarrier;
28
+ s.some((j) => j.airline === g.name) || s.push({
29
+ logo: J(g.iataCode),
30
+ airline: g.name
31
+ });
32
+ });
33
+ }), R(), { flightNumbers: r, airlines: s };
34
+ }, [i.flightDetails.slices]), M = () => {
35
+ i.cash > 0 ? o(i, m.CASH) : o(i, m.POINTS);
36
+ }, $ = !X(
37
+ i.departureTime,
38
+ i.arrivalTime
39
+ );
40
+ return /* @__PURE__ */ e("div", { className: "flight-result", onClick: M, children: /* @__PURE__ */ a("div", { className: "content", children: [
41
+ /* @__PURE__ */ e("div", { className: "flight-info", children: /* @__PURE__ */ a("div", { className: "flight-locations", children: [
42
+ /* @__PURE__ */ e("div", { className: "airlines", children: B.map((r, s) => /* @__PURE__ */ e(U.Fragment, { children: /* @__PURE__ */ a("div", { className: "tip", children: [
43
+ /* @__PURE__ */ e("img", { src: r.logo, alt: r.airline }),
44
+ /* @__PURE__ */ e("span", { className: "right", children: r.airline })
45
+ ] }, s) }, s)) }),
46
+ /* @__PURE__ */ a("div", { className: "flight-location", children: [
47
+ /* @__PURE__ */ a("p", { className: "show-desktop", children: [
48
+ n.city,
49
+ ",",
50
+ k(n.country)
51
+ ] }),
52
+ /* @__PURE__ */ e("p", { className: "show-desktop", children: h(i.departureTime).format(
53
+ c.FlightShortDate
54
+ ) }),
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
+ ] }),
58
+ /* @__PURE__ */ a("div", { className: "flight-duration", children: [
59
+ /* @__PURE__ */ e("span", { className: "line" }),
60
+ /* @__PURE__ */ a("p", { children: [
61
+ Q(f.slices[0].duration),
62
+ " ",
63
+ " - ",
64
+ i.numberOfStops > 0 ? `${i.numberOfStops} Stop${i.numberOfStops > 1 ? "s" : ""}` : "Direct"
65
+ ] }),
66
+ /* @__PURE__ */ e("span", { className: "line" })
67
+ ] }),
68
+ /* @__PURE__ */ a("div", { children: [
69
+ /* @__PURE__ */ a("p", { className: "show-desktop", children: [
70
+ t.city,
71
+ ", ",
72
+ k(t.country)
73
+ ] }),
74
+ /* @__PURE__ */ a("p", { className: "show-desktop", children: [
75
+ h(i.arrivalTime).format(
76
+ c.FlightShortDate
77
+ ),
78
+ " "
79
+ ] }),
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
+ ] })
83
+ ] }) }),
84
+ /* @__PURE__ */ a("div", { className: "flight-footer", children: [
85
+ /* @__PURE__ */ a("div", { className: "flight-detail-container", children: [
86
+ /* @__PURE__ */ a(
87
+ "div",
88
+ {
89
+ className: "flight-detail",
90
+ onClick: (r) => {
91
+ r.stopPropagation(), b(!d);
92
+ },
93
+ children: [
94
+ /* @__PURE__ */ e("p", { children: "Aircraft" }),
95
+ /* @__PURE__ */ a("p", { className: "chevron-text", children: [
96
+ /* @__PURE__ */ e(z, {}),
97
+ /* @__PURE__ */ a("span", { children: [
98
+ p[0],
99
+ p.length > 1 && /* @__PURE__ */ a("sup", { children: [
100
+ "+",
101
+ p.length - 1
102
+ ] })
103
+ ] })
104
+ ] })
105
+ ]
106
+ }
107
+ ),
108
+ i.cabinClass && /* @__PURE__ */ a("div", { className: "flight-detail", children: [
109
+ /* @__PURE__ */ e("p", { children: "Class" }),
110
+ /* @__PURE__ */ e("p", { children: i.cabinClass })
111
+ ] })
112
+ ] }),
113
+ /* @__PURE__ */ a("div", { className: "booking-options", children: [
114
+ i.cash > 0 && /* @__PURE__ */ a(
115
+ "div",
116
+ {
117
+ className: "cash-value",
118
+ onClick: (r) => {
119
+ r.stopPropagation(), o(i, m.CASH);
120
+ },
121
+ children: [
122
+ /* @__PURE__ */ e("img", { src: i.airlineLogo }),
123
+ /* @__PURE__ */ a("div", { children: [
124
+ /* @__PURE__ */ e("label", { children: w ? "Book For" : "From" }),
125
+ /* @__PURE__ */ e(
126
+ A,
127
+ {
128
+ amount: i.cash,
129
+ currency: i.currency
130
+ }
131
+ )
132
+ ] })
133
+ ]
134
+ }
135
+ ),
136
+ i.points > 0 && /* @__PURE__ */ a(
137
+ "div",
138
+ {
139
+ className: "points-value",
140
+ onClick: (r) => {
141
+ r.stopPropagation(), o(i, m.POINTS);
142
+ },
143
+ children: [
144
+ /* @__PURE__ */ e("img", { src: I.programLogo }),
145
+ /* @__PURE__ */ a("div", { children: [
146
+ /* @__PURE__ */ e("label", { children: E ? "Book For" : "From" }),
147
+ /* @__PURE__ */ a("p", { children: [
148
+ `${Y(i.points)} miles`,
149
+ ((u = i.cashFee) == null ? void 0 : u.amount) > 0 || (((y = (F = (v = i.paymentOptions) == null ? void 0 : v.find(
150
+ (r) => r.points > -1
151
+ )) == null ? void 0 : F.cashFee) == null ? void 0 : y.amount) ?? 0) > 0 && /* @__PURE__ */ a(H, { children: [
152
+ " + ",
153
+ /* @__PURE__ */ e(
154
+ A,
155
+ {
156
+ amount: ((D = (C = i.paymentOptions.find(
157
+ (r) => r.points > -1
158
+ )) == null ? void 0 : C.cashFee) == null ? void 0 : D.amount) ?? 0,
159
+ currency: ((O = (S = i.paymentOptions.find(
160
+ (r) => r.points > -1
161
+ )) == null ? void 0 : S.cashFee) == null ? void 0 : O.currency) ?? "",
162
+ customDisplay: "No fee",
163
+ zeroDisplayOption: W.CUSTOM
164
+ }
165
+ )
166
+ ] })
167
+ ] })
168
+ ] })
169
+ ]
170
+ }
171
+ )
172
+ ] })
173
+ ] }),
174
+ /* @__PURE__ */ e("div", { className: `flight-details ${d ? "is-open" : ""}`, children: /* @__PURE__ */ e("div", { className: "inner", children: /* @__PURE__ */ e(
175
+ G,
176
+ {
177
+ itinerary: f.slices[0].segments,
178
+ origin: n,
179
+ destination: t,
180
+ isMultiDayFlight: $
181
+ }
182
+ ) }) })
183
+ ] }) });
184
+ };
185
+ export {
186
+ ci as F,
187
+ Y as c
188
+ };
@@ -1,8 +1,8 @@
1
1
  import "react/jsx-runtime";
2
2
  import "react";
3
3
  import "../../moment-BGjjqtLQ.js";
4
- import { a as e } from "../../FlightItinerary-B_uX-d7I.js";
5
- import "../../index-D0Heof44.js";
4
+ import { a as e } from "../../FlightItinerary-VggJiPkC.js";
5
+ import "../../index-7zRjF0bU.js";
6
6
  import "../../arrayExtensions-DFLvtO8l.js";
7
7
  export {
8
8
  e as default
@@ -1,187 +1,14 @@
1
- import { jsx as e, jsxs as a, Fragment as H } from "react/jsx-runtime";
2
- import U, { useState as T, useMemo as _ } from "react";
3
- import { g as k, E as c, F as z, a as G } from "../../FlightItinerary-B_uX-d7I.js";
4
- import { DEFAULT_AIRLINE_PROGRAM as V, getFlightNumber as q, getLogoPath as J, getAirlineProgram as K } from "../../utils/flightUtils.js";
5
- import { h } from "../../moment-BGjjqtLQ.js";
6
- import { g as Q } from "../../index-D0Heof44.js";
1
+ import "react/jsx-runtime";
2
+ import "react";
3
+ import { F as g } from "../../FlightResult-DLe2iE7E.js";
4
+ import "../../FlightItinerary-VggJiPkC.js";
5
+ import "../../utils/flightUtils.js";
6
+ import "../../moment-BGjjqtLQ.js";
7
+ import "../../index-7zRjF0bU.js";
7
8
  import "../../arrayExtensions-DFLvtO8l.js";
8
- import { EPaymentType as m } from "../../enums/EPaymentType.js";
9
- import { CashValue as A, EInvalidAmountDisplayOption as W } from "@odynn/awayz-core";
10
- import { isSameDayFlight as X } from "../../utils/flightDateUtils.js";
11
- import '../../assets/FlightResult.css';function Y(i) {
12
- if (!i || isNaN(i) || i < 0) return "N/A";
13
- let o = i == null ? void 0 : i.toString().split(".")[0];
14
- return o == null ? void 0 : o.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
15
- }
16
- const ci = ({ details: i, onClick: o }) => {
17
- var u, v, F, y, C, D, S, O;
18
- const [d, b] = T(!1), s = i.origin, t = i.destination, f = i.flightDetails, N = i.paymentOptions || [], w = N.filter((r) => r.points === -1).length === 1, E = N.filter((r) => r.points > -1).length === 1, [I, L] = T(V), R = async () => {
19
- const r = await K(i.airlineProgram);
20
- L(r);
21
- }, { flightNumbers: p, airlines: B } = _(() => {
22
- const r = [], n = [];
23
- return i.flightDetails.slices.forEach((x) => {
24
- x.segments.forEach((l) => {
25
- const P = q(l);
26
- r.includes(P) || r.push(P);
27
- const g = l.operatingCarrierFlightNumber ? l.operatingCarrier : l.marketingCarrier;
28
- n.some((j) => j.airline === g.name) || n.push({
29
- logo: J(g.iataCode),
30
- airline: g.name
31
- });
32
- });
33
- }), R(), { flightNumbers: r, airlines: n };
34
- }, [i.flightDetails.slices]), M = () => {
35
- i.cash > 0 ? o(i, m.CASH) : o(i, m.POINTS);
36
- }, $ = !X(
37
- i.departureTime,
38
- i.arrivalTime
39
- );
40
- return /* @__PURE__ */ e("div", { className: "flight-result", onClick: M, children: /* @__PURE__ */ a("div", { className: "content", children: [
41
- /* @__PURE__ */ e("div", { className: "flight-info", children: /* @__PURE__ */ a("div", { className: "flight-locations", children: [
42
- /* @__PURE__ */ e("div", { className: "airlines", children: B.map((r, n) => /* @__PURE__ */ e(U.Fragment, { children: /* @__PURE__ */ a("div", { className: "tip", children: [
43
- /* @__PURE__ */ e("img", { src: r.logo, alt: r.airline }),
44
- /* @__PURE__ */ e("span", { className: "right", children: r.airline })
45
- ] }, n) }, n)) }),
46
- /* @__PURE__ */ a("div", { className: "flight-location", children: [
47
- /* @__PURE__ */ a("p", { className: "show-desktop", children: [
48
- s.city,
49
- ",",
50
- k(s.country)
51
- ] }),
52
- /* @__PURE__ */ e("p", { className: "show-desktop", children: h(i.departureTime).format(
53
- c.FlightShortDate
54
- ) }),
55
- /* @__PURE__ */ e("p", { className: "show-mobile", children: s.airportCode }),
56
- /* @__PURE__ */ e("p", { className: "show-mobile", children: h(i.departureTime).format(c.FlightTime) })
57
- ] }),
58
- /* @__PURE__ */ a("div", { className: "flight-duration", children: [
59
- /* @__PURE__ */ e("span", { className: "line" }),
60
- /* @__PURE__ */ a("p", { children: [
61
- Q(f.slices[0].duration),
62
- " ",
63
- " - ",
64
- i.numberOfStops > 0 ? `${i.numberOfStops} Stop${i.numberOfStops > 1 ? "s" : ""}` : "Direct"
65
- ] }),
66
- /* @__PURE__ */ e("span", { className: "line" })
67
- ] }),
68
- /* @__PURE__ */ a("div", { children: [
69
- /* @__PURE__ */ a("p", { className: "show-desktop", children: [
70
- t.city,
71
- ", ",
72
- k(t.country)
73
- ] }),
74
- /* @__PURE__ */ a("p", { className: "show-desktop", children: [
75
- h(i.arrivalTime).format(
76
- c.FlightShortDate
77
- ),
78
- " "
79
- ] }),
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
- ] })
83
- ] }) }),
84
- /* @__PURE__ */ a("div", { className: "flight-footer", children: [
85
- /* @__PURE__ */ a("div", { className: "flight-detail-container", children: [
86
- /* @__PURE__ */ a(
87
- "div",
88
- {
89
- className: "flight-detail",
90
- onClick: (r) => {
91
- r.stopPropagation(), b(!d);
92
- },
93
- children: [
94
- /* @__PURE__ */ e("p", { children: "Aircraft" }),
95
- /* @__PURE__ */ a("p", { className: "chevron-text", children: [
96
- /* @__PURE__ */ e(z, {}),
97
- /* @__PURE__ */ a("span", { children: [
98
- p[0],
99
- p.length > 1 && /* @__PURE__ */ a("sup", { children: [
100
- "+",
101
- p.length - 1
102
- ] })
103
- ] })
104
- ] })
105
- ]
106
- }
107
- ),
108
- i.cabinClass && /* @__PURE__ */ a("div", { className: "flight-detail", children: [
109
- /* @__PURE__ */ e("p", { children: "Class" }),
110
- /* @__PURE__ */ e("p", { children: i.cabinClass })
111
- ] })
112
- ] }),
113
- /* @__PURE__ */ a("div", { className: "booking-options", children: [
114
- i.cash > 0 && /* @__PURE__ */ a(
115
- "div",
116
- {
117
- className: "cash-value",
118
- onClick: (r) => {
119
- r.stopPropagation(), o(i, m.CASH);
120
- },
121
- children: [
122
- /* @__PURE__ */ e("img", { src: i.airlineLogo }),
123
- /* @__PURE__ */ a("div", { children: [
124
- /* @__PURE__ */ e("label", { children: w ? "Book For" : "From" }),
125
- /* @__PURE__ */ e(
126
- A,
127
- {
128
- amount: i.cash,
129
- currency: i.currency
130
- }
131
- )
132
- ] })
133
- ]
134
- }
135
- ),
136
- i.points > 0 && /* @__PURE__ */ a(
137
- "div",
138
- {
139
- className: "points-value",
140
- onClick: (r) => {
141
- r.stopPropagation(), o(i, m.POINTS);
142
- },
143
- children: [
144
- /* @__PURE__ */ e("img", { src: I.programLogo }),
145
- /* @__PURE__ */ a("div", { children: [
146
- /* @__PURE__ */ e("label", { children: E ? "Book For" : "From" }),
147
- /* @__PURE__ */ a("p", { children: [
148
- `${Y(i.points)} miles`,
149
- ((u = i.cashFee) == null ? void 0 : u.amount) > 0 || (((y = (F = (v = i.paymentOptions) == null ? void 0 : v.find(
150
- (r) => r.points > -1
151
- )) == null ? void 0 : F.cashFee) == null ? void 0 : y.amount) ?? 0) > 0 && /* @__PURE__ */ a(H, { children: [
152
- " + ",
153
- /* @__PURE__ */ e(
154
- A,
155
- {
156
- amount: ((D = (C = i.paymentOptions.find(
157
- (r) => r.points > -1
158
- )) == null ? void 0 : C.cashFee) == null ? void 0 : D.amount) ?? 0,
159
- currency: ((O = (S = i.paymentOptions.find(
160
- (r) => r.points > -1
161
- )) == null ? void 0 : S.cashFee) == null ? void 0 : O.currency) ?? "",
162
- customDisplay: "No fee",
163
- zeroDisplayOption: W.CUSTOM
164
- }
165
- )
166
- ] })
167
- ] })
168
- ] })
169
- ]
170
- }
171
- )
172
- ] })
173
- ] }),
174
- /* @__PURE__ */ e("div", { className: `flight-details ${d ? "is-open" : ""}`, children: /* @__PURE__ */ e("div", { className: "inner", children: /* @__PURE__ */ e(
175
- G,
176
- {
177
- itinerary: f.slices[0].segments,
178
- origin: s,
179
- destination: t,
180
- isMultiDayFlight: $
181
- }
182
- ) }) })
183
- ] }) });
184
- };
9
+ import "../../enums/EPaymentType.js";
10
+ import "@odynn/awayz-core";
11
+ import "../../utils/flightDateUtils.js";
185
12
  export {
186
- ci as FlightResult
13
+ g as FlightResult
187
14
  };
@@ -1,4 +1,4 @@
1
- import { FlightResult as l } from "./FlightResult/FlightResult.js";
1
+ import { F as l } from "../FlightResult-DLe2iE7E.js";
2
2
  export {
3
3
  l as FlightResult
4
4
  };
@@ -1,6 +1,8 @@
1
1
  import { useFlightSearch as o } from "./useFlightSearch/useFlightSearch.js";
2
- import { useAirportSearch as h } from "./useAirportSearch/useAirportSearch.js";
2
+ import { useAirportSearch as a } from "./useAirportSearch/useAirportSearch.js";
3
+ import { EBaggage as p } from "./useFlightSearch/useFlightSearch.types.js";
3
4
  export {
4
- h as useAirportSearch,
5
+ p as EBaggage,
6
+ a as useAirportSearch,
5
7
  o as useFlightSearch
6
8
  };
@@ -1,15 +1,14 @@
1
- import { useState as H, useRef as J } from "react";
2
- import { useMutation as k } from "@tanstack/react-query";
3
- import { EFlightType as $, EFlightPaymentType as F } from "../../types/enums.js";
4
- import { FlightService as D } from "../../services/flights/FlightsService.js";
5
- import { mapDataToFlightDetails as X, groupFlightResults as Z, buildFlightSearchQuery as Q } from "../../utils/flightUtils.js";
1
+ import { useAwayzContext as J, awayzClient as F, getBaseUrl as X } from "@odynn/awayz-core";
2
+ import { useMutation as U } from "@tanstack/react-query";
6
3
  import "../../moment-BGjjqtLQ.js";
7
4
  import "../../arrayExtensions-DFLvtO8l.js";
8
5
  import { c as B } from "../../objectUtils-CyIaVmog.js";
9
- import ee from "../../stores/useFlightStore.js";
10
- import { useAwayzContext as te, awayzClient as L, getBaseUrl as ne } from "@odynn/awayz-core";
11
- import { ECabinClass as re } from "../../types/ECabinClass.js";
12
- var y = /* @__PURE__ */ ((e) => (e.LOCATIONS = "LOCATIONS", e.CHECK_USER = "CHECK_USER", e.USER_REGIONS = "USER_REGIONS", e.CONVERT_CURRENCY = "CONVERT_CURRENCY", e.CLIENT_COMPONENT_KEY = "CLIENT_COMPONENT_KEY", e.SEARCH_LIMIT = "SEARCH_LIMIT", e.PROGRAMS = "PROGRAMS", e.BANKS = "BANKS", e.CARDS = "CARDS", e.USER_CARDS = "USER_CARDS", e.TRIPS = "TRIPS", e.UNCATEGORISED_BOOKINGS = "UNCATEGORISED_BOOKINGS", e.BOOKING = "BOOKING", e))(y || {});
6
+ import { useState as H, useRef as Z } from "react";
7
+ import { FlightService as D } from "../../services/flights/FlightsService.js";
8
+ import Q from "../../stores/useFlightStore.js";
9
+ import { EFlightType as $, EFlightPaymentType as P } from "../../types/enums.js";
10
+ import { ECabinClass as ee } from "../../types/ECabinClass.js";
11
+ import { mapDataToFlightDetails as te, groupFlightResults as ne, buildFlightSearchQuery as re } from "../../utils/flightUtils.js";
13
12
  async function oe(e, n) {
14
13
  const o = e.getReader();
15
14
  let r;
@@ -50,21 +49,21 @@ function ae(e, n, o) {
50
49
  if (c.length === 0)
51
50
  o == null || o(r), r = Y();
52
51
  else if (u > 0) {
53
- const a = s.decode(c.subarray(0, u)), d = u + (c[u + 1] === 32 ? 2 : 1), g = s.decode(c.subarray(d));
52
+ const a = s.decode(c.subarray(0, u)), d = u + (c[u + 1] === 32 ? 2 : 1), S = s.decode(c.subarray(d));
54
53
  switch (a) {
55
54
  case "data":
56
55
  r.data = r.data ? r.data + `
57
- ` + g : g;
56
+ ` + S : S;
58
57
  break;
59
58
  case "event":
60
- r.event = g;
59
+ r.event = S;
61
60
  break;
62
61
  case "id":
63
- e(r.id = g);
62
+ e(r.id = S);
64
63
  break;
65
64
  case "retry":
66
- const b = parseInt(g, 10);
67
- isNaN(b) || n(r.retry = b);
65
+ const m = parseInt(S, 10);
66
+ isNaN(m) || n(r.retry = m);
68
67
  break;
69
68
  }
70
69
  }
@@ -92,35 +91,35 @@ var ue = function(e, n) {
92
91
  };
93
92
  const G = "text/event-stream", ce = 1e3, W = "last-event-id";
94
93
  function le(e, n) {
95
- 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"]);
96
- return new Promise((b, _) => {
94
+ var { signal: o, headers: r, onopen: s, onmessage: E, onclose: c, onerror: u, openWhenHidden: a, fetch: d } = n, S = ue(n, ["signal", "headers", "onopen", "onmessage", "onclose", "onerror", "openWhenHidden", "fetch"]);
95
+ return new Promise((m, _) => {
97
96
  const p = Object.assign({}, r);
98
97
  p.accept || (p.accept = G);
99
- let S;
98
+ let b;
100
99
  function R() {
101
- S.abort(), document.hidden || v();
100
+ b.abort(), document.hidden || v();
102
101
  }
103
102
  a || document.addEventListener("visibilitychange", R);
104
103
  let A = ce, I = 0;
105
104
  function T() {
106
- document.removeEventListener("visibilitychange", R), window.clearTimeout(I), S.abort();
105
+ document.removeEventListener("visibilitychange", R), window.clearTimeout(I), b.abort();
107
106
  }
108
107
  o == null || o.addEventListener("abort", () => {
109
- T(), b();
108
+ T(), m();
110
109
  });
111
- const P = d ?? window.fetch, q = s ?? de;
110
+ const L = d ?? window.fetch, M = s ?? de;
112
111
  async function v() {
113
112
  var w;
114
- S = new AbortController();
113
+ b = new AbortController();
115
114
  try {
116
- const C = await P(e, Object.assign(Object.assign({}, g), { headers: p, signal: S.signal }));
117
- await q(C), await oe(C.body, se(ae((h) => {
115
+ const C = await L(e, Object.assign(Object.assign({}, S), { headers: p, signal: b.signal }));
116
+ await M(C), await oe(C.body, se(ae((h) => {
118
117
  h ? p[W] = h : delete p[W];
119
118
  }, (h) => {
120
119
  A = h;
121
- }, E))), c == null || c(), T(), b();
120
+ }, E))), c == null || c(), T(), m();
122
121
  } catch (C) {
123
- if (!S.signal.aborted)
122
+ if (!b.signal.aborted)
124
123
  try {
125
124
  const h = (w = u == null ? void 0 : u(C)) !== null && w !== void 0 ? w : A;
126
125
  window.clearTimeout(I), I = window.setTimeout(v, h);
@@ -137,9 +136,10 @@ function de(e) {
137
136
  if (!(n != null && n.startsWith(G)))
138
137
  throw new Error(`Expected content-type to be ${G}, Actual: ${n}`);
139
138
  }
140
- const z = 1, K = re.ECONOMY;
141
- let U = new AbortController();
142
- const fe = 3 * 60 * 1e3, V = (e) => {
139
+ var y = /* @__PURE__ */ ((e) => (e.LOCATIONS = "LOCATIONS", e.CHECK_USER = "CHECK_USER", e.USER_REGIONS = "USER_REGIONS", e.CONVERT_CURRENCY = "CONVERT_CURRENCY", e.CLIENT_COMPONENT_KEY = "CLIENT_COMPONENT_KEY", e.SEARCH_LIMIT = "SEARCH_LIMIT", e.PROGRAMS = "PROGRAMS", e.USER_PROGRAMS = "USER_PROGRAMS", e.BANKS = "BANKS", e.CARDS = "CARDS", e.USER_CARDS = "USER_CARDS", e.TRIPS = "TRIPS", e.UNCATEGORISED_BOOKINGS = "UNCATEGORISED_BOOKINGS", e.BOOKING = "BOOKING", e))(y || {});
140
+ const z = 1, V = ee.ECONOMY;
141
+ let k = new AbortController();
142
+ const fe = 3 * 60 * 1e3, K = (e) => {
143
143
  if (!e.origin || !e.destination)
144
144
  throw new Error("Origin and destination are required.");
145
145
  if (!e.departureDate)
@@ -147,26 +147,26 @@ const fe = 3 * 60 * 1e3, V = (e) => {
147
147
  if (e.flightType === $.ROUND_TRIP && !e.returnDate)
148
148
  throw new Error("Return date is required for round-trip flights.");
149
149
  }, we = () => {
150
- const { token: e, config: n } = te(), [o, r] = H(""), [s, E] = H([]), [c, u] = H(!1), a = J(null), {
150
+ const { token: e, config: n } = J(), [o, r] = H(""), [s, E] = H([]), [c, u] = H(!1), a = Z(null), {
151
151
  inboundResults: d,
152
- outboundResults: g,
153
- setInboundResults: b,
152
+ outboundResults: S,
153
+ setInboundResults: m,
154
154
  setOutboundResults: _,
155
155
  partialOfferRequestId: p,
156
- setPartialOfferRequestId: S
157
- } = ee(), R = ({
156
+ setPartialOfferRequestId: b
157
+ } = Q(), R = ({
158
158
  data: t,
159
159
  inbound: f
160
160
  }) => {
161
- const l = X(t);
162
- return (f ? b : _)(Z(l)), l;
161
+ const l = te(t);
162
+ return (f ? m : _)(ne(l)), l;
163
163
  }, {
164
164
  mutate: A,
165
165
  status: I,
166
166
  error: T
167
- } = k({
167
+ } = U({
168
168
  mutationFn: async (t) => {
169
- V(t);
169
+ K(t);
170
170
  const l = {
171
171
  passengers: Array.from(
172
172
  { length: t.passengers ?? z },
@@ -174,7 +174,7 @@ const fe = 3 * 60 * 1e3, V = (e) => {
174
174
  ),
175
175
  origin: t.origin || "",
176
176
  destination: t.destination || "",
177
- cabin_class: t.cabinClass ?? K
177
+ cabin_class: t.cabinClass ?? V
178
178
  };
179
179
  if (t.flightType === $.ONE_WAY) {
180
180
  const i = await D.cashOnlySearch({
@@ -204,19 +204,19 @@ const fe = 3 * 60 * 1e3, V = (e) => {
204
204
  console.log("oh lol, it didn't work");
205
205
  return;
206
206
  }
207
- R({ data: l }), i && S(i);
207
+ R({ data: l }), i && b(i);
208
208
  },
209
209
  onError: (t) => {
210
210
  console.error("Error in outbound flight search:", t);
211
211
  },
212
212
  onSettled: () => {
213
- L.invalidateQueries({ queryKey: [y.SEARCH_LIMIT] });
213
+ F.invalidateQueries({ queryKey: [y.SEARCH_LIMIT] });
214
214
  }
215
215
  }), {
216
- mutate: P,
217
- status: q,
216
+ mutate: L,
217
+ status: M,
218
218
  error: v
219
- } = k({
219
+ } = U({
220
220
  mutationFn: async (t) => {
221
221
  if (!p)
222
222
  throw new Error("No partialOfferRequestId found for inbound search.");
@@ -236,13 +236,13 @@ const fe = 3 * 60 * 1e3, V = (e) => {
236
236
  console.error("Error in inbound flight search:", t);
237
237
  },
238
238
  onSettled: () => {
239
- L.invalidateQueries({ queryKey: [y.SEARCH_LIMIT] });
239
+ F.invalidateQueries({ queryKey: [y.SEARCH_LIMIT] });
240
240
  }
241
241
  }), {
242
242
  mutate: w,
243
243
  status: C,
244
244
  error: h
245
- } = k({
245
+ } = U({
246
246
  mutationFn: async (t) => {
247
247
  if (!p)
248
248
  throw new Error("No partialOfferRequestId found for round-trip fares.");
@@ -262,42 +262,42 @@ const fe = 3 * 60 * 1e3, V = (e) => {
262
262
  console.error("Error in round-trip fare search:", t);
263
263
  },
264
264
  onSettled: () => {
265
- L.invalidateQueries({ queryKey: [y.SEARCH_LIMIT] });
265
+ F.invalidateQueries({ queryKey: [y.SEARCH_LIMIT] });
266
266
  }
267
267
  }), j = async (t) => {
268
268
  var x;
269
269
  u(!0);
270
- const f = t.paymentType === F.CASH_AND_MILES ? ['"cash"', '"points"'] : ['"points"'], l = Q({
270
+ const f = t.paymentType === P.CASH_AND_MILES ? ['"cash"', '"points"'] : ['"points"'], l = re({
271
271
  originCode: t.origin,
272
272
  destinationCode: t.destination,
273
273
  departureDate: t.departureDate,
274
- cabinClass: t.cabinClass ?? K,
274
+ cabinClass: t.cabinClass ?? V,
275
275
  passengerCount: t.passengers ?? z,
276
276
  paymentType: f
277
277
  });
278
- let i = [], M = 0;
279
- U = new AbortController(), a.current = setTimeout(() => {
278
+ let i = [], q = 0;
279
+ k = new AbortController(), a.current = setTimeout(() => {
280
280
  O();
281
- }, (((x = n == null ? void 0 : n.flightsConfig) == null ? void 0 : x.streamTimeoutTotalSeconds) ?? fe) * 1e3), le(ne() + l, {
281
+ }, (((x = n == null ? void 0 : n.flightsConfig) == null ? void 0 : x.streamTimeoutTotalSeconds) ?? fe) * 1e3), le(X() + l, {
282
282
  headers: {
283
283
  "Content-Type": "application/json",
284
284
  Authorization: e ?? "",
285
285
  "client-id": (n == null ? void 0 : n.clientId) ?? ""
286
286
  },
287
287
  openWhenHidden: !0,
288
- signal: U.signal,
288
+ signal: k.signal,
289
289
  onmessage(N) {
290
290
  try {
291
- const m = B(JSON.parse(N.data));
292
- if (m.success === !1)
291
+ const g = B(JSON.parse(N.data));
292
+ if (g.success === !1)
293
293
  return;
294
- if (m.close === !0) {
294
+ if (g.close === !0) {
295
295
  O();
296
296
  return;
297
297
  }
298
- m.status === 200 && m.flights && m.flights.length > 0 && (M = 0, i = [...i, ...m.flights], R({ data: i })), m.ping && (M++, M >= n.flightsConfig.streamTimeoutPingCount && O());
299
- } catch (m) {
300
- console.error("Error parsing message:", m), O();
298
+ g.status === 200 && g.flights && g.flights.length > 0 && (q = 0, i = [...i, ...g.flights], R({ data: i })), g.ping && (q++, q >= n.flightsConfig.streamTimeoutPingCount && O());
299
+ } catch (g) {
300
+ console.error("Error parsing message:", g), O();
301
301
  }
302
302
  },
303
303
  onerror(N) {
@@ -309,7 +309,7 @@ const fe = 3 * 60 * 1e3, V = (e) => {
309
309
  keepalive: !1
310
310
  });
311
311
  }, O = () => {
312
- U.abort(), a.current && (clearTimeout(a.current), a.current = null), u(!1), L.invalidateQueries({ queryKey: [y.SEARCH_LIMIT] });
312
+ k.abort(), a.current && (clearTimeout(a.current), a.current = null), u(!1), F.invalidateQueries({ queryKey: [y.SEARCH_LIMIT] });
313
313
  };
314
314
  return {
315
315
  /**
@@ -317,7 +317,7 @@ const fe = 3 * 60 * 1e3, V = (e) => {
317
317
  * @type {boolean}
318
318
  * @default false
319
319
  */
320
- loading: I === "pending" || q === "pending" || c,
320
+ loading: I === "pending" || M === "pending" || c,
321
321
  /**
322
322
  * Loading status for fares
323
323
  * @type {boolean}
@@ -328,7 +328,7 @@ const fe = 3 * 60 * 1e3, V = (e) => {
328
328
  inboundError: v,
329
329
  roundTripFaresError: h,
330
330
  // Results
331
- outboundResults: g,
331
+ outboundResults: S,
332
332
  inboundResults: d,
333
333
  roundTripFares: s,
334
334
  // Mutation triggers
@@ -339,14 +339,14 @@ const fe = 3 * 60 * 1e3, V = (e) => {
339
339
  * @param {ISearchFlightArgs} args - The search arguments
340
340
  */
341
341
  searchOutboundFlights: async (t) => {
342
- switch (V(t), _([]), O(), t.paymentType) {
343
- case F.CASH_AND_MILES:
342
+ switch (K(t), _([]), O(), t.paymentType) {
343
+ case P.CASH_AND_MILES:
344
344
  j(t);
345
345
  break;
346
- case F.CASH:
346
+ case P.CASH:
347
347
  A(t);
348
348
  break;
349
- case F.MILES:
349
+ case P.MILES:
350
350
  j(t);
351
351
  break;
352
352
  }
@@ -357,7 +357,7 @@ const fe = 3 * 60 * 1e3, V = (e) => {
357
357
  *
358
358
  * @param {string} outboundOfferId - The ID of the outbound offer
359
359
  */
360
- searchInboundFlights: P,
360
+ searchInboundFlights: L,
361
361
  /**
362
362
  * Used to get round-trip fares after selecting both outbound and inbound flights
363
363
  * @type {function}
@@ -50,9 +50,9 @@ const $ = (n, s) => {
50
50
  }, D = "https://assets.duffel.com/img/airlines/for-light-background/full-color-lockup/";
51
51
  export {
52
52
  D,
53
- T as a,
54
- $ as b,
55
- p as c,
56
- M as d,
53
+ $ as a,
54
+ M as b,
55
+ T as c,
56
+ p as d,
57
57
  g
58
58
  };
@@ -1,3 +1,4 @@
1
1
  export * from './useFlightSearch/useFlightSearch';
2
2
  export * from './useAirportSearch/useAirportSearch';
3
- export type { IFlightResult, IFlightOffer, IFlightDetails, EBaggage, IAirportLocation } from './useFlightSearch/useFlightSearch.types';
3
+ export type { IFlightResult, IFlightOffer, IFlightDetails, IAirportLocation } from './useFlightSearch/useFlightSearch.types';
4
+ export { EBaggage } from './useFlightSearch/useFlightSearch.types';
@@ -1,4 +1,4 @@
1
- import { ISlice, IBaggage, ICarrier, ISegment, IPassenger, ICoordinates, commaSeparatedNumber, getDuration, getCountryNameByCode, getTimezoneOffsetOrCode, calculateTimeDifference, getTimeString, EDateFormats } from '@type-op/shared';
1
+ import { ISlice, IBaggage, ICarrier, ISegment, IPassenger, ICoordinates, commaSeparatedNumber, getDuration, getCountryNameByCode, getTimezoneOffsetOrCode, calculateTimeDifference, getTimeString, EDateFormats, DUFFEL_ASSET_PATH } from '@type-op/shared';
2
2
  export * from './hooks';
3
3
  export * from './components';
4
4
  export * from './enums';
@@ -7,4 +7,5 @@ export { getLogoPath, getFlightNumber } from './utils/flightUtils';
7
7
  export { isSameDayFlight } from './utils/flightDateUtils';
8
8
  export { EFlightPaymentType, EFlightType } from './types/enums';
9
9
  export { ECabinClass, getCabinClassLabel, getCabinClassList } from './types/ECabinClass';
10
- export type { ISlice, IBaggage, ICarrier, ISegment, IPassenger, ICoordinates, commaSeparatedNumber, getDuration, getCountryNameByCode, getTimezoneOffsetOrCode, calculateTimeDifference, getTimeString, EDateFormats };
10
+ export type { ISlice, IBaggage, ICarrier, ISegment, IPassenger, ICoordinates, DUFFEL_ASSET_PATH };
11
+ export { commaSeparatedNumber, getDuration, getCountryNameByCode, getTimezoneOffsetOrCode, calculateTimeDifference, getTimeString, EDateFormats };
@@ -1,5 +1,5 @@
1
- import { IFlightOffer, IFlightResult } from '../hooks/useFlightSearch/useFlightSearch.types';
2
1
  import { ISegment } from '@type-op/shared';
2
+ import { IFlightOffer, IFlightResult } from '../hooks/useFlightSearch/useFlightSearch.types';
3
3
  import { IAirlineProgram } from '../services/wallet/WalletService.types';
4
4
  import { ECabinClass } from '../types/ECabinClass';
5
5
  /**
package/dist/main.js CHANGED
@@ -1,24 +1,37 @@
1
- import { useFlightSearch as r } from "./hooks/useFlightSearch/useFlightSearch.js";
2
- import { useAirportSearch as a } from "./hooks/useAirportSearch/useAirportSearch.js";
3
- import { FlightResult as g } from "./components/FlightResult/FlightResult.js";
4
- import { EPaymentType as l } from "./enums/EPaymentType.js";
5
- import { DEFAULT_AIRLINE_PROGRAM as s, getAirlineProgram as h, getFlightNumber as f, getLogoPath as x } from "./utils/flightUtils.js";
6
- import { isSameDayFlight as n } from "./utils/flightDateUtils.js";
7
- import { EFlightPaymentType as C, EFlightType as E } from "./types/enums.js";
8
- import { ECabinClass as A, getCabinClassLabel as L, getCabinClassList as P } from "./types/ECabinClass.js";
1
+ import { useFlightSearch as o } from "./hooks/useFlightSearch/useFlightSearch.js";
2
+ import { useAirportSearch as g } from "./hooks/useAirportSearch/useAirportSearch.js";
3
+ import { EBaggage as s } from "./hooks/useFlightSearch/useFlightSearch.types.js";
4
+ import { F as f, c as l } from "./FlightResult-DLe2iE7E.js";
5
+ import { EPaymentType as x } from "./enums/EPaymentType.js";
6
+ import { DEFAULT_AIRLINE_PROGRAM as C, getAirlineProgram as E, getFlightNumber as F, getLogoPath as c } from "./utils/flightUtils.js";
7
+ import { isSameDayFlight as y } from "./utils/flightDateUtils.js";
8
+ import { EFlightPaymentType as T, EFlightType as A } from "./types/enums.js";
9
+ import { ECabinClass as L, getCabinClassLabel as P, getCabinClassList as S } from "./types/ECabinClass.js";
10
+ import { c as R, g as d, b as O, a as B } from "./index-7zRjF0bU.js";
11
+ import { E as _, g as z } from "./FlightItinerary-VggJiPkC.js";
12
+ import "./arrayExtensions-DFLvtO8l.js";
13
+ import "react";
9
14
  export {
10
- s as DEFAULT_AIRLINE_PROGRAM,
11
- A as ECabinClass,
12
- C as EFlightPaymentType,
13
- E as EFlightType,
14
- l as EPaymentType,
15
- g as FlightResult,
16
- h as getAirlineProgram,
17
- L as getCabinClassLabel,
18
- P as getCabinClassList,
19
- f as getFlightNumber,
20
- x as getLogoPath,
21
- n as isSameDayFlight,
22
- a as useAirportSearch,
23
- r as useFlightSearch
15
+ C as DEFAULT_AIRLINE_PROGRAM,
16
+ s as EBaggage,
17
+ L as ECabinClass,
18
+ _ as EDateFormats,
19
+ T as EFlightPaymentType,
20
+ A as EFlightType,
21
+ x as EPaymentType,
22
+ f as FlightResult,
23
+ R as calculateTimeDifference,
24
+ l as commaSeparatedNumber,
25
+ E as getAirlineProgram,
26
+ P as getCabinClassLabel,
27
+ S as getCabinClassList,
28
+ z as getCountryNameByCode,
29
+ d as getDuration,
30
+ F as getFlightNumber,
31
+ c as getLogoPath,
32
+ O as getTimeString,
33
+ B as getTimezoneOffsetOrCode,
34
+ y as isSameDayFlight,
35
+ g as useAirportSearch,
36
+ o as useFlightSearch
24
37
  };
@@ -1,33 +1,33 @@
1
- import { mapBaggageType as Q } from "../hooks/useFlightSearch/useFlightSearch.types.js";
2
- import { h as g } from "../moment-BGjjqtLQ.js";
3
- import { c as K, D as V } from "../index-D0Heof44.js";
1
+ import { awayzClient as Q } from "@odynn/awayz-core";
2
+ import { d as K, D as V } from "../index-7zRjF0bU.js";
4
3
  import "../arrayExtensions-DFLvtO8l.js";
5
4
  import "react";
6
- import { awayzClient as Y } from "@odynn/awayz-core";
5
+ import { h as g } from "../moment-BGjjqtLQ.js";
6
+ import { mapBaggageType as Y } from "../hooks/useFlightSearch/useFlightSearch.types.js";
7
7
  import { WalletService as x } from "../services/wallet/WalletService.js";
8
8
  import { ERewardProgramCategories as H } from "../services/wallet/WalletService.types.js";
9
9
  const re = (t) => t == null ? void 0 : t.map((e) => {
10
- var i, n, l, m, s, a, r, c, o, d, u, C, w, b, D, F, L, A, T, P, k, h, O, v, R, E, I, _, N, z, M, S, Z, $, G;
10
+ var a, c, n, l, s, i, o, m, r, u, d, C, w, b, D, F, L, A, h, T, P, k, O, v, R, E, I, _, N, z, S, Z, $, G, M;
11
11
  return {
12
12
  id: e.id,
13
13
  points: (e == null ? void 0 : e.points) >= 0 ? e.points : -1,
14
14
  partial: e == null ? void 0 : e.partial,
15
15
  origin: {
16
- city: ((i = e.slices[0].segments[0].origin) == null ? void 0 : i.cityName) || ((l = (n = e.slices[0].segments[0].origin) == null ? void 0 : n.city) == null ? void 0 : l.name),
17
- country: ((m = e.slices[0].segments[0].origin) == null ? void 0 : m.iataCountryCode) || ((a = (s = e.slices[0].segments[0].origin) == null ? void 0 : s.city) == null ? void 0 : a.iataCountryCode),
18
- airportCode: ((r = e.slices[0].segments[0].origin) == null ? void 0 : r.iataCityCode) || ((o = (c = e.slices[0].segments[0].origin) == null ? void 0 : c.city) == null ? void 0 : o.iataCode),
16
+ city: ((a = e.slices[0].segments[0].origin) == null ? void 0 : a.cityName) || ((n = (c = e.slices[0].segments[0].origin) == null ? void 0 : c.city) == null ? void 0 : n.name),
17
+ country: ((l = e.slices[0].segments[0].origin) == null ? void 0 : l.iataCountryCode) || ((i = (s = e.slices[0].segments[0].origin) == null ? void 0 : s.city) == null ? void 0 : i.iataCountryCode),
18
+ airportCode: ((o = e.slices[0].segments[0].origin) == null ? void 0 : o.iataCityCode) || ((r = (m = e.slices[0].segments[0].origin) == null ? void 0 : m.city) == null ? void 0 : r.iataCode),
19
19
  coordinates: {
20
- latitude: (u = (d = e.slices[0].segments[0].origin) == null ? void 0 : d.city) == null ? void 0 : u.latitude,
20
+ latitude: (d = (u = e.slices[0].segments[0].origin) == null ? void 0 : u.city) == null ? void 0 : d.latitude,
21
21
  longitude: (w = (C = e.slices[0].segments[0].origin) == null ? void 0 : C.city) == null ? void 0 : w.longitude
22
22
  }
23
23
  },
24
24
  destination: {
25
25
  city: ((D = (b = e.slices[0].segments.getLast()) == null ? void 0 : b.destination) == null ? void 0 : D.cityName) || ((A = (L = (F = e.slices[0].segments.getLast()) == null ? void 0 : F.destination) == null ? void 0 : L.city) == null ? void 0 : A.name),
26
- country: ((P = (T = e.slices[0].segments.getLast()) == null ? void 0 : T.destination) == null ? void 0 : P.iataCountryCode) || ((O = (h = (k = e.slices[0].segments.getLast()) == null ? void 0 : k.destination) == null ? void 0 : h.city) == null ? void 0 : O.iataCountryCode),
26
+ country: ((T = (h = e.slices[0].segments.getLast()) == null ? void 0 : h.destination) == null ? void 0 : T.iataCountryCode) || ((O = (k = (P = e.slices[0].segments.getLast()) == null ? void 0 : P.destination) == null ? void 0 : k.city) == null ? void 0 : O.iataCountryCode),
27
27
  airportCode: ((R = (v = e.slices[0].segments.getLast()) == null ? void 0 : v.destination) == null ? void 0 : R.iataCityCode) || ((_ = (I = (E = e.slices[0].segments.getLast()) == null ? void 0 : E.destination) == null ? void 0 : I.city) == null ? void 0 : _.iataCode),
28
28
  coordinates: {
29
- latitude: (M = (z = (N = e.slices[0].segments.getLast()) == null ? void 0 : N.destination) == null ? void 0 : z.city) == null ? void 0 : M.latitude,
30
- longitude: ($ = (Z = (S = e.slices[0].segments.getLast()) == null ? void 0 : S.destination) == null ? void 0 : Z.city) == null ? void 0 : $.longitude
29
+ latitude: (S = (z = (N = e.slices[0].segments.getLast()) == null ? void 0 : N.destination) == null ? void 0 : z.city) == null ? void 0 : S.latitude,
30
+ longitude: (G = ($ = (Z = e.slices[0].segments.getLast()) == null ? void 0 : Z.destination) == null ? void 0 : $.city) == null ? void 0 : G.longitude
31
31
  }
32
32
  },
33
33
  airline: e.owner.name,
@@ -55,62 +55,62 @@ const re = (t) => t == null ? void 0 : t.map((e) => {
55
55
  duration: e.slices[0].duration
56
56
  }),
57
57
  cashFee: e.cashFee,
58
- cabinClass: e.slices[0].fareBrandName || e.slices[0].segments[0].passengers[0].cabinClassMarketingName || ((G = e.slices[0].segments[0].passengers[0].cabin) == null ? void 0 : G.marketingName)
58
+ cabinClass: e.slices[0].fareBrandName || e.slices[0].segments[0].passengers[0].cabinClassMarketingName || ((M = e.slices[0].segments[0].passengers[0].cabin) == null ? void 0 : M.marketingName)
59
59
  };
60
60
  }), j = (t) => {
61
- const e = t.operatingCarrierFlightNumber ? t.operatingCarrier : t.marketingCarrier, i = t.operatingCarrierFlightNumber ?? t.marketingCarrierFlightNumber;
62
- return e.iataCode + " " + J(i);
61
+ const e = t.operatingCarrierFlightNumber ? t.operatingCarrier : t.marketingCarrier, a = t.operatingCarrierFlightNumber ?? t.marketingCarrierFlightNumber;
62
+ return e.iataCode + " " + J(a);
63
63
  }, oe = ({
64
64
  originCode: t,
65
65
  destinationCode: e,
66
- departureDate: i,
67
- cabinClass: n,
68
- passengerCount: l,
69
- paymentType: m
66
+ departureDate: a,
67
+ cabinClass: c,
68
+ passengerCount: n,
69
+ paymentType: l
70
70
  }) => {
71
71
  let s = "/flights/search/one-way/points-cash?";
72
- return s += `origin=${t}`, s += `&destination=${e}`, s += `&departure_date=${i}`, s += `&cabin_class=${n}`, s += `&adults=${l}`, s += `&cash_or_points=[${m}]`, s;
73
- }, W = (t) => t.flightDetails.slices[0].segments.map((i) => j(i)).join("_"), ce = (t) => {
72
+ return s += `origin=${t}`, s += `&destination=${e}`, s += `&departure_date=${a}`, s += `&cabin_class=${c}`, s += `&adults=${n}`, s += `&cash_or_points=[${l}]`, s;
73
+ }, W = (t) => t.flightDetails.slices[0].segments.map((a) => j(a)).join("_"), ce = (t) => {
74
74
  const e = {};
75
75
  t.forEach((s) => {
76
- var r;
77
- const a = W(s);
78
- if (e[a]) {
79
- const c = U(s);
80
- e[a].flight.paymentOptions.push(c);
81
- const o = p(
82
- e[a].flight.paymentOptions
76
+ var o;
77
+ const i = W(s);
78
+ if (e[i]) {
79
+ const m = U(s);
80
+ e[i].flight.paymentOptions.push(m);
81
+ const r = p(
82
+ e[i].flight.paymentOptions
83
83
  );
84
- e[a].flight.cash = o.lowestCash, e[a].flight.points = o.lowestPoints;
84
+ e[i].flight.cash = r.lowestCash, r.currency && (e[i].flight.flightDetails.baseCurrency = r.currency, e[i].flight.currency = r.currency), e[i].flight.points = r.lowestPoints;
85
85
  } else {
86
- const { origin: c, destination: o } = s, d = [U(s)], u = p(d);
87
- e[a] = {
86
+ const { origin: m, destination: r } = s, u = [U(s)], d = p(u);
87
+ e[i] = {
88
88
  programs: [],
89
89
  flight: {
90
90
  id: s.awayzGroupId,
91
91
  partial: s.partial,
92
92
  origin: {
93
- city: c.city,
94
- country: c.country,
95
- airportCode: c.airportCode,
96
- coordinates: c.coordinates
93
+ city: m.city,
94
+ country: m.country,
95
+ airportCode: m.airportCode,
96
+ coordinates: m.coordinates
97
97
  },
98
98
  destination: {
99
- city: o.city,
100
- country: o.country,
101
- airportCode: o.airportCode,
102
- coordinates: o.coordinates
99
+ city: r.city,
100
+ country: r.country,
101
+ airportCode: r.airportCode,
102
+ coordinates: r.coordinates
103
103
  },
104
104
  airline: s.airline,
105
105
  airlineLogo: y(
106
106
  s.flightDetails.slices[0].segments[0].marketingCarrier.iataCode
107
107
  ),
108
108
  flightNumber: s.flightNumber,
109
- paymentOptions: d,
109
+ paymentOptions: u,
110
110
  numberOfStops: s.numberOfStops,
111
111
  departureTime: s.departureTime,
112
112
  arrivalTime: s.arrivalTime,
113
- awayzGroupId: a,
113
+ awayzGroupId: i,
114
114
  duration: s.duration,
115
115
  airlineProgram: s.airlineProgram,
116
116
  durationMinutes: K({
@@ -124,73 +124,73 @@ const re = (t) => t == null ? void 0 : t.map((e) => {
124
124
  destinationTimeZone: s.flightDetails.slices[0].segments.getLast().destination.timeZone,
125
125
  duration: s.flightDetails.slices[0].duration
126
126
  }),
127
- cash: u.lowestCash,
128
- points: u.lowestPoints,
127
+ cash: d.lowestCash,
128
+ points: d.lowestPoints,
129
129
  flightDetails: s.flightDetails,
130
130
  currency: s.flightDetails.baseCurrency,
131
131
  cashFee: s.cashFee,
132
- cabinClass: s.flightDetails.slices[0].fareBrandName || s.flightDetails.slices[0].segments[0].passengers[0].cabinClassMarketingName || ((r = s.flightDetails.slices[0].segments[0].passengers[0].cabin) == null ? void 0 : r.marketingName)
132
+ cabinClass: s.flightDetails.slices[0].fareBrandName || s.flightDetails.slices[0].segments[0].passengers[0].cabinClassMarketingName || ((o = s.flightDetails.slices[0].segments[0].passengers[0].cabin) == null ? void 0 : o.marketingName)
133
133
  }
134
134
  };
135
135
  }
136
- s.airlineProgram && !e[a].programs.includes(s.airlineProgram) && e[a].programs.push(s.airlineProgram);
136
+ s.airlineProgram && !e[i].programs.includes(s.airlineProgram) && e[i].programs.push(s.airlineProgram);
137
137
  });
138
- const i = [];
138
+ const a = [];
139
139
  Object.values(e).forEach((s) => {
140
- const a = [
140
+ const i = [
141
141
  ...new Set(
142
- s.flight.paymentOptions.map((r) => r.carrier.name)
142
+ s.flight.paymentOptions.map((o) => o.carrier.name)
143
143
  )
144
144
  ];
145
- s.programs.length > 0 ? s.programs.forEach((r) => {
146
- a.forEach((c) => {
147
- var d;
148
- const o = p(
145
+ s.programs.length > 0 ? s.programs.forEach((o) => {
146
+ i.forEach((m) => {
147
+ var u;
148
+ const r = p(
149
149
  s.flight.paymentOptions.filter(
150
- (u) => u.program === r || u.cash > 0 && u.carrier.name === c
150
+ (d) => d.program === o || d.cash > 0 && d.carrier.name === m
151
151
  )
152
152
  );
153
- i.push({
153
+ a.push({
154
154
  ...s.flight,
155
- airline: c,
155
+ airline: m,
156
156
  airlineLogo: y(
157
- (d = s.flight.paymentOptions.find(
158
- (u) => u.carrier.name === c
159
- )) == null ? void 0 : d.carrier.iataCode
157
+ (u = s.flight.paymentOptions.find(
158
+ (d) => d.carrier.name === m
159
+ )) == null ? void 0 : u.carrier.iataCode
160
160
  ),
161
- airlineProgram: r,
162
- cash: o.lowestCash,
163
- points: o.lowestPoints
161
+ airlineProgram: o,
162
+ cash: r.lowestCash,
163
+ points: r.lowestPoints
164
164
  });
165
165
  });
166
- }) : a.forEach((r) => {
167
- var o;
168
- const { lowestCash: c } = p(
166
+ }) : i.forEach((o) => {
167
+ var r;
168
+ const { lowestCash: m } = p(
169
169
  s.flight.paymentOptions.filter(
170
- (d) => d.carrier.name === r
170
+ (u) => u.carrier.name === o
171
171
  )
172
172
  );
173
- i.push({
173
+ a.push({
174
174
  ...s.flight,
175
- airline: r,
175
+ airline: o,
176
176
  airlineLogo: y(
177
- (o = s.flight.paymentOptions.find(
178
- (d) => d.carrier.name === r
179
- )) == null ? void 0 : o.carrier.iataCode
177
+ (r = s.flight.paymentOptions.find(
178
+ (u) => u.carrier.name === o
179
+ )) == null ? void 0 : r.carrier.iataCode
180
180
  ),
181
- cash: c
181
+ cash: m
182
182
  });
183
183
  });
184
184
  });
185
- const { cashlessResults: n, otherResults: l } = i.reduce(
186
- (s, a) => (a.cash <= 0 && a.points > 0 ? s.cashlessResults.push(a) : a.cash > 0 && s.otherResults.push(a), s),
185
+ const { cashlessResults: c, otherResults: n } = a.reduce(
186
+ (s, i) => (i.cash <= 0 && i.points > 0 ? s.cashlessResults.push(i) : i.cash > 0 && s.otherResults.push(i), s),
187
187
  { cashlessResults: [], otherResults: [] }
188
- ), m = l;
189
- return n.forEach((s) => {
190
- m.find(
191
- (r) => r.awayzGroupId === s.awayzGroupId
192
- ) || m.push(s);
193
- }), m;
188
+ ), l = n;
189
+ return c.forEach((s) => {
190
+ l.find(
191
+ (o) => o.awayzGroupId === s.awayzGroupId
192
+ ) || l.push(s);
193
+ }), l;
194
194
  }, J = (t) => t ? t.replace(/^0+/, "") : "", me = (t) => `https://assets.duffel.com/img/airlines/for-light-background/full-color-logo/${t}.svg`, y = (t) => `${V}${t}.svg`, B = "/img/logo/odynn-eye.svg", q = {
195
195
  categoryLogo: B,
196
196
  programLogo: B,
@@ -204,30 +204,30 @@ const re = (t) => t == null ? void 0 : t.map((e) => {
204
204
  // Using App Foreground Colour
205
205
  url: "https://www.odynn.com"
206
206
  }, le = async (t) => {
207
- const { airlines: e } = await Y.ensureQueryData({
207
+ const { airlines: e } = await Q.ensureQueryData({
208
208
  queryKey: ["walletAwards"],
209
209
  queryFn: x.getAwards,
210
210
  staleTime: 864e5
211
211
  // 24 hours
212
212
  });
213
- let i = e.find(
214
- (n) => {
215
- var l, m, s, a;
216
- return ((m = (l = n.mainProgram) == null ? void 0 : l.toLowerCase()) == null ? void 0 : m.includes(t == null ? void 0 : t.toLowerCase())) || ((a = (s = n.displayProgram) == null ? void 0 : s.toLowerCase()) == null ? void 0 : a.includes(t == null ? void 0 : t.toLowerCase()));
213
+ let a = e.find(
214
+ (c) => {
215
+ var n, l, s, i;
216
+ return ((l = (n = c.mainProgram) == null ? void 0 : n.toLowerCase()) == null ? void 0 : l.includes(t == null ? void 0 : t.toLowerCase())) || ((i = (s = c.displayProgram) == null ? void 0 : s.toLowerCase()) == null ? void 0 : i.includes(t == null ? void 0 : t.toLowerCase()));
217
217
  }
218
218
  ) ?? q;
219
- return i || (i = {
219
+ return a || (a = {
220
220
  ...q,
221
221
  mainProgram: t,
222
222
  displayProgram: t,
223
223
  id: t
224
- }), i;
224
+ }), a;
225
225
  }, U = (t) => {
226
- var n, l, m, s;
227
- const i = (((m = (l = (n = t.flightDetails.slices.getFirst()) == null ? void 0 : n.segments.getFirst()) == null ? void 0 : l.passengers.getFirst()) == null ? void 0 : m.baggages) ?? []).map(
228
- (a) => ({
229
- type: Q(a.type),
230
- quantity: a.quantity
226
+ var c, n, l, s;
227
+ const a = (((l = (n = (c = t.flightDetails.slices.getFirst()) == null ? void 0 : c.segments.getFirst()) == null ? void 0 : n.passengers.getFirst()) == null ? void 0 : l.baggages) ?? []).map(
228
+ (i) => ({
229
+ type: Y(i.type),
230
+ quantity: i.quantity
231
231
  })
232
232
  );
233
233
  return {
@@ -239,21 +239,23 @@ const re = (t) => t == null ? void 0 : t.map((e) => {
239
239
  fareBrandName: (s = t.flightDetails.slices.getFirst()) == null ? void 0 : s.fareBrandName,
240
240
  cashFee: t.cashFee,
241
241
  conditions: t.flightDetails.conditions,
242
- baggages: i,
242
+ baggages: a,
243
243
  carrier: {
244
244
  iataCode: t.flightDetails.slices.getFirst().segments.getFirst().marketingCarrier.iataCode,
245
245
  name: t.flightDetails.slices.getFirst().segments.getFirst().marketingCarrier.name
246
246
  }
247
247
  };
248
248
  }, p = (t) => {
249
- const e = Math.min(
250
- ...t.filter((n) => n.cash > 0).map((n) => n.cash)
251
- ), i = Math.min(
249
+ let e = 1 / 0, a = "";
250
+ for (const n of t)
251
+ n.cash > 0 && n.cash < e && (e = n.cash, a = n.baseCurrency);
252
+ const c = Math.min(
252
253
  ...t.filter((n) => n.points > 0).map((n) => n.points)
253
254
  );
254
255
  return {
255
256
  lowestCash: e === 1 / 0 ? -1 : e,
256
- lowestPoints: i === 1 / 0 ? -1 : i
257
+ lowestPoints: c === 1 / 0 ? -1 : c,
258
+ currency: a
257
259
  };
258
260
  };
259
261
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@odynn/awayz-flights",
3
- "version": "0.3.9",
3
+ "version": "0.4.0",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"