/*
 Pikaday

 Copyright 2014 David Bushell | BSD & MIT license | https://github.com/dbushell/Pikaday
*/
(function(m,k){if("object"===typeof exports){try{var v=require("moment")}catch(h){}module.exports=k(v)}else"function"===typeof define&&define.amd?define(function(h){try{v=h("moment")}catch(y){}return k(v)}):m.Pikaday=k(m.moment)})(this,function(m){var k="function"===typeof m,v=!!window.addEventListener,h=window.document,y=window.setTimeout,p=function(a,b,d,c){v?a.addEventListener(b,d,!!c):a.attachEvent("on"+b,d)},u=function(a,b,d,c){v?a.removeEventListener(b,d,!!c):a.detachEvent("on"+b,d)},C=function(a,
b,d){if(h.createEvent){var c=h.createEvent("HTMLEvents");c.initEvent(b,!0,!1);c=w(c,d);a.dispatchEvent(c)}else h.createEventObject&&(c=h.createEventObject(),c=w(c,d),a.fireEvent("on"+b,c))},g=function(a,b){return-1!==(" "+a.className+" ").indexOf(" "+b+" ")},A=function(a){return/Array/.test(Object.prototype.toString.call(a))},n=function(a){return/Date/.test(Object.prototype.toString.call(a))&&!isNaN(a.getTime())},K=function(a,b){return[31,0===a%4&&0!==a%100||0===a%400?29:28,31,30,31,30,31,31,30,31,
30,31][b]},D=function(a){n(a)&&a.setHours(0,0,0,0)},E=function(a,b){return a.getTime()===b.getTime()},w=function(a,b,d){var c,l;for(c in b)if((l=void 0!==a[c])&&"object"===typeof b[c]&&null!==b[c]&&void 0===b[c].nodeName)n(b[c])?d&&(a[c]=new Date(b[c].getTime())):A(b[c])?d&&(a[c]=b[c].slice(0)):a[c]=w({},b[c],d);else if(d||!l)a[c]=b[c];return a},B=function(a){0>a.month&&(a.year-=Math.ceil(Math.abs(a.month)/12),a.month+=12);11<a.month&&(a.year+=Math.floor(Math.abs(a.month)/12),a.month-=12);return a},
q={field:null,bound:void 0,position:"bottom left",reposition:!0,format:"YYYY-MM-DD",defaultDate:null,setDefaultDate:!1,firstDay:0,formatStrict:!1,minDate:null,maxDate:null,yearRange:10,showWeekNumber:!1,minYear:0,maxYear:9999,minMonth:void 0,maxMonth:void 0,startRange:null,endRange:null,isRTL:!1,yearSuffix:"",showMonthAfterYear:!1,showDaysInNextAndPreviousMonths:!1,numberOfMonths:1,mainCalendar:"left",container:void 0,i18n:{previousMonth:"Previous Month",nextMonth:"Next Month",months:"January February March April May June July August September October November December".split(" "),
weekdays:"Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),weekdaysShort:"Sun Mon Tue Wed Thu Fri Sat".split(" ")},theme:null,onSelect:null,onOpen:null,onClose:null,onDraw:null},L=function(a,b,d){for(b+=a.firstDay;7<=b;)b-=7;return d?a.i18n.weekdaysShort[b]:a.i18n.weekdays[b]},M=function(a){var b=[],d="false";if(a.isEmpty)if(a.showDaysInNextAndPreviousMonths)b.push("is-outside-current-month");else return'<td class="is-empty"></td>';a.isDisabled&&b.push("is-disabled");a.isToday&&
b.push("is-today");a.isSelected&&(b.push("is-selected"),d="true");a.isInRange&&b.push("is-inrange");a.isStartRange&&b.push("is-startrange");a.isEndRange&&b.push("is-endrange");return'<td data-day="'+a.day+'" class="'+b.join(" ")+'" aria-selected="'+d+'"><button class="pika-button pika-day" type="button" data-pika-year="'+a.year+'" data-pika-month="'+a.month+'" data-pika-day="'+a.day+'">'+a.day+"</button></td>"},N=function(a,b,d){var c=new Date(d,0,1);return'<td class="pika-week">'+Math.ceil(((new Date(d,
b,a)-c)/864E5+c.getDay()+1)/7)+"</td>"},O=function(a,b){return"<tr>"+(b?a.reverse():a).join("")+"</tr>"},H=function(a,b,d,c,l,x){var e,f=a._o,h=d===f.minYear,g=d===f.maxYear;x='<div id="'+x+'" class="pika-title" role="heading" aria-live="assertive">';var n=!0,m=!0;var k=[];for(e=0;12>e;e++)k.push('<option value="'+(d===l?e-b:12+e-b)+'"'+(e===c?' selected="selected"':"")+(h&&e<f.minMonth||g&&e>f.maxMonth?'disabled="disabled"':"")+">"+f.i18n.months[e]+"</option>");l='<div class="pika-label">'+f.i18n.months[c]+
'<select class="pika-select pika-select-month" tabindex="-1">'+k.join("")+"</select></div>";if(A(f.yearRange)){e=f.yearRange[0];var p=f.yearRange[1]+1}else e=d-f.yearRange,p=1+d+f.yearRange;for(k=[];e<p&&e<=f.maxYear;e++)e>=f.minYear&&k.push('<option value="'+e+'"'+(e===d?' selected="selected"':"")+">"+e+"</option>");d='<div class="pika-label">'+d+f.yearSuffix+'<select class="pika-select pika-select-year" tabindex="-1">'+k.join("")+"</select></div>";x=f.showMonthAfterYear?x+(d+l):x+(l+d);h&&(0===
c||f.minMonth>=c)&&(n=!1);g&&(11===c||f.maxMonth<=c)&&(m=!1);0===b&&(x+='<button class="pika-prev'+(n?"":" is-disabled")+'" type="button">'+f.i18n.previousMonth+"</button>");b===a._o.numberOfMonths-1&&(x+='<button class="pika-next'+(m?"":" is-disabled")+'" type="button">'+f.i18n.nextMonth+"</button>");return x+"</div>"},F=function(a){var b=this,d=b.config(a);b._onMouseDown=function(a){if(b._v){a=a||window.event;var c=a.target||a.srcElement;if(c)if(g(c,"is-disabled")||(!g(c,"pika-button")||g(c,"is-empty")||
g(c.parentNode,"is-disabled")?g(c,"pika-prev")?b.prevMonth():g(c,"pika-next")&&b.nextMonth():(b.setDate(new Date(c.getAttribute("data-pika-year"),c.getAttribute("data-pika-month"),c.getAttribute("data-pika-day"))),d.bound&&y(function(){b.hide();d.field&&d.field.blur()},100))),g(c,"pika-select"))b._c=!0;else if(a.preventDefault)a.preventDefault();else return a.returnValue=!1}};b._onChange=function(a){a=a||window.event;(a=a.target||a.srcElement)&&(g(a,"pika-select-month")?b.gotoMonth(a.value):g(a,"pika-select-year")&&
b.gotoYear(a.value))};b._onKeyChange=function(a){a=a||window.event;if(b.isVisible())switch(a.keyCode){case 13:case 27:d.field.blur();break;case 37:a.preventDefault();b.adjustDate("subtract",1);break;case 38:b.adjustDate("subtract",7);break;case 39:b.adjustDate("add",1);break;case 40:b.adjustDate("add",7)}};b._onInputChange=function(a){a.firedBy!==b&&(a=k?(a=m(d.field.value,d.format,d.formatStrict))&&a.isValid()?a.toDate():null:new Date(Date.parse(d.field.value)),n(a)&&b.setDate(a),b._v||b.show())};
b._onInputFocus=function(){b.show()};b._onInputClick=function(){b.show()};b._onInputBlur=function(){var a=h.activeElement;do if(g(a,"pika-single"))return;while(a=a.parentNode);b._c||(b._b=y(function(){b.hide()},50));b._c=!1};b._onClick=function(a){a=a||window.event;var c=a=a.target||a.srcElement;if(a){v||!g(a,"pika-select")||a.onchange||(a.setAttribute("onchange","return;"),p(a,"change",b._onChange));do if(g(c,"pika-single")||c===d.trigger)return;while(c=c.parentNode);b._v&&a!==d.trigger&&c!==d.trigger&&
b.hide()}};b.el=h.createElement("div");b.el.className="pika-single"+(d.isRTL?" is-rtl":"")+(d.theme?" "+d.theme:"");p(b.el,"mousedown",b._onMouseDown,!0);p(b.el,"touchend",b._onMouseDown,!0);p(b.el,"change",b._onChange);p(h,"keydown",b._onKeyChange);d.field&&(d.container?d.container.appendChild(b.el):d.bound?h.body.appendChild(b.el):d.field.parentNode.insertBefore(b.el,d.field.nextSibling),p(d.field,"change",b._onInputChange),d.defaultDate||(d.defaultDate=k&&d.field.value?m(d.field.value,d.format).toDate():
new Date(Date.parse(d.field.value)),d.setDefaultDate=!0));a=d.defaultDate;n(a)?d.setDefaultDate?b.setDate(a,!0):b.gotoDate(a):b.gotoDate(new Date);d.bound?(this.hide(),b.el.className+=" is-bound",p(d.trigger,"click",b._onInputClick),p(d.trigger,"focus",b._onInputFocus),p(d.trigger,"blur",b._onInputBlur)):this.show()};F.prototype={config:function(a){this._o||(this._o=w({},q,!0));a=w(this._o,a,!0);a.isRTL=!!a.isRTL;a.field=a.field&&a.field.nodeName?a.field:null;a.theme="string"===typeof a.theme&&a.theme?
a.theme:null;a.bound=!!(void 0!==a.bound?a.field&&a.bound:a.field);a.trigger=a.trigger&&a.trigger.nodeName?a.trigger:a.field;a.disableWeekends=!!a.disableWeekends;a.disableDayFn="function"===typeof a.disableDayFn?a.disableDayFn:null;var b=parseInt(a.numberOfMonths,10)||1;a.numberOfMonths=4<b?4:b;n(a.minDate)||(a.minDate=!1);n(a.maxDate)||(a.maxDate=!1);a.minDate&&a.maxDate&&a.maxDate<a.minDate&&(a.maxDate=a.minDate=!1);a.minDate&&this.setMinDate(a.minDate);a.maxDate&&this.setMaxDate(a.maxDate);A(a.yearRange)?
(b=(new Date).getFullYear()-10,a.yearRange[0]=parseInt(a.yearRange[0],10)||b,a.yearRange[1]=parseInt(a.yearRange[1],10)||b):(a.yearRange=Math.abs(parseInt(a.yearRange,10))||q.yearRange,100<a.yearRange&&(a.yearRange=100));return a},toString:function(a){return n(this._d)?k?m(this._d).format(a||this._o.format):this._d.toDateString():""},getMoment:function(){return k?m(this._d):null},setMoment:function(a,b){k&&m.isMoment(a)&&this.setDate(a.toDate(),b)},getDate:function(){return n(this._d)?new Date(this._d.getTime()):
new Date},setDate:function(a,b){if(!a)return this._d=null,this._o.field&&(this._o.field.value="",C(this._o.field,"change",{firedBy:this})),this.draw();"string"===typeof a&&(a=new Date(Date.parse(a)));if(n(a)){var d=this._o.minDate,c=this._o.maxDate;n(d)&&a<d?a=d:n(c)&&a>c&&(a=c);this._d=new Date(a.getTime());D(this._d);this.gotoDate(this._d);this._o.field&&(this._o.field.value=this.toString(),C(this._o.field,"change",{firedBy:this}));b||"function"!==typeof this._o.onSelect||this._o.onSelect.call(this,
this.getDate())}},gotoDate:function(a){var b=!0;if(n(a)){if(this.calendars){b=new Date(this.calendars[0].year,this.calendars[0].month,1);var d=new Date(this.calendars[this.calendars.length-1].year,this.calendars[this.calendars.length-1].month,1),c=a.getTime();d.setMonth(d.getMonth()+1);d.setDate(d.getDate()-1);b=c<b.getTime()||d.getTime()<c}b&&(this.calendars=[{month:a.getMonth(),year:a.getFullYear()}],"right"===this._o.mainCalendar&&(this.calendars[0].month+=1-this._o.numberOfMonths));this.adjustCalendars()}},
adjustDate:function(a,b){var d=this.getDate(),c=864E5*parseInt(b),l;"add"===a?l=new Date(d.valueOf()+c):"subtract"===a&&(l=new Date(d.valueOf()-c));k&&("add"===a?l=m(d).add(b,"days").toDate():"subtract"===a&&(l=m(d).subtract(b,"days").toDate()));this.setDate(l)},adjustCalendars:function(){this.calendars[0]=B(this.calendars[0]);for(var a=1;a<this._o.numberOfMonths;a++)this.calendars[a]=B({month:this.calendars[0].month+a,year:this.calendars[0].year});this.draw()},gotoToday:function(){this.gotoDate(new Date)},
gotoMonth:function(a){isNaN(a)||(this.calendars[0].month=parseInt(a,10),this.adjustCalendars())},nextMonth:function(){this.calendars[0].month++;this.adjustCalendars()},prevMonth:function(){this.calendars[0].month--;this.adjustCalendars()},gotoYear:function(a){isNaN(a)||(this.calendars[0].year=parseInt(a,10),this.adjustCalendars())},setMinDate:function(a){a instanceof Date?(D(a),this._o.minDate=a,this._o.minYear=a.getFullYear(),this._o.minMonth=a.getMonth()):(this._o.minDate=q.minDate,this._o.minYear=
q.minYear,this._o.minMonth=q.minMonth,this._o.startRange=q.startRange);this.draw()},setMaxDate:function(a){a instanceof Date?(D(a),this._o.maxDate=a,this._o.maxYear=a.getFullYear(),this._o.maxMonth=a.getMonth()):(this._o.maxDate=q.maxDate,this._o.maxYear=q.maxYear,this._o.maxMonth=q.maxMonth,this._o.endRange=q.endRange);this.draw()},setStartRange:function(a){this._o.startRange=a},setEndRange:function(a){this._o.endRange=a},draw:function(a){if(this._v||a){var b=this._o,d=b.minYear,c=b.maxYear,l=b.minMonth,
h=b.maxMonth;a="";this._y<=d&&(this._y=d,!isNaN(l)&&this._m<l&&(this._m=l));this._y>=c&&(this._y=c,!isNaN(h)&&this._m>h&&(this._m=h));d="pika-title-"+Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,2);for(c=0;c<b.numberOfMonths;c++)a+='<div class="pika-lendar">'+H(this,c,this.calendars[c].year,this.calendars[c].month,this.calendars[0].year,d)+this.render(this.calendars[c].year,this.calendars[c].month,d)+"</div>";this.el.innerHTML=a;b.bound&&"hidden"!==b.field.type&&y(function(){b.trigger.focus()},
1);if("function"===typeof this._o.onDraw)this._o.onDraw(this);this._o.field.setAttribute("aria-label","Use the arrow keys to pick a date")}},adjustPosition:function(){var a;if(!this._o.container){this.el.style.position="absolute";var b=a=this._o.trigger;var d=this.el.offsetWidth;var c=this.el.offsetHeight;var l=window.innerWidth||h.documentElement.clientWidth;var k=window.innerHeight||h.documentElement.clientHeight;var e=window.pageYOffset||h.body.scrollTop||h.documentElement.scrollTop;if("function"===
typeof a.getBoundingClientRect){b=a.getBoundingClientRect();var f=b.left+window.pageXOffset;var g=b.bottom+window.pageYOffset}else for(f=b.offsetLeft,g=b.offsetTop+b.offsetHeight;b=b.offsetParent;)f+=b.offsetLeft,g+=b.offsetTop;if(this._o.reposition&&f+d>l||-1<this._o.position.indexOf("right")&&0<f-d+a.offsetWidth)f=f-d+a.offsetWidth;if(this._o.reposition&&g+c>k+e||-1<this._o.position.indexOf("top")&&0<g-c-a.offsetHeight)g=g-c-a.offsetHeight;this.el.style.left=f+"px";this.el.style.top=g+"px"}},render:function(a,
b,d){var c=this._o,h=new Date,g=K(a,b),e=(new Date(a,b,1)).getDay(),f=[],k=[];D(h);0<c.firstDay&&(e-=c.firstDay,0>e&&(e+=7));for(var m=0===b?11:b-1,p=11===b?0:b+1,q=0===b?a-1:a,u=11===b?a+1:a,v=K(q,m),w=g+e,r=w;7<r;)r-=7;w+=7-r;for(var y=r=0;r<w;r++){var t=new Date(a,b,1+(r-e)),A=n(this._d)?E(t,this._d):!1,C=E(t,h),B=r<e||r>=g+e,G=1+(r-e),I=b,J=a,F=c.startRange&&E(c.startRange,t),H=c.endRange&&E(c.endRange,t),P=c.startRange&&c.endRange&&c.startRange<t&&t<c.endRange,z;!(z=c.minDate&&t<c.minDate||c.maxDate&&
t>c.maxDate)&&(z=c.disableWeekends)&&(z=t.getDay(),z=0===z||6===z);t=z||c.disableDayFn&&c.disableDayFn(t);B&&(r<e?(G=v+G,I=m,J=q):(G-=g,I=p,J=u));k.push(M({day:G,month:I,year:J,isSelected:A,isToday:C,isDisabled:t,isEmpty:B,isStartRange:F,isEndRange:H,isInRange:P,showDaysInNextAndPreviousMonths:c.showDaysInNextAndPreviousMonths}));7===++y&&(c.showWeekNumber&&k.unshift(N(r-e,b,a)),f.push(O(k,c.isRTL)),k=[],y=0)}b=[];c.showWeekNumber&&b.push("<th></th>");for(a=0;7>a;a++)b.push('<th scope="col"><abbr title="'+
L(c,a)+'">'+L(c,a,!0)+"</abbr></th>");c="<thead><tr>"+(c.isRTL?b.reverse():b).join("")+"</tr></thead>";return'<table cellpadding="0" cellspacing="0" class="pika-table" role="grid" aria-labelledby="'+d+'">'+c+("<tbody>"+f.join("")+"</tbody>")+"</table>"},isVisible:function(){return this._v},show:function(){if(!this.isVisible()){var a=this.el;var b=(" "+a.className+" ").replace(" is-hidden "," ");b=b.trim?b.trim():b.replace(/^\s+|\s+$/g,"");a.className=b;this._v=!0;this.draw();this._o.bound&&(p(h,"click",
this._onClick),this.adjustPosition());"function"===typeof this._o.onOpen&&this._o.onOpen.call(this)}},hide:function(){var a=this._v;if(!1!==a){this._o.bound&&u(h,"click",this._onClick);this.el.style.position="static";this.el.style.left="auto";this.el.style.top="auto";var b=this.el;g(b,"is-hidden")||(b.className=""===b.className?"is-hidden":b.className+" is-hidden");this._v=!1;void 0!==a&&"function"===typeof this._o.onClose&&this._o.onClose.call(this)}},destroy:function(){this.hide();u(this.el,"mousedown",
this._onMouseDown,!0);u(this.el,"touchend",this._onMouseDown,!0);u(this.el,"change",this._onChange);this._o.field&&(u(this._o.field,"change",this._onInputChange),this._o.bound&&(u(this._o.trigger,"click",this._onInputClick),u(this._o.trigger,"focus",this._onInputFocus),u(this._o.trigger,"blur",this._onInputBlur)));this.el.parentNode&&this.el.parentNode.removeChild(this.el)}};return F});