1!function o(r,l,s){function c(t,e){if(!l[t]){if(!r[t]){var a="function"==typeof require&&require;if(!e&&a)return a(t,!0);if(u)return u(t,!0);var n=new Error("Cannot find module '"+t+"'");throw n.code="MODULE_NOT_FOUND",n}var i=l[t]={exports:{}};r[t][0].call(i.exports,function(e){return c(r[t][1][e]||e)},i,i.exports,o,r,l,s)}return l[t].exports}for(var u="function"==typeof require&&require,e=0;e<s.length;e++)c(s[e]);return c}({1:[function(e,t,a){"use strict";var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i="function"==typeof Symbol&&"symbol"===n(Symbol.iterator)?function(e){return void 0===e?"undefined":n(e)}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":void 0===e?"undefined":n(e)};Object.defineProperty(a,"__esModule",{value:!0});var o=function(){function n(e,t){for(var a=0;a<t.length;a++){var n=t[a];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(e,t,a){return t&&n(e.prototype,t),a&&n(e,a),e}}();function c(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!==(void 0===t?"undefined":i(t))&&"function"!=typeof t?e:t}function r(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+(void 0===t?"undefined":i(t)));e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var l=function(e){function s(e){c(this,s);var t=u(this,(s.__proto__||Object.getPrototypeOf(s)).call(this,e));t.fieldName="";var a=t.props,n=a.fieldName,i=a.fieldValue,o=a.field;null!=n&&(t.fieldName=n);var r=t.parseFieldValue(i);if(t.state={vals:r,current:0,show_selector:!1,is_checking:!1,check_available:!1},t.options={showing:1,max:12},null!=o&&o.max){var l=parseInt(o.max);isNaN(l)||(t.options.max=l)}return t.format="YYYY-MM-DD",null!=o&&null!=o.format&&""!=o.format&&(t.format=o.format),t.wrapperRef=null,t.toggleDate=t.toggleDate.bind(t),t.switchMonth=t.switchMonth.bind(t),t.onFocusInput=t.onFocusInput.bind(t),t.setWrapperRef=t.setWrapperRef.bind(t),t.handleClickOutside=t.handleClickOutside.bind(t),t.onClickApply=t.onClickApply.bind(t),t.onClickCancel=t.onClickCancel.bind(t),t}return r(s,React.Component),o(s,[{key:"setWrapperRef",value:function(e){this.wrapperRef=e}},{key:"componentDidMount",value:function(){document.addEventListener("mousedown",this.handleClickOutside,!0)}},{key:"componentWillUnmount",value:function(){document.removeEventListener("mousedown",this.handleClickOutside,!0)}},{key:"handleClickOutside",value:function(e){1==this.state.show_selector&&this.wrapperRef&&0==this.wrapperRef.contains(e.target)&&this.setState({show_selector:!1})}},{key:"parseFieldValue",value:function(e){var t=[];if(null!=e&&Array.isArray(e)&&2==e.length){var a=/-/gm;t=[e[0].replace(a,""),e[1].replace(a,"")]}return(t=t.filter(function(e,t,a){return a.indexOf(e)===t})).length<2&&(t=[]),t}},{key:"doAvailableCheck",value:function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null,a=this,t=a.props.field;if(null!=t&&null!=t.action&&""!=t.action){a.setState({is_checking:!0});var n={action:t.action};null!=t.postid&&""!=t.postid&&(n.postid=t.postid),n.dates=a.getQueryDates(e),axios.post(_townhub_add_ons.url,Qs.stringify(n)).then(function(e){if(null!=e.data.debug&&e.data.debug&&console.log(e),e.data.success){var t={available:e.data.available};null!=e.data.check_available&&!0===e.data.check_available&&(t.check_available=!0),t.is_checking=!1,a.setState(t)}}).catch(function(e){console.log(e),a.setState({is_checking:!1})})}}},{key:"getQueryDates",value:function(e){var t=this.options.showing,a=this.state.current;null!=e&&(a=e);for(var n=[],i=0;i<t;i++)for(var o=new Date,r=o.getFullYear(),l=o.getMonth(),s=new Date(r,l+a+i+1,0).getDate(),c=1;c<=s;c++){var u=new Date(r,l+a+i,c),h=u.getFullYear(),d=u.getMonth(),f=this._getMonthNum(d),m=this._getDateNum(c);n.push(""+h+f+m)}return n}},{key:"onFocusInput",value:function(e){this.doAvailableCheck(),this.setState({show_selector:!0})}},{key:"onClickCancel",value:function(){this.setState({vals:[],show_selector:!1}),this.props.getCheckInOut(["",""])}},{key:"onClickApply",value:function(){this.setState({show_selector:!1})}},{key:"switchMonth",value:function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"next",t=this.options.max,a=this.state.current;"next"==e?a<t&&++a:0<a&&--a,this.setState({current:a})}},{key:"toggleDate",value:function(e){var t=1<arguments.length&&void 0!==arguments[1]&&arguments[1],a=this.state.vals;Array.isArray(a)&&(2<=a.length?a=[e]:1==a.length?t?a=[e]:a[0]<=e?a.push(e):a=[e]:a=[e],2==a.length?(this.props.getCheckInOut([this._formatOutDate(a[0]),this._formatOutDate(a[1])]),this.setState({show_selector:!1})):this.setState({vals:a}))}},{key:"_fieldClass",value:function(){var e="submit-field",t=this.state,a=t.vals,n=t.show_selector;return 2==a.length&&(e+=" ckinout-has-value"),1==n&&(e+=" show-selector"),e}},{key:"_renderFieldHeader",value:function(){var e=this.props.field;return React.createElement("div",{className:"lfield-header"},""!=e.icon&&React.createElement("span",{className:"lfield-icon"},React.createElement("i",{className:e.icon})),""!=e.label&&React.createElement("label",{className:"lfield-label",onClick:this.onFocusInput},e.label))}},{key:"_getMonthDatas",value:function(e){var t=this.state,a=t.check_available,n=t.available,i=this.state.vals;null!=e&&"function"==typeof e.getMonth||(e=new Date);var o=new Date,r=e.getFullYear(),l=e.getMonth(),s=this._getMonthNum(l),c=new Date(r,l,1),u=new Date(r,l+1,0),h=c.getDay(),d=u.getDate();o=new Date(o.getFullYear(),o.getMonth(),o.getDate());var f=[],m={iso_date:"2018-12-16",date:0,status:"prev",time:"",selected:!1,first:!1,last:!1,inside:!1};
1if(null!=_townhub_add_ons.week_starts_monday&&"yes"==_townhub_add_ons.week_starts_monday)if(0===h)f.push(m),f.push(m),f.push(m),f.push(m),f.push(m),f.push(m);else for(var p=1;p<h;p++)f.push(m);else if(0!==h)for(var v=0;v<h;v++)f.push(m);for(var g=1;g<=d;g++){var y=new Date(r,l,g),b=this._getDateNum(g),_=""+r+s+b,k=r+"-"+s+"-"+b,w=!1,D=!1,E=!1,R=!1;2==i.length?(_==i[0]&&(D=w=!0),_==i[1]&&(E=w=!0),i[0]<_&&_<i[1]&&(R=!0)):1==i.length&&_==i[0]&&(D=w=!0);var N={iso_date:k,date:g,status:y<o?"past":"available",time:_,selected:w,first:D,last:E,inside:R};if(1===i.length&&null!=this.props.min_nights&&"available"==N.status){var S=parseInt(i[0]),C=parseInt(_),O=parseInt(this.props.min_nights);isNaN(S)||isNaN(C)||isNaN(O)||S<C&&this._getNightsDiff(C,S)<O&&(N.status="unavailable")}null!=a&&!0===a&&(null!=n[_]?N.metas=n[_]:"past"!=N.status&&(N.status="unavailable")),f.push(N)}return f}},{key:"_getMonthNum",value:function(e){return(e=parseInt(e)+1)<10?"0"+e:e}},{key:"_getDateNum",value:function(e){return e<10?"0"+e:e}},{key:"_renderDays",value:function(){var a=[];return _townhub_add_ons.i18n.days.forEach(function(e,t){return a.push(React.createElement(h,{key:t,day:e}))}),React.createElement("div",{className:"cal-days"},a)}},{key:"_getMonthString",value:function(e){null!=e&&"function"==typeof e.getMonth||(e=new Date);var t=e.getFullYear(),a=e.getMonth();return _townhub_add_ons.i18n.months[a].replace("{YEAR}",t)}},{key:"_formatOutDate",value:function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"20181216",t=!(1<arguments.length&&void 0!==arguments[1])||arguments[1],a="",n="",i="";return null!=(e=String(e))&&8==e.length?(a=e.substr(0,4),n=e.substr(4,2),i=e.substr(6,2),1==t?a+"-"+n+"-"+i:this.format.replace("YYYY",a).replace("MM",n).replace("DD",i)):""}},{key:"_renderStringValue",value:function(){var e=this.state.vals,t="";return 2==e.length&&(t+=this._formatOutDate(e[0],!1),t+=" -> ",t+=this._formatOutDate(e[1],!1)),t}},{key:"_getDatesDiff",value:function(){var e=0<arguments.length&&void 0!==arguments[0]&&arguments[0],t=this.state.vals,a=0;if(2==t.length){var n=new Date(this._formatOutDate(t[0])),i=new Date(this._formatOutDate(t[1]));a=Math.floor((i-n)/864e5),1==e&&++a}return a}},{key:"_getNightsDiff",value:function(e,t){var a=2<arguments.length&&void 0!==arguments[2]&&arguments[2],n=0,i=new Date(this._formatOutDate(e,!0)),o=new Date(this._formatOutDate(t,!0));return n=Math.floor((i-o)/864e5),1==a&&++n,n}},{key:"_renderMonthFooter",value:function(){return this.state.vals.length<2&&" disabled",React.createElement("div",{className:"cal-months-footer"},React.createElement("span",{className:"selected-date"},this._renderStringValue()),React.createElement("button",{className:"btn-cal-cancel",type:"button",onClick:this.onClickCancel},_townhub_add_ons.i18n.checkout_can))}},{key:"_renderSelector",value:function(){var l=this,e=this.options,t=e.showing,a=e.max,s=this.state.current,n="cal-month-nav month-next",i="cal-month-nav month-prev";s<=0&&(i+=" month-disabled"),a<=s&&(n+=" month-disabled");for(var o=React.createElement("article",{className:"cal-months-header"},React.createElement("div",{className:i,onClick:function(e){return l.switchMonth("prev")}},React.createElement("span",null)),React.createElement("div",{className:n,onClick:function(e){return l.switchMonth("next")}},React.createElement("span",null))),c=[],r=function(e){var t=new Date,a=t.getFullYear(),n=t.getMonth(),i=new Date(a,n+s+e,1),o=l._getMonthDatas(i),r=[];o.forEach(function(e,t){return r.push(React.createElement(f,{key:t,date:e,toggleDate:l.toggleDate}))}),c.push(React.createElement("div",{key:e,className:"cal-month"},React.createElement("div",{className:"cal-month-header"},React.createElement("div",{className:"cal-month-string"},l._getMonthString(i))),React.createElement("div",{className:"cal-dates-wrap"},l._renderDays(),React.createElement("div",{className:"cal-dates"},r))))},u=0;u<t;u++)r(u);var h="cal-months-wrap months-"+this.options.showing,d="lfield-content checkinout-field";return null!=this.props.field&&null!=this.props.field.action&&""!=this.props.field.action&&(d+=" checkinout-picker-wrap"),React.createElement("div",{className:d},!0===this.state.is_checking&&React.createElement("div",{className:"loading-indicator calendar-check-loading"},React.createElement("span",null),React.createElement("span",null),React.createElement("span",null)),React.createElement("div",{className:h},o,c,this._renderMonthFooter()))}},{key:"render",value:function(){var e=this.options;e.showing,e.max,this.state.current;return React.createElement("div",{className:this._fieldClass(),ref:this.setWrapperRef},null!=this.props.field&&this._renderFieldHeader(),React.createElement("input",{type:"text",className:"in-out-dates",value:this._renderStringValue(),readOnly:!0,onFocus:this.onFocusInput}),React.createElement("div",{className:"in-out-count"},React.createElement("i",{className:"fa fa-question-circle"}),React.createElement("span",null,_townhub_add_ons.i18n.nights," : ",React.createElement("strong",null,this._getDatesDiff(!1)))),1==this.state.show_selector&&this._renderSelector())}}],[{key:"getDerivedStateFromProps",value:function(e,t){var a=t.vals,n=e.fieldValue;if(2===n.length){var i=n[0].replace(/-/gm,""),o=n[1].replace(/-/gm,"");if(2===a.length&&(i!=a[0]||o!=a[1]))return{vals:[i,o]};if(0===a.length&&""!=i&&""!=o)return{vals:[i,o]}}return null}}]),s}();a.default=l;var f=function(e){function a(e){c(this,a);var t=u(this,(a.__proto__||Object.getPrototypeOf(a)).call(this,e));return t.onToggle=t.onToggle.bind(t),t}return r(a,React.Component),o(a,[{key:"onToggle",value:function(e){var t=this.props.date,a=t.time,n=t.status,i=t.selected;"available"===n&&this.props.toggleDate(a,i)}},{key:"render",value:function(){var e=this.props.date,t=e.status,a=e.date,n="cal-date";return n+="prev"===t?" cal-date-diff":"past"===t?" cal-date-past":"unavailable"===t?" cal-date-unavailable":" cal-date-available",e.selected&&(n+=" cal-date-checked"),e.first&&(n+=" cal-date-cfirst"),e.last&&(n+=" cal-date-clast"),e.inside&&(n+=" cal-date-inside"),React.createElement("div",{className:n,onClick:this.onToggle},"prev"!=t&&React.createElement("span",null,a))}}]),a}(),h=function(e){function t(){return c(this,t),u(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return r(t,React.Component),o(t,[{key:"render",value:function(){var e=this.props.day;return React.createElement("div",{className:"cal-day"},e)}}]),t}()},{}],2:[function(e,t,a){"use strict";var h=n(e("./src/components/DatePickerField")),m=n(e("./src/components/DateRangePicker")),l=n(e("./src/components/TimePickerField")),p=n(e("./src/components/AvailabilityCalendar"));
1function n(e){return e&&e.__esModule?e:{default:e}}function i(){var e=document.querySelectorAll(".cth-date-picker");if(e.length)for(var t=0;t<e.length;t++){var a=e[t],n="date-picker",i="",o="",r="",l="",s="",c=!1,u="";a.hasAttribute("data-name")&&(n=a.getAttribute("data-name")),a.hasAttribute("data-format")&&(i=a.getAttribute("data-format")),a.hasAttribute("data-default")&&(o=a.getAttribute("data-default")),""==o&&(o="current"),a.hasAttribute("data-action")&&(r=a.getAttribute("data-action")),a.hasAttribute("data-postid")&&(l=a.getAttribute("data-postid")),a.hasAttribute("data-selected")&&(u=a.getAttribute("data-selected")),a.hasAttribute("data-placeholder")&&(s=a.getAttribute("data-placeholder")),a.hasAttribute("data-required")&&(c="yes"===a.getAttribute("data-required")),ReactDOM.render(React.createElement(h.default,{onChange:function(e){},fname:n,format:i,value:o,action:r,postid:l,selected:u,placeholder:s,required:c}),a)}}function o(){var e=document.querySelectorAll(".cth-daterange-picker");if(e.length)for(var t=0;t<e.length;t++){var a=e[t],n="checkin",i="checkout",o="12",r="",l="",s="",c="",u="",h="",d="",f=1;a.hasAttribute("data-max")&&(o=a.getAttribute("data-max")),a.hasAttribute("data-name")&&(n=a.getAttribute("data-name")),a.hasAttribute("data-name2")&&(i=a.getAttribute("data-name2")),a.hasAttribute("data-format")&&(r=a.getAttribute("data-format")),a.hasAttribute("data-default")&&(l=a.getAttribute("data-default")),a.hasAttribute("data-action")&&(h=a.getAttribute("data-action")),a.hasAttribute("data-postid")&&(u=a.getAttribute("data-postid")),a.hasAttribute("data-label")&&(s=a.getAttribute("data-label")),a.hasAttribute("data-icon")&&(c=a.getAttribute("data-icon")),a.hasAttribute("data-selected")&&(d=a.getAttribute("data-selected")),a.hasAttribute("data-mnights")&&0<a.getAttribute("data-mnights")&&(f=a.getAttribute("data-mnights")),ReactDOM.render(React.createElement(m.default,{fname:n,fname2:i,format:r,value:l,label:s,icon:c,selected:d,action:h,postid:u,mnights:f,max:o}),a)}}function r(){var e=document.querySelectorAll(".cth-time-picker");if(e.length)for(var t=0;t<e.length;t++){var a=e[t],n="time-picker",i="",o="",r="";a.hasAttribute("data-name")&&(n=a.getAttribute("data-name")),a.hasAttribute("data-format")&&(i=a.getAttribute("data-format")),a.hasAttribute("data-default")&&(o=a.getAttribute("data-default")),a.hasAttribute("data-icon")&&(r=a.getAttribute("data-icon")),ReactDOM.render(React.createElement(l.default,{fname:n,format:i,value:o,icon:r}),a)}}i(),o(),r(),function(){var e=document.querySelectorAll(".cth-availability-calendar");if(e.length)for(var t=0;t<e.length;t++){var a=e[t],n="1",i="12",o="date-picker",r="",l="",s="",c="",u="",h=!1,d=1,f="";a.hasAttribute("data-show")&&(n=a.getAttribute("data-show")),a.hasAttribute("data-max")&&(i=a.getAttribute("data-max")),a.hasAttribute("data-name")&&(o=a.getAttribute("data-name")),a.hasAttribute("data-format")&&(r=a.getAttribute("data-format")),a.hasAttribute("data-default")&&(l=a.getAttribute("data-default")),""==l&&(l="current"),a.hasAttribute("data-action")&&(s=a.getAttribute("data-action")),a.hasAttribute("data-postid")&&(c=a.getAttribute("data-postid")),a.hasAttribute("data-selected")&&(u=a.getAttribute("data-selected")),a.hasAttribute("data-single")&&(h="yes"===a.getAttribute("data-single")),a.hasAttribute("min_nights")&&(d=a.getAttribute("min_nights")),a.hasAttribute("scroll_ele_id")&&(f=a.getAttribute("scroll_ele_id")),ReactDOM.render(React.createElement(p.default,{fname:o,format:r,value:l,action:s,postid:c,selected:u,show:n,max:i,single:h,min_nights:d,scroll_ele_id:f}),a)}}(),window.addEventListener("filterChanged",function(){i(),o(),r()},!0),window.addEventListener("roomModalOpened",function(e){var t=document.getElementById("cth-availability-room");if(null!=t){var a="1",n="12",i="date-picker",o="",r="",l="",s="",c="",u=!1,h=1,d="";t.hasAttribute("data-show")&&(a=t.getAttribute("data-show")),t.hasAttribute("data-max")&&(n=t.getAttribute("data-max")),t.hasAttribute("data-name")&&(i=t.getAttribute("data-name")),t.hasAttribute("data-format")&&(o=t.getAttribute("data-format")),t.hasAttribute("data-default")&&(r=t.getAttribute("data-default")),""==r&&(r="current"),t.hasAttribute("data-action")&&(l=t.getAttribute("data-action")),t.hasAttribute("data-postid")&&(s=t.getAttribute("data-postid")),t.hasAttribute("data-selected")&&(c=t.getAttribute("data-selected")),t.hasAttribute("data-single")&&(u="yes"===t.getAttribute("data-single")),t.hasAttribute("min_nights")&&(h=t.getAttribute("min_nights")),t.hasAttribute("scroll_ele_id")&&(d=t.getAttribute("scroll_ele_id")),ReactDOM.render(React.createElement(p.default,{fname:i,format:o,value:r,action:l,postid:s,selected:c,show:a,max:n,single:u,min_nights:h,scroll_ele_id:d}),t)}},!0)},{"./src/components/AvailabilityCalendar":3,"./src/components/DatePickerField":4,"./src/components/DateRangePicker":5,"./src/components/TimePickerField":6}],3:[function(e,t,a){"use strict";var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i="function"==typeof Symbol&&"symbol"===n(Symbol.iterator)?function(e){return void 0===e?"undefined":n(e)}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":void 0===e?"undefined":n(e)};Object.defineProperty(a,"__esModule",{value:!0});var s="function"==typeof Symbol&&"symbol"===i(Symbol.iterator)?function(e){return void 0===e?"undefined":i(e)}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":void 0===e?"undefined":i(e)},o=function(){function n(e,t){for(var a=0;a<t.length;a++){var n=t[a];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(e,t,a){return t&&n(e.prototype,t),a&&n(e,a),e}}();function d(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function f(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!==(void 0===t?"undefined":i(t))&&"function"!=typeof t?e:t}function r(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+(void 0===t?"undefined":i(t)));e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var l=function(e){function h(e){d(this,h);var t=f(this,(h.__proto__||Object.getPrototypeOf(h)).call(this,e)),a=t.props,n=a.fname,i=a.format,o=a.value,r=a.action,l=a.postid,s=a.selected,c=(a.show,a.max,a.single,a.min_nights),u=a.scroll_ele_id;return t.field={fieldName:n,format:i,value:o,action:r,postid:l,min_nights:c,select_event:s,scroll_ele_id:u},t}return r(h,React.Component),o(h,[{key:"render",value:function(){return React.createElement(c,{value:this.props.value,field:this.field,onChange:function(e){},options:{date_pick:!0,time_pick:!1,showing:this.props.show,max:this.props.max,single:this.props.single}})}}]),h}();a.default=l;var c=function(e){function l(e){d(this,l);var t=f(this,(l.__proto__||Object.getPrototypeOf(l)).call(this,e)),a=t.props,n=a.options,i=a.field,o={showing:1,max:12,date_pick:!0,time_pick:!0,single:!1};null!=n&&"object"===(void 0===n?"undefined":s(n))&&(o=Object.assign(o,n)),o.max=parseInt(o.max),o.showing=parseInt(o.showing),t.options=o,t.fieldName="",t.format="YYYY-MM-DD",null!=i&&(null!=i.fieldName&&(t.fieldName=i.fieldName),null!=i.format&&""!=i.format&&(t.format=i.format));var r={vals:[],available:{},current:0,check_available:!1,is_checking:!1};return t.state=r,t.toggleDate=t.toggleDate.bind(t),t.switchMonth=t.switchMonth.bind(t),t}
1return r(l,React.Component),o(l,[{key:"componentDidMount",value:function(){this.doAvailableCheck()}},{key:"doAvailableCheck",value:function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null,a=this,t=this.props.field;if(null!=t&&null!=t.action&&""!=t.action){a.setState({is_checking:!0});var n={action:t.action};null!=t.postid&&""!=t.postid&&(n.postid=t.postid),n.dates=this.getQueryDates(e),axios.post(_townhub_add_ons.url,Qs.stringify(n)).then(function(e){if(null!=e.data.debug&&e.data.debug&&console.log(e),e.data.success){var t={available:Object.assign({},a.state.available,e.data.available)};null!=e.data.check_available&&!0===e.data.check_available&&(t.check_available=!0),t.is_checking=!1,a.setState(t)}}).catch(function(e){console.log(e),a.setState({is_checking:!1})})}}},{key:"isValidDate",value:function(e){return e instanceof Date&&!isNaN(e)}},{key:"getDateSave",value:function(e){if(!1===this.isValidDate(e))return"";var t=e.getFullYear(),a=e.getMonth(),n=e.getDate(),i=this._getDateNum(n);return""+t+this._getMonthNum(a)+i}},{key:"getTimeSave",value:function(e){!1===this.isValidDate(e)&&(e=new Date);var t=e.getHours(),a=e.getMinutes(),n=e.getSeconds();return""+this._getDateNum(t)+this._getDateNum(a)+this._getDateNum(n)}},{key:"getTimeIso",value:function(e){if(!1===this.isValidDate(e))return"";var t=e.getHours(),a=e.getMinutes(),n=e.getSeconds();return this._getDateNum(t)+":"+this._getDateNum(a)+":"+this._getDateNum(n)}},{key:"getDateIso",value:function(e){!1===this.isValidDate(e)&&(e=new Date);var t=e.getFullYear(),a=e.getMonth(),n=e.getDate(),i=this._getDateNum(n);return t+"-"+this._getMonthNum(a)+"-"+i}},{key:"switchMonth",value:function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"next",t=this.options,a=t.max,n=t.showing,i=this.state.current;i=parseInt(i),"next"==e?i+n<=a&&(i+=n):0<=i-n&&(i-=n),this.setState({current:i}),this.doAvailableCheck(i)}},{key:"toggleDate",value:function(e){var t=1<arguments.length&&void 0!==arguments[1]&&arguments[1],a=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null,n=this.state.vals,i=this.state,o=i.check_available,r=i.available;if(Array.isArray(n))if(!0===this.options.single)n=[e],a.single_selected=!0;else if(2<=n.length)n=[e];else if(1==n.length)if(t)n=[e];else{var l=parseInt(n[0]);if(l<e){var s=!1;if(null!=o&&!0===o)for(var c=new Date(this._formatOutDate(l,!0)),u=c.getFullYear(),h=c.getMonth(),d=c.getDate();d<365;d++){var f=new Date(u,h,d),m=""+f.getFullYear()+this._getMonthNum(f.getMonth())+this._getDateNum(f.getDate());if(!this.getTimesCompared(m,e,"<"))break;if(null==r[m]){s=!0;break}}s?n=[e]:n.push(e)}else n=[e]}else n=[e];else n=[e];this.setState({vals:n});var p={vals:n,metas:a};if(this.dispatchEvent("selected",p),null!=this.props.field.scroll_ele_id&&""!=this.props.field.scroll_ele_id){var v=document.getElementById(this.props.field.scroll_ele_id);null!=v&&(2==n.length?this.scrollBkFormIntoView(v):this.options.single&&this.scrollBkFormIntoView(v))}}},{key:"dispatchEvent",value:function(e,t){var a=this.props.field;if(null!=a&&null!=a.select_event&&""!=a.select_event){var n=new CustomEvent(a.select_event+"_"+e,{detail:t});window.dispatchEvent(n)}}},{key:"getOffsetTop",value:function(e){var t=e.getBoundingClientRect(),a=document.body,n=document.documentElement,i=window.pageYOffset||n.scrollTop||a.scrollTop,o=n.clientTop||a.clientTop||0,r=t.top+i-o;return Math.round(r)}},{key:"scrollBkFormIntoView",value:function(e){var t=150;null!=document.getElementById("wpadminbar")&&(t=182),window.scroll({top:this.getOffsetTop(e)-t,behavior:"smooth"})}},{key:"getTimesCompared",value:function(e,t){var a=2<arguments.length&&void 0!==arguments[2]?arguments[2]:">",n=new Date(this._formatOutDate(e,!0)),i=new Date(this._formatOutDate(t,!0));switch(a){case">":return n.getTime()>i.getTime();case">=":return n.getTime()>=i.getTime();case"=":return n.getTime()==i.getTime();case"<":return n.getTime()<i.getTime();case"<=":return n.getTime()<=i.getTime()}}},{key:"_getNightsDiff",value:function(e,t){var a=2<arguments.length&&void 0!==arguments[2]&&arguments[2],n=0,i=new Date(this._formatOutDate(e,!0)),o=new Date(this._formatOutDate(t,!0));return n=Math.floor((i-o)/864e5),1==a&&++n,n}},{key:"getReturnValue",value:function(e,t){var a="";return this.options.time_pick&&null!=t&&(a=" "+t),this.options.date_pick&&null!=e&&(a=this._formatOutDate(e)+a),a.trim()}},{key:"_fieldClass",value:function(){return"available-calendar"}},{key:"_getMonthDatas",value:function(e){var t=this.state,a=t.check_available,n=t.available,i=t.vals;!1===this.isValidDate(e)&&(e=new Date);var o=new Date,r=e.getFullYear(),l=e.getMonth(),s=this._getMonthNum(l),c=new Date(r,l,1),u=new Date(r,l+1,0),h=c.getDay(),d=u.getDate();o=new Date(o.getFullYear(),o.getMonth(),o.getDate());var f=[],m={iso_date:"2018-12-16",date:0,status:"prev",time:"",selected:!1,metas:{},first:!1,last:!1,inside:!1};
1if(null!=_townhub_add_ons.week_starts_monday&&"yes"==_townhub_add_ons.week_starts_monday)if(0===h)f.push(m),f.push(m),f.push(m),f.push(m),f.push(m),f.push(m);else for(var p=1;p<h;p++)f.push(m);else if(0!==h)for(var v=0;v<h;v++)f.push(m);for(var g=1;g<=d;g++){var y=new Date(r,l,g),b=this._getDateNum(g),_=""+r+s+b,k=r+"-"+s+"-"+b,w=!1,D=!1,E=!1,R=!1;2==i.length?(_==i[0]&&(D=w=!0),_==i[1]&&(E=w=!0),i[0]<_&&_<i[1]&&(R=!0)):1==i.length&&_==i[0]&&(D=w=!0);var N={iso_date:k,date:g,status:y<o?"past":"available",time:_,selected:w,metas:{},first:D,last:E,inside:R};if(null!=a&&!0===a&&(null!=n[_]?N.metas=n[_]:"past"!=N.status&&(N.status="unavailable")),!1===this.options.single&&1===i.length&&null!=this.props.field.min_nights&&"available"==N.status){var S=parseInt(i[0]),C=parseInt(_),O=parseInt(this.props.field.min_nights);isNaN(S)||isNaN(C)||isNaN(O)||S<C&&this._getNightsDiff(C,S)<O&&(N.status="unavailable")}f.push(N)}return f}},{key:"_getMonthNum",value:function(e){return(e=parseInt(e)+1)<10?"0"+e:e}},{key:"_getDateNum",value:function(e){return e<10?"0"+e:e}},{key:"_renderDays",value:function(){var a=[];return _townhub_add_ons.i18n.days.forEach(function(e,t){return a.push(React.createElement(u,{key:t,day:e}))}),React.createElement("div",{className:"cal-days"},a)}},{key:"_getMonthString",value:function(e){null!=e&&"function"==typeof e.getMonth||(e=new Date);var t=e.getFullYear(),a=e.getMonth();return _townhub_add_ons.i18n.months[a].replace("{YEAR}",t)}},{key:"_formatOutDate",value:function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"20181216",t=1<arguments.length&&void 0!==arguments[1]&&arguments[1],a="",n="",i="";return null!=(e=String(e))&&8==e.length?(a=e.substr(0,4),n=e.substr(4,2),i=e.substr(6,2),1==t?a+"-"+n+"-"+i:this.format.replace("YYYY",a).replace("MM",n).replace("DD",i)):""}},{key:"getQueryDates",value:function(e){var t=this.options.showing,a=this.state.current;null!=e&&(a=e);for(var n=[],i=0;i<t;i++)for(var o=new Date,r=o.getFullYear(),l=o.getMonth(),s=new Date(r,l+a+i+1,0).getDate(),c=1;c<=s;c++){var u=new Date(r,l+a+i,c),h=u.getFullYear(),d=u.getMonth(),f=this._getMonthNum(d),m=this._getDateNum(c);n.push(""+h+f+m)}return n}},{key:"_renderPickers",value:function(){for(var l=this,e=this.options,t=e.showing,a=e.max,s=this.state.current,c=[],n=function(e){var t=new Date,a=t.getFullYear(),n=t.getMonth(),i=new Date(a,n+s+e,1),o=l._getMonthDatas(i),r=[];o.forEach(function(e,t){return r.push(React.createElement(m,{key:t,date:e,toggleDate:l.toggleDate,single:l.options.single}))}),o.length,c.push(React.createElement("div",{key:e,className:"cal-month cal-month-"+o.length+"-days"},React.createElement("div",{className:"cal-month-header"},React.createElement("div",{className:"cal-month-string"},l._getMonthString(i))),React.createElement("div",{className:"cal-dates-wrap"},l._renderDays(),React.createElement("div",{className:"cal-dates"},r))))},i=0;i<t;i++)n(i);var o="cal-month-nav month-next",r="cal-month-nav month-prev";s<=0&&(r+=" month-disabled"),a<=s&&(o+=" month-disabled");var u=React.createElement("article",{className:"cal-months-header"},React.createElement("div",{className:r,onClick:function(e){return l.switchMonth("prev")}},React.createElement("span",null)),React.createElement("div",{className:o,onClick:function(e){return l.switchMonth("next")}},React.createElement("span",null))),h="cal-months-wrap months-"+this.options.showing;return React.createElement("div",{className:"available-cal-months"},!0===this.state.is_checking&&React.createElement("div",{className:"loading-indicator calendar-check-loading"},React.createElement("span",null),React.createElement("span",null),React.createElement("span",null)),React.createElement("div",{className:h},React.createElement("div",{className:"cal-months-inner"},u,c)))}},{key:"render",value:function(){return React.createElement("div",{className:this._fieldClass()},this._renderPickers())}}]),l}(),m=function(e){function a(e){d(this,a);var t=f(this,(a.__proto__||Object.getPrototypeOf(a)).call(this,e));return t.onToggle=t.onToggle.bind(t),t}return r(a,React.Component),o(a,[{key:"onToggle",value:function(e){var t=this.props.date,a=t.time,n=t.status,i=t.selected,o=t.metas;"available"===n&&this.props.toggleDate(a,i,o)}},{key:"render",value:function(){var e=this.props.date,t=e.status,a=e.date,n=e.selected,i=e.metas,o=e.first,r=e.last,l=e.inside,s="cal-date";return s+="prev"===t?" cal-date-diff":"past"===t?" cal-date-past":"unavailable"===t?" cal-date-unavailable":" cal-date-available",n&&(s+=" cal-date-checked"),o&&(s+=" cal-date-cfirst",null!=this.props.single&&!0===this.props.single&&(s+=" cal-date-single")),r&&(s+=" cal-date-clast"),l&&(s+=" cal-date-inside"),React.createElement("div",{className:s,onClick:this.onToggle},("available"==t||"unavailable"==t||"past"==t)&&React.createElement("span",null,a),"prev"!=t&&"past"!=t&&null!=i&&null!=i.avaiHtml&&""!=i.avaiHtml&&React.createElement("div",{className:"available-cal-metas",dangerouslySetInnerHTML:{__html:i.avaiHtml}}))}}]),a}(),u=function(e){function t(){return d(this,t),f(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return r(t,React.Component),o(t,[{key:"render",value:function(){var e=this.props.day;return React.createElement("div",{className:"cal-day"},e)}}]),t}()},{}],4:[function(e,t,a){"use strict";var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},d="function"==typeof Symbol&&"symbol"===n(Symbol.iterator)?function(e){return void 0===e?"undefined":n(e)}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":void 0===e?"undefined":n(e)};Object.defineProperty(a,"__esModule",{value:!0});var i,o=function(){function n(e,t){for(var a=0;a<t.length;a++){var n=t[a];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(e,t,a){return t&&n(e.prototype,t),a&&n(e,a),e}}(),r=e("./inners/DatePicker"),l=(i=r)&&i.__esModule?i:{default:i};var s=function(e){function h(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,h);var t=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!==(void 0===t?"undefined":d(t))&&"function"!=typeof t?e:t}(this,(h.__proto__||Object.getPrototypeOf(h)).call(this,e)),a=t.props,n=a.fname,i=a.format,o=a.value,r=a.action,l=a.postid,s=a.selected,c=a.placeholder,u=a.required;return t.field={fieldName:n,format:i,value:o,action:r,postid:l,select_event:s,placeholder:c,required:u},t.onPickerChanged=t.onPickerChanged.bind(t),t}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+(void 0===t?"undefined":d(t)));e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(h,React.Component),o(h,[{key:"onPickerChanged",value:function(e){this.props.onChange(e)}},{key:"render",value:function(){return React.createElement(l.default,{value:this.props.value,field:this.field,onChange:this.onPickerChanged,options:{date_pick:!0,time_pick:!1}})}}]),h}();a.default=s},{"./inners/DatePicker":7}],5:[function(e,t,a){"use strict";var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},l="function"==typeof Symbol&&"symbol"===n(Symbol.iterator)?function(e){return void 0===e?"undefined":n(e)}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":void 0===e?"undefined":n(e)};Object.defineProperty(a,"__esModule",{value:!0});var i,o=function(){function n(e,t){for(var a=0;a<t.length;a++){var n=t[a];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(e,t,a){return t&&n(e.prototype,t),a&&n(e,a),e}}(),r=e("../../bookingsrc/components/CheckInOut"),s=(i=r)&&i.__esModule?i:{default:i};var c=function(e){function r(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,r);var t=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!==(void 0===t?"undefined":l(t))&&"function"!=typeof t?e:t}(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e)),a=t.props.value,
1n={checkin:"",checkout:""},i=null!=e.mnights?e.mnights:1;if(null!=a&&"string"==typeof a){var o=a.split(";");2==o.length?(n.checkin=t.formatDate(o[0],null),n.checkout=t.formatDate(o[1],null)):"current"==a&&(n.checkin=t.formatDate(null,null),n.checkout=t.formatDate(null,i))}return t.min_nights=i,t.state=n,t.getCheckInOut=t.getCheckInOut.bind(t),t.handleAvaiCalEvent=t.handleAvaiCalEvent.bind(t),t}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+(void 0===t?"undefined":l(t)));e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(r,React.Component),o(r,[{key:"componentDidMount",value:function(){window.addEventListener("availability_dates_selected",this.handleAvaiCalEvent,!0)}},{key:"componentWillUnmount",value:function(){window.removeEventListener("availability_dates_selected",this.handleAvaiCalEvent,!0)}},{key:"dispatchEvent",value:function(e,t){var a=this.props.selected;if(null!=a&&""!=a){var n=new CustomEvent(a+"_"+e,{detail:t});window.dispatchEvent(n)}}},{key:"handleAvaiCalEvent",value:function(e){if(null!=e.detail){var t=e.detail,a=t.vals;t.metas;if(null!=a&&Array.isArray(a)&&2==a.length){var n={checkin:this._formatOutDate(a[0]),checkout:this._formatOutDate(a[1])};this.setState(n),n.nights=this._getDatesDiff([n.checkin,n.checkout]),n.days=n.nights+1,this.dispatchEvent("selected",n)}}}},{key:"_formatOutDate",value:function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"20181216";return null!=e&&8==e.length?e.substr(0,4)+"-"+e.substr(4,2)+"-"+e.substr(6,2):""}},{key:"getCheckInOut",value:function(e){if(Array.isArray(e))if(2==e.length){var t={checkin:e[0],checkout:e[1]};this.setState(t),t.nights=this._getDatesDiff([t.checkin,t.checkout]),t.days=t.nights+1,this.dispatchEvent("selected",t)}else 1==e.length&&this.setState({checkin:e[0],checkout:""})}},{key:"isValidDate",value:function(e){return e instanceof Date&&!isNaN(e)}},{key:"_getDatesDiff",value:function(e){var t=1<arguments.length&&void 0!==arguments[1]&&arguments[1],a=0;if(2==e.length){var n=new Date(e[0]),i=new Date(e[1]);if(!1===this.isValidDate(n)||!1===this.isValidDate(i))return 0;a=Math.floor((i-n)/864e5),1==t&&++a}return a}},{key:"formatDate",value:function(e,t){var a=2<arguments.length&&void 0!==arguments[2]?arguments[2]:"YYYY-MM-DD";(0==(e=null==e||""==e?new Date:new Date(e))instanceof Date||isNaN(e))&&(e=new Date);var n=e.getDate();null==t||isNaN(parseInt(t))||(n+=parseInt(t),e.setDate(n),n=e.getDate());var i=e.getFullYear(),o=e.getMonth(),r=this._getMonthNum(o),l=this._getDateNum(n);return""!=a?a.replace(/YYYY/g,i).replace(/MM/g,r).replace(/DD/g,l):e.toString()}},{key:"_getMonthNum",value:function(e){return(e=parseInt(e)+1)<10?"0"+e:e}},{key:"_getDateNum",value:function(e){return e<10?"0"+e:e}},{key:"render",value:function(){return React.createElement("div",{className:"cal-item"},React.createElement(s.default,{fieldValue:[this.state.checkin,this.state.checkout],field:{label:this.props.label,icon:this.props.icon,format:this.props.format,action:this.props.action,postid:this.props.postid,max:null!=this.props.max?this.props.max:12},getCheckInOut:this.getCheckInOut,min_nights:this.min_nights}),React.createElement("input",{type:"hidden",name:this.props.fname,value:this.state.checkin,readOnly:!0}),React.createElement("input",{type:"hidden",name:this.props.fname2,value:this.state.checkout,readOnly:!0}))}}]),r}();a.default=c},{"../../bookingsrc/components/CheckInOut":1}],6:[function(e,t,a){"use strict";var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},l="function"==typeof Symbol&&"symbol"===n(Symbol.iterator)?function(e){return void 0===e?"undefined":n(e)}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":void 0===e?"undefined":n(e)};Object.defineProperty(a,"__esModule",{value:!0});var i,o=function(){function n(e,t){for(var a=0;a<t.length;a++){var n=t[a];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(e,t,a){return t&&n(e.prototype,t),a&&n(e,a),e}}(),r=e("./inners/TimePicker"),s=(i=r)&&i.__esModule?i:{default:i};var c=function(e){function r(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,r);var t=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!==(void 0===t?"undefined":l(t))&&"function"!=typeof t?e:t}(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e)),a=t.props,n=a.fname,i=a.format,o=a.icon;return t.field={fName:n,format:i,place:"",icon:o},t.getTimeValue=t.getTimeValue.bind(t),t}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+(void 0===t?"undefined":l(t)));e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(r,React.Component),o(r,[{key:"getTimeValue",value:function(e){}},{key:"render",value:function(){return React.createElement(s.default,{value:this.props.value,field:this.field,getTime:this.getTimeValue})}}]),r}();a.default=c},{"./inners/TimePicker":8}],7:[function(e,t,a){"use strict";var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i="function"==typeof Symbol&&"symbol"===n(Symbol.iterator)?function(e){return void 0===e?"undefined":n(e)}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":void 0===e?"undefined":n(e)};Object.defineProperty(a,"__esModule",{value:!0});var s="function"==typeof Symbol&&"symbol"===i(Symbol.iterator)?function(e){return void 0===e?"undefined":i(e)}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":void 0===e?"undefined":i(e)},o=function(){function n(e,t){for(var a=0;a<t.length;a++){var n=t[a];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(e,t,a){return t&&n(e.prototype,t),a&&n(e,a),e}}();function c(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!==(void 0===t?"undefined":i(t))&&"function"!=typeof t?e:t}function r(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+(void 0===t?"undefined":i(t)));e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var l=function(e){function l(e){c(this,l);var t=u(this,(l.__proto__||Object.getPrototypeOf(l)).call(this,e)),a=t.props,n=a.options,i=a.field,o={showing:1,max:12,date_pick:!0,time_pick:!0};null!=n&&"object"===(void 0===n?"undefined":s(n))&&(o=Object.assign(o,n)),t.options=o,t.fieldName="",t.format="YYYY-MM-DD",null!=i&&(null!=i.fieldName&&(t.fieldName=i.fieldName),null!=i.format&&""!=i.format&&(t.format=i.format));var r=t.parseFieldValue(t.props.value);return r.current=0,r.show_selector=!1,r.check_available=!1,r.is_checking=!1,t.state=r,t.wrapperRef=null,t.toggleDate=t.toggleDate.bind(t),t.switchMonth=t.switchMonth.bind(t),t.onFocusInput
1=t.onFocusInput.bind(t),t.handleClickOutside=t.handleClickOutside.bind(t),t.handleAvaiCalEvent=t.handleAvaiCalEvent.bind(t),t.onClickCancel=t.onClickCancel.bind(t),t.selectTime=t.selectTime.bind(t),t}return r(l,React.Component),o(l,[{key:"doAvailableCheck",value:function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null,a=this,t=this.props.field;if(null!=t&&null!=t.action&&""!=t.action){a.setState({is_checking:!0});var n={action:t.action};null!=t.postid&&""!=t.postid&&(n.postid=t.postid),n.dates=this.getQueryDates(e),axios.post(_townhub_add_ons.url,Qs.stringify(n)).then(function(e){if(null!=e.data.debug&&e.data.debug&&console.log(e),e.data.success){var t={available:e.data.available};null!=e.data.check_available&&!0===e.data.check_available&&(t.check_available=!0),t.is_checking=!1,a.setState(t)}}).catch(function(e){console.log(e),a.setState({is_checking:!1})})}}},{key:"componentDidMount",value:function(){document.addEventListener("mousedown",this.handleClickOutside,!0),window.addEventListener("availability_dates_selected",this.handleAvaiCalEvent,!0)}},{key:"componentWillUnmount",value:function(){document.removeEventListener("mousedown",this.handleClickOutside,!0),window.removeEventListener("availability_dates_selected",this.handleAvaiCalEvent,!0)}},{key:"handleAvaiCalEvent",value:function(e){if(null!=e.detail){var t=e.detail,a=t.vals,n=t.metas;if(null!=a&&Array.isArray(a)&&a.length){this.setState({date:a[0]});var i=Object.assign({},n,{tvals:a});this.dispatchEvent("selected",i)}}}},{key:"handleClickOutside",value:function(e){1==this.state.show_selector&&this.wrapperRef&&0==this.wrapperRef.contains(e.target)&&this.setState({show_selector:!1})}},{key:"UNSAFE_componentWillReceiveProps",value:function(e){var t=this.parseFieldValue(e.value);this.setState(t)}},{key:"parseFieldValue",value:function(e){var t=!1;if(""!=e)if("current"==e)t=new Date;else{if("hide"==e)return{date:"",time:""};t=new Date(e)}var a={};return this.options.date_pick?a.date=this.getDateSave(t):a.date="",this.options.time_pick?this.isValidDate(t)?a.time=this.getTimeIso(t):a.time=e:a.time="",a}},{key:"isValidDate",value:function(e){return e instanceof Date&&!isNaN(e)}},{key:"getDateSave",value:function(e){if(!1===this.isValidDate(e))return"";var t=e.getFullYear(),a=e.getMonth(),n=e.getDate(),i=this._getDateNum(n);return""+t+this._getMonthNum(a)+i}},{key:"getTimeSave",value:function(e){!1===this.isValidDate(e)&&(e=new Date);var t=e.getHours(),a=e.getMinutes(),n=e.getSeconds();return""+this._getDateNum(t)+this._getDateNum(a)+this._getDateNum(n)}},{key:"getTimeIso",value:function(e){if(!1===this.isValidDate(e))return"";var t=e.getHours(),a=e.getMinutes(),n=e.getSeconds();return this._getDateNum(t)+":"+this._getDateNum(a)+":"+this._getDateNum(n)}},{key:"getDateIso",value:function(e){!1===this.isValidDate(e)&&(e=new Date);var t=e.getFullYear(),a=e.getMonth(),n=e.getDate(),i=this._getDateNum(n);return t+"-"+this._getMonthNum(a)+"-"+i}},{key:"onFocusInput",value:function(e){this.setState({show_selector:!0}),this.doAvailableCheck()}},{key:"onClickCancel",value:function(){this.setState({date:"",time:"",show_selector:!1}),this.props.onChange(this.getReturnValue("",""))}},{key:"switchMonth",value:function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"next",t=this.options.max,a=this.state.current;"next"==e?a<t&&++a:0<a&&--a,this.setState({current:a}),this.doAvailableCheck(a)}},{key:"toggleDate",value:function(e){1<arguments.length&&void 0!==arguments[1]&&arguments[1];var t=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null,a={date:e};(!1===this.options.time_pick||this.options.time_pick&&""!=this.state.time)&&(a.show_selector=!1),this.setState(a);var n=Object.assign({},t,{tvals:[e]});this.dispatchEvent("selected",n),this.props.onChange(this.getReturnValue(e,this.state.time))}},{key:"dispatchEvent",value:function(e,t){var a=this.props.field;if(null!=a&&null!=a.select_event&&""!=a.select_event){var n=new CustomEvent(a.select_event+"_"+e,{detail:t});window.dispatchEvent(n)}}},{key:"getReturnValue",value:function(e,t){var a=!(2<arguments.length&&void 0!==arguments[2])||arguments[2],n="";return this.options.time_pick&&null!=t&&(n=" "+t),this.options.date_pick&&null!=e&&(n=this._formatOutDate(e,a)+n),n.trim()}},{key:"_fieldClass",value:function(){var e=this.state,t=e.date,a=e.time,n="date-time-picker-field";1==e.show_selector&&(n+=" show-selector");var i="";return this.options.time_pick&&(i=" "+a),this.options.date_pick&&(i=this._formatOutDate(t)+i),""==(i=i.trim())&&(n+=" has-empty-val"),n}},{key:"_getMonthDatas",value:function(e){var t=this.state,a=t.check_available,n=t.available;!1===this.isValidDate(e)&&(e=new Date);var i=new Date,o=e.getFullYear(),r=e.getMonth(),l=this._getMonthNum(r),s=new Date(o,r,1),c=new Date(o,r+1,0),u=s.getDay(),h=c.getDate();i=new Date(i.getFullYear(),i.getMonth(),i.getDate());var d=[],f={iso_date:"2018-12-16",date:0,status:"prev",time:"",selected:!1,metas:{}};
1if(null!=_townhub_add_ons.week_starts_monday&&"yes"==_townhub_add_ons.week_starts_monday)if(0===u)d.push(f),d.push(f),d.push(f),d.push(f),d.push(f),d.push(f);else for(var m=1;m<u;m++)d.push(f);else if(0!==u)for(var p=0;p<u;p++)d.push(f);for(var v=1;v<=h;v++){var g=new Date(o,r,v),y=this._getDateNum(v),b=""+o+l+y,_=o+"-"+l+"-"+y,k=!1;b==this.state.date&&(k=!0);var w={iso_date:_,date:v,status:g<i?"past":"available",time:b,selected:k,metas:{}};null!=a&&!0===a&&(null!=n[b]?w.metas=n[b]:"past"!=w.status&&(w.status="unavailable")),d.push(w)}return d}},{key:"_getMonthNum",value:function(e){return(e=parseInt(e)+1)<10?"0"+e:e}},{key:"_getDateNum",value:function(e){return e<10?"0"+e:e}},{key:"_renderDays",value:function(){var a=[];return _townhub_add_ons.i18n.days.forEach(function(e,t){return a.push(React.createElement(h,{key:t,day:e}))}),React.createElement("div",{className:"cal-days"},a)}},{key:"_getMonthString",value:function(e){null!=e&&"function"==typeof e.getMonth||(e=new Date);var t=e.getFullYear(),a=e.getMonth();return _townhub_add_ons.i18n.months[a].replace("{YEAR}",t)}},{key:"_formatOutDate",value:function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"20181216",t=1<arguments.length&&void 0!==arguments[1]&&arguments[1],a="",n="",i="";return null!=e&&8==e.length?(a=e.substr(0,4),n=e.substr(4,2),i=e.substr(6,2),1==t?a+"-"+n+"-"+i:this.format.replace("YYYY",a).replace("MM",n).replace("DD",i)):""}},{key:"_renderInputValue",value:function(){var e=0<arguments.length&&void 0!==arguments[0]&&arguments[0],t=this.state,a=t.date,n=t.time,i="";return this.options.time_pick&&(i=" "+n),this.options.date_pick&&(i=this._formatOutDate(a,e)+i),i.trim()}},{key:"_renderLabelValue",value:function(){var e=0<arguments.length&&void 0!==arguments[0]&&arguments[0],t=this.state,a=t.date,n=t.time,i="";return this.options.time_pick&&(i=" "+n),this.options.date_pick&&(i=this._formatOutDate(a,e)+i),i=i.trim()}},{key:"_getDatesDiff",value:function(){var e=0<arguments.length&&void 0!==arguments[0]&&arguments[0],t=this.state.vals,a=0;if(2==t.length){var n=new Date(this._formatOutDate(t[0])),i=new Date(this._formatOutDate(t[1]));a=Math.floor((i-n)/864e5),1==e&&++a}return a}},{key:"_renderMonthFooter",value:function(){return React.createElement("div",{className:"cal-months-footer"},React.createElement("button",{className:"btn-cal-cancel",type:"button",onClick:this.onClickCancel},_townhub_add_ons.i18n.cancel))}},{key:"selectTime",value:function(e,t){var a={time:e};(!1===this.options.date_pick||this.options.date_pick&&""!=this.state.date)&&(a.show_selector=!1),this.setState(a),this.props.onChange(this.getReturnValue(this.state.date,e))}},{key:"_renderTimePicker",value:function(){var n=this,i=[];return this.getTimeArray().forEach(function(t,e){var a="time-picker-item cal-time";n.state.time==t&&(a+=" cal-time-selected"),i.push(React.createElement("span",{key:e,className:a,onClick:function(e){return n.selectTime(t,e)}},t))}),React.createElement("div",{className:"time-picker-inner"},i)}},{key:"getTimeArray",value:function(){var e=[],t=void 0,a=void 0;for(t=0;t<24;t++)for(a=0;a<4;a++)e.push((t<10?"0"+t:t)+":"+(0===a?"00":15*a)+":00");return e.push("24:00:00"),e}},{key:"getQueryDates",value:function(e){var t=this.options.showing,a=this.state.current;null!=e&&(a=e);for(var n=[],i=0;i<t;i++)for(var o=new Date,r=o.getFullYear(),l=o.getMonth(),s=new Date(r,l+a+i+1,0).getDate(),c=1;c<=s;c++){var u=new Date(r,l+a+i,c),h=u.getFullYear(),d=u.getMonth(),f=this._getMonthNum(d),m=this._getDateNum(c);n.push(""+h+f+m)}return n}},{key:"_renderPickers",value:function(){for(var l=this,e=this.options,t=e.showing,a=e.max,s=this.state.current,c=[],u=30,n=function(e){var t=new Date,a=t.getFullYear(),n=t.getMonth(),i=new Date(a,n+s+e,1),o=l._getMonthDatas(i),r=[];o.forEach(function(e,t){return r.push(React.createElement(f,{key:t,date:e,toggleDate:l.toggleDate}))}),u=o.length,c.push(React.createElement("div",{key:e,className:"cal-month cal-month-"+o.length+"-days"},React.createElement("div",{className:"cal-month-header"},React.createElement("div",{className:"cal-month-string"},l._getMonthString(i))),React.createElement("div",{className:"cal-dates-wrap"},l._renderDays(),React.createElement("div",{className:"cal-dates"},r))))},i=0;i<t;i++)n(i);var o="cal-month-nav month-next",r="cal-month-nav month-prev";s<=0&&(r+=" month-disabled"),a<=s&&(o+=" month-disabled");var h=React.createElement("article",{className:"cal-months-header"},React.createElement("div",{className:r,onClick:function(e){return l.switchMonth("prev")}},React.createElement("span",null)),React.createElement("div",{className:o,onClick:function(e){return l.switchMonth("next")}},React.createElement("span",null))),d="cal-months-wrap months-"+this.options.showing+" date-pick-"+this.options.date_pick+" time-pick-"+this.options.time_pick+" month-"+u+"-days";return 35<u&&(d+=" month-days-long"),React.createElement("div",{className:"date-time-picker-wrapper date-time-picker checkinout-field"},React.createElement("div",{className:"date-time-picker-inner"},!0===this.state.is_checking&&React.createElement("div",{className:"loading-indicator calendar-check-loading"},React.createElement("span",null),React.createElement("span",null),React.createElement("span",null)),React.createElement("div",{className:d},this.options.date_pick&&React.createElement("div",{className:"date-picker-wrap"},h,c),this.options.time_pick&&React.createElement("div",{className:"time-picker-wrap"},this._renderTimePicker()),this._renderMonthFooter())))}},{key:"render",value:function(){var t=this,e="",a=!1;return null!=this.props.field&&(null!=this.props.field.placeholder&&(e=this.props.field.placeholder),null!=this.props.field.required&&(a=this.props.field.required)),React.createElement("div",{className:this._fieldClass(),ref:function(e){return t.wrapperRef=e}},React.createElement("input",{name:this.fieldName,type:"text",className:"cth-input hid-input",value:this._renderInputValue(!0),onChange:function(e){console.log(e.target.value)},onFocus:this.onFocusInput,placeholder:e,required:a}),React.createElement("label",{onClick:this.onFocusInput,className:"cth-dpick-label-val"},this._renderLabelValue(),React.createElement("span",{className:"cth-cleardate",onClick:this.onClickCancel},React.createElement("i",{className:"fal fa-times"}))),!0===this.state.show_selector&&this._renderPickers())}}]),l}();a.default=l;var f=function(e){function a(e){c(this,a);var t=u(this,(a.__proto__||Object.getPrototypeOf(a)).call(this,e));return t.onToggle=t.onToggle.bind(t),t}return r(a,React.Component),o(a,[{key:"onToggle",value:function(e){var t=this.props.date,a=t.time,n=t.status,i=t.selected,o=t.metas;"available"!==n&&"past"!==n||this.props.toggleDate(a,i,o)}},{key:"render",value:function(){var e=this.props.date,t=e.status,a=e.date,n=e.selected,i=e.metas,o="cal-date";return o+="prev"===t?" cal-date-diff":"past"===t?" cal-date-past":"unavailable"===t?" cal-date-unavailable":" cal-date-available",n&&(o+=" cal-date-checked"),React.createElement("div",{className:o,onClick:this.onToggle},("available"==t||"unavailable"==t||"past"==t)&&React.createElement("span",null,a),null!=i&&null!=i.html&&""!=i.html&&React.createElement("div",{className:"available-date-metas tooltip-metas",dangerouslySetInnerHTML:{__html:i.html}}))}}]),a}(),h=function(e){function t(){return c(this,t),u(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return r(t,React.Component),o(t,[{key:"render",value:function(){var e=this.props.day;return React.createElement("div",{className:"cal-day"},e)}}]),t}()},{}],8:[function(e,t,a){"use strict";var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},s="function"==typeof Symbol&&"symbol"===n(Symbol.iterator)?function(e){return void 0===e?"undefined":n(e)}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":void 0===e?"undefined":n(e)};Object.defineProperty(a,"__esModule",{value:!0});var c="function"==typeof Symbol&&"symbol"===s(Symbol.iterator)?function(e){return void 0===e?"undefined":s(e)}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":void 0===e?"undefined":s(e)},i=function(){function n(e,t){for(var a=0;a<t.length;a++){var n=t[a];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(e,t,a){return t&&n(e.prototype,t),a&&n(e,a),e}}();var o=function(e){function l(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,l);var t=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!==(void 0===t?"undefined":s(t))&&"function"!=typeof t?e:t}(this,(l.__proto__||Object.getPrototypeOf(l)).call(this,e)),a=t.props,n=a.options,i=a.field,o={h24:!1};null!=n&&"object"===(void 0===n?"undefined":c(n))&&(o=Object.assign(o,n)),t.options=o,t.fName="",t.format="H:i:s",null!=i&&(null!=i.fName&&(t.fName=i.fName),null!=i.format&&""!=i.format&&(t.format=i.format));var r=t.parseFieldValue(t.props.value);
1return r.show_selector=!1,t.state=r,t.wrapperRef=null,t.onChange=t.onChange.bind(t),t.onClickQtt=t.onClickQtt.bind(t),t.onFocusInput=t.onFocusInput.bind(t),t.handleClickOutside=t.handleClickOutside.bind(t),t.onClearTime=t.onClearTime.bind(t),t}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+(void 0===t?"undefined":s(t)));e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(l,React.Component),i(l,[{key:"componentDidMount",value:function(){document.addEventListener("mousedown",this.handleClickOutside,!0)}},{key:"componentWillUnmount",value:function(){document.removeEventListener("mousedown",this.handleClickOutside,!0)}},{key:"handleClickOutside",value:function(e){1==this.state.show_selector&&this.wrapperRef&&0==this.wrapperRef.contains(e.target)&&this.setState({show_selector:!1})}},{key:"onFocusInput",value:function(e){this.setState({show_selector:!0})}},{key:"getRealInt",value:function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0,a=parseInt(e);return isNaN(a)?t:a}},{key:"parseFieldValue",value:function(e){var t={hour:"",minute:"",second:"",apm:"AM"};if(""===(e=(""+e).trim()))return t;e=e.toLowerCase();var a=this.getRealInt(e.substr(0,2)),n=this.getRealInt(e.substr(3,2));return-1!==e.indexOf("pm")?t.apm="PM":-1!==e.indexOf("am")&&(t.apm="AM"),t.hour=a,t.minute=n,t}},{key:"getReturn",value:function(e){null==e&&(e=this.state);var t=e,a=t.hour,n=t.minute,i=t.second,o=t.apm;return""===a&&""===n&&""===i?"":this.format.replace("g",a).replace("G",this.get24Hour(a,o)).replace("h",this.zeroLeading(a)).replace("H",this.get24Hour(a,o,!0)).replace("i",this.zeroLeading(n)).replace("s",this.zeroLeading(i)).replace("a",o.toLowerCase()).replace("A",o)}},{key:"get24Hour",value:function(e,t){var a=2<arguments.length&&void 0!==arguments[2]&&arguments[2];return e=this.getRealInt(e),"PM"===t&&e<12&&(e+=12),a&&e<10&&(e="0"+e),e}},{key:"zeroLeading",value:function(e){return(e=this.getRealInt(e))<10?"0"+e:e}},{key:"onChange",value:function(e,t){var a=this.state;"apm"===t?a.apm="AM"===e?"PM":"AM":(a[t]=this.getRealInt(e.target.value),""===a.hour&&(a.hour=0),""===a.minute&&(a.minute=0),""===a.second&&(a.second=0)),this.setState(a),this.props.getTime(this.getReturn(a))}},{key:"onClearTime",value:function(){this.setState({hour:"",minute:"",second:""}),this.props.getTime("")}},{key:"onClickQtt",value:function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"up",t=arguments[1],a=2<arguments.length&&void 0!==arguments[2]?arguments[2]:0,n=(3<arguments.length&&void 0!==arguments[3]&&arguments[3],this.state),i=n[t];if("down"==e&&a<i?--i:"up"==e&&++i,"minute"===t){var o=this.getRealInt(n.hour);59<i&&(i=0,o<12?n.hour=n.hour+1:(n.hour=0,"AM"===n.apm?n.apm="PM":n.apm="AM"))}if("hour"===t){var r=this.getRealInt(n.minute);(12<i&&0==r||11<i&&0<r)&&(i=0,"AM"===n.apm?n.apm="PM":n.apm="AM")}n[t]=i,""===n.hour&&(n.hour=0),""===n.minute&&(n.minute=0),""===n.second&&(n.second=0),this.setState(n),this.props.getTime(this.getReturn(n))}},{key:"_renderPickers",value:function(){var t=this;return React.createElement("div",{className:"cth-tpick-inner"},React.createElement("div",{className:"cth-tpick-item qtt-item fl-wrap"},React.createElement("div",{className:"qtt-input"},React.createElement("input",{type:"number",min:"0",max:"12",pattern:"\\d*",step:"1",value:this.state.hour,onChange:function(e){return t.onChange(e,"hour")}}),React.createElement("div",{className:"qtt-nav"},React.createElement("div",{className:"qtt-btn qtt-up",onClick:function(e){return t.onClickQtt("up","hour",0,12)}},"+"),React.createElement("div",{className:"qtt-btn qtt-down",onClick:function(e){return t.onClickQtt("down","hour",0,12)}},"-")))),React.createElement("div",{className:"cth-tpick-item qtt-item fl-wrap"},React.createElement("div",{className:"qtt-input"},React.createElement("input",{type:"number",min:"0",max:"59",pattern:"\\d*",step:"1",value:this.state.minute,onChange:function(e){return t.onChange(e,"minute")}}),React.createElement("div",{className:"qtt-nav"},React.createElement("div",{className:"qtt-btn qtt-up",onClick:function(e){return t.onClickQtt("up","minute",0,59)}},"+"),React.createElement("div",{className:"qtt-btn qtt-down",onClick:function(e){return t.onClickQtt("down","minute",0,59)}},"-")))),React.createElement("div",{className:"cth-tpick-item cth-tpick-apm"},React.createElement("button",{type:"button",onClick:function(e){return t.onChange(t.state.apm,"apm")},className:"am-pm-switch"},_townhub_add_ons.i18n[this.state.apm])))}},{key:"render",value:function(){var t=this,e=this.props.field,a=e.place,n=e.icon;null==n&&(n=""),null==a&&(a="");var i="cth-tpick-wrapper";1==this.state.show_selector&&(i+=" tpicker-show");var o=this.getReturn(null);return React.createElement("div",{className:i,ref:function(e){return t.wrapperRef=e}},""!=n&&React.createElement("i",{className:"tpick-icon "+n}
1),React.createElement("input",{type:"text",name:this.fName,className:"cth-input",placeholder:a,value:o,readOnly:!0,onFocus:this.onFocusInput}),""!=o&&React.createElement("span",{className:"cth-cleartime",onClick:this.onClearTime},React.createElement("i",{className:"fal fa-times"})),!0===this.state.show_selector&&this._renderPickers())}}]),l}();a.default=o},{}]},{},[2]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.