@travelswitchhq/flight-search-react 1.0.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.
package/dist/index.mjs ADDED
@@ -0,0 +1,2255 @@
1
+ // src/Flight.tsx
2
+ import { useState, useRef, useEffect, useMemo, useCallback } from "react";
3
+ import { Calendar } from "primereact/calendar";
4
+ import { Accordion, AccordionTab } from "primereact/accordion";
5
+ import { AutoComplete } from "primereact/autocomplete";
6
+ import { PrimeReactProvider } from "primereact/api";
7
+ import { JSEncrypt } from "jsencrypt";
8
+
9
+ // src/flight-search-widget.styles.ts
10
+ var flightSearchWidgetStyles = `
11
+ :root {
12
+ --font-family: Montserrat, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
13
+ --ar-font-family: Arial, sans-serif;
14
+ --label-color: #66797F;
15
+ --body-text: #0B1215;
16
+ --btn-radius: 8px;
17
+ --radius: 12px;
18
+ --primary-btn: #2C0A82;
19
+ --primary-button-text: #ffffff;
20
+ --button-primary-border: #2C0A82;
21
+ --form-border: #d8dcde;
22
+ --white: #ffffff;
23
+ --gray: #999;
24
+ --widget-bg: #f5f5f8;
25
+ --widget-font-size: 1.4rem;
26
+ --widget-z-index-base: 1000;
27
+ --widget-transition: all 0.2s ease;
28
+ --widget-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
29
+ --widget-shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.15);
30
+ --grid-gap-sm: 2px;
31
+ --grid-gap-md: 10px;
32
+ --grid-gap-lg: 20px;
33
+ --flex-gap-sm: 5px;
34
+ --flex-gap-md: 15px;
35
+ --flex-gap-lg: 20px;
36
+ }
37
+ .sw-container {
38
+ contain: layout;
39
+ position: relative;
40
+ display: block;
41
+ width: 100%;
42
+ min-width: 1240px;
43
+ margin: 0;
44
+ padding: 0;
45
+ box-sizing: border-box;
46
+ color: var(--body-text);
47
+ font-family: var(--font-family);
48
+ font-size: var(--widget-font-size);
49
+ font-weight: 400;
50
+ line-height: 1.5;
51
+ -webkit-font-smoothing: antialiased;
52
+ -moz-osx-font-smoothing: grayscale;
53
+ -webkit-tap-highlight-color: transparent;
54
+ background: var(--widget-bg);
55
+ *,
56
+ *::before,
57
+ *::after {
58
+ box-sizing: border-box;
59
+ }
60
+ }
61
+ .sw-container button,
62
+ .sw-container input {
63
+ font-family: var(--font-family);
64
+ }
65
+ .sw-container h1,
66
+ .sw-container h2,
67
+ .sw-container h3,
68
+ .sw-container h4,
69
+ .sw-container h5,
70
+ .sw-container h6,
71
+ .sw-container p {
72
+ display: block;
73
+ margin: 0;
74
+ color: inherit;
75
+ font-family: var(--font-family);
76
+ font-weight: normal;
77
+ line-height: 1.4;
78
+ }
79
+ .sw-container h1 {
80
+ font-size: 22px;
81
+ }
82
+ .sw-container h2 {
83
+ font-size: 20px;
84
+ }
85
+ .sw-container h3 {
86
+ font-size: 18px;
87
+ }
88
+ .sw-container h4 {
89
+ font-size: 16px;
90
+ }
91
+ .sw-container h5 {
92
+ font-size: 14px;
93
+ }
94
+ .sw-container h6,
95
+ .sw-container small {
96
+ font-size: 12px;
97
+ }
98
+ .sw-container .sw-fw500 {
99
+ font-weight: 500 !important;
100
+ }
101
+ .sw-container .sw-flex {
102
+ display: flex;
103
+ }
104
+ .sw-container .sw-align-center {
105
+ display: flex;
106
+ align-items: center;
107
+ }
108
+ .sw-container .sw-gap-5 {
109
+ gap: 5px;
110
+ }
111
+ .sw-container .sw-gap-15 {
112
+ gap: 15px;
113
+ }
114
+ .sw-container .sw-justify-between {
115
+ justify-content: space-between;
116
+ }
117
+ .sw-container .enFont{
118
+ font-family: var(--ar-font-family);
119
+ }
120
+ .sw-container .sw-text-ellipsis {
121
+ display: -webkit-box;
122
+ overflow: hidden;
123
+ -webkit-box-orient: vertical;
124
+ text-overflow: ellipsis;
125
+ }
126
+ .sw-container .sw-text-label {
127
+ color: var(--label-color);
128
+ }
129
+ .sw-booking-form {
130
+ position: relative;
131
+ display: grid;
132
+ grid-template-columns: 1fr repeat(4, minmax(0, 1fr)) minmax(80px, 0.8fr);
133
+ gap: var(--grid-gap-sm);
134
+ min-height: 55px;
135
+ min-width: 0;
136
+ border-radius: var(--radius);
137
+ overflow: visible;
138
+ }
139
+ .sw-card-box {
140
+ position: relative;
141
+ display: block;
142
+ padding: 20px;
143
+ background-color: var(--white);
144
+ border-radius: var(--radius);
145
+ }
146
+ body[dir="ltr"] .sw-card-box .br-right,
147
+ body[dir="rtl"] .sw-card-box .br-left{
148
+ border-top-right-radius: var(--radius);
149
+ border-bottom-right-radius: var(--radius);
150
+ }
151
+ body[dir="rtl"] .sw-card-box .br-right,
152
+ body[dir="ltr"] .sw-card-box .br-left{
153
+ border-top-left-radius: var(--radius);
154
+ border-bottom-left-radius: var(--radius);
155
+ }
156
+ .sw-form-field {
157
+ display: flex;
158
+ flex-direction: column;
159
+ flex: 1 1 auto;
160
+ gap: 3px;
161
+ padding: 10px 15px;
162
+ background-color: #f8f8f8;
163
+ min-width: 0;
164
+ overflow: visible;
165
+ }
166
+ .sw-form-field .p-calendar {
167
+ position: unset;
168
+ }
169
+ .sw-form-field label {
170
+ display: block;
171
+ width: 100%;
172
+ margin: 0;
173
+ padding: 0;
174
+ overflow: hidden;
175
+ white-space: nowrap;
176
+ color: var(--label-color);
177
+ font-size: 12px;
178
+ font-weight: 500;
179
+ -webkit-box-orient: vertical;
180
+ text-overflow: ellipsis;
181
+ }
182
+ .p-button-label {
183
+ flex: unset;
184
+ }
185
+ .sw-form-field input,
186
+ .sw-form-field .p-inputtext {
187
+ display: block;
188
+ width: 100%;
189
+ margin: 0;
190
+ padding: 0;
191
+ border: 0;
192
+ border-radius: 0;
193
+ outline: none;
194
+ background: transparent;
195
+ box-shadow: none;
196
+ color: var(--body-text);
197
+ font-size: 14px;
198
+ font-weight: 500;
199
+ }
200
+ .sw-form-field input::placeholder,
201
+ .sw-form-field .p-inputtext::placeholder {
202
+ color: var(--label-color) !important;
203
+ }
204
+ .sw-form-swap {
205
+ position: absolute;
206
+ top: 50%;
207
+ left: 50%;
208
+ z-index: 2;
209
+ display: flex;
210
+ align-items: center;
211
+ justify-content: center;
212
+ padding: 3px;
213
+ border: 1px solid var(--form-border);
214
+ border-radius: 50%;
215
+ background-color: #fff;
216
+ cursor: pointer;
217
+ transform: translate(-50%, -50%);
218
+ }
219
+ .sw-srh-wrap.sw-srh-box.sw-pos-rel .sw-form-field.sw-pos-rel:last-child {
220
+ padding-inline-start: 25px;
221
+ }
222
+ .sw-custom-dropdown {
223
+ display: block;
224
+ width: 100%;
225
+ }
226
+ .sw-custom-dropdown-trigger {
227
+ display: flex;
228
+ align-items: center;
229
+ justify-content: space-between;
230
+ flex: 1 1 auto;
231
+ width: 100%;
232
+ min-width: 0;
233
+ margin: 0;
234
+ padding: 0;
235
+ border: 0;
236
+ outline: none;
237
+ background: transparent;
238
+ cursor: pointer;
239
+ color: var(--body-text);
240
+ font-size: 14px;
241
+ font-weight: 500;
242
+ }
243
+ .sw-custom-dropdown-trigger .sw-placeholder {
244
+ color: var(--label-color);
245
+ }
246
+ .sw-dropdown-arrow {
247
+ margin-left: 8px;
248
+ color: var(--label-color);
249
+ font-size: 10px;
250
+ transition: transform 0.2s ease;
251
+ }
252
+ .sw-dropdown{
253
+ position: absolute;
254
+ top: calc(100% + 5px);
255
+ left: 0;
256
+ right: 0;
257
+ z-index: calc(var(--widget-z-index-base) + 5);
258
+ display: block;
259
+ visibility: visible;
260
+ opacity: 1;
261
+ }
262
+ .sw-dropdown,
263
+ .p-autocomplete-panel {
264
+ width: 380px;
265
+ max-height: 310px;
266
+ margin: 0;
267
+ padding: 0;
268
+ overflow: auto;
269
+ overflow-x: hidden;
270
+ background: var(--white);
271
+ border: 1px solid var(--form-border);
272
+ border-radius: var(--radius);
273
+ box-shadow: var(--widget-shadow);
274
+ }
275
+ .sw-dropdown::-webkit-scrollbar {
276
+ display: none;
277
+ }
278
+ .sw-dropdown-list-card,
279
+ .sw-dropdown-list-box,
280
+ .p-autocomplete-item {
281
+ display: flex;
282
+ align-items: center;
283
+ gap: 15px;
284
+ margin: 0 20px;
285
+ padding: 10px 0;
286
+ cursor: pointer;
287
+ font-family: var(--font-family);
288
+ }
289
+ .p-autocomplete-item{
290
+ font-size: 14px;
291
+ font-weight: 400;
292
+ }
293
+ .p-autocomplete-item:hover{
294
+ background-color: var(--primary-light);
295
+ }
296
+ .sw-dropdown-list-box {
297
+ display: flex;
298
+ justify-content: space-between;
299
+ }
300
+ .sw-dropdown-list-card {
301
+ display: grid;
302
+ grid-template-columns: 45px auto;
303
+ }
304
+ .sw-dropdown-item-badge {
305
+ display: grid;
306
+ place-items: center;
307
+ width: fit-content;
308
+ height: unset;
309
+ margin: 0;
310
+ padding: 4px 8px;
311
+ background-color: #f4f5f5;
312
+ border-radius: 4px;
313
+ font-weight: 500;
314
+ }
315
+ .sw-dropdown-list {
316
+ display: block;
317
+ margin: 0;
318
+ padding: 0;
319
+ list-style: none;
320
+ }
321
+ .sw-dropdown-list-item {
322
+ display: block;
323
+ margin: 0;
324
+ padding: 0;
325
+ cursor: pointer;
326
+ color: var(--body-text);
327
+ font-size: 14px;
328
+ transition: background-color 0.2s ease;
329
+ }
330
+ .sw-current {
331
+ font-weight: 500;
332
+ }
333
+ .sw-en-font {
334
+ font-family: Arial, sans-serif;
335
+ }
336
+ .sw-bg-color-loc {
337
+ color: var(--primary);
338
+ }
339
+ .sw-scale-rotate {
340
+ transition: transform 0.2s ease;
341
+ }
342
+ .sw-custom-dropdown-item:hover {
343
+ background-color: var(--secondary-light);
344
+ }
345
+ .sw-custom-dropdown-item:first-child {
346
+ border-top-left-radius: var(--btn-radius);
347
+ border-top-right-radius: var(--btn-radius);
348
+ }
349
+ .sw-custom-dropdown-item:last-child {
350
+ border-bottom-left-radius: var(--btn-radius);
351
+ border-bottom-right-radius: var(--btn-radius);
352
+ }
353
+ .sw-rooms-guests-menu {
354
+ position: absolute;
355
+ top: 100%;
356
+ right: 0;
357
+ z-index: var(--widget-z-index-base);
358
+ display: block;
359
+ width: 75%;
360
+ margin-top: 4px;
361
+ padding: 20px;
362
+ background: var(--white);
363
+ border: 1px solid var(--form-border);
364
+ border-radius: var(--radius);
365
+ box-shadow: var(--widget-shadow);
366
+ }
367
+ .sw-pos-rel {
368
+ position: relative;
369
+ }
370
+ .sw-rooms-guests-title {
371
+ margin: 0 0 15px 0 !important;
372
+ font-size: 16px !important;
373
+ font-weight: 500 !important;
374
+ }
375
+ .sw-room-section {
376
+ display: grid;
377
+ grid-template-columns: 1.2fr 3fr 4fr 50px;
378
+ align-items: center;
379
+ padding: 10px 0;
380
+ }
381
+ .sw-pb0 {
382
+ padding-bottom: 0;
383
+ }
384
+ .sw-room-section:last-of-type {
385
+ margin-bottom: 15px;
386
+ }
387
+ .sw-room-header {
388
+ display: flex;
389
+ align-items: center;
390
+ gap: 5px;
391
+ color: var(--primary);
392
+ font-size: 14px;
393
+ font-weight: 500;
394
+ }
395
+ .sw-room-controls-child {
396
+ display: grid;
397
+ grid-template-columns: repeat(4, minmax(0, 1fr));
398
+ gap: var(--grid-gap-lg);
399
+ min-width: 0;
400
+ }
401
+ .sw-room-controls-child .p-dropdown {
402
+ padding: 10px;
403
+ border: 1px solid var(--form-border);
404
+ border-radius: var(--radius);
405
+ }
406
+ .sw-room-controls-child .p-dropdown-item {
407
+ padding: 10px;
408
+ font-size: 14px;
409
+ }
410
+ .sw-room-controls-child .p-dropdown-panel {
411
+ background: var(--white);
412
+ border: 1px solid var(--form-border);
413
+ border-radius: var(--btn-radius);
414
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
415
+ }
416
+ .sw-room-controls-group {
417
+ display: grid;
418
+ grid-template-columns: repeat(2, minmax(0, 1fr));
419
+ justify-content: center;
420
+ gap: var(--grid-gap-md);
421
+ min-width: 0;
422
+ }
423
+ .sw-room-control-item {
424
+ display: flex;
425
+ flex-direction: column;
426
+ flex: 1 1 auto;
427
+ justify-content: space-between;
428
+ gap: var(--flex-gap-sm);
429
+ min-width: 0;
430
+ }
431
+ .sw-room-control-label {
432
+ color: var(--body-text);
433
+ font-size: 14px;
434
+ font-weight: 400;
435
+ }
436
+ .sw-room-control-buttons {
437
+ display: grid;
438
+ grid-template-columns: 36px 40px 36px;
439
+ align-items: center;
440
+ overflow: hidden;
441
+ }
442
+ .sw-count-button {
443
+ display: flex;
444
+ align-items: center;
445
+ justify-content: center;
446
+ width: 36px;
447
+ height: 36px;
448
+ margin: 0;
449
+ padding: 0;
450
+ border: none;
451
+ border-radius: 50%;
452
+ background: var(--primary);
453
+ cursor: pointer;
454
+ color: var(--white);
455
+ font-size: 20px;
456
+ font-weight: 500;
457
+ transition: var(--widget-transition);
458
+ }
459
+ .sw-count-button:focus-visible {
460
+ outline: 2px solid var(--primary);
461
+ outline-offset: 2px;
462
+ }
463
+ .sw-count-button:hover:not(:disabled) {
464
+ background: var(--primary-btn);
465
+ opacity: 0.9;
466
+ transform: scale(1.05);
467
+ }
468
+ .sw-count-button.sw-disabled {
469
+ opacity: 0.6;
470
+ cursor: not-allowed;
471
+ }
472
+ .sw-count-button:disabled {
473
+ cursor: not-allowed;
474
+ }
475
+ .sw-count-value {
476
+ min-width: 30px;
477
+ text-align: center;
478
+ color: var(--body-text);
479
+ font-size: 16px;
480
+ font-weight: 500;
481
+ }
482
+ .sw-add-room-button {
483
+ display: flex;
484
+ align-items: center;
485
+ gap: 8px;
486
+ width: auto;
487
+ height: 40px;
488
+ margin: 0 !important;
489
+ padding: 1rem;
490
+ border: 1px solid var(--primary);
491
+ border-radius: var(--radius);
492
+ background-color: transparent;
493
+ cursor: pointer;
494
+ color: var(--primary);
495
+ font-size: 14px;
496
+ font-weight: 500;
497
+ }
498
+ .sw-rooms-guests-cta {
499
+ display: flex;
500
+ gap: 10px;
501
+ }
502
+ .sw-rooms-guests-footer {
503
+ display: flex;
504
+ justify-content: space-between;
505
+ gap: 10px;
506
+ margin-top: 15px;
507
+ padding-top: 15px;
508
+ border-top: 1px solid var(--form-border);
509
+ }
510
+ .sw-reset-button {
511
+ padding: 10px 20px;
512
+ border: 1px solid var(--primary);
513
+ border-radius: var(--btn-radius);
514
+ background: transparent;
515
+ cursor: pointer;
516
+ color: var(--primary);
517
+ font-size: 14px;
518
+ font-weight: 500;
519
+ transition: all 0.2s ease;
520
+ }
521
+ .sw-reset-button:hover {
522
+ background: var(--primary-light);
523
+ }
524
+ .sw-apply-button {
525
+ padding: 10px 20px;
526
+ border: 1px solid var(--button-primary-border);
527
+ border-radius: var(--btn-radius);
528
+ background: var(--primary-btn);
529
+ cursor: pointer;
530
+ color: var(--primary-button-text);
531
+ font-size: 14px;
532
+ font-weight: 500;
533
+ transition: all 0.2s ease;
534
+ }
535
+ .sw-apply-button:hover {
536
+ opacity: 0.9;
537
+ background: var(--primary);
538
+ }
539
+ .sw-search-button,
540
+ .sw-search-button.p-button {
541
+ display: flex;
542
+ align-items: center;
543
+ justify-content: center;
544
+ gap: 10px;
545
+ width: auto;
546
+ height: 100%;
547
+ min-height: 56px;
548
+ margin: 0;
549
+ padding: 0 15px;
550
+ border: 1px solid var(--button-primary-border);
551
+ background-color: var(--primary-btn);
552
+ cursor: pointer;
553
+ color: var(--primary-button-text);
554
+ font-size: 16px;
555
+ font-weight: 400;
556
+ transition: var(--widget-transition);
557
+ }
558
+ .sw-search-button:focus-visible,
559
+ .sw-search-button.p-button:focus-visible {
560
+ outline: 2px solid var(--primary);
561
+ outline-offset: 2px;
562
+ }
563
+ .sw-search-button:hover:not(:disabled),
564
+ .sw-search-button.p-button:hover:not(:disabled) {
565
+ background-color: var(--primary);
566
+ opacity: 0.9;
567
+ box-shadow: var(--widget-shadow-hover);
568
+ }
569
+ .sw-search-button .p-button-icon-left {
570
+ margin: 0;
571
+ }
572
+ .sw-search-button svg,
573
+ .sw-search-button .p-button-icon {
574
+ flex-shrink: 0;
575
+ }
576
+ .p-calendar .p-datepicker {
577
+ top: 100% !important;
578
+ display: block;
579
+ min-width: 100%;
580
+ margin-top: 5px !important;
581
+ padding: 15px;
582
+ background-color: var(--white);
583
+ border: 1px solid var(--form-border);
584
+ border-radius: var(--radius);
585
+ box-shadow: var(--widget-shadow);
586
+ }
587
+ .sw-srh-wrap {
588
+ display: flex;
589
+ gap: 2px;
590
+ }
591
+ .sw-com-cal p{
592
+ color: var(--body-text);
593
+ font-size: 14px;
594
+ font-weight: 500;
595
+ }
596
+ .sw-com-cal .p-inputtext{
597
+ visibility: hidden;
598
+ height: 0;
599
+ width: 0;
600
+ ;
601
+ }
602
+ .p-datepicker-header {
603
+ padding-bottom: 15px;
604
+ }
605
+ .p-datepicker-prev[style="visibility: hidden;"]::after,
606
+ .p-datepicker-next[style="visibility: hidden;"]::after {
607
+ visibility: hidden !important;
608
+ }
609
+ .p-datepicker-prev,
610
+ .p-datepicker-next {
611
+ cursor: pointer;
612
+
613
+ }
614
+ .p-datepicker-prev::after,
615
+ .p-datepicker-next::after {
616
+ content: "";
617
+ display: block;
618
+ width: 14px;
619
+ height: 14px;
620
+ visibility: visible;
621
+ background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1024 1024'><path fill='%231b1a1f' d='m222.927 580.115 301.354 328.512c24.354 28.708 20.825 71.724-7.883 96.078s-71.724 20.825-96.078-7.883L19.576 559.963a67.9 67.9 0 0 1-13.784-20.022 68 68 0 0 1-5.977-29.488l.001-.063a68.34 68.34 0 0 1 7.265-29.134 68 68 0 0 1 1.384-2.6 67.6 67.6 0 0 1 10.102-13.687L429.966 21.113c25.592-27.611 68.721-29.247 96.331-3.656s29.247 68.721 3.656 96.331L224.088 443.784h730.46c37.647 0 68.166 30.519 68.166 68.166s-30.519 68.166-68.166 68.166z'/></svg>");
622
+ }
623
+ .p-datepicker-header button {
624
+ margin: 0;
625
+ padding: 0 5px;
626
+ border: 0;
627
+ border-color: var(--white);
628
+ outline: none;
629
+ background: transparent;
630
+ color: var(--body-text);
631
+ font-size: 16px;
632
+ font-weight: 500;
633
+ line-height: 20px;
634
+ }
635
+ .p-datepicker-header button .p-icon {
636
+ display: none;
637
+ }
638
+ .p-datepicker .p-datepicker-next {
639
+ transform: rotate(180deg);
640
+ }
641
+ .p-datepicker .p-datepicker-header button {
642
+ border: 0;
643
+ border-color: var(--white);
644
+ outline: none;
645
+ box-shadow: none !important;
646
+ background: transparent;
647
+ color: var(--body-text);
648
+ font-size: 16px;
649
+ font-weight: 500;
650
+ line-height: 20px;
651
+ }
652
+ .p-datepicker .p-datepicker-calendar-container th {
653
+ padding: 10px 0;
654
+ color: var(--body-text);
655
+ font-size: 14px;
656
+ font-weight: 400;
657
+ line-height: 1.4;
658
+ }
659
+ .p-datepicker .p-datepicker-calendar-container td {
660
+ padding: 0;
661
+ }
662
+ .p-datepicker .p-datepicker-calendar-container td span {
663
+ padding: 10px 0;
664
+ border-radius: 0;
665
+ font-size: 14px;
666
+ width: 45px;
667
+ height: 45px;
668
+ }
669
+ .p-datepicker-group-container .p-datepicker-group:not(:last-child) {
670
+ border-inline-end: 1px solid var(--form-border);
671
+ padding-inline-end: 10px;
672
+ margin-inline-end: 10px;
673
+ }
674
+ .p-datepicker-other-month span{
675
+ opacity: 0;
676
+ }
677
+ .p-datepicker .p-highlight {
678
+ position: relative;
679
+ background: var(--primary) !important;
680
+ color: var(--white) !important;
681
+ }
682
+ .sw-product-tabs {
683
+ position: relative;
684
+ z-index: 1;
685
+ }
686
+ .sw-product-tabs .p-tabview-nav {
687
+ display: flex;
688
+ flex-wrap: wrap;
689
+ gap: 10px;
690
+ margin: 0;
691
+ padding: 0;
692
+ list-style: none;
693
+ }
694
+ .sw-product-tabs .sw-product-list {
695
+ position: relative;
696
+ gap: 10px;
697
+ padding: 0 10px 10px;
698
+ border: 0 !important;
699
+ border-radius: 0;
700
+ cursor: pointer;
701
+ }
702
+ .p-tabview-selected .sw-product-list:before {
703
+ content: "";
704
+ position: absolute;
705
+ bottom: 0;
706
+ left: 0;
707
+ inset-inline-start: 0;
708
+ width: 100%;
709
+ border: 2px solid var(--primary) !important;
710
+ border-radius: 40px;
711
+ }
712
+ .p-tabview-ink-bar {
713
+ display: none;
714
+ }
715
+ .sw-advanced-search-options .p-accordion-header-link {
716
+ display: flex;
717
+ flex-direction: row-reverse;
718
+ gap: 10px;
719
+ width: fit-content;
720
+ margin-top: 15px;
721
+ color: var(--body-text);
722
+ font-size: 14px;
723
+ }
724
+ .sw-advanced-search-options .p-toggleable-content {
725
+ margin-top: 20px;
726
+ }
727
+ .sw-advanced-search-options .p-accordion-content .sw-hsrh-advan-cont:not(:last-child) {
728
+ margin-bottom: 16px;
729
+ }
730
+ .sw-advanced-search-options .p-accordion-header-link svg {
731
+ transform: rotate(90deg);
732
+ }
733
+ .sw-advanced-search-options .p-accordion-header-link[aria-expanded="true"] svg {
734
+ transform: scale(-1);
735
+ }
736
+ .sw-material-checkbox {
737
+ position: relative;
738
+ display: inline-flex;
739
+ gap: 10px;
740
+ cursor: pointer;
741
+ user-select: none;
742
+ color: var(--body-text);
743
+ font-size: 14px;
744
+ }
745
+ .sw-material-checkbox input {
746
+ display: none;
747
+ }
748
+ .sw-material-checkbox input:checked + .sw-checkmark {
749
+ background-color: var(--primary);
750
+ border-color: var(--primary);
751
+ }
752
+ .sw-material-checkbox input:checked + .sw-checkmark::after {
753
+ content: "";
754
+ position: absolute;
755
+ top: 2px;
756
+ left: 6px;
757
+ display: block;
758
+ width: 6px;
759
+ height: 11px;
760
+ border: solid #fff;
761
+ border-width: 0 2px 2px 0;
762
+ transform: rotate(45deg);
763
+ }
764
+ .sw-material-checkbox .sw-checkmark {
765
+ position: relative;
766
+ display: inline-block;
767
+ width: 20px;
768
+ min-width: 20px;
769
+ height: 20px;
770
+ background-color: #fff;
771
+ border: 1px solid var(--form-border);
772
+ border-radius: 4px;
773
+ transition: background-color 0.3s, border-color 0.3s;
774
+ }
775
+ .sw-material-checkbox .sw-checkmark::after {
776
+ content: "";
777
+ position: absolute;
778
+ display: none;
779
+ }
780
+ .sw-tab-checkbox {
781
+ display: flex;
782
+ cursor: pointer;
783
+ -webkit-user-select: none;
784
+ user-select: none;
785
+ }
786
+ .sw-tab-checkbox input {
787
+ display: none;
788
+ }
789
+ .sw-tab-checkbox input:checked + .sw-tab-content,
790
+ .sw-tab-checkbox input[type=radio]:checked + .sw-tab-content {
791
+ border: 1px solid var(--primary);
792
+ background-color: var(--primary-light);
793
+ color: var(--primary);
794
+ }
795
+ .sw-tab-content {
796
+ height: 40px;
797
+ padding: 6px 15px;
798
+ border: 1px solid var(--form-border);
799
+ border-radius: var(--radius);
800
+ align-content: center;
801
+ }
802
+ @media print {
803
+ .sw-container {
804
+ display: none;
805
+ }
806
+ }
807
+ .sw-dropdown,
808
+ .sw-rooms-guests-menu,
809
+ .p-calendar .p-datepicker {
810
+ will-change: transform, opacity;
811
+ transform: translateZ(0);
812
+ }
813
+ .sw-dropdown {
814
+ -webkit-overflow-scrolling: touch;
815
+ scroll-behavior: smooth;
816
+ }
817
+ .sw-container img {
818
+ max-width: 100%;
819
+ height: auto;
820
+ }
821
+ .sw-container svg {
822
+ max-width: 100%;
823
+ height: auto;
824
+ }
825
+ .sw-container {
826
+ isolation: isolate;
827
+ }
828
+ .sw-srh-grid {
829
+ display: grid;
830
+ grid-template-columns: minmax(200px, 2fr) minmax(100px, 1fr) minmax(80px, 0.6fr) minmax(60px, 0.4fr);
831
+ gap: var(--grid-gap-sm, 2px);
832
+ margin-top: 15px;
833
+ border-radius: var(--radius);
834
+ min-width: 0;
835
+ overflow: visible;
836
+ }
837
+ .sw-srh-wrap .sw-form-field {
838
+ flex: 1 1 50%;
839
+ min-width: 0;
840
+ justify-content: center;
841
+ }
842
+ .sw-add-return-label label {
843
+ color: var(--primary) !important;
844
+ }
845
+ .sw-srh-main-head {
846
+ display: flex;
847
+ align-items: center;
848
+ justify-content: space-between;
849
+ margin-bottom: 15px;
850
+ }
851
+ .sw-srh-head {
852
+ display: flex;
853
+ align-items: center;
854
+ gap: 10px;
855
+ }
856
+ .sw-srh-round-text {
857
+ display: flex;
858
+ align-items: center;
859
+ gap: 8px;
860
+ height: 40px;
861
+ }
862
+ .sw-remove-segment{
863
+ fill: var(--primary);
864
+ cursor: pointer;
865
+ display: grid;
866
+ place-content: center;
867
+ position: absolute;
868
+ z-index: 2;
869
+ border-radius: 50%;
870
+ inset-inline-end: 12px;
871
+ border: 1px solid var(--primary);
872
+ width: 22px;
873
+ height: 22px;
874
+ top: 19px;
875
+ svg{
876
+ width: 22px;
877
+ height: 22px;
878
+ }
879
+ }
880
+ .sw-srh-mc .sw-srh-wrap.sw-srh-box{
881
+ position: relative;
882
+ }
883
+ .sw-srh-mc {
884
+ grid-template-columns: 6.3fr 2.5fr 1.15fr !important;
885
+ min-width: 0;
886
+ }
887
+ .sw-srh-mc .sw-com-cal .p-inputtext{
888
+ visibility: visible !important;
889
+ height: auto !important;
890
+ width: auto !important;
891
+ }
892
+ .sw-srh-mc .sw-srh-wrap.sw-pos-rel:nth-child(3){
893
+ flex-basis: 30%;
894
+ }
895
+ .sw-srh-mc .sw-srh-mc-foot {
896
+ display: flex;
897
+ align-items: flex-end;
898
+ width: fit-content;
899
+ grid-column-start: 2;
900
+ }
901
+ .sw-srh-mc .sw-srh-mc-foot button {
902
+ display: flex;
903
+ align-items: center;
904
+ gap: 7px;
905
+ margin-inline-start: 5px;
906
+ padding: 8px 10px;
907
+ border: 1px solid var(--primary);
908
+ border-radius: 30px;
909
+ background-color: transparent;
910
+ color: var(--primary);
911
+ font-size: 14px;
912
+ }
913
+ .sw-srh-mc .sw-srh-mc-foot button svg {
914
+ fill: var(--primary);
915
+ }
916
+ .sw-srh-mc .sw-srh-add-btn {
917
+ display: flex;
918
+ align-items: center;
919
+ gap: 7px;
920
+ margin-inline-start: 5px;
921
+ padding: 0.8rem 1rem;
922
+ border-radius: 30px;
923
+ color: var(--primary);
924
+ font-size: 1.4rem;
925
+ }
926
+ .sw-srh-mc .sw-traveller {
927
+ grid-row-start: 1;
928
+ grid-column-start: 2;
929
+ }
930
+ .sw-srh-mc button {
931
+ grid-row-start: 1;
932
+ grid-column-start: 3;
933
+ }
934
+ .sw-srh-box {
935
+ grid-column-start: 1;
936
+ }
937
+ .p-autocomplete-multiple-container {
938
+ width: 100%;
939
+ min-width: 270px;
940
+ padding: 10px;
941
+ padding-inline-end: 2rem;
942
+ border: 1px solid var(--form-border);
943
+ border-radius: var(--radius);
944
+ gap: 0.5rem;
945
+ font-size: 14px;
946
+ }
947
+ .p-autocomplete-multiple-container .p-autocomplete-token {
948
+ padding: 5px 8px;
949
+ border-radius: 5px;
950
+ background: var(--primary-light);
951
+ gap: 5px;
952
+ color: var(--primary);
953
+ }
954
+ .p-autocomplete-token .p-autocomplete-token-label{
955
+ font-size: 12px;
956
+ font-weight: 400;
957
+ }
958
+ .sw-fsrh-adv-cont {
959
+ display: flex;
960
+ align-items: center;
961
+ gap: 20px;
962
+ }
963
+ .sw-fsrh-chk-main {
964
+ display: flex;
965
+ gap: 20px;
966
+ font-size: 1.4rem;
967
+ font-weight: 400;
968
+ }
969
+ .sw-srh-pax {
970
+ display: flex;
971
+ align-items: center;
972
+ gap: 10px;
973
+ }
974
+ .sw-srh-pax:not(:last-child) {
975
+ margin-bottom: 15px;
976
+ }
977
+ .sw-srh-common-adult {
978
+ width: 92px;
979
+ }
980
+ .sw-srh-pax h3 {
981
+ font-size: 14px;
982
+ }
983
+ .sw-srh-pax p {
984
+ color: var(--label-color);
985
+ font-size: 12px;
986
+ }
987
+ .sw-srh-button-wrapper button {
988
+ width: 32px;
989
+ height: 30px;
990
+ margin: 0;
991
+ padding: 0;
992
+ border: 0;
993
+ border-radius: 8px;
994
+ background-color: transparent;
995
+ font-size: 14px;
996
+ font-weight: 400;
997
+ }
998
+ .sw-srh-button-wrapper button.sw-active-button {
999
+ background-color: var(--secondary);
1000
+ color: var(--white);
1001
+ }
1002
+ .sw-traveller .sw-rooms-guests-menu {
1003
+ width: 460px;
1004
+ }
1005
+ .sw-srh-class {
1006
+ display: flex;
1007
+ flex-wrap: wrap;
1008
+ gap: var(--flex-gap-md, 10px);
1009
+ align-items: stretch;
1010
+ }
1011
+ .sw-srh-class .sw-tab-content {
1012
+ min-width: fit-content;
1013
+ display: block;
1014
+ }
1015
+ .sw-srh-class label {
1016
+ width: fit-content !important;
1017
+ }
1018
+ .sw-srh-class .sw-tab-checkbox input:checked + .sw-tab-content,
1019
+ .sw-srh-class .sw-tab-checkbox input[type=radio]:checked + .sw-tab-content {
1020
+ background-color: var(--primary);
1021
+ color: var(--white);
1022
+ }
1023
+ .sw-srh-h-grid {
1024
+ position: relative;
1025
+ display: grid;
1026
+ grid-template-columns: 2.2fr 1.8fr 3fr 1.8fr 1.15fr;
1027
+ gap: var(--grid-gap-sm, 2px);
1028
+ min-height: 55px;
1029
+ min-width: 0;
1030
+ overflow: visible;
1031
+ border-radius: var(--radius);
1032
+ }
1033
+ .sw-srh-loc {
1034
+ display: block !important;
1035
+ padding: 15px 0 12px;
1036
+ border-bottom: 1px solid var(--form-border);
1037
+ }
1038
+ .sw-srh-count-wrapper,
1039
+ .sw-srh-loc {
1040
+ display: flex;
1041
+ align-items: center;
1042
+ gap: 15px;
1043
+ margin: 0 20px;
1044
+ cursor: pointer;
1045
+ }
1046
+ .sw-hotel-search-form-icon {
1047
+ display: grid;
1048
+ place-content: center;
1049
+ width: 40px;
1050
+ height: 40px;
1051
+ background: #f4f5f5;
1052
+ border-radius: var(--radius);
1053
+ }
1054
+ .sw-hotel-search-form-icon.sw-fill {
1055
+ background: var(--primary-light);
1056
+ }
1057
+ .sw-hsrh-advan-cont {
1058
+ display: flex;
1059
+ align-items: center;
1060
+ gap: 10px;
1061
+ }
1062
+ .sw-checkbox-wrap {
1063
+ cursor: pointer;
1064
+ }
1065
+ .sw-checkbox-wrap input {
1066
+ display: none;
1067
+ }
1068
+ .sw-checkbox-wrap input:checked + .sw-star-checkbox {
1069
+ padding: 8px 12px;
1070
+ border: 1px solid var(--primary-light);
1071
+ border-radius: 20px;
1072
+ background: var(--primary-light);
1073
+ gap: 5px;
1074
+ color: var(--primary);
1075
+ font-size: 14px;
1076
+ line-height: 1;
1077
+ }
1078
+ .sw-checkbox-wrap .sw-star-checkbox {
1079
+ display: flex;
1080
+ align-items: center;
1081
+ gap: 5px;
1082
+ padding: 8px 12px;
1083
+ border: 1px solid var(--form-border);
1084
+ border-radius: 20px;
1085
+ font-size: 14px;
1086
+ line-height: 1;
1087
+ }
1088
+ .sw-star-checkbox-wrap input:checked + .sw-star-checkbox {
1089
+ padding: 7px 12px;
1090
+ border: 1px solid #fcf2e8;
1091
+ border-radius: 20px;
1092
+ background: #fcf2e8;
1093
+ color: #ffae43;
1094
+ }
1095
+ .sw-star-checkbox-wrap input:checked + .sw-star-checkbox svg path {
1096
+ fill: #ffae43;
1097
+ }
1098
+ .sw-hsrh-chk-main {
1099
+ display: flex;
1100
+ gap: var(--flex-gap-md, 10px);
1101
+ font-size: 1.4rem;
1102
+ font-weight: 400;
1103
+ flex-wrap: wrap;
1104
+ }
1105
+ .sw-srh-class {
1106
+ display: flex;
1107
+ flex-wrap: wrap;
1108
+ gap: var(--flex-gap-md, 10px);
1109
+ align-items: stretch;
1110
+ }
1111
+ .sw-srh-class .sw-tab-content {
1112
+ flex: 0 1 auto;
1113
+ min-width: fit-content;
1114
+ }
1115
+ `;
1116
+
1117
+ // src/Flight.tsx
1118
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
1119
+ var normalizeDomainName = (domainName) => {
1120
+ const trimmed = domainName.trim();
1121
+ if (!trimmed) return "";
1122
+ if (trimmed.startsWith("http://") || trimmed.startsWith("https://")) {
1123
+ try {
1124
+ return new URL(trimmed).hostname;
1125
+ } catch {
1126
+ return trimmed.replace(/^https?:\/\//, "").split("/")[0] ?? "";
1127
+ }
1128
+ }
1129
+ return trimmed.split("/")[0] ?? "";
1130
+ };
1131
+ var buildEncryptedToken = (domainName) => {
1132
+ const normalizedDomain = normalizeDomainName(domainName);
1133
+ if (!normalizedDomain) return null;
1134
+ const encryptor = new JSEncrypt();
1135
+ encryptor.setPublicKey(RSA_PUBLIC_KEY);
1136
+ const payload = `${normalizedDomain}~${(/* @__PURE__ */ new Date()).getTime()}`;
1137
+ const encrypted = encryptor.encrypt(payload);
1138
+ return typeof encrypted === "string" ? encrypted : null;
1139
+ };
1140
+ var STYLE_ELEMENT_ID = "tfsw-flight-styles";
1141
+ var PRIMEICONS_LINK_ID = "tfsw-primeicons";
1142
+ var RSA_PUBLIC_KEY = `-----BEGIN PUBLIC KEY-----
1143
+ MIICITANBgkqhkiG9w0BAQEFAAOCAg4AMIICCQKCAgB0rRSHGZK/FtK15IRfQxtl
1144
+ dN5ToPtfXGzTNBe1vGhow5xqp6BLubMKKPwCj3zOJiAm1Ip1VNqqYxWnaL8ZErBF
1145
+ rErtE0r7kn50QgGgJCpdrWJ4unhaoe1su207d9oY6D6OBH90v1aXA6ZjN7zTJmiq
1146
+ FJZOOTQE6t/XwNAOphq/B6Lcr1iQSQmSqaMozy4OQ4NvIzNTQn5tcs9qJBMsKFeU
1147
+ cSp8VK76JBNEqSuEHNmbV2d/IQ5XAqVUiAs34kH2xWRSbBmy0WK3c3QKGzC1MRWM
1148
+ 9JauLN56TKUFOmUSjfWY3caJru6HxsiMTGKnvflXHfgA2aLAPxu72pIHoCTy5Hxj
1149
+ AUoKM7qXUn/kQj4Ci0M/0LRF4boqd37wpbyVNeXNvqm+dLjxklf/+NHMfNL2Wvb4
1150
+ ekHUVI8nMVPgswIcQ7q/Njf9DC+LA+/duf8m9JDjI3J6r9y1gQugdkLETGzF2Gj1
1151
+ ToU0Pocrg6CFHImqq2z+cOeWnURrV0f0I1UWWGCb79OZxZ5oDjM9uCLRsoe8+Npg
1152
+ ACZNf4AbnM7OUNj5TEYs6t/tUYouvTB7gH452I3EH6KWBl+ZTgCg0RFkOMazNOjn
1153
+ 4J0yfbaPvpVgKzF2WRyn63mTO2tdLRl5s9uqMFhXmCs6IzEqBpxMKL1aS6ONZLDG
1154
+ 5qPtpCPJnUFQEBTVlSO15QIDAQAB
1155
+ -----END PUBLIC KEY-----`;
1156
+ var SSO_RSA_PUBLIC_KEY = `-----BEGIN PUBLIC KEY-----
1157
+ MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAv+PThexweK9V8axQRaB3
1158
+ JrhYm/y2JAhED2o7V4Kpi4PpwdkcsVuACwxPt8M51idar/lBNnm12yJAvMnSRAYP
1159
+ Gv+iYCE5VV+XPzUZuu/ho3sARxO3bCSRx9Xk0JZkd0Q7Muvy3Z74N9lML+g4DAHH
1160
+ 1SA+tQnvk2hLwna7vd6pHfmVDROEkTTqv0EF+0cVCUhwrXcEZ7NLrs3BPWLbxzus
1161
+ jlYsutTU0oaCeeag+xX6vbb+LFjDBvxngdlPzApUU0z9T4r/Mqbdb73e2FMrPSHO
1162
+ rJo+bRQ1+GE0EoFxYTyYVyOrd9bpfUhcc/ziK8Bu2M8lQk9pFs+1DGb1wC1TWklf
1163
+ ZCHX79BPP+tyLFugqmCLm+WprtNl+Cv93VQuwue6m9UATeiWHYrA9uZ0mWHvRPuD
1164
+ EaXCAvT3JUDqTnuV/mTu8cAr+HWMfB7wQ+XWyi6TVAfQovMawV89Gtk5q7Ep2L89
1165
+ MShfennamuIRODd7IuDLN24h8laBEKz0lPATsvyS3ITHG+DdwUjU+ptGYGzGI+ps
1166
+ YadkX8g5DSjQs8JZvCN22ktjGRLCudvS8e0IfgzRe6QQ90NmQ3dmtC4AsatHBeM5
1167
+ S7wetGyB9NHx52liu+AwZqiiLk8Yf/Y2/4394Z+kE/CYVFnCMEOxRhx/Fs3QRCm2
1168
+ piJcd0xNaTlQZ4IcB08NBMECAwEAAQ==
1169
+ -----END PUBLIC KEY-----`;
1170
+ var buildEncryptedSsoUserToken = (user) => {
1171
+ if (!user) return null;
1172
+ const email = (user.email ?? "").trim();
1173
+ if (!email) return null;
1174
+ const encryptor = new JSEncrypt();
1175
+ encryptor.setPublicKey(SSO_RSA_PUBLIC_KEY);
1176
+ const payloadUser = {
1177
+ ...user,
1178
+ email,
1179
+ ts: user.ts ?? (/* @__PURE__ */ new Date()).toISOString()
1180
+ };
1181
+ const payload = JSON.stringify(payloadUser);
1182
+ const encrypted = encryptor.encrypt(payload);
1183
+ return typeof encrypted === "string" ? encrypted : null;
1184
+ };
1185
+ var ensureStylesInjected = () => {
1186
+ if (typeof document === "undefined") {
1187
+ return;
1188
+ }
1189
+ if (document.getElementById(STYLE_ELEMENT_ID)) {
1190
+ return;
1191
+ }
1192
+ const style = document.createElement("style");
1193
+ style.id = STYLE_ELEMENT_ID;
1194
+ style.textContent = flightSearchWidgetStyles;
1195
+ document.head.appendChild(style);
1196
+ };
1197
+ var ensurePrimeIconsLoaded = () => {
1198
+ if (typeof document === "undefined") {
1199
+ return;
1200
+ }
1201
+ if (document.getElementById(PRIMEICONS_LINK_ID)) {
1202
+ return;
1203
+ }
1204
+ const link = document.createElement("link");
1205
+ link.id = PRIMEICONS_LINK_ID;
1206
+ link.rel = "stylesheet";
1207
+ link.href = "https://unpkg.com/primeicons@7.0.0/primeicons.css";
1208
+ document.head.appendChild(link);
1209
+ };
1210
+ var DEFAULT_AIRPORTS = [
1211
+ { ac: "AUH", an: "Abu Dhabi International Airport", cc: "AE", cn: "United Arab Emirates", ct: "Abu Dhabi" },
1212
+ { ac: "CAI", an: "Cairo International Airport", cc: "EG", cn: "Egypt", ct: "Cairo" },
1213
+ { ac: "DXB", an: "Dubai International Airport", cc: "AE", cn: "United Arab Emirates", ct: "Dubai" },
1214
+ { ac: "RUH", an: "King Khalid International Airport", cc: "SA", cn: "Saudi Arabia", ct: "Riyadh" },
1215
+ { ac: "LOS", an: "Murtala Muhammed International Airport", cc: "NG", cn: "Nigeria", ct: "Lagos" },
1216
+ { ac: "LON", an: "London All Airports", cc: "GB", cn: "United Kingdom", ct: "London" },
1217
+ { ac: "PAR", an: "All Airports", cc: "FR", cn: "France", ct: "Paris" },
1218
+ { ac: "NYC", an: "All airports", cc: "US", cn: "United States Of America", ct: "New York" }
1219
+ ];
1220
+ function formatAirportDisplay(airport) {
1221
+ const code = airport.ac ?? "";
1222
+ const name = airport.an ?? airport.ct ?? "";
1223
+ return name ? `${name} (${code})` : code;
1224
+ }
1225
+ function getAirportCode(airport) {
1226
+ return airport.ac ?? "";
1227
+ }
1228
+ function formatDisplayDate(date) {
1229
+ if (!date || !(date instanceof Date) || isNaN(date.getTime())) return "Select date";
1230
+ return date.toLocaleDateString("en-GB", { day: "2-digit", month: "short", year: "numeric" });
1231
+ }
1232
+ function FlightSearchWidget({
1233
+ config,
1234
+ ssoUser
1235
+ }) {
1236
+ const theme = config?.theme;
1237
+ const primaryColor = theme?.primary ?? "#2c0a82";
1238
+ const secondaryColor = theme?.secondary ?? "#2c0a82";
1239
+ const primaryLightColor = theme?.primaryLight ?? "#f3e2ff";
1240
+ const fontName = config?.fontName;
1241
+ const redirectionDomain = config?.redirectionDomain;
1242
+ const airportSearchApiBaseUrl = "https://adminapi-go.dev.futuretravelplatform.com/api";
1243
+ const airlineSearchApiBaseUrl = "https://adminapi.dev.futuretravelplatform.com/api";
1244
+ const langCode = "en";
1245
+ const [airlineQuery, setAirlineQuery] = useState("");
1246
+ const [airlineSuggestions, setAirlineSuggestions] = useState([]);
1247
+ const [selectedAirlines, setSelectedAirlines] = useState([]);
1248
+ const [validationErrors, setValidationErrors] = useState({});
1249
+ const createDefaultSegment = () => ({
1250
+ origin: "Origin",
1251
+ destination: "Destination",
1252
+ departureDate: /* @__PURE__ */ new Date(),
1253
+ returnDate: new Date((/* @__PURE__ */ new Date()).setDate((/* @__PURE__ */ new Date()).getDate() + 1)),
1254
+ dateRange: [/* @__PURE__ */ new Date(), new Date((/* @__PURE__ */ new Date()).setDate((/* @__PURE__ */ new Date()).getDate() + 1))],
1255
+ travelerClass: "Economy",
1256
+ adultCount: 1,
1257
+ childCount: 0,
1258
+ infantCount: 0
1259
+ });
1260
+ const [formState, setFormState] = useState(() => ({
1261
+ tripType: "round-trip",
1262
+ segments: [{
1263
+ origin: "Origin",
1264
+ destination: "Destination",
1265
+ departureDate: /* @__PURE__ */ new Date(),
1266
+ returnDate: new Date((/* @__PURE__ */ new Date()).setDate((/* @__PURE__ */ new Date()).getDate() + 1)),
1267
+ dateRange: [/* @__PURE__ */ new Date(), new Date((/* @__PURE__ */ new Date()).setDate((/* @__PURE__ */ new Date()).getDate() + 1))],
1268
+ travelerClass: "Economy",
1269
+ adultCount: 1,
1270
+ childCount: 0,
1271
+ infantCount: 0
1272
+ }]
1273
+ }));
1274
+ const { tripType, segments } = formState;
1275
+ const setTripType = (value) => setFormState((prev) => ({ ...prev, tripType: value }));
1276
+ const setSegments = (updater) => setFormState((prev) => ({ ...prev, segments: updater(prev.segments) }));
1277
+ const [advancedOptions, setAdvancedOptions] = useState({
1278
+ isDirectFlights: false,
1279
+ isRefundable: false,
1280
+ isBaggage: false,
1281
+ preferredAirlineList: [],
1282
+ isFlexiDate: false,
1283
+ isUmrah: false
1284
+ });
1285
+ const [isOriginDropdownOpen, setIsOriginDropdownOpen] = useState(false);
1286
+ const [isDestinationDropdownOpen, setIsDestinationDropdownOpen] = useState(false);
1287
+ const [isRoomsGuestsMenuOpen, setIsRoomsGuestsMenuOpen] = useState(false);
1288
+ const originDropdownRef = useRef(null);
1289
+ const destinationDropdownRef = useRef(null);
1290
+ const roomsGuestsMenuRef = useRef(null);
1291
+ const dateRangeCalendarRef = useRef(null);
1292
+ const segmentCalendarRefs = useRef({});
1293
+ const getMaxSegments = () => {
1294
+ if (tripType === "custom-search") return 3;
1295
+ if (tripType === "multi-city") return 6;
1296
+ return 1;
1297
+ };
1298
+ const [segmentDropdowns, setSegmentDropdowns] = useState({});
1299
+ const segmentRefs = useRef({});
1300
+ const [predictiveSearchList, setPredictiveSearchList] = useState({});
1301
+ const searchDebounceRef = useRef(null);
1302
+ const airlineSearchDebounceRef = useRef(null);
1303
+ const getPredictiveState = (segmentIndex) => {
1304
+ return predictiveSearchList[segmentIndex] ?? {
1305
+ fromAirport: [],
1306
+ toAirport: [],
1307
+ selectedFromIndex: -1,
1308
+ selectedToIndex: -1
1309
+ };
1310
+ };
1311
+ const getAirportListBySearch = useCallback(async (searchKeyword) => {
1312
+ if (!searchKeyword.trim()) return [];
1313
+ const url = `${airportSearchApiBaseUrl.replace(/\/$/, "")}/Airport/GetList/${encodeURIComponent(langCode)}/${encodeURIComponent(searchKeyword.trim())}`;
1314
+ try {
1315
+ const res = await fetch(url);
1316
+ if (!res.ok) return [];
1317
+ const data = await res.json();
1318
+ if (Array.isArray(data)) return data;
1319
+ if (data && Array.isArray(data.data)) return data.data;
1320
+ if (data && Array.isArray(data.result)) return data.result;
1321
+ return [];
1322
+ } catch {
1323
+ return [];
1324
+ }
1325
+ }, [airportSearchApiBaseUrl, langCode]);
1326
+ const getAirlineListBySearch = useCallback(async (searchKeyword) => {
1327
+ if (!searchKeyword.trim()) return [];
1328
+ const lang = (langCode ?? "en").toUpperCase();
1329
+ const url = `${airlineSearchApiBaseUrl.replace(/\/$/, "")}/MasterSearch/GetAllAirline/${encodeURIComponent(lang)}/${encodeURIComponent(searchKeyword.trim())}`;
1330
+ try {
1331
+ const token = buildEncryptedToken(redirectionDomain ?? "");
1332
+ const res = await fetch(url, {
1333
+ headers: token ? { token } : void 0
1334
+ });
1335
+ if (!res.ok) return [];
1336
+ const data = await res.json();
1337
+ if (Array.isArray(data)) return data;
1338
+ if (data && Array.isArray(data.data)) return data.data;
1339
+ if (data && Array.isArray(data.result)) return data.result;
1340
+ return [];
1341
+ } catch {
1342
+ return [];
1343
+ }
1344
+ }, [airlineSearchApiBaseUrl, langCode, redirectionDomain]);
1345
+ const searchAirport = useCallback((segmentIndex, dropdownType, value) => {
1346
+ if (value.length < 3) {
1347
+ setPredictiveSearchList((prev) => ({
1348
+ ...prev,
1349
+ [segmentIndex]: {
1350
+ ...prev[segmentIndex] ?? { fromAirport: [], toAirport: [], selectedFromIndex: -1, selectedToIndex: -1 },
1351
+ [dropdownType === "origin" ? "fromAirport" : "toAirport"]: [],
1352
+ [dropdownType === "origin" ? "selectedFromIndex" : "selectedToIndex"]: -1
1353
+ }
1354
+ }));
1355
+ return;
1356
+ }
1357
+ getAirportListBySearch(value).then((res) => {
1358
+ setPredictiveSearchList((prev) => ({
1359
+ ...prev,
1360
+ [segmentIndex]: {
1361
+ ...prev[segmentIndex] ?? { fromAirport: [], toAirport: [], selectedFromIndex: -1, selectedToIndex: -1 },
1362
+ [dropdownType === "origin" ? "fromAirport" : "toAirport"]: res,
1363
+ [dropdownType === "origin" ? "selectedFromIndex" : "selectedToIndex"]: res?.length === 0 ? -1 : 0
1364
+ }
1365
+ }));
1366
+ });
1367
+ }, [getAirportListBySearch]);
1368
+ const closeAirportDropdown = useCallback((dropdownType, segmentIndex) => {
1369
+ if (dropdownType === "origin") {
1370
+ setIsOriginDropdownOpen(false);
1371
+ } else {
1372
+ setIsDestinationDropdownOpen(false);
1373
+ }
1374
+ setSegmentDropdowns((prev) => ({
1375
+ ...prev,
1376
+ [segmentIndex]: { ...prev[segmentIndex] || { origin: false, destination: false }, [dropdownType]: false }
1377
+ }));
1378
+ }, []);
1379
+ const selectAirport = useCallback((airport, dropdownType, segmentIndex) => {
1380
+ const display = formatAirportDisplay(airport);
1381
+ setSegments((prev) => {
1382
+ const updated = [...prev];
1383
+ if (!updated[segmentIndex]) return prev;
1384
+ if (dropdownType === "origin") updated[segmentIndex] = { ...updated[segmentIndex], origin: display };
1385
+ else updated[segmentIndex] = { ...updated[segmentIndex], destination: display };
1386
+ return updated;
1387
+ });
1388
+ closeAirportDropdown(dropdownType, segmentIndex);
1389
+ }, [closeAirportDropdown]);
1390
+ const updateSelectedIndex = useCallback((segmentIndex, dropdownType, newIndex) => {
1391
+ setPredictiveSearchList((prev) => {
1392
+ const state = prev[segmentIndex] ?? { fromAirport: [], toAirport: [], selectedFromIndex: -1, selectedToIndex: -1 };
1393
+ const list = dropdownType === "origin" ? state.fromAirport : state.toAirport;
1394
+ const len = list.length;
1395
+ if (len === 0) return prev;
1396
+ const clamped = (newIndex % len + len) % len;
1397
+ return {
1398
+ ...prev,
1399
+ [segmentIndex]: {
1400
+ ...state,
1401
+ [dropdownType === "origin" ? "selectedFromIndex" : "selectedToIndex"]: clamped
1402
+ }
1403
+ };
1404
+ });
1405
+ }, []);
1406
+ const handleKeyDown = useCallback((event, dropdownType, segmentIndex) => {
1407
+ const state = getPredictiveState(segmentIndex);
1408
+ const options = dropdownType === "origin" ? state.fromAirport : state.toAirport;
1409
+ const selectedIndex = dropdownType === "origin" ? state.selectedFromIndex : state.selectedToIndex;
1410
+ const isOpen = segmentIndex === 0 ? dropdownType === "origin" ? isOriginDropdownOpen : isDestinationDropdownOpen : segmentDropdowns[segmentIndex]?.[dropdownType];
1411
+ switch (event.key) {
1412
+ case "ArrowDown":
1413
+ if (isOpen && options.length) {
1414
+ event.preventDefault();
1415
+ updateSelectedIndex(segmentIndex, dropdownType, selectedIndex + 1);
1416
+ }
1417
+ break;
1418
+ case "ArrowUp":
1419
+ if (isOpen && options.length) {
1420
+ event.preventDefault();
1421
+ updateSelectedIndex(segmentIndex, dropdownType, selectedIndex - 1);
1422
+ }
1423
+ break;
1424
+ case "Enter":
1425
+ if (isOpen && options.length && selectedIndex >= 0 && options[selectedIndex]) {
1426
+ event.preventDefault();
1427
+ selectAirport(options[selectedIndex], dropdownType, segmentIndex);
1428
+ }
1429
+ break;
1430
+ case "Escape":
1431
+ if (isOpen) {
1432
+ event.preventDefault();
1433
+ closeAirportDropdown(dropdownType, segmentIndex);
1434
+ }
1435
+ break;
1436
+ default:
1437
+ break;
1438
+ }
1439
+ }, [isOriginDropdownOpen, isDestinationDropdownOpen, segmentDropdowns, getPredictiveState, updateSelectedIndex, selectAirport, closeAirportDropdown]);
1440
+ const DEBOUNCE_MS = 300;
1441
+ const triggerSearchAirport = useCallback((segmentIndex, dropdownType, value) => {
1442
+ if (searchDebounceRef.current) clearTimeout(searchDebounceRef.current);
1443
+ if (value.length < 3) {
1444
+ searchAirport(segmentIndex, dropdownType, value);
1445
+ return;
1446
+ }
1447
+ searchDebounceRef.current = setTimeout(() => {
1448
+ searchDebounceRef.current = null;
1449
+ searchAirport(segmentIndex, dropdownType, value);
1450
+ }, DEBOUNCE_MS);
1451
+ }, [searchAirport]);
1452
+ const triggerSearchAirline = useCallback((value) => {
1453
+ if (airlineSearchDebounceRef.current) clearTimeout(airlineSearchDebounceRef.current);
1454
+ if (value.length < 2) {
1455
+ setAirlineSuggestions([]);
1456
+ return;
1457
+ }
1458
+ airlineSearchDebounceRef.current = setTimeout(() => {
1459
+ airlineSearchDebounceRef.current = null;
1460
+ getAirlineListBySearch(value).then(setAirlineSuggestions);
1461
+ }, DEBOUNCE_MS);
1462
+ }, [getAirlineListBySearch]);
1463
+ useEffect(() => () => {
1464
+ if (searchDebounceRef.current) clearTimeout(searchDebounceRef.current);
1465
+ if (airlineSearchDebounceRef.current) clearTimeout(airlineSearchDebounceRef.current);
1466
+ }, []);
1467
+ const themeStyle = useMemo(
1468
+ () => {
1469
+ const style = {
1470
+ ["--primary"]: primaryColor,
1471
+ ["--secondary"]: secondaryColor,
1472
+ ["--primary-light"]: primaryLightColor
1473
+ };
1474
+ if (fontName) {
1475
+ style["--font-family"] = fontName;
1476
+ }
1477
+ return style;
1478
+ },
1479
+ [primaryColor, secondaryColor, primaryLightColor]
1480
+ );
1481
+ useEffect(() => {
1482
+ ensureStylesInjected();
1483
+ ensurePrimeIconsLoaded();
1484
+ }, []);
1485
+ useEffect(() => {
1486
+ const handleClickOutside = (event) => {
1487
+ const target = event.target;
1488
+ const isInsidePrimeDropdown = target.closest(".p-dropdown-panel") !== null || target.closest(".p-dropdown-items-wrapper") !== null || target.closest(".p-dropdown-item") !== null || target.closest(".p-component")?.classList.contains("p-dropdown") !== false || target.closest('[data-pc-section="panel"]') !== null || target.closest('[data-pc-name="dropdown"]') !== null;
1489
+ if (originDropdownRef.current && !originDropdownRef.current.contains(target)) {
1490
+ setIsOriginDropdownOpen(false);
1491
+ }
1492
+ if (destinationDropdownRef.current && !destinationDropdownRef.current.contains(target)) {
1493
+ setIsDestinationDropdownOpen(false);
1494
+ }
1495
+ if (!isInsidePrimeDropdown && roomsGuestsMenuRef.current && !roomsGuestsMenuRef.current.contains(target)) {
1496
+ setIsRoomsGuestsMenuOpen(false);
1497
+ }
1498
+ const isInsideCustomDropdown = target.closest(".sw-custom-dropdown") !== null;
1499
+ const isInsideCalendar = target.closest(".p-datepicker") !== null || target.closest(".p-calendar") !== null;
1500
+ if (!isInsideCustomDropdown && !isInsideCalendar) {
1501
+ setSegmentDropdowns({});
1502
+ return;
1503
+ }
1504
+ Object.keys(segmentRefs.current).forEach((key) => {
1505
+ const index = Number.parseInt(key, 10);
1506
+ const refs = segmentRefs.current[index];
1507
+ if (refs) {
1508
+ if (refs.origin && !refs.origin.contains(target)) {
1509
+ setSegmentDropdowns((prev) => ({
1510
+ ...prev,
1511
+ [index]: { ...prev[index] || { origin: false, destination: false }, origin: false }
1512
+ }));
1513
+ }
1514
+ if (refs.destination && !refs.destination.contains(target)) {
1515
+ setSegmentDropdowns((prev) => ({
1516
+ ...prev,
1517
+ [index]: {
1518
+ ...prev[index] || { origin: false, destination: false },
1519
+ destination: false
1520
+ }
1521
+ }));
1522
+ }
1523
+ }
1524
+ });
1525
+ };
1526
+ document.addEventListener("mousedown", handleClickOutside);
1527
+ return () => {
1528
+ document.removeEventListener("mousedown", handleClickOutside);
1529
+ };
1530
+ }, []);
1531
+ useEffect(() => {
1532
+ if (tripType === "multi-city" || tripType === "custom-search") {
1533
+ setSegments((prev) => {
1534
+ const maxSegments = getMaxSegments();
1535
+ if (prev.length === 0) {
1536
+ const first = createDefaultSegment();
1537
+ const second = {
1538
+ origin: "Origin",
1539
+ destination: "Destination",
1540
+ departureDate: /* @__PURE__ */ new Date(),
1541
+ returnDate: null,
1542
+ dateRange: null,
1543
+ travelerClass: first.travelerClass,
1544
+ adultCount: first.adultCount,
1545
+ childCount: first.childCount,
1546
+ infantCount: first.infantCount
1547
+ };
1548
+ return [first, second];
1549
+ }
1550
+ if (prev.length === 1) {
1551
+ const first = prev[0];
1552
+ const second = {
1553
+ origin: "Origin",
1554
+ destination: "Destination",
1555
+ departureDate: /* @__PURE__ */ new Date(),
1556
+ returnDate: null,
1557
+ dateRange: null,
1558
+ travelerClass: first.travelerClass,
1559
+ adultCount: first.adultCount,
1560
+ childCount: first.childCount,
1561
+ infantCount: first.infantCount
1562
+ };
1563
+ return [first, second];
1564
+ }
1565
+ if (prev.length > maxSegments) return prev.slice(0, maxSegments);
1566
+ return prev;
1567
+ });
1568
+ } else {
1569
+ setSegments((prev) => {
1570
+ if (prev.length === 0) return [createDefaultSegment()];
1571
+ if (prev.length > 1) return [prev[0]];
1572
+ return prev;
1573
+ });
1574
+ }
1575
+ }, [tripType]);
1576
+ const isValidLocationValue = (value, placeholder) => {
1577
+ if (typeof value !== "string") return false;
1578
+ const trimmed = value.trim();
1579
+ return trimmed.length > 0 && trimmed !== placeholder;
1580
+ };
1581
+ const handleSegmentFieldChange = (index, field, value) => {
1582
+ setSegments((prev) => {
1583
+ const updated = [...prev];
1584
+ if (!updated[index]) return prev;
1585
+ updated[index] = { ...updated[index], [field]: value };
1586
+ if (field === "departureDate" && (tripType === "multi-city" || tripType === "custom-search") && value instanceof Date && !isNaN(value.getTime())) {
1587
+ for (let i = index + 1; i < updated.length; i += 1) {
1588
+ updated[i] = { ...updated[i], departureDate: value };
1589
+ }
1590
+ }
1591
+ return updated;
1592
+ });
1593
+ if (field === "origin" || field === "destination") {
1594
+ setSegmentDropdowns((prev) => ({
1595
+ ...prev,
1596
+ [index]: { ...prev[index], [field]: false }
1597
+ }));
1598
+ const placeholder = field === "origin" ? "Origin" : "Destination";
1599
+ if (isValidLocationValue(value, placeholder)) {
1600
+ setValidationErrors((prev) => ({
1601
+ ...prev,
1602
+ [index]: { ...prev[index] ?? {}, [field]: false }
1603
+ }));
1604
+ }
1605
+ }
1606
+ };
1607
+ const handleTravellerChange = (field, value) => {
1608
+ setSegments((prev) => {
1609
+ const updated = prev.map(
1610
+ (seg, i) => i === 0 ? { ...seg, [field]: value } : seg
1611
+ );
1612
+ return updated;
1613
+ });
1614
+ };
1615
+ const toggleSegmentDropdown = (index, field) => {
1616
+ setSegmentDropdowns((prev) => ({
1617
+ ...prev,
1618
+ [index]: {
1619
+ ...prev[index] || { origin: false, destination: false },
1620
+ [field]: !prev[index]?.[field]
1621
+ }
1622
+ }));
1623
+ };
1624
+ const addFlightSegment = () => {
1625
+ const maxSegments = getMaxSegments();
1626
+ if (segments.length < maxSegments) {
1627
+ const template = segments[0] ?? createDefaultSegment();
1628
+ setSegments((prev) => [
1629
+ ...prev,
1630
+ {
1631
+ origin: "Origin",
1632
+ destination: "Destination",
1633
+ departureDate: /* @__PURE__ */ new Date(),
1634
+ returnDate: null,
1635
+ dateRange: null,
1636
+ travelerClass: template.travelerClass,
1637
+ adultCount: template.adultCount,
1638
+ childCount: template.childCount,
1639
+ infantCount: template.infantCount
1640
+ }
1641
+ ]);
1642
+ }
1643
+ };
1644
+ const removeFlightSegment = (index) => {
1645
+ if (segments.length > 1) {
1646
+ setSegments((prev) => prev.filter((_, i) => i !== index));
1647
+ }
1648
+ };
1649
+ const extractAirportCode = (location) => {
1650
+ const match = location.match(/\(([A-Z]{3})\)/);
1651
+ return match ? match[1] : location;
1652
+ };
1653
+ const MONTH_NAMES = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
1654
+ const formatDate = (date) => {
1655
+ if (!date) return "";
1656
+ const day = String(date.getDate()).padStart(2, "0");
1657
+ const month = MONTH_NAMES[date.getMonth()];
1658
+ const year = date.getFullYear();
1659
+ return `${day}-${month}-${year}`;
1660
+ };
1661
+ const getTripTypeNumber = () => {
1662
+ switch (tripType) {
1663
+ case "one-way":
1664
+ return 1;
1665
+ case "round-trip":
1666
+ return 2;
1667
+ case "multi-city":
1668
+ return 3;
1669
+ case "custom-search":
1670
+ return 4;
1671
+ default:
1672
+ return 2;
1673
+ }
1674
+ };
1675
+ const getClassCode = (className) => {
1676
+ const classMap = {
1677
+ "Economy": "Y",
1678
+ "Business": "C",
1679
+ "First Class": "F",
1680
+ "Premium Economy": "W"
1681
+ };
1682
+ return classMap[className] || "Y";
1683
+ };
1684
+ const buildItineraryRequests = () => {
1685
+ const itineraryReqs = [];
1686
+ const firstSegment = segments[0];
1687
+ if (!firstSegment) return itineraryReqs;
1688
+ if (tripType === "one-way") {
1689
+ itineraryReqs.push({
1690
+ departureCode: extractAirportCode(firstSegment.origin),
1691
+ returnCode: extractAirportCode(firstSegment.destination),
1692
+ departureDate: formatDate(firstSegment.departureDate),
1693
+ class: getClassCode(firstSegment.travelerClass)
1694
+ });
1695
+ } else if (tripType === "round-trip") {
1696
+ itineraryReqs.push({
1697
+ departureCode: extractAirportCode(firstSegment.origin),
1698
+ returnCode: extractAirportCode(firstSegment.destination),
1699
+ departureDate: formatDate(firstSegment.departureDate),
1700
+ class: getClassCode(firstSegment.travelerClass)
1701
+ });
1702
+ const returnDate = firstSegment.dateRange?.[1] ?? firstSegment.returnDate ?? firstSegment.departureDate;
1703
+ itineraryReqs.push({
1704
+ departureCode: extractAirportCode(firstSegment.destination),
1705
+ returnCode: extractAirportCode(firstSegment.origin),
1706
+ departureDate: formatDate(returnDate),
1707
+ class: getClassCode(firstSegment.travelerClass)
1708
+ });
1709
+ } else if (tripType === "multi-city" || tripType === "custom-search") {
1710
+ segments.forEach((segment) => {
1711
+ itineraryReqs.push({
1712
+ departureCode: extractAirportCode(segment.origin),
1713
+ returnCode: extractAirportCode(segment.destination),
1714
+ departureDate: formatDate(segment.departureDate),
1715
+ class: getClassCode(segment.travelerClass)
1716
+ });
1717
+ });
1718
+ }
1719
+ return itineraryReqs;
1720
+ };
1721
+ const isBaggageOption = () => {
1722
+ return advancedOptions.isBaggage;
1723
+ };
1724
+ const getTripKey = () => {
1725
+ switch (tripType) {
1726
+ case "one-way":
1727
+ return "OW";
1728
+ case "round-trip":
1729
+ return "IRT";
1730
+ case "multi-city":
1731
+ return "NMC";
1732
+ case "custom-search":
1733
+ return "MC";
1734
+ default:
1735
+ return "OW";
1736
+ }
1737
+ };
1738
+ const isFlexiDateOption = () => {
1739
+ return advancedOptions.isFlexiDate;
1740
+ };
1741
+ const isUmrahFareOption = () => {
1742
+ return advancedOptions.isUmrah;
1743
+ };
1744
+ const createQueryString = () => {
1745
+ const queryStringObj = {};
1746
+ const itineraryReqs = buildItineraryRequests();
1747
+ let trip_index = 1;
1748
+ itineraryReqs.forEach((itineraryReqObj) => {
1749
+ queryStringObj[`dep${trip_index}`] = itineraryReqObj.departureCode;
1750
+ queryStringObj[`ret${trip_index}`] = itineraryReqObj.returnCode;
1751
+ queryStringObj[`dtt${trip_index}`] = itineraryReqObj.departureDate;
1752
+ queryStringObj[`cl${trip_index}`] = itineraryReqObj.class;
1753
+ trip_index++;
1754
+ });
1755
+ queryStringObj[`triptype`] = getTripTypeNumber();
1756
+ const firstSeg = segments[0];
1757
+ queryStringObj[`adult`] = firstSeg?.adultCount ?? 1;
1758
+ queryStringObj[`child`] = firstSeg?.childCount ?? 0;
1759
+ queryStringObj[`infant`] = firstSeg?.infantCount ?? 0;
1760
+ queryStringObj[`direct`] = advancedOptions.isDirectFlights;
1761
+ queryStringObj[`baggage`] = isBaggageOption();
1762
+ queryStringObj[`key`] = getTripKey();
1763
+ queryStringObj[`airlines`] = advancedOptions.preferredAirlineList.join(",") || "";
1764
+ queryStringObj[`ref`] = advancedOptions.isRefundable;
1765
+ queryStringObj[`lc`] = (langCode ?? "en").toUpperCase();
1766
+ queryStringObj[`curr`] = "AED";
1767
+ queryStringObj[`mgcc`] = "AE";
1768
+ queryStringObj["ipc"] = isFlexiDateOption();
1769
+ queryStringObj[`umrah`] = isUmrahFareOption();
1770
+ return queryStringObj;
1771
+ };
1772
+ const handleSearch = () => {
1773
+ const queryStringObj = createQueryString();
1774
+ console.log("Query String Object:", queryStringObj);
1775
+ console.log("Searching with:", formState, "domain:", redirectionDomain);
1776
+ const queryParams = new URLSearchParams();
1777
+ Object.keys(queryStringObj).forEach((key) => {
1778
+ const value = queryStringObj[key];
1779
+ if (key === "airlines" || key === "mgcc") {
1780
+ queryParams.append(key, value !== null && value !== void 0 ? String(value) : "");
1781
+ } else if (value !== null && value !== void 0 && value !== "") {
1782
+ queryParams.append(key, String(value));
1783
+ }
1784
+ });
1785
+ const ssoToken = buildEncryptedSsoUserToken(ssoUser);
1786
+ if (ssoToken) {
1787
+ queryParams.append("to", ssoToken);
1788
+ }
1789
+ const queryString = queryParams.toString();
1790
+ console.log("Query String:", queryString);
1791
+ if (redirectionDomain) {
1792
+ const url = `${redirectionDomain}/flight/listing?${queryString}`;
1793
+ window.open(url, "_blank");
1794
+ }
1795
+ };
1796
+ const handleSubmit = (e) => {
1797
+ e.preventDefault();
1798
+ const isMultiCityOrCustom = tripType === "multi-city" || tripType === "custom-search";
1799
+ const segmentsToValidate = isMultiCityOrCustom ? segments : segments.slice(0, 1);
1800
+ const nextErrors = {};
1801
+ segmentsToValidate.forEach((segment, index) => {
1802
+ const originInvalid = !isValidLocationValue(segment.origin, "Origin");
1803
+ const destinationInvalid = !isValidLocationValue(segment.destination, "Destination");
1804
+ if (originInvalid || destinationInvalid) {
1805
+ nextErrors[index] = {
1806
+ origin: originInvalid,
1807
+ destination: destinationInvalid
1808
+ };
1809
+ }
1810
+ });
1811
+ if (Object.keys(nextErrors).length > 0) {
1812
+ setValidationErrors(nextErrors);
1813
+ return;
1814
+ }
1815
+ handleSearch();
1816
+ };
1817
+ const renderAirportDropdown = (segmentIndex, dropdownType, dropdownRef, isOpen, onOpen) => {
1818
+ const isOrigin = dropdownType === "origin";
1819
+ const value = segments[segmentIndex]?.[dropdownType];
1820
+ const placeholder = isOrigin ? "Origin" : "Destination";
1821
+ const label = isOrigin ? "From" : "To";
1822
+ const list = isOrigin ? getPredictiveState(segmentIndex).fromAirport : getPredictiveState(segmentIndex).toAirport;
1823
+ const selectedIndex = isOrigin ? getPredictiveState(segmentIndex).selectedFromIndex : getPredictiveState(segmentIndex).selectedToIndex;
1824
+ return /* @__PURE__ */ jsxs("div", { className: `sw-form-field sw-pos-rel ${validationErrors[segmentIndex]?.[dropdownType] ? "sw-is-invalid" : ""}`, children: [
1825
+ /* @__PURE__ */ jsx("label", { htmlFor: `${dropdownType}-${segmentIndex}`, children: label }),
1826
+ /* @__PURE__ */ jsxs("div", { className: `sw-custom-dropdown ${validationErrors[segmentIndex]?.[dropdownType] ? "sw-has-error" : ""}`, ref: dropdownRef, children: [
1827
+ /* @__PURE__ */ jsx(
1828
+ "input",
1829
+ {
1830
+ type: "text",
1831
+ id: `${dropdownType}-${segmentIndex}`,
1832
+ className: `sw-custom-dropdown-trigger ${value === placeholder || !value ? "sw-placeholder" : ""}`,
1833
+ value: value === placeholder ? "" : value ?? "",
1834
+ placeholder,
1835
+ onFocus: onOpen,
1836
+ onChange: (e) => {
1837
+ const val = e.target.value;
1838
+ handleSegmentFieldChange(segmentIndex, dropdownType, val);
1839
+ triggerSearchAirport(segmentIndex, dropdownType, val);
1840
+ },
1841
+ onKeyDown: (e) => handleKeyDown(e, dropdownType, segmentIndex)
1842
+ }
1843
+ ),
1844
+ isOpen && /* @__PURE__ */ jsx("div", { className: "sw-dropdown", children: /* @__PURE__ */ jsx("ul", { className: "sw-dropdown-list", children: list.length > 0 ? list.map((airport, i) => /* @__PURE__ */ jsx("li", { className: `sw-dropdown-list-item ${selectedIndex === i ? "highlight" : ""}`, onClick: () => selectAirport(airport, dropdownType, segmentIndex), children: /* @__PURE__ */ jsxs("div", { className: "sw-dropdown-list-card", children: [
1845
+ /* @__PURE__ */ jsx("h6", { className: "sw-dropdown-item-badge sw-en-font", children: getAirportCode(airport) }),
1846
+ /* @__PURE__ */ jsxs("div", { children: [
1847
+ /* @__PURE__ */ jsx("h5", { className: "sw-fw500 sw-text-ellipsis", children: formatAirportDisplay(airport) }),
1848
+ /* @__PURE__ */ jsxs("h6", { className: "sw-text-label sw-text-ellipsis", children: [
1849
+ airport.ct,
1850
+ airport.cn ? `, ${airport.cn}` : ""
1851
+ ] })
1852
+ ] })
1853
+ ] }) }, airport.id ?? airport.ac ?? i)) : DEFAULT_AIRPORTS.map((airport, i) => /* @__PURE__ */ jsx("li", { className: "sw-dropdown-list-item ", onClick: () => selectAirport(airport, dropdownType, segmentIndex), children: /* @__PURE__ */ jsxs("div", { className: "sw-dropdown-list-card", children: [
1854
+ /* @__PURE__ */ jsx("h6", { className: "sw-dropdown-item-badge sw-en-font", children: getAirportCode(airport) }),
1855
+ /* @__PURE__ */ jsxs("div", { children: [
1856
+ /* @__PURE__ */ jsx("h5", { className: "sw-fw500 sw-text-ellipsis", children: formatAirportDisplay(airport) }),
1857
+ /* @__PURE__ */ jsxs("h6", { className: "sw-text-label sw-text-ellipsis", children: [
1858
+ airport.ct,
1859
+ airport.cn ? `, ${airport.cn}` : ""
1860
+ ] })
1861
+ ] })
1862
+ ] }) }, airport.ac ?? i)) }) })
1863
+ ] })
1864
+ ] });
1865
+ };
1866
+ const getMinDateForSegment = (index) => {
1867
+ const today = /* @__PURE__ */ new Date();
1868
+ if (index <= 0) return today;
1869
+ const prev = segments[index - 1]?.departureDate;
1870
+ if (prev instanceof Date && !isNaN(prev.getTime())) return prev;
1871
+ return today;
1872
+ };
1873
+ const renderFlightSegment = (index, segment, isMultiCityOrCustom) => {
1874
+ const canRemove = segments.length > 2 && index > 0 && isMultiCityOrCustom;
1875
+ const originRef = (el) => {
1876
+ if (!segmentRefs.current[index]) segmentRefs.current[index] = { origin: null, destination: null };
1877
+ segmentRefs.current[index].origin = el;
1878
+ };
1879
+ const destinationRef = (el) => {
1880
+ if (!segmentRefs.current[index]) segmentRefs.current[index] = { origin: null, destination: null };
1881
+ segmentRefs.current[index].destination = el;
1882
+ };
1883
+ const isOriginOpen = segmentDropdowns[index]?.origin ?? false;
1884
+ const isDestOpen = segmentDropdowns[index]?.destination ?? false;
1885
+ return /* @__PURE__ */ jsxs("div", { className: "sw-srh-wrap sw-srh-box", children: [
1886
+ renderAirportDropdown(index, "origin", originDropdownRef || originRef, isOriginOpen, () => toggleSegmentDropdown(index, "origin")),
1887
+ renderAirportDropdown(index, "destination", destinationDropdownRef || destinationRef, isDestOpen, () => toggleSegmentDropdown(index, "destination")),
1888
+ isMultiCityOrCustom && /* @__PURE__ */ jsx("div", { className: "sw-srh-wrap sw-pos-rel", children: /* @__PURE__ */ jsxs("div", { className: "sw-form-field sw-com-cal", children: [
1889
+ /* @__PURE__ */ jsx("label", { htmlFor: `departure-${index}`, children: "Departure" }),
1890
+ /* @__PURE__ */ jsx(
1891
+ Calendar,
1892
+ {
1893
+ numberOfMonths: 2,
1894
+ id: `departure-${index}`,
1895
+ appendTo: "self",
1896
+ value: segment.departureDate ?? null,
1897
+ onChange: (e) => {
1898
+ const raw = e.value;
1899
+ const nextDate = raw instanceof Date ? raw : typeof raw === "string" ? new Date(raw) : null;
1900
+ handleSegmentFieldChange(
1901
+ index,
1902
+ "departureDate",
1903
+ nextDate && !isNaN(nextDate.getTime()) ? nextDate : null
1904
+ );
1905
+ },
1906
+ dateFormat: "dd M yy",
1907
+ placeholder: "29 Jan 2026",
1908
+ className: "p-inputtext-sm",
1909
+ minDate: getMinDateForSegment(index)
1910
+ }
1911
+ )
1912
+ ] }) }),
1913
+ canRemove && /* @__PURE__ */ jsx("div", { className: "sw-srh-wrap", children: /* @__PURE__ */ jsx(
1914
+ "a",
1915
+ {
1916
+ type: "button",
1917
+ className: "sw-remove-segment",
1918
+ onClick: () => removeFlightSegment(index),
1919
+ children: /* @__PURE__ */ jsx("svg", { viewBox: "0 0 200 200", width: "35", height: "35", xmlns: "http://www.w3.org/2000/svg", role: "presentation", children: /* @__PURE__ */ jsx("path", { d: "M124.697 135.303L100 110.606l-24.697 24.697l-10.606-10.606L89.393 100L64.697 75.303l10.606-10.606L100 89.394l24.697-24.697l10.606 10.606L110.607 100l24.696 24.697z" }) })
1920
+ }
1921
+ ) })
1922
+ ] }, index);
1923
+ };
1924
+ return /* @__PURE__ */ jsx(PrimeReactProvider, { value: { hideOverlaysOnDocumentScrolling: false }, children: /* @__PURE__ */ jsx("div", { className: "tfsw-root sw-container", style: themeStyle, children: /* @__PURE__ */ jsxs("div", { className: "sw-card-box", children: [
1925
+ /* @__PURE__ */ jsx("div", { className: "sw-srh-main-head", children: /* @__PURE__ */ jsx("div", { className: "sw-srh-head", children: /* @__PURE__ */ jsx("div", { className: "sw-srh-round-text", children: [
1926
+ { value: "round-trip", label: "Round-trip" },
1927
+ { value: "one-way", label: "One-way" },
1928
+ { value: "custom-search", label: "Custom Search" },
1929
+ { value: "multi-city", label: "Multi-city" }
1930
+ ].map((option) => /* @__PURE__ */ jsxs("label", { className: "sw-tab-checkbox", children: [
1931
+ /* @__PURE__ */ jsx(
1932
+ "input",
1933
+ {
1934
+ type: "radio",
1935
+ name: "trip",
1936
+ value: option.value,
1937
+ checked: tripType === option.value,
1938
+ onChange: (e) => setTripType(e.target.value)
1939
+ }
1940
+ ),
1941
+ /* @__PURE__ */ jsx("h5", { className: "sw-tab-content", children: option.label })
1942
+ ] }, option.value)) }) }) }),
1943
+ /* @__PURE__ */ jsxs("form", { className: `sw-srh-grid ${tripType === "multi-city" || tripType === "custom-search" ? "sw-srh-mc" : ""}`, onSubmit: handleSubmit, children: [
1944
+ tripType === "multi-city" || tripType === "custom-search" ? segments.map((segment, index) => renderFlightSegment(index, segment, true)) : /* @__PURE__ */ jsxs("div", { className: "sw-srh-wrap sw-srh-box", children: [
1945
+ renderAirportDropdown(0, "origin", originDropdownRef, isOriginDropdownOpen, () => setIsOriginDropdownOpen(true)),
1946
+ renderAirportDropdown(0, "destination", destinationDropdownRef, isDestinationDropdownOpen, () => setIsDestinationDropdownOpen(true))
1947
+ ] }),
1948
+ (tripType === "round-trip" || tripType === "one-way") && /* @__PURE__ */ jsx("div", { className: "sw-srh-wrap sw-pos-rel ", children: tripType === "round-trip" ? /* @__PURE__ */ jsxs(Fragment, { children: [
1949
+ /* @__PURE__ */ jsxs("div", { style: { cursor: "pointer" }, onClick: () => dateRangeCalendarRef.current?.show?.(), className: "sw-form-field sw-com-cal", children: [
1950
+ /* @__PURE__ */ jsxs("div", { children: [
1951
+ /* @__PURE__ */ jsx("label", { children: "Departure" }),
1952
+ /* @__PURE__ */ jsx("p", { children: segments[0]?.dateRange?.[0]?.toLocaleDateString("en-GB", { day: "2-digit", month: "short", year: "numeric" }) })
1953
+ ] }),
1954
+ /* @__PURE__ */ jsx(
1955
+ Calendar,
1956
+ {
1957
+ numberOfMonths: 2,
1958
+ ref: dateRangeCalendarRef,
1959
+ id: "dateRange",
1960
+ appendTo: "self",
1961
+ selectionMode: "range",
1962
+ value: segments[0]?.dateRange ?? null,
1963
+ minDate: /* @__PURE__ */ new Date(),
1964
+ onChange: (e) => {
1965
+ const range = e.value;
1966
+ setSegments((prev) => {
1967
+ const u = [...prev];
1968
+ if (!u[0]) return prev;
1969
+ u[0] = {
1970
+ ...u[0],
1971
+ dateRange: range,
1972
+ departureDate: range?.[0] ?? /* @__PURE__ */ new Date(),
1973
+ returnDate: range?.[1] ?? /* @__PURE__ */ new Date()
1974
+ };
1975
+ return u;
1976
+ });
1977
+ if (range?.[0] && range?.[1]) setTimeout(() => {
1978
+ dateRangeCalendarRef.current?.hide?.();
1979
+ }, 150);
1980
+ },
1981
+ dateFormat: "dd M yy",
1982
+ placeholder: "Select date range",
1983
+ className: "p-inputtext-sm tfsw-calendar-input"
1984
+ }
1985
+ )
1986
+ ] }),
1987
+ /* @__PURE__ */ jsx("div", { style: { cursor: "pointer" }, className: "sw-form-field sw-com-cal", onClick: () => dateRangeCalendarRef.current?.show?.(), children: /* @__PURE__ */ jsxs("div", { children: [
1988
+ /* @__PURE__ */ jsx("label", { children: "Return" }),
1989
+ /* @__PURE__ */ jsx("p", { children: (segments[0]?.dateRange?.[1] ?? segments[0]?.dateRange?.[0])?.toLocaleDateString("en-GB", { day: "2-digit", month: "short", year: "numeric" }) })
1990
+ ] }) })
1991
+ ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
1992
+ /* @__PURE__ */ jsxs(
1993
+ "div",
1994
+ {
1995
+ className: "sw-form-field sw-pos-rel sw-com-cal",
1996
+ style: { cursor: "pointer" },
1997
+ onClick: () => segmentCalendarRefs.current[0]?.show?.(),
1998
+ children: [
1999
+ /* @__PURE__ */ jsx("label", { children: "Departure" }),
2000
+ /* @__PURE__ */ jsx("p", { children: formatDisplayDate(segments[0]?.departureDate) }),
2001
+ /* @__PURE__ */ jsx(
2002
+ Calendar,
2003
+ {
2004
+ numberOfMonths: 2,
2005
+ ref: (el) => {
2006
+ segmentCalendarRefs.current[0] = el;
2007
+ },
2008
+ value: segments[0]?.departureDate ?? null,
2009
+ onChange: (e) => {
2010
+ const raw = e.value;
2011
+ const nextDate = raw instanceof Date ? raw : typeof raw === "string" ? new Date(raw) : null;
2012
+ handleSegmentFieldChange(
2013
+ 0,
2014
+ "departureDate",
2015
+ nextDate && !isNaN(nextDate.getTime()) ? nextDate : null
2016
+ );
2017
+ },
2018
+ appendTo: "self",
2019
+ minDate: /* @__PURE__ */ new Date(),
2020
+ dateFormat: "dd M yy",
2021
+ className: "p-inputtext-sm tfsw-calendar-input"
2022
+ }
2023
+ )
2024
+ ]
2025
+ }
2026
+ ),
2027
+ /* @__PURE__ */ jsx("div", { className: "sw-form-field sw-pos-rel sw-com-cal sw-add-return-label", style: { cursor: "pointer" }, onClick: () => {
2028
+ setTripType("round-trip");
2029
+ setTimeout(() => document.getElementById("dateRange")?.querySelector("input")?.focus?.(), 100);
2030
+ }, children: /* @__PURE__ */ jsx("label", { children: "Add return" }) })
2031
+ ] }) }),
2032
+ (tripType === "multi-city" || tripType === "custom-search") && /* @__PURE__ */ jsx("div", { className: "sw-srh-mc-foot", children: segments.length < getMaxSegments() && /* @__PURE__ */ jsxs("button", { type: "button", className: "sw-srh-add-btn", onClick: addFlightSegment, children: [
2033
+ /* @__PURE__ */ jsxs("svg", { width: "14", height: "14", viewBox: "0 0 16 16", xmlns: "http://www.w3.org/2000/svg", children: [
2034
+ /* @__PURE__ */ jsx("path", { fill: "none", d: "M0 0h16v16H0z" }),
2035
+ /* @__PURE__ */ jsx("path", { d: "M15 7H9V1H7v6H1v2h6v6h2V9h6z" })
2036
+ ] }),
2037
+ "Add Another Flight"
2038
+ ] }) }),
2039
+ /* @__PURE__ */ jsxs("div", { className: "sw-form-field sw-traveller sw-pos-rel", children: [
2040
+ /* @__PURE__ */ jsx("label", { htmlFor: "rooms", children: "Travellers and Class" }),
2041
+ /* @__PURE__ */ jsxs("div", { className: "sw-custom-dropdown", ref: roomsGuestsMenuRef, children: [
2042
+ /* @__PURE__ */ jsx(
2043
+ "div",
2044
+ {
2045
+ className: "sw-custom-dropdown-trigger",
2046
+ onClick: () => setIsRoomsGuestsMenuOpen(!isRoomsGuestsMenuOpen),
2047
+ children: /* @__PURE__ */ jsxs("span", { children: [
2048
+ (segments[0]?.adultCount ?? 0) + (segments[0]?.childCount ?? 0) + (segments[0]?.infantCount ?? 0),
2049
+ " Traveller",
2050
+ (segments[0]?.adultCount ?? 0) + (segments[0]?.childCount ?? 0) + (segments[0]?.infantCount ?? 0) !== 1 ? "s" : "",
2051
+ ", ",
2052
+ segments[0]?.travelerClass ?? "Economy"
2053
+ ] })
2054
+ }
2055
+ ),
2056
+ isRoomsGuestsMenuOpen && /* @__PURE__ */ jsxs("div", { className: "sw-rooms-guests-menu", children: [
2057
+ /* @__PURE__ */ jsx("h3", { className: "sw-rooms-guests-title", children: "Number of Travellers" }),
2058
+ /* @__PURE__ */ jsxs("div", { className: "sw-srh-pax", children: [
2059
+ /* @__PURE__ */ jsxs("div", { className: "sw-srh-common-adult", children: [
2060
+ /* @__PURE__ */ jsx("h3", { children: "Adults" }),
2061
+ /* @__PURE__ */ jsx("p", { children: "Age (12+)" })
2062
+ ] }),
2063
+ /* @__PURE__ */ jsx("div", { className: "sw-srh-button-wrapper", children: [1, 2, 3, 4, 5, 6, 7, 8, 9].map((count) => {
2064
+ const childCount = segments[0]?.childCount ?? 0;
2065
+ const infantCount = segments[0]?.infantCount ?? 0;
2066
+ const isDisabled = count + childCount > 9;
2067
+ return /* @__PURE__ */ jsx(
2068
+ "button",
2069
+ {
2070
+ type: "button",
2071
+ className: `sw-en-font ${(segments[0]?.adultCount ?? 0) === count ? "sw-active-button" : ""} ${isDisabled ? "disabled" : ""}`,
2072
+ disabled: isDisabled,
2073
+ onClick: () => {
2074
+ const newChildCount = Math.min(childCount, 9 - count);
2075
+ setSegments((prev) => {
2076
+ const updated = [...prev];
2077
+ if (!updated[0]) return prev;
2078
+ updated[0] = {
2079
+ ...updated[0],
2080
+ adultCount: count,
2081
+ childCount: newChildCount,
2082
+ infantCount: Math.min(infantCount, count)
2083
+ };
2084
+ return updated;
2085
+ });
2086
+ },
2087
+ children: count
2088
+ },
2089
+ count
2090
+ );
2091
+ }) })
2092
+ ] }),
2093
+ /* @__PURE__ */ jsxs("div", { className: "sw-srh-pax", children: [
2094
+ /* @__PURE__ */ jsxs("div", { className: "sw-srh-common-adult", children: [
2095
+ /* @__PURE__ */ jsx("h3", { children: "Child" }),
2096
+ /* @__PURE__ */ jsx("p", { children: "Age (2-11)" })
2097
+ ] }),
2098
+ /* @__PURE__ */ jsx("div", { className: "sw-srh-button-wrapper", children: [0, 1, 2, 3, 4, 5, 6, 7, 8].map((count) => {
2099
+ const adultCount = segments[0]?.adultCount ?? 0;
2100
+ const isDisabled = adultCount + count > 9;
2101
+ return /* @__PURE__ */ jsx(
2102
+ "button",
2103
+ {
2104
+ type: "button",
2105
+ className: `sw-en-font ${(segments[0]?.childCount ?? 0) === count ? "sw-active-button" : ""} ${isDisabled ? "disabled" : ""}`,
2106
+ disabled: isDisabled,
2107
+ onClick: () => handleTravellerChange("childCount", count),
2108
+ children: count
2109
+ },
2110
+ count
2111
+ );
2112
+ }) })
2113
+ ] }),
2114
+ /* @__PURE__ */ jsxs("div", { className: "sw-srh-pax", children: [
2115
+ /* @__PURE__ */ jsxs("div", { className: "sw-srh-common-adult", children: [
2116
+ /* @__PURE__ */ jsx("h3", { children: "Infant" }),
2117
+ /* @__PURE__ */ jsx("p", { children: "Under 2 years" })
2118
+ ] }),
2119
+ /* @__PURE__ */ jsx("div", { className: "sw-srh-button-wrapper", children: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9].map((count) => {
2120
+ const adultCount = segments[0]?.adultCount ?? 0;
2121
+ const isDisabled = count > adultCount;
2122
+ return /* @__PURE__ */ jsx(
2123
+ "button",
2124
+ {
2125
+ type: "button",
2126
+ className: `sw-en-font ${(segments[0]?.infantCount ?? 0) === count ? "sw-active-button" : ""} ${isDisabled ? "disabled" : ""}`,
2127
+ disabled: isDisabled,
2128
+ onClick: () => handleTravellerChange("infantCount", count),
2129
+ children: count
2130
+ },
2131
+ count
2132
+ );
2133
+ }) })
2134
+ ] }),
2135
+ /* @__PURE__ */ jsx("h3", { className: "sw-rooms-guests-title", children: "Travel Class" }),
2136
+ /* @__PURE__ */ jsx("div", { className: "sw-srh-class", children: ["Economy", "Business", "First Class", "Premium Economy"].map((classOption) => /* @__PURE__ */ jsxs("label", { className: "sw-tab-checkbox", children: [
2137
+ /* @__PURE__ */ jsx(
2138
+ "input",
2139
+ {
2140
+ type: "radio",
2141
+ name: "travel-class",
2142
+ checked: (segments[0]?.travelerClass ?? "Economy") === classOption,
2143
+ onChange: () => handleTravellerChange("travelerClass", classOption)
2144
+ }
2145
+ ),
2146
+ /* @__PURE__ */ jsx("span", { className: "sw-tab-content", children: classOption })
2147
+ ] }, classOption)) }),
2148
+ /* @__PURE__ */ jsxs("div", { className: "sw-rooms-guests-footer", children: [
2149
+ /* @__PURE__ */ jsx("div", {}),
2150
+ /* @__PURE__ */ jsxs("div", { className: "sw-rooms-guests-cta", children: [
2151
+ /* @__PURE__ */ jsx(
2152
+ "button",
2153
+ {
2154
+ type: "button",
2155
+ className: "sw-reset-button",
2156
+ onClick: () => {
2157
+ setSegments((prev) => {
2158
+ const updated = [...prev];
2159
+ if (!updated[0]) return prev;
2160
+ updated[0] = { ...updated[0], adultCount: 1, childCount: 0, infantCount: 0, travelerClass: "Economy" };
2161
+ return updated;
2162
+ });
2163
+ },
2164
+ children: "Reset"
2165
+ }
2166
+ ),
2167
+ /* @__PURE__ */ jsx(
2168
+ "button",
2169
+ {
2170
+ type: "button",
2171
+ className: "sw-apply-button",
2172
+ onClick: () => setIsRoomsGuestsMenuOpen(false),
2173
+ children: "Apply"
2174
+ }
2175
+ )
2176
+ ] })
2177
+ ] })
2178
+ ] })
2179
+ ] })
2180
+ ] }),
2181
+ /* @__PURE__ */ jsxs("button", { type: "submit", className: "sw-search-button", children: [
2182
+ /* @__PURE__ */ jsx("span", { className: "pi pi-search", "aria-hidden": "true" }),
2183
+ "Search"
2184
+ ] })
2185
+ ] }),
2186
+ /* @__PURE__ */ jsx("div", { className: "sw-advanced-search-options", children: /* @__PURE__ */ jsx(Accordion, { children: /* @__PURE__ */ jsx(AccordionTab, { header: "Advanced Search options", children: /* @__PURE__ */ jsxs("div", { className: "sw-fsrh-adv-cont", children: [
2187
+ /* @__PURE__ */ jsx(
2188
+ AutoComplete,
2189
+ {
2190
+ value: selectedAirlines,
2191
+ suggestions: airlineSuggestions,
2192
+ completeMethod: (e) => {
2193
+ const query = e.query ?? "";
2194
+ setAirlineQuery(query);
2195
+ triggerSearchAirline(query);
2196
+ },
2197
+ onChange: (e) => {
2198
+ const next = e.value ?? [];
2199
+ setSelectedAirlines(next);
2200
+ setAdvancedOptions((prev) => ({
2201
+ ...prev,
2202
+ preferredAirlineList: next.map((item) => item.airline_code)
2203
+ }));
2204
+ },
2205
+ field: "airline_name",
2206
+ multiple: true,
2207
+ forceSelection: true,
2208
+ placeholder: "Preferred airline"
2209
+ }
2210
+ ),
2211
+ /* @__PURE__ */ jsxs("div", { className: "sw-fsrh-chk-main", children: [
2212
+ /* @__PURE__ */ jsxs("label", { className: "sw-material-checkbox", children: [
2213
+ /* @__PURE__ */ jsx(
2214
+ "input",
2215
+ {
2216
+ type: "checkbox",
2217
+ checked: advancedOptions.isRefundable,
2218
+ onChange: (e) => setAdvancedOptions((prev) => ({ ...prev, isRefundable: e.target.checked }))
2219
+ }
2220
+ ),
2221
+ /* @__PURE__ */ jsx("span", { className: "sw-checkmark" }),
2222
+ "Refundable"
2223
+ ] }),
2224
+ /* @__PURE__ */ jsxs("label", { className: "sw-material-checkbox", children: [
2225
+ /* @__PURE__ */ jsx(
2226
+ "input",
2227
+ {
2228
+ type: "checkbox",
2229
+ checked: advancedOptions.isBaggage,
2230
+ onChange: (e) => setAdvancedOptions((prev) => ({ ...prev, isBaggage: e.target.checked }))
2231
+ }
2232
+ ),
2233
+ /* @__PURE__ */ jsx("span", { className: "sw-checkmark" }),
2234
+ "Baggage only"
2235
+ ] }),
2236
+ /* @__PURE__ */ jsxs("label", { className: "sw-material-checkbox", children: [
2237
+ /* @__PURE__ */ jsx(
2238
+ "input",
2239
+ {
2240
+ type: "checkbox",
2241
+ checked: advancedOptions.isDirectFlights,
2242
+ onChange: (e) => setAdvancedOptions((prev) => ({ ...prev, isDirectFlights: e.target.checked }))
2243
+ }
2244
+ ),
2245
+ /* @__PURE__ */ jsx("span", { className: "sw-checkmark" }),
2246
+ "Direct Flights"
2247
+ ] })
2248
+ ] })
2249
+ ] }) }) }) })
2250
+ ] }) }) });
2251
+ }
2252
+ export {
2253
+ FlightSearchWidget
2254
+ };
2255
+ //# sourceMappingURL=index.mjs.map