<html><head></head><body><dom-module id="ha-panel-history"><template><style include="iron-flex ha-style">.content{padding:0 16px 16px;}vaadin-date-picker{--vaadin-date-picker-clear-icon:{display:none;};margin-bottom:24px;margin-right:16px;max-width:200px;}paper-dropdown-menu{max-width:100px;}paper-item{cursor:pointer;}</style><ha-state-history-data hass="[[hass]]" filter-type="[[_filterType]]" start-time="[[_computeStartTime(_currentDate)]]" end-time="[[endTime]]" data="{{stateHistoryInput}}" is-loading="{{isLoadingData}}"></ha-state-history-data><app-header-layout has-scrolling-region=""><app-header slot="header" fixed=""><app-toolbar><ha-menu-button narrow="[[narrow]]" show-menu="[[showMenu]]"></ha-menu-button><div main-title="">History</div></app-toolbar></app-header><div class="flex content"><div class="flex layout horizontal wrap"><vaadin-date-picker id="picker" value="{{_currentDate}}" label="Showing entries for" disabled="[[isLoadingData]]"></vaadin-date-picker><paper-dropdown-menu label-float="" label="Period" disabled="[[isLoadingData]]"><paper-listbox slot="dropdown-content" selected="{{_periodIndex}}"><paper-item>1 day</paper-item><paper-item>3 days</paper-item><paper-item>1 week</paper-item></paper-listbox></paper-dropdown-menu></div><state-history-charts history-data="[[stateHistoryOutput]]" is-loading-data="[[isLoadingData]]" end-time="[[endTime]]"></state-history-charts></div></app-header-layout></template></dom-module><script>Polymer({is:"ha-panel-history",properties:{hass:{type:Object},narrow:{type:Boolean},showMenu:{type:Boolean,value:!1},stateHistoryInput:{type:Object,value:null,observer:"stateHistoryObserver"},stateHistoryOutput:{type:Object,value:null},_periodIndex:{type:Number,value:0},isLoadingData:{type:Boolean,value:!1},endTime:{type:Object,computed:"_computeEndTime(_currentDate, _periodIndex)"},_currentDate:{type:String,value:function(){var t=new Date;return new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate())).toISOString().split("T")[0]}},_filterType:{type:String,value:"date"}},datepickerFocus:function(){this.datePicker.adjustPosition()},attached:function(){var t=new Date;this.$.picker.set("i18n.parseDate",function(){return t}),this.$.picker.set("i18n.formatDate",function(e){return t=e,window.hassUtil.formatDate(e)})},_computeStartTime:function(t){if(t){var e=t.split("-");return e[1]=parseInt(e[1])-1,new Date(e[0],e[1],e[2])}},_computeEndTime:function(t,e){var n=this._computeStartTime(t),r=new Date(n);return r.setDate(n.getDate()+this._computeFilterDays(e)),r},_computeFilterDays:function(t){switch(t){case 1:return 3;case 2:return 7;default:return 1}},stateHistoryObserver:function(t){this.async(function(){t===this.stateHistoryInput&&(this.stateHistoryOutput=t)}.bind(this),1)}});</script></body></html>