@odynn/awayz-flights 0.7.8 → 0.7.11

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,341 @@
1
+ import { jsx as i, jsxs as n, Fragment as L } from "react/jsx-runtime";
2
+ import { useAwayzContext as ar, RewardsService as R, CashValue as $, EToolTipPosition as z, EInvalidAmountDisplayOption as or, awayzClient as Q, CurrencyService as cr } from "@odynn/awayz-core";
3
+ import { useQuery as lr } from "@tanstack/react-query";
4
+ import { g as mr } from "./index-7zRjF0bU.js";
5
+ import { G as pr, g as q, a as v, E as P, F as hr, b as gr } from "./FlightItinerary-Dy-2zMYt.js";
6
+ import { E as x } from "./enums-Bmg_7eKJ.js";
7
+ import "./arrayExtensions-DFLvtO8l.js";
8
+ import fr, { useState as F, useMemo as O, useEffect as I } from "react";
9
+ import { h as p } from "./moment-BGjjqtLQ.js";
10
+ import { useTranslation as ur } from "react-i18next";
11
+ import { EPaymentType as E } from "./enums/EPaymentType.js";
12
+ import { isSameDayFlight as dr } from "./utils/flightDateUtils.js";
13
+ import { DEFAULT_AIRLINE_PROGRAM as w, getFlightNumber as yr, getLogoPath as Nr, getAirlineProgram as vr } from "./utils/flightUtils.js";
14
+ import './assets/FlightResult.css';const Pr = (r, s, c = s + "s") => r === 1 ? s : c;
15
+ function Fr(r) {
16
+ if (!r || isNaN(r) || r < 0) return "N/A";
17
+ let s = r == null ? void 0 : r.toString().split(".")[0];
18
+ return s == null ? void 0 : s.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
19
+ }
20
+ function b(r) {
21
+ return pr({ attr: { viewBox: "0 0 512 512" }, child: [{ tag: "path", attr: { d: "M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM216 336l24 0 0-64-24 0c-13.3 0-24-10.7-24-24s10.7-24 24-24l48 0c13.3 0 24 10.7 24 24l0 88 8 0c13.3 0 24 10.7 24 24s-10.7 24-24 24l-80 0c-13.3 0-24-10.7-24-24s10.7-24 24-24zm40-208a32 32 0 1 1 0 64 32 32 0 1 1 0-64z" }, child: [] }] })(r);
22
+ }
23
+ async function K(r, s, c) {
24
+ if (!r || s === c) return r;
25
+ const a = await Q.ensureQueryData({
26
+ queryKey: [x.CONVERT_CURRENCY, s, c],
27
+ staleTime: 1e3 * 60 * 60,
28
+ // 1 hour
29
+ queryFn: () => cr.convertCurrency({
30
+ baseCurrency: s,
31
+ targetCurrency: c
32
+ })
33
+ });
34
+ return r * a;
35
+ }
36
+ const _r = ({
37
+ details: r,
38
+ onClick: s,
39
+ showBestValue: c = !1,
40
+ onShowBestValueCalculation: a,
41
+ customStyling: G = !1,
42
+ customCashComponent: Y,
43
+ customPointsComponent: j
44
+ }) => {
45
+ const { t: g } = ur(), [k, H] = F(!1), [f, J] = F(
46
+ "none"
47
+ /* NONE */
48
+ ), [W, X] = F(!1), { config: T } = ar(), u = r.origin, d = r.destination, M = r.flightDetails, y = r.paymentOptions || [], Z = y.filter((e) => e.points === -1).length === 1, V = y.filter((e) => e.points > -1).length === 1, [B, S] = F(w), m = O(() => {
49
+ var e = y.filter((t) => t.points > -1).sort((t, o) => t.points - o.points);
50
+ return e.find(
51
+ (t) => t.program === r.airlineProgram
52
+ ) || e[0];
53
+ }, [y, r.airlineProgram]), rr = async () => {
54
+ if (!m) {
55
+ S(w);
56
+ return;
57
+ }
58
+ const e = await vr(m.program);
59
+ S(e);
60
+ };
61
+ I(() => {
62
+ rr();
63
+ }, [m]);
64
+ const { flightNumbers: C, airlines: er } = O(() => {
65
+ const e = [], t = [];
66
+ return r.flightDetails.slices.forEach((o) => {
67
+ o.segments.forEach((l) => {
68
+ const h = yr(l);
69
+ e.includes(h) || e.push(h);
70
+ const N = l.operatingCarrier;
71
+ t.some((A) => A.airline === N.name) || t.push({
72
+ logo: Nr(N.iataCode),
73
+ airline: N.name
74
+ });
75
+ });
76
+ }), { flightNumbers: e, airlines: t };
77
+ }, [r.flightDetails.slices]), ir = () => {
78
+ r.cash > 0 ? s(r, E.CASH) : s(r, E.POINTS);
79
+ }, nr = !dr(
80
+ r.departureTime,
81
+ r.arrivalTime
82
+ ), D = r == null ? void 0 : r.airlineProgram, { data: U } = lr({
83
+ queryKey: [x.VALUE_CENTS, D, "test"],
84
+ queryFn: () => R.getCentPerPoint(D),
85
+ staleTime: 1 / 0,
86
+ enabled: !!D && c
87
+ }), _ = O(() => {
88
+ var e, t;
89
+ return (t = (e = r.paymentOptions) == null ? void 0 : e.find(
90
+ (o) => {
91
+ var l;
92
+ return o.program === r.airlineProgram && ((l = o.cashFee) == null ? void 0 : l.amount) !== 0;
93
+ }
94
+ )) == null ? void 0 : t.cashFee;
95
+ }, [r.paymentOptions, r.airlineProgram]), tr = async () => {
96
+ if (!r || !U || !r.points || !r.cash)
97
+ return;
98
+ const e = r.currency;
99
+ let t = {
100
+ valueCents: 1,
101
+ currency: e
102
+ };
103
+ try {
104
+ t = await Q.ensureQueryData({
105
+ queryKey: [x.VALUE_CENTS, r.airlineProgram],
106
+ staleTime: 1e3 * 60 * 60,
107
+ // 1 hour
108
+ queryFn: () => R.getCentPerPoint(r.airlineProgram)
109
+ });
110
+ } catch (sr) {
111
+ console.warn(
112
+ "Failed to fetch value cents for airline program:",
113
+ r.airlineProgram,
114
+ sr
115
+ );
116
+ }
117
+ const o = _ ?? {
118
+ amount: 0,
119
+ currency: e
120
+ }, [l, h] = await Promise.all([
121
+ K(
122
+ o.amount,
123
+ o.currency,
124
+ e
125
+ ),
126
+ K(
127
+ t.valueCents,
128
+ t.currency,
129
+ e
130
+ )
131
+ ]), A = h * r.points / 100 + l < r.cash;
132
+ J(
133
+ A ? "points" : "cash"
134
+ /* CASH */
135
+ );
136
+ };
137
+ return I(() => {
138
+ tr();
139
+ }, [r, U, _]), I(() => {
140
+ const e = p(r.expiresAt), t = p();
141
+ if (!(e.year() === p(0).year()) && e.isAfter(t)) {
142
+ const l = e.diff(t), h = setTimeout(() => {
143
+ X(!0);
144
+ }, l);
145
+ return () => {
146
+ clearTimeout(h);
147
+ };
148
+ }
149
+ }, [r.expiresAt]), /* @__PURE__ */ i(
150
+ "div",
151
+ {
152
+ className: `${G ? "" : "awayz-"}flight-result`,
153
+ onClick: ir,
154
+ children: /* @__PURE__ */ n("div", { className: "content", children: [
155
+ /* @__PURE__ */ i("div", { className: "flight-info", children: /* @__PURE__ */ n("div", { className: "flight-locations", children: [
156
+ /* @__PURE__ */ i("div", { className: "airlines", children: er.map((e, t) => /* @__PURE__ */ i(fr.Fragment, { children: /* @__PURE__ */ n("div", { className: "tip", children: [
157
+ /* @__PURE__ */ i(
158
+ "img",
159
+ {
160
+ src: e.logo,
161
+ alt: e.airline,
162
+ onError: (o) => o.currentTarget.src = (T == null ? void 0 : T.logoFallbackImageUrl) ?? ""
163
+ }
164
+ ),
165
+ /* @__PURE__ */ i("span", { className: "right", children: e.airline })
166
+ ] }, t) }, t)) }),
167
+ /* @__PURE__ */ n("div", { className: "flight-location", children: [
168
+ /* @__PURE__ */ n("p", { className: "show-desktop", children: [
169
+ u.city,
170
+ ",",
171
+ q(u.country)
172
+ ] }),
173
+ /* @__PURE__ */ i("p", { className: "show-desktop", children: p(r.departureTime).format(
174
+ g(v.DATE_TIME_MEDIUM, P.FlightShortDate)
175
+ ) }),
176
+ /* @__PURE__ */ i("p", { className: "show-mobile", children: u.airportCode }),
177
+ /* @__PURE__ */ i("p", { className: "show-mobile", children: p(r.departureTime).format(
178
+ g(v.TIME_ONLY, P.FlightTime)
179
+ ) })
180
+ ] }),
181
+ /* @__PURE__ */ n("div", { className: "flight-duration", children: [
182
+ /* @__PURE__ */ i("span", { className: "line" }),
183
+ /* @__PURE__ */ n("p", { children: [
184
+ mr(M.slices[0].duration),
185
+ " ",
186
+ " - ",
187
+ r.numberOfStops > 0 ? `${r.numberOfStops} ${Pr(
188
+ r.numberOfStops,
189
+ "Stop"
190
+ )}` : "Direct"
191
+ ] }),
192
+ /* @__PURE__ */ i("span", { className: "line" })
193
+ ] }),
194
+ /* @__PURE__ */ n("div", { children: [
195
+ /* @__PURE__ */ n("p", { className: "show-desktop", children: [
196
+ d.city,
197
+ ", ",
198
+ q(d.country)
199
+ ] }),
200
+ /* @__PURE__ */ n("p", { className: "show-desktop", children: [
201
+ p(r.arrivalTime).format(
202
+ g(v.DATE_TIME_MEDIUM, P.FlightShortDate)
203
+ ),
204
+ " "
205
+ ] }),
206
+ /* @__PURE__ */ i("p", { className: "show-mobile", children: d.airportCode }),
207
+ /* @__PURE__ */ i("p", { className: "show-mobile", children: p(r.arrivalTime).format(
208
+ g(v.TIME_ONLY, P.FlightTime)
209
+ ) })
210
+ ] })
211
+ ] }) }),
212
+ /* @__PURE__ */ n("div", { className: "flight-footer", children: [
213
+ /* @__PURE__ */ i("div", { className: "flight-detail-container", children: /* @__PURE__ */ n(
214
+ "div",
215
+ {
216
+ className: "flight-detail",
217
+ onClick: (e) => {
218
+ e.stopPropagation(), H(!k);
219
+ },
220
+ children: [
221
+ /* @__PURE__ */ i("p", { children: "Aircraft" }),
222
+ /* @__PURE__ */ n("p", { className: "chevron-text", children: [
223
+ /* @__PURE__ */ i(hr, {}),
224
+ /* @__PURE__ */ n("span", { children: [
225
+ C[0],
226
+ C.length > 1 && /* @__PURE__ */ n("sup", { children: [
227
+ "+",
228
+ C.length - 1
229
+ ] })
230
+ ] })
231
+ ] })
232
+ ]
233
+ }
234
+ ) }),
235
+ /* @__PURE__ */ i("div", { className: "booking-options ", children: W ? /* @__PURE__ */ n("div", { className: "offer-expiry", children: [
236
+ /* @__PURE__ */ i("span", { children: /* @__PURE__ */ i(b, {}) }),
237
+ /* @__PURE__ */ i("p", { className: "expired-tip", children: "Offer Expired" })
238
+ ] }) : /* @__PURE__ */ n(L, { children: [
239
+ Y || r.cash > 0 && /* @__PURE__ */ n(
240
+ "div",
241
+ {
242
+ className: `amount-value ${f === "cash" && c ? "show-best-value-flag" : ""}`,
243
+ onClick: (e) => {
244
+ e.stopPropagation(), s(r, E.CASH);
245
+ },
246
+ children: [
247
+ /* @__PURE__ */ i("b", { children: "Cash" }),
248
+ /* @__PURE__ */ n("div", { children: [
249
+ /* @__PURE__ */ i("label", { children: Z ? "Book For" : "From" }),
250
+ /* @__PURE__ */ i(
251
+ $,
252
+ {
253
+ amount: r.cash,
254
+ currency: r.currency,
255
+ position: z.LEFT
256
+ }
257
+ )
258
+ ] }),
259
+ f === "cash" && c && /* @__PURE__ */ n(
260
+ "div",
261
+ {
262
+ className: "best-value-flag tip",
263
+ onClick: (e) => {
264
+ e.stopPropagation(), a == null || a(r);
265
+ },
266
+ children: [
267
+ a && /* @__PURE__ */ i(b, {}),
268
+ /* @__PURE__ */ i("p", { children: "Best Value" }),
269
+ a && /* @__PURE__ */ i("span", { children: "Click to learn more" })
270
+ ]
271
+ }
272
+ )
273
+ ]
274
+ }
275
+ ),
276
+ j || r.points > 0 && /* @__PURE__ */ n(
277
+ "div",
278
+ {
279
+ className: `amount-value ${f === "points" && c ? "show-best-value-flag" : ""}`,
280
+ onClick: (e) => {
281
+ e.stopPropagation(), s(r, E.POINTS);
282
+ },
283
+ children: [
284
+ f === "points" && c && /* @__PURE__ */ n(
285
+ "div",
286
+ {
287
+ className: "best-value-flag tip",
288
+ onClick: (e) => {
289
+ e.stopPropagation(), a == null || a(r);
290
+ },
291
+ children: [
292
+ a && /* @__PURE__ */ i(b, {}),
293
+ /* @__PURE__ */ i("p", { children: "Best Value" }),
294
+ a && /* @__PURE__ */ i("span", { children: "Click to learn more" })
295
+ ]
296
+ }
297
+ ),
298
+ /* @__PURE__ */ i("div", { className: "amount-airline-logo", children: /* @__PURE__ */ i("img", { src: B.programLogo }) }),
299
+ /* @__PURE__ */ n("div", { children: [
300
+ /* @__PURE__ */ i("label", { children: V ? "Book For" : "From" }),
301
+ /* @__PURE__ */ n("p", { children: [
302
+ `${Fr(
303
+ m.points
304
+ )} ${g("miles")}`,
305
+ !!m.cashFee && /* @__PURE__ */ n(L, { children: [
306
+ " + ",
307
+ /* @__PURE__ */ i(
308
+ $,
309
+ {
310
+ amount: m.cashFee.amount,
311
+ currency: m.cashFee.currency,
312
+ customDisplay: "No fee",
313
+ zeroDisplayOption: or.CUSTOM,
314
+ position: z.LEFT
315
+ }
316
+ )
317
+ ] })
318
+ ] })
319
+ ] })
320
+ ]
321
+ }
322
+ )
323
+ ] }) })
324
+ ] }),
325
+ /* @__PURE__ */ i("div", { className: `flight-details ${k ? "is-open" : ""}`, children: /* @__PURE__ */ i("div", { className: "inner", children: /* @__PURE__ */ i(
326
+ gr,
327
+ {
328
+ itinerary: M.slices[0].segments,
329
+ origin: u,
330
+ destination: d,
331
+ isMultiDayFlight: nr
332
+ }
333
+ ) }) })
334
+ ] })
335
+ }
336
+ );
337
+ };
338
+ export {
339
+ _r as F,
340
+ Fr as c
341
+ };
@@ -1,10 +1,10 @@
1
1
  import "react/jsx-runtime";
2
2
  import "@odynn/awayz-core";
3
3
  import "@tanstack/react-query";
4
- import { F as x } from "../../FlightResult-KDQSMbR8.js";
4
+ import { F as x } from "../../FlightResult-gPF9SQ7r.js";
5
5
  import "../../index-7zRjF0bU.js";
6
6
  import "../../FlightItinerary-Dy-2zMYt.js";
7
- import "../../enums-D9aZqf8G.js";
7
+ import "../../enums-Bmg_7eKJ.js";
8
8
  import "../../arrayExtensions-DFLvtO8l.js";
9
9
  import "react";
10
10
  import "../../moment-BGjjqtLQ.js";
@@ -1,4 +1,4 @@
1
- import { F as l } from "../FlightResult-KDQSMbR8.js";
1
+ import { F as l } from "../FlightResult-gPF9SQ7r.js";
2
2
  export {
3
3
  l as FlightResult
4
4
  };
@@ -0,0 +1,4 @@
1
+ var S = /* @__PURE__ */ ((R) => (R.LOCATIONS = "LOCATIONS", R.CHECK_USER = "CHECK_USER", R.USER_REGIONS = "USER_REGIONS", R.CONVERT_CURRENCY = "CONVERT_CURRENCY", R.CLIENT_COMPONENT_KEY = "CLIENT_COMPONENT_KEY", R.SEARCH_LIMIT = "SEARCH_LIMIT", R.PROGRAMS = "PROGRAMS", R.USER_PROGRAMS = "USER_PROGRAMS", R.LINKED_USER_PROGRAMS = "LINKED_USER_PROGRAMS", R.BANKS = "BANKS", R.CARDS = "CARDS", R.USER_CARDS = "USER_CARDS", R.TRIPS = "TRIPS", R.UNCATEGORISED_BOOKINGS = "UNCATEGORISED_BOOKINGS", R.BOOKING = "BOOKING", R.VALUE_CENTS = "VALUE_CENTS", R.AVAILABILITY_ALERTS = "AVAILABILITY_ALERTS", R.ALERT_NOTIFICATIONS = "ALERT_NOTIFICATIONS", R.POINTS_AS_CASH = "POINTS_AS_CASH", R.GET_USER_REGION = "get_user_region", R.PRICING = "pricing", R.FAQS = "faqs", R.FEATURES = "features", R.AIRLINE_HEALTH = "airline_health", R))(S || {});
2
+ export {
3
+ S as E
4
+ };
@@ -2,8 +2,8 @@ import { useAwayzContext as V, awayzClient as _, getBaseUrl as G } from "@odynn/
2
2
  import { useMutation as j } from "@tanstack/react-query";
3
3
  import "../../moment-BGjjqtLQ.js";
4
4
  import "../../arrayExtensions-DFLvtO8l.js";
5
- import { c as U } from "../../objectUtils-CyIaVmog.js";
6
- import { E as q } from "../../enums-D9aZqf8G.js";
5
+ import { c as U } from "../../objectUtils-3IeCVocm.js";
6
+ import { E as q } from "../../enums-Bmg_7eKJ.js";
7
7
  import { useState as x, useRef as X } from "react";
8
8
  import { FlightService as k } from "../../services/flights/FlightsService.js";
9
9
  import Z from "../../stores/useFlightStore.js";
@@ -1,4 +1,4 @@
1
- import { IChangeCondition, ICoordinates, IPassenger, ISlice } from '@type-op/shared';
1
+ import { IChangeCondition, ICoordinates, IPassenger, ISlice, ITransferPartner } from '@type-op/shared';
2
2
  import { EFlightPaymentType, EFlightType } from '../../types';
3
3
  import { ECabinClass } from '../../types/ECabinClass';
4
4
  export interface ISearchFlightArgs {
@@ -150,6 +150,7 @@ export interface IFlightResult {
150
150
  currency: string;
151
151
  cabinClass: string;
152
152
  expiresAt: string;
153
+ transferPartners: ITransferPartner[];
153
154
  }
154
155
  export interface IAirportLocation {
155
156
  city: string;
package/dist/main.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { useFlightSearch as o } from "./hooks/useFlightSearch/useFlightSearch.js";
2
2
  import { useAirportSearch as g } from "./hooks/useAirportSearch/useAirportSearch.js";
3
3
  import { EBaggage as s } from "./hooks/useFlightSearch/useFlightSearch.types.js";
4
- import { F as f, c as l } from "./FlightResult-KDQSMbR8.js";
4
+ import { F as f, c as l } from "./FlightResult-gPF9SQ7r.js";
5
5
  import { EPaymentType as x } from "./enums/EPaymentType.js";
6
6
  import { DEFAULT_AIRLINE_PROGRAM as C, getAirlineProgram as E, getFlightNumber as F, getLogoPath as c } from "./utils/flightUtils.js";
7
7
  import { isSameDayFlight as y } from "./utils/flightDateUtils.js";
@@ -1,10 +1,7 @@
1
- function c(e) {
2
- return e = e.replace(/^_+/, ""), e.replace(/_([a-z])/g, (r, a) => a.toUpperCase());
3
- }
4
1
  const t = (e) => Array.isArray(e) ? e.map((r) => t(r)) : typeof e == "object" && e !== null ? Object.keys(e).reduce((r, a) => {
5
- const n = c(a);
2
+ const n = s(a);
6
3
  return r[n] = t(e[a]), r;
7
- }, {}) : e;
4
+ }, {}) : e, s = (e) => (e = e.replace(/^_+/, ""), e.replace(/_([a-z])/gi, (r, a) => a.toUpperCase()));
8
5
  export {
9
6
  t as c
10
7
  };
@@ -4,7 +4,7 @@ var o = (c, s, a) => p(c, typeof s != "symbol" ? s + "" : s, a);
4
4
  import { clientInstance as d } from "@odynn/awayz-core";
5
5
  import "../../moment-BGjjqtLQ.js";
6
6
  import "../../arrayExtensions-DFLvtO8l.js";
7
- import { c as f } from "../../objectUtils-CyIaVmog.js";
7
+ import { c as f } from "../../objectUtils-3IeCVocm.js";
8
8
  import "react";
9
9
  import { EFlightEndpoint as i } from "../../constants/endpoints.js";
10
10
  class y {
@@ -5,7 +5,7 @@ import { ERewardProgramCategories as o } from "./WalletService.types.js";
5
5
  import { clientInstance as n } from "@odynn/awayz-core";
6
6
  import "../../moment-BGjjqtLQ.js";
7
7
  import "../../arrayExtensions-DFLvtO8l.js";
8
- import { c as a } from "../../objectUtils-CyIaVmog.js";
8
+ import { c as a } from "../../objectUtils-3IeCVocm.js";
9
9
  import "react";
10
10
  import { EWalletEndpoints as i } from "../../constants/endpoints.js";
11
11
  class u {
@@ -2,29 +2,29 @@ import { defaultAwayzConfig as H, awayzClient as K } from "@odynn/awayz-core";
2
2
  import { d as B, D as Y } from "../index-7zRjF0bU.js";
3
3
  import "../arrayExtensions-DFLvtO8l.js";
4
4
  import "react";
5
- import { h as g } from "../moment-BGjjqtLQ.js";
5
+ import { h as u } from "../moment-BGjjqtLQ.js";
6
6
  import { EFlightEndpoint as j } from "../constants/endpoints.js";
7
7
  import { mapBaggageType as Q } from "../hooks/useFlightSearch/useFlightSearch.types.js";
8
8
  import { WalletService as W } from "../services/wallet/WalletService.js";
9
9
  import { ERewardProgramCategories as J } from "../services/wallet/WalletService.types.js";
10
10
  const ce = (t) => t == null ? void 0 : t.map((e) => {
11
- var a, l, c, n, s, i, r, o, p, m, u, d, y, b, F, w, L, D, A, T, P, h, O, I, k, R, _, v, E, M, $, z, G, S;
11
+ var i, p, o, c, s, a, n, r, l, m, g, d, y, F, b, w, L, D, A, P, h, T, O, I, k, R, _, v, E, M, $, z, G, S;
12
12
  return {
13
13
  id: e.id,
14
14
  points: (e == null ? void 0 : e.points) >= 0 ? e.points : -1,
15
15
  partial: e == null ? void 0 : e.partial,
16
16
  origin: {
17
- city: ((a = e.slices[0].segments[0].origin) == null ? void 0 : a.cityName) || ((c = (l = e.slices[0].segments[0].origin) == null ? void 0 : l.city) == null ? void 0 : c.name),
18
- country: ((n = e.slices[0].segments[0].origin) == null ? void 0 : n.iataCountryCode) || ((i = (s = e.slices[0].segments[0].origin) == null ? void 0 : s.city) == null ? void 0 : i.iataCountryCode),
19
- airportCode: ((r = e.slices[0].segments[0].origin) == null ? void 0 : r.iataCityCode) || ((p = (o = e.slices[0].segments[0].origin) == null ? void 0 : o.city) == null ? void 0 : p.iataCode),
17
+ city: ((i = e.slices[0].segments[0].origin) == null ? void 0 : i.cityName) || ((o = (p = e.slices[0].segments[0].origin) == null ? void 0 : p.city) == null ? void 0 : o.name),
18
+ country: ((c = e.slices[0].segments[0].origin) == null ? void 0 : c.iataCountryCode) || ((a = (s = e.slices[0].segments[0].origin) == null ? void 0 : s.city) == null ? void 0 : a.iataCountryCode),
19
+ airportCode: ((n = e.slices[0].segments[0].origin) == null ? void 0 : n.iataCityCode) || ((l = (r = e.slices[0].segments[0].origin) == null ? void 0 : r.city) == null ? void 0 : l.iataCode),
20
20
  coordinates: {
21
- latitude: (u = (m = e.slices[0].segments[0].origin) == null ? void 0 : m.city) == null ? void 0 : u.latitude,
21
+ latitude: (g = (m = e.slices[0].segments[0].origin) == null ? void 0 : m.city) == null ? void 0 : g.latitude,
22
22
  longitude: (y = (d = e.slices[0].segments[0].origin) == null ? void 0 : d.city) == null ? void 0 : y.longitude
23
23
  }
24
24
  },
25
25
  destination: {
26
- city: ((F = (b = e.slices[0].segments.getLast()) == null ? void 0 : b.destination) == null ? void 0 : F.cityName) || ((D = (L = (w = e.slices[0].segments.getLast()) == null ? void 0 : w.destination) == null ? void 0 : L.city) == null ? void 0 : D.name),
27
- country: ((T = (A = e.slices[0].segments.getLast()) == null ? void 0 : A.destination) == null ? void 0 : T.iataCountryCode) || ((O = (h = (P = e.slices[0].segments.getLast()) == null ? void 0 : P.destination) == null ? void 0 : h.city) == null ? void 0 : O.iataCountryCode),
26
+ city: ((b = (F = e.slices[0].segments.getLast()) == null ? void 0 : F.destination) == null ? void 0 : b.cityName) || ((D = (L = (w = e.slices[0].segments.getLast()) == null ? void 0 : w.destination) == null ? void 0 : L.city) == null ? void 0 : D.name),
27
+ country: ((P = (A = e.slices[0].segments.getLast()) == null ? void 0 : A.destination) == null ? void 0 : P.iataCountryCode) || ((O = (T = (h = e.slices[0].segments.getLast()) == null ? void 0 : h.destination) == null ? void 0 : T.city) == null ? void 0 : O.iataCountryCode),
28
28
  airportCode: ((k = (I = e.slices[0].segments.getLast()) == null ? void 0 : I.destination) == null ? void 0 : k.iataCityCode) || ((v = (_ = (R = e.slices[0].segments.getLast()) == null ? void 0 : R.destination) == null ? void 0 : _.city) == null ? void 0 : v.iataCode),
29
29
  coordinates: {
30
30
  latitude: ($ = (M = (E = e.slices[0].segments.getLast()) == null ? void 0 : E.destination) == null ? void 0 : M.city) == null ? void 0 : $.latitude,
@@ -39,8 +39,8 @@ const ce = (t) => t == null ? void 0 : t.map((e) => {
39
39
  currency: e.baseCurrency,
40
40
  flightNumber: q(e.slices[0].segments[0]),
41
41
  awayzGroupId: e.slices[0].comparisonKey || e.awayzRouteId || e.awayzGroupId || e.id,
42
- departureTime: g(e.slices[0].segments[0].departingAt).toDate(),
43
- arrivalTime: g(
42
+ departureTime: u(e.slices[0].segments[0].departingAt).toDate(),
43
+ arrivalTime: u(
44
44
  e.slices[0].segments[e.slices[0].segments.length - 1].arrivingAt
45
45
  ).toDate(),
46
46
  numberOfStops: e.slices[0].segments.length - 1,
@@ -49,76 +49,75 @@ const ce = (t) => t == null ? void 0 : t.map((e) => {
49
49
  airlineProgram: e.airlineProgram,
50
50
  paymentOptions: [],
51
51
  durationMinutes: B({
52
- departureTime: g(e.slices[0].segments[0].departingAt),
53
- arrivalTime: g(e.slices[0].segments.getLast().arrivingAt),
52
+ departureTime: u(e.slices[0].segments[0].departingAt),
53
+ arrivalTime: u(e.slices[0].segments.getLast().arrivingAt),
54
54
  originTimeZone: e.slices[0].segments[0].origin.timeZone,
55
55
  destinationTimeZone: e.slices[0].segments.getLast().destination.timeZone,
56
56
  duration: e.slices[0].duration
57
57
  }),
58
58
  cashFee: e.cashFee,
59
59
  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,
60
- expiresAt: e.expiresAt
60
+ expiresAt: e.expiresAt,
61
+ transferPartners: []
61
62
  };
62
63
  }), q = (t) => {
63
- const e = t.operatingCarrierFlightNumber ? t.operatingCarrier : t.marketingCarrier, a = t.operatingCarrierFlightNumber ?? t.marketingCarrierFlightNumber;
64
- return e.iataCode + " " + X(a);
64
+ const e = t.operatingCarrierFlightNumber ? t.operatingCarrier : t.marketingCarrier, i = t.operatingCarrierFlightNumber ?? t.marketingCarrierFlightNumber;
65
+ return e.iataCode + " " + X(i);
65
66
  }, me = ({
66
67
  originCode: t,
67
68
  destinationCode: e,
68
- dates: a,
69
- cabinClass: l,
70
- passengerCount: c,
71
- paymentType: n
69
+ dates: i,
70
+ cabinClass: p,
71
+ passengerCount: o,
72
+ paymentType: c
72
73
  }) => {
73
74
  let s = `${j.CASH_POINTS_FLIGHT_SEARCH}?`;
74
- return s += `origin=${t}`, s += `&destination=${e}`, s += `&departure_dates=[${a.map((i) => `"${i}"`).join(",")}]`, s += `&cabin_class=${l}`, s += `&adults=${c}`, s += `&cash_or_points=[${n}]`, s;
75
- }, V = (t) => t.flightDetails.slices[0].segments.map((a) => q(a)).join("_") + "_" + g(t.departureTime).format("YYYYMMDD"), le = (t) => {
75
+ return s += `origin=${t}`, s += `&destination=${e}`, s += `&departure_dates=[${i.map((a) => `"${a}"`).join(",")}]`, s += `&cabin_class=${p}`, s += `&adults=${o}`, s += `&cash_or_points=[${c}]`, s;
76
+ }, V = (t) => t.flightDetails.slices[0].segments.map((i) => q(i)).join("_") + "_" + u(t.departureTime).format("YYYYMMDD"), le = (t) => {
76
77
  const e = {};
77
78
  t.forEach((s) => {
78
- const i = V(s);
79
- if (e[i]) {
80
- const r = U(s);
81
- e[i].flight.paymentOptions.push(r);
82
- const { lowestCash: o, currency: p, lowestPoints: m } = x(
83
- e[i].flight.paymentOptions
84
- );
85
- e[i].flight.points = m, e[i].flight.cash = o, p && (e[i].flight.currency = p);
79
+ const a = V(s);
80
+ if (e[a]) {
81
+ const n = U(s);
82
+ e[a].flight.paymentOptions.push(n);
83
+ const { lowestCash: r, currency: l, lowestPoints: m, cashFee: g } = x(e[a].flight.paymentOptions);
84
+ e[a].flight.points = m, e[a].flight.cashFee = g, e[a].flight.cash = r, l && (e[a].flight.currency = l);
86
85
  } else {
87
- const { origin: r, destination: o } = s, p = [U(s)], m = x(p);
88
- e[i] = {
86
+ const { origin: n, destination: r } = s, l = [U(s)], m = x(l);
87
+ e[a] = {
89
88
  programs: [],
90
89
  flight: {
91
90
  id: s.awayzGroupId,
92
91
  partial: s.partial,
93
92
  origin: {
93
+ city: n.city,
94
+ country: n.country,
95
+ airportCode: n.airportCode,
96
+ coordinates: n.coordinates
97
+ },
98
+ destination: {
94
99
  city: r.city,
95
100
  country: r.country,
96
101
  airportCode: r.airportCode,
97
102
  coordinates: r.coordinates
98
103
  },
99
- destination: {
100
- city: o.city,
101
- country: o.country,
102
- airportCode: o.airportCode,
103
- coordinates: o.coordinates
104
- },
105
104
  airline: s.airline,
106
105
  airlineLogo: C(
107
106
  s.flightDetails.slices[0].segments[0].operatingCarrier.iataCode
108
107
  ),
109
108
  flightNumber: s.flightNumber,
110
- paymentOptions: p,
109
+ paymentOptions: l,
111
110
  numberOfStops: s.numberOfStops,
112
111
  departureTime: s.departureTime,
113
112
  arrivalTime: s.arrivalTime,
114
- awayzGroupId: i,
113
+ awayzGroupId: a,
115
114
  duration: s.duration,
116
115
  airlineProgram: s.airlineProgram,
117
116
  durationMinutes: B({
118
- departureTime: g(
117
+ departureTime: u(
119
118
  s.flightDetails.slices[0].segments[0].departingAt
120
119
  ),
121
- arrivalTime: g(
120
+ arrivalTime: u(
122
121
  s.flightDetails.slices[0].segments.getLast().arrivingAt
123
122
  ),
124
123
  originTimeZone: s.flightDetails.slices[0].segments[0].origin.timeZone,
@@ -131,46 +130,47 @@ const ce = (t) => t == null ? void 0 : t.map((e) => {
131
130
  currency: s.flightDetails.baseCurrency,
132
131
  cashFee: s.cashFee,
133
132
  cabinClass: s.flightDetails.slices[0].segments[0].passengers[0].cabinClass || s.flightDetails.slices[0].segments[0].passengers[0].cabin.name || s.flightDetails.slices[0].segments[0].passengers[0].cabinClassMarketingName || s.flightDetails.slices[0].segments[0].passengers[0].cabin.marketingName,
134
- expiresAt: s.expiresAt
133
+ expiresAt: s.expiresAt,
134
+ transferPartners: s.transferPartners || []
135
135
  }
136
136
  };
137
137
  }
138
- s.airlineProgram && !e[i].programs.includes(s.airlineProgram) && e[i].programs.push(s.airlineProgram);
138
+ s.airlineProgram && !e[a].programs.includes(s.airlineProgram) && e[a].programs.push(s.airlineProgram);
139
139
  });
140
- const a = [];
140
+ const i = [];
141
141
  Object.values(e).forEach((s) => {
142
- const i = s.flight.paymentOptions.filter((r) => r.cash > 0).reduce(
143
- (r, o) => o.cash < r.cash ? o : r,
142
+ const a = s.flight.paymentOptions.filter((n) => n.cash > 0).reduce(
143
+ (n, r) => r.cash < n.cash ? r : n,
144
144
  { cash: 1 / 0, carrier: { name: "", iataCode: "" } }
145
145
  );
146
- s.programs.length > 0 ? s.programs.forEach((r) => {
147
- const o = s.flight.paymentOptions.filter(
148
- (m) => m.program === r && m.points > 0
149
- ), p = o.length > 0 ? Math.min(...o.map((m) => m.points)) : -1;
150
- a.push({
146
+ s.programs.length > 0 ? s.programs.forEach((n) => {
147
+ const r = s.flight.paymentOptions.filter(
148
+ (m) => m.program === n && m.points > 0
149
+ ), l = r.length > 0 ? Math.min(...r.map((m) => m.points)) : -1;
150
+ i.push({
151
151
  ...s.flight,
152
- airline: i.carrier.name,
153
- airlineLogo: C(i.carrier.iataCode),
154
- airlineProgram: r,
155
- cash: i.cash !== 1 / 0 ? i.cash : -1,
156
- points: p
152
+ airline: a.carrier.name,
153
+ airlineLogo: C(a.carrier.iataCode),
154
+ airlineProgram: n,
155
+ cash: a.cash !== 1 / 0 ? a.cash : -1,
156
+ points: l
157
157
  });
158
- }) : a.push({
158
+ }) : i.push({
159
159
  ...s.flight,
160
- airline: i.carrier.name,
161
- airlineLogo: C(i.carrier.iataCode),
162
- cash: i.cash !== 1 / 0 ? i.cash : -1
160
+ airline: a.carrier.name,
161
+ airlineLogo: C(a.carrier.iataCode),
162
+ cash: a.cash !== 1 / 0 ? a.cash : -1
163
163
  });
164
164
  });
165
- const { cashlessResults: l, otherResults: c } = a.reduce(
166
- (s, i) => (i.cash <= 0 && i.points > 0 ? s.cashlessResults.push(i) : i.cash > 0 && s.otherResults.push(i), s),
165
+ const { cashlessResults: p, otherResults: o } = i.reduce(
166
+ (s, a) => (a.cash <= 0 && a.points > 0 ? s.cashlessResults.push(a) : a.cash > 0 && s.otherResults.push(a), s),
167
167
  { cashlessResults: [], otherResults: [] }
168
- ), n = [...c];
169
- return l.forEach((s) => {
170
- (!n.find(
171
- (r) => r.awayzGroupId === s.awayzGroupId
172
- ) || c.length === 0) && n.push(s);
173
- }), n;
168
+ ), c = [...o];
169
+ return p.forEach((s) => {
170
+ (!c.find(
171
+ (n) => n.awayzGroupId === s.awayzGroupId
172
+ ) || o.length === 0) && c.push(s);
173
+ }), c;
174
174
  }, X = (t) => t ? t.replace(/^0+/, "") : "", pe = (t) => `https://assets.duffel.com/img/airlines/for-light-background/full-color-logo/${t}.svg`, C = (t) => `${Y}${t}.svg`, Z = H.logoFallbackImageUrl, N = {
175
175
  categoryLogo: Z,
176
176
  programLogo: Z,
@@ -190,21 +190,21 @@ const ce = (t) => t == null ? void 0 : t.map((e) => {
190
190
  staleTime: 864e5
191
191
  // 24 hours
192
192
  });
193
- let a = e.find(
194
- (l) => {
195
- var c, n, s, i;
196
- return ((n = (c = l.mainProgram) == null ? void 0 : c.toLowerCase()) == null ? void 0 : n.includes(t == null ? void 0 : t.toLowerCase())) || ((i = (s = l.displayProgram) == null ? void 0 : s.toLowerCase()) == null ? void 0 : i.includes(t == null ? void 0 : t.toLowerCase()));
193
+ let i = e.find(
194
+ (p) => {
195
+ var o, c, s, a;
196
+ return ((c = (o = p.mainProgram) == null ? void 0 : o.toLowerCase()) == null ? void 0 : c.includes(t == null ? void 0 : t.toLowerCase())) || ((a = (s = p.displayProgram) == null ? void 0 : s.toLowerCase()) == null ? void 0 : a.includes(t == null ? void 0 : t.toLowerCase()));
197
197
  }
198
198
  ) ?? N;
199
- return a || (a = {
199
+ return i || (i = {
200
200
  ...N,
201
201
  mainProgram: t,
202
202
  displayProgram: t,
203
203
  id: t
204
- }), a;
204
+ }), i;
205
205
  }, U = (t) => {
206
- var c, n, s, i, r, o, p, m, u, d;
207
- const e = ((s = (n = (c = t.flightDetails.slices.getFirst()) == null ? void 0 : c.segments.getFirst()) == null ? void 0 : n.passengers.getFirst()) == null ? void 0 : s.baggages) ?? [], a = ((o = (r = (i = t.flightDetails.slices.getFirst()) == null ? void 0 : i.segments.getFirst()) == null ? void 0 : r.passengers.getFirst()) == null ? void 0 : o.cabinClassMarketingName) ?? ((u = (m = (p = t.flightDetails.slices.getFirst()) == null ? void 0 : p.segments.getFirst()) == null ? void 0 : m.passengers.getFirst()) == null ? void 0 : u.cabinClass), l = e.map(
206
+ var o, c, s, a, n, r, l, m, g, d;
207
+ const e = ((s = (c = (o = t.flightDetails.slices.getFirst()) == null ? void 0 : o.segments.getFirst()) == null ? void 0 : c.passengers.getFirst()) == null ? void 0 : s.baggages) ?? [], i = ((r = (n = (a = t.flightDetails.slices.getFirst()) == null ? void 0 : a.segments.getFirst()) == null ? void 0 : n.passengers.getFirst()) == null ? void 0 : r.cabinClassMarketingName) ?? ((g = (m = (l = t.flightDetails.slices.getFirst()) == null ? void 0 : l.segments.getFirst()) == null ? void 0 : m.passengers.getFirst()) == null ? void 0 : g.cabinClass), p = e.map(
208
208
  (y) => ({
209
209
  type: Q(y.type),
210
210
  quantity: y.quantity
@@ -217,27 +217,37 @@ const ce = (t) => t == null ? void 0 : t.map((e) => {
217
217
  program: t.airlineProgram,
218
218
  baseCurrency: t.flightDetails.baseCurrency,
219
219
  fareBrandName: (d = t.flightDetails.slices.getFirst()) == null ? void 0 : d.fareBrandName,
220
- cabinClass: a,
220
+ cabinClass: i,
221
221
  cashFee: t.cashFee,
222
222
  conditions: t.flightDetails.conditions,
223
- baggages: l,
223
+ baggages: p,
224
224
  carrier: {
225
225
  iataCode: t.flightDetails.slices.getFirst().segments.getFirst().marketingCarrier.iataCode,
226
226
  name: t.flightDetails.slices.getFirst().segments.getFirst().marketingCarrier.name
227
227
  }
228
228
  };
229
229
  }, x = (t) => {
230
- const e = t.filter((n) => n.cash > 0);
231
- let a = { cash: 1 / 0, baseCurrency: "" };
232
- for (const n of e)
233
- n.cash < a.cash && (a = n);
234
- const l = Math.min(
235
- ...t.filter((n) => n.points > 0).map((n) => n.points)
236
- ), c = a.cash;
230
+ const e = t.filter((s) => s.cash > 0);
231
+ let i = { cash: 1 / 0, baseCurrency: "" };
232
+ for (const s of e)
233
+ s.cash < i.cash && (i = s);
234
+ const o = [...t].filter(
235
+ (s) => s.points > 0
236
+ ).reduce(
237
+ (s, a) => a.points < s.points ? a : s,
238
+ {
239
+ points: 1 / 0,
240
+ cashFee: {
241
+ amount: 0,
242
+ currency: ""
243
+ }
244
+ }
245
+ ), c = i.cash;
237
246
  return {
238
247
  lowestCash: c === 1 / 0 ? -1 : c,
239
- lowestPoints: l === 1 / 0 ? -1 : l,
240
- currency: a.baseCurrency === "" ? null : a.baseCurrency
248
+ lowestPoints: o.points === 1 / 0 ? -1 : o.points,
249
+ cashFee: o.cashFee,
250
+ currency: i.baseCurrency === "" ? null : i.baseCurrency
241
251
  };
242
252
  };
243
253
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@odynn/awayz-flights",
3
- "version": "0.7.8",
3
+ "version": "0.7.11",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"
@@ -1,332 +0,0 @@
1
- import { jsx as r, jsxs as n, Fragment as S } from "react/jsx-runtime";
2
- import { useAwayzContext as te, RewardsService as U, CashValue as _, EToolTipPosition as L, EInvalidAmountDisplayOption as se, awayzClient as q, CurrencyService as ae } from "@odynn/awayz-core";
3
- import { useQuery as oe } from "@tanstack/react-query";
4
- import { g as ce } from "./index-7zRjF0bU.js";
5
- import { G as le, g as R, a as N, E as v, F as me, b as pe } from "./FlightItinerary-Dy-2zMYt.js";
6
- import { E as b } from "./enums-D9aZqf8G.js";
7
- import "./arrayExtensions-DFLvtO8l.js";
8
- import he, { useState as P, useEffect as O, useMemo as $ } from "react";
9
- import { h as m } from "./moment-BGjjqtLQ.js";
10
- import { useTranslation as ge } from "react-i18next";
11
- import { EPaymentType as E } from "./enums/EPaymentType.js";
12
- import { isSameDayFlight as fe } from "./utils/flightDateUtils.js";
13
- import { DEFAULT_AIRLINE_PROGRAM as ue, getFlightNumber as de, getLogoPath as ye, getAirlineProgram as Ne } from "./utils/flightUtils.js";
14
- import './assets/FlightResult.css';const ve = (e, s, c = s + "s") => e === 1 ? s : c;
15
- function Pe(e) {
16
- if (!e || isNaN(e) || e < 0) return "N/A";
17
- let s = e == null ? void 0 : e.toString().split(".")[0];
18
- return s == null ? void 0 : s.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
19
- }
20
- function I(e) {
21
- return le({ attr: { viewBox: "0 0 512 512" }, child: [{ tag: "path", attr: { d: "M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM216 336l24 0 0-64-24 0c-13.3 0-24-10.7-24-24s10.7-24 24-24l48 0c13.3 0 24 10.7 24 24l0 88 8 0c13.3 0 24 10.7 24 24s-10.7 24-24 24l-80 0c-13.3 0-24-10.7-24-24s10.7-24 24-24zm40-208a32 32 0 1 1 0 64 32 32 0 1 1 0-64z" }, child: [] }] })(e);
22
- }
23
- async function z(e, s, c) {
24
- if (!e || s === c) return e;
25
- const o = await q.ensureQueryData({
26
- queryKey: [b.CONVERT_CURRENCY, s, c],
27
- staleTime: 1e3 * 60 * 60,
28
- // 1 hour
29
- queryFn: () => ae.convertCurrency({
30
- baseCurrency: s,
31
- targetCurrency: c
32
- })
33
- });
34
- return e * o;
35
- }
36
- const Ue = ({
37
- details: e,
38
- onClick: s,
39
- showBestValue: c = !1,
40
- onShowBestValueCalculation: o,
41
- customStyling: w = !1,
42
- customCashComponent: K,
43
- customPointsComponent: Q
44
- }) => {
45
- const { t: h } = ge(), [x, G] = P(!1), [f, Y] = P(
46
- "none"
47
- /* NONE */
48
- ), [j, H] = P(!1), { config: F } = te(), u = e.origin, d = e.destination, k = e.flightDetails, T = e.paymentOptions || [], J = T.filter((i) => i.points === -1).length === 1, W = T.filter((i) => i.points > -1).length === 1, [X, Z] = P(ue), V = async () => {
49
- const i = T.filter((a) => a.points > -1).sort((a, l) => a.points - l.points)[0], t = await Ne(i.program);
50
- Z(t);
51
- };
52
- O(() => {
53
- V();
54
- }, [e.paymentOptions]);
55
- const { flightNumbers: C, airlines: B } = $(() => {
56
- const i = [], t = [];
57
- return e.flightDetails.slices.forEach((a) => {
58
- a.segments.forEach((l) => {
59
- const p = de(l);
60
- i.includes(p) || i.push(p);
61
- const y = l.operatingCarrier;
62
- t.some((A) => A.airline === y.name) || t.push({
63
- logo: ye(y.iataCode),
64
- airline: y.name
65
- });
66
- });
67
- }), { flightNumbers: i, airlines: t };
68
- }, [e.flightDetails.slices]), ee = () => {
69
- e.cash > 0 ? s(e, E.CASH) : s(e, E.POINTS);
70
- }, re = !fe(
71
- e.departureTime,
72
- e.arrivalTime
73
- ), D = e == null ? void 0 : e.airlineProgram, { data: M } = oe({
74
- queryKey: [b.VALUE_CENTS, D, "test"],
75
- queryFn: () => U.getCentPerPoint(D),
76
- staleTime: 1 / 0,
77
- enabled: !!D && c
78
- }), g = $(() => {
79
- var i, t;
80
- return (t = (i = e.paymentOptions) == null ? void 0 : i.find(
81
- (a) => {
82
- var l;
83
- return a.program === e.airlineProgram && ((l = a.cashFee) == null ? void 0 : l.amount) !== 0;
84
- }
85
- )) == null ? void 0 : t.cashFee;
86
- }, [e.paymentOptions, e.airlineProgram]), ie = async () => {
87
- if (!e || !M || !e.points || !e.cash)
88
- return;
89
- const i = e.currency;
90
- let t = {
91
- valueCents: 1,
92
- currency: i
93
- };
94
- try {
95
- t = await q.ensureQueryData({
96
- queryKey: [b.VALUE_CENTS, e.airlineProgram],
97
- staleTime: 1e3 * 60 * 60,
98
- // 1 hour
99
- queryFn: () => U.getCentPerPoint(e.airlineProgram)
100
- });
101
- } catch (ne) {
102
- console.warn(
103
- "Failed to fetch value cents for airline program:",
104
- e.airlineProgram,
105
- ne
106
- );
107
- }
108
- const a = g ?? {
109
- amount: 0,
110
- currency: i
111
- }, [l, p] = await Promise.all([
112
- z(
113
- a.amount,
114
- a.currency,
115
- i
116
- ),
117
- z(
118
- t.valueCents,
119
- t.currency,
120
- i
121
- )
122
- ]), A = p * e.points / 100 + l < e.cash;
123
- Y(
124
- A ? "points" : "cash"
125
- /* CASH */
126
- );
127
- };
128
- return O(() => {
129
- ie();
130
- }, [e, M, g]), O(() => {
131
- const i = m(e.expiresAt), t = m();
132
- if (!(i.year() === m(0).year()) && i.isAfter(t)) {
133
- const l = i.diff(t), p = setTimeout(() => {
134
- H(!0);
135
- }, l);
136
- return () => {
137
- clearTimeout(p);
138
- };
139
- }
140
- }, [e.expiresAt]), /* @__PURE__ */ r(
141
- "div",
142
- {
143
- className: `${w ? "" : "awayz-"}flight-result`,
144
- onClick: ee,
145
- children: /* @__PURE__ */ n("div", { className: "content", children: [
146
- /* @__PURE__ */ r("div", { className: "flight-info", children: /* @__PURE__ */ n("div", { className: "flight-locations", children: [
147
- /* @__PURE__ */ r("div", { className: "airlines", children: B.map((i, t) => /* @__PURE__ */ r(he.Fragment, { children: /* @__PURE__ */ n("div", { className: "tip", children: [
148
- /* @__PURE__ */ r(
149
- "img",
150
- {
151
- src: i.logo,
152
- alt: i.airline,
153
- onError: (a) => a.currentTarget.src = (F == null ? void 0 : F.logoFallbackImageUrl) ?? ""
154
- }
155
- ),
156
- /* @__PURE__ */ r("span", { className: "right", children: i.airline })
157
- ] }, t) }, t)) }),
158
- /* @__PURE__ */ n("div", { className: "flight-location", children: [
159
- /* @__PURE__ */ n("p", { className: "show-desktop", children: [
160
- u.city,
161
- ",",
162
- R(u.country)
163
- ] }),
164
- /* @__PURE__ */ r("p", { className: "show-desktop", children: m(e.departureTime).format(
165
- h(N.DATE_TIME_MEDIUM, v.FlightShortDate)
166
- ) }),
167
- /* @__PURE__ */ r("p", { className: "show-mobile", children: u.airportCode }),
168
- /* @__PURE__ */ r("p", { className: "show-mobile", children: m(e.departureTime).format(
169
- h(N.TIME_ONLY, v.FlightTime)
170
- ) })
171
- ] }),
172
- /* @__PURE__ */ n("div", { className: "flight-duration", children: [
173
- /* @__PURE__ */ r("span", { className: "line" }),
174
- /* @__PURE__ */ n("p", { children: [
175
- ce(k.slices[0].duration),
176
- " ",
177
- " - ",
178
- e.numberOfStops > 0 ? `${e.numberOfStops} ${ve(
179
- e.numberOfStops,
180
- "Stop"
181
- )}` : "Direct"
182
- ] }),
183
- /* @__PURE__ */ r("span", { className: "line" })
184
- ] }),
185
- /* @__PURE__ */ n("div", { children: [
186
- /* @__PURE__ */ n("p", { className: "show-desktop", children: [
187
- d.city,
188
- ", ",
189
- R(d.country)
190
- ] }),
191
- /* @__PURE__ */ n("p", { className: "show-desktop", children: [
192
- m(e.arrivalTime).format(
193
- h(N.DATE_TIME_MEDIUM, v.FlightShortDate)
194
- ),
195
- " "
196
- ] }),
197
- /* @__PURE__ */ r("p", { className: "show-mobile", children: d.airportCode }),
198
- /* @__PURE__ */ r("p", { className: "show-mobile", children: m(e.arrivalTime).format(
199
- h(N.TIME_ONLY, v.FlightTime)
200
- ) })
201
- ] })
202
- ] }) }),
203
- /* @__PURE__ */ n("div", { className: "flight-footer", children: [
204
- /* @__PURE__ */ r("div", { className: "flight-detail-container", children: /* @__PURE__ */ n(
205
- "div",
206
- {
207
- className: "flight-detail",
208
- onClick: (i) => {
209
- i.stopPropagation(), G(!x);
210
- },
211
- children: [
212
- /* @__PURE__ */ r("p", { children: "Aircraft" }),
213
- /* @__PURE__ */ n("p", { className: "chevron-text", children: [
214
- /* @__PURE__ */ r(me, {}),
215
- /* @__PURE__ */ n("span", { children: [
216
- C[0],
217
- C.length > 1 && /* @__PURE__ */ n("sup", { children: [
218
- "+",
219
- C.length - 1
220
- ] })
221
- ] })
222
- ] })
223
- ]
224
- }
225
- ) }),
226
- /* @__PURE__ */ r("div", { className: "booking-options ", children: j ? /* @__PURE__ */ n("div", { className: "offer-expiry", children: [
227
- /* @__PURE__ */ r("span", { children: /* @__PURE__ */ r(I, {}) }),
228
- /* @__PURE__ */ r("p", { className: "expired-tip", children: "Offer Expired" })
229
- ] }) : /* @__PURE__ */ n(S, { children: [
230
- K || e.cash > 0 && /* @__PURE__ */ n(
231
- "div",
232
- {
233
- className: `amount-value ${f === "cash" && c ? "show-best-value-flag" : ""}`,
234
- onClick: (i) => {
235
- i.stopPropagation(), s(e, E.CASH);
236
- },
237
- children: [
238
- /* @__PURE__ */ r("b", { children: "Cash" }),
239
- /* @__PURE__ */ n("div", { children: [
240
- /* @__PURE__ */ r("label", { children: J ? "Book For" : "From" }),
241
- /* @__PURE__ */ r(
242
- _,
243
- {
244
- amount: e.cash,
245
- currency: e.currency,
246
- position: L.LEFT
247
- }
248
- )
249
- ] }),
250
- f === "cash" && c && /* @__PURE__ */ n(
251
- "div",
252
- {
253
- className: "best-value-flag tip",
254
- onClick: (i) => {
255
- i.stopPropagation(), o == null || o(e);
256
- },
257
- children: [
258
- o && /* @__PURE__ */ r(I, {}),
259
- /* @__PURE__ */ r("p", { children: "Best Value" }),
260
- o && /* @__PURE__ */ r("span", { children: "Click to learn more" })
261
- ]
262
- }
263
- )
264
- ]
265
- }
266
- ),
267
- Q || e.points > 0 && /* @__PURE__ */ n(
268
- "div",
269
- {
270
- className: `amount-value ${f === "points" && c ? "show-best-value-flag" : ""}`,
271
- onClick: (i) => {
272
- i.stopPropagation(), s(e, E.POINTS);
273
- },
274
- children: [
275
- f === "points" && c && /* @__PURE__ */ n(
276
- "div",
277
- {
278
- className: "best-value-flag tip",
279
- onClick: (i) => {
280
- i.stopPropagation(), o == null || o(e);
281
- },
282
- children: [
283
- o && /* @__PURE__ */ r(I, {}),
284
- /* @__PURE__ */ r("p", { children: "Best Value" }),
285
- o && /* @__PURE__ */ r("span", { children: "Click to learn more" })
286
- ]
287
- }
288
- ),
289
- /* @__PURE__ */ r("div", { className: "amount-airline-logo", children: /* @__PURE__ */ r("img", { src: X.programLogo }) }),
290
- /* @__PURE__ */ n("div", { children: [
291
- /* @__PURE__ */ r("label", { children: W ? "Book For" : "From" }),
292
- /* @__PURE__ */ n("p", { children: [
293
- `${Pe(e.points)} ${h(
294
- "miles"
295
- )}`,
296
- !!g && /* @__PURE__ */ n(S, { children: [
297
- " + ",
298
- /* @__PURE__ */ r(
299
- _,
300
- {
301
- amount: g.amount,
302
- currency: g.currency,
303
- customDisplay: "No fee",
304
- zeroDisplayOption: se.CUSTOM,
305
- position: L.LEFT
306
- }
307
- )
308
- ] })
309
- ] })
310
- ] })
311
- ]
312
- }
313
- )
314
- ] }) })
315
- ] }),
316
- /* @__PURE__ */ r("div", { className: `flight-details ${x ? "is-open" : ""}`, children: /* @__PURE__ */ r("div", { className: "inner", children: /* @__PURE__ */ r(
317
- pe,
318
- {
319
- itinerary: k.slices[0].segments,
320
- origin: u,
321
- destination: d,
322
- isMultiDayFlight: re
323
- }
324
- ) }) })
325
- ] })
326
- }
327
- );
328
- };
329
- export {
330
- Ue as F,
331
- Pe as c
332
- };
@@ -1,4 +0,0 @@
1
- var R = /* @__PURE__ */ ((S) => (S.LOCATIONS = "LOCATIONS", S.CHECK_USER = "CHECK_USER", S.USER_REGIONS = "USER_REGIONS", S.CONVERT_CURRENCY = "CONVERT_CURRENCY", S.CLIENT_COMPONENT_KEY = "CLIENT_COMPONENT_KEY", S.SEARCH_LIMIT = "SEARCH_LIMIT", S.PROGRAMS = "PROGRAMS", S.USER_PROGRAMS = "USER_PROGRAMS", S.LINKED_USER_PROGRAMS = "LINKED_USER_PROGRAMS", S.BANKS = "BANKS", S.CARDS = "CARDS", S.USER_CARDS = "USER_CARDS", S.TRIPS = "TRIPS", S.UNCATEGORISED_BOOKINGS = "UNCATEGORISED_BOOKINGS", S.BOOKING = "BOOKING", S.VALUE_CENTS = "VALUE_CENTS", S.AVAILABILITY_ALERTS = "AVAILABILITY_ALERTS", S.ALERT_NOTIFICATIONS = "ALERT_NOTIFICATIONS", S.POINTS_AS_CASH = "POINTS_AS_CASH", S))(R || {});
2
- export {
3
- R as E
4
- };