export const __rspack_esm_id="39591";export const __rspack_esm_ids=["39591"];export const __webpack_modules__={5242(e,t,s){s.a(e,async function(e,i){try{s.r(t),s.d(t,{DialogEnergyBatterySettings:()=>w});s(44114),s(18111),s(7588);var o=s(62826),r=s(96196),a=s(97735),n=s(1087),_=s(81423),h=s(18350),c=s(72554),l=(s(93444),s(38114)),g=s(64808),p=s(14503),y=s(66902),u=e([_,h,c,y,l]);[_,h,c,y,l]=u.then?(await u)():u;const d=["energy"];class w extends r.WF{async showDialog(e){this._params=e,this._source=e.source?{...e.source}:(0,l.oU)(),this._powerType=(0,y.S9)(e.source?.power_config,e.source?.stat_rate),this._powerConfig=(0,y.us)(e.source?.power_config,e.source?.stat_rate),this._energy_units=(await(0,g.j4)(this.hass,"energy")).units;const t=[];this._params.battery_sources.forEach(e=>{t.push(e.stat_energy_from),t.push(e.stat_energy_to)}),this._excludeList=t.filter(e=>e!==this._source?.stat_energy_from&&e!==this._source?.stat_energy_to),this._excludeListPower=(0,y.A_)(this._params.battery_sources,this._powerConfig,e.source?.stat_rate),this._open=!0}closeDialog(){return this._open=!1,!0}_dialogClosed(){this._params=void 0,this._source=void 0,this._powerType="none",this._powerConfig={},this._error=void 0,this._excludeList=void 0,this._excludeListPower=void 0,(0,n.r)(this,"dialog-closed",{dialog:this.localName})}render(){return this._params&&this._source?r.qy` <ha-dialog .hass="${this.hass}" .open="${this._open}" header-title="${this.hass.localize("ui.panel.config.energy.battery.dialog.header")}" prevent-scrim-close @closed="${this._dialogClosed}"> ${this._error?r.qy`<p class="error">${this._error}</p>`:r.s6} <ha-statistic-picker .hass="${this.hass}" .helpMissingEntityUrl="${l.X4}" .includeUnitClass="${d}" .value="${this._source.stat_energy_to}" .label="${this.hass.localize("ui.panel.config.energy.battery.dialog.energy_into_battery")}" .excludeStatistics="${[...this._excludeList||[],this._source.stat_energy_from]}" @value-changed="${this._statisticToChanged}" .helper="${this.hass.localize("ui.panel.config.energy.battery.dialog.energy_helper_into",{unit:this._energy_units?.join(", ")||""})}" autofocus></ha-statistic-picker> <ha-statistic-picker .hass="${this.hass}" .helpMissingEntityUrl="${l.X4}" .includeUnitClass="${d}" .value="${this._source.stat_energy_from}" .label="${this.hass.localize("ui.panel.config.energy.battery.dialog.energy_out_of_battery")}" .excludeStatistics="${[...this._excludeList||[],this._source.stat_energy_to]}" @value-changed="${this._statisticFromChanged}" .helper="${this.hass.localize("ui.panel.config.energy.battery.dialog.energy_helper_out",{unit:this._energy_units?.join(", ")||""})}"></ha-statistic-picker> <ha-energy-power-config .hass="${this.hass}" .powerType="${this._powerType}" .powerConfig="${this._powerConfig}" .excludeList="${this._excludeListPower}" .localizeBaseKey="${"ui.panel.config.energy.battery.dialog"}" @power-config-changed="${this._handlePowerConfigChanged}"></ha-energy-power-config> <ha-dialog-footer slot="footer"> <ha-button appearance="plain" @click="${this.closeDialog}" slot="secondaryAction"> ${this.hass.localize("ui.common.cancel")} </ha-button> <ha-button @click="${this._save}" .disabled="${!this._isValid()}" slot="primaryAction"> ${this.hass.localize("ui.common.save")} </ha-button> </ha-dialog-footer> </ha-dialog> `:r.s6}_isValid(){if(!this._source?.stat_energy_from||!this._source?.stat_energy_to)return!1;const e=this.shadowRoot?.querySelector("ha-energy-power-config");return!(e&&!e.isValid())}_statisticToChanged(e){this._source={...this._source,stat_energy_to:e.detail.value}}_statisticFromChanged(e){this._source={...this._source,stat_energy_from:e.detail.value}}_handlePowerConfigChanged(e){this._powerType=e.detail.powerType,this._powerConfig=e.detail.powerConfig}async _save(){try{const e={type:"battery",stat_energy_from:this._source.stat_energy_from,stat_energy_to:this._source.stat_energy_to};"none"!==this._powerType&&(e.power_config={...this._powerConfig}),await this._params.saveCallback(e),this.closeDialog()}catch(e){this._error=e.message}}static get styles(){return[p.RF,p.nA,r.AH`ha-statistic-picker{display:block;margin-bottom:var(--ha-space-4)}ha-statistic-picker:last-of-type{margin-bottom:0}`]}constructor(...e){super(...e),this._open=!1,this._powerType="none",this._powerConfig={}}}(0,o.Cg)([(0,a.MZ)({attribute:!1})],w.prototype,"hass",void 0),(0,o.Cg)([(0,a.wk)()],w.prototype,"_params",void 0),(0,o.Cg)([(0,a.wk)()],w.prototype,"_open",void 0),(0,o.Cg)([(0,a.wk)()],w.prototype,"_source",void 0),(0,o.Cg)([(0,a.wk)()],w.prototype,"_powerType",void 0),(0,o.Cg)([(0,a.wk)()],w.prototype,"_powerConfig",void 0),(0,o.Cg)([(0,a.wk)()],w.prototype,"_energy_units",void 0),(0,o.Cg)([(0,a.wk)()],w.prototype,"_error",void 0),w=(0,o.Cg)([(0,a.EM)("dialog-energy-battery-settings")],w),i()}catch(e){i(e)}})}};
//# sourceMappingURL=39591.900010614b953a36.js.map