!function(t){var e=0;t.add("module","datepicker",{translations:{en:{days:["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],months:["","January","February","March","April","May","June","July","August","September","October","November","December"],"months-short":["","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]}},init:function(t,i){this.app=t,this.$doc=t.$doc,this.$win=t.$win,this.$body=t.$body,this.lang=t.lang,this.animate=t.animate;var a={year:!1,month:!1,day:!1,format:"%d.%m.%Y",embed:!1,target:!1,selectYear:!1,sundayFirst:!1,startDate:!1,endDate:!1,animationOpen:"slideDown",animationClose:"slideUp"};this.context=i,this.params=i.getParams(a),this.$element=i.getElement(),this.$target=i.getTarget(),this.uuid=e++,this.namespace=".kube.datepicker-"+this.uuid,this.dateRegexp=/^(.*?)(\/|\.|,|\s|\-)(.*?)(?:\/|\.|,|\s|\-)(.*?)$/,this.value="",this.today={},this.current={},this.next={},this.prev={},this.selected={}},start:function(){this.$element.attr("uuid",this.uuid),this._buildStartEndDate(),this.$datepicker=t.create("class.datepicker.box",this.app,this),this.$datepicker.build(),this.params.embed?(this.build(),this.update(),this.$datepicker.addClass("is-embed"),this.$element.append(this.$datepicker)):(this.$datepicker.addClass("is-hidden"),this.$body.append(this.$datepicker),this.$element.on("click"+this.namespace,this._open.bind(this)))},stop:function(){this._disableEvents(),this.$datepicker.remove(),this.$element.off(this.namespace),this.$element.removeClass("datepicker-in")},build:function(){this._buildValue(),this._buildTodayDate(),this._buildSelectedDate(),this._buildCurrentDate()},update:function(){this._buildPrevNextDate(),this.$grid=t.create("class.datepicker.grid",this.app,this),this.$grid.build(),this.$datepicker.setControls(this.prev,this.next),this.$datepicker.setMonth(this.lang.get("months")[this.current.month]),this.$datepicker.setYear(this.current.year),this.$datepicker.setGrid(this.$grid)},setDate:function(e){e.preventDefault();var i=t.dom(e.target);if(i.attr("data-disabled")===!0)return this._close();var a={day:i.attr("data-day"),month:i.attr("data-month"),year:i.attr("data-year")},s=this._convertDateToFormat(a);if(this.params.embed===!1){var n=0!==this.$target.length?this.$target:this.$element;"INPUT"===n.get().tagName?n.val(s):n.text(s),this._close()}this.app.broadcast("datepicker.set",this,s,a)},setNextMonth:function(t){t.preventDefault(),this.current=this.next,this.update()},setPrevMonth:function(t){t.preventDefault(),this.current=this.prev,this.update()},setYear:function(){this.current.year=this.$datepicker.getYearFromSelect(),this.selected.day=!1,this.$datepicker.setYear(this.current.year),this.update()},_buildValue:function(){var t=0!==this.$target.length?this.$target:this.$element;this.value="INPUT"===t.get().tagName?t.val():t.text().trim()},_buildTodayDate:function(){var t=new Date;this.today={year:t.getFullYear(),month:parseInt(t.getMonth()+1),day:parseInt(t.getDate())}},_buildSelectedDate:function(){this.selected=this._parseDateString(this.value),""===this.value&&(this.selected.year=this.params.year?this.params.year:this.selected.year,this.selected.month=this.params.month?parseInt(this.params.month):this.selected.month,this.selected.day=!1)},_buildCurrentDate:function(){this.current=this.selected},_buildPrevNextDate:function(){var t=this._getPrevYearAndMonth(this.current.year,this.current.month);this.prev={year:t.year,month:t.month};var t=this._getNextYearAndMonth(this.current.year,this.current.month);this.next={year:t.year,month:t.month}},_buildStartEndDate:function(){this.params.startDate=this.params.startDate?this._parseDateString(this.params.startDate):!1,this.params.endDate=this.params.endDate?this._parseDateString(this.params.endDate):!1},_buildPosition:function(){this.position={};var t=this.$element.offset(),e=this.$element.innerHeight(),i=this.$element.innerWidth(),a=this.$datepicker.innerWidth(),s=this.$datepicker.innerHeight(),n=this.$win.width(),r=this.$doc.height(),h=0,d=t.left,o=t.top+e+1;this.position.type="left",d+a>n&&(this.position.type="right",h=n-(d+i)),o+s>r&&(this.params.animationOpen="show",this.params.animationClose="hide",o=o-s-e-2),this.position.top=o,this.position.left=d,this.position.right=h},_open:function(t){t&&t.preventDefault(),this._isOpened()||(this._closeAll(),this.app.broadcast("datepicker.open",this),this.build(),this.update(),this._buildPosition(),this._setPosition(),this.animate.run(this.$datepicker,this.params.animationOpen,this._opened.bind(this)))},_opened:function(){this._enableEvents(),this.$element.addClass("datepicker-in"),this.$datepicker.addClass("is-open"),this.app.broadcast("datepicker.opened",this)},_isOpened:function(){return this.$datepicker.hasClass("is-open")},_close:function(e){e&&0!==t.dom(e.target).closest(".datepicker").length||this._isOpened()&&(this.app.broadcast("datepicker.close",this),this.animate.run(this.$datepicker,this.params.animationClose,this._closed.bind(this)))},_closed:function(){this._disableEvents(),this.$datepicker.removeClass("is-open"),this.$element.removeClass("datepicker-in"),this.app.broadcast("datepicker.closed",this)},_closeAll:function(){t.dom(".datepicker.is-open").each(function(e){var i=t.dom(e),a=i.attr("data-uuid");this.$doc.off(".kube.datepicker-"+a),this.$win.off(".kube.datepicker-"+a),i.removeClass("is-open"),i.addClass("is-hidden")}.bind(this)),t.dom(".datepicker-in").removeClass("datepicker-in")},_handleKeyboard:function(t){27===t.which&&this._close()},_enableEvents:function(){this.$doc.on("keyup"+this.namespace,this._handleKeyboard.bind(this)),this.$doc.on("click"+this.namespace+" touchstart"+this.namespace,this._close.bind(this)),this.$win.on("resize"+this.namespace,this._resizePosition.bind(this))},_disableEvents:function(){this.$doc.off(this.namespace),this.$win.off(this.namespace)},_resizePosition:function(){this._buildPosition(),this._setPosition()},_setPosition:function(){var t="auto",e=this.position.right+"px";"left"===this.position.type&&(t=this.position.left+"px",e="auto"),this.$datepicker.css({top:this.position.top+"px",left:t,right:e})},_parseDateString:function(t){var e={},i=t.match(this.dateRegexp),a=this.params.format.match(this.dateRegexp);return e.year=null===i?this.today.year:parseInt(i[4]),"%m"===a[1]||"%M"===a[1]||"%F"===a[1]?(e.month=null===i?this.today.month:this._parseMonth(a[1],i[1]),e.day=null===i?!1:parseInt(i[3])):(e.month=null===i?this.today.month:this._parseMonth(a[3],i[3]),e.day=null===i?!1:parseInt(i[1])),e.splitter=null===i?".":i[2],e},_parseMonth:function(t,e){var i=parseInt(e);return"%M"===t?i=this.lang.get("months-short").indexOf(e):"%F"===t&&(i=this.lang.get("months").indexOf(e)),i},_convertDateToFormat:function(t){var e=this.params.format.replace("%d",t.day);return e=e.replace("%F",this.lang.get("months")[t.month]),e=e.replace("%m",this._addZero(t.month)),e=e.replace("%M",this.lang.get("months-short")[t.month]),e=e.replace("%Y",t.year)},_addZero:function(t){return t=Number(t),10>t?"0"+t:t},_getPrevYearAndMonth:function(t,e){var i={year:t,month:parseInt(e)-1};return i.month<=0&&(i.month=12,i.year--),i},_getNextYearAndMonth:function(t,e){var i={year:t,month:parseInt(e)+1};return i.month>12&&(i.month=1,i.year++),i}})}(Kube),function(t){t.add("class","datepicker.box",{"extends":["dom"],init:function(t,e){this.app=t,this.lang=t.lang,this.datepicker=e,this.params=e.params,this.namespace=e.namespace,this.selected=e.selected},build:function(){this._buildBox(),this._buildHead(),this._buildControlPrev(),this._buildMonthBox(),this._buildControlNext(),this._buildWeekdays(),this._buildBody()},getYearFromSelect:function(){return Number(this.$yearSelect.val())},setMonth:function(t){this.$month.html(t)},setYear:function(t){this.$yearValue.html(t),this.params.selectYear&&this.$yearSelect&&this.$yearSelect.val(t)},setGrid:function(t){this.$dbody.html(""),this.$dbody.append(t)},setControls:function(t,e){var i=function(t,e){return e=e?e:t.day,new Date(t.year+"/"+t.month+"/"+e)};if(this.params.startDate){var a=i(t,31),s=i(this.params.startDate),n=s.getTime()>a.getTime()?"hide":"show";this.$prev[n]()}if(this.params.endDate){var r=i(e,1),h=i(this.params.endDate),n=h.getTime()"),this.addClass("datepicker")},_buildHead:function(){this.$head=t.dom('
'),this.append(this.$head)},_buildControlPrev:function(){this.$prev=t.dom('').html("<"),this.$prev.on("click"+this.namespace,this.datepicker.setPrevMonth.bind(this.datepicker)),this.$head.append(this.$prev)},_buildControlNext:function(){this.$next=t.dom('').html(">"),this.$next.on("click"+this.namespace,this.datepicker.setNextMonth.bind(this.datepicker)),this.$head.append(this.$next)},_buildMonthBox:function(){this.$monthBox=t.dom('
'),this.$head.append(this.$monthBox),this._buildMonth(),this._buildYear(),this._buildYearSelect()},_buildMonth:function(){this.$month=t.dom(""),this.$monthBox.append(this.$month)},_buildYear:function(){this.$year=t.dom(""),this.$yearValue=t.dom(""),this.$year.append(this.$yearValue),this.$monthBox.append(this.$year)},_buildYearSelect:function(){if(this.params.selectYear){var e=new Date,i=this.params.startDate?this.params.startDate.year:e.getFullYear()-99,a=this.params.endDate?this.params.endDate.year:e.getFullYear();if(!(2>a-i)){this.$yearSelect=t.dom("