!function(l){l(function(){MPHB.DateRules=can.Construct.extend({},{dates:{},init:function(t){this.dates=t},canCheckIn:function(t){var e=this.formatDate(t);return!this.dates.hasOwnProperty(e)||!this.dates[e].not_check_in&&!this.dates[e].not_stay_in},canCheckOut:function(t){var e=this.formatDate(t);return!this.dates.hasOwnProperty(e)||!this.dates[e].not_check_out},canStayIn:function(t){var e=this.formatDate(t);return!this.dates.hasOwnProperty(e)||!this.dates[e].not_stay_in},getNearestNotStayInDate:function(t,e){var a=MPHB.Utils.cloneDate(e),i=l.datepick.formatDate("yyyy-mm-dd",t),n=l.datepick.formatDate("yyyy-mm-dd",e);return l.each(this.dates,function(t,e){return!(n li img").width(),t.sync='.mphb-gallery-thumbnail-slider[data-group="'+this.groupId+'"]',this.navSliderEl.addClass("flexslider mphb-flexslider mphb-gallery-thumbnails-slider").flexslider(e)}this.sliderEl.addClass("flexslider mphb-flexslider mphb-gallery-slider").flexslider(t),this.slidersLoaded=!0}}}),MPHB.format_price=function(t,e){e=e||{};var a=MPHB._data.settings.currency;e=l.extend({trim_zeros:!1},a,e),t=MPHB.number_format(t,e.decimals,e.decimal_separator,e.thousand_separator);var i=e.price_format.replace("%s",t);if(e.trim_zeros){var n=new RegExp("\\"+e.decimal_separator+"0+$|(\\"+e.decimal_separator+"\\d*[1-9])0+$");i=i.replace(n,"$1")}return''+i+""},MPHB.number_format=function(t,e,a,i){var n,s,r="";return e=e||0,a=a||".",i=i||",",t<0&&(r="-",t*=-1),3<(s=(n=parseInt(t=(+t||0).toFixed(e))+"").length)?s%=3:s=0,r+(s?n.substr(0,s)+i:"")+n.substr(s).replace(/(\d{3})(?=\d)/g,"$1"+i)+(e?a+Math.abs(t-n).toFixed(e).replace(/-/,0).slice(2):"")},MPHB.post=function(t,e,a){t="mphb_"+t,e=l.extend({action:t,mphb_nonce:MPHB._data.nonces[t],lang:MPHB._data.settings.currentLanguage},e);var i=l.extend({url:MPHB._data.ajaxUrl,type:"POST",dataType:"json",data:e},a);return l.ajax(i)},can.Construct("MPHB.Season",{},{startDate:null,endDate:null,allowedDays:[],init:function(t){var e=MPHB._data.settings.dateTransferFormat;this.startDate=l.datepick.parseDate(e,t.start_date),this.endDate=l.datepick.parseDate(e,t.end_date),this.allowedDays=t.allowed_days},isContainDate:function(t){return t>=this.startDate&&t<=this.endDate&&MPHB.Utils.inArray(t.getDay(),this.allowedDays)}}),MPHB.ReservationRulesChecker=can.Construct.extend({myThis:null},{rules:{checkInDays:{},checkOutDays:{},minStay:{},maxStay:{},minAdvance:{},maxAdvance:{}},init:function(t){this.rules.checkInDays=l.map(t.check_in_days,function(t){return new MPHB.Rules.CheckInDayRule(t)}),this.rules.checkOutDays=l.map(t.check_out_days,function(t){return new MPHB.Rules.CheckOutDayRule(t)}),this.rules.minStay=l.map(t.min_stay_length,function(t){return new MPHB.Rules.MinDaysRule(t)}),this.rules.maxStay=l.map(t.max_stay_length,function(t){return new MPHB.Rules.MaxDaysRule(t)}),this.rules.minAdvance=l.map(t.min_advance_reservation,function(t){return new MPHB.Rules.MinAdvanceDaysRule(t)}),this.rules.maxAdvance=l.map(t.max_advance_reservation,function(t){return new MPHB.Rules.MaxAdvanceDaysRule(t)})},getActualRule:function(t,a,i){var n=null;return l.each(this.rules[t],function(t,e){if(e.isActualRule(a,i))return n=e,!1}),n},getActualCombinedRule:function(t,i){var n=[],s=[];return l.each(this.rules[t],function(t,e){var a=MPHB.Utils.arrayDiff(e.roomTypeIds,n);if(a.length&&e.isActualForDate(i))return s.push(e),n=n.concat(a),!e.isAllRoomTypeRule()&&(!!MPHB.Utils.arrayDiff(MPHB._data.allRoomTypeIds,n).length&&void 0)}),this.combineRules(t,s)},combineRules:function(t,e){var a;switch(t){case"checkInDays":var i=[];l.each(e,function(t,e){i=i.concat(e.days)}),i=MPHB.Utils.arrayUnique(i),a=new MPHB.Rules.CheckInDayRule({season_ids:[0],room_type_ids:[0],check_in_days:i});break;case"checkOutDays":i=[];l.each(e,function(t,e){i=i.concat(e.days)}),i=MPHB.Utils.arrayUnique(i),a=new MPHB.Rules.CheckOutDayRule({season_ids:[0],room_type_ids:[0],check_out_days:i});break;case"minStay":var n=MPHB.Utils.arrayMin(l.map(e,function(t){return t.min}));a=new MPHB.Rules.MinDaysRule({season_ids:[0],room_type_ids:[0],min_stay_length:n});break;case"maxStay":n=MPHB.Utils.arrayMax(l.map(e,function(t){return t.max}));a=new MPHB.Rules.MaxDaysRule({season_ids:[0],room_type_ids:[0],max_stay_length:n});break;case"minAdvance":n=MPHB.Utils.arrayMin(l.map(e,function(t){return t.min}));a=new MPHB.Rules.MinAdvanceDaysRule({season_ids:[0],room_type_ids:[0],min_advance_reservation:n});break;case"maxAdvance":n=MPHB.Utils.arrayMax(l.map(e,function(t){return t.max}));a=new MPHB.Rules.MaxAdvanceDaysRule({season_ids:[0],room_type_ids:[0],max_advance_reservation:n})}return a},isCheckInSatisfy:function(t,e){return e?this.getActualRule("checkInDays",t,e).verify(t):this.getActualCombinedRule("checkInDays",t).verify(t)},isCheckOutSatisfy:function(t,e,a){return a?this.getActualRule("checkOutDays",t,a).verify(t,e):this.getActualCombinedRule("checkOutDays",t).verify(t,e)},getMinStay:function(t,e){return e?this.getActualRule("minStay",t,e).min:this.getActualCombinedRule("minStay",t).min},getMaxStay:function(t,e){return e?this.getActualRule("maxStay",t,e).max:this.getActualCombinedRule("maxStay",t).max},getToday:function(){return MPHB.HotelDataManager.myThis.today},getMinAdvance:function(t){return t?this.getActualRule("minAdvance",this.getToday(),t).min:this.getActualCombinedRule("minAdvance",this.getToday()).min},getMaxAdvance:function(t){return t?this.getActualRule("maxAdvance",this.getToday(),t).max:this.getActualCombinedRule("maxAdvance",this.getToday()).max},getMinCheckInDate:function(t){var e=this.getMinAdvance(t);return 0=MPHB.Utils.formatDateToCompare(a)}}),MPHB.Rules.BasicRule("MPHB.Rules.MaxDaysRule",{},{max:null,init:function(t){this._super(t),this.max=0!=t.max_stay_length?t.max_stay_length:3652},verify:function(t,e){var a=l.datepick.add(MPHB.Utils.cloneDate(t),this.max,"d");return MPHB.Utils.formatDateToCompare(e)<=MPHB.Utils.formatDateToCompare(a)}}),can.Construct("MPHB.HotelDataManager",{myThis:null,ROOM_STATUS_AVAILABLE:"available",ROOM_STATUS_NOT_AVAILABLE:"not-available",ROOM_STATUS_BOOKED:"booked",ROOM_STATUS_PAST:"past",ROOM_STATUS_EARLIER_MIN_ADVANCE:"earlier-min-advance",ROOM_STATUS_LATER_MAX_ADVANCE:"later-max-advance",ROOM_STATUS_BOOKING_BUFFER:"booking-buffer"},{today:null,roomTypesData:{},translationIds:{},dateRules:null,typeRules:{},seasons:{},init:function(t){(MPHB.HotelDataManager.myThis=this).setToday(l.datepick.parseDate(MPHB._data.settings.dateTransferFormat,t.today)),this.initSeasons(t.seasons),this.initRoomTypesData(t.roomTypesData,t.rules),this.initRules(t.rules)},initRoomTypesData:function(t,n){var s=this;l.each(t,function(t,e){t=parseInt(t);var a=parseInt(e.originalId);a!=t&&(s.translationIds.hasOwnProperty(a)||(s.translationIds[a]=[]),s.translationIds[a].push(t));var i=new MPHB.RoomTypeData(t,e);l.each(n.dates,function(t,e){e.not_stay_in&&i.blockAllRoomsOnDate(t)}),n.blockedTypes.hasOwnProperty(a)&&l.each(n.blockedTypes[a],function(t,e){e.not_stay_in&&i.blockAllRoomsOnDate(t)}),s.roomTypesData[t]=i})},initRules:function(t){this.dateRules=new MPHB.DateRules(t.dates);var i=this;l.each(t.blockedTypes,function(t,a){i.typeRules[t]=new MPHB.DateRules(a),i.translationIds.hasOwnProperty(t)&&l.each(i.translationIds[t],function(t,e){i.typeRules[e]=new MPHB.DateRules(a)})}),this.reservationRules=new MPHB.ReservationRulesChecker(t.reservationRules)},initSeasons:function(t){l.each(t,this.proxy(function(t,e){this.seasons[t]=new MPHB.Season(e)}))},setToday:function(t){this.today=t},getRoomTypeData:function(t){return!!this.roomTypesData.hasOwnProperty(t)&&this.roomTypesData[t]},fillDateCellData:function(t,e,a,i){i=i||e;var n=[],s=[],r=t.roomTypeId;return this.notStayIn(e,r)&&(n.push(MPHB._data.translations.notStayIn),s.push("mphb-not-stay-in-date")),"checkIn"==a&&this.notCheckIn(e,r,i)&&(n.push(MPHB._data.translations.notCheckIn),s.push("mphb-not-check-in-date")),"checkOut"==a&&this.notCheckOut(e,r,i)&&(n.push(MPHB._data.translations.notCheckOut),s.push("mphb-not-check-out-date")),MPHB.Utils.compareDates(e,this.today,">=")&&this.isEarlierThanMinAdvanceDate(e,r)&&n.push(MPHB._data.translations.earlierMinAdvance),"checkOut"!=a&&this.isLaterThamMaxAdvanceDate(e,r)&&n.push(MPHB._data.translations.laterMaxAdvance),n.length&&(t.title+=" "+MPHB._data.translations.rules+" "+n.join(", ")),s.length&&(t.dateClass+=(t.dateClass.length?" ":"")+s.join(" ")),t},notStayIn:function(t,e){var a=this.dateRules.canStayIn(t);return this.typeRules[e]&&(a=a&&this.typeRules[e].canStayIn(t)),!a},notCheckIn:function(t,e,a){var i=this.dateRules.canCheckIn(t);return i=i&&this.reservationRules.isCheckInSatisfy(t,e),this.typeRules[e]&&(i=i&&this.typeRules[e].canCheckIn(t)),!i},notCheckOut:function(t,e,a){var i=this.dateRules.canCheckOut(t);return i=i&&this.reservationRules.isCheckOutSatisfy(a,t,e),this.typeRules[e]&&(i=i&&this.typeRules[e].canCheckOut(t)),!i},isEarlierThanMinAdvanceDate:function(t,e){var a=this.reservationRules.getMinCheckInDate(e);return null!=a&&MPHB.Utils.compareDates(t,a,"<")},isLaterThamMaxAdvanceDate:function(t,e){var a=this.reservationRules.getMaxAdvanceDate(e);return null!=a&&MPHB.Utils.compareDates(t,a,">")}}),MPHB.TermsSwitcher=can.Construct.extend({},{init:function(t,e){var a=t.children(".mphb-terms-and-conditions");t.find(".mphb-terms-and-conditions-link").on("click",function(t){t.preventDefault(),a.toggleClass("mphb-active")})}}),MPHB.Utils=can.Construct.extend({formatDateToCompare:function(t){return l.datepick.formatDate("yyyymmdd",t)},compareDates:function(t,e,a){t=MPHB.Utils.formatDateToCompare(t),e=MPHB.Utils.formatDateToCompare(e);if(null==a)return e":return e=":return e<=t;case"<":return t');var a=this;braintree.setup(this.clientToken,"dropin",{container:e,onReady:function(t){a.checkout=t},onPaymentMethodReceived:function(t){a.storeNonce(t.nonce),a.billingSection.parentForm.element.submit(),a.billingSection.showPreloader()}}),t.removeClass("mphb-billing-fields-hidden")}},cancelSelection:function(){if(this._super(),null!=this.checkout){var t=this;this.checkout.teardown(function(){t.checkout=null})}}}),MPHB.CouponSection=can.Control.extend({},{applyCouponTimeout:null,parentForm:null,appliedCouponEl:null,couponEl:null,messageHolderEl:null,init:function(t,e){this.parentForm=e.form,this.couponEl=t.find('[name="mphb_coupon_code"]'),this.appliedCouponEl=t.find('[name="mphb_applied_coupon_code"]'),this.messageHolderEl=t.find(".mphb-coupon-message")},".mphb-apply-coupon-code-button click":function(t,e){e.preventDefault(),e.stopPropagation(),this.clearMessage();var a=this.couponEl.val();if(a.length){this.appliedCouponEl.val("");var i=this;this.showPreloader(),clearTimeout(this.applyCouponTimeout),this.applyCouponTimeout=setTimeout(function(){var t=i.parentForm.parseFormToJSON();l.ajax({url:MPHB._data.ajaxUrl,type:"POST",dataType:"json",data:{action:"mphb_apply_coupon",mphb_nonce:MPHB._data.nonces.mphb_apply_coupon,mphb_coupon_code:a,formValues:t,lang:MPHB._data.settings.currentLanguage},success:function(t){t.hasOwnProperty("success")?t.success?(i.parentForm.setCheckoutData(t.data),i.couponEl.val(""),i.appliedCouponEl.val(t.data.coupon.applied_code),i.showMessage(t.data.coupon.message)):i.showMessage(t.data.message):i.showMessage(MPHB._data.translations.errorHasOccured)},error:function(t){i.showMessage(MPHB._data.translations.errorHasOccured)},complete:function(t){i.hidePreloader()}})},500)}else this.showMessage(MPHB._data.translations.emptyCouponCode)},removeCoupon:function(){this.appliedCouponEl.val(""),this.clearMessage()},showPreloader:function(){this.parentForm.showPreloader()},hidePreloader:function(){this.parentForm.hidePreloader()},clearMessage:function(){this.messageHolderEl.html("").addClass("mphb-hide")},showMessage:function(t){this.messageHolderEl.html(t).removeClass("mphb-hide")}}),MPHB.CheckoutForm=can.Control.extend({myThis:null},{priceBreakdownTableEl:null,bookBtnEl:null,errorsWrapperEl:null,preloaderEl:null,billingSection:null,couponSection:null,waitResponse:!1,updateInfoTimeout:null,updateRatesTimeout:null,freeBooking:!1,currentInfoAjax:null,toPay:0,init:function(t,e){(MPHB.CheckoutForm.myThis=this).bookBtnEl=this.element.find("input[type=submit]"),this.errorsWrapperEl=this.element.find(".mphb-errors-wrapper"),this.preloaderEl=this.element.find(".mphb-preloader"),this.priceBreakdownTableEl=this.element.find("table.mphb-price-breakdown"),MPHB._data.settings.useBilling&&(this.billingSection=new MPHB.BillingSection(this.element.find("#mphb-billing-details"),{form:this,gateways:MPHB._data.gateways})),MPHB._data.settings.useCoupons&&(this.couponSection=new MPHB.CouponSection(this.element.find("#mphb-coupon-details"),{form:this})),this.element.find(".mphb-room-details").each(function(t,e){new MPHB.GuestsChooser(l(e),{minAdults:MPHB._data.checkout.min_adults,minChildren:MPHB._data.checkout.min_children})});var a=this;l(".mphb-room-details").each(function(){a.updateRatePrices(l(this))}),this.updateCheckoutInfo()},setTotal:function(t,e){this.toPay=t,this.element.find(".mphb-total-price-field").html(e)},setDeposit:function(t,e){this.toPay=t,this.element.find(".mphb-deposit-amount-field").html(e)},setupPriceBreakdown:function(t){this.priceBreakdownTableEl.replaceWith(t),this.priceBreakdownTableEl=this.element.find("table.mphb-price-breakdown")},updateCheckoutInfo:function(){var e=this;e.hideErrors(),e.showPreloader(),clearTimeout(this.updateInfoTimeout),this.updateInfoTimeout=setTimeout(function(){var t=e.parseFormToJSON();e.currentInfoAjax=l.ajax({url:MPHB._data.ajaxUrl,type:"GET",dataType:"json",data:{action:"mphb_update_checkout_info",mphb_nonce:MPHB._data.nonces.mphb_update_checkout_info,formValues:t,lang:MPHB._data.settings.currentLanguage},beforeSend:function(){null!=e.currentInfoAjax&&(e.currentInfoAjax.abort(),e.hideErrors())},success:function(t){t.hasOwnProperty("success")?t.success?t.data&&e.setCheckoutData(t.data):e.showError(t.data.message):e.showError(MPHB._data.translations.errorHasOccured)},error:function(t){e.showError(MPHB._data.translations.errorHasOccured)},complete:function(t){e.hidePreloader(),e.currentInfoAjax=null}})},500)},setCheckoutData:function(t){this.setTotal(t.newAmount,t.priceHtml),this.setupPriceBreakdown(t.priceBreakdown),MPHB._data.settings.useBilling&&(this.setDeposit(t.depositAmount,t.depositPrice),this.billingSection.updateGatewaysData(t.gateways),t.isFree?this.setFreeMode():this.unsetFreeMode())},setFreeMode:function(){this.freeBooking=!0,this.billingSection.element.addClass("mphb-hide"),this.element.append(l("",{type:"hidden",name:"mphb_gateway_id",value:"manual",id:"mphb-manual-payment-input"}))},unsetFreeMode:function(){this.freeBooking=!1,this.billingSection.element.removeClass("mphb-hide"),this.element.find("#mphb-manual-payment-input").remove()},updateRatePrices:function(t){if(t&&t.length){var e=parseInt(t.attr("data-index")),a=t.find(".mphb_sc_checkout-rate"),i=l.map(a,function(t){return parseInt(t.value)});if(!(i.length<=1)){var n=this.parseFormToJSON(),s=n.mphb_room_details[e],r=s.adults||"",o=s.children||"";clearTimeout(this.updateRatesTimeout),this.updateRatesTimeout=setTimeout(function(){l.ajax({url:MPHB._data.ajaxUrl,type:"GET",dataType:"json",data:{action:"mphb_update_rate_prices",mphb_nonce:MPHB._data.nonces.mphb_update_rate_prices,rates:i,adults:r,children:o,check_in_date:n.mphb_check_in_date,check_out_date:n.mphb_check_out_date,lang:MPHB._data.settings.currentLanguage},success:function(t){if(t.hasOwnProperty("success")){var n=t.data;l.each(a,function(t,e){var a=e.value;if(null!=n[a]){var i=l(e).parent().children("strong");i.children(".mphb-price").remove(),i.append(n[a])}})}}})},500)}}},".mphb_checkout-guests-chooser change":function(t,e){this.updateRatePrices(t.closest(".mphb-room-details")),this.updateCheckoutInfo()},".mphb_checkout-rate change":function(t,e){this.updateCheckoutInfo()},".mphb_checkout-service, .mphb_checkout-service-adults change":function(t,e){this.updateCheckoutInfo()},".mphb_checkout-service-quantity input":function(t,e){this.updateCheckoutInfo()},'select[name="mphb_country"] change':function(t,e){if(null!=this.billingSection){var a=l(t).val();this.billingSection.onInput("country",a)}},getCountry:function(){return this.getCustomerDetail("country")},".mphb-price-breakdown-expand click":function(t,e){e.preventDefault(),l(t).blur();var a=l(t).parents("tr.mphb-price-breakdown-group");a.find(".mphb-price-breakdown-rate").toggleClass("mphb-hide"),a.nextUntil("tr.mphb-price-breakdown-group").toggleClass("mphb-hide"),l(t).children(".mphb-inner-icon").toggleClass("mphb-hide")},hideErrors:function(){this.errorsWrapperEl.empty().addClass("mphb-hide")},showError:function(t){this.errorsWrapperEl.html(t).removeClass("mphb-hide")},showPreloader:function(){this.waitResponse=!0,this.bookBtnEl.attr("disabled","disabled"),this.preloaderEl.removeClass("mphb-hide")},hidePreloader:function(){this.waitResponse=!1,this.bookBtnEl.removeAttr("disabled"),this.preloaderEl.addClass("mphb-hide")},parseFormToJSON:function(){return!!(this.element&&0this.totalCapacity&&this.$adultsChooser.on("change",this.limitChildren.bind(this)))},limitChildren:function(){var t=this.$adultsChooser.val(),e=this.findMax(t,this.minChildren,this.maxChildren);this.limitOptions(this.$childrenChooser,this.minChildren,e,t)},findMax:function(t,e,a){var i=this.totalCapacity;return""!==t&&(i=this.totalCapacity-t,i=Math.max(e,i)),Math.min(i,a)},limitOptions:function(t,e,i,a){var n=e;t.children().each(function(t,e){var a=e.value;""!==a&&(a=parseInt(a),i'+s+"");t.append(r)}""!==a&&t.children(":selected").prop("selected",!1)}}),MPHB.StripeGateway=MPHB.Gateway.extend({},{publicKey:"",locale:"auto",currency:"EUR",successUrl:window.location.href,defaultCountry:"",paymentDescription:"Accommodation(s) reservation",statementDescriptor:"Hotel Booking",fullAddressRequired:!1,i18n:{},style:{},api:null,elements:null,cardControl:null,idealControl:null,ibanControl:null,payments:null,customer:null,defaultCustomer:null,mountWrapper:null,errorsWrapper:null,hasErrors:!1,undefinedError:MPHB._data.translations.errorHasOccured,init:function(t){this._super(t),this.api=Stripe(this.publicKey),this.elements=this.api.elements({locale:this.locale}),this.cardControl=this.elements.create("card",{style:this.style,hidePostalCode:this.fullAddressRequired}),this.idealControl=this.elements.create("idealBank",{style:this.style}),this.ibanControl=this.elements.create("iban",{style:this.style,supportedCountries:["SEPA"]}),this.payments=new MPHB.StripeGateway.PaymentMethods(t.settings.paymentMethods,this.defaultCountry),this.addListeners()},initSettings:function(t){this._super(t),this.publicKey=t.publicKey,this.locale=t.locale,this.currency=t.currency,this.successUrl=t.successUrl,this.defaultCountry=t.defaultCountry,this.paymentDescription=t.paymentDescription,this.statementDescriptor=t.statementDescriptor,this.fullAddressRequired=MPHB._data.settings.fullAddressRequired,this.defaultCustomer=t.customer,this.i18n=t.i18n,this.style=t.style,this.idempotencyKey=l(".mphb_sc_checkout-form").find('input[name="'+t.idempotencyKeyFieldName+'"]').val()},addListeners:function(){var t=this.onChange.bind(this);this.cardControl.on("change",t),this.ibanControl.on("change",t)},onChange:function(t){t.error?(this.showError(t.error.message),this.hasErrors=!0):(this.hideErrors(),this.hasErrors=!1)},onInput:function(t,e){"country"==t&&this.payments.selectCountry(e)},afterSelection:function(t){this._super(t),t.append(this.mountHtml()),this.mountWrapper=t,this.errorsWrapper=t.find("#mphb-stripe-errors"),this.cardControl.mount("#mphb-stripe-card-element"),this.payments.isEnabled("ideal")&&this.idealControl.mount("#mphb-stripe-ideal-element"),this.payments.isEnabled("sepa_debit")&&this.ibanControl.mount("#mphb-stripe-iban-element"),this.payments.mount(t);var e=this;this.payments.inputs.on("change",function(){switch(e.payments.currentPayment){case"card":e.cardControl.clear();break;case"ideal":e.idealControl.clear();break;case"sepa_debit":e.ibanControl.clear()}e.payments.selectPayment(this.value)}),t.removeClass("mphb-billing-fields-hidden")},cancelSelection:function(){this._super(),this.mountWrapper=null,this.errorsWrapper=null,this.cardControl.unmount(),this.payments.isEnabled("ideal")&&this.idealControl.unmount(),this.payments.isEnabled("sepa_debit")&&this.ibanControl.unmount(),this.payments.unmount()},canSubmit:function(t,e){return this.hasErrors?Promise.resolve(!1):(this.setCustomer(e),"card"==this.payments.currentPayment?this.createPaymentMethod().then(this.createPaymentIntent.bind(this,t)).then(this.confirmCardPayment.bind(this)).then(this.handleStripeErrors.bind(this)).then(this.completeCardPayment.bind(this)):this.createSource(t).then(this.handleStripeErrors.bind(this)).then(this.completeSourcePayment.bind(this)))},setCustomer:function(t){var e=l.extend({},t);e.email||(e.email=this.defaultCustomer.email),e.name||(e.name=this.defaultCustomer.name,e.first_name=this.defaultCustomer.first_name,e.last_name=this.defaultCustomer.last_name),e.hasOwnProperty("country")||(e.country=this.payments.currentCountry),this.customer=e},createPaymentIntent:function(t,e){var n=this;return new Promise(function(a,i){MPHB.post("create_stripe_payment_intent",{amount:t,description:n.paymentDescription,paymentMethodId:e.paymentMethod.id},{success:function(t){if(t.hasOwnProperty("success"))if(t.success){var e={id:t.data.id,client_secret:t.data.client_secret,object:"payment_intent"};a(e)}else n.showError(t.data.message),i(new Error(t.data.message));else n.showError(n.undefinedError),i(new Error(n.undefinedError))},error:function(t){n.showError(n.undefinedError),i(new Error(n.undefinedError))}})})},confirmCardPayment:function(t){return this.api.confirmCardPayment(t.client_secret,{paymentMethod:t.paymentMethod})},createCardPayment:function(t){return this.api.handleCardPayment(t.client_secret,this.cardControl,{payment_method_data:{billing_details:{name:this.customer.name,email:this.customer.email}}})},createPaymentMethod:function(){return this.api.createPaymentMethod({type:"card",card:this.cardControl,billing_details:{name:this.customer.name,email:this.customer.email}})},createSource:function(t){var e=this.payments.currentPayment,a=this.customer,i={type:e,amount:this.convertToSmallestUnit(t),currency:this.currency.toLowerCase(),owner:{name:a.name,email:a.email},mandate:{notification_method:"none"},redirect:{return_url:this.successUrl},statement_descriptor:this.statementDescriptor},n=null;switch(e){case"bancontact":0<=["en","de","fr","nl"].indexOf(this.locale)&&(i.bancontact={preferred_language:this.locale});break;case"ideal":n=this.idealControl;break;case"giropay":break;case"sepa_debit":n=this.ibanControl;break;case"sofort":i.sofort={country:a.country},0<=["de","en","es","it","fr","nl","pl"].indexOf(this.locale)&&(i.sofort.preferred_language=this.locale)}return null!=n?this.api.createSource(n,i):this.api.createSource(i)},handleStripeErrors:function(t){if(t.error)throw this.showError(t.error.message),new Error(t.error.message);return null!=t.paymentIntent?t.paymentIntent:t.source},completeCardPayment:function(t){return this.saveToCheckout("payment_method",this.payments.currentPayment),this.saveToCheckout("payment_intent_id",t.id),!0},completeSourcePayment:function(t){return this.saveToCheckout("payment_method",this.payments.currentPayment),this.saveToCheckout("source_id",t.id),t.redirect&&t.redirect.url&&0',t+=""},methodsHtml:function(){if(this.payments.onlyCardEnabled())return"";var n=this.i18n,s='"},fieldsHtml:function(t){if(!this.payments.isEnabled(t))return"";var e="";switch(e+='
',e+="
",t){case"card":e+=this.cardHtml();break;case"ideal":e+=this.idealHtml();break;case"sepa_debit":e+=this.ibanHtml();break;default:e+=this.redirectHtml()}return e+="
","sepa_debit"==t&&(e+='

'+this.i18n.iban_policy+"

"),e+="
"},cardHtml:function(){var t="";return this.payments.onlyCardEnabled()&&(t+='"),t+='
'},idealHtml:function(){return'
'},ibanHtml:function(){return'
'},redirectHtml:function(){return'

'+this.i18n.redirect_notice+"

"},showError:function(t){this.errorsWrapper.html(t).removeClass("mphb-hide")},hideErrors:function(){this.errorsWrapper.addClass("mphb-hide").text("")}}),MPHB.DirectBooking=can.Control.extend({},{reservationForm:null,elementsToHide:null,quantitySection:null,wrapperWithSelect:null,wrapperWithoutSelect:null,priceWrapper:null,quantitySelect:null,availableLabel:null,typeId:0,init:function(t,e){this.reservationForm=e.reservationForm,this.elementsToHide=t.find(".mphb-reserve-room-section, .mphb-rooms-quantity-wrapper, .mphb-regular-price"),this.quantitySection=t.find(".mphb-reserve-room-section"),this.wrapperWithSelect=this.quantitySection.find(".mphb-rooms-quantity-wrapper.mphb-rooms-quantity-multiple"),this.wrapperWithoutSelect=this.quantitySection.find(".mphb-rooms-quantity-wrapper.mphb-rooms-quantity-single"),this.priceWrapper=this.quantitySection.find(".mphb-period-price"),this.quantitySelect=this.quantitySection.find(".mphb-rooms-quantity"),this.availableLabel=this.quantitySection.find(".mphb-available-rooms-count"),this.typeId=t.find('input[name="mphb_room_type_id"]').val(),this.typeId=parseInt(this.typeId)},hideSections:function(){this.elementsToHide.addClass("mphb-hide")},showSections:function(t){this.quantitySection.removeClass("mphb-hide"),t&&this.priceWrapper.removeClass("mphb-hide")},resetQuantityOptions:function(t){this.quantitySelect.empty();for(var e=1;e<=t;e++){var a='";this.quantitySelect.append(a)}this.quantitySelect.val(1),this.availableLabel.text(t),1",{class:"mphb-error",html:t});this.errorsWrapper.append(e).removeClass("mphb-hide")},clearErrors:function(){this.errorsWrapper.empty().addClass("mphb-hide")},lock:function(){this.element.find("[name]").attr("disabled","disabled"),this.reserveBtn.attr("disabled","disabled").addClass("mphb-disabled"),this.reserveBtnPreloader.removeClass("mphb-hide")},unlock:function(){this.element.find("[name]").removeAttr("disabled"),this.reserveBtn.removeAttr("disabled").removeClass("mphb-disabled"),this.reserveBtnPreloader.addClass("mphb-hide")},setFormWaitingMode:function(){this.mode=MPHB.ReservationForm.MODE_WAITING,this.lock()},setFormNormalMode:function(){this.mode=MPHB.ReservationForm.MODE_NORMAL,this.unlock()},initCheckInDatepicker:function(){var t=this.formEl.find('input[type="text"][id^=mphb_check_in_date]');this.checkInDatepicker=new MPHB.RoomTypeCheckInDatepicker(t,{form:this,roomTypeId:this.searchRoomTypeId}),this.updateCheckInLimitations()},initCheckOutDatepicker:function(){var t=this.formEl.find('input[type="text"][id^=mphb_check_out_date]');this.checkOutDatepicker=new MPHB.RoomTypeCheckOutDatepicker(t,{form:this,roomTypeId:this.searchRoomTypeId})},initReserveBtn:function(){this.reserveBtn=this.formEl.find(".mphb-reserve-btn"),this.reserveBtnPreloader=this.formEl.find(".mphb-preloader"),this.setFormNormalMode()},updateCheckInLimitations:function(t){void 0===t&&(t=!0);var e=this.retrieveCheckInLimitations();this.checkInDatepicker.setOption("maxAdvanceDate",e.maxAdvanceDate)},updateCheckOutLimitations:function(t){void 0===t&&(t=!0);var e=this.retrieveCheckOutLimitations(this.checkInDatepicker.getDate(),this.checkOutDatepicker.getDate());this.checkOutDatepicker.setOption("minDate",e.minDate),this.checkOutDatepicker.setOption("maxDate",e.maxDate),this.checkOutDatepicker.setDate(t?e.date:null)},retrieveCheckInLimitations:function(){return{maxAdvanceDate:MPHB.HotelDataManager.myThis.reservationRules.getMaxAdvanceDate(this.checkInDatepicker.roomTypeId)}},retrieveCheckOutLimitations:function(t,e){var a=MPHB.HotelDataManager.myThis.today,i=null,n=null;return null!==t&&(a=MPHB.HotelDataManager.myThis.reservationRules.getMinCheckOutDate(t,this.searchRoomTypeId),i=MPHB.HotelDataManager.myThis.reservationRules.getMaxCheckOutDate(t,this.searchRoomTypeId),this.isDirectBooking&&(i=this.roomTypeData.getNearestLockedCheckOutDate(t,i),i=this.roomTypeData.getNearestHaveNotPriceDate(t,i)),i=MPHB.HotelDataManager.myThis.dateRules.getNearestNotStayInDate(t,i),n=this.isCheckOutDateNotValid(t,e,a,i)?this.retrieveRecommendedCheckOutDate(t,a,i):e),{minDate:a,maxDate:i,date:n}},retrieveRecommendedCheckOutDate:function(t,e,a){for(var i=null,n=MPHB.Utils.cloneDate(e);MPHB.Utils.formatDateToCompare(n)<=MPHB.Utils.formatDateToCompare(a);){var s=l.datepick.add(MPHB.Utils.cloneDate(n),-1,"d");if(!this.isCheckOutDateNotValid(t,n,e,a)&&(!this.isDirectBooking||this.roomTypeData.hasPriceForDate(s))){i=n;break}n=l.datepick.add(n,1,"d")}return i},isCheckOutDateNotValid:function(t,e,a,i){var n=!this.isDirectBooking||this.roomTypeData.canCheckOut(e);return n=n&&MPHB.HotelDataManager.myThis.dateRules.canCheckOut(e),null===e||MPHB.Utils.formatDateToCompare(e)MPHB.Utils.formatDateToCompare(i)||!MPHB.HotelDataManager.myThis.reservationRules.isCheckOutSatisfy(t,e,this.searchRoomTypeId)||!n},clearDatepickers:function(){this.checkInDatepicker.clear(),this.checkOutDatepicker.clear()},refreshDatepickers:function(){this.checkInDatepicker.refresh(),this.checkOutDatepicker.refresh()},onDatepickChange:function(){null!=this.directBooking&&this.directBooking.hideSections()}}),MPHB.RoomTypeCalendar=can.Control.extend({},{roomTypeData:null,roomTypeId:null,init:function(t,e){this.roomTypeId=parseInt(t.attr("id").replace(/^mphb-calendar-/,"")),this.roomTypeData=MPHB.HotelDataManager.myThis.getRoomTypeData(this.roomTypeId);var a=MPHB._data.settings.numberOfMonthCalendar,i=t.attr("data-monthstoshow");if(i){var n=i.split(",");a=1==n.length?parseInt(i):n}var s=MPHB.HotelDataManager.myThis.reservationRules.getMinCheckInDate(this.roomTypeId);t.hide().datepick({onDate:this.proxy(function(t,e){var a={selectable:!1,dateClass:"mphb-date-cell",title:"",roomTypeId:this.roomTypeId};return e?a=this.roomTypeData.fillDateData(a,t):a.dateClass+=" mphb-extra-date",a}),minDate:s,monthsToShow:a,firstDay:MPHB._data.settings.firstDay,pickerClass:MPHB._data.settings.datepickerClass,useMouseWheel:!1}).show(),l(window).on("mphb-update-room-type-data-"+this.roomTypeId,this.proxy(function(t){this.refresh()}))},refresh:function(){this.element.hide(),l.datepick._update(this.element[0],!0),this.element.show()}}),MPHB.Datepicker("MPHB.RoomTypeCheckInDatepicker",{},{isDirectBooking:!1,init:function(t,e){this._super(t,e),this.isDirectBooking="1"==MPHB._data.settings.isDirectBooking,0===this.roomTypeId&&(this.roomTypeId=e.form.hasOwnProperty("roomTypeId")?e.form.roomTypeId:0)},getDatepickSettings:function(){return{minDate:MPHB.HotelDataManager.myThis.reservationRules.getMinCheckInDate(this.roomTypeId),onDate:this.proxy(function(t,e){var a={dateClass:"mphb-date-cell",selectable:!1,title:"",roomTypeId:this.roomTypeId};if(e){var i=MPHB.Utils.compareDates(t,MPHB.HotelDataManager.myThis.reservationRules.getMinCheckInDate(this.roomTypeId),"<"),n=null!==this.getMaxAdvanceDate()&&MPHB.Utils.compareDates(t,this.getMaxAdvanceDate(),">"),s=!i&&!n&&MPHB.HotelDataManager.myThis.reservationRules.isCheckInSatisfy(t,this.roomTypeId)&&MPHB.HotelDataManager.myThis.dateRules.canCheckIn(t);this.isDirectBooking?(a=this.form.roomTypeData.fillDateData(a,t,"checkIn"),s=s&&this.form.roomTypeData.canCheckIn(t)):(this.form.roomTypeData.isEarlierThanToday(t)&&(a.dateClass+=" mphb-past-date",a.title+=" "+MPHB._data.translations.past),a=MPHB.HotelDataManager.myThis.fillDateCellData(a,t,"checkIn")),s&&(a.selectable=!0)}else a.dateClass+=" mphb-extra-date";return a.selectable?a.dateClass+=" mphb-date-selectable":a.dateClass+=" mphb-unselectable-date",a}),onSelect:this.proxy(function(t){this.form.updateCheckOutLimitations(),this.form.onDatepickChange()}),pickerClass:"mphb-datepick-popup mphb-check-in-datepick "+MPHB._data.settings.datepickerClass}},setDate:function(t){return null==t?this._super(t):MPHB.HotelDataManager.myThis.reservationRules.isCheckInSatisfy(t,this.roomTypeId)&&MPHB.HotelDataManager.myThis.dateRules.canCheckIn(t)?this._super(t):this._super(null)}}),MPHB.RoomTypeCheckOutDatepicker=MPHB.Datepicker.extend({},{isDirectBooking:!1,init:function(t,e){this._super(t,e),this.isDirectBooking="1"==MPHB._data.settings.isDirectBooking},getDatepickSettings:function(){return{onDate:this.proxy(function(t,e){var a={dateClass:"mphb-date-cell",selectable:!1,title:"",roomTypeId:this.roomTypeId};if(e){var i=this.form.checkInDatepicker.getDate(),n=null!==this.getMinDate()&&MPHB.Utils.formatDateToCompare(t)MPHB.Utils.formatDateToCompare(this.getMaxDate());if(null!==i&&MPHB.Utils.formatDateToCompare(t)===MPHB.Utils.formatDateToCompare(i)&&(a.dateClass+=" mphb-check-in-date",a.title+=MPHB._data.translations.checkInDate),n){var r=!!i&&MPHB.HotelDataManager.myThis.reservationRules.getMinCheckOutDate(i,this.roomTypeId);MPHB.Utils.formatDateToCompare(t)=this.activeRoomsCount},isDateBookingCheckIn:function(t){var e=l.datepick.formatDate("yyyy-mm-dd",t);return this.checkInDates.hasOwnProperty(e)},isDateBookingCheckOut:function(t){var e=l.datepick.formatDate("yyyy-mm-dd",t);return!!this.checkOutDates.hasOwnProperty(e)&&(this.bookedDates.hasOwnProperty(e)?this.checkOutDates[e]+this.bookedDates[e]>=this.activeRoomsCount:this.checkOutDates[e]>=this.activeRoomsCount)},hasPriceForDate:function(t){var e=l.datepick.formatDate("yyyy-mm-dd",t);return MPHB.Utils.inArray(e,this.havePriceDates)},getAvailableRoomsCount:function(t){var e=l.datepick.formatDate("yyyy-mm-dd",t),a=this.activeRoomsCount;return this.bookedDates.hasOwnProperty(e)&&(a-=this.bookedDates[e]),this.blockedDates.hasOwnProperty(e)&&(a-=this.blockedDates[e]),a<0&&(a=0),a},fillDateData:function(t,e,a,i){i=i||e;var n=[],s=[];switch(this.getDateStatus(e)){case MPHB.HotelDataManager.ROOM_STATUS_PAST:s.push("mphb-past-date"),n.push(MPHB._data.translations.past);break;case MPHB.HotelDataManager.ROOM_STATUS_AVAILABLE:s.push("mphb-available-date"),n.push(MPHB._data.translations.available+"("+this.getAvailableRoomsCount(e)+")"),this.isDateBookingCheckOut(e)&&s.push("mphb-date-check-out");break;case MPHB.HotelDataManager.ROOM_STATUS_NOT_AVAILABLE:s.push("mphb-not-available-date"),n.push(MPHB._data.translations.notAvailable);break;case MPHB.HotelDataManager.ROOM_STATUS_BOOKED:s.push("mphb-booked-date"),n.push(MPHB._data.translations.booked),this.isDateBookingCheckIn(e)&&s.push("mphb-date-check-in"),this.isDateBookingCheckOut(e)&&s.push("mphb-date-check-out");break;case MPHB.HotelDataManager.ROOM_STATUS_EARLIER_MIN_ADVANCE:case MPHB.HotelDataManager.ROOM_STATUS_LATER_MAX_ADVANCE:n.push(MPHB._data.translations.notAvailable),this.isDateBookingCheckOut(e)&&(s.push("mphb-booked-date"),s.push("mphb-date-check-out"),s.push("mphb-available-date"))}return t.dateClass+=(t.dateClass.length?" ":"")+s.join(" "),t.title+=(t.title.length?", ":"")+n.join(", "),t=MPHB.HotelDataManager.myThis.fillDateCellData(t,e,a,i)},appendRulesToTitle:function(t,e){var a=[];return MPHB.HotelDataManager.myThis.dateRules.canStayIn(t)||a.push(MPHB._data.translations.notStayIn),MPHB.HotelDataManager.myThis.dateRules.canCheckIn(t)||a.push(MPHB._data.translations.notCheckIn),MPHB.HotelDataManager.myThis.dateRules.canCheckOut(t)||a.push(MPHB._data.translations.notCheckOut),a.length&&(e+=" "+MPHB._data.translations.rules+" "+a.join(", ")),e},isEarlierThanToday:function(t){return MPHB.Utils.formatDateToCompare(t)"),n=MPHB.Utils.compareDates(t,this.getMinDate(),"<");e?(!i&&!n&&MPHB.HotelDataManager.myThis.reservationRules.isCheckInSatisfy(t,this.roomTypeId)&&MPHB.HotelDataManager.myThis.dateRules.canCheckIn(t)&&(a.selectable=!0),a=MPHB.HotelDataManager.myThis.fillDateCellData(a,t,"checkIn")):a.dateClass+=" mphb-extra-date";return a.selectable?a.dateClass+=" mphb-selectable-date":a.dateClass+=" mphb-unselectable-date",a}),pickerClass:"mphb-datepick-popup mphb-check-in-datepick "+MPHB._data.settings.datepickerClass}}}),MPHB.SearchCheckOutDatepicker=MPHB.Datepicker.extend({},{getDatepickSettings:function(){return{onDate:this.proxy(function(t,e){var a={dateClass:"mphb-date-cell",selectable:!1,title:""};if(e){var i=this.form.checkInDatepicker.getDate(),n=null!==this.getMinDate()&&MPHB.Utils.formatDateToCompare(t)MPHB.Utils.formatDateToCompare(this.getMaxDate());if(null!==i&&MPHB.Utils.formatDateToCompare(t)===MPHB.Utils.formatDateToCompare(i)&&(a.dateClass+=" mphb-check-in-date",a.title+=MPHB._data.translations.checkInDate),n&&(MPHB.Utils.formatDateToCompare(t)MPHB.Utils.formatDateToCompare(i)||!MPHB.HotelDataManager.myThis.reservationRules.isCheckOutSatisfy(t,e)||!MPHB.HotelDataManager.myThis.dateRules.canCheckOut(e)}}),MPHB.RoomBookSection=can.Control.extend({},{roomTypeId:null,roomTitle:"",roomPrice:0,quantitySelect:null,bookButton:null,confirmButton:null,removeButton:null,messageHolder:null,messageWrapper:null,form:null,init:function(t,e){this.reservationCart=e.reservationCart,this.roomTypeId=parseInt(t.attr("data-room-type-id")),this.roomTitle=t.attr("data-room-type-title"),this.roomPrice=parseFloat(t.attr("data-room-price")),this.confirmButton=t.find(".mphb-confirm-reservation"),this.quantitySelect=t.find(".mphb-rooms-quantity"),this.messageWrapper=t.find(".mphb-rooms-reservation-message-wrapper"),this.messageHolder=t.find(".mphb-rooms-reservation-message")},getRoomTypeId:function(){return this.roomTypeId},getPrice:function(){return this.roomPrice},".mphb-book-button click":function(t,e){e.preventDefault(),e.stopPropagation();var a=parseInt(this.quantitySelect.val());if(this.reservationCart.addToCart(this.roomTypeId,a),MPHB._data.settings.isDirectBooking)t.prop("disabled",!0),this.reservationCart.confirmReservation();else{var i=(1==a?MPHB._data.translations.roomsAddedToReservation_singular:MPHB._data.translations.roomsAddedToReservation_plural).replace("%1$d",a).replace("%2$s",this.roomTitle);this.messageHolder.html(i),this.element.addClass("mphb-rooms-added")}},".mphb-remove-from-reservation click":function(t,e){e.preventDefault(),e.stopPropagation(),this.reservationCart.removeFromCart(this.roomTypeId),this.messageHolder.empty(),this.element.removeClass("mphb-rooms-added")},".mphb-confirm-reservation click":function(t,e){e.preventDefault(),e.stopPropagation(),this.reservationCart.confirmReservation()}}),MPHB.ReservationCart=can.Control.extend({},{cartForm:null,cartDetails:null,roomBookSections:{},cartContents:{},init:function(t,e){this.cartForm=t.find("#mphb-reservation-cart"),this.cartDetails=t.find(".mphb-reservation-details"),this.initRoomBookSections(t.find(".mphb-reserve-room-section"))},initRoomBookSections:function(t){var a,i=this;l.each(t,function(t,e){a=new MPHB.RoomBookSection(l(e),{reservationCart:i}),i.roomBookSections[a.getRoomTypeId()]=a})},addToCart:function(t,e){this.cartContents[t]=e,this.updateCartView(),this.updateCartInputs()},removeFromCart:function(t){delete this.cartContents[t],this.updateCartView(),this.updateCartInputs()},calcRoomsInCart:function(){var a=0;return l.each(this.cartContents,function(t,e){a+=e}),a},calcTotalPrice:function(){var a=0,i=0,n=this;return l.each(this.cartContents,function(t,e){i=n.roomBookSections[t].getPrice(),a+=i*e}),a},updateCartView:function(){if(l.isEmptyObject(this.cartContents))this.cartForm.addClass("mphb-empty-cart");else{var t=this.calcRoomsInCart(),e=(1==t?MPHB._data.translations.countRoomsSelected_singular:MPHB._data.translations.countRoomsSelected_plural).replace("%s",t);this.cartDetails.find(".mphb-cart-message").html(e);var a=this.calcTotalPrice(),i=MPHB.format_price(a,{trim_zeros:!0});this.cartDetails.find(".mphb-cart-total-price>.mphb-cart-total-price-value").html(i),this.cartForm.removeClass("mphb-empty-cart")}},updateCartInputs:function(){this.cartForm.find('[name^="mphb_rooms_details"]').remove();var i=this;l.each(this.cartContents,function(t,e){var a=l("",{name:"mphb_rooms_details["+t+"]",type:"hidden",value:e});i.cartForm.prepend(a)})},confirmReservation:function(){this.cartForm.submit()}}),MPHB.StripeGateway.PaymentMethods=can.Construct.extend({},{listAll:["card","bancontact","ideal","giropay","sepa_debit","sofort"],listEnabled:["card"],paymentMethods:{},currentPayment:"card",currentCountry:"",inputs:null,isMounted:!1,init:function(t,e){this.listEnabled=t.slice(0),this.initPayments(),this.selectCountry(e)},initPayments:function(){var e=this;this.forEach(function(t){e.paymentMethods[t]={isEnabled:0<=e.listEnabled.indexOf(t),nav:null,fields:null}})},selectPayment:function(t){t!=this.currentPayment&&this.paymentMethods.hasOwnProperty(t)&&(this.togglePayment(this.currentPayment,!1),this.togglePayment(t,!0),this.currentPayment=t)},togglePayment:function(t,e){this.isMounted&&(this.paymentMethods[t].nav.toggleClass("active",e),this.paymentMethods[t].fields.toggleClass("mphb-hide",!e))},selectCountry:function(t){this.currentCountry!=t&&(this.currentCountry=t,this.currentPayment="card",this.showRelevantMethods())},showRelevantMethods:function(){if(this.isMounted){var a=this.currentPayment;this.forEach(function(t,e){e.fields.toggleClass("mphb-hide",t!=a)}),this.inputs.val([a])}},mount:function(a){this.forEach(function(t,e){e.nav=a.find(".mphb-stripe-payment-method."+t),e.fields=a.find(".mphb-stripe-payment-fields."+t)}),this.inputs=a.find('input[name="stripe_payment_method"]'),this.isMounted=!0},unmount:function(){this.forEach(function(t,e){e.nav=null,e.fields=null}),this.inputs=null,this.isMounted=!1},forEach:function(e){var a=this;this.listAll.forEach(function(t){e(t,a.paymentMethods[t],a)})},isEnabled:function(t){return this.paymentMethods[t].isEnabled},onlyCardEnabled:function(){return 1==this.listEnabled.length&&this.paymentMethods.card.isEnabled},isSelected:function(t){return t==this.currentPayment}}),new MPHB.HotelDataManager(MPHB._data),MPHB._data.page.isCheckoutPage?new MPHB.CheckoutForm(l(".mphb_sc_checkout-form")):MPHB._data.page.isCreateBookingPage&&new MPHB.CheckoutForm(l(".mphb_cb_checkout_form")),MPHB._data.page.isSearchResultsPage&&new MPHB.ReservationCart(l(".mphb_sc_search_results-wrapper"));var t=l(".mphb-calendar.mphb-datepick");l.each(t,function(t,e){new MPHB.RoomTypeCalendar(l(e))});var e=l(".mphb-booking-form");l.each(e,function(t,e){new MPHB.ReservationForm(l(e))});var a=l("form.mphb_sc_search-form, form.mphb_widget_search-form, form.mphb_cb_search_form");l.each(a,function(t,e){new MPHB.SearchForm(l(e))});var i=l(".mphb-flexslider-gallery-wrapper");l.each(i,function(t,e){new MPHB.FlexsliderGallery(e)});var n=l(".mphb-checkout-terms-wrapper");0