"use strict";(self.webpackChunkhome_assistant_frontend=self.webpackChunkhome_assistant_frontend||[]).push([["20196"],{97999:function(e,t,s){s.a(e,async function(e,o){try{s.r(t),s.d(t,{HuiFanPresetModesCardFeatureEditor:function(){return _}});var i=s(20054),a=(s(18111),s(61701),s(62953),s(40445)),n=s(96196),r=s(77845),l=s(22786),d=s(1087),c=s(52763),u=e([c]);c=(u.then?(await u)():u)[0];const h=["customize_modes"];let m,p=e=>e;class _ extends n.WF{setConfig(e){this._config=e}render(){var e,t;if(!this.hass||!this._config)return n.s6;const s=null!==(e=this.context)&&void 0!==e&&e.entity_id?this.hass.states[null===(t=this.context)||void 0===t?void 0:t.entity_id]:void 0,o=Object.assign(Object.assign({style:"dropdown"},this._config),{},{customize_modes:void 0!==this._config.preset_modes}),i=this._schema(this.hass.localize,this.hass.formatEntityAttributeValue,s,o.customize_modes);return(0,n.qy)(m||(m=p` <ha-form .hass="${0}" .data="${0}" .schema="${0}" .computeLabel="${0}" @value-changed="${0}"></ha-form> `),this.hass,o,i,this._computeLabelCallback,this._valueChanged)}_valueChanged(e){var t,s;const o=e.detail.value,{customize_modes:a}=o,n=(0,i.A)(o,h),r=null!==(t=this.context)&&void 0!==t&&t.entity_id?this.hass.states[null===(s=this.context)||void 0===s?void 0:s.entity_id]:void 0;a&&!n.preset_modes&&(n.preset_modes=(null==r?void 0:r.attributes.preset_modes)||[]),!a&&n.preset_modes&&delete n.preset_modes,(0,d.r)(this,"config-changed",{config:n})}constructor(...e){super(...e),this._schema=(0,l.A)((e,t,s,o)=>{var i;return[{name:"style",selector:{select:{multiple:!1,mode:"list",options:["dropdown","icons"].map(t=>({value:t,label:e(`ui.panel.lovelace.editor.features.types.fan-preset-modes.style_list.${t}`)}))}}},{name:"customize_modes",selector:{boolean:{}}},...o?[{name:"preset_modes",selector:{select:{reorder:!0,multiple:!0,options:(null==s||null===(i=s.attributes.preset_modes)||void 0===i?void 0:i.map(e=>({value:e,label:t(s,"preset_mode",e)})))||[]}}}]:[]]}),this._computeLabelCallback=e=>{switch(e.name){case"style":case"preset_modes":case"customize_modes":return this.hass.localize(`ui.panel.lovelace.editor.features.types.fan-preset-modes.${e.name}`);default:return""}}}}(0,a.Cg)([(0,r.MZ)({attribute:!1})],_.prototype,"hass",void 0),(0,a.Cg)([(0,r.MZ)({attribute:!1})],_.prototype,"context",void 0),(0,a.Cg)([(0,r.wk)()],_.prototype,"_config",void 0),_=(0,a.Cg)([(0,r.EM)("hui-fan-preset-modes-card-feature-editor")],_),o()}catch(h){o(h)}})}}]);
//# sourceMappingURL=20196.a7db026466931719.js.map