export const __rspack_esm_id="67854";export const __rspack_esm_ids=["67854"];export const __webpack_modules__={99389(t,s,a){a.a(t,async function(t,e){try{a.r(s),a.d(s,{HuiEnergyGasGraphCard:()=>S});a(44114),a(18111),a(22489),a(7588),a(18237);var r=a(62826),i=a(73684),o=a(40600),n=a(81859),h=a(96196),c=a(44457),_=a(94333),p=a(22786),d=a(18427),g=a(20058),l=a(44439),u=(a(76776),a(38114)),y=a(23528),m=a(54706),f=a(784),b=a(97372),v=a(40345),C=a(34127),k=t([l,v,C,u,g,b]);[l,v,C,u,g,b]=k.then?(await k)():k;class S extends((0,m.E)(h.WF)){hassSubscribe(){return[(0,u.tb)(this.hass,{key:this._config?.collection_key}).subscribe(t=>this._getStatistics(t))]}getCardSize(){return 3}setConfig(t){this._config=t}shouldUpdate(t){return(0,f.xP)(this,t)||t.size>1||!t.has("hass")}render(){return this.hass&&this._config?h.qy` <ha-card> ${this._config.title?h.qy` <div class="card-header"> <span>${this._config.title}</span> ${this._total?h.qy`<hui-energy-graph-chip .tooltip="${this._formatTotal(this._total)}"> ${(0,g.ZV)(this._total,this.hass.locale)} ${this._unit} </hui-energy-graph-chip>`:h.s6} </div>`:h.s6} <div class="content ${(0,_.H)({"has-header":!!this._config.title})}"> <ha-chart-base .hass="${this.hass}" .data="${this._chartData}" .options="${this._createOptions(this._start,this._end,this.hass.locale,this.hass.config,this._unit,this._compareStart,this._compareEnd)}" chart-type="bar"></ha-chart-base> ${this._chartData.length?"":h.qy`<div class="no-data"> ${(0,i.c)(this._start)?this.hass.localize("ui.panel.lovelace.cards.energy.no_data"):this.hass.localize("ui.panel.lovelace.cards.energy.no_data_period")} </div>`} </div> </ha-card> `:h.s6}async _getStatistics(t){this._start=t.start,this._end=t.end||(0,o.o)(),this._compareStart=t.startCompare,this._compareEnd=t.endCompare;const s=t.prefs.energy_sources.filter(t=>"gas"===t.type);this._unit=t.gasUnit;const a=[],e=getComputedStyle(this);if(t.statsCompare)a.push(...this._processDataSet(t.statsCompare,t.statsMetadata,s,e,!0));else{const t=s[0]?.stat_energy_from??"placeholder";a.push({id:"compare-"+t,type:"bar",stack:"gas",data:[]})}a.push(...this._processDataSet(t.stats,t.statsMetadata,s,e)),(0,b.RR)(a),this._chartData=a,this._total=this._processTotal(t.stats,s)}_processTotal(t,s){return s.reduce((s,a)=>s+(a.stat_energy_from in t?t[a.stat_energy_from].reduce((t,s)=>t+(s.change||0),0):0),0)}_processDataSet(t,s,a,e,r=!1){const i=[],o=(0,b.ok)(this._start,this._compareStart);return a.forEach((a,n)=>{let h=null;const c=[];if(a.stat_energy_from in t){const s=t[a.stat_energy_from];for(const t of s){if(null===t.change||void 0===t.change||0===t.change)continue;if(h===t.start)continue;const s=[t.start,t.change];r&&(s[2]=s[0],s[0]=o(new Date(t.start))),c.push(s),h=t.start}}i.push({type:"bar",cursor:"default",id:r?"compare-"+a.stat_energy_from:a.stat_energy_from,name:(0,y.$O)(this.hass,a.stat_energy_from,s[a.stat_energy_from]),barMaxWidth:50,itemStyle:{borderColor:(0,d.g)(e,this.hass.themes.darkMode,!1,r,"--energy-gas-color",n)},color:(0,d.g)(e,this.hass.themes.darkMode,!0,r,"--energy-gas-color",n),data:c,stack:r?"compare-gas":"gas"})}),i}constructor(...t){super(...t),this._chartData=[],this._start=(0,n.R)(),this._end=(0,o.o)(),this.hassSubscribeRequiredHostProps=["_config"],this._formatTotal=t=>this.hass.localize("ui.panel.lovelace.cards.energy.energy_gas_graph.total_consumed",{num:(0,g.ZV)(t,this.hass.locale),unit:this._unit}),this._createOptions=(0,p.A)((t,s,a,e,r,i,o)=>(0,b.od)(t,s,a,e,r,i,o,this._formatTotal))}}S.styles=h.AH`ha-card{height:100%}.card-header{display:flex;justify-content:space-between;align-items:center;padding-bottom:0}.content{padding:16px}.has-header{padding-top:0}.no-data{position:absolute;height:100%;top:0;left:0;right:0;display:flex;justify-content:center;align-items:center;padding:20%;margin-left:32px;margin-inline-start:32px;margin-inline-end:initial;box-sizing:border-box}`,(0,r.Cg)([(0,c.MZ)({attribute:!1})],S.prototype,"hass",void 0),(0,r.Cg)([(0,c.wk)()],S.prototype,"_config",void 0),(0,r.Cg)([(0,c.wk)()],S.prototype,"_chartData",void 0),(0,r.Cg)([(0,c.wk)()],S.prototype,"_start",void 0),(0,r.Cg)([(0,c.wk)()],S.prototype,"_end",void 0),(0,r.Cg)([(0,c.wk)()],S.prototype,"_compareStart",void 0),(0,r.Cg)([(0,c.wk)()],S.prototype,"_compareEnd",void 0),(0,r.Cg)([(0,c.wk)()],S.prototype,"_unit",void 0),(0,r.Cg)([(0,c.wk)()],S.prototype,"_total",void 0),S=(0,r.Cg)([(0,c.EM)("hui-energy-gas-graph-card")],S),e()}catch(t){e(t)}})}};
//# sourceMappingURL=67854.015001f80f2e478b.js.map