@odynn/awayz-flights 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/README.md +50 -0
  2. package/dist/FlightItinerary-C2U8MR2H.js +396 -0
  3. package/dist/FlightsService-Bc_71ary.js +4536 -0
  4. package/dist/arrayExtensions-BS8S8Zke.js +3116 -0
  5. package/dist/assets/_styles.css +1 -0
  6. package/dist/assets/_styles2.css +1 -0
  7. package/dist/components/FlightItinerary/FlightItinerary.js +11 -0
  8. package/dist/components/FlightResult/FlightResult.js +138 -0
  9. package/dist/components/index.js +6 -0
  10. package/dist/constants/constants.js +4 -0
  11. package/dist/constants/endpoints.js +4 -0
  12. package/dist/enums/EPaymentType.js +4 -0
  13. package/dist/enums/index.js +4 -0
  14. package/dist/hooks/index.js +6 -0
  15. package/dist/hooks/useAirportSearch/useAirportSearch.js +37 -0
  16. package/dist/hooks/useAirportSearch/useAirportSearch.types.js +1 -0
  17. package/dist/hooks/useFlightSearch/useFlightSearch.js +265 -0
  18. package/dist/hooks/useFlightSearch/useFlightSearch.types.js +4 -0
  19. package/dist/lib/components/FlightItinerary/FlightItinerary.d.ts +10 -0
  20. package/dist/lib/components/FlightResult/FlightResult.d.ts +8 -0
  21. package/dist/lib/components/index.d.ts +1 -0
  22. package/dist/lib/constants/constants.d.ts +1 -0
  23. package/dist/lib/constants/endpoints.d.ts +6 -0
  24. package/dist/lib/enums/EPaymentType.d.ts +4 -0
  25. package/dist/lib/enums/index.d.ts +1 -0
  26. package/dist/lib/hooks/index.d.ts +2 -0
  27. package/dist/lib/hooks/useAirportSearch/useAirportSearch.d.ts +6 -0
  28. package/dist/lib/hooks/useAirportSearch/useAirportSearch.types.d.ts +11 -0
  29. package/dist/lib/hooks/useFlightSearch/useFlightSearch.d.ts +8 -0
  30. package/dist/lib/hooks/useFlightSearch/useFlightSearch.types.d.ts +277 -0
  31. package/dist/lib/main.d.ts +3 -0
  32. package/dist/lib/services/flights/FlightsService.d.ts +11 -0
  33. package/dist/lib/services/flights/FlightsService.types.d.ts +201 -0
  34. package/dist/lib/types/enums.d.ts +15 -0
  35. package/dist/lib/types/index.d.ts +1 -0
  36. package/dist/lib/utils/flightUtils.d.ts +45 -0
  37. package/dist/main.js +14 -0
  38. package/dist/moment-BGjjqtLQ.js +2594 -0
  39. package/dist/services/flights/FlightsService.js +9 -0
  40. package/dist/services/flights/FlightsService.types.js +1 -0
  41. package/dist/types/enums.js +6 -0
  42. package/dist/types/index.js +6 -0
  43. package/dist/utils/flightUtils.js +181 -0
  44. package/package.json +72 -0
@@ -0,0 +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 .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}
@@ -0,0 +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-itinerary{display:flex;flex-direction:column}.flight-itinerary .layover{position:relative;padding-bottom:3rem}.flight-itinerary .layover:before{content:"";position:absolute;top:0;bottom:0;left:calc(.5rem + 1px);width:3px;background:repeating-linear-gradient(0deg,#d8e3ea 0,#d8e3ea 5px,#0000 0,#0000 8px);z-index:7}.flight-itinerary .layover>div>p,.flight-itinerary .layover>div>i{color:#a9b2b7}.flight-itinerary .departure,.flight-itinerary .arrival{display:flex;gap:2rem}.flight-itinerary .departure>p,.flight-itinerary .arrival>p{position:relative;margin-left:2rem}.flight-itinerary .departure>p:before,.flight-itinerary .arrival>p:before{content:"";border:2px solid #d8e3ea;height:1rem;width:1rem;border-radius:50%;position:absolute;left:-2rem;top:-.2rem;z-index:10;background-color:var(--foreground, #fff)}.flight-itinerary .departure>p .time-zone,.flight-itinerary .arrival>p .time-zone{color:var(--text-light, rgba(37, 46, 52, .2509803922));font-size:.8rem}.flight-itinerary .departure>p .travel-time,.flight-itinerary .arrival>p .travel-time{color:var(--text-light, rgba(37, 46, 52, .2509803922));font-size:.8rem;display:flex;flex-direction:row;margin-top:1rem;gap:.25rem;align-items:center}.flight-itinerary .departure{padding-bottom:2rem;position:relative}.flight-itinerary .departure:before{content:"";position:absolute;top:0;bottom:0;left:calc(.5rem + 1px);width:2px;background-color:#d8e3ea;z-index:7}.flight-itinerary .departure div{flex:1;display:flex;flex-direction:column;gap:4px;position:relative;border-radius:.5rem}.flight-itinerary .departure div span{font-weight:500}.flight-itinerary .departure div img{max-width:150px;max-height:20px;align-self:flex-start}
@@ -0,0 +1,11 @@
1
+ import "react/jsx-runtime";
2
+ import "react";
3
+ import "../../moment-BGjjqtLQ.js";
4
+ import '../../assets/_styles2.css';/* empty css */
5
+ import "../../types/enums.js";
6
+ import { a as d } from "../../FlightItinerary-C2U8MR2H.js";
7
+ import "../../arrayExtensions-BS8S8Zke.js";
8
+ import "../../constants/constants.js";
9
+ export {
10
+ d as default
11
+ };
@@ -0,0 +1,138 @@
1
+ import { jsx as r, jsxs as e } from "react/jsx-runtime";
2
+ import b, { useState as y, useMemo as F } from "react";
3
+ import '../../assets/_styles.css';/* empty css */
4
+ import { E as d, F as C, a as k } from "../../FlightItinerary-C2U8MR2H.js";
5
+ import { getFlightNumber as O } from "../../utils/flightUtils.js";
6
+ import { h as f } from "../../moment-BGjjqtLQ.js";
7
+ import "../../arrayExtensions-BS8S8Zke.js";
8
+ import { EPaymentType as u } from "../../enums/EPaymentType.js";
9
+ const E = (i, t) => {
10
+ if (i <= 0) return "N/A";
11
+ var a = new Intl.NumberFormat("en-US", {
12
+ style: "currency",
13
+ currency: t
14
+ });
15
+ return i ? a.format(Math.round(i)).toString().split(".")[0] : a.format(0);
16
+ }, j = ({ details: i, onClick: t }) => {
17
+ const [a, N] = y(!1), h = i.origin, m = i.destination, v = i.flightDetails, { flightNumbers: c, airlines: D } = F(() => {
18
+ const l = [], n = [];
19
+ return i.flightDetails.slices.forEach((S) => {
20
+ S.segments.forEach((s) => {
21
+ const p = O(s);
22
+ console.log({ segment: s }), l.includes(p) || l.push(p);
23
+ const o = s.operatingCarrierFlightNumber ? s.operatingCarrier : s.marketingCarrier;
24
+ n.some(
25
+ (g) => g.logo === o.logoSymbolUrl && g.airline === o.name
26
+ ) || n.push({
27
+ logo: o.logoSymbolUrl,
28
+ airline: o.name
29
+ });
30
+ });
31
+ }), { flightNumbers: l, airlines: n };
32
+ }, [i.flightDetails.slices]);
33
+ return /* @__PURE__ */ r("div", { className: "flight-result", onClick: () => t(i), children: /* @__PURE__ */ e("div", { className: "content", children: [
34
+ /* @__PURE__ */ r("div", { className: "flight-info", children: /* @__PURE__ */ e("div", { className: "flight-locations", children: [
35
+ /* @__PURE__ */ r("div", { className: "airlines", children: D.map((l, n) => /* @__PURE__ */ r(b.Fragment, { children: /* @__PURE__ */ r("div", { className: "tip", children: /* @__PURE__ */ r("img", { src: l.logo, alt: l.airline }) }, n) }, n)) }),
36
+ /* @__PURE__ */ e("div", { className: "flight-location", children: [
37
+ /* @__PURE__ */ e("p", { children: [
38
+ h.city,
39
+ ","
40
+ ] }),
41
+ /* @__PURE__ */ r("p", { children: f(i.departureTime).format(
42
+ // isMobile
43
+ // ? EDateFormats.FlightTime
44
+ // :
45
+ d.FlightShortDate
46
+ ) })
47
+ ] }),
48
+ /* @__PURE__ */ e("div", { className: "flight-duration", children: [
49
+ /* @__PURE__ */ r("span", { className: "line" }),
50
+ /* @__PURE__ */ r("p", { children: i.numberOfStops > 0 ? `${i.numberOfStops} Stop${i.numberOfStops > 1 ? "s" : ""}` : "Direct" }),
51
+ /* @__PURE__ */ r("span", { className: "line" })
52
+ ] }),
53
+ /* @__PURE__ */ e("div", { children: [
54
+ /* @__PURE__ */ e("p", { children: [
55
+ m.city,
56
+ ",",
57
+ " "
58
+ ] }),
59
+ /* @__PURE__ */ e("p", { children: [
60
+ f(i.arrivalTime).format(
61
+ // isMobile
62
+ // ? EDateFormats.FlightTime
63
+ // :
64
+ d.FlightShortDate
65
+ ),
66
+ " "
67
+ ] })
68
+ ] })
69
+ ] }) }),
70
+ /* @__PURE__ */ e("div", { className: "flight-footer", children: [
71
+ /* @__PURE__ */ e("div", { className: "flight-detail-container", children: [
72
+ /* @__PURE__ */ e(
73
+ "div",
74
+ {
75
+ className: "flight-detail",
76
+ onClick: (l) => {
77
+ l.stopPropagation(), N(!a);
78
+ },
79
+ children: [
80
+ /* @__PURE__ */ r("p", { children: "Aircraft" }),
81
+ /* @__PURE__ */ e("p", { className: "chevron-text", children: [
82
+ /* @__PURE__ */ r(C, {}),
83
+ /* @__PURE__ */ e("span", { children: [
84
+ c[0],
85
+ c.length > 1 && /* @__PURE__ */ e("sup", { children: [
86
+ "+",
87
+ c.length - 1
88
+ ] })
89
+ ] })
90
+ ] })
91
+ ]
92
+ }
93
+ ),
94
+ /* @__PURE__ */ e("div", { className: "flight-detail", children: [
95
+ /* @__PURE__ */ r("p", { children: "Class" }),
96
+ /* @__PURE__ */ r("p", { children: i.flightDetails.slices[0].fareBrandName })
97
+ ] }),
98
+ /* @__PURE__ */ e("div", { className: "flight-detail", children: [
99
+ /* @__PURE__ */ r("p", { children: "Marketing Carrier" }),
100
+ /* @__PURE__ */ r("p", { children: i.flightDetails.slices[0].segments[0].marketingCarrier.name })
101
+ ] })
102
+ ] }),
103
+ /* @__PURE__ */ e("div", { className: "booking-options", children: [
104
+ i.cash > 0 && // details.showCashOption &&
105
+ /* @__PURE__ */ r(
106
+ "div",
107
+ {
108
+ className: "cash-value",
109
+ onClick: (l) => {
110
+ l.stopPropagation(), t(i, u.CASH);
111
+ },
112
+ children: /* @__PURE__ */ r("p", { children: E(i.cash, "USD") })
113
+ }
114
+ ),
115
+ i.points > 0 && /* @__PURE__ */ r(
116
+ "div",
117
+ {
118
+ className: "points-value",
119
+ onClick: (l) => {
120
+ l.stopPropagation(), t(i, u.POINTS);
121
+ }
122
+ }
123
+ )
124
+ ] })
125
+ ] }),
126
+ /* @__PURE__ */ r("div", { className: `flight-details ${a ? "is-open" : ""}`, children: /* @__PURE__ */ r("div", { className: "inner", children: /* @__PURE__ */ r(
127
+ k,
128
+ {
129
+ itinerary: v.slices[0].segments,
130
+ origin: h,
131
+ destination: m
132
+ }
133
+ ) }) })
134
+ ] }) });
135
+ };
136
+ export {
137
+ j as default
138
+ };
@@ -0,0 +1,6 @@
1
+ import "react/jsx-runtime";
2
+ import "react";
3
+ import '../assets/_styles2.css';import '../assets/_styles.css';/* empty css */
4
+ import "../moment-BGjjqtLQ.js";
5
+ import "../arrayExtensions-BS8S8Zke.js";
6
+ /* empty css */
@@ -0,0 +1,4 @@
1
+ const o = "https://assets.duffel.com/img/airlines/for-light-background/full-color-lockup/";
2
+ export {
3
+ o as DUFFEL_ASSET_PATH
4
+ };
@@ -0,0 +1,4 @@
1
+ var s = /* @__PURE__ */ ((r) => (r.GET_AIRPORTS = "/flights/search/airports", r.CASH_FLIGHT_SEARCH = "/flights/search/one-way/cash", r.CASH_OUTBOUND_SEARCH = "flights/search/multi/outbound", r.CASH_INBOUND_SEARCH = "flights/search/multi/inbound", r))(s || {});
2
+ export {
3
+ s as EFlightEndpoint
4
+ };
@@ -0,0 +1,4 @@
1
+ var S = /* @__PURE__ */ ((r) => (r.CASH = "CASH", r.POINTS = "POINTS", r))(S || {});
2
+ export {
3
+ S as EPaymentType
4
+ };
@@ -0,0 +1,4 @@
1
+ import { EPaymentType as o } from "./EPaymentType.js";
2
+ export {
3
+ o as EPaymentType
4
+ };
@@ -0,0 +1,6 @@
1
+ import { useFlightSearch as o } from "./useFlightSearch/useFlightSearch.js";
2
+ import { useAirportSearch as h } from "./useAirportSearch/useAirportSearch.js";
3
+ export {
4
+ h as useAirportSearch,
5
+ o as useFlightSearch
6
+ };
@@ -0,0 +1,37 @@
1
+ import { useState as c } from "react";
2
+ import { F as m } from "../../FlightsService-Bc_71ary.js";
3
+ const _ = () => {
4
+ const [n, t] = c(!1), [o, i] = c([]);
5
+ return { loading: n, searchAirports: async (d) => {
6
+ t(!0);
7
+ const a = await m.getAirports(d);
8
+ if (!a.success)
9
+ return;
10
+ const u = a.data.map((e) => {
11
+ var s;
12
+ return {
13
+ city: {
14
+ name: e.city_name,
15
+ code: e.iata_city_code
16
+ },
17
+ coordinates: {
18
+ latitude: e.latitude,
19
+ longitude: e.longitude
20
+ },
21
+ country: {
22
+ code: e.iata_country_code,
23
+ name: (s = e.country) == null ? void 0 : s.name
24
+ },
25
+ name: e.name,
26
+ iataCode: e.iata_code,
27
+ id: e.id,
28
+ type: e.type,
29
+ label: `${e.iata_code} - ${e.name}`
30
+ };
31
+ });
32
+ i(u), t(!1);
33
+ }, airports: o };
34
+ };
35
+ export {
36
+ _ as useAirportSearch
37
+ };
@@ -0,0 +1,265 @@
1
+ import { useState as T, useRef as k } from "react";
2
+ import { ECabinClass as L, EFlightPaymentType as C, EFlightType as _ } from "../../types/enums.js";
3
+ import { c as j, F as I } from "../../FlightsService-Bc_71ary.js";
4
+ import { buildFlightSearchQuery as q, parseFlightDetails as x, groupFlightResults as H } from "../../utils/flightUtils.js";
5
+ import "../../moment-BGjjqtLQ.js";
6
+ import "../../arrayExtensions-BS8S8Zke.js";
7
+ async function M(s, t) {
8
+ const r = s.getReader();
9
+ let n;
10
+ for (; !(n = await r.read()).done; )
11
+ t(n.value);
12
+ }
13
+ function U(s) {
14
+ let t, r, n, a = !1;
15
+ return function(l) {
16
+ t === void 0 ? (t = l, r = 0, n = -1) : t = Y(t, l);
17
+ const i = t.length;
18
+ let o = 0;
19
+ for (; r < i; ) {
20
+ a && (t[r] === 10 && (o = ++r), a = !1);
21
+ let c = -1;
22
+ for (; r < i && c === -1; ++r)
23
+ switch (t[r]) {
24
+ case 58:
25
+ n === -1 && (n = r - o);
26
+ break;
27
+ case 13:
28
+ a = !0;
29
+ case 10:
30
+ c = r;
31
+ break;
32
+ }
33
+ if (c === -1)
34
+ break;
35
+ s(t.subarray(o, c), n), o = r, n = -1;
36
+ }
37
+ o === i ? t = void 0 : o !== 0 && (t = t.subarray(o), r -= o);
38
+ };
39
+ }
40
+ function W(s, t, r) {
41
+ let n = F();
42
+ const a = new TextDecoder();
43
+ return function(l, i) {
44
+ if (l.length === 0)
45
+ r == null || r(n), n = F();
46
+ else if (i > 0) {
47
+ const o = a.decode(l.subarray(0, i)), c = i + (l[i + 1] === 32 ? 2 : 1), h = a.decode(l.subarray(c));
48
+ switch (o) {
49
+ case "data":
50
+ n.data = n.data ? n.data + `
51
+ ` + h : h;
52
+ break;
53
+ case "event":
54
+ n.event = h;
55
+ break;
56
+ case "id":
57
+ s(n.id = h);
58
+ break;
59
+ case "retry":
60
+ const m = parseInt(h, 10);
61
+ isNaN(m) || t(n.retry = m);
62
+ break;
63
+ }
64
+ }
65
+ };
66
+ }
67
+ function Y(s, t) {
68
+ const r = new Uint8Array(s.length + t.length);
69
+ return r.set(s), r.set(t, s.length), r;
70
+ }
71
+ function F() {
72
+ return {
73
+ data: "",
74
+ event: "",
75
+ id: "",
76
+ retry: void 0
77
+ };
78
+ }
79
+ var $ = function(s, t) {
80
+ var r = {};
81
+ for (var n in s) Object.prototype.hasOwnProperty.call(s, n) && t.indexOf(n) < 0 && (r[n] = s[n]);
82
+ if (s != null && typeof Object.getOwnPropertySymbols == "function")
83
+ for (var a = 0, n = Object.getOwnPropertySymbols(s); a < n.length; a++)
84
+ t.indexOf(n[a]) < 0 && Object.prototype.propertyIsEnumerable.call(s, n[a]) && (r[n[a]] = s[n[a]]);
85
+ return r;
86
+ };
87
+ const D = "text/event-stream", z = 1e3, A = "last-event-id";
88
+ function B(s, t) {
89
+ var { signal: r, headers: n, onopen: a, onmessage: S, onclose: l, onerror: i, openWhenHidden: o, fetch: c } = t, h = $(t, ["signal", "headers", "onopen", "onmessage", "onclose", "onerror", "openWhenHidden", "fetch"]);
90
+ return new Promise((m, E) => {
91
+ const w = Object.assign({}, n);
92
+ w.accept || (w.accept = D);
93
+ let b;
94
+ function R() {
95
+ b.abort(), document.hidden || y();
96
+ }
97
+ o || document.addEventListener("visibilitychange", R);
98
+ let O = z, e = 0;
99
+ function d() {
100
+ document.removeEventListener("visibilitychange", R), window.clearTimeout(e), b.abort();
101
+ }
102
+ r == null || r.addEventListener("abort", () => {
103
+ d(), m();
104
+ });
105
+ const p = c ?? window.fetch, f = a ?? J;
106
+ async function y() {
107
+ var u;
108
+ b = new AbortController();
109
+ try {
110
+ const v = await p(s, Object.assign(Object.assign({}, h), { headers: w, signal: b.signal }));
111
+ await f(v), await M(v.body, U(W((g) => {
112
+ g ? w[A] = g : delete w[A];
113
+ }, (g) => {
114
+ O = g;
115
+ }, S))), l == null || l(), d(), m();
116
+ } catch (v) {
117
+ if (!b.signal.aborted)
118
+ try {
119
+ const g = (u = i == null ? void 0 : i(v)) !== null && u !== void 0 ? u : O;
120
+ window.clearTimeout(e), e = window.setTimeout(y, g);
121
+ } catch (g) {
122
+ d(), E(g);
123
+ }
124
+ }
125
+ }
126
+ y();
127
+ });
128
+ }
129
+ function J(s) {
130
+ const t = s.headers.get("content-type");
131
+ if (!(t != null && t.startsWith(D)))
132
+ throw new Error(`Expected content-type to be ${D}, Actual: ${t}`);
133
+ }
134
+ const N = 1, P = L.ECONOMY, K = 3 * 60 * 1e3, te = () => {
135
+ const [s, t] = T(!1), [r, n] = T(""), [a, S] = T([]), [l, i] = T([]), o = k(null), c = k(null), h = async (e) => {
136
+ switch (m(e), e.paymentType) {
137
+ default:
138
+ case C.CASH_AND_MILES:
139
+ E(e), b(e);
140
+ break;
141
+ case C.CASH:
142
+ b(e);
143
+ break;
144
+ case C.MILES:
145
+ E(e);
146
+ break;
147
+ }
148
+ }, m = (e) => {
149
+ if (!e.origin || !e.destination)
150
+ throw new Error("Origin and destination are required.");
151
+ if (!e.departureDate)
152
+ throw new Error("Departure date is required.");
153
+ if (e.flightType === _.ROUND_TRIP && !e.returnDate)
154
+ throw new Error("Return date is required for round-trip flights.");
155
+ }, E = async (e) => {
156
+ if (!o.current) {
157
+ const d = e.paymentType === C.CASH_AND_MILES ? ['"cash"', '"points"'] : ['"points"'], p = q({
158
+ originCode: e.origin,
159
+ destinationCode: e.destination,
160
+ departureDate: e.departureDate,
161
+ cabinClass: e.cabinClass || P,
162
+ passengerCount: e.passengers || N,
163
+ paymentType: d
164
+ });
165
+ let f = [];
166
+ await B(
167
+ "https://appdev.odynn.info:3003" + p,
168
+ {
169
+ headers: {
170
+ "Content-Type": "application/json",
171
+ Authorization: localStorage.getItem("token") || "",
172
+ "client-id": localStorage.getItem("clientId") || ""
173
+ },
174
+ onmessage(y) {
175
+ try {
176
+ const u = j(JSON.parse(y.data));
177
+ u.success, u.close, u.meta, u.flights && (f = O({
178
+ data: u.flights,
179
+ previousResults: f
180
+ }));
181
+ } catch (u) {
182
+ console.error("Error parsing message:", u);
183
+ }
184
+ },
185
+ onclose() {
186
+ console.log("EventSource closed");
187
+ }
188
+ }
189
+ ), c.current = setTimeout(() => {
190
+ w();
191
+ }, K);
192
+ }
193
+ }, w = () => {
194
+ o.current && (o.current.close(), o.current = null, c.current && (clearTimeout(c.current), c.current = null), t(!1));
195
+ }, b = async (e) => {
196
+ t(!0);
197
+ try {
198
+ const p = {
199
+ passengers: Array.from(
200
+ { length: e.passengers ?? N },
201
+ () => ({
202
+ type: "adult"
203
+ })
204
+ ),
205
+ origin: e.origin || "",
206
+ destination: e.destination || "",
207
+ cabin_class: e.cabinClass || P
208
+ };
209
+ let f;
210
+ switch (e.flightType) {
211
+ default:
212
+ case _.ONE_WAY:
213
+ f = await I.cashOnlySearch({
214
+ ...p,
215
+ departure_date: e.departureDate
216
+ });
217
+ break;
218
+ case _.ROUND_TRIP:
219
+ const v = await I.roundTripOutboundSearch({
220
+ ...p,
221
+ departure_date: e.departureDate,
222
+ return_date: e.returnDate
223
+ });
224
+ f = v.data, n(v.id);
225
+ break;
226
+ }
227
+ const { success: y, data: u } = f;
228
+ if (!y)
229
+ return;
230
+ O({ data: u });
231
+ } catch (d) {
232
+ console.error("Error during flight search:", d);
233
+ } finally {
234
+ t(!1);
235
+ }
236
+ }, R = async (e) => {
237
+ t(!0), i([]);
238
+ const { data: d, success: p } = await I.roundTripInboundSearch({
239
+ outbound_offer_id: e,
240
+ outbound_offer_request_id: r
241
+ });
242
+ t(!1), p && O({
243
+ data: d.offers,
244
+ inbound: !0
245
+ });
246
+ }, O = ({
247
+ data: e,
248
+ previousResults: d,
249
+ inbound: p
250
+ }) => {
251
+ const f = x(e, d);
252
+ var y = p ? i : S;
253
+ return y(H(f)), f;
254
+ };
255
+ return {
256
+ loading: s,
257
+ inboundResults: l,
258
+ outboundResults: a,
259
+ searchOutboundFlights: h,
260
+ searchInboundFlights: R
261
+ };
262
+ };
263
+ export {
264
+ te as useFlightSearch
265
+ };
@@ -0,0 +1,4 @@
1
+ var c = /* @__PURE__ */ ((r) => (r.CARRY_ON = "carry_on", r.CHECKED = "checked", r))(c || {});
2
+ export {
3
+ c as EBaggage
4
+ };
@@ -0,0 +1,10 @@
1
+ import { IAirportLocation, ISegment } from '../../hooks/useFlightSearch/useFlightSearch.types';
2
+ interface FlightItineraryProps {
3
+ origin: IAirportLocation;
4
+ destination: IAirportLocation;
5
+ itinerary: ISegment[];
6
+ onDisableRenderItinerary?: () => void;
7
+ isMultiDayFlight?: boolean;
8
+ }
9
+ declare const FlightItinerary: ({ itinerary, origin, destination, onDisableRenderItinerary, isMultiDayFlight }: FlightItineraryProps) => import("react/jsx-runtime").JSX.Element;
10
+ export default FlightItinerary;
@@ -0,0 +1,8 @@
1
+ import { IFlightResult } from '../../hooks/useFlightSearch/useFlightSearch.types';
2
+ import { EPaymentType } from '../../enums';
3
+ export interface IFlightResultProps {
4
+ details: IFlightResult;
5
+ onClick: (flightDetails: IFlightResult, paymentType?: EPaymentType) => void;
6
+ }
7
+ declare const FlightResult: ({ details, onClick }: IFlightResultProps) => import("react/jsx-runtime").JSX.Element;
8
+ export default FlightResult;
@@ -0,0 +1 @@
1
+ export * from './FlightResult/FlightResult';
@@ -0,0 +1 @@
1
+ export declare const DUFFEL_ASSET_PATH = "https://assets.duffel.com/img/airlines/for-light-background/full-color-lockup/";
@@ -0,0 +1,6 @@
1
+ export declare enum EFlightEndpoint {
2
+ GET_AIRPORTS = "/flights/search/airports",
3
+ CASH_FLIGHT_SEARCH = "/flights/search/one-way/cash",
4
+ CASH_OUTBOUND_SEARCH = "flights/search/multi/outbound",
5
+ CASH_INBOUND_SEARCH = "flights/search/multi/inbound"
6
+ }
@@ -0,0 +1,4 @@
1
+ export declare enum EPaymentType {
2
+ CASH = "CASH",
3
+ POINTS = "POINTS"
4
+ }
@@ -0,0 +1 @@
1
+ export * from './EPaymentType';
@@ -0,0 +1,2 @@
1
+ export * from './useFlightSearch/useFlightSearch';
2
+ export * from './useAirportSearch/useAirportSearch';
@@ -0,0 +1,6 @@
1
+ import { IAirport } from './useAirportSearch.types';
2
+ export declare const useAirportSearch: () => {
3
+ loading: boolean;
4
+ searchAirports: (searchInput: string) => Promise<void>;
5
+ airports: IAirport[];
6
+ };
@@ -0,0 +1,11 @@
1
+ import { ICoordinates, INameCode } from '@type-op/shared';
2
+ export interface IAirport {
3
+ id: string;
4
+ name: string;
5
+ iataCode: string;
6
+ coordinates: ICoordinates;
7
+ city: INameCode;
8
+ country: INameCode;
9
+ type: string;
10
+ label: string;
11
+ }
@@ -0,0 +1,8 @@
1
+ import { IFlightResult, ISearchFlightArgs } from './useFlightSearch.types';
2
+ export declare const useFlightSearch: () => {
3
+ loading: boolean;
4
+ inboundResults: IFlightResult[];
5
+ outboundResults: IFlightResult[];
6
+ searchOutboundFlights: (args: ISearchFlightArgs) => Promise<void>;
7
+ searchInboundFlights: (outboundOfferId: string) => Promise<void>;
8
+ };