(self.webpackChunkhome_assistant_frontend=self.webpackChunkhome_assistant_frontend||[]).push([["14558"],{34370:function(i,a,e){e(18111),e(7588),i.exports=function i(a){return Object.freeze(a),Object.getOwnPropertyNames(a).forEach(function(e){!a.hasOwnProperty(e)||null===a[e]||"object"!=typeof a[e]&&"function"!=typeof a[e]||Object.isFrozen(a[e])||i(a[e])}),a}},69293:function(i,a,e){"use strict";e.a(i,async function(i,s){try{e.r(a),e.d(a,{HuiDialogSuggestBadge:function(){return x}});e(18111),e(61701),e(3362),e(62953);var t=e(40445),o=e(34370),n=e.n(o),h=e(96196),r=e(77845),l=e(1087),d=e(10763),g=e(18350),c=(e(93444),e(72554)),p=e(14503),u=e(92255),_=e(43908),f=e(82360),v=e(75196),m=i([d,g,c,_]);[d,g,c,_]=m.then?(await m)():m;let y,b,C,w,$,k,z=i=>i;class x extends h.WF{showDialog(i){this._params=i,this._badgeConfig=i.badgeConfig,this._open=!0,Object.isFrozen(this._badgeConfig)||(this._badgeConfig=n()(this._badgeConfig)),this._yamlEditor&&this._yamlEditor.setValue(this._badgeConfig)}closeDialog(){this._open=!1}_dialogClosed(){this._open=!1,this._params=void 0,this._badgeConfig=void 0,(0,l.r)(this,"dialog-closed",{dialog:this.localName})}_renderPreview(){return this._badgeConfig?(0,h.qy)(y||(y=z` <div class="element-preview"> ${0} </div> `),this._badgeConfig.map(i=>(0,h.qy)(b||(b=z` <hui-badge .hass="${0}" .config="${0}" preview></hui-badge> `),this.hass,i))):h.s6}render(){return this._params?(0,h.qy)(C||(C=z` <ha-dialog .hass="${0}" .open="${0}" header-title="${0}" @closed="${0}"> <div> ${0} ${0} </div> <ha-dialog-footer slot="footer"> <ha-button slot="secondaryAction" appearance="plain" @click="${0}" autofocus> ${0} </ha-button> ${0} </ha-dialog-footer> </ha-dialog> `),this.hass,this._open,this.hass.localize("ui.panel.lovelace.editor.suggest_badge.header"),this._dialogClosed,this._renderPreview(),this._params.yaml&&this._badgeConfig?(0,h.qy)(w||(w=z` <div class="editor"> <ha-yaml-editor .hass="${0}" .defaultValue="${0}" in-dialog></ha-yaml-editor> </div> `),this.hass,this._badgeConfig):h.s6,this.closeDialog,this._params.yaml?this.hass.localize("ui.common.close"):this.hass.localize("ui.common.cancel"),this._params.yaml?h.s6:(0,h.qy)($||($=z` <ha-button slot="primaryAction" @click="${0}" .loading="${0}"> ${0} </ha-button> `),this._save,this._saving,this.hass.localize("ui.panel.lovelace.editor.suggest_badge.add"))):h.s6}static get styles(){return[p.nA,(0,h.AH)(k||(k=z`ha-dialog{--dialog-z-index:6}.hidden{display:none}.element-preview{position:relative;display:flex;align-items:flex-start;flex-wrap:wrap;justify-content:center;gap:var(--ha-space-2);margin:0}.editor{padding-top:16px}`))]}_computeNewConfig(i,a){const{viewIndex:e}=(0,v.$P)(a),s=this._badgeConfig;return(0,f.En)(i,[e],s)}async _save(){var i,a,e;if(!(null!==(i=this._params)&&void 0!==i&&i.lovelaceConfig&&null!==(a=this._params)&&void 0!==a&&a.path&&null!==(e=this._params)&&void 0!==e&&e.saveConfig&&this._badgeConfig))return;this._saving=!0;const s=this._computeNewConfig(this._params.lovelaceConfig,this._params.path);await this._params.saveConfig(s),this._saving=!1,(0,u.f)(this,this.hass),this.closeDialog()}constructor(...i){super(...i),this._open=!1,this._saving=!1}}(0,t.Cg)([(0,r.MZ)({attribute:!1})],x.prototype,"hass",void 0),(0,t.Cg)([(0,r.wk)()],x.prototype,"_params",void 0),(0,t.Cg)([(0,r.wk)()],x.prototype,"_open",void 0),(0,t.Cg)([(0,r.wk)()],x.prototype,"_badgeConfig",void 0),(0,t.Cg)([(0,r.wk)()],x.prototype,"_saving",void 0),(0,t.Cg)([(0,r.P)("ha-yaml-editor")],x.prototype,"_yamlEditor",void 0),x=(0,t.Cg)([(0,r.EM)("hui-dialog-suggest-badge")],x),s()}catch(y){s(y)}})},92255:function(i,a,e){"use strict";e.d(a,{f:function(){return t}});var s=e(81619);const t=(i,a)=>(0,s.P)(i,{message:a.localize("ui.common.successfully_saved")})}}]);
//# sourceMappingURL=14558.d3c33261a6d33034.js.map