"use strict";(self.webpackChunkhome_assistant_frontend=self.webpackChunkhome_assistant_frontend||[]).push([["87980"],{24519:function(a,e,o){o.a(a,async function(a,i){try{o.r(e),o.d(e,{HuiSaveConfig:function(){return w}});o(3362);var t=o(40445),s=o(96196),l=o(77845),h=o(1087),n=o(18350),c=o(72554),r=(o(93444),o(6),o(26300)),p=(o(59646),o(10763)),g=o(14503),d=o(36918),f=o(93275),_=a([n,c,r,p]);[n,c,r,p]=_.then?(await _)():_;let v,u,m,y,C,$,b=a=>a;const A="M11,18H13V16H11V18M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2M12,20C7.59,20 4,16.41 4,12C4,7.59 7.59,4 12,4C16.41,4 20,7.59 20,12C20,16.41 16.41,20 12,20M12,6A4,4 0 0,0 8,10H10A2,2 0 0,1 12,8A2,2 0 0,1 14,10C14,12 11,11.75 11,15H13C13,12.75 16,12.5 16,10A4,4 0 0,0 12,6Z",k={views:[{title:"Home"}]};class w extends s.WF{showDialog(a){this._params=a,this._emptyConfig=!1,this._open=!0}closeDialog(){return this._open=!1,!0}_dialogClosed(){this._params=void 0,(0,h.r)(this,"dialog-closed",{dialog:this.localName})}render(){if(!this._params)return s.s6;const a=this.hass.localize("ui.panel.lovelace.editor.save_config.header");return(0,s.qy)(v||(v=b` <ha-dialog .hass="${0}" .open="${0}" header-title="${0}" prevent-scrim-close @closed="${0}"> <ha-icon-button .path="${0}" .label="${0}" .href="${0}" title="${0}" target="_blank" rel="noreferrer" slot="headerActionItems"></ha-icon-button>  <div> <p> ${0} </p> ${0} </div> ${0} </ha-dialog> `),this.hass,this._open,a,this._dialogClosed,A,this.hass.localize("ui.common.help"),(0,d.o)(this.hass,"/lovelace/"),this.hass.localize("ui.panel.lovelace.menu.help"),this.hass.localize("ui.panel.lovelace.editor.save_config.para"),"storage"===this._params.mode?(0,s.qy)(u||(u=b` <p> ${0} </p> <ha-formfield .label="${0}"> <ha-switch .checked="${0}" @change="${0}" autofocus></ha-switch></ha-formfield> `),this.hass.localize("ui.panel.lovelace.editor.save_config.para_sure"),this.hass.localize("ui.panel.lovelace.editor.save_config.empty_config"),this._emptyConfig,this._emptyConfigChanged):(0,s.qy)(m||(m=b` <p> ${0} </p> <p> ${0} </p> <p> ${0} </p> <ha-yaml-editor .hass="${0}" .defaultValue="${0}" autofocus></ha-yaml-editor> `),this.hass.localize("ui.panel.lovelace.editor.save_config.yaml_mode"),this.hass.localize("ui.panel.lovelace.editor.save_config.yaml_control"),this.hass.localize("ui.panel.lovelace.editor.save_config.yaml_config"),this.hass,this._params.lovelace.config),"storage"===this._params.mode?(0,s.qy)(y||(y=b` <ha-dialog-footer slot="footer"> <ha-button slot="secondaryAction" appearance="plain" @click="${0}"> ${0} </ha-button> <ha-button slot="primaryAction" @click="${0}" .loading="${0}"> ${0} </ha-button> </ha-dialog-footer> `),this.closeDialog,this.hass.localize("ui.common.cancel"),this._saveConfig,this._saving,this.hass.localize("ui.panel.lovelace.editor.save_config.save")):(0,s.qy)(C||(C=b` <ha-dialog-footer slot="footer"> <ha-button slot="primaryAction" @click="${0}"> ${0} </ha-button> </ha-dialog-footer> `),this.closeDialog,this.hass.localize("ui.panel.lovelace.editor.save_config.close")))}_emptyConfigChanged(a){this._emptyConfig=a.target.checked}async _saveConfig(){if(this.hass&&this._params){this._saving=!0;try{const a=this._params.lovelace;await a.saveConfig(this._emptyConfig?k:await(0,f.d4)(a.config,this.hass)),a.setEditMode(!0),this._saving=!1,this.closeDialog()}catch(a){alert(`Saving failed: ${a.message}`),this._saving=!1}}}static get styles(){return[g.nA,(0,s.AH)($||($=b`ha-dialog{--dialog-content-padding:0 24px 24px 24px}ha-dialog ha-icon-button[slot=headerActionItems]{color:var(--secondary-text-color)}`))]}constructor(){super(),this._emptyConfig=!1,this._open=!1,this._saving=!1}}(0,t.Cg)([(0,l.MZ)({attribute:!1})],w.prototype,"hass",void 0),(0,t.Cg)([(0,l.wk)()],w.prototype,"_params",void 0),(0,t.Cg)([(0,l.wk)()],w.prototype,"_emptyConfig",void 0),(0,t.Cg)([(0,l.wk)()],w.prototype,"_saving",void 0),(0,t.Cg)([(0,l.wk)()],w.prototype,"_open",void 0),w=(0,t.Cg)([(0,l.EM)("hui-dialog-save-config")],w),i()}catch(v){i(v)}})}}]);
//# sourceMappingURL=87980.be88bb0b9aba180b.js.map