!function(n,t){"use strict";var i;if("object"==typeof exports){try{i=require("moment")}catch(n){}module.exports=t(i)}else"function"==typeof define&&define.amd?define(function(n){try{i=n("moment")}catch(n){}return t(i)}):n.Pikaday=t(n.moment)}(this,function(n){"use strict";function u(n,t,i,r){y?n.addEventListener(t,i,!!r):n.attachEvent("on"+t,i)}function e(n,t,i,r){y?n.removeEventListener(t,i,!!r):n.detachEvent("on"+t,i)}function i(n,t){return-1!==(" "+n.className+" ").indexOf(" "+t+" ")}function l(n,t){i(n,t)||(n.className=""===n.className?t:n.className+" "+t)}function a(n,t){var i;n.className=(i=(" "+n.className+" ").replace(" "+t+" "," ")).trim?i.trim():i.replace(/^\s+|\s+$/g,"")}function v(n){return/Array/.test(Object.prototype.toString.call(n))}function r(n){return/Date/.test(Object.prototype.toString.call(n))&&!isNaN(n.getTime())}function w(n,t){return[31,(i=n)%4==0&&i%100!=0||i%400==0?29:28,31,30,31,30,31,31,30,31,30,31][t];var i}function h(n){r(n)&&n.setHours(0,0,0,0)}function c(n,t){return n.getTime()===t.getTime()}function b(n,i,r){var u;t.createEvent?((u=t.createEvent("HTMLEvents")).initEvent(i,!0,!1),u=s(u,r),n.dispatchEvent(u)):t.createEventObject&&(u=t.createEventObject(),u=s(u,r),n.fireEvent("on"+i,u))}function k(n){return n.month<0&&(n.year-=Math.ceil(Math.abs(n.month)/12),n.month+=12),11<n.month&&(n.year+=Math.floor(Math.abs(n.month)/12),n.month-=12),n}function d(n,t,i){for(t+=n.firstDay;7<=t;)t-=7;return i?n.i18n.weekdaysShort[t]:n.i18n.weekdays[t]}function nt(n){var t=[],i="false";if(n.isEmpty){if(!n.showDaysInNextAndPreviousMonths)return'<td class="is-empty"><\/td>';t.push("is-outside-current-month");n.enableSelectionDaysInNextAndPreviousMonths||t.push("is-selection-disabled")}return n.isDisabled&&t.push("is-disabled"),n.isToday&&t.push("is-today"),n.isSelected&&(t.push("is-selected"),i="true"),n.hasEvent&&t.push("has-event"),n.isInRange&&t.push("is-inrange"),n.isStartRange&&t.push("is-startrange"),n.isEndRange&&t.push("is-endrange"),'<td data-day="'+n.day+'" class="'+t.join(" ")+'" aria-selected="'+i+'"><button class="pika-button pika-day" type="button" data-pika-year="'+n.year+'" data-pika-month="'+n.month+'" data-pika-day="'+n.day+'">'+n.day+"<\/button><\/td>"}function tt(n,t){function r(n){return(n+7-1)%7}var i,e;n.setHours(0,0,0,0);var o=n.getDate(),s=n.getDay(),u=t,f=u-1;return n.setDate(o+f-r(s)),i=new Date(n.getFullYear(),0,u),e=(n.getTime()-i.getTime())/864e5,1+Math.round((e-f+r(i.getDay()))/7)}function it(n,t,i,r,u,f){for(var a,c,l,e=n._o,y=i===e.minYear,p=i===e.maxYear,h='<div id="'+f+'" class="pika-title" role="heading" aria-live="assertive">',w=!0,b=!0,s=[],o=0;o<12;o++)s.push('<option value="'+(i===u?o-t:12+o-t)+'"'+(o===r?' selected="selected"':"")+(y&&o<e.minMonth||p&&o>e.maxMonth?' disabled="disabled"':"")+">"+e.i18n.months[o]+"<\/option>");for(c='<div class="pika-label">'+e.i18n.months[r]+'<select class="pika-select pika-select-month" tabindex="-1">'+s.join("")+"<\/select><\/div>",a=v(e.yearRange)?(o=e.yearRange[0],e.yearRange[1]+1):(o=i-e.yearRange,1+i+e.yearRange),s=[];o<a&&o<=e.maxYear;o++)o>=e.minYear&&s.push('<option value="'+o+'"'+(o===i?' selected="selected"':"")+">"+o+"<\/option>");return l='<div class="pika-label">'+i+e.yearSuffix+'<select class="pika-select pika-select-year" tabindex="-1">'+s.join("")+"<\/select><\/div>",h+=e.showMonthAfterYear?l+c:c+l,y&&(0===r||e.minMonth>=r)&&(w=!1),p&&(11===r||e.maxMonth<=r)&&(b=!1),0===t&&(h+='<button class="pika-prev'+(w?"":" is-disabled")+'" type="button">'+e.i18n.previousMonth+"<\/button>"),t===n._o.numberOfMonths-1&&(h+='<button class="pika-next'+(b?"":" is-disabled")+'" type="button">'+e.i18n.nextMonth+"<\/button>"),h+"<\/div>"}function rt(n,t,i){return'<table cellpadding="0" cellspacing="0" class="pika-table" role="grid" aria-labelledby="'+i+'">'+function(n){var t,i=[];for(n.showWeekNumber&&i.push("<th><\/th>"),t=0;t<7;t++)i.push('<th scope="col"><abbr title="'+d(n,t)+'">'+d(n,t,!0)+"<\/abbr><\/th>");return"<thead><tr>"+(n.isRTL?i.reverse():i).join("")+"<\/tr><\/thead>"}(n)+("<tbody>"+t.join("")+"<\/tbody>")+"<\/table>"}function g(f){var e=this,s=e.config(f),h;e._onMouseDown=function(n){if(e._v){var t=(n=n||window.event).target||n.srcElement;if(t)if(i(t,"is-disabled")||(!i(t,"pika-button")||i(t,"is-empty")||i(t.parentNode,"is-disabled")?i(t,"pika-prev")?e.prevMonth():i(t,"pika-next")&&e.nextMonth():(e.setDate(new Date(t.getAttribute("data-pika-year"),t.getAttribute("data-pika-month"),t.getAttribute("data-pika-day"))),s.bound&&p(function(){e.hide();s.blurFieldOnSelect&&s.field&&s.field.blur()},100))),i(t,"pika-select"))e._c=!0;else{if(!n.preventDefault)return n.returnValue=!1;n.preventDefault()}}};e._onChange=function(n){var t=(n=n||window.event).target||n.srcElement;t&&(i(t,"pika-select-month")?e.gotoMonth(t.value):i(t,"pika-select-year")&&e.gotoYear(t.value))};e._onKeyChange=function(n){if(n=n||window.event,e.isVisible())switch(n.keyCode){case 13:case 27:s.field&&s.field.blur();break;case 37:e.adjustDate("subtract",1);break;case 38:e.adjustDate("subtract",7);break;case 39:e.adjustDate("add",1);break;case 40:e.adjustDate("add",7);break;case 8:case 46:e.setDate(null)}};e._parseFieldValue=function(){if(s.parse)return s.parse(s.field.value,s.format);if(o){var t=n(s.field.value,s.format,s.formatStrict);return t&&t.isValid()?t.toDate():null}return new Date(Date.parse(s.field.value))};e._onInputChange=function(n){var t;n.firedBy!==e&&(t=e._parseFieldValue(),r(t)&&e.setDate(t),e._v||e.show())};e._onInputFocus=function(){e.show()};e._onInputClick=function(){e.show()};e._onInputBlur=function(){var n=t.activeElement;do if(i(n,"pika-single"))return;while(n=n.parentNode);e._c||(e._b=p(function(){e.hide()},50));e._c=!1};e._onClick=function(n){var t=(n=n||window.event).target||n.srcElement,r=t;if(t){!y&&i(t,"pika-select")&&(t.onchange||(t.setAttribute("onchange","return;"),u(t,"change",e._onChange)));do if(i(r,"pika-single")||r===s.trigger)return;while(r=r.parentNode);e._v&&t!==s.trigger&&r!==s.trigger&&e.hide()}};e.el=t.createElement("div");e.el.className="pika-single"+(s.isRTL?" is-rtl":"")+(s.theme?" "+s.theme:"");u(e.el,"mousedown",e._onMouseDown,!0);u(e.el,"touchend",e._onMouseDown,!0);u(e.el,"change",e._onChange);s.keyboardInput&&u(t,"keydown",e._onKeyChange);s.field&&(s.container?s.container.appendChild(e.el):s.bound?t.body.appendChild(e.el):s.field.parentNode.insertBefore(e.el,s.field.nextSibling),u(s.field,"change",e._onInputChange),s.defaultDate||(s.defaultDate=e._parseFieldValue(),s.setDefaultDate=!0));h=s.defaultDate;r(h)?s.setDefaultDate?e.setDate(h,!0):e.gotoDate(h):e.gotoDate(new Date);s.bound?(this.hide(),e.el.className+=" is-bound",u(s.trigger,"click",e._onInputClick),u(s.trigger,"focus",e._onInputFocus),u(s.trigger,"blur",e._onInputBlur)):this.show()}var o="function"==typeof n,y=!!window.addEventListener,t=window.document,p=window.setTimeout,s=function(n,t,i){var u,f;for(u in t)(f=void 0!==n[u])&&"object"==typeof t[u]&&null!==t[u]&&void 0===t[u].nodeName?r(t[u])?i&&(n[u]=new Date(t[u].getTime())):v(t[u])?i&&(n[u]=t[u].slice(0)):n[u]=s({},t[u],i):!i&&f||(n[u]=t[u]);return n},f={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,firstWeekOfYearMinDays:4,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"],weekdays:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],weekdaysShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]},theme:null,events:[],onSelect:null,onOpen:null,onClose:null,onDraw:null,keyboardInput:!0};return g.prototype={config:function(n){var t,i,u;return this._o||(this._o=s({},f,!0)),t=s(this._o,n,!0),t.isRTL=!!t.isRTL,t.field=t.field&&t.field.nodeName?t.field:null,t.theme="string"==typeof t.theme&&t.theme?t.theme:null,t.bound=!!(void 0!==t.bound?t.field&&t.bound:t.field),t.trigger=t.trigger&&t.trigger.nodeName?t.trigger:t.field,t.disableWeekends=!!t.disableWeekends,t.disableDayFn="function"==typeof t.disableDayFn?t.disableDayFn:null,u=parseInt(t.numberOfMonths,10)||1,t.numberOfMonths=4<u?4:u,r(t.minDate)||(t.minDate=!1),r(t.maxDate)||(t.maxDate=!1),t.minDate&&t.maxDate&&t.maxDate<t.minDate&&(t.maxDate=t.minDate=!1),t.minDate&&this.setMinDate(t.minDate),t.maxDate&&this.setMaxDate(t.maxDate),v(t.yearRange)?(i=(new Date).getFullYear()-10,t.yearRange[0]=parseInt(t.yearRange[0],10)||i,t.yearRange[1]=parseInt(t.yearRange[1],10)||i):(t.yearRange=Math.abs(parseInt(t.yearRange,10))||f.yearRange,100<t.yearRange&&(t.yearRange=100)),t},toString:function(t){return t=t||this._o.format,r(this._d)?this._o.toString?this._o.toString(this._d,t):o?n(this._d).format(t):this._d.toDateString():""},getMoment:function(){return o?n(this._d):null},setMoment:function(t,i){o&&n.isMoment(t)&&this.setDate(t.toDate(),i)},getDate:function(){return r(this._d)?new Date(this._d.getTime()):null},setDate:function(n,t){if(!n)return this._d=null,this._o.field&&(this._o.field.value="",b(this._o.field,"change",{firedBy:this})),this.draw();var i,u;"string"==typeof n&&(n=new Date(Date.parse(n)));r(n)&&(i=this._o.minDate,u=this._o.maxDate,r(i)&&n<i?n=i:r(u)&&u<n&&(n=u),this._d=new Date(n.getTime()),h(this._d),this.gotoDate(this._d),this._o.field&&(this._o.field.value=this.toString(),b(this._o.field,"change",{firedBy:this})),t||"function"!=typeof this._o.onSelect||this._o.onSelect.call(this,this.getDate()))},clear:function(){this.setDate(null)},gotoDate:function(n){var u,t,i,f=!0;r(n)&&(this.calendars&&(u=new Date(this.calendars[0].year,this.calendars[0].month,1),t=new Date(this.calendars[this.calendars.length-1].year,this.calendars[this.calendars.length-1].month,1),i=n.getTime(),t.setMonth(t.getMonth()+1),t.setDate(t.getDate()-1),f=i<u.getTime()||t.getTime()<i),f&&(this.calendars=[{month:n.getMonth(),year:n.getFullYear()}],"right"===this._o.mainCalendar&&(this.calendars[0].month+=1-this._o.numberOfMonths)),this.adjustCalendars())},adjustDate:function(n,t){var i,r=this.getDate()||new Date,u=864e5*parseInt(t);"add"===n?i=new Date(r.valueOf()+u):"subtract"===n&&(i=new Date(r.valueOf()-u));this.setDate(i)},adjustCalendars:function(){this.calendars[0]=k(this.calendars[0]);for(var n=1;n<this._o.numberOfMonths;n++)this.calendars[n]=k({month:this.calendars[0].month+n,year:this.calendars[0].year});this.draw()},gotoToday:function(){this.gotoDate(new Date)},gotoMonth:function(n){isNaN(n)||(this.calendars[0].month=parseInt(n,10),this.adjustCalendars())},nextMonth:function(){this.calendars[0].month++;this.adjustCalendars()},prevMonth:function(){this.calendars[0].month--;this.adjustCalendars()},gotoYear:function(n){isNaN(n)||(this.calendars[0].year=parseInt(n,10),this.adjustCalendars())},setMinDate:function(n){n instanceof Date?(h(n),this._o.minDate=n,this._o.minYear=n.getFullYear(),this._o.minMonth=n.getMonth()):(this._o.minDate=f.minDate,this._o.minYear=f.minYear,this._o.minMonth=f.minMonth,this._o.startRange=f.startRange);this.draw()},setMaxDate:function(n){n instanceof Date?(h(n),this._o.maxDate=n,this._o.maxYear=n.getFullYear(),this._o.maxMonth=n.getMonth()):(this._o.maxDate=f.maxDate,this._o.maxYear=f.maxYear,this._o.maxMonth=f.maxMonth,this._o.endRange=f.endRange);this.draw()},setStartRange:function(n){this._o.startRange=n},setEndRange:function(n){this._o.endRange=n},draw:function(n){var i;if(this._v||n){var r,t=this._o,e=t.minYear,o=t.maxYear,u=t.minMonth,f=t.maxMonth,s="";for(this._y<=e&&(this._y=e,!isNaN(u)&&this._m<u&&(this._m=u)),this._y>=o&&(this._y=o,!isNaN(f)&&this._m>f&&(this._m=f)),i=0;i<t.numberOfMonths;i++)r="pika-title-"+Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,2),s+='<div class="pika-lendar">'+it(this,i,this.calendars[i].year,this.calendars[i].month,this.calendars[0].year,r)+this.render(this.calendars[i].year,this.calendars[i].month,r)+"<\/div>";this.el.innerHTML=s;t.bound&&"hidden"!==t.field.type&&p(function(){t.trigger.focus()},1);"function"==typeof this._o.onDraw&&this._o.onDraw(this);t.bound&&t.field.setAttribute("aria-label",t.ariaLabel)}},adjustPosition:function(){var u,n,f,e,h,c,v,i,r,y,o,s;if(!this._o.container){if(this.el.style.position="absolute",n=u=this._o.trigger,f=this.el.offsetWidth,e=this.el.offsetHeight,h=window.innerWidth||t.documentElement.clientWidth,c=window.innerHeight||t.documentElement.clientHeight,v=window.pageYOffset||t.body.scrollTop||t.documentElement.scrollTop,s=o=!0,"function"==typeof u.getBoundingClientRect)i=(y=u.getBoundingClientRect()).left+window.pageXOffset,r=y.bottom+window.pageYOffset;else for(i=n.offsetLeft,r=n.offsetTop+n.offsetHeight;n=n.offsetParent;)i+=n.offsetLeft,r+=n.offsetTop;(this._o.reposition&&h<i+f||-1<this._o.position.indexOf("right")&&0<i-f+u.offsetWidth)&&(i=i-f+u.offsetWidth,o=!1);(this._o.reposition&&c+v<r+e||-1<this._o.position.indexOf("top")&&0<r-e-u.offsetHeight)&&(r=r-e-u.offsetHeight,s=!1);this.el.style.left=i+"px";this.el.style.top=r+"px";l(this.el,o?"left-aligned":"right-aligned");l(this.el,s?"bottom-aligned":"top-aligned");a(this.el,o?"right-aligned":"left-aligned");a(this.el,s?"top-aligned":"bottom-aligned")}},render:function(t,i,u){var f=this._o,ut=new Date,y=w(t,i),s=new Date(t,i,1).getDay(),ft=[],a=[],kt;h(ut);0<f.firstDay&&(s-=f.firstDay)<0&&(s+=7);for(var et=0===i?11:i-1,dt=11===i?0:i+1,ot=0===i?t-1:t,gt=11===i?t+1:t,ni=w(ot,et),p=y+s,b=p;7<b;)b-=7;p+=7-b;for(var k,st,ht,ct,lt,at,d,vt,g=!1,l=0,yt=0;l<p;l++){var e=new Date(t,i,l-s+1),pt=!!r(this._d)&&c(e,this._d),ti=c(e,ut),ii=-1!==f.events.indexOf(e.toDateString()),wt=l<s||y+s<=l,v=l-s+1,it=i,bt=t,ri=f.startRange&&c(f.startRange,e),ui=f.endRange&&c(f.endRange,e),fi=f.startRange&&f.endRange&&f.startRange<e&&e<f.endRange;wt&&(bt=l<s?(v=ni+v,it=et,ot):(v-=y,it=dt,gt));kt={day:v,month:it,year:bt,hasEvent:ii,isSelected:pt,isToday:ti,isDisabled:f.minDate&&e<f.minDate||f.maxDate&&e>f.maxDate||f.disableWeekends&&(0===(vt=e.getDay())||6===vt)||f.disableDayFn&&f.disableDayFn(e),isEmpty:wt,isStartRange:ri,isEndRange:ui,isInRange:fi,showDaysInNextAndPreviousMonths:f.showDaysInNextAndPreviousMonths,enableSelectionDaysInNextAndPreviousMonths:f.enableSelectionDaysInNextAndPreviousMonths};f.pickWholeWeek&&pt&&(g=!0);a.push(nt(kt));7==++yt&&(f.showWeekNumber&&a.unshift((ht=l-s,ct=i,lt=t,at=f.firstWeekOfYearMinDays,d=new Date(lt,ct,ht),'<td class="pika-week">'+(o?n(d).isoWeek():tt(d,at))+"<\/td>")),ft.push((k=a,st=f.isRTL,'<tr class="pika-row'+(f.pickWholeWeek?" pick-whole-week":"")+(g?" is-selected":"")+'">'+(st?k.reverse():k).join("")+"<\/tr>")),yt=0,g=!(a=[]))}return rt(f,ft,u)},isVisible:function(){return this._v},show:function(){this.isVisible()||(this._v=!0,this.draw(),a(this.el,"is-hidden"),this._o.bound&&(u(t,"click",this._onClick),this.adjustPosition()),"function"==typeof this._o.onOpen&&this._o.onOpen.call(this))},hide:function(){var n=this._v;!1!==n&&(this._o.bound&&e(t,"click",this._onClick),this._o.container||(this.el.style.position="static",this.el.style.left="auto",this.el.style.top="auto"),l(this.el,"is-hidden"),this._v=!1,void 0!==n&&"function"==typeof this._o.onClose&&this._o.onClose.call(this))},destroy:function(){var n=this._o;this.hide();e(this.el,"mousedown",this._onMouseDown,!0);e(this.el,"touchend",this._onMouseDown,!0);e(this.el,"change",this._onChange);n.keyboardInput&&e(t,"keydown",this._onKeyChange);n.field&&(e(n.field,"change",this._onInputChange),n.bound&&(e(n.trigger,"click",this._onInputClick),e(n.trigger,"focus",this._onInputFocus),e(n.trigger,"blur",this._onInputBlur)));this.el.parentNode&&this.el.parentNode.removeChild(this.el)}},g})