if(void 0!==document.getElementById("xtd-search-flight")&&null!=document.getElementById("xtd-search-flight")){Vue.component("v-select",VueSelect.VueSelect);var xtenderSearchFlight=new Vue({el:"#xtd-search-flight",data:function(){var e={from:null,to:null,date:"",pax:2};return{empty_leg:e,legs:[JSON.parse(JSON.stringify(e))],requirements:"",requirements_visibility:!1,return_flight:!0,options:[],loading:"",modal:!1,modal_visibility:!1}},mounted:function(){this.mountFlatPickrs(0),this.$el.className.indexOf("modal")>=0&&(this.modal=!0)},watch:{modal_visibility:function(e){e?this.$el.className+=" xtd-search-flight--modal-opened":this.$el.className=this.$el.className.replace(" xtd-search-flight--modal-opened",""),this.setActive()}},methods:{setActive(){this.active=!this.active;let e=document.body;this.active?e.classList.add("airline-in"):e.classList.remove("airline-in")},isSearchDisabled:function(){var e=!0;return window.lodash.each(this.legs,(function(t){!0===e&&null!==t.from&&null!==t.to&&t.date.length>1&&t.pax>0&&(e=!1)})),e},searchFlights:function(){var e=this,t=leg="";window.lodash.each(e.legs,(function(e){leg="",leg+=e.from.value+" | "+e.from.label+" | "+e.from.location+" ✈ ✈ ✈ ✈ ",leg+=e.to.value+" | "+e.to.label+" | "+e.to.location+" | "+e.date+" | PAX: "+e.pax+"\n",t+=leg+"\n"})),e.requirements.length>0&&(t+="Requirements: \n",t+=e.requirements+"\n"),window.location.href=this.$el.dataset.url+"?"+this.$el.dataset.query+"="+encodeURIComponent(t)},deleteRequirements:function(){this.requirements_visibility=!1,this.requirements=""},deleteLeg:function(e){var t=[];window.lodash.each(this.legs,(function(i,n){e!==n&&t.push(i)})),this.legs=t},onChangePax:function(e,t){var i=this;(isNaN(parseInt(i.legs[t].pax))||i.legs[t].pax<1)&&(i.legs[t].pax=1)},mountFlatPickrs:function(e){var t=this;setTimeout((function(){flatpickr(t.$refs["flatpikr_"+e][0],{enableTime:!0,dateFormat:"Y-m-d H:i",time_24hr:!0,minDate:Date.now()})}),500)},addReturn:function(){var e=this;e.legs.push(e.empty_leg),e.return_flight=!1,this.mountFlatPickrs(e.legs.length-1)},addRequirements:function(){this.requirements_visibility=!0},addFlight:function(){var e=this;e.legs.push(JSON.parse(JSON.stringify(e.empty_leg))),this.mountFlatPickrs(e.legs.length-1)},onSearch:function(e,t){e.length>2&&(t(!0),this.search(t,e,this))},search:window.lodash.debounce((function(e,t,i){t=t.split(" ").join("-");var n=window.xtenderAirline.rest_url.substr(0,window.xtenderAirline.rest_url.indexOf("/xtender/v1/airports/")+21),s=window.xtenderAirline.rest_url.substr(window.xtenderAirline.rest_url.indexOf("/xtender/v1/airports/")+21,-1);this.$http.get(n+encodeURIComponent(t)+s,{}).then((function(t){this.options=t.body.slice(0,50),e(!1)}),(function(t){e(!1)}))}),700)}})}