@odynn/awayz-flights 0.10.14 → 0.10.16

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.
@@ -0,0 +1,5 @@
1
+ var T = /* @__PURE__ */ ((_) => (_.TOKEN = "token", _.REFRESH_TOKEN = "refreshToken", _.CLIENT_ID = "clientId", _.AUTH_FLOW = "authFlow", _.OVERRIDE_TOKEN_EXCHANGE_ENDPOINT = "overrideExchangeTokenEndpoint", _))(T || {}), d = /* @__PURE__ */ ((_) => (_.ISO = "dates:iso", _.DISPLAY_SHORT = "dates:displayShort", _.DISPLAY_MEDIUM = "dates:displayMedium", _.DISPLAY_LONG = "dates:displayLong", _.DISPLAY_FULL = "dates:displayFull", _.DISPLAY_SHORT_WITH_YEAR = "dates:displayShortWithYear", _.DISPLAY_MEDIUM_WITH_YEAR = "dates:displayMediumWithYear", _.DISPLAY_LONG_WITH_YEAR = "dates:displayLongWithYear", _.DISPLAY_FULL_WITH_YEAR = "dates:displayFullWithYear", _.DATE_TIME_SHORT = "dates:dateTimeShort", _.DATE_TIME_MEDIUM = "dates:dateTimeMedium", _.DATE_TIME_LONG = "dates:dateTimeLong", _.DATE_TIME_FULL = "dates:dateTimeFull", _.DATE_TIME_SHORT_WITH_YEAR = "dates:dateTimeShortWithYear", _.DATE_TIME_MEDIUM_WITH_YEAR = "dates:dateTimeMediumWithYear", _.DATE_TIME_LONG_WITH_YEAR = "dates:dateTimeLongWithYear", _.DATE_TIME_FULL_WITH_YEAR = "dates:dateTimeFullWithYear", _.TIME_ONLY = "dates:timeOnly", _.TIME_WITH_SECONDS = "dates:timeWithSeconds", _))(d || {});
2
+ export {
3
+ d as E,
4
+ T as a
5
+ };
@@ -129,6 +129,8 @@ export interface IFlightPaymentOption {
129
129
  };
130
130
  cabinClass?: string;
131
131
  slices?: ISlice[];
132
+ isCached?: boolean;
133
+ lastCachedTime?: string;
132
134
  }
133
135
  export interface IFlightResult {
134
136
  id: string;
@@ -158,6 +160,8 @@ export interface IFlightResult {
158
160
  cabinClass: string;
159
161
  expiresAt: string;
160
162
  transferPartners: string[];
163
+ isCached: boolean;
164
+ lastCachedTime: string;
161
165
  }
162
166
  export interface IAirportLocation {
163
167
  city: string;
@@ -203,6 +207,8 @@ export interface IFlightOffer {
203
207
  };
204
208
  googleUrl: string;
205
209
  partners: string[];
210
+ isCached: boolean;
211
+ lastCachedTime: string;
206
212
  }
207
213
  export interface IPaymentRequirements {
208
214
  requiresInstantPayment: boolean;
package/dist/main.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { useFlightSearch as Y } from "./hooks/useFlightSearch/useFlightSearch.js";
2
2
  import { useAirportSearch as p } from "./hooks/useAirportSearch/useAirportSearch.js";
3
3
  import { EBaggage as l } from "./hooks/useFlightSearch/useFlightSearch.types.js";
4
- import { F as h, g as f } from "./FlightItinerary-WKjh-sAR.js";
4
+ import { F as h, g as f } from "./FlightItinerary-BMRY5V0b.js";
5
5
  import { FlightItineraryDropdown as S } from "./components/FlightItineraryDropdown/FlightItineraryDropdown.js";
6
6
  import "react/jsx-runtime";
7
7
  import "react";
@@ -3,30 +3,30 @@ import "react/jsx-runtime";
3
3
  import { d as q } from "../dateUtils-Cb9VQiIL.js";
4
4
  import "../arrayExtensions-Ce8YopTP.js";
5
5
  import "react";
6
- import { h as y } from "../moment-BGjjqtLQ.js";
6
+ import { h as C } from "../moment-BGjjqtLQ.js";
7
7
  import { EFlightEndpoint as V } from "../constants/endpoints.js";
8
8
  import { mapBaggageType as W } from "../hooks/useFlightSearch/useFlightSearch.types.js";
9
9
  import { WalletService as J } from "../services/wallet/WalletService.js";
10
10
  import { ERewardProgramCategories as X } from "../services/wallet/WalletService.types.js";
11
- const f = "https://assets.duffel.com/img/airlines/for-light-background/full-color-lockup/", Ce = (s) => s == null ? void 0 : s.map((e) => {
12
- var m, o, c, t, i, p, l, n, r, u, d, g, b, F, A, L, w, h, D, P, I, k, T, O, R, _, v, E, M, N, $, z, G, Z, S, U;
13
- const a = te(e);
11
+ const f = "https://assets.duffel.com/img/airlines/for-light-background/full-color-lockup/", ye = (s) => s == null ? void 0 : s.map((e) => {
12
+ var l, n, c, a, i, u, d, r, o, p, m, g, y, b, F, A, L, w, T, D, P, I, k, O, R, _, v, E, M, N, $, z, G, Z, S, U;
13
+ const t = ae(e);
14
14
  return {
15
15
  id: e.id,
16
16
  points: (e == null ? void 0 : e.points) >= 0 ? e.points : -1,
17
17
  partial: e == null ? void 0 : e.partial,
18
18
  origin: {
19
- city: ((m = e.slices[0].segments[0].origin) == null ? void 0 : m.cityName) || ((c = (o = e.slices[0].segments[0].origin) == null ? void 0 : o.city) == null ? void 0 : c.name) || "",
20
- country: ((t = e.slices[0].segments[0].origin) == null ? void 0 : t.iataCountryCode) || ((p = (i = e.slices[0].segments[0].origin) == null ? void 0 : i.city) == null ? void 0 : p.iataCountryCode) || "",
21
- airportCode: ((l = e.slices[0].segments[0].origin) == null ? void 0 : l.iataCode) || ((r = (n = e.slices[0].segments[0].origin) == null ? void 0 : n.city) == null ? void 0 : r.iataCode) || "",
19
+ city: ((l = e.slices[0].segments[0].origin) == null ? void 0 : l.cityName) || ((c = (n = e.slices[0].segments[0].origin) == null ? void 0 : n.city) == null ? void 0 : c.name) || "",
20
+ country: ((a = e.slices[0].segments[0].origin) == null ? void 0 : a.iataCountryCode) || ((u = (i = e.slices[0].segments[0].origin) == null ? void 0 : i.city) == null ? void 0 : u.iataCountryCode) || "",
21
+ airportCode: ((d = e.slices[0].segments[0].origin) == null ? void 0 : d.iataCode) || ((o = (r = e.slices[0].segments[0].origin) == null ? void 0 : r.city) == null ? void 0 : o.iataCode) || "",
22
22
  coordinates: {
23
- latitude: ((d = (u = e.slices[0].segments[0].origin) == null ? void 0 : u.city) == null ? void 0 : d.latitude) || 0,
24
- longitude: ((b = (g = e.slices[0].segments[0].origin) == null ? void 0 : g.city) == null ? void 0 : b.longitude) || 0
23
+ latitude: ((m = (p = e.slices[0].segments[0].origin) == null ? void 0 : p.city) == null ? void 0 : m.latitude) || 0,
24
+ longitude: ((y = (g = e.slices[0].segments[0].origin) == null ? void 0 : g.city) == null ? void 0 : y.longitude) || 0
25
25
  }
26
26
  },
27
27
  destination: {
28
- city: ((A = (F = e.slices[0].segments.getLast()) == null ? void 0 : F.destination) == null ? void 0 : A.cityName) || ((h = (w = (L = e.slices[0].segments.getLast()) == null ? void 0 : L.destination) == null ? void 0 : w.city) == null ? void 0 : h.name) || "",
29
- country: ((P = (D = e.slices[0].segments.getLast()) == null ? void 0 : D.destination) == null ? void 0 : P.iataCountryCode) || ((T = (k = (I = e.slices[0].segments.getLast()) == null ? void 0 : I.destination) == null ? void 0 : k.city) == null ? void 0 : T.iataCountryCode) || "",
28
+ city: ((F = (b = e.slices[0].segments.getLast()) == null ? void 0 : b.destination) == null ? void 0 : F.cityName) || ((w = (L = (A = e.slices[0].segments.getLast()) == null ? void 0 : A.destination) == null ? void 0 : L.city) == null ? void 0 : w.name) || "",
29
+ country: ((D = (T = e.slices[0].segments.getLast()) == null ? void 0 : T.destination) == null ? void 0 : D.iataCountryCode) || ((k = (I = (P = e.slices[0].segments.getLast()) == null ? void 0 : P.destination) == null ? void 0 : I.city) == null ? void 0 : k.iataCountryCode) || "",
30
30
  airportCode: ((R = (O = e.slices[0].segments.getLast()) == null ? void 0 : O.destination) == null ? void 0 : R.iataCode) || ((E = (v = (_ = e.slices[0].segments.getLast()) == null ? void 0 : _.destination) == null ? void 0 : v.city) == null ? void 0 : E.iataCode) || "",
31
31
  coordinates: {
32
32
  latitude: (($ = (N = (M = e.slices[0].segments.getLast()) == null ? void 0 : M.destination) == null ? void 0 : N.city) == null ? void 0 : $.latitude) || 0,
@@ -34,15 +34,15 @@ const f = "https://assets.duffel.com/img/airlines/for-light-background/full-colo
34
34
  }
35
35
  },
36
36
  // `airline` is an existing unqualified field; semantics are display-primary carrier.
37
- airline: (a == null ? void 0 : a.name) ?? "",
38
- airlineLogo: C((a == null ? void 0 : a.iataCode) ?? ""),
39
- displayAirlineIataCode: (a == null ? void 0 : a.iataCode) ?? "",
37
+ airline: (t == null ? void 0 : t.name) ?? "",
38
+ airlineLogo: h((t == null ? void 0 : t.iataCode) ?? ""),
39
+ displayAirlineIataCode: (t == null ? void 0 : t.iataCode) ?? "",
40
40
  cash: e.totalAmount ? parseFloat(e.totalAmount) : 0,
41
41
  currency: e.baseCurrency,
42
42
  flightNumber: ee(e.slices[0].segments[0]),
43
43
  awayzGroupId: e.slices[0].comparisonKey || e.awayzRouteId || e.awayzGroupId || e.id,
44
- departureTime: y(e.slices[0].segments[0].departingAt).toDate(),
45
- arrivalTime: y(
44
+ departureTime: C(e.slices[0].segments[0].departingAt).toDate(),
45
+ arrivalTime: C(
46
46
  e.slices[0].segments[e.slices[0].segments.length - 1].arrivingAt
47
47
  ).toDate(),
48
48
  numberOfStops: e.slices[0].segments.length - 1,
@@ -51,8 +51,8 @@ const f = "https://assets.duffel.com/img/airlines/for-light-background/full-colo
51
51
  airlineProgram: e.airlineProgram,
52
52
  paymentOptions: [],
53
53
  durationMinutes: q({
54
- departureTime: y(e.slices[0].segments[0].departingAt),
55
- arrivalTime: y((S = e.slices[0].segments.getLast()) == null ? void 0 : S.arrivingAt),
54
+ departureTime: C(e.slices[0].segments[0].departingAt),
55
+ arrivalTime: C((S = e.slices[0].segments.getLast()) == null ? void 0 : S.arrivingAt),
56
56
  originTimeZone: e.slices[0].segments[0].origin.timeZone,
57
57
  destinationTimeZone: (U = e.slices[0].segments.getLast()) == null ? void 0 : U.destination.timeZone,
58
58
  duration: e.slices[0].duration
@@ -60,135 +60,139 @@ const f = "https://assets.duffel.com/img/airlines/for-light-background/full-colo
60
60
  cashFee: e.cashFee,
61
61
  cabinClass: e.slices[0].segments[0].passengers[0].cabinClass || e.slices[0].segments[0].passengers[0].cabin.name || e.slices[0].segments[0].passengers[0].cabinClassMarketingName || e.slices[0].segments[0].passengers[0].cabin.marketingName,
62
62
  expiresAt: e.expiresAt,
63
- transferPartners: e.partners
63
+ transferPartners: e.partners,
64
+ isCached: e.isCached,
65
+ lastCachedTime: e.lastCachedTime
64
66
  };
65
67
  }), ee = (s) => {
66
- const e = s.marketingCarrier ?? s.operatingCarrier, a = s.marketingCarrierFlightNumber ?? s.operatingCarrierFlightNumber;
67
- return e.iataCode + " " + H(a);
68
+ const e = s.marketingCarrier ?? s.operatingCarrier, t = s.marketingCarrierFlightNumber ?? s.operatingCarrierFlightNumber;
69
+ return e.iataCode + " " + H(t);
68
70
  }, se = (s) => {
69
- var a;
70
- const e = (a = s == null ? void 0 : s.segments) == null ? void 0 : a[0];
71
+ var t;
72
+ const e = (t = s == null ? void 0 : s.segments) == null ? void 0 : t[0];
71
73
  return (e == null ? void 0 : e.marketingCarrier) ?? (e == null ? void 0 : e.operatingCarrier);
72
- }, te = (s) => {
74
+ }, ae = (s) => {
73
75
  var e;
74
76
  return se((e = s == null ? void 0 : s.slices) == null ? void 0 : e[0]);
75
- }, be = (s) => !s.operatingCarrier || !s.marketingCarrier ? "" : s.operatingCarrier.iataCode !== s.marketingCarrier.iataCode ? s.operatingCarrier.name : "", Fe = ({
77
+ }, he = (s) => !s.operatingCarrier || !s.marketingCarrier ? "" : s.operatingCarrier.iataCode !== s.marketingCarrier.iataCode ? s.operatingCarrier.name : "", be = ({
76
78
  originCode: s,
77
79
  destinationCode: e,
78
- dates: a,
79
- cabinClass: m,
80
- passengerCount: o,
80
+ dates: t,
81
+ cabinClass: l,
82
+ passengerCount: n,
81
83
  paymentType: c
82
84
  }) => {
83
- let t = `${V.CASH_POINTS_FLIGHT_SEARCH}?`;
84
- return t += `origin=${s}`, t += `&destination=${e}`, t += `&departure_dates=[${a.map((i) => `"${i}"`).join(",")}]`, t += `&cabin_class=${m}`, t += `&adults=${o}`, t += `&cash_or_points=[${c}]`, t;
85
- }, ae = (s) => s.flightDetails.slices[0].segments.map((a) => ie(a)).join("_") + "_" + y(s.departureTime).format("YYYYMMDD"), ie = (s) => {
86
- const e = s.operatingCarrier ?? s.marketingCarrier, a = s.operatingCarrierFlightNumber ?? s.marketingCarrierFlightNumber;
87
- return e.iataCode + " " + H(a);
88
- }, Ae = (s) => s ? s.replace(/[_-]/g, " ").split(" ").map((e) => e.charAt(0).toUpperCase() + e.slice(1).toLowerCase()).join(" ") : "", Le = (s) => {
85
+ let a = `${V.CASH_POINTS_FLIGHT_SEARCH}?`;
86
+ return a += `origin=${s}`, a += `&destination=${e}`, a += `&departure_dates=[${t.map((i) => `"${i}"`).join(",")}]`, a += `&cabin_class=${l}`, a += `&adults=${n}`, a += `&cash_or_points=[${c}]`, a;
87
+ }, te = (s) => s.flightDetails.slices[0].segments.map((t) => ie(t)).join("_") + "_" + C(s.departureTime).format("YYYYMMDD"), ie = (s) => {
88
+ const e = s.operatingCarrier ?? s.marketingCarrier, t = s.operatingCarrierFlightNumber ?? s.marketingCarrierFlightNumber;
89
+ return e.iataCode + " " + H(t);
90
+ }, Fe = (s) => s ? s.replace(/[_-]/g, " ").split(" ").map((e) => e.charAt(0).toUpperCase() + e.slice(1).toLowerCase()).join(" ") : "", Ae = (s) => {
89
91
  const e = {};
90
- s.forEach((t) => {
91
- var p, l;
92
- const i = ae(t);
92
+ s.forEach((a) => {
93
+ var u, d;
94
+ const i = te(a);
93
95
  if (e[i]) {
94
- const n = K(t);
95
- e[i].flight.paymentOptions.push(n);
96
- const { lowestCash: r, currency: u, lowestPoints: d, cashFee: g } = j(e[i].flight.paymentOptions);
97
- e[i].flight.points = d, e[i].flight.cashFee = g, e[i].flight.cash = r, u && (e[i].flight.currency = u);
96
+ const r = K(a);
97
+ e[i].flight.paymentOptions.push(r);
98
+ const { lowestCash: o, currency: p, lowestPoints: m, cashFee: g, cacheData: y } = j(e[i].flight.paymentOptions);
99
+ e[i].flight.points = m, e[i].flight.cashFee = g, e[i].flight.cash = o, p && (e[i].flight.currency = p), e[i].flight.isCached = y.isCached, e[i].flight.lastCachedTime = y.lastCachedTime;
98
100
  } else {
99
- const { origin: n, destination: r } = t, u = [K(t)], d = j(u);
101
+ const { origin: r, destination: o } = a, p = [K(a)], m = j(p);
100
102
  e[i] = {
101
103
  programs: [],
102
104
  flight: {
103
- id: t.awayzGroupId,
104
- partial: t.partial,
105
+ id: a.awayzGroupId,
106
+ partial: a.partial,
105
107
  origin: {
106
- city: n.city,
107
- country: n.country,
108
- airportCode: n.airportCode,
109
- coordinates: n.coordinates
110
- },
111
- destination: {
112
108
  city: r.city,
113
109
  country: r.country,
114
110
  airportCode: r.airportCode,
115
111
  coordinates: r.coordinates
116
112
  },
117
- airline: t.airline,
118
- airlineLogo: t.airlineLogo,
119
- displayAirlineIataCode: t.displayAirlineIataCode,
120
- flightNumber: t.flightNumber,
121
- paymentOptions: u,
122
- numberOfStops: t.numberOfStops,
123
- departureTime: t.departureTime,
124
- arrivalTime: t.arrivalTime,
113
+ destination: {
114
+ city: o.city,
115
+ country: o.country,
116
+ airportCode: o.airportCode,
117
+ coordinates: o.coordinates
118
+ },
119
+ airline: a.airline,
120
+ airlineLogo: a.airlineLogo,
121
+ displayAirlineIataCode: a.displayAirlineIataCode,
122
+ flightNumber: a.flightNumber,
123
+ paymentOptions: p,
124
+ numberOfStops: a.numberOfStops,
125
+ departureTime: a.departureTime,
126
+ arrivalTime: a.arrivalTime,
125
127
  awayzGroupId: i,
126
- duration: t.duration,
127
- airlineProgram: t.airlineProgram,
128
+ duration: a.duration,
129
+ airlineProgram: a.airlineProgram,
128
130
  durationMinutes: q({
129
- departureTime: y(
130
- t.flightDetails.slices[0].segments[0].departingAt
131
+ departureTime: C(
132
+ a.flightDetails.slices[0].segments[0].departingAt
131
133
  ),
132
- arrivalTime: y(
133
- (p = t.flightDetails.slices[0].segments.getLast()) == null ? void 0 : p.arrivingAt
134
+ arrivalTime: C(
135
+ (u = a.flightDetails.slices[0].segments.getLast()) == null ? void 0 : u.arrivingAt
134
136
  ),
135
- originTimeZone: t.flightDetails.slices[0].segments[0].origin.timeZone,
136
- destinationTimeZone: (l = t.flightDetails.slices[0].segments.getLast()) == null ? void 0 : l.destination.timeZone,
137
- duration: t.flightDetails.slices[0].duration
137
+ originTimeZone: a.flightDetails.slices[0].segments[0].origin.timeZone,
138
+ destinationTimeZone: (d = a.flightDetails.slices[0].segments.getLast()) == null ? void 0 : d.destination.timeZone,
139
+ duration: a.flightDetails.slices[0].duration
138
140
  }),
139
- cash: d.lowestCash,
140
- points: d.lowestPoints,
141
- flightDetails: t.flightDetails,
142
- currency: t.flightDetails.baseCurrency,
143
- cashFee: t.cashFee,
144
- cabinClass: t.flightDetails.slices[0].segments[0].passengers[0].cabinClass || t.flightDetails.slices[0].segments[0].passengers[0].cabin.name || t.flightDetails.slices[0].segments[0].passengers[0].cabinClassMarketingName || t.flightDetails.slices[0].segments[0].passengers[0].cabin.marketingName,
145
- expiresAt: t.expiresAt,
146
- transferPartners: t.transferPartners || []
141
+ cash: m.lowestCash,
142
+ points: m.lowestPoints,
143
+ flightDetails: a.flightDetails,
144
+ currency: a.flightDetails.baseCurrency,
145
+ cashFee: a.cashFee,
146
+ cabinClass: a.flightDetails.slices[0].segments[0].passengers[0].cabinClass || a.flightDetails.slices[0].segments[0].passengers[0].cabin.name || a.flightDetails.slices[0].segments[0].passengers[0].cabinClassMarketingName || a.flightDetails.slices[0].segments[0].passengers[0].cabin.marketingName,
147
+ expiresAt: a.expiresAt,
148
+ transferPartners: a.transferPartners || [],
149
+ isCached: a.isCached,
150
+ lastCachedTime: a.lastCachedTime
147
151
  }
148
152
  };
149
153
  }
150
- t.airlineProgram && !e[i].programs.includes(t.airlineProgram) && e[i].programs.push(t.airlineProgram);
154
+ a.airlineProgram && !e[i].programs.includes(a.airlineProgram) && e[i].programs.push(a.airlineProgram);
151
155
  });
152
- const a = [];
153
- Object.values(e).forEach((t) => {
154
- const i = t.flight.paymentOptions.filter((n) => n.cash > 0).reduce(
155
- (n, r) => r.cash < n.cash ? r : n,
156
+ const t = [];
157
+ Object.values(e).forEach((a) => {
158
+ const i = a.flight.paymentOptions.filter((r) => r.cash > 0).reduce(
159
+ (r, o) => o.cash < r.cash ? o : r,
156
160
  { cash: 1 / 0, carrier: { name: "", iataCode: "" } }
157
- ), p = {
158
- iataCode: t.flight.displayAirlineIataCode,
159
- name: t.flight.airline
160
- }, l = i.cash !== 1 / 0 ? i.carrier : p;
161
- t.programs.length > 0 ? t.programs.forEach((n) => {
162
- const r = t.flight.paymentOptions.filter(
163
- (d) => d.program === n && d.points > 0
164
- ), u = r.length > 0 ? Math.min(...r.map((d) => d.points)) : -1;
165
- a.push({
166
- ...t.flight,
167
- airline: l.name,
168
- airlineLogo: C(l.iataCode),
169
- displayAirlineIataCode: l.iataCode,
170
- airlineProgram: n,
161
+ ), u = {
162
+ iataCode: a.flight.displayAirlineIataCode,
163
+ name: a.flight.airline
164
+ }, d = i.cash !== 1 / 0 ? i.carrier : u;
165
+ a.programs.length > 0 ? a.programs.forEach((r) => {
166
+ const o = a.flight.paymentOptions.filter(
167
+ (m) => m.program === r && m.points > 0
168
+ ), p = o.length > 0 ? Math.min(...o.map((m) => m.points)) : -1;
169
+ t.push({
170
+ ...a.flight,
171
+ airline: d.name,
172
+ airlineLogo: h(d.iataCode),
173
+ displayAirlineIataCode: d.iataCode,
174
+ airlineProgram: r,
171
175
  cash: i.cash !== 1 / 0 ? i.cash : -1,
172
- points: u
176
+ points: p
173
177
  });
174
- }) : a.push({
175
- ...t.flight,
176
- airline: l.name,
177
- airlineLogo: C(l.iataCode),
178
- displayAirlineIataCode: l.iataCode,
178
+ }) : t.push({
179
+ ...a.flight,
180
+ airline: d.name,
181
+ airlineLogo: h(d.iataCode),
182
+ displayAirlineIataCode: d.iataCode,
179
183
  cash: i.cash !== 1 / 0 ? i.cash : -1
180
184
  });
181
185
  });
182
- const { cashlessResults: m, otherResults: o } = a.reduce(
183
- (t, i) => (i.cash <= 0 && i.points > 0 ? t.cashlessResults.push(i) : i.cash > 0 && t.otherResults.push(i), t),
186
+ const { cashlessResults: l, otherResults: n } = t.reduce(
187
+ (a, i) => (i.cash <= 0 && i.points > 0 ? a.cashlessResults.push(i) : i.cash > 0 && a.otherResults.push(i), a),
184
188
  { cashlessResults: [], otherResults: [] }
185
- ), c = [...o];
186
- return m.forEach((t) => {
189
+ ), c = [...n];
190
+ return l.forEach((a) => {
187
191
  (!c.find(
188
- (p) => p.awayzGroupId === t.awayzGroupId
189
- ) || o.length === 0) && c.push(t);
192
+ (u) => u.awayzGroupId === a.awayzGroupId
193
+ ) || n.length === 0) && c.push(a);
190
194
  }), c;
191
- }, H = (s) => s ? s.replace(/^0+/, "") : "", we = (s) => `https://assets.duffel.com/img/airlines/for-light-background/full-color-logo/${s}.svg`, C = (s) => `${f}${s}.svg`, B = Y.logoFallbackImageUrl, x = {
195
+ }, H = (s) => s ? s.replace(/^0+/, "") : "", Le = (s) => `https://assets.duffel.com/img/airlines/for-light-background/full-color-logo/${s}.svg`, h = (s) => `${f}${s}.svg`, B = Y.logoFallbackImageUrl, x = {
192
196
  categoryLogo: B,
193
197
  programLogo: B,
194
198
  awayzActive: [],
@@ -200,28 +204,28 @@ const f = "https://assets.duffel.com/img/airlines/for-light-background/full-colo
200
204
  colour: "#fff",
201
205
  // Using App Foreground Colour
202
206
  url: "https://www.odynn.com"
203
- }, he = async (s) => {
207
+ }, we = async (s) => {
204
208
  const { airlines: e } = await Q.ensureQueryData({
205
209
  queryKey: ["walletAwards"],
206
210
  queryFn: J.getAwards,
207
211
  staleTime: 864e5
208
212
  // 24 hours
209
213
  });
210
- let a = e.find(
211
- (m) => {
212
- var o, c, t, i;
213
- return ((c = (o = m.mainProgram) == null ? void 0 : o.toLowerCase()) == null ? void 0 : c.includes(s == null ? void 0 : s.toLowerCase())) || ((i = (t = m.displayProgram) == null ? void 0 : t.toLowerCase()) == null ? void 0 : i.includes(s == null ? void 0 : s.toLowerCase()));
214
+ let t = e.find(
215
+ (l) => {
216
+ var n, c, a, i;
217
+ return ((c = (n = l.mainProgram) == null ? void 0 : n.toLowerCase()) == null ? void 0 : c.includes(s == null ? void 0 : s.toLowerCase())) || ((i = (a = l.displayProgram) == null ? void 0 : a.toLowerCase()) == null ? void 0 : i.includes(s == null ? void 0 : s.toLowerCase()));
214
218
  }
215
219
  ) ?? x;
216
- return a || (a = {
220
+ return t || (t = {
217
221
  ...x,
218
222
  mainProgram: s,
219
223
  displayProgram: s,
220
224
  id: s
221
- }), a;
225
+ }), t;
222
226
  }, K = (s) => {
223
- var o, c, t, i, p, l, n, r, u, d;
224
- const e = ((t = (c = (o = s.flightDetails.slices.getFirst()) == null ? void 0 : o.segments.getFirst()) == null ? void 0 : c.passengers.getFirst()) == null ? void 0 : t.baggages) ?? [], a = ((l = (p = (i = s.flightDetails.slices.getFirst()) == null ? void 0 : i.segments.getFirst()) == null ? void 0 : p.passengers.getFirst()) == null ? void 0 : l.cabinClassMarketingName) ?? ((u = (r = (n = s.flightDetails.slices.getFirst()) == null ? void 0 : n.segments.getFirst()) == null ? void 0 : r.passengers.getFirst()) == null ? void 0 : u.cabinClass), m = e.map(
227
+ var n, c, a, i, u, d, r, o, p, m;
228
+ const e = ((a = (c = (n = s.flightDetails.slices.getFirst()) == null ? void 0 : n.segments.getFirst()) == null ? void 0 : c.passengers.getFirst()) == null ? void 0 : a.baggages) ?? [], t = ((d = (u = (i = s.flightDetails.slices.getFirst()) == null ? void 0 : i.segments.getFirst()) == null ? void 0 : u.passengers.getFirst()) == null ? void 0 : d.cabinClassMarketingName) ?? ((p = (o = (r = s.flightDetails.slices.getFirst()) == null ? void 0 : r.segments.getFirst()) == null ? void 0 : o.passengers.getFirst()) == null ? void 0 : p.cabinClass), l = e.map(
225
229
  (g) => ({
226
230
  type: W(g.type),
227
231
  quantity: g.quantity
@@ -233,39 +237,45 @@ const f = "https://assets.duffel.com/img/airlines/for-light-background/full-colo
233
237
  points: s.points,
234
238
  program: s.airlineProgram,
235
239
  baseCurrency: s.flightDetails.baseCurrency,
236
- fareBrandName: ((d = s.flightDetails.slices.getFirst()) == null ? void 0 : d.fareBrandName) ?? "",
237
- cabinClass: a,
240
+ fareBrandName: ((m = s.flightDetails.slices.getFirst()) == null ? void 0 : m.fareBrandName) ?? "",
241
+ cabinClass: t,
238
242
  cashFee: s.cashFee,
239
243
  conditions: s.flightDetails.conditions,
240
- baggages: m,
244
+ baggages: l,
241
245
  // `carrier` is an existing unqualified field; semantics are marketing carrier.
242
246
  carrier: {
243
247
  iataCode: s.displayAirlineIataCode,
244
248
  name: s.airline
245
- }
249
+ },
250
+ isCached: s.isCached,
251
+ lastCachedTime: s.lastCachedTime
246
252
  };
247
253
  }, j = (s) => {
248
- const e = s.filter((t) => t.cash > 0);
249
- let a = { cash: 1 / 0, baseCurrency: "" };
250
- for (const t of e)
251
- t.cash < a.cash && (a = t);
252
- const o = [...s].filter(
253
- (t) => t.points > 0
254
- ).reduce(
255
- (t, i) => i.points < t.points ? i : t,
256
- {
257
- points: 1 / 0,
258
- cashFee: {
259
- amount: 0,
260
- currency: ""
261
- }
262
- }
263
- ), c = a.cash;
254
+ const e = s.filter((a) => a.cash > 0);
255
+ let t = { cash: 1 / 0, baseCurrency: "" };
256
+ for (const a of e)
257
+ a.cash < t.cash && (t = a);
258
+ const l = [...s].filter(
259
+ (a) => a.points > 0
260
+ );
261
+ let n = {
262
+ points: 1 / 0,
263
+ cashFee: { amount: 0, currency: "" },
264
+ isCached: !1,
265
+ lastCachedTime: ""
266
+ };
267
+ for (const a of l)
268
+ a.points < n.points && (n = a);
269
+ const c = t.cash;
264
270
  return {
265
271
  lowestCash: c === 1 / 0 ? -1 : c,
266
- lowestPoints: o.points === 1 / 0 ? -1 : o.points,
267
- cashFee: o.cashFee,
268
- currency: a.baseCurrency === "" ? null : a.baseCurrency
272
+ lowestPoints: n.points === 1 / 0 ? -1 : n.points,
273
+ cashFee: n.cashFee,
274
+ currency: t.baseCurrency === "" ? null : t.baseCurrency,
275
+ cacheData: {
276
+ isCached: n.isCached ?? !1,
277
+ lastCachedTime: n.lastCachedTime ?? ""
278
+ }
269
279
  };
270
280
  }, ne = (s) => [
271
281
  ...Array.from({ length: s.adults }, () => ({
@@ -276,30 +286,30 @@ const f = "https://assets.duffel.com/img/airlines/for-light-background/full-colo
276
286
  type: "child"
277
287
  /* CHILD */
278
288
  }))
279
- ], De = (s) => {
280
- const a = {
289
+ ], Te = (s) => {
290
+ const t = {
281
291
  adults: (s == null ? void 0 : s.adults) ?? 1,
282
292
  children: (s == null ? void 0 : s.children) ?? 0
283
- }, m = ne(a);
293
+ }, l = ne(t);
284
294
  return {
285
- passengerCount: a.adults + a.children,
286
- passengerList: m
295
+ passengerCount: t.adults + t.children,
296
+ passengerList: l
287
297
  };
288
298
  };
289
299
  export {
290
300
  x as DEFAULT_AIRLINE_PROGRAM,
291
- Fe as buildFlightSearchQuery,
301
+ be as buildFlightSearchQuery,
292
302
  ne as buildPassengerArray,
293
- Ae as formatCabinClass,
294
- he as getAirlineProgram,
303
+ Fe as formatCabinClass,
304
+ we as getAirlineProgram,
295
305
  ee as getFlightNumber,
296
- C as getFullLogoPath,
297
- we as getLogoPath,
298
- be as getOperatedBy,
299
- te as getPrimaryDisplayCarrierForFlightOffer,
306
+ h as getFullLogoPath,
307
+ Le as getLogoPath,
308
+ he as getOperatedBy,
309
+ ae as getPrimaryDisplayCarrierForFlightOffer,
300
310
  se as getPrimaryDisplayCarrierForSlice,
301
- Le as groupFlightResults,
302
- Ce as mapDataToFlightDetails,
303
- De as passengerValues,
311
+ Ae as groupFlightResults,
312
+ ye as mapDataToFlightDetails,
313
+ Te as passengerValues,
304
314
  H as removeLeadingZeros
305
315
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@odynn/awayz-flights",
3
- "version": "0.10.14",
3
+ "version": "0.10.16",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"
@@ -69,7 +69,7 @@
69
69
  },
70
70
  "dependencies": {
71
71
  "@microsoft/fetch-event-source": "^2.0.1",
72
- "@odynn/awayz-core": ">= 0.10.0",
72
+ "@odynn/awayz-core": "^0.10.31",
73
73
  "@radix-ui/react-dialog": "^1.1.15",
74
74
  "@tanstack/react-query": "^5.67.1",
75
75
  "country-code-lookup": "^0.1.3"
@@ -1,104 +0,0 @@
1
- import { jsx as t, jsxs as a, Fragment as g } from "react/jsx-runtime";
2
- import { useAwayzContext as Y } from "@odynn/awayz-core";
3
- import { g as S, b as C } from "./dateUtils-Cb9VQiIL.js";
4
- import { l as E } from "./arrayExtensions-Ce8YopTP.js";
5
- import "react";
6
- import { h as l } from "./moment-BGjjqtLQ.js";
7
- import { useTranslation as N } from "react-i18next";
8
- import { a as W } from "./index-Kopwbl-x.js";
9
- import './assets/FlightItinerary.css';const f = (r) => {
10
- var o;
11
- if (!r) return "";
12
- try {
13
- return (o = E.byIso(r)) == null ? void 0 : o.country;
14
- } catch (d) {
15
- return console.error(d), "";
16
- }
17
- };
18
- var n = /* @__PURE__ */ ((r) => (r.ISO = "dates:iso", r.DISPLAY_SHORT = "dates:displayShort", r.DISPLAY_MEDIUM = "dates:displayMedium", r.DISPLAY_LONG = "dates:displayLong", r.DISPLAY_FULL = "dates:displayFull", r.DISPLAY_SHORT_WITH_YEAR = "dates:displayShortWithYear", r.DISPLAY_MEDIUM_WITH_YEAR = "dates:displayMediumWithYear", r.DISPLAY_LONG_WITH_YEAR = "dates:displayLongWithYear", r.DISPLAY_FULL_WITH_YEAR = "dates:displayFullWithYear", r.DATE_TIME_SHORT = "dates:dateTimeShort", r.DATE_TIME_MEDIUM = "dates:dateTimeMedium", r.DATE_TIME_LONG = "dates:dateTimeLong", r.DATE_TIME_FULL = "dates:dateTimeFull", r.DATE_TIME_SHORT_WITH_YEAR = "dates:dateTimeShortWithYear", r.DATE_TIME_MEDIUM_WITH_YEAR = "dates:dateTimeMediumWithYear", r.DATE_TIME_LONG_WITH_YEAR = "dates:dateTimeLongWithYear", r.DATE_TIME_FULL_WITH_YEAR = "dates:dateTimeFullWithYear", r.TIME_ONLY = "dates:timeOnly", r.TIME_WITH_SECONDS = "dates:timeWithSeconds", r))(n || {});
19
- const D = ({
20
- itinerary: r,
21
- hideCabinClass: o
22
- }) => {
23
- const { t: d } = N(), { config: e } = Y();
24
- return /* @__PURE__ */ t("div", { className: "flight-itinerary", children: r.map((i, A) => {
25
- var c, _, T, h, m, p, I;
26
- const s = r[A + 1], L = i.operatingCarrier.logoSymbolUrl ?? i.operatingCarrier.logo ?? ((c = i.marketingCarrier) == null ? void 0 : c.logoSymbolUrl) ?? ((_ = i.marketingCarrier) == null ? void 0 : _.logo), M = ((h = (T = i.passengers[0]) == null ? void 0 : T.cabin) == null ? void 0 : h.marketingName.toLowerCase()) ?? ((m = i.passengers[0]) == null ? void 0 : m.cabinClass);
27
- return /* @__PURE__ */ a(g, { children: [
28
- /* @__PURE__ */ a("div", { className: "flight-itinerary-segment", children: [
29
- /* @__PURE__ */ a("div", { children: [
30
- /* @__PURE__ */ a("div", { className: "segment-details", children: [
31
- /* @__PURE__ */ t(
32
- "img",
33
- {
34
- src: L,
35
- alt: i.operatingCarrier.name,
36
- onError: (u) => u.currentTarget.src = (e == null ? void 0 : e.logoFallbackImageUrl) ?? ""
37
- }
38
- ),
39
- /* @__PURE__ */ a("div", { children: [
40
- /* @__PURE__ */ a("p", { children: [
41
- l(i.departingAt).format(
42
- d(n.DATE_TIME_MEDIUM)
43
- ),
44
- " ",
45
- "-",
46
- " ",
47
- l(i.arrivingAt).format(
48
- d(n.DATE_TIME_MEDIUM)
49
- )
50
- ] }),
51
- /* @__PURE__ */ a("div", { className: "flight-locations", children: [
52
- /* @__PURE__ */ t("p", { children: i.origin.iataCode }),
53
- /* @__PURE__ */ t(W, {}),
54
- /* @__PURE__ */ t("p", { children: i.destination.iataCode })
55
- ] })
56
- ] })
57
- ] }),
58
- /* @__PURE__ */ a("div", { className: "segment-times", children: [
59
- /* @__PURE__ */ t("p", { children: S(i.duration) }),
60
- !o && /* @__PURE__ */ t("p", { className: "cabin-class", children: M })
61
- ] })
62
- ] }),
63
- /* @__PURE__ */ a("div", { className: "operated-by", children: [
64
- /* @__PURE__ */ a("p", { children: [
65
- "Operated by ",
66
- i.operatingCarrier.name
67
- ] }),
68
- /* @__PURE__ */ a("p", { children: [
69
- "Aircraft ",
70
- (p = i.aircraft) == null ? void 0 : p.name,
71
- " •",
72
- " ",
73
- i.operatingCarrier.iataCode,
74
- " ",
75
- i.operatingCarrierFlightNumber ?? i.marketingCarrierFlightNumber
76
- ] })
77
- ] })
78
- ] }, i.id),
79
- s && /* @__PURE__ */ a("div", { className: "flight-itinerary-layover", children: [
80
- /* @__PURE__ */ a("p", { children: [
81
- "Layover in",
82
- " ",
83
- ((I = i.destination.city) == null ? void 0 : I.name) ?? i.destination.cityName,
84
- ", ",
85
- f(i.destination.iataCountryCode),
86
- " ",
87
- "(",
88
- i.destination.iataCode,
89
- ")"
90
- ] }),
91
- /* @__PURE__ */ t("p", { children: C(
92
- l(s.departingAt).diff(
93
- i.arrivingAt,
94
- "minutes"
95
- )
96
- ) })
97
- ] })
98
- ] });
99
- }) });
100
- };
101
- export {
102
- D as F,
103
- f as g
104
- };