@odynn/awayz-flights 0.1.5 → 0.1.7

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,4 +1,4 @@
1
- import { jsx as e, jsxs as r } from "react/jsx-runtime";
1
+ import { jsx as r, jsxs as e } from "react/jsx-runtime";
2
2
  import b, { useState as C, useMemo as k } from "react";
3
3
  import { g as f, E as u, F as O, a as E } from "../../FlightItinerary-BKwj8UCu.js";
4
4
  import { getFlightNumber as P } from "../../utils/flightUtils.js";
@@ -29,39 +29,39 @@ import '../../assets/FlightResult.css';const M = (i, l) => {
29
29
  });
30
30
  }), { flightNumbers: n, airlines: t };
31
31
  }, [i.flightDetails.slices]);
32
- return /* @__PURE__ */ e("div", { className: "flight-result", onClick: () => l(i), children: /* @__PURE__ */ r("div", { className: "content", children: [
33
- /* @__PURE__ */ e("div", { className: "flight-info", children: /* @__PURE__ */ r("div", { className: "flight-locations", children: [
34
- /* @__PURE__ */ e("div", { className: "airlines", children: S.map((n, t) => /* @__PURE__ */ e(b.Fragment, { children: /* @__PURE__ */ e("div", { className: "tip", children: /* @__PURE__ */ e("img", { src: n.logo, alt: n.airline }) }, t) }, t)) }),
35
- /* @__PURE__ */ r("div", { className: "flight-location", children: [
36
- /* @__PURE__ */ r("p", { children: [
32
+ return /* @__PURE__ */ r("div", { className: "flight-result", onClick: () => l(i), children: /* @__PURE__ */ e("div", { className: "content", children: [
33
+ /* @__PURE__ */ r("div", { className: "flight-info", children: /* @__PURE__ */ e("div", { className: "flight-locations", children: [
34
+ /* @__PURE__ */ r("div", { className: "airlines", children: S.map((n, t) => /* @__PURE__ */ r(b.Fragment, { children: /* @__PURE__ */ r("div", { className: "tip", children: /* @__PURE__ */ r("img", { src: n.logo, alt: n.airline }) }, t) }, t)) }),
35
+ /* @__PURE__ */ e("div", { className: "flight-location", children: [
36
+ /* @__PURE__ */ e("p", { children: [
37
37
  c.city,
38
38
  ",",
39
39
  f(c.country)
40
40
  ] }),
41
- /* @__PURE__ */ e("p", { children: N(i.departureTime).format(
41
+ /* @__PURE__ */ r("p", { children: N(i.departureTime).format(
42
42
  // isMobile
43
43
  // ? EDateFormats.FlightTime
44
44
  // :
45
45
  u.FlightShortDate
46
46
  ) })
47
47
  ] }),
48
- /* @__PURE__ */ r("div", { className: "flight-duration", children: [
49
- /* @__PURE__ */ e("span", { className: "line" }),
50
- /* @__PURE__ */ r("p", { children: [
48
+ /* @__PURE__ */ e("div", { className: "flight-duration", children: [
49
+ /* @__PURE__ */ r("span", { className: "line" }),
50
+ /* @__PURE__ */ e("p", { children: [
51
51
  I(g.slices[0].duration),
52
52
  " ",
53
53
  " - ",
54
54
  i.numberOfStops > 0 ? `${i.numberOfStops} Stop${i.numberOfStops > 1 ? "s" : ""}` : "Direct"
55
55
  ] }),
56
- /* @__PURE__ */ e("span", { className: "line" })
56
+ /* @__PURE__ */ r("span", { className: "line" })
57
57
  ] }),
58
- /* @__PURE__ */ r("div", { children: [
59
- /* @__PURE__ */ r("p", { children: [
58
+ /* @__PURE__ */ e("div", { children: [
59
+ /* @__PURE__ */ e("p", { children: [
60
60
  h.city,
61
61
  ", ",
62
62
  f(h.country)
63
63
  ] }),
64
- /* @__PURE__ */ r("p", { children: [
64
+ /* @__PURE__ */ e("p", { children: [
65
65
  N(i.arrivalTime).format(
66
66
  // isMobile
67
67
  // ? EDateFormats.FlightTime
@@ -72,9 +72,9 @@ import '../../assets/FlightResult.css';const M = (i, l) => {
72
72
  ] })
73
73
  ] })
74
74
  ] }) }),
75
- /* @__PURE__ */ r("div", { className: "flight-footer", children: [
76
- /* @__PURE__ */ r("div", { className: "flight-detail-container", children: [
77
- /* @__PURE__ */ r(
75
+ /* @__PURE__ */ e("div", { className: "flight-footer", children: [
76
+ /* @__PURE__ */ e("div", { className: "flight-detail-container", children: [
77
+ /* @__PURE__ */ e(
78
78
  "div",
79
79
  {
80
80
  className: "flight-detail",
@@ -82,12 +82,12 @@ import '../../assets/FlightResult.css';const M = (i, l) => {
82
82
  n.stopPropagation(), y(!a);
83
83
  },
84
84
  children: [
85
- /* @__PURE__ */ e("p", { children: "Aircraft" }),
86
- /* @__PURE__ */ r("p", { className: "chevron-text", children: [
87
- /* @__PURE__ */ e(O, {}),
88
- /* @__PURE__ */ r("span", { children: [
85
+ /* @__PURE__ */ r("p", { children: "Aircraft" }),
86
+ /* @__PURE__ */ e("p", { className: "chevron-text", children: [
87
+ /* @__PURE__ */ r(O, {}),
88
+ /* @__PURE__ */ e("span", { children: [
89
89
  m[0],
90
- m.length > 1 && /* @__PURE__ */ r("sup", { children: [
90
+ m.length > 1 && /* @__PURE__ */ e("sup", { children: [
91
91
  "+",
92
92
  m.length - 1
93
93
  ] })
@@ -96,18 +96,18 @@ import '../../assets/FlightResult.css';const M = (i, l) => {
96
96
  ]
97
97
  }
98
98
  ),
99
- /* @__PURE__ */ r("div", { className: "flight-detail", children: [
100
- /* @__PURE__ */ e("p", { children: "Class" }),
101
- /* @__PURE__ */ e("p", { children: i.flightDetails.slices[0].fareBrandName })
99
+ /* @__PURE__ */ e("div", { className: "flight-detail", children: [
100
+ /* @__PURE__ */ r("p", { children: "Class" }),
101
+ /* @__PURE__ */ r("p", { children: i.flightDetails.slices[0].fareBrandName })
102
102
  ] }),
103
- /* @__PURE__ */ r("div", { className: "flight-detail", children: [
104
- /* @__PURE__ */ e("p", { children: "Marketing Carrier" }),
105
- /* @__PURE__ */ e("p", { children: i.flightDetails.slices[0].segments[0].marketingCarrier.name })
103
+ /* @__PURE__ */ e("div", { className: "flight-detail", children: [
104
+ /* @__PURE__ */ r("p", { children: "Marketing Carrier" }),
105
+ /* @__PURE__ */ r("p", { children: i.flightDetails.slices[0].segments[0].marketingCarrier.name })
106
106
  ] })
107
107
  ] }),
108
- /* @__PURE__ */ r("div", { className: "booking-options", children: [
108
+ /* @__PURE__ */ e("div", { className: "booking-options", children: [
109
109
  i.cash > 0 && // details.showCashOption &&
110
- /* @__PURE__ */ r(
110
+ /* @__PURE__ */ e(
111
111
  "div",
112
112
  {
113
113
  className: "cash-value",
@@ -115,12 +115,12 @@ import '../../assets/FlightResult.css';const M = (i, l) => {
115
115
  n.stopPropagation(), l(i, v.CASH);
116
116
  },
117
117
  children: [
118
- /* @__PURE__ */ e("p", { children: D ? "Book For" : "From" }),
119
- /* @__PURE__ */ e("p", { children: M(i.cash, "USD") })
118
+ /* @__PURE__ */ r("p", { children: D ? "Book For" : "From" }),
119
+ /* @__PURE__ */ r("p", { children: M(i.cash, "USD") })
120
120
  ]
121
121
  }
122
122
  ),
123
- i.points > 0 && /* @__PURE__ */ e(
123
+ i.points > 0 && /* @__PURE__ */ r(
124
124
  "div",
125
125
  {
126
126
  className: "points-value",
@@ -131,7 +131,7 @@ import '../../assets/FlightResult.css';const M = (i, l) => {
131
131
  )
132
132
  ] })
133
133
  ] }),
134
- /* @__PURE__ */ e("div", { className: `flight-details ${a ? "is-open" : ""}`, children: /* @__PURE__ */ e("div", { className: "inner", children: /* @__PURE__ */ e(
134
+ /* @__PURE__ */ r("div", { className: `flight-details ${a ? "is-open" : ""}`, children: /* @__PURE__ */ r("div", { className: "inner", children: /* @__PURE__ */ r(
135
135
  E,
136
136
  {
137
137
  itinerary: g.slices[0].segments,
@@ -1,681 +1,17 @@
1
- var me = (t) => {
2
- throw TypeError(t);
3
- };
4
- var se = (t, e, s) => e.has(t) || me("Cannot " + s);
5
- var r = (t, e, s) => (se(t, e, "read from private field"), s ? s.call(t) : e.get(t)), p = (t, e, s) => e.has(t) ? me("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, s), u = (t, e, s, n) => (se(t, e, "write to private field"), n ? n.call(t, s) : e.set(t, s), s), b = (t, e, s) => (se(t, e, "access private method"), s);
6
- import * as S from "react";
7
- import "react/jsx-runtime";
8
- import { F as Ue } from "../../FlightsService-BuVR3KQV.js";
9
- var de = class {
10
- constructor() {
11
- this.listeners = /* @__PURE__ */ new Set(), this.subscribe = this.subscribe.bind(this);
12
- }
13
- subscribe(t) {
14
- return this.listeners.add(t), this.onSubscribe(), () => {
15
- this.listeners.delete(t), this.onUnsubscribe();
16
- };
17
- }
18
- hasListeners() {
19
- return this.listeners.size > 0;
20
- }
21
- onSubscribe() {
22
- }
23
- onUnsubscribe() {
24
- }
25
- }, K = typeof window > "u" || "Deno" in globalThis;
26
- function De() {
27
- }
28
- function ve(t) {
29
- return typeof t == "number" && t >= 0 && t !== 1 / 0;
30
- }
31
- function qe(t, e) {
32
- return Math.max(t + (e || 0) - Date.now(), 0);
33
- }
34
- function Z(t, e) {
35
- return typeof t == "function" ? t(e) : t;
36
- }
37
- function F(t, e) {
38
- return typeof t == "function" ? t(e) : t;
39
- }
40
- function re(t, e) {
41
- if (t === e)
42
- return t;
43
- const s = Re(t) && Re(e);
44
- if (s || we(t) && we(e)) {
45
- const n = s ? t : Object.keys(t), a = n.length, c = s ? e : Object.keys(e), i = c.length, o = s ? [] : {};
46
- let f = 0;
47
- for (let g = 0; g < i; g++) {
48
- const y = s ? g : c[g];
49
- (!s && n.includes(y) || s) && t[y] === void 0 && e[y] === void 0 ? (o[y] = void 0, f++) : (o[y] = re(t[y], e[y]), o[y] === t[y] && t[y] !== void 0 && f++);
50
- }
51
- return a === i && f === a ? t : o;
52
- }
53
- return e;
54
- }
55
- function ne(t, e) {
56
- if (!e || Object.keys(t).length !== Object.keys(e).length)
57
- return !1;
58
- for (const s in t)
59
- if (t[s] !== e[s])
60
- return !1;
61
- return !0;
62
- }
63
- function Re(t) {
64
- return Array.isArray(t) && t.length === Object.keys(t).length;
65
- }
66
- function we(t) {
67
- if (!Oe(t))
68
- return !1;
69
- const e = t.constructor;
70
- if (e === void 0)
71
- return !0;
72
- const s = e.prototype;
73
- return !(!Oe(s) || !s.hasOwnProperty("isPrototypeOf") || Object.getPrototypeOf(t) !== Object.prototype);
74
- }
75
- function Oe(t) {
76
- return Object.prototype.toString.call(t) === "[object Object]";
77
- }
78
- function Se(t, e, s) {
79
- if (typeof s.structuralSharing == "function")
80
- return s.structuralSharing(t, e);
81
- if (s.structuralSharing !== !1) {
82
- if (process.env.NODE_ENV !== "production")
83
- try {
84
- return re(t, e);
85
- } catch (n) {
86
- console.error(
87
- `Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${s.queryHash}]: ${n}`
88
- );
89
- }
90
- return re(t, e);
91
- }
92
- return e;
93
- }
94
- var I, x, q, Le, ke = (Le = class extends de {
95
- constructor() {
96
- super();
97
- p(this, I);
98
- p(this, x);
99
- p(this, q);
100
- u(this, q, (e) => {
101
- if (!K && window.addEventListener) {
102
- const s = () => e();
103
- return window.addEventListener("visibilitychange", s, !1), () => {
104
- window.removeEventListener("visibilitychange", s);
105
- };
106
- }
107
- });
108
- }
109
- onSubscribe() {
110
- r(this, x) || this.setEventListener(r(this, q));
111
- }
112
- onUnsubscribe() {
113
- var e;
114
- this.hasListeners() || ((e = r(this, x)) == null || e.call(this), u(this, x, void 0));
115
- }
116
- setEventListener(e) {
117
- var s;
118
- u(this, q, e), (s = r(this, x)) == null || s.call(this), u(this, x, e((n) => {
119
- typeof n == "boolean" ? this.setFocused(n) : this.onFocus();
120
- }));
121
- }
122
- setFocused(e) {
123
- r(this, I) !== e && (u(this, I, e), this.onFocus());
124
- }
125
- onFocus() {
126
- const e = this.isFocused();
127
- this.listeners.forEach((s) => {
128
- s(e);
129
- });
130
- }
131
- isFocused() {
132
- var e;
133
- return typeof r(this, I) == "boolean" ? r(this, I) : ((e = globalThis.document) == null ? void 0 : e.visibilityState) !== "hidden";
134
- }
135
- }, I = new WeakMap(), x = new WeakMap(), q = new WeakMap(), Le), Ne = new ke(), k, Q, N, je, _e = (je = class extends de {
136
- constructor() {
137
- super();
138
- p(this, k, !0);
139
- p(this, Q);
140
- p(this, N);
141
- u(this, N, (e) => {
142
- if (!K && window.addEventListener) {
143
- const s = () => e(!0), n = () => e(!1);
144
- return window.addEventListener("online", s, !1), window.addEventListener("offline", n, !1), () => {
145
- window.removeEventListener("online", s), window.removeEventListener("offline", n);
146
- };
147
- }
148
- });
149
- }
150
- onSubscribe() {
151
- r(this, Q) || this.setEventListener(r(this, N));
152
- }
153
- onUnsubscribe() {
154
- var e;
155
- this.hasListeners() || ((e = r(this, Q)) == null || e.call(this), u(this, Q, void 0));
156
- }
157
- setEventListener(e) {
158
- var s;
159
- u(this, N, e), (s = r(this, Q)) == null || s.call(this), u(this, Q, e(this.setOnline.bind(this)));
160
- }
161
- setOnline(e) {
162
- r(this, k) !== e && (u(this, k, e), this.listeners.forEach((n) => {
163
- n(e);
164
- }));
165
- }
166
- isOnline() {
167
- return r(this, k);
168
- }
169
- }, k = new WeakMap(), Q = new WeakMap(), N = new WeakMap(), je), Ae = new _e();
170
- function Ce() {
171
- let t, e;
172
- const s = new Promise((a, c) => {
173
- t = a, e = c;
174
- });
175
- s.status = "pending", s.catch(() => {
176
- });
177
- function n(a) {
178
- Object.assign(s, a), delete s.resolve, delete s.reject;
179
- }
180
- return s.resolve = (a) => {
181
- n({
182
- status: "fulfilled",
183
- value: a
184
- }), t(a);
185
- }, s.reject = (a) => {
186
- n({
187
- status: "rejected",
188
- reason: a
189
- }), e(a);
190
- }, s;
191
- }
192
- function ze(t) {
193
- return (t ?? "online") === "online" ? Ae.isOnline() : !0;
194
- }
195
- function Be() {
196
- let t = [], e = 0, s = (o) => {
197
- o();
198
- }, n = (o) => {
199
- o();
200
- }, a = (o) => setTimeout(o, 0);
201
- const c = (o) => {
202
- e ? t.push(o) : a(() => {
203
- s(o);
204
- });
205
- }, i = () => {
206
- const o = t;
207
- t = [], o.length && a(() => {
208
- n(() => {
209
- o.forEach((f) => {
210
- s(f);
211
- });
212
- });
213
- });
214
- };
215
- return {
216
- batch: (o) => {
217
- let f;
218
- e++;
219
- try {
220
- f = o();
221
- } finally {
222
- e--, e || i();
223
- }
224
- return f;
225
- },
226
- /**
227
- * All calls to the wrapped function will be batched.
228
- */
229
- batchCalls: (o) => (...f) => {
230
- c(() => {
231
- o(...f);
232
- });
233
- },
234
- schedule: c,
235
- /**
236
- * Use this method to set a custom notify function.
237
- * This can be used to for example wrap notifications with `React.act` while running tests.
238
- */
239
- setNotifyFunction: (o) => {
240
- s = o;
241
- },
242
- /**
243
- * Use this method to set a custom function to batch notifications together into a single tick.
244
- * By default React Query will use the batch function provided by ReactDOM or React Native.
245
- */
246
- setBatchNotifyFunction: (o) => {
247
- n = o;
248
- },
249
- setScheduler: (o) => {
250
- a = o;
251
- }
252
- };
253
- }
254
- var Te = Be();
255
- function He(t, e) {
256
- return {
257
- fetchFailureCount: 0,
258
- fetchFailureReason: null,
259
- fetchStatus: ze(e.networkMode) ? "fetching" : "paused",
260
- ...t === void 0 && {
261
- error: null,
262
- status: "pending"
263
- }
264
- };
265
- }
266
- var w, h, G, R, T, _, L, E, X, A, z, M, P, j, B, l, J, ie, ae, oe, ue, he, ce, le, Me, Ie, Ve = (Ie = class extends de {
267
- constructor(e, s) {
268
- super();
269
- p(this, l);
270
- p(this, w);
271
- p(this, h);
272
- p(this, G);
273
- p(this, R);
274
- p(this, T);
275
- p(this, _);
276
- p(this, L);
277
- p(this, E);
278
- p(this, X);
279
- p(this, A);
280
- // This property keeps track of the last query with defined data.
281
- // It will be used to pass the previous data and query to the placeholder function between renders.
282
- p(this, z);
283
- p(this, M);
284
- p(this, P);
285
- p(this, j);
286
- p(this, B, /* @__PURE__ */ new Set());
287
- this.options = s, u(this, w, e), u(this, E, null), u(this, L, Ce()), this.options.experimental_prefetchInRender || r(this, L).reject(
288
- new Error("experimental_prefetchInRender feature flag is not enabled")
289
- ), this.bindMethods(), this.setOptions(s);
290
- }
291
- bindMethods() {
292
- this.refetch = this.refetch.bind(this);
293
- }
294
- onSubscribe() {
295
- this.listeners.size === 1 && (r(this, h).addObserver(this), Ee(r(this, h), this.options) ? b(this, l, J).call(this) : this.updateResult(), b(this, l, ue).call(this));
296
- }
297
- onUnsubscribe() {
298
- this.hasListeners() || this.destroy();
299
- }
300
- shouldFetchOnReconnect() {
301
- return fe(
302
- r(this, h),
303
- this.options,
304
- this.options.refetchOnReconnect
305
- );
306
- }
307
- shouldFetchOnWindowFocus() {
308
- return fe(
309
- r(this, h),
310
- this.options,
311
- this.options.refetchOnWindowFocus
312
- );
313
- }
314
- destroy() {
315
- this.listeners = /* @__PURE__ */ new Set(), b(this, l, he).call(this), b(this, l, ce).call(this), r(this, h).removeObserver(this);
316
- }
317
- setOptions(e, s) {
318
- const n = this.options, a = r(this, h);
319
- if (this.options = r(this, w).defaultQueryOptions(e), this.options.enabled !== void 0 && typeof this.options.enabled != "boolean" && typeof this.options.enabled != "function" && typeof F(this.options.enabled, r(this, h)) != "boolean")
320
- throw new Error(
321
- "Expected enabled to be a boolean or a callback that returns a boolean"
322
- );
323
- b(this, l, le).call(this), r(this, h).setOptions(this.options), n._defaulted && !ne(this.options, n) && r(this, w).getQueryCache().notify({
324
- type: "observerOptionsUpdated",
325
- query: r(this, h),
326
- observer: this
327
- });
328
- const c = this.hasListeners();
329
- c && Fe(
330
- r(this, h),
331
- a,
332
- this.options,
333
- n
334
- ) && b(this, l, J).call(this), this.updateResult(s), c && (r(this, h) !== a || F(this.options.enabled, r(this, h)) !== F(n.enabled, r(this, h)) || Z(this.options.staleTime, r(this, h)) !== Z(n.staleTime, r(this, h))) && b(this, l, ie).call(this);
335
- const i = b(this, l, ae).call(this);
336
- c && (r(this, h) !== a || F(this.options.enabled, r(this, h)) !== F(n.enabled, r(this, h)) || i !== r(this, j)) && b(this, l, oe).call(this, i);
337
- }
338
- getOptimisticResult(e) {
339
- const s = r(this, w).getQueryCache().build(r(this, w), e), n = this.createResult(s, e);
340
- return We(this, n) && (u(this, R, n), u(this, _, this.options), u(this, T, r(this, h).state)), n;
341
- }
342
- getCurrentResult() {
343
- return r(this, R);
344
- }
345
- trackResult(e, s) {
346
- const n = {};
347
- return Object.keys(e).forEach((a) => {
348
- Object.defineProperty(n, a, {
349
- configurable: !1,
350
- enumerable: !0,
351
- get: () => (this.trackProp(a), s == null || s(a), e[a])
352
- });
353
- }), n;
354
- }
355
- trackProp(e) {
356
- r(this, B).add(e);
357
- }
358
- getCurrentQuery() {
359
- return r(this, h);
360
- }
361
- refetch({ ...e } = {}) {
362
- return this.fetch({
363
- ...e
364
- });
365
- }
366
- fetchOptimistic(e) {
367
- const s = r(this, w).defaultQueryOptions(e), n = r(this, w).getQueryCache().build(r(this, w), s);
368
- return n.fetch().then(() => this.createResult(n, s));
369
- }
370
- fetch(e) {
371
- return b(this, l, J).call(this, {
372
- ...e,
373
- cancelRefetch: e.cancelRefetch ?? !0
374
- }).then(() => (this.updateResult(), r(this, R)));
375
- }
376
- createResult(e, s) {
377
- var ge;
378
- const n = r(this, h), a = this.options, c = r(this, R), i = r(this, T), o = r(this, _), g = e !== n ? e.state : r(this, G), { state: y } = e;
379
- let d = { ...y }, H = !1, m;
380
- if (s._optimisticResults) {
381
- const v = this.hasListeners(), U = !v && Ee(e, s), D = v && Fe(e, n, s, a);
382
- (U || D) && (d = {
383
- ...d,
384
- ...He(y.data, e.options)
385
- }), s._optimisticResults === "isRestoring" && (d.fetchStatus = "idle");
386
- }
387
- let { error: V, errorUpdatedAt: $, status: O } = d;
388
- if (s.select && d.data !== void 0)
389
- if (c && d.data === (i == null ? void 0 : i.data) && s.select === r(this, X))
390
- m = r(this, A);
391
- else
392
- try {
393
- u(this, X, s.select), m = s.select(d.data), m = Se(c == null ? void 0 : c.data, m, s), u(this, A, m), u(this, E, null);
394
- } catch (v) {
395
- u(this, E, v);
396
- }
397
- else
398
- m = d.data;
399
- if (s.placeholderData !== void 0 && m === void 0 && O === "pending") {
400
- let v;
401
- if (c != null && c.isPlaceholderData && s.placeholderData === (o == null ? void 0 : o.placeholderData))
402
- v = c.data;
403
- else if (v = typeof s.placeholderData == "function" ? s.placeholderData(
404
- (ge = r(this, z)) == null ? void 0 : ge.state.data,
405
- r(this, z)
406
- ) : s.placeholderData, s.select && v !== void 0)
407
- try {
408
- v = s.select(v), u(this, E, null);
409
- } catch (U) {
410
- u(this, E, U);
411
- }
412
- v !== void 0 && (O = "success", m = Se(
413
- c == null ? void 0 : c.data,
414
- v,
415
- s
416
- ), H = !0);
417
- }
418
- r(this, E) && (V = r(this, E), m = r(this, A), $ = Date.now(), O = "error");
419
- const W = d.fetchStatus === "fetching", ee = O === "pending", te = O === "error", ye = ee && W, be = m !== void 0, C = {
420
- status: O,
421
- fetchStatus: d.fetchStatus,
422
- isPending: ee,
423
- isSuccess: O === "success",
424
- isError: te,
425
- isInitialLoading: ye,
426
- isLoading: ye,
427
- data: m,
428
- dataUpdatedAt: d.dataUpdatedAt,
429
- error: V,
430
- errorUpdatedAt: $,
431
- failureCount: d.fetchFailureCount,
432
- failureReason: d.fetchFailureReason,
433
- errorUpdateCount: d.errorUpdateCount,
434
- isFetched: d.dataUpdateCount > 0 || d.errorUpdateCount > 0,
435
- isFetchedAfterMount: d.dataUpdateCount > g.dataUpdateCount || d.errorUpdateCount > g.errorUpdateCount,
436
- isFetching: W,
437
- isRefetching: W && !ee,
438
- isLoadingError: te && !be,
439
- isPaused: d.fetchStatus === "paused",
440
- isPlaceholderData: H,
441
- isRefetchError: te && be,
442
- isStale: pe(e, s),
443
- refetch: this.refetch,
444
- promise: r(this, L)
445
- };
446
- if (this.options.experimental_prefetchInRender) {
447
- const v = (Y) => {
448
- C.status === "error" ? Y.reject(C.error) : C.data !== void 0 && Y.resolve(C.data);
449
- }, U = () => {
450
- const Y = u(this, L, C.promise = Ce());
451
- v(Y);
452
- }, D = r(this, L);
453
- switch (D.status) {
454
- case "pending":
455
- e.queryHash === n.queryHash && v(D);
456
- break;
457
- case "fulfilled":
458
- (C.status === "error" || C.data !== D.value) && U();
459
- break;
460
- case "rejected":
461
- (C.status !== "error" || C.error !== D.reason) && U();
462
- break;
463
- }
464
- }
465
- return C;
466
- }
467
- updateResult(e) {
468
- const s = r(this, R), n = this.createResult(r(this, h), this.options);
469
- if (u(this, T, r(this, h).state), u(this, _, this.options), r(this, T).data !== void 0 && u(this, z, r(this, h)), ne(n, s))
470
- return;
471
- u(this, R, n);
472
- const a = {}, c = () => {
473
- if (!s)
474
- return !0;
475
- const { notifyOnChangeProps: i } = this.options, o = typeof i == "function" ? i() : i;
476
- if (o === "all" || !o && !r(this, B).size)
477
- return !0;
478
- const f = new Set(
479
- o ?? r(this, B)
480
- );
481
- return this.options.throwOnError && f.add("error"), Object.keys(r(this, R)).some((g) => {
482
- const y = g;
483
- return r(this, R)[y] !== s[y] && f.has(y);
484
- });
485
- };
486
- (e == null ? void 0 : e.listeners) !== !1 && c() && (a.listeners = !0), b(this, l, Me).call(this, { ...a, ...e });
487
- }
488
- onQueryUpdate() {
489
- this.updateResult(), this.hasListeners() && b(this, l, ue).call(this);
490
- }
491
- }, w = new WeakMap(), h = new WeakMap(), G = new WeakMap(), R = new WeakMap(), T = new WeakMap(), _ = new WeakMap(), L = new WeakMap(), E = new WeakMap(), X = new WeakMap(), A = new WeakMap(), z = new WeakMap(), M = new WeakMap(), P = new WeakMap(), j = new WeakMap(), B = new WeakMap(), l = new WeakSet(), J = function(e) {
492
- b(this, l, le).call(this);
493
- let s = r(this, h).fetch(
494
- this.options,
495
- e
496
- );
497
- return e != null && e.throwOnError || (s = s.catch(De)), s;
498
- }, ie = function() {
499
- b(this, l, he).call(this);
500
- const e = Z(
501
- this.options.staleTime,
502
- r(this, h)
503
- );
504
- if (K || r(this, R).isStale || !ve(e))
505
- return;
506
- const n = qe(r(this, R).dataUpdatedAt, e) + 1;
507
- u(this, M, setTimeout(() => {
508
- r(this, R).isStale || this.updateResult();
509
- }, n));
510
- }, ae = function() {
511
- return (typeof this.options.refetchInterval == "function" ? this.options.refetchInterval(r(this, h)) : this.options.refetchInterval) ?? !1;
512
- }, oe = function(e) {
513
- b(this, l, ce).call(this), u(this, j, e), !(K || F(this.options.enabled, r(this, h)) === !1 || !ve(r(this, j)) || r(this, j) === 0) && u(this, P, setInterval(() => {
514
- (this.options.refetchIntervalInBackground || Ne.isFocused()) && b(this, l, J).call(this);
515
- }, r(this, j)));
516
- }, ue = function() {
517
- b(this, l, ie).call(this), b(this, l, oe).call(this, b(this, l, ae).call(this));
518
- }, he = function() {
519
- r(this, M) && (clearTimeout(r(this, M)), u(this, M, void 0));
520
- }, ce = function() {
521
- r(this, P) && (clearInterval(r(this, P)), u(this, P, void 0));
522
- }, le = function() {
523
- const e = r(this, w).getQueryCache().build(r(this, w), this.options);
524
- if (e === r(this, h))
525
- return;
526
- const s = r(this, h);
527
- u(this, h, e), u(this, G, e.state), this.hasListeners() && (s == null || s.removeObserver(this), e.addObserver(this));
528
- }, Me = function(e) {
529
- Te.batch(() => {
530
- e.listeners && this.listeners.forEach((s) => {
531
- s(r(this, R));
532
- }), r(this, w).getQueryCache().notify({
533
- query: r(this, h),
534
- type: "observerResultsUpdated"
535
- });
536
- });
537
- }, Ie);
538
- function $e(t, e) {
539
- return F(e.enabled, t) !== !1 && t.state.data === void 0 && !(t.state.status === "error" && e.retryOnMount === !1);
540
- }
541
- function Ee(t, e) {
542
- return $e(t, e) || t.state.data !== void 0 && fe(t, e, e.refetchOnMount);
543
- }
544
- function fe(t, e, s) {
545
- if (F(e.enabled, t) !== !1) {
546
- const n = typeof s == "function" ? s(t) : s;
547
- return n === "always" || n !== !1 && pe(t, e);
548
- }
549
- return !1;
550
- }
551
- function Fe(t, e, s, n) {
552
- return (t !== e || F(n.enabled, t) === !1) && (!s.suspense || t.state.status !== "error") && pe(t, s);
553
- }
554
- function pe(t, e) {
555
- return F(e.enabled, t) !== !1 && t.isStaleByTime(Z(e.staleTime, t));
556
- }
557
- function We(t, e) {
558
- return !ne(t.getCurrentResult(), e);
559
- }
560
- var Je = S.createContext(
561
- void 0
562
- ), Ke = (t) => {
563
- const e = S.useContext(Je);
564
- if (!e)
565
- throw new Error("No QueryClient set, use QueryClientProvider to set one");
566
- return e;
567
- }, Pe = S.createContext(!1), Ge = () => S.useContext(Pe);
568
- Pe.Provider;
569
- function Xe() {
570
- let t = !1;
571
- return {
572
- clearReset: () => {
573
- t = !1;
574
- },
575
- reset: () => {
576
- t = !0;
577
- },
578
- isReset: () => t
579
- };
580
- }
581
- var Ye = S.createContext(Xe()), Ze = () => S.useContext(Ye);
582
- function et(t, e) {
583
- return typeof t == "function" ? t(...e) : !!t;
584
- }
585
- function xe() {
586
- }
587
- var tt = (t, e) => {
588
- (t.suspense || t.throwOnError || t.experimental_prefetchInRender) && (e.isReset() || (t.retryOnMount = !1));
589
- }, st = (t) => {
590
- S.useEffect(() => {
591
- t.clearReset();
592
- }, [t]);
593
- }, rt = ({
594
- result: t,
595
- errorResetBoundary: e,
596
- throwOnError: s,
597
- query: n,
598
- suspense: a
599
- }) => t.isError && !e.isReset() && !t.isFetching && n && (a && t.data === void 0 || et(s, [t.error, n])), nt = (t) => {
600
- const e = t.staleTime;
601
- t.suspense && (t.staleTime = typeof e == "function" ? (...s) => Math.max(e(...s), 1e3) : Math.max(e ?? 1e3, 1e3), typeof t.gcTime == "number" && (t.gcTime = Math.max(t.gcTime, 1e3)));
602
- }, it = (t, e) => t.isLoading && t.isFetching && !e, at = (t, e) => (t == null ? void 0 : t.suspense) && e.isPending, Qe = (t, e, s) => e.fetchOptimistic(t).catch(() => {
603
- s.clearReset();
604
- });
605
- function ot(t, e, s) {
606
- var d, H, m, V, $;
607
- if (process.env.NODE_ENV !== "production" && (typeof t != "object" || Array.isArray(t)))
608
- throw new Error(
609
- 'Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object'
610
- );
611
- const n = Ke(), a = Ge(), c = Ze(), i = n.defaultQueryOptions(t);
612
- (H = (d = n.getDefaultOptions().queries) == null ? void 0 : d._experimental_beforeQuery) == null || H.call(
613
- d,
614
- i
615
- ), process.env.NODE_ENV !== "production" && (i.queryFn || console.error(
616
- `[${i.queryHash}]: No queryFn was passed as an option, and no default queryFn was found. The queryFn parameter is only optional when using a default queryFn. More info here: https://tanstack.com/query/latest/docs/framework/react/guides/default-query-function`
617
- )), i._optimisticResults = a ? "isRestoring" : "optimistic", nt(i), tt(i, c), st(c);
618
- const o = !n.getQueryCache().get(i.queryHash), [f] = S.useState(
619
- () => new e(
620
- n,
621
- i
622
- )
623
- ), g = f.getOptimisticResult(i), y = !a && t.subscribed !== !1;
624
- if (S.useSyncExternalStore(
625
- S.useCallback(
626
- (O) => {
627
- const W = y ? f.subscribe(Te.batchCalls(O)) : xe;
628
- return f.updateResult(), W;
629
- },
630
- [f, y]
631
- ),
632
- () => f.getCurrentResult(),
633
- () => f.getCurrentResult()
634
- ), S.useEffect(() => {
635
- f.setOptions(i, { listeners: !1 });
636
- }, [i, f]), at(i, g))
637
- throw Qe(i, f, c);
638
- if (rt({
639
- result: g,
640
- errorResetBoundary: c,
641
- throwOnError: i.throwOnError,
642
- query: n.getQueryCache().get(i.queryHash),
643
- suspense: i.suspense
644
- }))
645
- throw g.error;
646
- if ((V = (m = n.getDefaultOptions().queries) == null ? void 0 : m._experimental_afterQuery) == null || V.call(
647
- m,
648
- i,
649
- g
650
- ), i.experimental_prefetchInRender && !K && it(g, a)) {
651
- const O = o ? (
652
- // Fetch immediately on render in order to ensure `.promise` is resolved even if the component is unmounted
653
- Qe(i, f, c)
654
- ) : (
655
- // subscribe to the "cache promise" so that we can finalize the currentThenable once data comes in
656
- ($ = n.getQueryCache().get(i.queryHash)) == null ? void 0 : $.promise
657
- );
658
- O == null || O.catch(xe).finally(() => {
659
- f.updateResult();
660
- });
661
- }
662
- return i.notifyOnChangeProps ? g : f.trackResult(g);
663
- }
664
- function ut(t, e) {
665
- return ot(t, Ve);
666
- }
667
- const dt = (t) => {
668
- const { data: e, isLoading: s, error: n } = ut({
669
- queryKey: ["airports", t],
670
- queryFn: () => Ue.getAirports(t),
671
- enabled: !!t && t.length > 2
1
+ import { useQuery as t } from "@tanstack/react-query";
2
+ import { F as a } from "../../FlightsService-BuVR3KQV.js";
3
+ const n = (r) => {
4
+ const { data: o, isLoading: e, error: i } = t({
5
+ queryKey: ["airports", r],
6
+ queryFn: () => a.getAirports(r),
7
+ enabled: !!r && r.length > 2
672
8
  });
673
9
  return {
674
- airports: e ?? [],
675
- loading: s,
676
- error: n
10
+ airports: o ?? [],
11
+ loading: e,
12
+ error: i
677
13
  };
678
14
  };
679
15
  export {
680
- dt as useAirportSearch
16
+ n as useAirportSearch
681
17
  };
@@ -4,7 +4,7 @@
4
4
  * @param {string} searchInput - The user-provided query.
5
5
  */
6
6
  export declare const useAirportSearch: (searchInput: string) => {
7
- airports: import('../../services/flights/FlightsService.types').IAirportResponse[];
7
+ airports: import('./useAirportSearch.types').IAirport[];
8
8
  loading: boolean;
9
9
  error: Error | null;
10
10
  };
@@ -1,8 +1,9 @@
1
1
  import { TServiceResponse } from '@type-op/shared';
2
- import { IAirportResponse, IOneWayCashOnlyFlightSearchArgs, IRoundCashOnlyFlightSearchArgs } from './FlightsService.types';
2
+ import { IOneWayCashOnlyFlightSearchArgs, IRoundCashOnlyFlightSearchArgs } from './FlightsService.types';
3
3
  import { IFlightOffer } from '../../hooks/useFlightSearch/useFlightSearch.types';
4
+ import { IAirport } from '../../hooks/useAirportSearch/useAirportSearch.types';
4
5
  declare class _FlightService {
5
- getAirports: (searchTerm: string) => Promise<IAirportResponse[]>;
6
+ getAirports: (searchTerm: string) => Promise<IAirport[]>;
6
7
  cashOnlySearch: (args: IOneWayCashOnlyFlightSearchArgs) => Promise<TServiceResponse<IFlightOffer[]>>;
7
8
  roundTripOutboundSearch: (args: IRoundCashOnlyFlightSearchArgs) => Promise<any>;
8
9
  roundTripInboundSearch: (args: any) => Promise<any>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@odynn/awayz-flights",
3
- "version": "0.1.5",
3
+ "version": "0.1.7",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"