@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
package/README.md ADDED
@@ -0,0 +1,50 @@
1
+ # React + TypeScript + Vite
2
+
3
+ This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
4
+
5
+ Currently, two official plugins are available:
6
+
7
+ - [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh
8
+ - [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
9
+
10
+ ## Expanding the ESLint configuration
11
+
12
+ If you are developing a production application, we recommend updating the configuration to enable type aware lint rules:
13
+
14
+ - Configure the top-level `parserOptions` property like this:
15
+
16
+ ```js
17
+ export default tseslint.config({
18
+ languageOptions: {
19
+ // other options...
20
+ parserOptions: {
21
+ project: ['./tsconfig.node.json', './tsconfig.app.json'],
22
+ tsconfigRootDir: import.meta.dirname,
23
+ },
24
+ },
25
+ })
26
+ ```
27
+
28
+ - Replace `tseslint.configs.recommended` to `tseslint.configs.recommendedTypeChecked` or `tseslint.configs.strictTypeChecked`
29
+ - Optionally add `...tseslint.configs.stylisticTypeChecked`
30
+ - Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and update the config:
31
+
32
+ ```js
33
+ // eslint.config.js
34
+ import react from 'eslint-plugin-react'
35
+
36
+ export default tseslint.config({
37
+ // Set the react version
38
+ settings: { react: { version: '18.3' } },
39
+ plugins: {
40
+ // Add the react plugin
41
+ react,
42
+ },
43
+ rules: {
44
+ // other rules...
45
+ // Enable its recommended rules
46
+ ...react.configs.recommended.rules,
47
+ ...react.configs['jsx-runtime'].rules,
48
+ },
49
+ })
50
+ ```
@@ -0,0 +1,396 @@
1
+ import { jsxs as o, jsx as c, Fragment as L } from "react/jsx-runtime";
2
+ import f, { useMemo as U } from "react";
3
+ import { h as p } from "./moment-BGjjqtLQ.js";
4
+ import './assets/_styles2.css';/* empty css */
5
+ import { ECabinClass as W } from "./types/enums.js";
6
+ import { l as k } from "./arrayExtensions-BS8S8Zke.js";
7
+ import { DUFFEL_ASSET_PATH as K } from "./constants/constants.js";
8
+ const B = (e) => {
9
+ const t = Math.floor(e / 1440);
10
+ let r = e % 1440;
11
+ const i = Math.floor(r / 60), n = Math.floor(r % 60);
12
+ return `${t ? `${t}d` : ""} ${i}h ${n}m`;
13
+ };
14
+ function E({
15
+ departureAt: e,
16
+ departureTimeZone: t,
17
+ arrivalAt: r,
18
+ arrivalTimeZone: i
19
+ }) {
20
+ const n = p.tz(e, t);
21
+ return p.tz(r, i).diff(n, "minutes");
22
+ }
23
+ const Z = (e, t) => {
24
+ if (!e)
25
+ return "";
26
+ const r = p(t).tz(e).format("z"), i = p(t).tz(e).format("Z");
27
+ return `${/^\s*[+\-]?\d+\s*$/.test(r) ? `${i} GMT` : r}`;
28
+ }, z = (e) => {
29
+ var t;
30
+ if (!e) return "";
31
+ try {
32
+ return (t = k.byIso(e)) == null ? void 0 : t.country;
33
+ } catch (r) {
34
+ return console.error(r), "";
35
+ }
36
+ };
37
+ var N = /* @__PURE__ */ ((e) => (e.USStringDateFormat = "MMM DD, YYYY", e.USStringDateTimeFormat = "MMM DD, YYYY, h:mm A (z)", e.FlightShortDate = "MMM DD - h:mm A", e.FlightTime = "h:mm A", e.DateFormat = "MM/DD", e.StringDateFormat = "MMM DD", e.FullDateFormat = "MM/DD/YYYY", e.ServerDate = "YYYY-MM-DD", e.GoogleDateFormat = "YYYYMMDDTHHmmssZ", e.AppleDateFormat = "YYYYMMDDTHHmmss", e.USStringDateWithTimeFormat = "MMM DD, YYYY, h:mm A", e))(N || {}), G = {
38
+ color: void 0,
39
+ size: void 0,
40
+ className: void 0,
41
+ style: void 0,
42
+ attr: void 0
43
+ }, x = f.createContext && /* @__PURE__ */ f.createContext(G), q = ["attr", "size", "title"];
44
+ function J(e, t) {
45
+ if (e == null) return {};
46
+ var r = Q(e, t), i, n;
47
+ if (Object.getOwnPropertySymbols) {
48
+ var l = Object.getOwnPropertySymbols(e);
49
+ for (n = 0; n < l.length; n++)
50
+ i = l[n], !(t.indexOf(i) >= 0) && Object.prototype.propertyIsEnumerable.call(e, i) && (r[i] = e[i]);
51
+ }
52
+ return r;
53
+ }
54
+ function Q(e, t) {
55
+ if (e == null) return {};
56
+ var r = {};
57
+ for (var i in e)
58
+ if (Object.prototype.hasOwnProperty.call(e, i)) {
59
+ if (t.indexOf(i) >= 0) continue;
60
+ r[i] = e[i];
61
+ }
62
+ return r;
63
+ }
64
+ function A() {
65
+ return A = Object.assign ? Object.assign.bind() : function(e) {
66
+ for (var t = 1; t < arguments.length; t++) {
67
+ var r = arguments[t];
68
+ for (var i in r)
69
+ Object.prototype.hasOwnProperty.call(r, i) && (e[i] = r[i]);
70
+ }
71
+ return e;
72
+ }, A.apply(this, arguments);
73
+ }
74
+ function _(e, t) {
75
+ var r = Object.keys(e);
76
+ if (Object.getOwnPropertySymbols) {
77
+ var i = Object.getOwnPropertySymbols(e);
78
+ t && (i = i.filter(function(n) {
79
+ return Object.getOwnPropertyDescriptor(e, n).enumerable;
80
+ })), r.push.apply(r, i);
81
+ }
82
+ return r;
83
+ }
84
+ function S(e) {
85
+ for (var t = 1; t < arguments.length; t++) {
86
+ var r = arguments[t] != null ? arguments[t] : {};
87
+ t % 2 ? _(Object(r), !0).forEach(function(i) {
88
+ X(e, i, r[i]);
89
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(r)) : _(Object(r)).forEach(function(i) {
90
+ Object.defineProperty(e, i, Object.getOwnPropertyDescriptor(r, i));
91
+ });
92
+ }
93
+ return e;
94
+ }
95
+ function X(e, t, r) {
96
+ return t = R(t), t in e ? Object.defineProperty(e, t, { value: r, enumerable: !0, configurable: !0, writable: !0 }) : e[t] = r, e;
97
+ }
98
+ function R(e) {
99
+ var t = ee(e, "string");
100
+ return typeof t == "symbol" ? t : t + "";
101
+ }
102
+ function ee(e, t) {
103
+ if (typeof e != "object" || !e) return e;
104
+ var r = e[Symbol.toPrimitive];
105
+ if (r !== void 0) {
106
+ var i = r.call(e, t || "default");
107
+ if (typeof i != "object") return i;
108
+ throw new TypeError("@@toPrimitive must return a primitive value.");
109
+ }
110
+ return (t === "string" ? String : Number)(e);
111
+ }
112
+ function V(e) {
113
+ return e && e.map((t, r) => /* @__PURE__ */ f.createElement(t.tag, S({
114
+ key: r
115
+ }, t.attr), V(t.child)));
116
+ }
117
+ function P(e) {
118
+ return (t) => /* @__PURE__ */ f.createElement(te, A({
119
+ attr: S({}, e.attr)
120
+ }, t), V(e.child));
121
+ }
122
+ function te(e) {
123
+ var t = (r) => {
124
+ var {
125
+ attr: i,
126
+ size: n,
127
+ title: l
128
+ } = e, g = J(e, q), u = n || r.size || "1em", m;
129
+ return r.className && (m = r.className), e.className && (m = (m ? m + " " : "") + e.className), /* @__PURE__ */ f.createElement("svg", A({
130
+ stroke: "currentColor",
131
+ fill: "currentColor",
132
+ strokeWidth: "0"
133
+ }, r.attr, i, g, {
134
+ className: m,
135
+ style: S(S({
136
+ color: e.color || r.color
137
+ }, r.style), e.style),
138
+ height: u,
139
+ width: u,
140
+ xmlns: "http://www.w3.org/2000/svg"
141
+ }), l && /* @__PURE__ */ f.createElement("title", null, l), e.children);
142
+ };
143
+ return x !== void 0 ? /* @__PURE__ */ f.createElement(x.Consumer, null, (r) => t(r)) : t(G);
144
+ }
145
+ function I(e) {
146
+ return P({ tag: "svg", attr: { viewBox: "0 0 448 512" }, child: [{ tag: "path", attr: { d: "M12 192h424c6.6 0 12 5.4 12 12v260c0 26.5-21.5 48-48 48H48c-26.5 0-48-21.5-48-48V204c0-6.6 5.4-12 12-12zm436-44v-36c0-26.5-21.5-48-48-48h-48V12c0-6.6-5.4-12-12-12h-40c-6.6 0-12 5.4-12 12v52H160V12c0-6.6-5.4-12-12-12h-40c-6.6 0-12 5.4-12 12v52H48C21.5 64 0 85.5 0 112v36c0 6.6 5.4 12 12 12h424c6.6 0 12-5.4 12-12z" }, child: [] }] })(e);
147
+ }
148
+ function se(e) {
149
+ return P({ tag: "svg", attr: { viewBox: "0 0 448 512" }, child: [{ tag: "path", attr: { d: "M207.029 381.476L12.686 187.132c-9.373-9.373-9.373-24.569 0-33.941l22.667-22.667c9.357-9.357 24.522-9.375 33.901-.04L224 284.505l154.745-154.021c9.379-9.335 24.544-9.317 33.901.04l22.667 22.667c9.373 9.373 9.373 24.569 0 33.941L240.971 381.476c-9.373 9.372-24.569 9.372-33.942 0z" }, child: [] }] })(e);
150
+ }
151
+ function re(e) {
152
+ return P({ tag: "svg", attr: { viewBox: "0 0 512 512" }, child: [{ tag: "path", attr: { d: "M256,8C119,8,8,119,8,256S119,504,256,504,504,393,504,256,393,8,256,8Zm92.49,313h0l-20,25a16,16,0,0,1-22.49,2.5h0l-67-49.72a40,40,0,0,1-15-31.23V112a16,16,0,0,1,16-16h32a16,16,0,0,1,16,16V256l58,42.5A16,16,0,0,1,348.49,321Z" }, child: [] }] })(e);
153
+ }
154
+ const ue = ({
155
+ itinerary: e,
156
+ origin: t,
157
+ destination: r,
158
+ onDisableRenderItinerary: i,
159
+ isMultiDayFlight: n
160
+ }) => {
161
+ var u, m, b, y, j, w;
162
+ const l = () => W.ECONOMY, g = U(() => {
163
+ var v, M, C, O, T, D, Y;
164
+ const a = [];
165
+ for (let h = 0; h < e.length; h++) {
166
+ const d = e[h], s = e[h + 1];
167
+ if (!s)
168
+ break;
169
+ const F = {
170
+ arrival: {
171
+ airport: (v = d.destination) == null ? void 0 : v.name,
172
+ city: (C = (M = d.destination) == null ? void 0 : M.city) == null ? void 0 : C.name,
173
+ country: "France",
174
+ //getCountryNameByCode(segment.destination?.iata_country_code),
175
+ time: d.arrivingAt,
176
+ // ?? segment.arrival_datetime,
177
+ arrivalTimeZone: d.destination.timeZone
178
+ },
179
+ departure: {
180
+ airport: (O = s.origin) == null ? void 0 : O.name,
181
+ city: (D = (T = s.origin) == null ? void 0 : T.city) == null ? void 0 : D.name,
182
+ country: "France",
183
+ //getCountryNameByCode(segment.destination?.iata_country_code),
184
+ time: s.departingAt,
185
+ // ?? segment.departure_datetime,
186
+ airline: s.operatingCarrier.name,
187
+ airlineCode: s.operatingCarrier.iataCode,
188
+ aircraft: (Y = s.aircraft) == null ? void 0 : Y.name,
189
+ flightNumber: s.operatingCarrierFlightNumber,
190
+ cabin: s.passengers[0].cabinClassMarketingName ?? l(),
191
+ departureTimeZone: s.origin.timeZone
192
+ },
193
+ layoverTime: E({
194
+ // we need to swap around the departure and arrival times
195
+ departureAt: d.arrivingAt,
196
+ departureTimeZone: d.destination.timeZone,
197
+ arrivalAt: s.departingAt,
198
+ arrivalTimeZone: s.origin.timeZone
199
+ })
200
+ };
201
+ F.layoverTime <= 0 && (i == null || i()), a.push(F);
202
+ }
203
+ return a;
204
+ }, [e]);
205
+ return /* @__PURE__ */ o("div", { className: "flight-itinerary", children: [
206
+ /* @__PURE__ */ c(
207
+ $,
208
+ {
209
+ airport: e[0].origin.name,
210
+ city: t.city,
211
+ country: z(t.country),
212
+ departureAt: e[0].departingAt,
213
+ departureTimeZone: e[0].origin.timeZone,
214
+ arrivalAt: e[0].arrivingAt,
215
+ arrivalTimeZone: e[0].destination.timeZone,
216
+ airline: e[0].operatingCarrier.name,
217
+ airlineCode: e[0].operatingCarrier.iataCode,
218
+ aircraft: (u = e[0].aircraft) == null ? void 0 : u.name,
219
+ flightNumber: e[0].operatingCarrierFlightNumber,
220
+ cabin: e[0].passengers[0].cabinClassMarketingName ?? l(),
221
+ isMultiDayFlight: n
222
+ }
223
+ ),
224
+ g.map((a, v) => {
225
+ var M, C, O, T, D, Y, h, d;
226
+ return /* @__PURE__ */ o(f.Fragment, { children: [
227
+ /* @__PURE__ */ c(
228
+ H,
229
+ {
230
+ airport: a.arrival.airport,
231
+ city: a.arrival.city,
232
+ country: a.arrival.country,
233
+ time: a.arrival.time,
234
+ isLayover: !0,
235
+ layoverTime: B(a.layoverTime),
236
+ arrivalTimeZone: Z(
237
+ a.arrival.arrivalTimeZone,
238
+ a.arrival.time
239
+ )
240
+ }
241
+ ),
242
+ /* @__PURE__ */ c(
243
+ $,
244
+ {
245
+ airport: (M = a.departure) == null ? void 0 : M.airport,
246
+ city: (C = a.departure) == null ? void 0 : C.city,
247
+ country: (O = a.departure) == null ? void 0 : O.country,
248
+ departureAt: a.departure.time,
249
+ departureTimeZone: a.departure.departureTimeZone,
250
+ arrivalAt: e[v + 1].arrivingAt,
251
+ arrivalTimeZone: e[v + 1].destination.timeZone,
252
+ airline: (T = a.departure) == null ? void 0 : T.airline,
253
+ airlineCode: (D = a.departure) == null ? void 0 : D.airlineCode,
254
+ aircraft: (Y = a.departure) == null ? void 0 : Y.aircraft,
255
+ flightNumber: (h = a.departure) == null ? void 0 : h.flightNumber,
256
+ cabin: (d = a.departure) == null ? void 0 : d.cabin
257
+ }
258
+ )
259
+ ] }, a.departure.flightNumber || v);
260
+ }),
261
+ /* @__PURE__ */ c(
262
+ H,
263
+ {
264
+ airport: (b = (m = e.getLast()) == null ? void 0 : m.destination) == null ? void 0 : b.name,
265
+ city: r.city,
266
+ country: z(r.country),
267
+ time: (y = e.getLast()) == null ? void 0 : y.arrivingAt,
268
+ arrivalTimeZone: Z(
269
+ (j = e.getLast()) == null ? void 0 : j.destination.timeZone,
270
+ (w = e.getLast()) == null ? void 0 : w.arrivingAt
271
+ // ?? itinerary.getLast()?.arrival_datetime
272
+ ),
273
+ isMultiDayFlight: n
274
+ }
275
+ )
276
+ ] });
277
+ }, $ = ({
278
+ airport: e,
279
+ city: t,
280
+ country: r,
281
+ airline: i,
282
+ airlineCode: n,
283
+ flightNumber: l,
284
+ aircraft: g,
285
+ cabin: u,
286
+ departureAt: m,
287
+ departureTimeZone: b,
288
+ arrivalAt: y,
289
+ arrivalTimeZone: j,
290
+ isMultiDayFlight: w
291
+ }) => {
292
+ const a = E({
293
+ departureAt: m,
294
+ departureTimeZone: b,
295
+ arrivalAt: y,
296
+ arrivalTimeZone: j
297
+ });
298
+ return /* @__PURE__ */ o("div", { className: "departure", children: [
299
+ /* @__PURE__ */ o("p", { children: [
300
+ p(m).format(N.FlightTime),
301
+ " ",
302
+ /* @__PURE__ */ o("span", { className: "time-zone", children: [
303
+ "(",
304
+ Z(b, m),
305
+ ")"
306
+ ] }),
307
+ /* @__PURE__ */ c("br", {}),
308
+ w ? /* @__PURE__ */ o("div", { className: "travel-time", children: [
309
+ /* @__PURE__ */ c(I, {}),
310
+ /* @__PURE__ */ o("span", { children: [
311
+ " ",
312
+ "Departure:",
313
+ " ",
314
+ p(m).format(N.StringDateFormat)
315
+ ] })
316
+ ] }) : /* @__PURE__ */ c(L, {}),
317
+ /* @__PURE__ */ o("div", { className: "travel-time", children: [
318
+ /* @__PURE__ */ c(re, {}),
319
+ /* @__PURE__ */ o("span", { children: [
320
+ "Travel Time: ",
321
+ B(a)
322
+ ] })
323
+ ] })
324
+ ] }),
325
+ /* @__PURE__ */ o("div", { children: [
326
+ /* @__PURE__ */ o("span", { children: [
327
+ e,
328
+ ", ",
329
+ t,
330
+ ", ",
331
+ r
332
+ ] }),
333
+ /* @__PURE__ */ c("img", { src: `${K}${n}.svg`, alt: i }),
334
+ /* @__PURE__ */ o("p", { children: [
335
+ /* @__PURE__ */ c("strong", { children: "Aircraft:" }),
336
+ " ",
337
+ g
338
+ ] }),
339
+ /* @__PURE__ */ o("p", { children: [
340
+ /* @__PURE__ */ c("strong", { children: "Flight:" }),
341
+ " ",
342
+ n,
343
+ " ",
344
+ l
345
+ ] }),
346
+ /* @__PURE__ */ o("p", { children: [
347
+ /* @__PURE__ */ c("strong", { children: "Cabin:" }),
348
+ " ",
349
+ u
350
+ ] })
351
+ ] })
352
+ ] });
353
+ }, H = ({
354
+ airport: e,
355
+ city: t,
356
+ country: r,
357
+ time: i,
358
+ isLayover: n,
359
+ layoverTime: l,
360
+ arrivalTimeZone: g,
361
+ isMultiDayFlight: u
362
+ }) => /* @__PURE__ */ o("div", { className: `arrival ${n ? "layover" : ""}`, children: [
363
+ /* @__PURE__ */ o("p", { children: [
364
+ p(i).format(N.FlightTime),
365
+ " ",
366
+ /* @__PURE__ */ o("span", { className: "time-zone", children: [
367
+ "(",
368
+ g,
369
+ ")"
370
+ ] }),
371
+ u && !n ? /* @__PURE__ */ o("div", { className: "travel-time", children: [
372
+ /* @__PURE__ */ c(I, {}),
373
+ /* @__PURE__ */ o("span", { children: [
374
+ "Arrival: ",
375
+ p(i).format(N.StringDateFormat)
376
+ ] })
377
+ ] }) : /* @__PURE__ */ c(L, {})
378
+ ] }),
379
+ /* @__PURE__ */ o("div", { children: [
380
+ /* @__PURE__ */ o("p", { children: [
381
+ n ? "Layover in" : "",
382
+ " ",
383
+ e,
384
+ ", ",
385
+ t,
386
+ ", ",
387
+ r
388
+ ] }),
389
+ /* @__PURE__ */ c("i", { children: n ? l : "" })
390
+ ] })
391
+ ] });
392
+ export {
393
+ N as E,
394
+ se as F,
395
+ ue as a
396
+ };