"use strict";(self.webpackChunkhome_assistant_frontend=self.webpackChunkhome_assistant_frontend||[]).push([["73618"],{62284:function(e,t,s){s.a(e,async function(e,i){try{s.r(t),s.d(t,{HuiEnergyCompareCard:function(){return $}});s(3362),s(62953);var a=s(40445),r=s(6946),o=s(73983),n=s(96196),h=s(77845),c=s(72487),p=s(38114),l=s(54706),d=s(784),_=s(38962),u=s(1087),y=s(14503),g=e([_,c,p]);[_,c,p]=g.then?(await g)():g;let m,C,f,b,v,k,w=e=>e;class $ extends((0,l.E)(n.WF)){static async getConfigElement(){return await s.e("79062").then(s.bind(s,54197)),document.createElement("hui-energy-graph-card-editor")}static getStubConfig(e,t,s){return{type:"energy-compare"}}getCardSize(){return 1}setConfig(e){e.collection_key&&(0,p.s8)(e.collection_key),this._config=e}hassSubscribe(){return[(0,p.tb)(this.hass,{key:this._config.collection_key}).subscribe(e=>this._update(e))]}shouldUpdate(e){return(0,d.xP)(this,e)||e.has("preview")||e.size>1||!e.has("hass")}update(e){super.update(e),e.has("preview")&&this._checkVisibility()}render(){if(this.preview)return(0,n.qy)(m||(m=w` <ha-alert> ${0} </ha-alert> `),this.hass.localize("ui.panel.lovelace.cards.energy.energy_compare.info",{start:(0,n.qy)(C||(C=w`<b>${0}</b>`),(0,c.Yq)(new Date,this.hass.locale,this.hass.config)),end:(0,n.qy)(f||(f=w`<b>${0}</b> <span>(${0})</span>`),(0,c.Yq)(new Date,this.hass.locale,this.hass.config),this.hass.localize("ui.panel.lovelace.cards.energy.energy_compare.compare_preview"))}));if(!this._startCompare||!this._endCompare)return n.s6;const e=(0,r.c)(this._endCompare,this._startCompare);return(0,n.qy)(b||(b=w` <ha-alert dismissable @alert-dismissed-clicked="${0}"> ${0} </ha-alert> `),this._stopCompare,this.hass.localize("ui.panel.lovelace.cards.energy.energy_compare.info",{start:(0,n.qy)(v||(v=w`<b>${0}${0}</b>`),(0,c.Yq)(this._start,this.hass.locale,this.hass.config),e>0?` -\n          ${(0,c.Yq)(this._end||(0,o.D)(new Date),this.hass.locale,this.hass.config)}`:""),end:(0,n.qy)(k||(k=w`<b>${0}${0}</b> <button class="link" @click="${0}"> (${0}) </button>`),(0,c.Yq)(this._startCompare,this.hass.locale,this.hass.config),e>0?` -\n          ${(0,c.Yq)(this._endCompare,this.hass.locale,this.hass.config)}`:"",this._changeCompareMode,this._compareMode===p.lh.PREVIOUS?this.hass.localize("ui.panel.lovelace.cards.energy.energy_compare.compare_previous_year"):this.hass.localize("ui.panel.lovelace.cards.energy.energy_compare.compare_previous_period"))}))}_changeCompareMode(){const e=(0,p.tb)(this.hass,{key:this._config.collection_key});e.setCompare(this._compareMode===p.lh.PREVIOUS?p.lh.YOY:p.lh.PREVIOUS),e.refresh()}_update(e){this._start=e.start,this._end=e.end,this._startCompare=e.startCompare,this._endCompare=e.endCompare,this._compareMode=e.compareMode,this._checkVisibility()}_checkVisibility(){const e=this.hidden;this.hidden=!this._startCompare&&!this.preview,e!==this.hidden&&(0,u.r)(this,"card-visibility-changed")}_stopCompare(){const e=(0,p.tb)(this.hass,{key:this._config.collection_key});e.setCompare(p.lh.NONE),e.refresh()}constructor(...e){super(...e),this.hidden=!0,this.preview=!1,this.connectedWhileHidden=!0,this.hassSubscribeRequiredHostProps=["_config"]}}$.styles=[y.og],(0,a.Cg)([(0,h.MZ)({attribute:!1})],$.prototype,"hass",void 0),(0,a.Cg)([(0,h.wk)()],$.prototype,"_config",void 0),(0,a.Cg)([(0,h.wk)()],$.prototype,"_start",void 0),(0,a.Cg)([(0,h.wk)()],$.prototype,"_end",void 0),(0,a.Cg)([(0,h.wk)()],$.prototype,"_startCompare",void 0),(0,a.Cg)([(0,h.wk)()],$.prototype,"_endCompare",void 0),(0,a.Cg)([(0,h.wk)()],$.prototype,"_compareMode",void 0),(0,a.Cg)([(0,h.MZ)({type:Boolean,reflect:!0})],$.prototype,"hidden",void 0),(0,a.Cg)([(0,h.MZ)({attribute:!1})],$.prototype,"preview",void 0),$=(0,a.Cg)([(0,h.EM)("hui-energy-compare-card")],$),i()}catch(m){i(m)}})},56434:function(e,t,s){s.d(t,{e:function(){return a}});var i=s(81977);function a(e,t,s){return(0,i.P)(e,12*t,s)}}}]);
//# sourceMappingURL=73618.bd0e269115741e10.js.map