import{ah as c,aX as F,a3 as I,af as G,aY as Y,aZ as y,q as _,I as h,y as D,aV as b,a_ as g,a$ as A,b0 as N,am as w,b1 as C,ag as k,a6 as m,v as U}from"./CEc7q5EE.js";import{u as x,D as L}from"./xRw9TWGb.js";import{u as v}from"./N0VBYgb3.js";const P="YYYY-MM-DD",Z="ALL",tt=99,et=0,O=t=>c(t).format(P),st=t=>({airport:F[t].airport,date:c().add(2,"day").format(P),duration:7,categories:1,Adults_0:2,Children_0:0});function at(t){return t?typeof t=="string"?c(t).isValid():"min"in t&&"max"in t?c(t.min).isValid()&&c(t.max).isValid():!1:!1}const H=(t,s,o)=>{const i={...o};if(t.lastminute){const e=t.selectedDateRangeStartDate||c();i.departureDate={min:O(e),max:O(c(e).add(10,"days"))}}else if(t.selectedDateRangeDuration)i.departureDate=O(t.selectedDateRangeStartDate);else{if(!t.selectedDateRangeStartDate||!t.selectedDateRangeEndDate)return o;i.departureDate=O(t.selectedDateRangeStartDate),i.homeDate=O(t.selectedDateRangeEndDate)}return i},$=(t,s,o)=>{const i={...o};if(t.lastminute)return i.tripLength={min:7,max:9},i;if(t.selectedDateRangeDuration)return t.selectedDateRangeDuration.value==="custom"?i.tripLength={min:t.selectedDateRangeDuration.custom[0],max:t.selectedDateRangeDuration.custom[1]}:i.tripLength={min:t.selectedDateRangeDuration,max:t.selectedDateRangeDuration+2},i;throw new Error("getSearchOptions: Duration missing")},j=(t,s,o,i)=>{const e={...o};if(t.filters.boards&&(e.board=t.filters.boards[5-t.filterBoard]),s!=null&&s.supplier&&(e.supplier=s.supplier),s!=null&&s.hotel_code&&(e.hotel_code=s.hotel_code),t!=null&&t.filterText&&t.filterText.length>0&&(e.text=t.filterText),t!=null&&t.filterTemperature&&(i!=null&&i.getTemperatureRange)&&!(i!=null&&i.temperatureRangeIsDefault)&&(e.temperature=i.getTemperatureRange),s!=null&&s.airport||t.selectedAirport)e.airport=s.airport||t.selectedAirport.airport;else throw new Error("getSearchOptions: Airport missing");return s!=null&&s.charterTags&&(e.charterTags=s.charterTags),e},B=(t,s,o)=>{const i={...o};return i.destinations=[...new Set(((s==null?void 0:s.selectedDestinations)||t.selectedDestinations||[]).concat(((s==null?void 0:s.selectedDestinationsL1)||t.selectedDestinationsL1).flatMap(e=>t.destinations.filter(a=>e===a.country&&a.visible))).filter(e=>!!e).map(e=>e==null?void 0:e.destination_id).filter(Boolean))],i},it=t=>{const{localeDateFormats:s}=x(),{destinations:o,countries:i,categories:e,date:a,date_end:r,duration:l}=t,n=u=>c(u,s.L,!0).isValid();return["Adults_0","airport","date"].every(u=>t[u])&&(o||i||e)&&n(a)&&(r&&n(r)||l)},J=t=>t.map(({ChildAges:s,...o})=>{const i=s.filter(e=>!I(e));return{...o,Children:i.length,ChildAges:i}}),ot=(t,s={},o={})=>{let i={rooms:J(t.rooms),rating:t.filterRating,tripadvisor:t.filterTripadvisor,tags:t.filterTags,charterTags:t.filterCharterTags,sort:t.sortBy,stopOver:{max:t.filterStopover}};return i=H(t,s,i),(t.lastminute||t.selectedDateRangeDuration)&&(i=$(t,s,i)),i=j(t,s,i,o),i=B(t,s,i),i},rt=(t,s,o)=>{o!=null&&o!==""&&t.push(`${s}=${o}`)},nt=(t,{selectedDuration:s})=>{var e;if(!(s!=null&&s.value))return;const o=s.custom&&s.custom.length===2&&s.custom.every(a=>!isNaN(parseInt(a))&&parseInt(a)>0);if((s.value==="custom"||((e=s.value)==null?void 0:e.value)==="custom")&&o)return s.custom;const i=+s.value.value;return t.durations.some(a=>a.value===i)?i:`${i},${s.max}`},lt=(t,s)=>{if(s.selectedDestinations.length===t.destinations.length)return"all";{const o=[];return s.selectedDestinationsL1.forEach(i=>{o.push(i),s.selectedDestinations=s.selectedDestinations.filter(e=>e.country!==i)}),{countries:o.join(","),destinations:s.selectedDestinations.map(i=>i==null?void 0:i.destination_id).filter(Boolean).join(",")}}},ct=t=>t.map(({id:s})=>s).join(","),V={Adults:0,Children:0,ChildAges:[]},K=t=>{const s=[];return t.rooms.forEach((o,i)=>{s.push({key:`Adults_${i}`,value:o.Adults}),s.push({key:`Children_${i}`,value:o.Children}),o.Children>0&&s.push({key:`ChildAges_${i}`,value:o.ChildAges.filter(e=>!I(e)).join(",")})}),s},q=t=>K(t).map(({key:s,value:o})=>`${s}=${o}`),dt=t=>{if(!t.Adults_0)return null;const s=[],o=(i,e)=>i==="ChildAges"?e.split(",").filter(Boolean).map(a=>parseInt(a)||0):parseInt(e)||0;return Object.keys(t).filter(i=>i.match(/Adults_|Children_|ChildAges_/)).map(i=>i.match(/(\w+)_(\d+)/)).forEach(([i,e,a])=>{s[a]={...s[a]||V,[e]:o(e,t[i])}}),s},ht=t=>!(t||[]).every(s=>((s==null?void 0:s.ChildAges)||[]).every(o=>!Number.isNaN(o)&&o!==null)),_t=t=>{const s=(t||[]).map(e=>({...e,ChildAges:((e==null?void 0:e.ChildAges)||[]).filter(a=>!I(a))})),o=e=>isNaN(e)?e.ChildAge:e,i=e=>e.map(o).filter(a=>a<=1).length;return{adults:s.reduce((e,{Adults:a})=>e+a,0)||0,children:s.reduce((e,{ChildAges:a})=>e+a.length,0)||0,infants:s.reduce((e,{ChildAges:a})=>e+i(a),0)||0,rooms:s.length}},W=t=>(t==null?void 0:t.start_date)||(t==null?void 0:t.end_date),St=t=>!!t&&!W(t),M=G("book",{state:()=>({stateObjects:[],tripinfo:null,roomtypes:null,hotelOptions:{},bookinfo:null,activeStep:-1,highestStep:-1,isRoundtrip:!0,showWaitinglist:!1,modalRoomTypes:[],error:null,customerDataError:null,isFullCustomerData:!1,priceIncrease:0,numberOfPeople:null,rooms:null,selectedAirport:null,selectedRoomGroup:{},selectedRooms:[],timeout:30*1e3,travelers:[],manager:null,luggageCost:0}),persist:{paths:["activeStep","stateObjects","tripinfo","bookinfo","roomtypes","hotelOptions","numberOfPeople","isRoundtrip","luggageCost","travelers","manager","rooms","step","isFullCustomerData","customerDataError"],appendPathsToKey:!0,storage:Y.localStorageWithExpiration({expiration:y.hour})},getters:{transferOptionArrivalSelectedObject(t){var s,o;return(o=(s=t.tripinfo)==null?void 0:s.transfer_options_arrival)==null?void 0:o.find(i=>i.rateKey===t.tripinfo.transfer_option_arrival_selected)},transferOptionReturnSelectedObject(t){var s,o;return(o=(s=t.tripinfo)==null?void 0:s.transfer_options_return)==null?void 0:o.find(i=>i.rateKey===t.tripinfo.transfer_option_return_selected)}},actions:{RESET_STATEOBJECT(){this.stateObjects=[]},SET_STATEOBJECTS(t){this.stateObjects=t},SET_STATEOBJECT({stateObject:t,step:s,clear:o}){this.stateObjects[s]=t,o&&this.stateObjects.splice(s+1)},SET_STEP(t){this.activeStep=t,this.highestStep=t===0||this.highestStep<t?t:this.highestStep},SET_HIGHESTSTEP(t){this.highestStep=t===0||this.highestStep<t?t:this.highestStep},SET_TRIPINFO(t){this.tripinfo=t},SET_BOOKINFO(t){this.bookinfo=t},SET_ROOMTYPES(t){this.roomtypes=t},SET_HOTELOPTIONS({hotels:t,minimumPrice:s,recommended:o}){if(!(t!=null&&t.length))return;const i={...this.hotelOptions};i.recommended=o,i.minimumPrice=s,i.hotels=t.filter(e=>{var a;return!!((a=e.meta)!=null&&a.Rating)}),this.hotelOptions=i},RESET_HOTELOPTIONS(){this.hotelOptions={}},SET_ROOMS(t){this.rooms=t},SET_NUMBEROFPEOPLE(t){this.numberOfPeople=t},SET_ROOMGROUP(t){this.selectedRoomGroup=t},SET_SELECTED_ROOMS(t){this.selectedRooms=t},SET_TIMEOUT(t){this.timeout=t*1e3},SET_TRAVELERS(t){this.travelers=t},SET_MANAGER(t){this.manager=t},SET_ERROR(t){this.error=t},SET_CUSTOMER_DATA_ERROR(t){this.customerDataError=t},SET_PRICEINCREASE(t){this.priceIncrease=t},SET_LUGGAGECOST(t){this.luggageCost=t},SET_ISROUNDTRIP(t){this.isRoundtrip=t},SET_SELECTED_AIRPORT(t){this.selectedAirport=t},SET_SHOWWAITINGLIST(t){this.showWaitinglist=t},SET_MODALROOMTYPES(t){this.modalRoomTypes=t},async getDataFromSSN({ssn:t,f:s}){const i=_().locale;let e="";s&&(e+="&f=1");const{data:a}=await h(`/${i}/booking/pnum?p=${t}${e}`);return a},async getDataFromPhone(t){const s=_(),o=D(),i=s.locale;if(!t||!o.showOfficeTools)return;const{data:e}=await h(`/${i}/reseller/customer-data-from-tel/${o.agentCookie.code}/${t}`);return e},async init({tripid:t,initialPrice:s,singlePrice:o}){const i=_(),e=D(),a=i.locale;this.SET_STEP(-1),this.SET_ISROUNDTRIP(!0),this.isFullCustomerData=!1,this.SET_CUSTOMER_DATA_ERROR(null),this.RESET_STATEOBJECT(),this.SET_TRAVELERS([]),this.SET_ROOMS(this.rooms?this.rooms:null),this.SET_ROOMGROUP({}),this.SET_MANAGER(null),this.SET_LUGGAGECOST(0),this.SET_NUMBEROFPEOPLE(null),this.SET_BOOKINFO(null),this.RESET_HOTELOPTIONS();try{localStorage.removeItem(b.extraLuggage)}catch{}const{data:r}=await h(`/${a}/booking/new-booking/${t}/${s||""}${o?`/${o}`:""}`);return this.SET_STATEOBJECT({stateObject:r.state,step:0}),this.SET_TRIPINFO({tripid:t,triptypeid:r.triptypeid,tripdate:r.tripdate,tripname:r.tripname,returndate:r.returndate,maxpax:r.maxpax,roomstypes_needed:r.roomstypes_needed,dynamic_flights:r.dynamic_flights,image:r.main_picture_cloudinary}),this.SET_STEP(0),r.dynamic_flights&&await e.fetchCharterAirports(),this.SET_TIMEOUT(r.bprocess_timeout),await e.fetchAgentCall({}),r},async roomTypes(t){var r,l;const s=_(),o=p(),i=D(),e=s.locale;t.state=this.stateObjects[0];let a;try{const{data:n}=await h(`/${e}/booking/roomtypes`,{method:"post",signal:g(this.timeout),body:t});if(a=n,a.require_property_list){const{data:d}=await h(`/${e}/charter/property_list`,{method:"post",body:{state:a.state,flight_offer_id:a.flight_offer_id}});this.SET_TRIPINFO({...this.tripinfo,hoteltype_needed:!0,priceChangedSinceStartUpdated:d.priceChangedSinceStart}),d.property_list.length&&(this.SET_HOTELOPTIONS({id:d.flight_offer_id,recommended:d.recommended_properties,minimumPrice:d.minimum_package_price,hotels:d.property_list}),a.state=d.state)}}catch(n){throw((r=n.data)==null?void 0:r.message)==="state_expired"&&o.SET_TIMEDOUT(!0),(l=n.data)!=null&&l.waitinglist&&this.SET_SHOWWAITINGLIST(n.data.message),n}if(a.airport_dictionary){const n={};a.airport_dictionary.forEach(d=>{n[d.iata]=d}),i.SET_CHARTER_AIRPORT_NAMES(n)}return this.SET_STATEOBJECT({stateObject:a.state,step:1}),this.SET_TRIPINFO({...this.tripinfo,flightOffer:a.flightOffer,luggage_policies:a.luggage_policies,pricing:a.pricing,price:a.price,priceInfo:a.price_info,priceBase:a.price,roomtypes_grouped_per_room:a.roomtypes_grouped_per_room,priceChangedSinceStart:a.inital_price_changed,pax_exception_codes:a.pax_exception_codes,airport:a.airport,selected_rooms:a.selected_rooms}),this.SET_ROOMTYPES(a.rooms),this.SET_SELECTED_ROOMS([]),this.SET_ROOMGROUP({}),this.SET_NUMBEROFPEOPLE(null),this.SET_STEP(1),a},async roomData(t){const o=_().locale;t.state=this.stateObjects[1]||this.stateObjects[0];const{data:i,error:e}=await h(`/${o}/booking/roomtypes-for-hotel`,{method:"post",throwOnFail:!1,signal:g(this.timeout),body:t});return e?(this.SET_MODALROOMTYPES(i==null?void 0:i.roomtypes),this.SET_STATEOBJECT({stateObject:t.state,step:1})):(this.SET_MODALROOMTYPES(i.roomtypes),this.SET_STATEOBJECT({stateObject:i.state,step:1})),i},async hotelInfo(t){const o=_().locale,{data:i}=await h(`/${o}/booking/property-info/${t}`,{signal:g(this.timeout)});return i},async customerData(t,s){var l;const o=_(),i=p(),e=o.locale;t.state&&this.SET_STATEOBJECT({stateObject:t.state,step:1}),t.state=this.stateObjects[1]||this.stateObjects[0],window.customerDataAbortController&&window.customerDataAbortController.abort(),!s&&window.preCustomerDataAbortController&&window.preCustomerDataAbortController.abort();let a;if(s){window.customerDataAbortController=new AbortController,A(window.customerDataAbortController,y.fourMinutes);try{const{data:n}=await h(`/${e}/booking/customer-data`,{method:"POST",signal:window.customerDataAbortController.signal,body:t});a=n}catch(n){this.isFullCustomerData=!0,this.SET_CUSTOMER_DATA_ERROR(n);return}this.isFullCustomerData=!0}else{window.preCustomerDataAbortController=new AbortController,this.SET_CUSTOMER_DATA_ERROR(null),this.isFullCustomerData=!1,this.customerData(t,!0);try{const{data:n}=await h(`/${e}/booking/pre-customer-data`,{method:"post",signal:window.preCustomerDataAbortController.signal,body:t});if(this.isFullCustomerData)return;a=n}catch(n){throw((l=n.data)==null?void 0:l.message)==="state_expired"&&i.SET_TIMEDOUT(!0),n}}let r={};return a.tripid&&(r={server_tripid:a.tripid,tripdate:a.tripdate,tripname:a.tripname,pricing:a.pricing,price:a.price,returndate:a.returndate}),a.priceInfo&&(r.priceInfo=a.priceInfo),a.numpax?this.SET_NUMBEROFPEOPLE(a.numpax):this.SET_NUMBEROFPEOPLE(null),this.SET_TRAVELERS([]),this.SET_STATEOBJECT({stateObject:a.state,step:2,clear:!0}),this.SET_TRIPINFO({...this.tripinfo,...r,flightOffer:a.flightOffer,luggage_policies:a.luggage_policies,selected_rooms:a.selected_rooms,socialsecuritynumber_needed:a.socialsecuritynumber_needed,required_full_name_according_to_passport:a.required_full_name_according_to_passport,ask_for_ssn:a.ask_for_ssn||a.socialsecuritynumber_needed,passportinfo_needed:a.passportinfo_needed,email_required:a.email_required,dob_needed:a.dob_needed,nationality_needed:a.nationality_needed,connecting_journey:a.connecting_journey,possible_pickups:a.possible_pickups,pricing:a.pricing,price:a.price,customerinfo:a.customerinfo,extras:a.extras,priceChangedSinceStart:a.priceChangedSinceStart,paymentDates:a.paymentDates,paymentNow:a.paymentNow,transfer_options_arrival:a.transfer_options_arrival,transfer_options_return:a.transfer_options_return,airport:a.airport,pax_exception_codes:a.pax_exception_codes,show_copy_bookmanager:a.show_copy_bookmanager,show_possible_pickups:a.show_possible_pickups,raw:a}),a},async addressData(t){var a,r,l;const s=_(),o=p(),i=s.locale;t.state=this.stateObjects[2];let e;try{const{data:n}=await h(`/${i}/booking/final-confirmation`,{method:"post",signal:g(this.timeout),body:t});e=n}catch(n){throw((a=n.data)==null?void 0:a.message)==="state_expired"&&o.SET_TIMEDOUT(!0),n}this.SET_STATEOBJECT({stateObject:e.state,step:3}),this.SET_STATEOBJECT({stateObject:null,step:99});try{localStorage.removeItem(b.extraLuggage)}catch{}return this.SET_LUGGAGECOST(0),this.SET_BOOKINFO(e.booking),this.SET_TRIPINFO({...this.tripinfo,price:e.price,priceChangedSinceStart:e.priceChangedSinceStart,customerinfo:e.customerinfo,originalFlightOffer:e.flightOffer,flightOffer:e.flightOffer,flightPricingIncluded:e.flightPricingIncluded,paymentDates:e.paymentDates,paymentNow:e.paymentNow,extras:e.extras,extra_costs:e.extra_costs,insuranceproducts:e.insuranceproducts,insurance_options:e.insurance_options,transfer_options_arrival:t.transfer_options_arrival,transfer_options_return:t.transfer_options_return,transfer_option_arrival_selected:(r=e.transfer_option_arrival_selected)==null?void 0:r.rateKey,transfer_option_return_selected:(l=e.transfer_option_return_selected)==null?void 0:l.rateKey,how_found_trip_options:e.how_found_trip_options,allow_confirmation_without_payment:e.allow_confirmation_without_payment,allow_open_requests:e.allow_open_requests,allow_send_invoice_on_completion:e.allow_send_invoice_on_completion,display_installment_options:e.display_installment_options}),this.SET_STEP(3),e},async confirmLuggage(t){var a;const s=_(),o=p(),i=s.locale;if(t.state=this.stateObjects[3],this.stateObjects[99]?t.state=this.stateObjects[99]:this.SET_STATEOBJECT({stateObject:this.stateObjects[3],step:99}),!t.selected_luggage.length){this.SET_STATEOBJECT({stateObject:t.state,step:3}),this.SET_TRIPINFO({...this.tripinfo,flightOffer:this.tripinfo.originalFlightOffer});return}let e;try{const{data:r}=await h(`/${i}/booking/confirm-luggage`,{method:"post",signal:g(this.timeout),body:t});e=r}catch(r){throw((a=r.data)==null?void 0:a.message)==="state_expired"&&o.SET_TIMEDOUT(!0),r}return this.SET_TRIPINFO({...this.tripinfo,flightOffer:e.flightOffer}),this.SET_STATEOBJECT({stateObject:e.state,step:3}),e},async paymentData(t){var n;const s=_(),o=p(),i=s.locale;t.state=this.stateObjects[3];let e=`/${i}/booking/get-payment-data`;t.final_confirmation||(t.final_confirmation=this.bookinfo.final_confirmation,t.skip=this.bookinfo.skip_payment),t.skip&&(e+="?skip_payment=1");let a;const r=JSON.parse(localStorage==null?void 0:localStorage.getItem(N)),l=w(C);try{const{data:d}=await h(e,{method:"post",signal:g(this.timeout),body:{final_confirmation:t.final_confirmation,user_host:window.location.host,protocol:window.location.protocol,state:t.state,...r?{utmList:r}:{},...l.value?{gaId:l.value}:{}}});a=d}catch(d){throw((n=d.data)==null?void 0:n.message)==="state_expired"&&o.SET_TIMEDOUT(!0),d}return this.SET_BOOKINFO({...this.bookinfo,final_confirmation:t.final_confirmation,skip_payment:t.skip}),this.SET_STATEOBJECT({stateObject:a.state,step:4}),a.ocr&&this.SET_BOOKINFO({...this.bookinfo,ocr:a.ocr}),a.bambora_token&&this.SET_BOOKINFO({...this.bookinfo,bambora_token:a.bambora_token}),a.priceIncrease||this.SET_STEP("loading"),a},async fetchInstallmentPaymentLink(t){var l;const s=_(),o=p(),i=s.locale,e=JSON.parse(localStorage==null?void 0:localStorage.getItem(N)),a=w(C);let r;try{const{data:n}=await h(`/${i}/booking/get-installment-payment-data`,{method:"post",signal:g(this.timeout),body:{final_confirmation:t,user_host:window.location.host,protocol:window.location.protocol,state:this.stateObjects[3],...e?{utmList:e}:{},...a.value?{gaId:a.value}:{}}});r=n}catch(n){throw((l=n.data)==null?void 0:l.message)==="state_expired"&&o.SET_TIMEDOUT(!0),n}return r},async finalize(){var a;const t=_(),s=p(),o=t.locale,i={state:this.stateObjects[4]};let e;try{const{data:r}=await h(`/${o}/booking/finalize`,{method:"post",signal:g(this.timeout),body:i});e=r}catch(r){throw((a=r.data)==null?void 0:a.message)==="state_expired"&&s.SET_TIMEDOUT(!0),r}return this.SET_STATEOBJECT({stateObject:e.state,step:5}),this.SET_STEP(5),this.SET_BOOKINFO({...this.bookinfo,ocr:e.ocr,customerId:e.customerId,success:e.success,status:e.status,payment_link:e.payment_link,pending_payments:e.pending_payments}),e},async getPreviousBooking(t){const s=_(),o=D(),i=s.locale;this.SET_BOOKINFO(null),this.SET_TRIPINFO(null);const{data:e}=await h(`/${i}/booking/get-previous-booking/${t}`,{signal:g(this.timeout)});if(this.SET_BOOKINFO({...e.final_confirmation.booking,how_found_trip:e.how_found_trip,bookable:e.bookable,bambora_token:e.bambora_token}),this.SET_TRIPINFO({...e.final_confirmation}),e.airport_dictionary){const a={};e.airport_dictionary.forEach(r=>{a[r.iata]=r}),o.SET_CHARTER_AIRPORT_NAMES(a)}return e}}}),p=G("charter",{state:()=>({destination:{},startpage:{},tagsFeatured:[],timeout:60*1e3,selectedAirport:null,selectedDestination:null,selectedDestinationL1:null,rooms:[{Adults:2,Children:0,ChildAges:[]}],calendarSuggestions:{forced:!1,homebound:{},outbound:{}},selectedStartDate:{currentDate:null,selectedDate:!1,selectedDateTime:!1,selectedHour:"00",selectedMinute:"00",selectedDatesItem:"",selectedDates:[],dateRange:{start:"",end:""},multipleDateRange:[]},mpis:null,currentSliderDate:3,loading:!1,loadingFlights:!1,dateSuggestions:[{loading:!0},{loading:!0},{loading:!0},{date:null,price:null},{loading:!0},{loading:!0},{loading:!0}],recommendedFlights:{quickest:null,cheapest:null,recommended:null},flightOffers:[],activeFlightOffer:null,selectedFlight:null,selectedFlightGroup:null,selectedRooms:[],hotelOptions:{},error:!1,nothingFound:!1,hotelError:!1,noHotelsFound:!1,searchingAlternatives:!1,modalRoomTypes:[],modalHotelId:null,timedout:!1,stateObjects:[]}),getters:{},actions:{SET_STARTPAGE(t){this.startpage=t},SET_TAGS_FEATURED(t){this.tagsFeatured=t},SET_TIMEDOUT(t){this.timedout=t},RESET_STATEOBJECT(){this.stateObjects=[]},SET_STATEOBJECT({stateObject:t,step:s}){this.stateObjects[s]=t},SET_SEARCHOPTIONS(t){this.selectedAirport=t.selectedAirport||this.selectedAirport,this.selectedDestination=t.selectedDestination||this.selectedDestination,this.selectedDestinationL1=t.selectedDestinationL1||this.selectedDestinationL1,this.rooms=t.rooms||this.rooms,this.selectedStartDate=t.selectedStartDate||this.selectedStartDate},SET_SELECTED_STARTDATE(t){this.selectedStartDate=t},SET_SELECTED_AIRPORT(t){this.selectedAirport=t},SET_SELECTED_DESTINATION(t){this.selectedDestination=t},SET_RECOMMENDED(t){this.recommendedFlights=t},SET_LOADING(t){this.loading=t},SET_MPIS(t){this.mpis=t},SET_SEARCHING_ALTERNATIVES(t){this.searchingAlternatives=t},SET_LOADINGFLIGHTS(t){this.loadingFlights=t},SET_FLIGHTOFFERS(t){this.flightOffers=t},SET_ACTIVE_FLIGHTOFFER(t){this.activeFlightOffer=t},SET_CURRENT_SLIDERDATE(t){this.currentSliderDate=t},SET_SELECTED_FLIGHT(t){this.selectedFlight=t},SET_SELECTED_FLIGHTGROUP(t){this.selectedFlightGroup=t},SET_SELECTED_ROOMS(t){this.selectedRooms=t},SET_CALENDAR_SUGGESTIONS(t){this.calendarSuggestions=t},SET_SUGGESTIONS(t){this.dateSuggestions=t},SET_SUGGESTION({index:t,info:s}){const o=[...this.dateSuggestions];o[t]=s,this.dateSuggestions=o},SET_SUGGESTION_BY_DATE({result:t,date_end:s}){const o=[...this.dateSuggestions],i=o.findIndex(e=>e.date===t.date);o[i]={...t,date_end:s},this.dateSuggestions=o},SET_RECOMMENDED_SUGGESTION_SEGMENTS(t){this.dateSuggestions[3].segments=t},SET_NOTHINGFOUND(t){this.nothingFound=t},SET_NOHOTELSFOUND(t){this.noHotelsFound=t},SET_HOTELOPTIONS({id:t,hotels:s,minimumPrice:o,recommended:i}){const e={...this.hotelOptions};e.recommended=e.recommended||{},e.recommended[t]=i,e.minimumPrice=o,e[t]=s,this.hotelOptions=e},RESET_HOTELOPTIONS(){this.hotelOptions={}},SET_HOTELERROR(t){this.hotelError=t},SET_ERROR(t){this.error=t},SET_MODALROOMTYPES(t){this.modalRoomTypes=t},SET_MODALHOTELID(t){this.modalHotelId=t},SET_ROOMS(t){this.rooms=t},SET_DESTINATION(t){this.destination=t},async fetchStart(){const s=_().locale,o="",{data:i}=await h(`/${s}/charter/startpage${o}`);this.SET_STARTPAGE(i)},async fetchTagsFeatured(){const s=_().locale,{data:o}=await h(`/${s}/charter/tags/featured`);return this.SET_TAGS_FEATURED(o),o},async fetchDestination({destination:t}){const o=_().locale,e=v().GET_CHARTER_DESTINATION;if(e.id===t)return this.SET_DESTINATION(e),e;const{data:a}=await h(`/${o}/destination_page/${t}`);if(a.sections){const r=a.sections.findIndex(({type:l})=>l==="destination_summary");r!==-1&&r&&(a.sections[r]={...a.sections[r],data:k(a.sections[r].data,["text","preamble"])})}return this.SET_DESTINATION(a),a},getURLParameters(t){var o,i,e,a,r,l,n,d,E;let s=[];return(o=t.selectedAirport)!=null&&o.airport&&s.push(`airport=${t.selectedAirport.airport}`),(e=(i=t.selectedStartDate)==null?void 0:i.dateRange)!=null&&e.start&&((r=(a=t.selectedStartDate)==null?void 0:a.dateRange)!=null&&r.end)&&s.push(`date=${c(t.selectedStartDate.dateRange.start).format("YYYY-MM-DD")}`,`date_end=${c(t.selectedStartDate.dateRange.end).format("YYYY-MM-DD")}`),(l=t.selectedDestination)!=null&&l.destination_page_id?s.push(`destination_page=${t.selectedDestination.destination_page_id}`):(n=t.selectedDestination)!=null&&n.destination_id?s.push(`destination_id=${(d=t.selectedDestination)==null?void 0:d.destination_id}`):(E=t.selectedDestination)!=null&&E.longitude&&(s.push(`destination_lng=${t.selectedDestination.longitude}`),s.push(`destination_lat=${t.selectedDestination.latitude}`),s.push(`destination_addr=${t.selectedDestination.formatted_address}`)),t.hotel&&s.push(`hotel=${t.hotel}`),t.rooms&&(s=[...s,...q(t)]),s.join("&")},async search(t){var l,n,d,E,T;const s=_(),o=D(),i=M(),e=s.locale;if(this.SET_SEARCHOPTIONS(m(t)),this.SET_FLIGHTOFFERS([]),this.RESET_HOTELOPTIONS(),this.SET_TIMEDOUT(!1),this.SET_NOTHINGFOUND(!1),this.SET_HOTELERROR(!1),this.SET_NOHOTELSFOUND(!1),this.SET_ACTIVE_FLIGHTOFFER(null),this.SET_SELECTED_FLIGHTGROUP(null),this.SET_SELECTED_FLIGHT(null),this.SET_RECOMMENDED({quickest:null,cheapest:null,recommended:null}),this.SET_MODALHOTELID(null),this.SET_MODALROOMTYPES([]),this.SET_ERROR(!1),!c((n=(l=this.selectedStartDate)==null?void 0:l.dateRange)==null?void 0:n.start).isValid()||!c((E=(d=this.selectedStartDate)==null?void 0:d.dateRange)==null?void 0:E.end).isValid())return this.SET_ERROR(!0),!1;const a={rooms:this.rooms};let r=!1;if(this.price&&(a.price_suggested=this.price),this.selectedAirport?a.airport=this.selectedAirport.airport:r=!0,this.selectedDestination&&this.selectedDestination.custom?(a.latitude=this.selectedDestination.latitude,a.longitude=this.selectedDestination.longitude):this.selectedDestination?a.destination_id=this.selectedDestination.destination_id:r=!0,this.selectedStartDate.dateRange?(a.date=c(this.selectedStartDate.dateRange.start).format("YYYY-MM-DD"),a.date_end=c(this.selectedStartDate.dateRange.end).format("YYYY-MM-DD")):r=!0,this.mpis!==null&&(a.mpis=this.mpis),r)return this.SET_LOADINGFLIGHTS(!1),this.SET_LOADING(!1),this.SET_SEARCHING_ALTERNATIVES(!1),!1;t.keepSuggestions?this.SET_LOADINGFLIGHTS(!0):(this.SET_LOADING(!0),this.SET_SUGGESTIONS([{loading:!0,date:c(this.selectedStartDate.dateRange.start).subtract(3,"day").format("YYYY-MM-DD"),date_end:c(this.selectedStartDate.dateRange.end).subtract(3,"day").format("YYYY-MM-DD")},{loading:!0},{loading:!0},{date:this.selectedStartDate.dateRange.start,price:null,original:!0,segments:0},{loading:!0},{loading:!0},{loading:!0,date:c(this.selectedStartDate.dateRange.start).add(3,"day").format("YYYY-MM-DD"),date_end:c(this.selectedStartDate.dateRange.end).add(3,"day").format("YYYY-MM-DD")}]),this.SET_SEARCHING_ALTERNATIVES(!1)),t.keepSuggestions||window.setTimeout(()=>this.getDateSuggestions(a),50);try{window.localStorage.setItem("sol_charter_search",JSON.stringify({selectedAirport:this.selectedAirport,rooms:this.rooms,selectedStartDate:this.selectedStartDate,selectedDestination:this.selectedDestination,selectedDestinationL1:this.selectedDestinationL1}))}catch{}try{window.cab&&window.cab.abort(),window.cab=new AbortController,A(window.cab,60*1e3);const{data:S}=await h(`/${e}/charter/offers`,{method:"POST",body:a,signal:window.cab.signal});if(this.SET_LOADING(!1),this.SET_LOADINGFLIGHTS(!1),(T=S.flight_offers)!=null&&T.length){const u={};S.airport_dictionary.forEach(R=>{u[R.iata]=R}),o.SET_CHARTER_AIRPORT_NAMES(u),this.SET_STATEOBJECT({stateObject:S.state,step:0}),i.SET_TIMEOUT(S.bprocess_timeout),this.SET_FLIGHTOFFERS(S.flight_offers),this.SET_RECOMMENDED({quickest:S.quickest_flightid,cheapest:S.cheapest_flightid,recommended:S.recommended_flightid});const f=S.flight_offers.find(R=>R.id===S.recommended_flightid);t.keepSuggestions||this.SET_RECOMMENDED_SUGGESTION_SEGMENTS(f.itinieraries[0].segments.length+f.itinieraries[1].segments.length),this.SET_SEARCHING_ALTERNATIVES(!1)}else this.SET_LOADINGFLIGHTS(!0),this.SET_SEARCHING_ALTERNATIVES(!0),this.getAlternativeStartDate(t);return S}catch(S){if(S.name==="AbortError")return;const{$sentryCaptureMessage:u}=U();u("charter/search error",{level:"warning",contexts:{details:S.data||S},tags:{type:"UX"}}),this.SET_LOADING(!1),this.SET_LOADINGFLIGHTS(!1),this.SET_ERROR(!0)}},getAlternativeStartDate(t){if(this.dateSuggestions.reduce((e,a)=>e||a.loading,!1)){window.setTimeout(()=>this.getAlternativeStartDate(t),50);return}const s=m(t);s.triedIndexes=s.triedIndexes||[];let o=[[2,4],[1,5],[0,6]].find(e=>{const a=this.dateSuggestions[e[0]],r=this.dateSuggestions[e[1]];return!a.loading&&a.price||!r.loading&&r.price});if(o!==void 0){const e=this.dateSuggestions[o[0]],a=this.dateSuggestions[o[1]];e.price&&a.price?o=e.price<=a.price?o[0]:o[1]:o=e.price?o[0]:o[1]}if(o===void 0){this.SET_LOADING(!1),this.SET_LOADINGFLIGHTS(!1),this.SET_NOTHINGFOUND(!0);return}this.SET_CURRENT_SLIDERDATE(o);const i=this.dateSuggestions[o];s.selectedStartDate.dateRange.start=c(i.date).format(L),s.selectedStartDate.dateRange.end=c(i.date_end).format(L),s.price=i.price,s.keepSuggestions=!0,s.triedIndexes.push(o),this.search(s)},async getCalendarSuggestions(t){const o=_().locale,{data:i}=await h(`/${o}/charter/calendar_suggestions`,{method:"POST",body:t}),e={};e.forced=i.forced,e.homebound=i.homebound,e.outbound=i.outbound,this.SET_CALENDAR_SUGGESTIONS(e)},getDateSuggestions(t){[1,2,3].forEach(async s=>{const i=_().locale,e={...t,date:c(t.date).add(s,"day").format("YYYY-MM-DD"),date_end:c(t.date_end).add(s,"day").format("YYYY-MM-DD")},a={...t,date:c(t.date).subtract(s,"day").format("YYYY-MM-DD"),date_end:c(t.date_end).subtract(s,"day").format("YYYY-MM-DD")};try{let r=!1;c(a.date,"YYYY-MM-DD").isBefore(c().subtract(1,"day"))&&(r=!0);const[{data:l},{data:n}]=await Promise.all([h(`/${i}/charter/day_suggestion`,{method:"POST",body:e,headers:{"Content-Type":"application/json"},timeout:6e4}),...r?[{error:!0}]:[h(`/${i}/charter/day_suggestion`,{method:"POST",body:a,headers:{"Content-Type":"application/json"},timeout:6e4})]]);l.error?this.SET_SUGGESTION({index:s+3,info:{loading:!1,date:e.date,date_end:e.date_end}}):this.SET_SUGGESTION({index:s+3,info:{...l,date_end:e.date_end}}),n.error?this.SET_SUGGESTION({index:3-s,info:{loading:!1,date:a.date,date_end:a.date_end}}):this.SET_SUGGESTION({index:3-s,info:{...n,date_end:a.date_end}})}catch(r){if(r.name==="AbortError")return;this.SET_SUGGESTION({index:s+3,info:{loading:!1,date:e.date,date_end:e.date_end}}),this.SET_SUGGESTION({index:3-s,info:{loading:!1,date:a.date,date_end:a.date_end}})}})},async getDateSuggestion(t){const o=_().locale,i={rooms:this.rooms,airport:this.selectedAirport.airport};if(this.selectedDestination&&this.selectedDestination.custom?(i.latitude=this.selectedDestination.latitude,i.longitude=this.selectedDestination.longitude):this.selectedDestination&&(i.destination_id=this.selectedDestination.destination_id),t===-1){i.date=c(this.dateSuggestions[0].date).subtract(1,"day").format("YYYY-MM-DD"),i.date_end=c(this.dateSuggestions[0].date_end).subtract(1,"day").format("YYYY-MM-DD");const e=m(this.dateSuggestions);e.unshift({loading:!0,date:i.date,date_end:i.date_end}),this.SET_SUGGESTIONS(e)}else{i.date=c(this.dateSuggestions[this.dateSuggestions.length-1].date).add(1,"day").format("YYYY-MM-DD"),i.date_end=c(this.dateSuggestions[this.dateSuggestions.length-1].date_end).add(1,"day").format("YYYY-MM-DD");const e=m(this.dateSuggestions);e.push({loading:!0,date:i.date,date_end:i.date_end}),this.SET_SUGGESTIONS(e)}try{const{data:e}=await h(`/${o}/charter/day_suggestion`,{method:"POST",body:i});this.SET_SUGGESTION_BY_DATE({result:e,date_end:i.date_end})}catch{this.SET_SUGGESTION_BY_DATE({result:{loading:!1,date:i.date},date_end:i.date_end})}},async getHotels({id:t,storeSuggestion:s,setPrice:o}){var a,r;const e=_().locale;this.SET_HOTELERROR(!1),this.SET_NOHOTELSFOUND(!1);try{const{data:l}=await h(`/${e}/charter/property_list`,{method:"POST",body:{state:this.stateObjects[0],flight_offer_id:t}});if(l.property_list.length){if(this.SET_HOTELOPTIONS({id:t,recommended:l.recommended_properties,minimumPrice:l.minimum_package_price,hotels:l.property_list}),s){const n=m(this.dateSuggestions);if(o){let d=null;if((a=l.recommended_properties)!=null&&a.length){const T={};l.property_list.forEach(u=>{T[u.id]=u});const S=Number.MAX_SAFE_INTEGER;d=l.recommended_properties.filter(u=>!!T[u.hotel_id]).reduce((u,f)=>T[f.hotel_id].min_additional_cost<u?T[f.hotel_id].min_additional_cost:u,S),d===S&&(d=null)}const E=n.find(({date:T})=>T===s);E&&(E.price=d||l.minimum_package_price)}this.SET_SUGGESTION({index:s,data:n[s]})}}else this.SET_NOHOTELSFOUND(!0);return this.SET_STATEOBJECT({stateObject:l.state,step:1}),l}catch(l){if(((r=l.data)==null?void 0:r.message)==="state_expired")throw this.SET_TIMEDOUT(!0),l;this.SET_HOTELERROR(!0)}},async hotelInfo(t){var i;const o=_().locale;try{window.cab&&window.cab.abort(),window.cab=new AbortController,A(window.cab,this.timeout);const{data:e}=await h(`/${o}/booking/property-info/${t}`,{signal:window.cab.signal});return e}catch(e){throw((i=e.data)==null?void 0:i.message)==="state_expired"&&this.SET_TIMEDOUT(!0),e}},async roomData(t){var i;const o=_().locale;t.state=this.stateObjects[1];try{window.cab&&window.cab.abort(),window.cab=new AbortController,A(window.cab,this.timeout);const{data:e}=await h(`/${o}/booking/roomtypes-for-hotel`,{method:"POST",body:t,signal:window.cab.signal});return this.SET_STATEOBJECT({stateObject:e.state,step:2}),this.SET_MODALROOMTYPES(e.roomtypes),this.SET_MODALHOTELID(t.hotelid),e}catch(e){throw((i=e.data)==null?void 0:i.message)==="state_expired"&&this.SET_TIMEDOUT(!0),e}},async customerData(t){var o;const s=M();t.state=this.stateObjects[2],s.SET_TRAVELERS([]),s.SET_MANAGER(null),s.SET_TRIPINFO({}),s.SET_ISROUNDTRIP(!1);try{return await s.customerData(t)}catch(i){throw((o=i.data)==null?void 0:o.message)==="state_expired"&&this.SET_TIMEDOUT(!0),i}}}});export{Z as A,P as D,tt as T,p as a,ot as b,St as c,rt as d,ct as e,O as f,nt as g,lt as h,K as i,it as j,st as k,et as l,ht as m,_t as n,at as o,dt as p,M as u};
//# sourceMappingURL=CKC1r8NV.js.map