/*
 Pikaday jQuery plugin.

 Copyright (C) 2013 David Bushell | BSD & MIT license | https://github.com/dbushell/Pikaday
*/
!function(l,e){if("object"==typeof exports){try{var k=require("moment")}catch(f){}module.exports=e(k)}else"function"==typeof define&&define.amd?define(function(f){try{k=f("moment")}catch(p){}return e(k)}):l.Pikaday=e(l.moment)}(this,function(l){var e="function"==typeof l,k=!!window.addEventListener,f=window.document,p=window.setTimeout,n=function(a,b,d,c){k?a.addEventListener(b,d,!!c):a.attachEvent("on"+b,d)},r=function(a,b,d,c){k?a.removeEventListener(b,d,!!c):a.detachEvent("on"+b,d)},m=function(a,
b){return-1!==(" "+a.className+" ").indexOf(" "+b+" ")},A=function(a){return/Array/.test(Object.prototype.toString.call(a))},q=function(a){return/Date/.test(Object.prototype.toString.call(a))&&!isNaN(a.getTime())},L=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]},C=function(a){q(a)&&a.setHours(0,0,0,0)},D=function(a,b){return a.getTime()===b.getTime()},v=function(a,b,d){var c,x;for(c in b)(x=void 0!==a[c])&&"object"==typeof b[c]&&null!==b[c]&&void 0===b[c].nodeName?
q(b[c])?d&&(a[c]=new Date(b[c].getTime())):A(b[c])?d&&(a[c]=b[c].slice(0)):a[c]=v({},b[c],d):!d&&x||(a[c]=b[c]);return a},E=function(a,b,d){var c;f.createEvent?((c=f.createEvent("HTMLEvents")).initEvent(b,!0,!1),c=v(c,d),a.dispatchEvent(c)):f.createEventObject&&(c=f.createEventObject(),c=v(c,d),a.fireEvent("on"+b,c))},B=function(a){return 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),a},u={field:null,bound:void 0,
ariaLabel:"Use the arrow keys to pick a date",position:"bottom left",reposition:!0,format:"YYYY-MM-DD",toString:null,parse:null,defaultDate:null,setDefaultDate:!1,firstDay:0,formatStrict:!1,minDate:null,maxDate:null,yearRange:10,showWeekNumber:!1,pickWholeWeek:!1,minYear:0,maxYear:9999,minMonth:void 0,maxMonth:void 0,startRange:null,endRange:null,isRTL:!1,yearSuffix:"",showMonthAfterYear:!1,showDaysInNextAndPreviousMonths:!1,enableSelectionDaysInNextAndPreviousMonths:!1,numberOfMonths:1,mainCalendar:"left",
container:void 0,blurFieldOnSelect:!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,events:[],onSelect:null,onOpen:null,onClose:null,onDraw:null,keyboardInput:!0},M=function(a,b,d){for(b+=a.firstDay;7<=b;)b-=7;return d?a.i18n.weekdaysShort[b]:
a.i18n.weekdays[b]},N=function(a){var b=[],d="false";if(a.isEmpty){if(!a.showDaysInNextAndPreviousMonths)return'<td class="is-empty"></td>';b.push("is-outside-current-month");a.enableSelectionDaysInNextAndPreviousMonths||b.push("is-selection-disabled")}return a.isDisabled&&b.push("is-disabled"),a.isToday&&b.push("is-today"),a.isSelected&&(b.push("is-selected"),d="true"),a.hasEvent&&b.push("has-event"),a.isInRange&&b.push("is-inrange"),a.isStartRange&&b.push("is-startrange"),a.isEndRange&&b.push("is-endrange"),
'<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>"},O=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>"},P=function(a,b,d,c){return'<tr class="pika-row'+(d?" pick-whole-week":"")+(c?" is-selected":"")+'">'+(b?a.reverse():a).join("")+"</tr>"},
H=function(a,b,d,c,x,h){var f,k,g=a._o,l=d===g.minYear,e=d===g.maxYear,m='<div id="'+h+'" class="pika-title" role="heading" aria-live="assertive">',q=!0,p=!0;var n=[];for(h=0;12>h;h++)n.push('<option value="'+(d===x?h-b:12+h-b)+'"'+(h===c?' selected="selected"':"")+(l&&h<g.minMonth||e&&h>g.maxMonth?'disabled="disabled"':"")+">"+g.i18n.months[h]+"</option>");x='<div class="pika-label">'+g.i18n.months[c]+'<select class="pika-select pika-select-month" tabindex="-1">'+n.join("")+"</select></div>";A(g.yearRange)?
(h=g.yearRange[0],f=g.yearRange[1]+1):(h=d-g.yearRange,f=1+d+g.yearRange);for(n=[];h<f&&h<=g.maxYear;h++)h>=g.minYear&&n.push('<option value="'+h+'"'+(h===d?' selected="selected"':"")+">"+h+"</option>");return k='<div class="pika-label">'+d+g.yearSuffix+'<select class="pika-select pika-select-year" tabindex="-1">'+n.join("")+"</select></div>",g.showMonthAfterYear?m+=k+x:m+=x+k,l&&(0===c||g.minMonth>=c)&&(q=!1),e&&(11===c||g.maxMonth<=c)&&(p=!1),0===b&&(m+='<button class="pika-prev'+(q?"":" is-disabled")+
'" type="button">'+g.i18n.previousMonth+"</button>"),b===a._o.numberOfMonths-1&&(m+='<button class="pika-next'+(p?"":" is-disabled")+'" type="button">'+g.i18n.nextMonth+"</button>"),m+"</div>"},F=function(a){var b=this,d=b.config(a);b._onMouseDown=function(a){if(b._v){var c=(a=a||window.event).target||a.srcElement;if(c)if(m(c,"is-disabled")||(!m(c,"pika-button")||m(c,"is-empty")||m(c.parentNode,"is-disabled")?m(c,"pika-prev")?b.prevMonth():m(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&&p(function(){b.hide();d.blurFieldOnSelect&&d.field&&d.field.blur()},100))),m(c,"pika-select"))b._c=!0;else{if(!a.preventDefault)return a.returnValue=!1,!1;a.preventDefault()}}};b._onChange=function(a){var c=(a=a||window.event).target||a.srcElement;c&&(m(c,"pika-select-month")?b.gotoMonth(c.value):m(c,"pika-select-year")&&b.gotoYear(c.value))};b._onKeyChange=function(a){if(a=a||window.event,b.isVisible())switch(a.keyCode){case 13:case 27:d.field&&
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){var c;a.firedBy!==b&&(c=d.parse?d.parse(d.field.value,d.format):e?(c=l(d.field.value,d.format,d.formatStrict))&&c.isValid()?c.toDate():null:new Date(Date.parse(d.field.value)),q(c)&&b.setDate(c),b._v||b.show())};b._onInputFocus=function(){b.show()};b._onInputClick=function(){b.show()};
b._onInputBlur=function(){var a=f.activeElement;do if(m(a,"pika-single"))return;while(a=a.parentNode);b._c||(b._b=p(function(){b.hide()},50));b._c=!1};b._onClick=function(a){var c=(a=a||window.event).target||a.srcElement;if(a=c){!k&&m(c,"pika-select")&&(c.onchange||(c.setAttribute("onchange","return;"),n(c,"change",b._onChange)));do if(m(a,"pika-single")||a===d.trigger)return;while(a=a.parentNode);b._v&&c!==d.trigger&&a!==d.trigger&&b.hide()}};b.el=f.createElement("div");b.el.className="pika-single"+
(d.isRTL?" is-rtl":"")+(d.theme?" "+d.theme:"");n(b.el,"mousedown",b._onMouseDown,!0);n(b.el,"touchend",b._onMouseDown,!0);n(b.el,"change",b._onChange);d.keyboardInput&&n(f,"keydown",b._onKeyChange);d.field&&(d.container?d.container.appendChild(b.el):d.bound?f.body.appendChild(b.el):d.field.parentNode.insertBefore(b.el,d.field.nextSibling),n(d.field,"change",b._onInputChange),d.defaultDate||(e&&d.field.value?d.defaultDate=l(d.field.value,d.format).toDate():d.defaultDate=new Date(Date.parse(d.field.value)),
d.setDefaultDate=!0));a=d.defaultDate;q(a)?d.setDefaultDate?b.setDate(a,!0):b.gotoDate(a):b.gotoDate(new Date);d.bound?(this.hide(),b.el.className+=" is-bound",n(d.trigger,"click",b._onInputClick),n(d.trigger,"focus",b._onInputFocus),n(d.trigger,"blur",b._onInputBlur)):this.show()};return F.prototype={config:function(a){this._o||(this._o=v({},u,!0));a=v(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,q(a.minDate)||(a.minDate=!1),q(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))||u.yearRange,100<a.yearRange&&(a.yearRange=100));return a},toString:function(a){return a=a||this._o.format,q(this._d)?this._o.toString?this._o.toString(this._d,a):e?l(this._d).format(a):this._d.toDateString():""},getMoment:function(){return e?l(this._d):null},setMoment:function(a,b){e&&l.isMoment(a)&&this.setDate(a.toDate(),b)},getDate:function(){return q(this._d)?
new Date(this._d.getTime()):null},setDate:function(a,b){if(!a)return this._d=null,this._o.field&&(this._o.field.value="",E(this._o.field,"change",{firedBy:this})),this.draw();if("string"==typeof a&&(a=new Date(Date.parse(a))),q(a)){var d=this._o.minDate,c=this._o.maxDate;q(d)&&a<d?a=d:q(c)&&a>c&&(a=c);this._d=new Date(a.getTime());C(this._d);this.gotoDate(this._d);this._o.field&&(this._o.field.value=this.toString(),E(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(q(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,c=this.getDate()||new Date,f=864E5*parseInt(b);"add"===a?d=new Date(c.valueOf()+f):"subtract"===a&&(d=new Date(c.valueOf()-f));this.setDate(d)},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?(C(a),this._o.minDate=a,this._o.minYear=a.getFullYear(),this._o.minMonth=a.getMonth()):(this._o.minDate=u.minDate,this._o.minYear=u.minYear,this._o.minMonth=u.minMonth,this._o.startRange=
u.startRange);this.draw()},setMaxDate:function(a){a instanceof Date?(C(a),this._o.maxDate=a,this._o.maxYear=a.getFullYear(),this._o.maxMonth=a.getMonth()):(this._o.maxDate=u.maxDate,this._o.maxYear=u.maxYear,this._o.maxMonth=u.maxMonth,this._o.endRange=u.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;var d=b.minYear;var c=b.maxYear,f=b.minMonth,h=b.maxMonth;a="";this._y<=d&&(this._y=d,
!isNaN(f)&&this._m<f&&(this._m=f));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&&p(function(){b.trigger.focus()},1);"function"==typeof this._o.onDraw&&
this._o.onDraw(this);b.bound&&b.field.setAttribute("aria-label",b.ariaLabel)}},adjustPosition:function(){var a,b,d,c,k,h,l;if(!this._o.container){if(this.el.style.position="absolute",a=this._o.trigger,b=a,d=this.el.offsetWidth,c=this.el.offsetHeight,k=window.innerWidth||f.documentElement.clientWidth,h=window.innerHeight||f.documentElement.clientHeight,l=window.pageYOffset||f.body.scrollTop||f.documentElement.scrollTop,"function"==typeof a.getBoundingClientRect){var e=(b=a.getBoundingClientRect()).left+
window.pageXOffset;var g=b.bottom+window.pageYOffset}else for(e=b.offsetLeft,g=b.offsetTop+b.offsetHeight;b=b.offsetParent;)e+=b.offsetLeft,g+=b.offsetTop;(this._o.reposition&&e+d>k||-1<this._o.position.indexOf("right")&&0<e-d+a.offsetWidth)&&(e=e-d+a.offsetWidth);(this._o.reposition&&g+c>h+l||-1<this._o.position.indexOf("top")&&0<g-c-a.offsetHeight)&&(g=g-c-a.offsetHeight);this.el.style.left=e+"px";this.el.style.top=g+"px"}},render:function(a,b,d){var c=this._o,f=new Date,h=L(a,b),e=(new Date(a,
b,1)).getDay(),k=[],g=[];C(f);0<c.firstDay&&0>(e-=c.firstDay)&&(e+=7);for(var l=0===b?11:b-1,m=11===b?0:b+1,n=0===b?a-1:a,p=11===b?a+1:a,u=L(n,l),r=h+e,y=r;7<y;)y-=7;r+=7-y;y=!1;for(var w=0,v=0;w<r;w++){var t=new Date(a,b,w-e+1),A=!!q(this._d)&&D(t,this._d),I=D(t,f),E=-1!==c.events.indexOf(t.toDateString()),B=w<e||w>=h+e,G=w-e+1,J=b,K=a,F=c.startRange&&D(c.startRange,t),H=c.endRange&&D(c.endRange,t),Q=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&&(w<e?(G=u+G,J=l,K=n):(G-=h,J=m,K=p));I={day:G,month:J,year:K,hasEvent:E,isSelected:A,isToday:I,isDisabled:t,isEmpty:B,isStartRange:F,isEndRange:H,isInRange:Q,showDaysInNextAndPreviousMonths:c.showDaysInNextAndPreviousMonths,enableSelectionDaysInNextAndPreviousMonths:c.enableSelectionDaysInNextAndPreviousMonths};c.pickWholeWeek&&A&&(y=!0);g.push(N(I));7==++v&&(c.showWeekNumber&&g.unshift(O(w-
e,b,a)),k.push(P(g,c.isRTL,c.pickWholeWeek,y)),g=[],v=0,y=!1)}b=[];c.showWeekNumber&&b.push("<th></th>");for(a=0;7>a;a++)b.push('<th scope="col"><abbr title="'+M(c,a)+'">'+M(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>"+k.join("")+"</tbody>")+"</table>"},isVisible:function(){return this._v},show:function(){if(!this.isVisible()){this._v=!0;this.draw();
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._o.bound&&(n(f,"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&&r(f,"click",this._onClick);this.el.style.position="static";this.el.style.left="auto";this.el.style.top="auto";var b=this.el;m(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(){var a=this._o;this.hide();r(this.el,"mousedown",this._onMouseDown,!0);r(this.el,"touchend",this._onMouseDown,!0);r(this.el,"change",this._onChange);a.keyboardInput&&r(f,"keydown",this._onKeyChange);a.field&&(r(a.field,"change",this._onInputChange),a.bound&&(r(a.trigger,"click",this._onInputClick),r(a.trigger,"focus",this._onInputFocus),r(a.trigger,"blur",this._onInputBlur)));this.el.parentNode&&
this.el.parentNode.removeChild(this.el)}},F});
!function(l,e){"object"==typeof exports?e(require("jquery"),require("pikaday")):"function"==typeof define&&define.amd?define(["jquery","pikaday"],e):e(l.jQuery,l.Pikaday)}(this,function(l,e){l.fn.pikaday=function(){var k=arguments;return k&&k.length||(k=[{}]),this.each(function(){var f=l(this),p=f.data("pikaday");p instanceof e?"string"==typeof k[0]&&"function"==typeof p[k[0]]&&(p[k[0]].apply(p,Array.prototype.slice.call(k,1)),"destroy"===k[0]&&f.removeData("pikaday")):"object"==typeof k[0]&&(p=l.extend({},
k[0]),p.field=f[0],f.data("pikaday",new e(p)))})}});