/*!
* AngularJS Material Design
* https://github.com/angular/material
* @license MIT
* v1.1.8-master-aba7b2b
*/
!function(e,t,a){"use strict";t.module("material.components.datepicker",["material.core","material.components.icon","material.components.virtualRepeat"]),function(){function e(){return{template:function(e,t){var a=t.hasOwnProperty("ngIf")?"":'ng-if="calendarCtrl.isInitialized"',n='
';return n},scope:{minDate:"=mdMinDate",maxDate:"=mdMaxDate",dateFilter:"=mdDateFilter",_mode:"@mdMode",_currentView:"@mdCurrentView"},require:["ngModel","mdCalendar"],controller:a,controllerAs:"calendarCtrl",bindToController:!0,link:function(e,t,a,n){var i=n[0],r=n[1];r.configureNgModel(i)}}}function a(e,a,n,r,l,s,d,o,c){s(e),this.$element=e,this.$scope=a,this.dateUtil=n,this.$mdUtil=r,this.keyCode=l.KEY_CODE,this.$$rAF=d,this.$mdDateLocale=c,this.today=this.dateUtil.createDateAtMidnight(),this.ngModelCtrl=null,this.SELECTED_DATE_CLASS="md-calendar-selected-date",this.TODAY_CLASS="md-calendar-date-today",this.FOCUSED_DATE_CLASS="md-focus",this.id=i++,this.displayDate=null,this.selectedDate=null,this.firstRenderableDate=null,this.lastRenderableDate=null,this.isInitialized=!1,this.width=0,this.scrollbarWidth=0,o.tabindex||e.attr("tabindex","-1");var h,u=t.bind(this,this.handleKeyEvent);h=e.parent().hasClass("md-datepicker-calendar")?t.element(document.body):e,h.on("keydown",u),a.$on("$destroy",function(){h.off("keydown",u)}),1===t.version.major&&t.version.minor<=4&&this.$onInit()}a.$inject=["$element","$scope","$$mdDateUtil","$mdUtil","$mdConstant","$mdTheming","$$rAF","$attrs","$mdDateLocale"],t.module("material.components.datepicker").directive("mdCalendar",e);var n=340,i=0,r={day:"month",month:"year"};a.prototype.$onInit=function(){this._mode&&r.hasOwnProperty(this._mode)?(this.currentView=r[this._mode],this.mode=this._mode):(this.currentView=this._currentView||"month",this.mode=null);var e=this.$mdDateLocale;this.minDate&&this.minDate>e.firstRenderableDate?this.firstRenderableDate=this.minDate:this.firstRenderableDate=e.firstRenderableDate,this.maxDate&&this.maxDate0?t():a.$$rAF(function(){var n=e.calendarScroller;a.scrollbarWidth=n.offsetWidth-n.clientWidth,a.width=i.querySelector("table").offsetWidth,t()})},a.prototype.getDateId=function(e,t){if(!t)throw new Error("A namespace for the date id has to be specified.");return["md",this.id,t,e.getFullYear(),e.getMonth(),e.getDate()].join("-")},a.prototype.updateVirtualRepeat=function(){var e=this.$scope,t=e.$on("$md-resize-enable",function(){e.$$phase||e.$apply(),t()})}}(),function(){function e(){return{template:'
").append(f)),u.setHasPlaceholder(l.mdPlaceholder),u.input=n,u.element.addClass(s).toggleClass(d,"calendar"!==l.mdHideIcons&&"all"!==l.mdHideIcons),u.label?p||l.$observe("required",function(e){u.label.toggleClass("md-required",!!e)}):i.expect(n,"aria-label",l.mdPlaceholder),e.$watch(u.isErrorGetter||function(){return c.$invalid&&(c.$touched||m&&m.$submitted)},u.setInvalid)}else if(m)var g=e.$watch(function(){return m.$submitted},function(e){e&&(h.updateErrorState(),g())})}}}function n(a,n,i,r,l,s,d,o,c,h,u){this.$window=r,this.dateUtil=c,this.$mdConstant=l,this.$mdUtil=d,this.$$rAF=h,this.$mdDateLocale=o,this.documentElement=t.element(document.documentElement),this.ngModelCtrl=null,this.inputElement=n[0].querySelector("input"),this.ngInputElement=t.element(this.inputElement),this.inputContainer=n[0].querySelector(".md-datepicker-input-container"),this.calendarPane=n[0].querySelector(".md-datepicker-calendar-pane"),this.calendarButton=n[0].querySelector(".md-datepicker-button"),this.inputMask=t.element(n[0].querySelector(".md-datepicker-input-mask-opaque")),this.$element=n,this.$attrs=i,this.$scope=a,this.date=null,this.isFocused=!1,this.isDisabled,this.setDisabled(n[0].disabled||t.isString(i.disabled)),this.isCalendarOpen=!1,this.openOnFocus=i.hasOwnProperty("mdOpenOnFocus"),this.mdInputContainer=null,this.calendarPaneOpenedFrom=null,this.calendarPaneId="md-date-pane-"+d.nextUid(),this.bodyClickHandler=t.bind(this,this.handleBodyClick),this.windowEventName=m.test(navigator.userAgent||navigator.vendor||e.opera)?"orientationchange":"resize",this.windowEventHandler=d.debounce(t.bind(this,this.closeCalendarPane),100),this.windowBlurHandler=t.bind(this,this.handleWindowBlur),this.ngDateFilter=u("date"),this.leftMargin=20,this.topMargin=null,i.tabindex?(this.ngInputElement.attr("tabindex",i.tabindex),i.$set("tabindex",null)):i.$set("tabindex","-1"),i.$set("aria-owns",this.calendarPaneId),s(n),s(t.element(this.calendarPane));var p=this;a.$on("$destroy",function(){p.detachCalendarPane()}),i.mdIsOpen&&a.$watch("ctrl.isOpen",function(e){e?p.openCalendarPane({target:p.inputElement}):p.closeCalendarPane()}),1===t.version.major&&t.version.minor<=4&&this.$onInit()}n.$inject=["$scope","$element","$attrs","$window","$mdConstant","$mdTheming","$mdUtil","$mdDateLocale","$$mdDateUtil","$$rAF","$filter"],a.$inject=["$$mdSvgRegistry","$mdUtil","$mdAria","inputDirective"],t.module("material.components.datepicker").directive("mdDatepicker",a);var i=3,r="md-datepicker-invalid",l="md-datepicker-open",s="_md-datepicker-floating-label",d="_md-datepicker-has-calendar-icon",o="_md-datepicker-has-triangle-icon",c=500,h=368,u=360,m=/ipad|iphone|ipod|android/i;n.prototype.$onInit=function(){this.locale=this.dateLocale?t.extend({},this.$mdDateLocale,this.dateLocale):this.$mdDateLocale,this.installPropertyInterceptors(),this.attachChangeListeners(),this.attachInteractionListeners()},n.prototype.configureNgModel=function(e,a,n){this.ngModelCtrl=e,this.mdInputContainer=a,this.$attrs.$set("type","date"),n[0].link.pre(this.$scope,{on:t.noop,val:t.noop,0:{}},this.$attrs,[e]);var i=this;i.ngModelCtrl.$formatters.push(function(e){var a=t.isDefined(e)?e:null;if(!(e instanceof Date)&&(a=Date.parse(e),!isNaN(a)&&t.isNumber(a)&&(e=new Date(a)),e&&!(e instanceof Date)))throw Error("The ng-model for md-datepicker must be a Date instance or a value that can be parsed into a date. Currently the model is of type: "+typeof e);return i.onExternalChange(e),e}),e.$viewChangeListeners.unshift(t.bind(this,this.updateErrorState));var r=i.$mdUtil.getModelOption(e,"updateOn");r&&this.ngInputElement.on(r,t.bind(this.$element,this.$element.triggerHandler,r))},n.prototype.attachChangeListeners=function(){var e=this;e.$scope.$on("md-calendar-change",function(t,a){e.setModelValue(a),e.onExternalChange(a),e.closeCalendarPane()}),e.ngInputElement.on("input",t.bind(e,e.resizeInputElement));var a=t.isDefined(this.debounceInterval)?this.debounceInterval:c;e.ngInputElement.on("input",e.$mdUtil.debounce(e.handleInputEvent,a,e))},n.prototype.attachInteractionListeners=function(){var e=this,a=this.$scope,n=this.$mdConstant.KEY_CODE;e.ngInputElement.on("keydown",function(t){t.altKey&&t.keyCode==n.DOWN_ARROW&&(e.openCalendarPane(t),a.$digest())}),e.openOnFocus&&(e.ngInputElement.on("focus",t.bind(e,e.openCalendarPane)),t.element(e.$window).on("blur",e.windowBlurHandler),a.$on("$destroy",function(){t.element(e.$window).off("blur",e.windowBlurHandler)})),a.$on("md-calendar-close",function(){e.closeCalendarPane()})},n.prototype.installPropertyInterceptors=function(){var e=this;if(this.$attrs.ngDisabled){var t=this.$scope.$parent;t&&t.$watch(this.$attrs.ngDisabled,function(t){e.setDisabled(t)})}Object.defineProperty(this,"placeholder",{get:function(){return e.inputElement.placeholder},set:function(t){e.inputElement.placeholder=t||""}})},n.prototype.setDisabled=function(e){this.isDisabled=e,this.inputElement.disabled=e,this.calendarButton&&(this.calendarButton.disabled=e)},n.prototype.updateErrorState=function(e){var a=e||this.date;if(this.clearErrorState(),this.dateUtil.isValidDate(a)){if(a=this.dateUtil.createDateAtMidnight(a),this.dateUtil.isValidDate(this.minDate)){var n=this.dateUtil.createDateAtMidnight(this.minDate);this.ngModelCtrl.$setValidity("mindate",a>=n)}if(this.dateUtil.isValidDate(this.maxDate)){var i=this.dateUtil.createDateAtMidnight(this.maxDate);this.ngModelCtrl.$setValidity("maxdate",a<=i)}t.isFunction(this.dateFilter)&&this.ngModelCtrl.$setValidity("filtered",this.dateFilter(a))}else this.ngModelCtrl.$setValidity("valid",null==a);t.element(this.inputContainer).toggleClass(r,!this.ngModelCtrl.$valid)},n.prototype.clearErrorState=function(){this.inputContainer.classList.remove(r),["mindate","maxdate","filtered","valid"].forEach(function(e){this.ngModelCtrl.$setValidity(e,!0)},this)},n.prototype.resizeInputElement=function(){this.inputElement.size=this.inputElement.value.length+i},n.prototype.handleInputEvent=function(){var e=this.inputElement.value,t=e?this.locale.parseDate(e):null;this.dateUtil.setDateTimeToMidnight(t);var a=""==e||this.dateUtil.isValidDate(t)&&this.locale.isDateComplete(e)&&this.isDateEnabled(t);a&&(this.setModelValue(t),this.date=t),this.updateErrorState(t)},n.prototype.isDateEnabled=function(e){return this.dateUtil.isDateWithinRange(e,this.minDate,this.maxDate)&&(!t.isFunction(this.dateFilter)||this.dateFilter(e))},n.prototype.attachCalendarPane=function(){var e=this.calendarPane,a=document.body;e.style.transform="",this.$element.addClass(l),this.mdInputContainer&&this.mdInputContainer.element.addClass(l),t.element(a).addClass("md-datepicker-is-showing");var n=this.inputContainer.getBoundingClientRect(),i=a.getBoundingClientRect();(!this.topMargin||this.topMargin<0)&&(this.topMargin=(this.inputMask.parent().prop("clientHeight")-this.ngInputElement.prop("clientHeight"))/2);
var r=n.top-i.top-this.topMargin,s=n.left-i.left-this.leftMargin,d=i.top<0&&0==document.body.scrollTop?-i.top:document.body.scrollTop,o=i.left<0&&0==document.body.scrollLeft?-i.left:document.body.scrollLeft,c=d+this.$window.innerHeight,m=o+this.$window.innerWidth;if(this.inputMask.css({position:"absolute",left:this.leftMargin+"px",top:this.topMargin+"px",width:n.width-1+"px",height:n.height-2+"px"}),s+u>m){if(m-u>0)s=m-u;else{s=o;var p=this.$window.innerWidth/u;e.style.transform="scale("+p+")"}e.classList.add("md-datepicker-pos-adjusted")}r+h>c&&c-h>d&&(r=c-h,e.classList.add("md-datepicker-pos-adjusted")),e.style.left=s+"px",e.style.top=r+"px",document.body.appendChild(e),this.$$rAF(function(){e.classList.add("md-pane-open")})},n.prototype.detachCalendarPane=function(){this.$element.removeClass(l),this.mdInputContainer&&this.mdInputContainer.element.removeClass(l),t.element(document.body).removeClass("md-datepicker-is-showing"),this.calendarPane.classList.remove("md-pane-open"),this.calendarPane.classList.remove("md-datepicker-pos-adjusted"),this.isCalendarOpen&&this.$mdUtil.enableScrolling(),this.calendarPane.parentNode&&this.calendarPane.parentNode.removeChild(this.calendarPane)},n.prototype.openCalendarPane=function(t){if(!this.isCalendarOpen&&!this.isDisabled&&!this.inputFocusedOnWindowBlur){this.isCalendarOpen=this.isOpen=!0,this.calendarPaneOpenedFrom=t.target,this.$mdUtil.disableScrollAround(this.calendarPane),this.attachCalendarPane(),this.focusCalendar(),this.evalAttr("ngFocus");var a=this;this.$mdUtil.nextTick(function(){a.documentElement.on("click touchstart",a.bodyClickHandler)},!1),e.addEventListener(this.windowEventName,this.windowEventHandler)}},n.prototype.closeCalendarPane=function(){function t(){a.isCalendarOpen=a.isOpen=!1}if(this.isCalendarOpen){var a=this;a.detachCalendarPane(),a.ngModelCtrl.$setTouched(),a.evalAttr("ngBlur"),a.documentElement.off("click touchstart",a.bodyClickHandler),e.removeEventListener(a.windowEventName,a.windowEventHandler),a.calendarPaneOpenedFrom.focus(),a.calendarPaneOpenedFrom=null,a.openOnFocus?a.$mdUtil.nextTick(t):t()}},n.prototype.getCalendarCtrl=function(){return t.element(this.calendarPane.querySelector("md-calendar")).controller("mdCalendar")},n.prototype.focusCalendar=function(){var e=this;this.$mdUtil.nextTick(function(){e.getCalendarCtrl().focus()},!1)},n.prototype.setFocused=function(e){e||this.ngModelCtrl.$setTouched(),this.openOnFocus||this.evalAttr(e?"ngFocus":"ngBlur"),this.isFocused=e},n.prototype.handleBodyClick=function(e){if(this.isCalendarOpen){var t=this.$mdUtil.getClosest(e.target,"md-calendar");t||this.closeCalendarPane(),this.$scope.$digest()}},n.prototype.handleWindowBlur=function(){this.inputFocusedOnWindowBlur=document.activeElement===this.inputElement},n.prototype.evalAttr=function(e){this.$attrs[e]&&this.$scope.$parent.$eval(this.$attrs[e])},n.prototype.setModelValue=function(e){var t=this.$mdUtil.getModelOption(this.ngModelCtrl,"timezone");this.ngModelCtrl.$setViewValue(this.ngDateFilter(e,"yyyy-MM-dd",t))},n.prototype.onExternalChange=function(e){var t=this.$mdUtil.getModelOption(this.ngModelCtrl,"timezone");this.date=e,this.inputElement.value=this.locale.formatDate(e,t),this.mdInputContainer&&this.mdInputContainer.setHasValue(!!e),this.resizeInputElement(),this.updateErrorState()}}()}(window,window.angular);