/*
 Pikaday

 Copyright 2014 David Bushell | BSD & MIT license | https://github.com/dbushell/Pikaday
 Pikaday jQuery plugin.

 Copyright 2013 David Bushell | BSD & MIT license | https://github.com/dbushell/Pikaday
*/
(function(k,g){if("object"===typeof exports){try{var l=require("moment")}catch(e){}module.exports=g(l)}else"function"===typeof define&&define.amd?define(function(e){try{l=e("moment")}catch(h){}return g(l)}):k.Pikaday=g(k.moment)})(this,function(k){var g="function"===typeof k,l=!!window.addEventListener,e=window.document,h=window.setTimeout,r=function(a,b,c,d){l?a.addEventListener(b,c,!!d):a.attachEvent("on"+b,c)},t=function(a,b,c,d){l?a.removeEventListener(b,c,!!d):a.detachEvent("on"+b,c)},z=function(a,
b,c){if(e.createEvent){var d=e.createEvent("HTMLEvents");d.initEvent(b,!0,!1);d=u(d,c);a.dispatchEvent(d)}else e.createEventObject&&(d=e.createEventObject(),d=u(d,c),a.fireEvent("on"+b,d))},p=function(a,b){return-1!==(" "+a.className+" ").indexOf(" "+b+" ")},y=function(a){return/Array/.test(Object.prototype.toString.call(a))},n=function(a){return/Date/.test(Object.prototype.toString.call(a))&&!isNaN(a.getTime())},A=function(a){n(a)&&a.setHours(0,0,0,0)},B=function(a,b){return a.getTime()===b.getTime()},
u=function(a,b,c){var d,v;for(d in b)if((v=void 0!==a[d])&&"object"===typeof b[d]&&null!==b[d]&&void 0===b[d].nodeName)n(b[d])?c&&(a[d]=new Date(b[d].getTime())):y(b[d])?c&&(a[d]=b[d].slice(0)):a[d]=u({},b[d],c);else if(c||!v)a[d]=b[d];return a},C=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},D={field:null,bound:void 0,position:"bottom left",reposition:!0,format:"YYYY-MM-DD",defaultDate:null,
setDefaultDate:!1,firstDay:0,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,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},E=function(a,b,c){for(b+=a.firstDay;7<=b;)b-=7;return c?a.i18n.weekdaysShort[b]:a.i18n.weekdays[b]},G=function(a){if(a.isEmpty)return'<td class="is-empty"></td>';var b=[];a.isDisabled&&b.push("is-disabled");a.isToday&&b.push("is-today");a.isSelected&&b.push("is-selected");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(" ")+'"><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>"},H=function(a,b,c){var d=new Date(c,0,1);return'<td class="pika-week">'+Math.ceil(((new Date(c,b,a)-d)/864E5+d.getDay()+1)/7)+"</td>"},I=function(a,b){return"<tr>"+(b?a.reverse():a).join("")+"</tr>"},J=function(a,b,c,d,v){var f,m=a._o,e=c===m.minYear,l=c===m.maxYear,x='<div class="pika-title">',
k=!0,g=!0;var h=[];for(f=0;12>f;f++)h.push('<option value="'+(c===v?f-b:12+f-b)+'"'+(f===d?" selected":"")+(e&&f<m.minMonth||l&&f>m.maxMonth?"disabled":"")+">"+m.i18n.months[f]+"</option>");v='<div class="pika-label">'+m.i18n.months[d]+'<select class="pika-select pika-select-month" tabindex="-1">'+h.join("")+"</select></div>";if(y(m.yearRange)){f=m.yearRange[0];var n=m.yearRange[1]+1}else f=c-m.yearRange,n=1+c+m.yearRange;for(h=[];f<n&&f<=m.maxYear;f++)f>=m.minYear&&h.push('<option value="'+f+'"'+
(f===c?" selected":"")+">"+f+"</option>");c='<div class="pika-label">'+c+m.yearSuffix+'<select class="pika-select pika-select-year" tabindex="-1">'+h.join("")+"</select></div>";x=m.showMonthAfterYear?x+(c+v):x+(v+c);e&&(0===d||m.minMonth>=d)&&(k=!1);l&&(11===d||m.maxMonth<=d)&&(g=!1);0===b&&(x+='<button class="pika-prev'+(k?"":" is-disabled")+'" type="button">'+m.i18n.previousMonth+"</button>");b===a._o.numberOfMonths-1&&(x+='<button class="pika-next'+(g?"":" is-disabled")+'" type="button">'+m.i18n.nextMonth+
"</button>");return x+"</div>"},F=function(a){var b=this,c=b.config(a);b._onMouseDown=function(a){if(b._v){a=a||window.event;var d=a.target||a.srcElement;if(d)if(p(d.parentNode,"is-disabled")||(p(d,"pika-button")&&!p(d,"is-empty")?(b.setDate(new Date(d.getAttribute("data-pika-year"),d.getAttribute("data-pika-month"),d.getAttribute("data-pika-day"))),c.bound&&h(function(){b.hide();c.field&&c.field.blur()},100)):p(d,"pika-prev")?b.prevMonth():p(d,"pika-next")&&b.nextMonth()),p(d,"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)&&(p(a,"pika-select-month")?b.gotoMonth(a.value):p(a,"pika-select-year")&&b.gotoYear(a.value))};b._onInputChange=function(a){a.firedBy!==b&&(a=g?(a=k(c.field.value,c.format))&&a.isValid()?a.toDate():null:new Date(Date.parse(c.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=e.activeElement;do if(p(a,"pika-single"))return;while(a=a.parentNode);b._c||(b._b=h(function(){b.hide()},50));b._c=!1};b._onClick=function(a){a=a||window.event;var d=a=a.target||a.srcElement;if(a){l||!p(a,"pika-select")||a.onchange||(a.setAttribute("onchange","return;"),r(a,"change",b._onChange));do if(p(d,"pika-single")||d===c.trigger)return;while(d=d.parentNode);b._v&&a!==c.trigger&&d!==c.trigger&&b.hide()}};b.el=e.createElement("div");b.el.className="pika-single"+(c.isRTL?" is-rtl":
"")+(c.theme?" "+c.theme:"");r(b.el,"mousedown",b._onMouseDown,!0);r(b.el,"touchend",b._onMouseDown,!0);r(b.el,"change",b._onChange);c.field&&(c.container?c.container.appendChild(b.el):c.bound?e.body.appendChild(b.el):c.field.parentNode.insertBefore(b.el,c.field.nextSibling),r(c.field,"change",b._onInputChange),c.defaultDate||(c.defaultDate=g&&c.field.value?k(c.field.value,c.format).toDate():new Date(Date.parse(c.field.value)),c.setDefaultDate=!0));a=c.defaultDate;n(a)?c.setDefaultDate?b.setDate(a,
!0):b.gotoDate(a):b.gotoDate(new Date);c.bound?(this.hide(),b.el.className+=" is-bound",r(c.trigger,"click",b._onInputClick),r(c.trigger,"focus",b._onInputFocus),r(c.trigger,"blur",b._onInputBlur)):this.show()};F.prototype={config:function(a){this._o||(this._o=u({},D,!0));a=u(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&&(A(a.maxDate),a.maxYear=a.maxDate.getFullYear(),a.maxMonth=a.maxDate.getMonth());y(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))||D.yearRange,100<a.yearRange&&(a.yearRange=100));return a},toString:function(a){return n(this._d)?g?k(this._d).format(a||this._o.format):this._d.toDateString():""},getMoment:function(){return g?k(this._d):null},setMoment:function(a,b){g&&k.isMoment(a)&&this.setDate(a.toDate(),b)},getDate:function(){return n(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="",z(this._o.field,"change",{firedBy:this})),this.draw();"string"===typeof a&&(a=new Date(Date.parse(a)));if(n(a)){var c=this._o.minDate,d=this._o.maxDate;n(c)&&a<c?a=c:n(d)&&a>d&&(a=d);this._d=new Date(a.getTime());A(this._d);this.gotoDate(this._d);this._o.field&&(this._o.field.value=this.toString(),z(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 c=new Date(this.calendars[this.calendars.length-1].year,this.calendars[this.calendars.length-1].month,1),d=a.getTime();c.setMonth(c.getMonth()+1);c.setDate(c.getDate()-1);b=d<b.getTime()||c.getTime()<d}b&&(this.calendars=[{month:a.getMonth(),year:a.getFullYear()}],"right"===this._o.mainCalendar&&(this.calendars[0].month+=1-this._o.numberOfMonths));this.adjustCalendars()}},adjustCalendars:function(){this.calendars[0]=
C(this.calendars[0]);for(var a=1;a<this._o.numberOfMonths;a++)this.calendars[a]=C({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(a);this._o.minDate=a;this._o.minYear=a.getFullYear();this._o.minMonth=a.getMonth()},setMaxDate:function(a){this._o.maxDate=a},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,c=b.minYear,d=b.maxYear,e=b.minMonth,f=b.maxMonth;a="";this._y<=c&&(this._y=c,!isNaN(e)&&this._m<e&&(this._m=e));this._y>=d&&(this._y=d,!isNaN(f)&&this._m>f&&(this._m=f));for(c=0;c<b.numberOfMonths;c++)a+=
'<div class="pika-lendar">'+J(this,c,this.calendars[c].year,this.calendars[c].month,this.calendars[0].year)+this.render(this.calendars[c].year,this.calendars[c].month)+"</div>";this.el.innerHTML=a;b.bound&&"hidden"!==b.field.type&&h(function(){b.trigger.focus()},1);if("function"===typeof this._o.onDraw){var m=this;h(function(){m._o.onDraw.call(m)},0)}}},adjustPosition:function(){var a;if(!this._o.container){this.el.style.position="absolute";var b=a=this._o.trigger;var c=this.el.offsetWidth;var d=
this.el.offsetHeight;var l=window.innerWidth||e.documentElement.clientWidth;var f=window.innerHeight||e.documentElement.clientHeight;var m=window.pageYOffset||e.body.scrollTop||e.documentElement.scrollTop;if("function"===typeof a.getBoundingClientRect){b=a.getBoundingClientRect();var k=b.left+window.pageXOffset;var g=b.bottom+window.pageYOffset}else for(k=b.offsetLeft,g=b.offsetTop+b.offsetHeight;b=b.offsetParent;)k+=b.offsetLeft,g+=b.offsetTop;if(this._o.reposition&&k+c>l||-1<this._o.position.indexOf("right")&&
0<k-c+a.offsetWidth)k=k-c+a.offsetWidth;if(this._o.reposition&&g+d>f+m||-1<this._o.position.indexOf("top")&&0<g-d-a.offsetHeight)g=g-d-a.offsetHeight;this.el.style.left=k+"px";this.el.style.top=g+"px"}},render:function(a,b){var c=this._o,d=new Date;var e=[31,0===a%4&&0!==a%100||0===a%400?29:28,31,30,31,30,31,31,30,31,30,31][b];var f=(new Date(a,b,1)).getDay(),k=[],g=[];A(d);0<c.firstDay&&(f-=c.firstDay,0>f&&(f+=7));for(var l=e+f,h=l;7<h;)h-=7;l+=7-h;for(var p=h=0;h<l;h++){var q=new Date(a,b,1+(h-
f)),r=n(this._d)?B(q,this._d):!1,t=B(q,d),u=h<f||h>=e+f,y=c.startRange&&B(c.startRange,q),z=c.endRange&&B(c.endRange,q),C=c.startRange&&c.endRange&&c.startRange<q&&q<c.endRange,w;!(w=c.minDate&&q<c.minDate||c.maxDate&&q>c.maxDate)&&(w=c.disableWeekends)&&(w=q.getDay(),w=0===w||6===w);q=w||c.disableDayFn&&c.disableDayFn(q);g.push(G({day:1+(h-f),month:b,year:a,isSelected:r,isToday:t,isDisabled:q,isEmpty:u,isStartRange:y,isEndRange:z,isInRange:C}));7===++p&&(c.showWeekNumber&&g.unshift(H(h-f,b,a)),k.push(I(g,
c.isRTL)),g=[],p=0)}e=[];c.showWeekNumber&&e.push("<th></th>");for(d=0;7>d;d++)e.push('<th scope="col"><abbr title="'+E(c,d)+'">'+E(c,d,!0)+"</abbr></th>");return'<table cellpadding="0" cellspacing="0" class="pika-table">'+("<thead>"+(c.isRTL?e.reverse():e).join("")+"</thead>")+("<tbody>"+k.join("")+"</tbody>")+"</table>"},isVisible:function(){return this._v},show:function(){if(!this._v){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&&(r(e,"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&&t(e,"click",this._onClick);this.el.style.position="static";this.el.style.left="auto";this.el.style.top="auto";var b=this.el;p(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();t(this.el,"mousedown",this._onMouseDown,!0);t(this.el,"touchend",this._onMouseDown,!0);t(this.el,"change",this._onChange);this._o.field&&(t(this._o.field,"change",this._onInputChange),this._o.bound&&(t(this._o.trigger,"click",this._onInputClick),t(this._o.trigger,"focus",this._onInputFocus),t(this._o.trigger,"blur",this._onInputBlur)));this.el.parentNode&&this.el.parentNode.removeChild(this.el)}};return F});
(function(k,g){"object"===typeof exports?g(require("jquery"),require("pikaday")):"function"===typeof define&&define.amd?define(["jquery","pikaday"],g):g(k.jQuery,k.Pikaday)})(this,function(k,g){k.fn.pikaday=function(){var l=arguments;l&&l.length||(l=[{}]);return this.each(function(){var e=k(this),h=e.data("pikaday");h instanceof g?"string"===typeof l[0]&&"function"===typeof h[l[0]]&&(h[l[0]].apply(h,Array.prototype.slice.call(l,1)),"destroy"===l[0]&&e.removeData("pikaday")):"object"===typeof l[0]&&
(h=k.extend({},l[0]),h.field=e[0],e.data("pikaday",new g(h)))})}});