@odynn/awayz-flights 0.2.7 → 0.2.8

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 +1 @@
1
- @import"https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap";@media (prefers-color-scheme: dark){body[data-theme=auto]{--background: #14181f;--opaque-background: #20242880;--foreground: #22272d;--text: #c3c9d2;--text-light: #c3c9d260;--border: #3b4048}}@media (prefers-color-scheme: light){body[data-theme=auto]{--background: #f9fdff;--opaque-background: #f9fdff95;--foreground: #fff;--text: #252e34;--text-light: #252e3460;--border: #e7eef3}}body[data-theme=light]{--background: #f9fdff;--opaque-background: #f9fdff95;--foreground: #fff;--text: #252e34;--text-light: #252e3460;--border: #e7eef3}*{font-family:Inter,sans-serif!important;margin:0;padding:0;box-sizing:border-box}:root{font-synthesis:none;text-rendering:optimizeLegibility;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.flight-result{background-color:var(--foreground, #fff);border:1px solid var(--border, #e7eef3);overflow:hidden;border-radius:.5rem;width:100%;margin:0 auto;position:relative;height:fit-content;padding:1px;transition:all .2s ease-in-out;z-index:10;animation:fade-up .2s ease-in-out both;backface-visibility:hidden}.flight-result .content{overflow:hidden;border-radius:.4rem;width:100%;margin:0 auto;position:relative;height:fit-content;z-index:1;display:flex;flex-direction:column}.flight-result .content>div{z-index:2}.flight-result .content>div.flight-info{flex:4;display:flex;flex-direction:column;min-height:60%;gap:.5rem;padding:1rem}.flight-result .content>div.flight-info .airlines{position:relative;width:50px;max-width:50px;height:30px}.flight-result .content>div.flight-info .airlines>div{position:absolute;display:flex;align-items:center;gap:.5rem;border:1px solid var(--border, #e7eef3);border-radius:50%;height:30px;width:30px;justify-content:center;background-color:var(--foreground, #fff)}.flight-result .content>div.flight-info .airlines>div img{width:70%}.flight-result .content>div.flight-info .airlines>div:nth-child(2){top:10px;left:15px}.flight-result .content>div.flight-info .airlines>div:nth-child(3){top:-10px;left:20px}.flight-result .content>div.flight-info .airlines>div span{font-size:.7rem}.flight-result .content>div.flight-info .airlines p{font-weight:600}.flight-result .content>div.flight-info .flight-locations{align-items:center;gap:1rem;display:flex}.flight-result .content>div.flight-info .flight-locations:last-child div p:first-child{font-weight:600}.flight-result .content>div.flight-info .flight-locations>div{flex:1;font-size:.8rem}.flight-result .content>div.flight-info .flight-locations>div:first-child{text-align:left}.flight-result .content>div.flight-info .flight-locations>div:last-child{text-align:right}.flight-result .content>div.flight-info .flight-locations .flight-duration{display:flex;flex-direction:row;align-items:center;justify-content:center;gap:1rem;font-weight:600;font-size:.7rem}.flight-result .content>div.flight-info .flight-locations .line{height:2px;flex:1;background:repeating-linear-gradient(90deg,var(--border, #e7eef3) 0 20px,rgba(0,0,0,0) 0 30px);z-index:1}.flight-result .content>div.flight-info .flight-locations>div{display:flex;flex-direction:column;text-align:center;flex:1;width:100%}.flight-result .content>div.flight-info .flight-locations>div.duration{flex-direction:row;align-items:center;justify-content:center;gap:.5rem}.flight-result .content>div.flight-info .flight-locations>div.duration p{opacity:.4}.flight-result .content>div.flight-info .flight-locations>div.flight-location{text-align:left;align-items:flex-start;max-width:fit-content}.flight-result .content>div.flight-info .flight-locations>div:last-child{text-align:right;align-items:flex-end;max-width:fit-content}.flight-result .content>div.flight-footer{flex:2;display:flex;justify-content:space-between;align-items:center;padding:1rem;gap:1rem;background-color:var(--background, #f9fdff);border-top:1px solid var(--border, #e7eef3)}@media screen and (max-width: 1024px){.flight-result .content>div.flight-footer{flex-direction:column}}.flight-result .content>div.flight-footer .view-details{display:flex;align-items:center;gap:1rem;cursor:pointer;-webkit-user-select:none;user-select:none}.flight-result .content>div.flight-footer .booking-options{display:flex;justify-content:flex-end;gap:1rem;font-size:.8rem;flex:3}@media screen and (max-width: 1024px){.flight-result .content>div.flight-footer .booking-options{width:100%;flex-direction:column}}.flight-result .content>div.flight-footer .booking-options>div{display:flex;align-items:center;justify-content:space-between;border:1px solid var(--border, #e7eef3);border-radius:50rem;padding:1rem;gap:2rem;cursor:pointer;transition:all .2s ease-in-out;background-color:var(--foreground, #fff)}.flight-result .content>div.flight-footer .booking-options>div.points-value{padding:.5rem 1rem}.flight-result .content>div.flight-footer .booking-options>div.points-value img{height:30px;max-width:100px}.flight-result .content>div.flight-footer .booking-options>div.cash-value .currency-conversion{display:flex}.flight-result .content>div.flight-footer .booking-options>div:first-of-type{grid-area:price}.flight-result .content>div.flight-footer .booking-options>div:last-of-type{grid-area:points}.flight-result .content>div.flight-footer .booking-options>div:hover{background-color:var(--background, #f9fdff)}.flight-result .content>div.flight-footer .booking-options>div p:last-child{font-weight:600}@media screen and (max-width: 1024px){.flight-result .content>div.flight-footer .booking-options>div{flex-direction:row;justify-content:space-between;align-items:center}.flight-result .content>div.flight-footer .booking-options>div.points-value{text-align:center}.flight-result .content>div.flight-footer .booking-options>div.points-value img{height:30px;max-width:80px}.flight-result .content>div.flight-footer .booking-options>div p:last-child{font-weight:600;font-size:1rem}}.flight-result .content .flight-detail-container{display:flex;gap:1rem;justify-content:space-between}@media screen and (max-width: 1024px){.flight-result .content .flight-detail-container{width:100%}}.flight-result .content .flight-detail:not(:first-of-type){border-left:1px solid var(--border, #e7eef3);padding:0 2rem}@media screen and (max-width: 1024px){.flight-result .content .flight-detail:not(:first-of-type){padding:0 .5rem}}.flight-result .content .flight-detail p{font-size:.8rem}.flight-result .content .flight-detail p:first-of-type{font-size:.7rem;color:var(--text-light, rgba(37, 46, 52, .2509803922))}.flight-result .content .flight-detail p:last-of-type{font-weight:600}.flight-result .content .flight-detail p.chevron-text{display:flex;align-items:center;gap:.5rem;cursor:pointer;-webkit-user-select:none;user-select:none}.flight-result .flight-details{display:grid;grid-template-rows:0fr;transition:all .2s ease-in-out;background-color:var(--foreground, #fff);border-top:1px solid var(--border, #e7eef3);border-width:0}.flight-result .flight-details.is-open{grid-template-rows:1fr;padding:1rem;border-top:1px solid var(--border, #e7eef3)}.flight-result .flight-details.is-open .inner{padding:1rem 0;scale:1;opacity:1}.flight-result .flight-details .inner{overflow:hidden;transition:all .2s ease-in-out;scale:.9;opacity:0;transform-origin:top center}.flight-result .skeleton{margin-bottom:2px}.flight-result:hover{cursor:pointer}.flight-result.skeleton-loader .content>div.flight-info .flight-locations>div.flight-location{max-width:unset}.flight-result.skeleton-loader .content>div.flight-info .flight-locations>div:last-child{max-width:unset}
1
+ @import"https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap";@media (prefers-color-scheme: dark){body[data-theme=auto]{--background: #14181f;--opaque-background: #20242880;--foreground: #22272d;--text: #c3c9d2;--text-light: #c3c9d260;--border: #3b4048}}@media (prefers-color-scheme: light){body[data-theme=auto]{--background: #f9fdff;--opaque-background: #f9fdff95;--foreground: #fff;--text: #252e34;--text-light: #252e3460;--border: #e7eef3}}body[data-theme=light]{--background: #f9fdff;--opaque-background: #f9fdff95;--foreground: #fff;--text: #252e34;--text-light: #252e3460;--border: #e7eef3}*{font-family:Inter,sans-serif!important;margin:0;padding:0;box-sizing:border-box}:root{font-synthesis:none;text-rendering:optimizeLegibility;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.flight-result{background-color:var(--foreground, #fff);border:1px solid var(--border, #e7eef3);overflow:hidden;border-radius:.5rem;width:100%;margin:0 auto;position:relative;height:fit-content;padding:1px;transition:all .2s ease-in-out;z-index:10;animation:fade-up .2s ease-in-out both;backface-visibility:hidden}.flight-result .content{overflow:hidden;border-radius:.4rem;width:100%;margin:0 auto;position:relative;height:fit-content;z-index:1;display:flex;flex-direction:column}.flight-result .content>div{z-index:2}.flight-result .content>div.flight-info{flex:4;display:flex;flex-direction:column;min-height:60%;gap:.5rem;padding:1rem}.flight-result .content>div.flight-info .airlines{position:relative;width:50px;max-width:50px;height:30px}.flight-result .content>div.flight-info .airlines>div{position:absolute;display:flex;align-items:center;gap:.5rem;border:1px solid var(--border, #e7eef3);border-radius:50%;height:30px;width:30px;justify-content:center;background-color:var(--foreground, #fff)}.flight-result .content>div.flight-info .airlines>div img{width:70%}.flight-result .content>div.flight-info .airlines>div:nth-child(2){top:10px;left:15px}.flight-result .content>div.flight-info .airlines>div:nth-child(3){top:-10px;left:20px}.flight-result .content>div.flight-info .airlines>div span{font-size:.7rem}.flight-result .content>div.flight-info .airlines p{font-weight:600}.flight-result .content>div.flight-info .flight-locations{align-items:center;gap:1rem;display:flex}.flight-result .content>div.flight-info .flight-locations:last-child div p:first-child{font-weight:600}.flight-result .content>div.flight-info .flight-locations>div{flex:1;font-size:.8rem}.flight-result .content>div.flight-info .flight-locations>div:first-child{text-align:left}.flight-result .content>div.flight-info .flight-locations>div:last-child{text-align:right}.flight-result .content>div.flight-info .flight-locations .flight-duration{display:flex;flex-direction:row;align-items:center;justify-content:center;gap:1rem;font-weight:600;font-size:.7rem}.flight-result .content>div.flight-info .flight-locations .line{height:2px;flex:1;background:repeating-linear-gradient(90deg,var(--border, #e7eef3) 0 20px,rgba(0,0,0,0) 0 30px);z-index:1}.flight-result .content>div.flight-info .flight-locations>div{display:flex;flex-direction:column;text-align:center;flex:1;width:100%}.flight-result .content>div.flight-info .flight-locations>div.duration{flex-direction:row;align-items:center;justify-content:center;gap:.5rem}.flight-result .content>div.flight-info .flight-locations>div.duration p{opacity:.4}.flight-result .content>div.flight-info .flight-locations>div.flight-location{text-align:left;align-items:flex-start;max-width:fit-content}.flight-result .content>div.flight-info .flight-locations>div:last-child{text-align:right;align-items:flex-end;max-width:fit-content}.flight-result .content>div.flight-footer{flex:2;display:flex;justify-content:space-between;align-items:center;padding:1rem;gap:1rem;background-color:var(--background, #f9fdff);border-top:1px solid var(--border, #e7eef3)}@media screen and (max-width: 1024px){.flight-result .content>div.flight-footer{flex-direction:column}}.flight-result .content>div.flight-footer .view-details{display:flex;align-items:center;gap:1rem;cursor:pointer;-webkit-user-select:none;user-select:none}.flight-result .content>div.flight-footer .booking-options{display:flex;justify-content:flex-end;gap:1rem;font-size:.8rem;flex:3}@media screen and (max-width: 1024px){.flight-result .content>div.flight-footer .booking-options{width:100%;flex-direction:column}}.flight-result .content>div.flight-footer .booking-options>div{display:flex;align-items:center;justify-content:space-between;border:1px solid var(--border, #e7eef3);border-radius:50rem;padding:.5rem 1rem;gap:2rem;cursor:pointer;transition:all .2s ease-in-out;background-color:var(--foreground, #fff)}.flight-result .content>div.flight-footer .booking-options>div img{height:30px;max-width:100px}.flight-result .content>div.flight-footer .booking-options>div>div{display:flex;flex-direction:column}.flight-result .content>div.flight-footer .booking-options>div label{font-size:.7rem;font-weight:600}.flight-result .content>div.flight-footer .booking-options>div.cash-value .currency-conversion{display:flex}.flight-result .content>div.flight-footer .booking-options>div:first-of-type{grid-area:price}.flight-result .content>div.flight-footer .booking-options>div:last-of-type{grid-area:points}.flight-result .content>div.flight-footer .booking-options>div:hover{background-color:var(--background, #f9fdff)}@media screen and (max-width: 1024px){.flight-result .content>div.flight-footer .booking-options>div{flex-direction:row;justify-content:space-between;align-items:center}.flight-result .content>div.flight-footer .booking-options>div.points-value{text-align:center}.flight-result .content>div.flight-footer .booking-options>div.points-value img{height:30px;max-width:80px}.flight-result .content>div.flight-footer .booking-options>div p:last-child{font-weight:600;font-size:1rem}}.flight-result .content .flight-detail-container{display:flex;gap:1rem;justify-content:space-between}@media screen and (max-width: 1024px){.flight-result .content .flight-detail-container{width:100%}}.flight-result .content .flight-detail:not(:first-of-type){border-left:1px solid var(--border, #e7eef3);padding:0 2rem}@media screen and (max-width: 1024px){.flight-result .content .flight-detail:not(:first-of-type){padding:0 .5rem}}.flight-result .content .flight-detail p{font-size:.8rem}.flight-result .content .flight-detail p:first-of-type{font-size:.7rem;color:var(--text-light, rgba(37, 46, 52, .2509803922))}.flight-result .content .flight-detail p:last-of-type{font-weight:600}.flight-result .content .flight-detail p.chevron-text{display:flex;align-items:center;gap:.5rem;cursor:pointer;-webkit-user-select:none;user-select:none}.flight-result .flight-details{display:grid;grid-template-rows:0fr;transition:all .2s ease-in-out;background-color:var(--foreground, #fff);border-top:1px solid var(--border, #e7eef3);border-width:0}.flight-result .flight-details.is-open{grid-template-rows:1fr;padding:1rem;border-top:1px solid var(--border, #e7eef3)}.flight-result .flight-details.is-open .inner{padding:1rem 0;scale:1;opacity:1}.flight-result .flight-details .inner{overflow:hidden;transition:all .2s ease-in-out;scale:.9;opacity:0;transform-origin:top center}.flight-result .skeleton{margin-bottom:2px}.flight-result:hover{cursor:pointer}.flight-result.skeleton-loader .content>div.flight-info .flight-locations>div.flight-location{max-width:unset}.flight-result.skeleton-loader .content>div.flight-info .flight-locations>div:last-child{max-width:unset}
@@ -1,96 +1,96 @@
1
- import { jsx as r, jsxs as e, Fragment as I } from "react/jsx-runtime";
2
- import T, { useState as N, useMemo as R } from "react";
3
- import { g as u, E as v, F as B, a as L } from "../../FlightItinerary-DgpK1LYF.js";
4
- import { DEFAULT_AIRLINE_PROGRAM as $, getFlightNumber as x, getLogoPath as M, getAirlineProgram as b } from "../../utils/flightUtils.js";
5
- import { h as F } from "../../arrayExtensions-DWKenJCh.js";
6
- import { g as j } from "../../dateUtils-DeNLG5hw.js";
7
- import { EPaymentType as o } from "../../enums/EPaymentType.js";
8
- import { CashValue as y } from "@odynn/awayz-core";
9
- import '../../assets/FlightResult.css';function H(i) {
1
+ import { jsx as e, jsxs as r, Fragment as I } from "react/jsx-runtime";
2
+ import T, { useState as N, useMemo as B } from "react";
3
+ import { g as v, E as F, F as L, a as R } from "../../FlightItinerary-DgpK1LYF.js";
4
+ import { DEFAULT_AIRLINE_PROGRAM as b, getFlightNumber as $, getLogoPath as x, getAirlineProgram as j } from "../../utils/flightUtils.js";
5
+ import { h as y } from "../../arrayExtensions-DWKenJCh.js";
6
+ import { g as H } from "../../dateUtils-DeNLG5hw.js";
7
+ import { EPaymentType as s } from "../../enums/EPaymentType.js";
8
+ import { CashValue as C } from "@odynn/awayz-core";
9
+ import '../../assets/FlightResult.css';function M(i) {
10
10
  if (!i || isNaN(i) || i < 0) return "N/A";
11
11
  let a = i == null ? void 0 : i.toString().split(".")[0];
12
12
  return a == null ? void 0 : a.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
13
13
  }
14
14
  const Q = ({ details: i, onClick: a }) => {
15
- var d;
16
- const [g, C] = N(!1), c = i.origin, l = i.destination, p = i.flightDetails, S = !i.paymentOptions || i.paymentOptions.length === 1, [D, P] = N($), A = async () => {
17
- const n = await b(i.airlineProgram);
15
+ var f;
16
+ const [g, S] = N(!1), c = i.origin, l = i.destination, p = i.flightDetails, d = !i.paymentOptions || i.paymentOptions.length === 1, [D, P] = N(b), A = async () => {
17
+ const n = await j(i.airlineProgram);
18
18
  P(n);
19
- }, { flightNumbers: h, airlines: O } = R(() => {
20
- const n = [], t = [];
19
+ }, { flightNumbers: h, airlines: O } = B(() => {
20
+ const n = [], o = [];
21
21
  return i.flightDetails.slices.forEach((k) => {
22
- k.segments.forEach((s) => {
23
- const f = x(s);
24
- n.includes(f) || n.push(f);
25
- const m = s.operatingCarrierFlightNumber ? s.operatingCarrier : s.marketingCarrier;
26
- t.some((E) => E.airline === m.name) || t.push({
27
- logo: M(m.iataCode),
22
+ k.segments.forEach((t) => {
23
+ const u = $(t);
24
+ n.includes(u) || n.push(u);
25
+ const m = t.operatingCarrierFlightNumber ? t.operatingCarrier : t.marketingCarrier;
26
+ o.some((E) => E.airline === m.name) || o.push({
27
+ logo: x(m.iataCode),
28
28
  airline: m.name
29
29
  });
30
30
  });
31
- }), A(), { flightNumbers: n, airlines: t };
31
+ }), A(), { flightNumbers: n, airlines: o };
32
32
  }, [i.flightDetails.slices]);
33
- return /* @__PURE__ */ r("div", { className: "flight-result", onClick: () => {
34
- i.cash > 0 ? a(i, o.CASH) : a(i, o.POINTS);
35
- }, children: /* @__PURE__ */ e("div", { className: "content", children: [
36
- /* @__PURE__ */ r("div", { className: "flight-info", children: /* @__PURE__ */ e("div", { className: "flight-locations", children: [
37
- /* @__PURE__ */ r("div", { className: "airlines", children: O.map((n, t) => /* @__PURE__ */ r(T.Fragment, { children: /* @__PURE__ */ r("div", { className: "tip", children: /* @__PURE__ */ r("img", { src: n.logo, alt: n.airline }) }, t) }, t)) }),
38
- /* @__PURE__ */ e("div", { className: "flight-location", children: [
39
- /* @__PURE__ */ e("p", { children: [
33
+ return /* @__PURE__ */ e("div", { className: "flight-result", onClick: () => {
34
+ i.cash > 0 ? a(i, s.CASH) : a(i, s.POINTS);
35
+ }, children: /* @__PURE__ */ r("div", { className: "content", children: [
36
+ /* @__PURE__ */ e("div", { className: "flight-info", children: /* @__PURE__ */ r("div", { className: "flight-locations", children: [
37
+ /* @__PURE__ */ e("div", { className: "airlines", children: O.map((n, o) => /* @__PURE__ */ e(T.Fragment, { children: /* @__PURE__ */ e("div", { className: "tip", children: /* @__PURE__ */ e("img", { src: n.logo, alt: n.airline }) }, o) }, o)) }),
38
+ /* @__PURE__ */ r("div", { className: "flight-location", children: [
39
+ /* @__PURE__ */ r("p", { children: [
40
40
  c.city,
41
41
  ",",
42
- u(c.country)
42
+ v(c.country)
43
43
  ] }),
44
- /* @__PURE__ */ r("p", { children: F(i.departureTime).format(
44
+ /* @__PURE__ */ e("p", { children: y(i.departureTime).format(
45
45
  // isMobile
46
46
  // ? EDateFormats.FlightTime
47
47
  // :
48
- v.FlightShortDate
48
+ F.FlightShortDate
49
49
  ) })
50
50
  ] }),
51
- /* @__PURE__ */ e("div", { className: "flight-duration", children: [
52
- /* @__PURE__ */ r("span", { className: "line" }),
53
- /* @__PURE__ */ e("p", { children: [
54
- j(p.slices[0].duration),
51
+ /* @__PURE__ */ r("div", { className: "flight-duration", children: [
52
+ /* @__PURE__ */ e("span", { className: "line" }),
53
+ /* @__PURE__ */ r("p", { children: [
54
+ H(p.slices[0].duration),
55
55
  " ",
56
56
  " - ",
57
57
  i.numberOfStops > 0 ? `${i.numberOfStops} Stop${i.numberOfStops > 1 ? "s" : ""}` : "Direct"
58
58
  ] }),
59
- /* @__PURE__ */ r("span", { className: "line" })
59
+ /* @__PURE__ */ e("span", { className: "line" })
60
60
  ] }),
61
- /* @__PURE__ */ e("div", { children: [
62
- /* @__PURE__ */ e("p", { children: [
61
+ /* @__PURE__ */ r("div", { children: [
62
+ /* @__PURE__ */ r("p", { children: [
63
63
  l.city,
64
64
  ", ",
65
- u(l.country)
65
+ v(l.country)
66
66
  ] }),
67
- /* @__PURE__ */ e("p", { children: [
68
- F(i.arrivalTime).format(
67
+ /* @__PURE__ */ r("p", { children: [
68
+ y(i.arrivalTime).format(
69
69
  // isMobile
70
70
  // ? EDateFormats.FlightTime
71
71
  // :
72
- v.FlightShortDate
72
+ F.FlightShortDate
73
73
  ),
74
74
  " "
75
75
  ] })
76
76
  ] })
77
77
  ] }) }),
78
- /* @__PURE__ */ e("div", { className: "flight-footer", children: [
79
- /* @__PURE__ */ e("div", { className: "flight-detail-container", children: [
80
- /* @__PURE__ */ e(
78
+ /* @__PURE__ */ r("div", { className: "flight-footer", children: [
79
+ /* @__PURE__ */ r("div", { className: "flight-detail-container", children: [
80
+ /* @__PURE__ */ r(
81
81
  "div",
82
82
  {
83
83
  className: "flight-detail",
84
84
  onClick: (n) => {
85
- n.stopPropagation(), C(!g);
85
+ n.stopPropagation(), S(!g);
86
86
  },
87
87
  children: [
88
- /* @__PURE__ */ r("p", { children: "Aircraft" }),
89
- /* @__PURE__ */ e("p", { className: "chevron-text", children: [
90
- /* @__PURE__ */ r(B, {}),
91
- /* @__PURE__ */ e("span", { children: [
88
+ /* @__PURE__ */ e("p", { children: "Aircraft" }),
89
+ /* @__PURE__ */ r("p", { className: "chevron-text", children: [
90
+ /* @__PURE__ */ e(L, {}),
91
+ /* @__PURE__ */ r("span", { children: [
92
92
  h[0],
93
- h.length > 1 && /* @__PURE__ */ e("sup", { children: [
93
+ h.length > 1 && /* @__PURE__ */ r("sup", { children: [
94
94
  "+",
95
95
  h.length - 1
96
96
  ] })
@@ -99,56 +99,57 @@ const Q = ({ details: i, onClick: a }) => {
99
99
  ]
100
100
  }
101
101
  ),
102
- /* @__PURE__ */ e("div", { className: "flight-detail", children: [
103
- /* @__PURE__ */ r("p", { children: "Class" }),
104
- /* @__PURE__ */ r("p", { children: i.flightDetails.slices[0].fareBrandName })
105
- ] }),
106
- /* @__PURE__ */ e("div", { className: "flight-detail", children: [
107
- /* @__PURE__ */ r("p", { children: "Marketing Carrier" }),
108
- /* @__PURE__ */ r("p", { children: i.airline })
102
+ /* @__PURE__ */ r("div", { className: "flight-detail", children: [
103
+ /* @__PURE__ */ e("p", { children: "Class" }),
104
+ /* @__PURE__ */ e("p", { children: i.flightDetails.slices[0].fareBrandName })
109
105
  ] })
110
106
  ] }),
111
- /* @__PURE__ */ e("div", { className: "booking-options", children: [
112
- i.cash > 0 && // details.showCashOption &&
113
- /* @__PURE__ */ e(
107
+ /* @__PURE__ */ r("div", { className: "booking-options", children: [
108
+ i.cash > 0 && /* @__PURE__ */ r(
114
109
  "div",
115
110
  {
116
111
  className: "cash-value",
117
112
  onClick: (n) => {
118
- n.stopPropagation(), a(i, o.CASH);
113
+ n.stopPropagation(), a(i, s.CASH);
119
114
  },
120
115
  children: [
121
- /* @__PURE__ */ r("p", { children: S ? "Book For" : "From" }),
122
- /* @__PURE__ */ r("p", { children: /* @__PURE__ */ r(
123
- y,
124
- {
125
- amount: i.cash,
126
- currency: i.currency
127
- }
128
- ) })
116
+ /* @__PURE__ */ e("img", { src: i.airlineLogo }),
117
+ /* @__PURE__ */ r("div", { children: [
118
+ /* @__PURE__ */ e("label", { children: d ? "Book For" : "From" }),
119
+ /* @__PURE__ */ e(
120
+ C,
121
+ {
122
+ amount: i.cash,
123
+ currency: i.currency
124
+ }
125
+ )
126
+ ] })
129
127
  ]
130
128
  }
131
129
  ),
132
- i.points > 0 && /* @__PURE__ */ e(
130
+ i.points > 0 && /* @__PURE__ */ r(
133
131
  "div",
134
132
  {
135
133
  className: "points-value",
136
134
  onClick: (n) => {
137
- n.stopPropagation(), a(i, o.POINTS);
135
+ n.stopPropagation(), a(i, s.POINTS);
138
136
  },
139
137
  children: [
140
- /* @__PURE__ */ r("img", { src: D.programLogo }),
141
- /* @__PURE__ */ e("p", { children: [
142
- `${H(i.points)} miles`,
143
- ((d = i.cashFee) == null ? void 0 : d.amount) > 0 && /* @__PURE__ */ e(I, { children: [
144
- " + ",
145
- /* @__PURE__ */ r(
146
- y,
147
- {
148
- amount: i.cashFee.amount,
149
- currency: i.cashFee.currency
150
- }
151
- )
138
+ /* @__PURE__ */ e("img", { src: D.programLogo }),
139
+ /* @__PURE__ */ r("div", { children: [
140
+ /* @__PURE__ */ e("label", { children: d ? "Book For" : "From" }),
141
+ /* @__PURE__ */ r("p", { children: [
142
+ `${M(i.points)} miles`,
143
+ ((f = i.cashFee) == null ? void 0 : f.amount) > 0 && /* @__PURE__ */ r(I, { children: [
144
+ " + ",
145
+ /* @__PURE__ */ e(
146
+ C,
147
+ {
148
+ amount: i.cashFee.amount,
149
+ currency: i.cashFee.currency
150
+ }
151
+ )
152
+ ] })
152
153
  ] })
153
154
  ] })
154
155
  ]
@@ -156,8 +157,8 @@ const Q = ({ details: i, onClick: a }) => {
156
157
  )
157
158
  ] })
158
159
  ] }),
159
- /* @__PURE__ */ r("div", { className: `flight-details ${g ? "is-open" : ""}`, children: /* @__PURE__ */ r("div", { className: "inner", children: /* @__PURE__ */ r(
160
- L,
160
+ /* @__PURE__ */ e("div", { className: `flight-details ${g ? "is-open" : ""}`, children: /* @__PURE__ */ e("div", { className: "inner", children: /* @__PURE__ */ e(
161
+ R,
161
162
  {
162
163
  itinerary: p.slices[0].segments,
163
164
  origin: c,
@@ -1,8 +1,8 @@
1
1
  import { useState as N, useRef as K } from "react";
2
2
  import { useMutation as L } from "@tanstack/react-query";
3
- import { ECabinClass as Q, EFlightType as J, EFlightPaymentType as k } from "../../types/enums.js";
4
- import { FlightService as D } from "../../services/flights/FlightsService.js";
5
- import { parseFlightDetails as V, groupFlightResults as G, buildFlightSearchQuery as X } from "../../utils/flightUtils.js";
3
+ import { ECabinClass as Q, EFlightType as J, EFlightPaymentType as A } from "../../types/enums.js";
4
+ import { FlightService as k } from "../../services/flights/FlightsService.js";
5
+ import { mapFlightDetailsToResults as V, groupFlightResults as G, buildFlightSearchQuery as X } from "../../utils/flightUtils.js";
6
6
  import "../../arrayExtensions-DWKenJCh.js";
7
7
  import { c as W } from "../../objectUtils-CyIaVmog.js";
8
8
  import Z from "../../stores/useFlightStore.js";
@@ -17,12 +17,12 @@ function re(o) {
17
17
  let t, r, n, s = !1;
18
18
  return function(c) {
19
19
  t === void 0 ? (t = c, r = 0, n = -1) : t = se(t, c);
20
- const u = t.length;
20
+ const i = t.length;
21
21
  let a = 0;
22
- for (; r < u; ) {
22
+ for (; r < i; ) {
23
23
  s && (t[r] === 10 && (a = ++r), s = !1);
24
- let d = -1;
25
- for (; r < u && d === -1; ++r)
24
+ let l = -1;
25
+ for (; r < i && l === -1; ++r)
26
26
  switch (t[r]) {
27
27
  case 58:
28
28
  n === -1 && (n = r - a);
@@ -30,24 +30,24 @@ function re(o) {
30
30
  case 13:
31
31
  s = !0;
32
32
  case 10:
33
- d = r;
33
+ l = r;
34
34
  break;
35
35
  }
36
- if (d === -1)
36
+ if (l === -1)
37
37
  break;
38
- o(t.subarray(a, d), n), a = r, n = -1;
38
+ o(t.subarray(a, l), n), a = r, n = -1;
39
39
  }
40
- a === u ? t = void 0 : a !== 0 && (t = t.subarray(a), r -= a);
40
+ a === i ? t = void 0 : a !== 0 && (t = t.subarray(a), r -= a);
41
41
  };
42
42
  }
43
43
  function oe(o, t, r) {
44
44
  let n = U();
45
45
  const s = new TextDecoder();
46
- return function(c, u) {
46
+ return function(c, i) {
47
47
  if (c.length === 0)
48
48
  r == null || r(n), n = U();
49
- else if (u > 0) {
50
- const a = s.decode(c.subarray(0, u)), d = u + (c[u + 1] === 32 ? 2 : 1), b = s.decode(c.subarray(d));
49
+ else if (i > 0) {
50
+ const a = s.decode(c.subarray(0, i)), l = i + (c[i + 1] === 32 ? 2 : 1), b = s.decode(c.subarray(l));
51
51
  switch (a) {
52
52
  case "data":
53
53
  n.data = n.data ? n.data + `
@@ -89,8 +89,8 @@ var ae = function(o, t) {
89
89
  };
90
90
  const x = "text/event-stream", ie = 1e3, z = "last-event-id";
91
91
  function ue(o, t) {
92
- var { signal: r, headers: n, onopen: s, onmessage: v, onclose: c, onerror: u, openWhenHidden: a, fetch: d } = t, b = ae(t, ["signal", "headers", "onopen", "onmessage", "onclose", "onerror", "openWhenHidden", "fetch"]);
93
- return new Promise((g, _) => {
92
+ var { signal: r, headers: n, onopen: s, onmessage: v, onclose: c, onerror: i, openWhenHidden: a, fetch: l } = t, b = ae(t, ["signal", "headers", "onopen", "onmessage", "onclose", "onerror", "openWhenHidden", "fetch"]);
93
+ return new Promise((g, D) => {
94
94
  const p = Object.assign({}, n);
95
95
  p.accept || (p.accept = x);
96
96
  let m;
@@ -105,13 +105,13 @@ function ue(o, t) {
105
105
  r == null || r.addEventListener("abort", () => {
106
106
  S(), g();
107
107
  });
108
- const q = d ?? window.fetch, P = s ?? ce;
108
+ const _ = l ?? window.fetch, q = s ?? ce;
109
109
  async function T() {
110
110
  var C;
111
111
  m = new AbortController();
112
112
  try {
113
- const O = await q(o, Object.assign(Object.assign({}, b), { headers: p, signal: m.signal }));
114
- await P(O), await ne(O.body, re(oe((h) => {
113
+ const O = await _(o, Object.assign(Object.assign({}, b), { headers: p, signal: m.signal }));
114
+ await q(O), await ne(O.body, re(oe((h) => {
115
115
  h ? p[z] = h : delete p[z];
116
116
  }, (h) => {
117
117
  F = h;
@@ -119,10 +119,10 @@ function ue(o, t) {
119
119
  } catch (O) {
120
120
  if (!m.signal.aborted)
121
121
  try {
122
- const h = (C = u == null ? void 0 : u(O)) !== null && C !== void 0 ? C : F;
122
+ const h = (C = i == null ? void 0 : i(O)) !== null && C !== void 0 ? C : F;
123
123
  window.clearTimeout(E), E = window.setTimeout(T, h);
124
124
  } catch (h) {
125
- S(), _(h);
125
+ S(), D(h);
126
126
  }
127
127
  }
128
128
  }
@@ -144,20 +144,19 @@ const de = 3 * 60 * 1e3, $ = (o) => {
144
144
  if (o.flightType === J.ROUND_TRIP && !o.returnDate)
145
145
  throw new Error("Return date is required for round-trip flights.");
146
146
  }, Ee = () => {
147
- const { token: o, config: t } = ee(), [r, n] = N(""), [s, v] = N([]), [c, u] = N(!1), a = K(null), {
148
- inboundResults: d,
147
+ const { token: o, config: t } = ee(), [r, n] = N(""), [s, v] = N([]), [c, i] = N(!1), a = K(null), {
148
+ inboundResults: l,
149
149
  outboundResults: b,
150
150
  setInboundResults: g,
151
- setOutboundResults: _,
151
+ setOutboundResults: D,
152
152
  partialOfferRequestId: p,
153
153
  setPartialOfferRequestId: m
154
154
  } = Z(), w = ({
155
155
  data: e,
156
- previousResults: l,
157
156
  inbound: f
158
157
  }) => {
159
- const i = V(e, l);
160
- return (f ? g : _)(G(i)), i;
158
+ const d = V(e);
159
+ return (f ? g : D)(G(d)), d;
161
160
  }, {
162
161
  mutate: F,
163
162
  status: E,
@@ -165,7 +164,7 @@ const de = 3 * 60 * 1e3, $ = (o) => {
165
164
  } = L({
166
165
  mutationFn: async (e) => {
167
166
  $(e);
168
- const f = {
167
+ const d = {
169
168
  passengers: Array.from(
170
169
  { length: e.passengers ?? B },
171
170
  () => ({ type: "adult" })
@@ -175,55 +174,55 @@ const de = 3 * 60 * 1e3, $ = (o) => {
175
174
  cabin_class: e.cabinClass || Y
176
175
  };
177
176
  if (e.flightType === J.ONE_WAY) {
178
- const i = await D.cashOnlySearch({
179
- ...f,
177
+ const u = await k.cashOnlySearch({
178
+ ...d,
180
179
  departure_date: e.departureDate
181
180
  });
182
181
  return {
183
- success: i.success,
184
- data: i.data
182
+ success: u.success,
183
+ data: u.data
185
184
  };
186
185
  } else {
187
- const i = await D.roundTripOutboundSearch({
188
- ...f,
186
+ const u = await k.roundTripOutboundSearch({
187
+ ...d,
189
188
  departure_date: e.departureDate,
190
189
  return_date: e.returnDate
191
190
  });
192
191
  return {
193
- success: i.success,
194
- data: i.data.offers,
195
- partialOfferRequestId: i.data.id
192
+ success: u.success,
193
+ data: u.data.offers,
194
+ partialOfferRequestId: u.data.id
196
195
  };
197
196
  }
198
197
  },
199
198
  onSuccess: (e) => {
200
- const { success: l, data: f, partialOfferRequestId: i } = e;
201
- if (!l) {
199
+ const { success: f, data: d, partialOfferRequestId: u } = e;
200
+ if (!f) {
202
201
  console.log("oh lol, it didn't work");
203
202
  return;
204
203
  }
205
- w({ data: f }), i && m(i);
204
+ w({ data: d }), u && m(u);
206
205
  },
207
206
  onError: (e) => {
208
207
  console.error("Error in outbound flight search:", e);
209
208
  }
210
209
  }), {
211
- mutate: q,
212
- status: P,
210
+ mutate: _,
211
+ status: q,
213
212
  error: T
214
213
  } = L({
215
214
  mutationFn: async (e) => {
216
215
  if (!p)
217
216
  throw new Error("No partialOfferRequestId found for inbound search.");
218
- return n(e), await D.roundTripInboundSearch({
217
+ return n(e), await k.roundTripInboundSearch({
219
218
  outboundOfferId: e,
220
219
  outboundOfferRequestId: p
221
220
  });
222
221
  },
223
222
  onSuccess: (e) => {
224
- const { success: l, data: f } = e;
225
- l && w({
226
- data: f.offers,
223
+ const { success: f, data: d } = e;
224
+ f && w({
225
+ data: d.offers,
227
226
  inbound: !0
228
227
  });
229
228
  },
@@ -238,36 +237,36 @@ const de = 3 * 60 * 1e3, $ = (o) => {
238
237
  mutationFn: async (e) => {
239
238
  if (!p)
240
239
  throw new Error("No partialOfferRequestId found for round-trip fares.");
241
- return await D.getRoundTripFares({
240
+ return await k.getRoundTripFares({
242
241
  outboundOfferId: r,
243
242
  outboundOfferRequestId: p,
244
243
  inboundOfferId: e
245
244
  });
246
245
  },
247
246
  onSuccess: (e) => {
248
- const { success: l, data: f } = e;
249
- if (!l) return;
250
- const i = f.offers;
251
- v(W(i));
247
+ const { success: f, data: d } = e;
248
+ if (!f) return;
249
+ const u = d.offers;
250
+ v(W(u));
252
251
  },
253
252
  onError: (e) => {
254
253
  console.error("Error in round-trip fare search:", e);
255
254
  }
256
255
  }), H = async (e) => {
257
256
  var M;
258
- u(!0);
259
- const l = e.paymentType === k.CASH_AND_MILES ? ['"cash"', '"points"'] : ['"points"'], f = X({
257
+ i(!0);
258
+ const f = e.paymentType === A.CASH_AND_MILES ? ['"cash"', '"points"'] : ['"points"'], d = X({
260
259
  originCode: e.origin,
261
260
  destinationCode: e.destination,
262
261
  departureDate: e.departureDate,
263
262
  cabinClass: e.cabinClass || Y,
264
263
  passengerCount: e.passengers || B,
265
- paymentType: l
264
+ paymentType: f
266
265
  });
267
- let i = [], I = 0;
266
+ let u = [], P = 0;
268
267
  j = new AbortController(), a.current = setTimeout(() => {
269
268
  R();
270
- }, (((M = t == null ? void 0 : t.flightsConfig) == null ? void 0 : M.streamTimeoutTotalSeconds) || de) * 1e3), ue(te() + f, {
269
+ }, (((M = t == null ? void 0 : t.flightsConfig) == null ? void 0 : M.streamTimeoutTotalSeconds) || de) * 1e3), ue(te() + d, {
271
270
  headers: {
272
271
  "Content-Type": "application/json",
273
272
  Authorization: o || "",
@@ -275,33 +274,32 @@ const de = 3 * 60 * 1e3, $ = (o) => {
275
274
  },
276
275
  openWhenHidden: !0,
277
276
  signal: j.signal,
278
- onmessage(A) {
277
+ onmessage(I) {
279
278
  try {
280
- const y = W(JSON.parse(A.data));
279
+ const y = W(JSON.parse(I.data));
281
280
  if (y.success === !1)
282
281
  return;
283
282
  if (y.close === !0) {
284
283
  R();
285
284
  return;
286
285
  }
287
- y.flights && (I = 0, i = w({
288
- data: y.flights,
289
- previousResults: i
290
- })), y.ping && (I++, I >= t.flightsConfig.streamTimeoutPingCount && R());
286
+ y.flights && (P = 0, u = [...u, ...y.flights], w({
287
+ data: u
288
+ })), y.ping && (P++, P >= t.flightsConfig.streamTimeoutPingCount && R());
291
289
  } catch (y) {
292
290
  console.error("Error parsing message:", y), R();
293
291
  }
294
292
  },
295
- onerror(A) {
296
- throw console.error("EventSource error:", A), R(), A;
293
+ onerror(I) {
294
+ throw console.error("EventSource error:", I), R(), I;
297
295
  },
298
296
  onclose() {
299
- u(!1);
297
+ i(!1);
300
298
  },
301
299
  keepalive: !1
302
300
  });
303
301
  }, R = () => {
304
- j.abort(), a.current && (clearTimeout(a.current), a.current = null), u(!1);
302
+ j.abort(), a.current && (clearTimeout(a.current), a.current = null), i(!1);
305
303
  };
306
304
  return {
307
305
  /**
@@ -309,7 +307,7 @@ const de = 3 * 60 * 1e3, $ = (o) => {
309
307
  * @type {boolean}
310
308
  * @default false
311
309
  */
312
- loading: E === "pending" || P === "pending" || c,
310
+ loading: E === "pending" || q === "pending" || c,
313
311
  /**
314
312
  * Loading status for fares
315
313
  * @type {boolean}
@@ -321,7 +319,7 @@ const de = 3 * 60 * 1e3, $ = (o) => {
321
319
  roundTripFaresError: h,
322
320
  // Results
323
321
  outboundResults: b,
324
- inboundResults: d,
322
+ inboundResults: l,
325
323
  roundTripFares: s,
326
324
  // Mutation triggers
327
325
  /**
@@ -333,13 +331,13 @@ const de = 3 * 60 * 1e3, $ = (o) => {
333
331
  searchOutboundFlights: async (e) => {
334
332
  switch ($(e), e.paymentType) {
335
333
  default:
336
- case k.CASH_AND_MILES:
334
+ case A.CASH_AND_MILES:
337
335
  H(e);
338
336
  break;
339
- case k.CASH:
337
+ case A.CASH:
340
338
  F(e);
341
339
  break;
342
- case k.MILES:
340
+ case A.MILES:
343
341
  H(e);
344
342
  break;
345
343
  }
@@ -350,7 +348,7 @@ const de = 3 * 60 * 1e3, $ = (o) => {
350
348
  *
351
349
  * @param {string} outboundOfferId - The ID of the outbound offer
352
350
  */
353
- searchInboundFlights: q,
351
+ searchInboundFlights: _,
354
352
  /**
355
353
  * Used to get round-trip fares after selecting both outbound and inbound flights
356
354
  * @type {function}
@@ -1,4 +1,4 @@
1
- import { IFlightOffer, IFlightResult, ISearchFlightArgs } from './useFlightSearch.types';
1
+ import { IFlightOffer, ISearchFlightArgs } from './useFlightSearch.types';
2
2
  /**
3
3
  * Flights hook for searching outbound, inbound, and round-trip flights
4
4
  * as well as getting fares for round-trip flights
@@ -19,8 +19,8 @@ export declare const useFlightSearch: () => {
19
19
  outboundError: Error | null;
20
20
  inboundError: Error | null;
21
21
  roundTripFaresError: Error | null;
22
- outboundResults: IFlightResult[];
23
- inboundResults: IFlightResult[];
22
+ outboundResults: import('./useFlightSearch.types').IFlightResult[];
23
+ inboundResults: import('./useFlightSearch.types').IFlightResult[];
24
24
  roundTripFares: IFlightOffer[];
25
25
  /**
26
26
  * Used to search for outbound flights
@@ -96,6 +96,7 @@ export interface IFlightResult {
96
96
  id: string;
97
97
  partial: boolean;
98
98
  airline: string;
99
+ airlineLogo: string;
99
100
  flightNumber: string;
100
101
  origin: IAirportLocation;
101
102
  destination: IAirportLocation;
@@ -7,15 +7,6 @@ import { IAirlineProgram } from '../services/wallet/WalletService.types';
7
7
  * @returns {IFlightResult[]} - correctly formatted flight details array
8
8
  */
9
9
  export declare const mapFlightDetailsToResults: (data: IFlightOffer[]) => IFlightResult[];
10
- /**
11
- * @param {IFlightResult[]} data Flight Offers Returned from Duffel
12
- * @param {IFlightResult[]} previousResults Previously Parsed Offers in the IFlightResult format, which should be maintained in the response array
13
- *
14
- * @description Transform the Flight Data to an Easier to Work With Structure than that provided by Duffel
15
- *
16
- * @returns A list of the newly parsed flight offers combined with the previously parsed results
17
- */
18
- export declare const parseFlightDetails: (data: IFlightOffer[], previousResults?: IFlightResult[]) => IFlightResult[];
19
10
  export declare const getFlightNumber: (segment: ISegment) => string;
20
11
  /**
21
12
  * Builds a flight search query URL with the provided parameters.
@@ -39,13 +30,39 @@ export declare const buildFlightSearchQuery: ({ originCode, destinationCode, dep
39
30
  paymentType: string[];
40
31
  }) => string;
41
32
  /**
42
- * @param flights IFlightResult[] -> Parsed Flight Response
43
- * @description -> Groups Flights According to Awayz Route Id
44
- * @returns an Object of Grouped Flights where each key is the Awayz Route ID
33
+ * This function organizes flight results into groups based on a unique flight key, consolidates payment options,
34
+ * and calculates the lowest cash and points values for each group. It also handles cases where multiple airline
35
+ * programs or marketing carriers are associated with a flight, producing multiple rows as needed. Finally, it
36
+ * ensures that cashless results are included in the final results if they are not already present by cash results.
37
+ *
38
+ * @param flights - An array of flight results to be grouped and processed.
39
+ *
40
+ * @example Data Input:
41
+ * 3 marketing airlines: Alaska, American, Hawaiian
42
+ * Alaska: 3 Cash Pricing - 1 Miles Pricing
43
+ * American: 1 Cash Pricing - 1 Miles Pricing
44
+ * Hawaiian: 3 Cash Pricing - 2 Miles Pricing
45
+ *
46
+ * We will get the following results dispayed on the UI:
47
+ *
48
+ * | Flight Number | Marketing Carrier | Cash | Miles |
49
+ * | ------------- | ----------------- | ---- | ----------------------- |
50
+ * | AS 939 | Alaska | $163 | Alaska Mileage 7500 pts |
51
+ * | AS 939 | American | $123 | Alaska Mileage 7500 pts |
52
+ * | AS 939 | Hawaiian | $201 | Alaska Mileage 7500 pts |
53
+ * | AS 939 | Alaska | $163 | AAdvantage 6500 pts |
54
+ * | AS 939 | American | $123 | AAdvantage 6500 pts |
55
+ * | AS 939 | Hawaiian | $201 | AAdvantage 6500 pts |
56
+ * | AS 939 | Alaska | $163 | Hawaiian Miles 8500 pts |
57
+ * | AS 939 | American | $123 | Hawaiian Miles 8500 pts |
58
+ * | AS 939 | Hawaiian | $201 | Hawaiian Miles 8500 pts |
59
+ *
60
+ * @returns An array of flight results, with duplicates removed and cashless results included.
45
61
  */
46
62
  export declare const groupFlightResults: (flights: IFlightResult[]) => IFlightResult[];
47
63
  export declare const removeLeadingZeros: (str: string) => string;
48
64
  export declare const getLogoPath: (carrier: string) => string;
65
+ export declare const getFullLogoPath: (carrier: string) => string;
49
66
  export declare const DEFAULT_AIRLINE_PROGRAM: IAirlineProgram;
50
67
  /**
51
68
  *
@@ -1,40 +1,44 @@
1
- import { h as F } from "../arrayExtensions-DWKenJCh.js";
1
+ import { h as p } from "../arrayExtensions-DWKenJCh.js";
2
2
  import { c as K } from "../dateUtils-DeNLG5hw.js";
3
3
  import "react";
4
- import { awayzClient as q } from "@odynn/awayz-core";
4
+ import { awayzClient as B } from "@odynn/awayz-core";
5
5
  import { WalletService as Q } from "../services/wallet/WalletService.js";
6
6
  import { ERewardProgramCategories as V } from "../services/wallet/WalletService.types.js";
7
- const S = (s) => s == null ? void 0 : s.map((e) => {
8
- var n, t, r, a, i, o, l, h, g, M, P, N, A, L, w, d, p, c, y, C, b, m, u, D, O, T, z, f, v, E, _, $, Z, G;
7
+ import { DUFFEL_ASSET_PATH as Y } from "../constants/constants.js";
8
+ const ie = (t) => t == null ? void 0 : t.map((e) => {
9
+ var n, o, d, m, s, i, a, r, l, c, u, C, w, L, D, b, A, h, F, P, T, O, R, k, v, E, I, _, z, S, Z, $, G, M;
9
10
  return {
10
11
  id: e.id,
11
12
  points: (e == null ? void 0 : e.points) >= 0 ? e.points : -1,
12
13
  partial: e == null ? void 0 : e.partial,
13
14
  origin: {
14
- city: ((n = e.slices[0].segments[0].origin) == null ? void 0 : n.cityName) || ((r = (t = e.slices[0].segments[0].origin) == null ? void 0 : t.city) == null ? void 0 : r.name),
15
- country: ((a = e.slices[0].segments[0].origin) == null ? void 0 : a.iataCountryCode) || ((o = (i = e.slices[0].segments[0].origin) == null ? void 0 : i.city) == null ? void 0 : o.iataCountryCode),
16
- airportCode: ((l = e.slices[0].segments[0].origin) == null ? void 0 : l.iataCityCode) || ((g = (h = e.slices[0].segments[0].origin) == null ? void 0 : h.city) == null ? void 0 : g.iataCode),
15
+ city: ((n = e.slices[0].segments[0].origin) == null ? void 0 : n.cityName) || ((d = (o = e.slices[0].segments[0].origin) == null ? void 0 : o.city) == null ? void 0 : d.name),
16
+ country: ((m = e.slices[0].segments[0].origin) == null ? void 0 : m.iataCountryCode) || ((i = (s = e.slices[0].segments[0].origin) == null ? void 0 : s.city) == null ? void 0 : i.iataCountryCode),
17
+ airportCode: ((a = e.slices[0].segments[0].origin) == null ? void 0 : a.iataCityCode) || ((l = (r = e.slices[0].segments[0].origin) == null ? void 0 : r.city) == null ? void 0 : l.iataCode),
17
18
  coordinates: {
18
- latitude: (P = (M = e.slices[0].segments[0].origin) == null ? void 0 : M.city) == null ? void 0 : P.latitude,
19
- longitude: (A = (N = e.slices[0].segments[0].origin) == null ? void 0 : N.city) == null ? void 0 : A.longitude
19
+ latitude: (u = (c = e.slices[0].segments[0].origin) == null ? void 0 : c.city) == null ? void 0 : u.latitude,
20
+ longitude: (w = (C = e.slices[0].segments[0].origin) == null ? void 0 : C.city) == null ? void 0 : w.longitude
20
21
  }
21
22
  },
22
23
  destination: {
23
- city: ((w = (L = e.slices[0].segments.getLast()) == null ? void 0 : L.destination) == null ? void 0 : w.cityName) || ((c = (p = (d = e.slices[0].segments.getLast()) == null ? void 0 : d.destination) == null ? void 0 : p.city) == null ? void 0 : c.name),
24
- country: ((C = (y = e.slices[0].segments.getLast()) == null ? void 0 : y.destination) == null ? void 0 : C.iataCountryCode) || ((u = (m = (b = e.slices[0].segments.getLast()) == null ? void 0 : b.destination) == null ? void 0 : m.city) == null ? void 0 : u.iataCountryCode),
25
- airportCode: ((O = (D = e.slices[0].segments.getLast()) == null ? void 0 : D.destination) == null ? void 0 : O.iataCityCode) || ((f = (z = (T = e.slices[0].segments.getLast()) == null ? void 0 : T.destination) == null ? void 0 : z.city) == null ? void 0 : f.iataCode),
24
+ city: ((D = (L = e.slices[0].segments.getLast()) == null ? void 0 : L.destination) == null ? void 0 : D.cityName) || ((h = (A = (b = e.slices[0].segments.getLast()) == null ? void 0 : b.destination) == null ? void 0 : A.city) == null ? void 0 : h.name),
25
+ country: ((P = (F = e.slices[0].segments.getLast()) == null ? void 0 : F.destination) == null ? void 0 : P.iataCountryCode) || ((R = (O = (T = e.slices[0].segments.getLast()) == null ? void 0 : T.destination) == null ? void 0 : O.city) == null ? void 0 : R.iataCountryCode),
26
+ airportCode: ((v = (k = e.slices[0].segments.getLast()) == null ? void 0 : k.destination) == null ? void 0 : v.iataCityCode) || ((_ = (I = (E = e.slices[0].segments.getLast()) == null ? void 0 : E.destination) == null ? void 0 : I.city) == null ? void 0 : _.iataCode),
26
27
  coordinates: {
27
- latitude: (_ = (E = (v = e.slices[0].segments.getLast()) == null ? void 0 : v.destination) == null ? void 0 : E.city) == null ? void 0 : _.latitude,
28
- longitude: (G = (Z = ($ = e.slices[0].segments.getLast()) == null ? void 0 : $.destination) == null ? void 0 : Z.city) == null ? void 0 : G.longitude
28
+ latitude: (Z = (S = (z = e.slices[0].segments.getLast()) == null ? void 0 : z.destination) == null ? void 0 : S.city) == null ? void 0 : Z.latitude,
29
+ longitude: (M = (G = ($ = e.slices[0].segments.getLast()) == null ? void 0 : $.destination) == null ? void 0 : G.city) == null ? void 0 : M.longitude
29
30
  }
30
31
  },
31
32
  airline: e.owner.name,
33
+ airlineLogo: g(
34
+ e.slices[0].segments[0].marketingCarrier.iataCode
35
+ ),
32
36
  cash: e.totalAmount ? parseFloat(e.totalAmount) : 0,
33
37
  currency: e.baseCurrency,
34
38
  flightNumber: j(e.slices[0].segments[0]),
35
39
  awayzGroupId: e.slices[0].comparisonKey || e.awayzRouteId || e.awayzGroupId || e.id,
36
- departureTime: F(e.slices[0].segments[0].departingAt).toDate(),
37
- arrivalTime: F(
40
+ departureTime: p(e.slices[0].segments[0].departingAt).toDate(),
41
+ arrivalTime: p(
38
42
  e.slices[0].segments[e.slices[0].segments.length - 1].arrivingAt
39
43
  ).toDate(),
40
44
  numberOfStops: e.slices[0].segments.length - 1,
@@ -43,101 +47,45 @@ const S = (s) => s == null ? void 0 : s.map((e) => {
43
47
  airlineProgram: e.airlineProgram,
44
48
  paymentOptions: [],
45
49
  durationMinutes: K({
46
- departureTime: F(e.slices[0].segments[0].departingAt),
47
- arrivalTime: F(e.slices[0].segments.getLast().arrivingAt),
50
+ departureTime: p(e.slices[0].segments[0].departingAt),
51
+ arrivalTime: p(e.slices[0].segments.getLast().arrivingAt),
48
52
  originTimeZone: e.slices[0].segments[0].origin.timeZone,
49
53
  destinationTimeZone: e.slices[0].segments.getLast().destination.timeZone,
50
54
  duration: e.slices[0].duration
51
55
  }),
52
56
  cashFee: e.cashFee
53
57
  };
54
- }), ee = (s, e) => {
55
- if (!(e != null && e.length))
56
- return S(s);
57
- const n = [...e], t = [], r = {};
58
- for (const i of s) {
59
- const o = i.slices[0].segments, l = o[0], h = {
60
- iataCode: l.operatingCarrier.iataCode,
61
- flightNumber: k(
62
- l.operatingCarrierFlightNumber
63
- )
64
- }, g = {
65
- iataCode: l.marketingCarrier.iataCode,
66
- flightNumber: k(
67
- l.marketingCarrierFlightNumber
68
- )
69
- }, M = i.awayzMatchId, P = `${h.iataCode}_${g.iataCode}-${g.flightNumber}`, N = i.awayzMarketerMatchId, A = !!h.flightNumber && h.flightNumber != "", L = !!g.flightNumber && g.flightNumber != "", w = n.filter((d, p) => {
70
- const c = d.flightDetails, y = d.flightDetails.slices[0].segments[0].operatingCarrierFlightNumber, C = c.id && !!y && y !== "";
71
- if (!(c.slices[0].segments.length === (o == null ? void 0 : o.length) && !c.slices[0].segments.find(
72
- (u, D) => u.departingAt !== o[D].departingAt || u.arrivingAt !== o[D].arrivingAt || u.duration !== o[D].duration
73
- )))
74
- return !1;
75
- let m = !1;
76
- return (L && A && c.awayzMatchId === M || !C && c.awayzMatchId === P || A && !L && c.awayzMarketerMatchId === N) && (m = !0), m && (r[c.id] = p), m;
77
- });
78
- if (w.length) {
79
- i.slices[0].comparisonKey = w[0].awayzGroupId;
80
- const d = w.find((p) => {
81
- var C, b, m, u;
82
- const c = (C = p.flightDetails.slices[0].fareBrandName) == null ? void 0 : C.toLowerCase(), y = (b = i.slices[0].fareBrandName) == null ? void 0 : b.toLowerCase();
83
- return y === c || // Special Case for AC Only match on first word
84
- // Due to differences in scraped points data and Duffel format
85
- g.iataCode === "AC" && ((m = y.split(" ")) == null ? void 0 : m[0]) === ((u = c.split(" ")) == null ? void 0 : u[0]);
86
- });
87
- if (d) {
88
- const p = r[d.id], c = {
89
- ...i,
90
- ...d,
91
- points: i.points,
92
- airlineProgram: i.airlineProgram,
93
- flightDetails: {
94
- ...i,
95
- ...d.flightDetails,
96
- points: i.points,
97
- airlineProgram: i.airlineProgram
98
- }
99
- };
100
- n[p] = c;
101
- } else
102
- t.push(i);
103
- } else
104
- t.push(i);
105
- }
106
- return [
107
- ...n,
108
- ...S(t) ?? []
109
- ];
110
- }, j = (s) => {
111
- const e = s.operatingCarrierFlightNumber ? s.operatingCarrier : s.marketingCarrier, n = s.operatingCarrierFlightNumber ?? s.marketingCarrierFlightNumber;
112
- return e.iataCode + " " + k(n);
113
- }, te = ({
114
- originCode: s,
58
+ }), j = (t) => {
59
+ const e = t.operatingCarrierFlightNumber ? t.operatingCarrier : t.marketingCarrier, n = t.operatingCarrierFlightNumber ?? t.marketingCarrierFlightNumber;
60
+ return e.iataCode + " " + H(n);
61
+ }, ae = ({
62
+ originCode: t,
115
63
  destinationCode: e,
116
64
  departureDate: n,
117
- cabinClass: t,
118
- passengerCount: r,
119
- paymentType: a
65
+ cabinClass: o,
66
+ passengerCount: d,
67
+ paymentType: m
120
68
  }) => {
121
- let i = "/flights/search/one-way/points-cash?";
122
- return i += `origin=${s}`, i += `&destination=${e}`, i += `&departure_date=${n}`, i += `&cabin_class=${t}`, i += `&adults=${r}`, i += `&cash_or_points=[${a}]`, i;
123
- }, se = (s) => {
69
+ let s = "/flights/search/one-way/points-cash?";
70
+ return s += `origin=${t}`, s += `&destination=${e}`, s += `&departure_date=${n}`, s += `&cabin_class=${o}`, s += `&adults=${d}`, s += `&cash_or_points=[${m}]`, s;
71
+ }, x = (t) => t.flightDetails.slices[0].segments.map((n) => j(n)).join("_"), ne = (t) => {
124
72
  const e = {};
125
- s.forEach((t) => {
126
- const r = t.flightDetails.slices[0].segments.map((a) => j(a)).join("_");
127
- if (e[r]) {
128
- const a = U(t);
129
- e[r].flight.paymentOptions.push(a);
130
- const i = I(
131
- e[r].flight.paymentOptions
73
+ t.forEach((s) => {
74
+ const i = x(s);
75
+ if (e[i]) {
76
+ const a = q(s);
77
+ e[i].flight.paymentOptions.push(a);
78
+ const r = y(
79
+ e[i].flight.paymentOptions
132
80
  );
133
- e[r].flight.cash = i.lowestCash, e[r].flight.points = i.lowestPoints;
81
+ e[i].flight.cash = r.lowestCash, e[i].flight.points = r.lowestPoints;
134
82
  } else {
135
- const { origin: a, destination: i } = t, o = [U(t)], l = I(o);
136
- e[r] = {
83
+ const { origin: a, destination: r } = s, l = [q(s)], c = y(l);
84
+ e[i] = {
137
85
  programs: [],
138
86
  flight: {
139
- id: t.awayzGroupId,
140
- partial: t.partial,
87
+ id: s.awayzGroupId,
88
+ partial: s.partial,
141
89
  origin: {
142
90
  city: a.city,
143
91
  country: a.country,
@@ -145,79 +93,103 @@ const S = (s) => s == null ? void 0 : s.map((e) => {
145
93
  coordinates: a.coordinates
146
94
  },
147
95
  destination: {
148
- city: i.city,
149
- country: i.country,
150
- airportCode: i.airportCode,
151
- coordinates: i.coordinates
96
+ city: r.city,
97
+ country: r.country,
98
+ airportCode: r.airportCode,
99
+ coordinates: r.coordinates
152
100
  },
153
- airline: t.airline,
154
- flightNumber: t.flightNumber,
155
- paymentOptions: o,
156
- numberOfStops: t.numberOfStops,
157
- departureTime: t.departureTime,
158
- arrivalTime: t.arrivalTime,
159
- awayzGroupId: t.awayzGroupId,
160
- duration: t.duration,
161
- airlineProgram: t.airlineProgram,
101
+ airline: s.airline,
102
+ airlineLogo: g(
103
+ s.flightDetails.slices[0].segments[0].marketingCarrier.iataCode
104
+ ),
105
+ flightNumber: s.flightNumber,
106
+ paymentOptions: l,
107
+ numberOfStops: s.numberOfStops,
108
+ departureTime: s.departureTime,
109
+ arrivalTime: s.arrivalTime,
110
+ awayzGroupId: i,
111
+ duration: s.duration,
112
+ airlineProgram: s.airlineProgram,
162
113
  durationMinutes: K({
163
- departureTime: F(
164
- t.flightDetails.slices[0].segments[0].departingAt
114
+ departureTime: p(
115
+ s.flightDetails.slices[0].segments[0].departingAt
165
116
  ),
166
- arrivalTime: F(
167
- t.flightDetails.slices[0].segments.getLast().arrivingAt
117
+ arrivalTime: p(
118
+ s.flightDetails.slices[0].segments.getLast().arrivingAt
168
119
  ),
169
- originTimeZone: t.flightDetails.slices[0].segments[0].origin.timeZone,
170
- destinationTimeZone: t.flightDetails.slices[0].segments.getLast().destination.timeZone,
171
- duration: t.flightDetails.slices[0].duration
120
+ originTimeZone: s.flightDetails.slices[0].segments[0].origin.timeZone,
121
+ destinationTimeZone: s.flightDetails.slices[0].segments.getLast().destination.timeZone,
122
+ duration: s.flightDetails.slices[0].duration
172
123
  }),
173
- cash: l.lowestCash,
174
- points: l.lowestPoints,
175
- flightDetails: t.flightDetails,
176
- currency: t.flightDetails.baseCurrency,
177
- cashFee: t.cashFee
124
+ cash: c.lowestCash,
125
+ points: c.lowestPoints,
126
+ flightDetails: s.flightDetails,
127
+ currency: s.flightDetails.baseCurrency,
128
+ cashFee: s.cashFee
178
129
  }
179
130
  };
180
131
  }
181
- t.airlineProgram && !e[r].programs.includes(t.airlineProgram) && e[r].programs.push(t.airlineProgram);
132
+ s.airlineProgram && !e[i].programs.includes(s.airlineProgram) && e[i].programs.push(s.airlineProgram);
182
133
  });
183
134
  const n = [];
184
- return Object.values(e).forEach((t) => {
185
- const r = [
135
+ Object.values(e).forEach((s) => {
136
+ const i = [
186
137
  ...new Set(
187
- t.flight.paymentOptions.map((a) => a.carrier.name)
138
+ s.flight.paymentOptions.map((a) => a.carrier.name)
188
139
  )
189
140
  ];
190
- t.programs.length > 0 ? t.programs.forEach((a) => {
191
- r.forEach((i) => {
192
- const o = I(
193
- t.flight.paymentOptions.filter(
194
- (l) => l.program === a || l.cash > 0 && l.carrier.name === i
141
+ s.programs.length > 0 ? s.programs.forEach((a) => {
142
+ i.forEach((r) => {
143
+ var c;
144
+ const l = y(
145
+ s.flight.paymentOptions.filter(
146
+ (u) => u.program === a || u.cash > 0 && u.carrier.name === r
195
147
  )
196
148
  );
197
149
  n.push({
198
- ...t.flight,
199
- airline: i,
150
+ ...s.flight,
151
+ airline: r,
152
+ airlineLogo: g(
153
+ (c = s.flight.paymentOptions.find(
154
+ (u) => u.carrier.name === r
155
+ )) == null ? void 0 : c.carrier.iataCode
156
+ ),
200
157
  airlineProgram: a,
201
- cash: o.lowestCash,
202
- points: o.lowestPoints
158
+ cash: l.lowestCash,
159
+ points: l.lowestPoints
203
160
  });
204
161
  });
205
- }) : r.forEach((a) => {
206
- const { lowestCash: i } = I(
207
- t.flight.paymentOptions.filter(
208
- (o) => o.carrier.name === a
162
+ }) : i.forEach((a) => {
163
+ var l;
164
+ const { lowestCash: r } = y(
165
+ s.flight.paymentOptions.filter(
166
+ (c) => c.carrier.name === a
209
167
  )
210
168
  );
211
169
  n.push({
212
- ...t.flight,
170
+ ...s.flight,
213
171
  airline: a,
214
- cash: i
172
+ airlineLogo: g(
173
+ (l = s.flight.paymentOptions.find(
174
+ (c) => c.carrier.name === a
175
+ )) == null ? void 0 : l.carrier.iataCode
176
+ ),
177
+ cash: r
215
178
  });
216
179
  });
217
- }), n;
218
- }, k = (s) => s ? s.replace(/^0+/, "") : "", ie = (s) => `https://assets.duffel.com/img/airlines/for-light-background/full-color-logo/${s}.svg`, R = "/img/logo/odynn-eye.svg", B = {
219
- categoryLogo: R,
220
- programLogo: R,
180
+ });
181
+ const { cashlessResults: o, otherResults: d } = n.reduce(
182
+ (s, i) => (i.cash <= 0 && i.points > 0 ? s.cashlessResults.push(i) : i.cash > 0 && s.otherResults.push(i), s),
183
+ { cashlessResults: [], otherResults: [] }
184
+ ), m = d;
185
+ return o.forEach((s) => {
186
+ m.find(
187
+ (a) => a.awayzGroupId === s.awayzGroupId
188
+ ) || m.push(s);
189
+ }), m;
190
+ }, H = (t) => t ? t.replace(/^0+/, "") : "", oe = (t) => `https://assets.duffel.com/img/airlines/for-light-background/full-color-logo/${t}.svg`, g = (t) => `${Y}${t}.svg`, U = "/img/logo/odynn-eye.svg", N = {
191
+ categoryLogo: U,
192
+ programLogo: U,
221
193
  awayzActive: [],
222
194
  mainProgram: "Unknown",
223
195
  displayProgram: "Unknown",
@@ -227,43 +199,43 @@ const S = (s) => s == null ? void 0 : s.map((e) => {
227
199
  colour: "#fff",
228
200
  // Using App Foreground Colour
229
201
  url: "https://www.odynn.com"
230
- }, ae = async (s) => {
231
- const { airlines: e } = await q.ensureQueryData({
202
+ }, re = async (t) => {
203
+ const { airlines: e } = await B.ensureQueryData({
232
204
  queryKey: ["walletAwards"],
233
205
  queryFn: Q.getAwards,
234
206
  staleTime: 864e5
235
207
  // 24 hours
236
208
  });
237
209
  let n = e.find(
238
- (t) => {
239
- var r, a, i, o;
240
- return ((a = (r = t.mainProgram) == null ? void 0 : r.toLowerCase()) == null ? void 0 : a.includes(s == null ? void 0 : s.toLowerCase())) || ((o = (i = t.displayProgram) == null ? void 0 : i.toLowerCase()) == null ? void 0 : o.includes(s == null ? void 0 : s.toLowerCase()));
210
+ (o) => {
211
+ var d, m, s, i;
212
+ return ((m = (d = o.mainProgram) == null ? void 0 : d.toLowerCase()) == null ? void 0 : m.includes(t == null ? void 0 : t.toLowerCase())) || ((i = (s = o.displayProgram) == null ? void 0 : s.toLowerCase()) == null ? void 0 : i.includes(t == null ? void 0 : t.toLowerCase()));
241
213
  }
242
- ) ?? B;
214
+ ) ?? N;
243
215
  return n || (n = {
244
- ...B,
245
- mainProgram: s,
246
- displayProgram: s,
247
- id: s
216
+ ...N,
217
+ mainProgram: t,
218
+ displayProgram: t,
219
+ id: t
248
220
  }), n;
249
- }, U = (s) => ({
250
- id: s.id,
251
- cash: s.cash,
252
- points: s.points,
253
- program: s.airlineProgram,
254
- baseCurrency: s.flightDetails.baseCurrency,
255
- fareBrandName: s.flightDetails.slices[0].fareBrandName,
256
- cashFee: s.cashFee,
257
- conditions: s.flightDetails.conditions,
221
+ }, q = (t) => ({
222
+ id: t.id,
223
+ cash: t.cash,
224
+ points: t.points,
225
+ program: t.airlineProgram,
226
+ baseCurrency: t.flightDetails.baseCurrency,
227
+ fareBrandName: t.flightDetails.slices[0].fareBrandName,
228
+ cashFee: t.cashFee,
229
+ conditions: t.flightDetails.conditions,
258
230
  carrier: {
259
- iataCode: s.flightDetails.slices[0].segments[0].marketingCarrier.iataCode,
260
- name: s.flightDetails.slices[0].segments[0].marketingCarrier.name
231
+ iataCode: t.flightDetails.slices[0].segments[0].marketingCarrier.iataCode,
232
+ name: t.flightDetails.slices[0].segments[0].marketingCarrier.name
261
233
  }
262
- }), I = (s) => {
234
+ }), y = (t) => {
263
235
  const e = Math.min(
264
- ...s.filter((t) => t.cash > 0).map((t) => t.cash)
236
+ ...t.filter((o) => o.cash > 0).map((o) => o.cash)
265
237
  ), n = Math.min(
266
- ...s.filter((t) => t.points > 0).map((t) => t.points)
238
+ ...t.filter((o) => o.points > 0).map((o) => o.points)
267
239
  );
268
240
  return {
269
241
  lowestCash: e === 1 / 0 ? -1 : e,
@@ -271,13 +243,13 @@ const S = (s) => s == null ? void 0 : s.map((e) => {
271
243
  };
272
244
  };
273
245
  export {
274
- B as DEFAULT_AIRLINE_PROGRAM,
275
- te as buildFlightSearchQuery,
276
- ae as getAirlineProgram,
246
+ N as DEFAULT_AIRLINE_PROGRAM,
247
+ ae as buildFlightSearchQuery,
248
+ re as getAirlineProgram,
277
249
  j as getFlightNumber,
278
- ie as getLogoPath,
279
- se as groupFlightResults,
280
- S as mapFlightDetailsToResults,
281
- ee as parseFlightDetails,
282
- k as removeLeadingZeros
250
+ g as getFullLogoPath,
251
+ oe as getLogoPath,
252
+ ne as groupFlightResults,
253
+ ie as mapFlightDetailsToResults,
254
+ H as removeLeadingZeros
283
255
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@odynn/awayz-flights",
3
- "version": "0.2.7",
3
+ "version": "0.2.8",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"