iobroker.lovelace
Version:
With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI
1 lines • 26.7 kB
JavaScript
export const __rspack_esm_id=95309;export const __rspack_esm_ids=[95309];export const __webpack_modules__={82474(t,e,s){s.a(t,async function(t,e){try{s(18111),s(20116),s(61701);var i=s(62826),a=s(5124),o=s(22441),n=s(22786),h=s(1087),r=s(74705),l=s(78649),d=s(53756),c=s(95350),p=s(24367),u=s(19711),g=(s(75064),s(38508)),m=(s(47680),s(67094),s(74281)),y=t([g,m]);[g,m]=y.then?(await y)():y;const _="M19,13H13V19H11V13H5V11H11V5H13V11H19V13Z",v="M11,13.5V21.5H3V13.5H11M12,2L17.5,11H6.5L12,2M17.5,13C20,13 22,15 22,17.5C22,20 20,22 17.5,22C15,22 13,20 13,17.5C13,15 15,13 17.5,13Z",b="___create-new-entity___";class f extends a.WF{willUpdate(t){this._pendingEntityId&&t.has("hass")&&this.hass.states!==t.get("hass")?.states&&this.hass.states[this._pendingEntityId]&&(this._setValue(this._pendingEntityId),this._pendingEntityId=void 0)}firstUpdated(t){super.firstUpdated(t),this.hass.loadBackendTranslation("title")}_findExtraOption(t){return t?this.extraOptions?.find(e=>e.id===t):void 0}_renderExtraOptionStart(t){const e=t.entity_id?this.hass.states[t.entity_id]:void 0;return e?a.qy` <state-badge slot="start" .stateObj="${e}" .hass="${this.hass}"></state-badge> `:t.icon_path?a.qy` <ha-svg-icon slot="start" .path="${t.icon_path}" style="margin:0 4px"></ha-svg-icon> `:t.icon?a.qy`<ha-icon slot="start" .icon="${t.icon}"></ha-icon>`:a.s6}get _showEntityId(){return this.showEntityId||this.hass.userData?.showEntityIdPicker}_shouldHideClearIcon(){return!!this._findExtraOption(this.value)?.hide_clear}render(){const t=this.placeholder??this.hass.localize("ui.components.entity.entity-picker.placeholder");return a.qy` <ha-generic-picker .hass="${this.hass}" .disabled="${this.disabled}" .autofocus="${this.autofocus}" .allowCustomValue="${this.allowCustomEntity}" .required="${this.required}" .label="${this.label}" .placeholder="${t}" .helper="${this.helper}" .value="${this.addButton?void 0:this.value}" .searchLabel="${this.searchLabel}" .notFoundLabel="${this._notFoundLabel}" .rowRenderer="${this._rowRenderer}" .getItems="${this._getItems}" .getAdditionalItems="${this._getAdditionalItems}" .hideClearIcon="${this.hideClearIcon||this._shouldHideClearIcon()}" .searchFn="${this._searchFn}" .valueRenderer="${this._valueRenderer}" .searchKeys="${d.t}" use-top-label .addButtonLabel="${this.addButton?this.addButtonLabel??this.hass.localize("ui.components.entity.entity-picker.add"):void 0}" .unknownItemText="${this.hass.localize("ui.components.entity.entity-picker.unknown")}" -changed="${this._valueChanged}"> </ha-generic-picker> `}async open(){await this.updateComplete,await(this._picker?.open())}_valueChanged(t){t.stopPropagation();const e=t.detail.value;if(e){if(e.startsWith(b)){const t=e.substring(b.length);return void(0,u.$)(this,{domain:t,dialogClosedCallback:t=>{t.entityId&&(this.hass.states[t.entityId]?this._setValue(t.entityId):this._pendingEntityId=t.entityId)}})}((0,l.n)(e)||this._findExtraOption(e))&&this._setValue(e)}else this._setValue(void 0)}_setValue(t){this.value=t,(0,h.r)(this,"value-changed",{value:t}),(0,h.r)(this,"change")}constructor(...t){super(...t),this.autofocus=!1,this.disabled=!1,this.required=!1,this.showEntityId=!1,this.hideClearIcon=!1,this.addButton=!1,this._valueRenderer=t=>{const e=t||"",s=this._findExtraOption(e);if(s)return a.qy` ${this._renderExtraOptionStart(s)} <span slot="headline">${s.primary}</span> ${s.secondary?a.qy`<span slot="supporting-text">${s.secondary}</span>`:a.s6} `;const i=this.hass.states[e];if(!i)return a.qy` <ha-svg-icon slot="start" .path="${v}" style="margin:0 4px"></ha-svg-icon> <span slot="headline">${e}</span> `;const{primary:o,secondary:n}=(0,r.Bj)(this.hass,i);return a.qy` <state-badge .hass="${this.hass}" .stateObj="${i}" slot="start"></state-badge> <span slot="headline">${o}</span> <span slot="supporting-text">${n}</span> `},this._rowRenderer=(t,e)=>{const s=this._showEntityId;return a.qy` <ha-combo-box-item type="button" compact="compact" .borderTop="${0!==e}"> ${t.icon_path?a.qy` <ha-svg-icon slot="start" style="margin:0 4px" .path="${t.icon_path}"></ha-svg-icon> `:a.qy` <state-badge slot="start" .stateObj="${t.stateObj}" .hass="${this.hass}"></state-badge> `} <span slot="headline">${t.primary}</span> ${t.secondary?a.qy`<span slot="supporting-text">${t.secondary}</span>`:a.s6} ${t.stateObj&&s?a.qy` <span slot="supporting-text" class="code"> ${t.stateObj.entity_id} </span> `:a.s6} ${t.domain_name&&!s?a.qy` <div slot="trailing-supporting-text" class="domain"> ${t.domain_name} </div> `:a.s6} </ha-combo-box-item> `},this._getAdditionalItems=()=>this._getCreateItems(this.hass.localize,this.createDomains),this._getCreateItems=(0,n.A)((t,e)=>e?.length?(this.hass.loadFragmentTranslation("config"),e.map(e=>{const s=t("ui.components.entity.entity-picker.create_helper",{domain:(0,p.z)(e)?t(`ui.panel.config.helpers.types.${e}`)||e:(0,c.p$)(t,e)});return{id:b+e,primary:s,secondary:t("ui.components.entity.entity-picker.new_entity"),icon_path:_}})):[]),this._getEntitiesMemoized=(0,n.A)(d.w),this._getItems=()=>{const t=this._getEntitiesMemoized(this.hass,this.includeDomains,this.excludeDomains,this.entityFilter,this.includeDeviceClasses,this.includeUnitOfMeasurement,this.includeEntities,this.excludeEntities,this.value);if(this.extraOptions?.length){return[...this.extraOptions.map(t=>({...t,stateObj:t.entity_id?this.hass.states[t.entity_id]:void 0})),...t]}return t},this._searchFn=(t,e)=>{const s=e.findIndex(e=>e.stateObj?.entity_id===t);if(-1===s)return e;const[i]=e.splice(s,1);return e.unshift(i),e},this._notFoundLabel=t=>this.hass.localize("ui.components.entity.entity-picker.no_match",{term:a.qy`<b>‘${t}’</b>`})}}(0,i.Cg)([(0,o.MZ)({attribute:!1})],f.prototype,"hass",void 0),(0,i.Cg)([(0,o.MZ)({type:Boolean})],f.prototype,"autofocus",void 0),(0,i.Cg)([(0,o.MZ)({type:Boolean})],f.prototype,"disabled",void 0),(0,i.Cg)([(0,o.MZ)({type:Boolean})],f.prototype,"required",void 0),(0,i.Cg)([(0,o.MZ)({type:Boolean,attribute:"allow-custom-entity"})],f.prototype,"allowCustomEntity",void 0),(0,i.Cg)([(0,o.MZ)({type:Boolean,attribute:"show-entity-id"})],f.prototype,"showEntityId",void 0),(0,i.Cg)([(0,o.MZ)()],f.prototype,"label",void 0),(0,i.Cg)([(0,o.MZ)()],f.prototype,"value",void 0),(0,i.Cg)([(0,o.MZ)()],f.prototype,"helper",void 0),(0,i.Cg)([(0,o.MZ)()],f.prototype,"placeholder",void 0),(0,i.Cg)([(0,o.MZ)({type:String,attribute:"search-label"})],f.prototype,"searchLabel",void 0),(0,i.Cg)([(0,o.MZ)({attribute:!1})],f.prototype,"createDomains",void 0),(0,i.Cg)([(0,o.MZ)({type:Array,attribute:"include-domains"})],f.prototype,"includeDomains",void 0),(0,i.Cg)([(0,o.MZ)({type:Array,attribute:"exclude-domains"})],f.prototype,"excludeDomains",void 0),(0,i.Cg)([(0,o.MZ)({type:Array,attribute:"include-device-classes"})],f.prototype,"includeDeviceClasses",void 0),(0,i.Cg)([(0,o.MZ)({type:Array,attribute:"include-unit-of-measurement"})],f.prototype,"includeUnitOfMeasurement",void 0),(0,i.Cg)([(0,o.MZ)({type:Array,attribute:"include-entities"})],f.prototype,"includeEntities",void 0),(0,i.Cg)([(0,o.MZ)({type:Array,attribute:"exclude-entities"})],f.prototype,"excludeEntities",void 0),(0,i.Cg)([(0,o.MZ)({attribute:!1})],f.prototype,"entityFilter",void 0),(0,i.Cg)([(0,o.MZ)({attribute:!1})],f.prototype,"extraOptions",void 0),(0,i.Cg)([(0,o.MZ)({attribute:"hide-clear-icon",type:Boolean})],f.prototype,"hideClearIcon",void 0),(0,i.Cg)([(0,o.MZ)({attribute:"add-button",type:Boolean})],f.prototype,"addButton",void 0),(0,i.Cg)([(0,o.MZ)({attribute:"add-button-label"})],f.prototype,"addButtonLabel",void 0),(0,i.Cg)([(0,o.P)("ha-generic-picker")],f.prototype,"_picker",void 0),(0,i.Cg)([(0,o.wk)()],f.prototype,"_pendingEntityId",void 0),f=(0,i.Cg)([(0,o.EM)("ha-entity-picker")],f),e()}catch(t){e(t)}})},53756(t,e,s){s.d(e,{t:()=>r,w:()=>l});s(74423),s(18111),s(22489),s(61701);var i=s(71727),a=s(74705),o=s(28978),n=s(15638),h=s(95350);const r=[{name:"search_labels.entityName",weight:10},{name:"search_labels.friendlyName",weight:8},{name:"search_labels.deviceName",weight:7},{name:"search_labels.areaName",weight:6},{name:"search_labels.domainName",weight:6},{name:"search_labels.entityId",weight:3}],l=(t,e,s,r,l,d,c,p,u,g="")=>{let m,y=Object.keys(t.states);return c&&(y=y.filter(t=>c.includes(t))),p&&(y=y.filter(t=>!p.includes(t))),e&&(y=y.filter(t=>e.includes((0,i.m)(t)))),s&&(y=y.filter(t=>!s.includes((0,i.m)(t)))),m=y.map(e=>{const s=t.states[e],r=(0,o.u)(s),[l,d,c]=(0,a.Cf)(s,[{type:"entity"},{type:"device"},{type:"area"}],t.entities,t.devices,t.areas,t.floors),p=(0,h.p$)(t.localize,(0,i.m)(e)),u=(0,n.qC)(t.language,t.translationMetadata.translations),m=l||d||e,y=[c,l?d:void 0].filter(Boolean).join(u?" ◂ ":" ▸ ");return{id:`${g}${e}`,primary:m,secondary:y,domain_name:p,sorting_label:[m,y].filter(Boolean).join("_"),search_labels:{entityName:l||null,deviceName:d||null,areaName:c||null,domainName:p||null,friendlyName:r||null,entityId:e},stateObj:s}}),l&&(m=m.filter(t=>t.id===u||t.stateObj?.attributes.device_class&&l.includes(t.stateObj.attributes.device_class))),d&&(m=m.filter(t=>t.id===u||t.stateObj?.attributes.unit_of_measurement&&d.includes(t.stateObj.attributes.unit_of_measurement))),r&&(m=m.filter(t=>t.id===u||t.stateObj&&r(t.stateObj))),m}},28949(t,e,s){s.d(e,{r:()=>o});s(44114),s(17642),s(58004),s(33853),s(45876),s(32475),s(15024),s(31698);const i=["light","climate","security","media_players","maintenance","weather","energy"],a=new Set(i);function o(t){const e=[],s=new Set;for(const i of t||[]){if("summary"===i.type){if(!a.has(i.key))continue;if(s.has(i.key))continue;s.add(i.key)}e.push(i)}for(const t of i)s.has(t)||e.push({type:"summary",key:t});return e}},96779(t,e,s){s.d(e,{q:()=>a});var i=s(45435);class a{get info(){return this._info}update(t,e){this._hass=t,e!==this._subscribedPath&&(this._unsub?.(),this._unsub=void 0,this._subscribedPath=e,e?this._unsub=(0,i.sy)(t,e,t=>{this._info=t,this._host.requestUpdate()}):this._info=i.Mw)}hostConnected(){if(this._hass&&this._subscribedPath&&!this._unsub){const t=this._subscribedPath;this._subscribedPath=void 0,this.update(this._hass,t)}}hostDisconnected(){this._unsub?.(),this._unsub=void 0}constructor(t){this._info=i.Mw,this._host=t,t.addController(this)}}},19711(t,e,s){s.d(e,{$:()=>o});var i=s(1087);const a=()=>Promise.all([s.e(80131),s.e(70183),s.e(47677)]).then(s.bind(s,79029)),o=(t,e)=>{(0,i.r)(t,"show-dialog",{dialogTag:"dialog-helper-detail",dialogImport:a,dialogParams:e})}},11197(t,e,s){s.a(t,async function(t,e){try{var i=s(62826),a=s(5124),o=s(22441),n=s(74705),h=s(1087),r=s(74281),l=s(26300),d=(s(8034),t([r,l]));[r,l]=d.then?(await d)():d;const c="M19,4H15.5L14.5,3H9.5L8.5,4H5V6H19M6,19A2,2 0 0,0 8,21H16A2,2 0 0,0 18,19V7H6V19Z";class p extends a.WF{render(){const t=this.hass.states[this.entityId],{primary:e,secondary:s}=t?(0,n.Bj)(this.hass,t):{primary:this.entityId,secondary:void 0};return a.qy` <ha-settings-row slim> <state-badge slot="prefix" .hass="${this.hass}" .stateObj="${t}"></state-badge> <span slot="heading">${e}</span> ${s?a.qy`<span slot="description">${s}</span>`:a.s6} <ha-icon-button .path="${c}" .label="${this.hass.localize("ui.common.delete")}" ="${this._delete}"></ha-icon-button> </ha-settings-row> `}_delete(){(0,h.r)(this,"delete-favorite-entity",{index:this.index})}constructor(...t){super(...t),this.index=0}}p.styles=a.AH`:host{display:block}ha-settings-row{padding:0;gap:var(--ha-space-3);min-height:40px;--settings-row-prefix-display:contents;--settings-row-content-display:contents;--settings-row-body-padding-top:var(--ha-space-1);--settings-row-body-padding-bottom:var(--ha-space-1)}state-badge{flex-shrink:0;width:24px;height:24px;--state-icon-color:var(--secondary-text-color)}[slot=description],[slot=heading]{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}ha-icon-button{--ha-icon-button-size:40px}`,(0,i.Cg)([(0,o.MZ)({attribute:!1})],p.prototype,"hass",void 0),(0,i.Cg)([(0,o.MZ)({attribute:"entity-id"})],p.prototype,"entityId",void 0),(0,i.Cg)([(0,o.MZ)({type:Number})],p.prototype,"index",void 0),p=(0,i.Cg)([(0,o.EM)("home-favorite-entity-list-item")],p),e()}catch(t){e(t)}})},69843(t,e,s){s.a(t,async function(t,e){try{s(74423);var i=s(62826),a=s(5124),o=s(22441),n=s(75751),h=s(1087),r=s(82474),l=(s(85938),s(67094),s(11197)),d=t([r,l]);[r,l]=d.then?(await d)():d;const c="M21 11H3V9H21V11M21 13H3V15H21V13Z";class p extends a.WF{render(){return a.qy` ${this.label?a.qy`<p class="field-label">${this.label}</p>`:a.s6} ${this.helper?a.qy`<p class="field-helper">${this.helper}</p>`:a.s6} <ha-sortable handle-selector=".handle" -moved="${this._moved}"> <div class="home-list"> ${(0,n.u)(this.favorites,t=>t,(t,e)=>a.qy` <div class="home-list-item favorite-row"> <div class="handle"> <ha-svg-icon .path="${c}"></ha-svg-icon> </div> <home-favorite-entity-list-item class="favorite-content" .hass="${this.hass}" .entityId="${t}" .index="${e}" -favorite-entity="${this._remove}"></home-favorite-entity-list-item> </div> `)} </div> </ha-sortable> <ha-entity-picker add-button .hass="${this.hass}" .addButtonLabel="${this.hass.localize("ui.panel.lovelace.editor.strategy.home.add_favorite_entity")}" .excludeEntities="${this.favorites}" -changed="${this._add}"></ha-entity-picker> `}_update(t){(0,h.r)(this,"value-changed",{value:t})}_add(t){t.stopPropagation();const e=t.detail.value;e&&(t.currentTarget.value="",this.favorites.includes(e)||this._update([...this.favorites,e]))}_remove(t){const{index:e}=t.detail,s=[...this.favorites];s.splice(e,1),this._update(s)}_moved(t){t.stopPropagation();const{oldIndex:e,newIndex:s}=t.detail,i=[...this.favorites],[a]=i.splice(e,1);i.splice(s,0,a),this._update(i)}constructor(...t){super(...t),this.favorites=[]}}p.styles=a.AH`.field-label{margin:0 0 var(--ha-space-1) 0;font-size:14px;color:var(--primary-text-color)}.field-helper{margin:0 0 var(--ha-space-2) 0;color:var(--secondary-text-color);font-size:12px}.home-list{display:flex;flex-direction:column}.favorite-row{display:flex;align-items:center;gap:var(--ha-space-2)}.favorite-content{flex:1;min-width:0}.handle{cursor:grab;color:var(--secondary-text-color);flex-shrink:0;display:flex;align-items:center}ha-entity-picker{display:block;padding-top:var(--ha-space-2)}`,(0,i.Cg)([(0,o.MZ)({attribute:!1})],p.prototype,"hass",void 0),(0,i.Cg)([(0,o.MZ)({attribute:!1})],p.prototype,"favorites",void 0),(0,i.Cg)([(0,o.MZ)()],p.prototype,"label",void 0),(0,i.Cg)([(0,o.MZ)()],p.prototype,"helper",void 0),p=(0,i.Cg)([(0,o.EM)("home-favorites-editor")],p),e()}catch(t){e(t)}})},61485(t,e,s){s.a(t,async function(t,e){try{var i=s(62826),a=s(5124),o=s(22441),n=s(89784),h=s(78870),r=s(1087),l=(s(47680),s(26300)),d=(s(8034),s(67094),s(96779)),c=t([l]);l=(c.then?(await c)():c)[0];const p="M19,4H15.5L14.5,3H9.5L8.5,4H5V6H19M6,19A2,2 0 0,0 8,21H16A2,2 0 0,0 18,19V7H6V19Z",u="M20.71,7.04C21.1,6.65 21.1,6 20.71,5.63L18.37,3.29C18,2.9 17.35,2.9 16.96,3.29L15.12,5.12L18.87,8.87M3,17.25V21H6.75L17.81,9.93L14.06,6.18L3,17.25Z";class g extends a.WF{willUpdate(t){(t.has("hass")||t.has("item"))&&this.hass&&this.item&&this._navInfo.update(this.hass,this.item.path)}render(){if(!this.item)return a.s6;const t=this._navInfo.info,e=this.item.label||t.label||this.item.path,s=this.item.icon||t.icon,i=s?void 0:t.iconPath,o={"--mdc-icon-size":"24px",color:this.item.color?(0,h.MP)(this.item.color):"var(--primary-color)"};return a.qy` <ha-settings-row slim> ${s?a.qy`<ha-icon slot="prefix" .icon="${s}" style="${(0,n.W)(o)}"></ha-icon>`:a.qy`<ha-svg-icon slot="prefix" .path="${i}" style="${(0,n.W)(o)}"></ha-svg-icon>`} <span slot="heading">${e}</span> <ha-icon-button .path="${u}" .label="${this.hass.localize("ui.common.edit")}" ="${this._edit}"></ha-icon-button> <ha-icon-button .path="${p}" .label="${this.hass.localize("ui.common.delete")}" ="${this._delete}"></ha-icon-button> </ha-settings-row> `}_edit(){(0,r.r)(this,"edit-shortcut",{index:this.index})}_delete(){(0,r.r)(this,"delete-shortcut",{index:this.index})}constructor(...t){super(...t),this.index=0,this._navInfo=new d.q(this)}}g.styles=a.AH`:host{display:block}ha-settings-row{padding:0;gap:var(--ha-space-3);min-height:40px;--settings-row-prefix-display:contents;--settings-row-content-display:contents;--settings-row-body-padding-top:var(--ha-space-1);--settings-row-body-padding-bottom:var(--ha-space-1)}ha-icon,ha-svg-icon{--mdc-icon-size:24px;flex-shrink:0}[slot=heading]{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}ha-icon-button{--ha-icon-button-size:40px}`,(0,i.Cg)([(0,o.MZ)({attribute:!1})],g.prototype,"hass",void 0),(0,i.Cg)([(0,o.MZ)({attribute:!1})],g.prototype,"item",void 0),(0,i.Cg)([(0,o.MZ)({type:Number})],g.prototype,"index",void 0),g=(0,i.Cg)([(0,o.EM)("home-shortcut-list-item")],g),e()}catch(t){e(t)}})},925(t,e,s){s.a(t,async function(t,e){try{s(18111),s(22489),s(61701),s(13579);var i=s(62826),a=s(5124),o=s(22441),n=s(75751),h=s(89784),r=s(22786),l=s(78870),d=s(1087),c=(s(47680),s(30879)),p=(s(8034),s(85938),s(67094),s(59646)),u=s(28949),g=s(8537),m=s(7094),y=s(61485),_=t([c,p,y,g]);[c,p,y,g]=_.then?(await _)():_;const v="M21 11H3V9H21V11M21 13H3V15H21V13Z",b="mdi:weather-partly-cloudy",f="teal";class $ extends a.WF{get _resolved(){return this._resolveShortcuts(this.shortcuts)}_itemKey(t){return"summary"===t.type?`summary:${t.key}`:`custom:${t.path}`}render(){const t=this._resolved,e=t.filter(t=>"custom"===t.type).map(t=>t.path);return a.qy` <ha-sortable handle-selector=".handle" -moved="${this._moved}"> <div class="list"> ${(0,n.u)(t,t=>this._itemKey(t),(t,e)=>{if("summary"===t.type){const e=this._summaryMeta(t.key);if(!e)return a.s6;const s=this._getSummaryLabel(t.key),i=(0,l.MP)(e.color);return a.qy` <div class="row"> <div class="handle"> <ha-svg-icon .path="${v}"></ha-svg-icon> </div> <ha-settings-row slim> <ha-icon slot="prefix" .icon="${e.icon}" style="${(0,h.W)({"--mdc-icon-size":"24px",color:i})}"></ha-icon> <span slot="heading">${s}</span> <ha-switch .checked="${!t.hidden}" .summaryKey="${t.key}" ="${this._summaryToggleChanged}"></ha-switch> </ha-settings-row> </div> `}return a.qy` <div class="row"> <div class="handle"> <ha-svg-icon .path="${v}"></ha-svg-icon> </div> <home-shortcut-list-item class="row-content" .hass="${this.hass}" .item="${t}" .index="${e}" -shortcut="${this._editShortcut}" -shortcut="${this._deleteShortcut}"></home-shortcut-list-item> </div> `})} </div> </ha-sortable> <ha-navigation-picker .hass="${this.hass}" .addButtonLabel="${this.hass.localize("ui.panel.home.editor.add_custom_shortcut")}" .excludePaths="${e}" -changed="${this._addShortcut}"></ha-navigation-picker> `}_getSummaryLabel(t){return"weather"===t?this.hass.localize("ui.panel.lovelace.strategy.home.summary_list.weather"):(0,g.rh)(this.hass.localize,t)}_summaryMeta(t){if("weather"===t)return{icon:b,color:f};if(t in g.It){const e=t;return{icon:g.It[e],color:g.uN[e]}}}_valueChanged(t){(0,d.r)(this,"value-changed",{value:t})}_moved(t){t.stopPropagation();const{oldIndex:e,newIndex:s}=t.detail,i=[...this._resolved],[a]=i.splice(e,1);i.splice(s,0,a),this._valueChanged(i)}_summaryToggleChanged(t){const{checked:e,summaryKey:s}=t.target,i=this._resolved.map(t=>"summary"===t.type&&t.key===s?{...t,hidden:!e||void 0}:t);this._valueChanged(i)}_addShortcut(t){t.stopPropagation();const e=t.detail.value;e&&(t.currentTarget.value="",this._resolved.some(t=>"custom"===t.type&&t.path===e)||this._valueChanged([...this._resolved,{type:"custom",path:e}]))}_editShortcut(t){const{index:e}=t.detail,s=this._resolved[e];s&&"custom"===s.type&&(0,m.q)(this,{item:s,saveCallback:t=>{const s=[...this._resolved];s[e]=t,this._valueChanged(s)}})}_deleteShortcut(t){const{index:e}=t.detail,s=[...this._resolved];s.splice(e,1),this._valueChanged(s)}constructor(...t){super(...t),this.shortcuts=[],this._resolveShortcuts=(0,r.A)(u.r)}}$.styles=a.AH`:host{display:block}.list{display:flex;flex-direction:column}.row{display:flex;align-items:center;gap:var(--ha-space-2)}.row-content{flex:1;min-width:0}ha-settings-row{flex:1;min-width:0;padding:0;gap:var(--ha-space-3);min-height:40px;--settings-row-prefix-display:contents;--settings-row-content-display:contents;--settings-row-body-padding-top:var(--ha-space-1);--settings-row-body-padding-bottom:var(--ha-space-1)}[slot=heading]{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.handle{cursor:grab;color:var(--secondary-text-color);flex-shrink:0;display:flex;align-items:center}ha-navigation-picker{display:block;padding-top:var(--ha-space-2)}`,(0,i.Cg)([(0,o.MZ)({attribute:!1})],$.prototype,"hass",void 0),(0,i.Cg)([(0,o.MZ)({attribute:!1})],$.prototype,"shortcuts",void 0),$=(0,i.Cg)([(0,o.EM)("home-shortcuts-editor")],$),e()}catch(t){e(t)}})},284(t,e,s){s.a(t,async function(t,i){try{s.r(e),s.d(e,{DialogEditHome:()=>b});var a=s(62826),o=s(5124),n=s(22441),h=s(22786),r=s(1087),l=s(38962),d=s(18350),c=(s(93444),s(72554)),p=(s(11382),s(52763)),u=(s(47680),s(14503)),g=s(69843),m=s(925),y=t([l,d,c,p,g,m]);[l,d,c,p,g,m]=y.then?(await y)():y;const _=8,v=[{name:"show_welcome_message",selector:{boolean:{}}}];class b extends o.WF{showDialog(t){this._params=t,this._state={favorite_entities:t.config.favorite_entities?[...t.config.favorite_entities]:[],show_suggested_entities:!t.config.hide_suggested_entities,show_welcome_message:!t.config.hide_welcome_message,shortcuts:t.config.shortcuts?[...t.config.shortcuts]:[]},this._open=!0}closeDialog(){return this._open=!1,!0}_dialogClosed(){this._params=void 0,this._state=void 0,this._submitting=!1,(0,r.r)(this,"dialog-closed",{dialog:this.localName})}render(){return this._params&&this._state?o.qy` <ha-dialog .open="${this._open}" .headerTitle="${this.hass.localize("ui.panel.home.editor.title")}" .headerSubtitle="${this.hass.localize("ui.panel.home.editor.description")}" prevent-scrim-close ="${this._dialogClosed}"> <ha-alert alert-type="info"> ${this.hass.localize("ui.panel.home.editor.areas_hint",{areas_page:o.qy`<a href="/config/areas?historyBack=1" ="${this.closeDialog}">${this.hass.localize("ui.panel.home.editor.areas_page")}</a>`})} </ha-alert> <ha-expansion-panel outlined expanded .header="${this.hass.localize("ui.panel.home.editor.personalize")}" .secondary="${this.hass.localize("ui.panel.home.editor.personalize_description")}"> <ha-icon slot="leading-icon" icon="mdi:palette-outline"></ha-icon> <div class="expansion-content"> <ha-form .hass="${this.hass}" .data="${{show_welcome_message:this._state.show_welcome_message}}" .schema="${v}" .computeLabel="${this._computeWelcomeLabel}" .computeHelper="${this._computeWelcomeHelper}" -changed="${this._welcomeChanged}"></ha-form> <home-favorites-editor .hass="${this.hass}" .favorites="${this._state.favorite_entities}" .label="${this.hass.localize("ui.panel.lovelace.editor.strategy.home.favorite_entities")}" -changed="${this._favoriteEntitiesChanged}"></home-favorites-editor> <ha-form .hass="${this.hass}" .data="${{show_suggested_entities:this._state.show_suggested_entities}}" .schema="${this._suggestedSchema(this._state.favorite_entities.length>=_)}" .computeLabel="${this._computeSuggestedLabel}" .computeHelper="${this._computeSuggestedHelper}" -changed="${this._suggestedChanged}"></ha-form> </div> </ha-expansion-panel> <ha-expansion-panel outlined expanded .header="${this.hass.localize("ui.panel.home.editor.summaries")}" .secondary="${this.hass.localize("ui.panel.home.editor.summaries_description")}"> <ha-icon slot="leading-icon" icon="mdi:view-dashboard-outline"></ha-icon> <div class="expansion-content"> <home-shortcuts-editor .hass="${this.hass}" .shortcuts="${this._state.shortcuts}" -changed="${this._shortcutsChanged}"></home-shortcuts-editor> </div> </ha-expansion-panel> <ha-dialog-footer slot="footer"> <ha-button appearance="plain" slot="secondaryAction" ="${this.closeDialog}" .disabled="${this._submitting}"> ${this.hass.localize("ui.common.cancel")} </ha-button> <ha-button slot="primaryAction" ="${this._save}" .disabled="${this._submitting}"> ${this.hass.localize("ui.common.save")} </ha-button> </ha-dialog-footer> </ha-dialog> `:o.s6}_favoriteEntitiesChanged(t){this._state={...this._state,favorite_entities:t.detail.value}}_welcomeChanged(t){this._state={...this._state,show_welcome_message:t.detail.value.show_welcome_message}}_suggestedChanged(t){this._state={...this._state,show_suggested_entities:t.detail.value.show_suggested_entities}}_shortcutsChanged(t){this._state={...this._state,shortcuts:t.detail.value}}async _save(){if(!this._params||!this._state)return;this._submitting=!0;const t=this._state,e={...this._params.config,favorite_entities:t.favorite_entities.length>0?t.favorite_entities:void 0,hide_suggested_entities:!t.show_suggested_entities||void 0,hide_welcome_message:!t.show_welcome_message||void 0,shortcuts:t.shortcuts.length>0?t.shortcuts:void 0};try{await this._params.saveConfig(e),this.closeDialog()}finally{this._submitting=!1}}constructor(...t){super(...t),this._open=!1,this._submitting=!1,this._suggestedSchema=(0,h.A)(t=>[{name:"show_suggested_entities",selector:{boolean:{}},disabled:t}]),this._computeWelcomeLabel=()=>this.hass.localize("ui.panel.home.editor.welcome_message"),this._computeWelcomeHelper=()=>this.hass.localize("ui.panel.home.editor.welcome_message_helper"),this._computeSuggestedLabel=()=>this.hass.localize("ui.panel.home.editor.suggested_entities"),this._computeSuggestedHelper=()=>{const t=(this._state?.favorite_entities.length??0)>=_;return this.hass.localize(t?"ui.panel.home.editor.suggested_entities_disabled_description":"ui.panel.home.editor.suggested_entities_description")}}}b.styles=[u.nA,o.AH`ha-dialog{--dialog-content-padding:var(--ha-space-6)}ha-expansion-panel{display:block;--expansion-panel-content-padding:0;border-radius:var(--ha-border-radius-md);--ha-card-border-radius:var(--ha-border-radius-md)}ha-expansion-panel+ha-expansion-panel{margin-top:var(--ha-space-2)}.expansion-content{padding:var(--ha-space-3)}ha-form{display:block}home-favorites-editor{display:block;margin-top:var(--ha-space-2);margin-bottom:var(--ha-space-4)}ha-alert{display:block;margin:calc(-1 * var(--dialog-content-padding));margin-bottom:var(--ha-space-4)}`],(0,a.Cg)([(0,n.MZ)({attribute:!1})],b.prototype,"hass",void 0),(0,a.Cg)([(0,n.wk)()],b.prototype,"_params",void 0),(0,a.Cg)([(0,n.wk)()],b.prototype,"_state",void 0),(0,a.Cg)([(0,n.wk)()],b.prototype,"_open",void 0),(0,a.Cg)([(0,n.wk)()],b.prototype,"_submitting",void 0),b=(0,a.Cg)([(0,n.EM)("dialog-edit-home")],b),i()}catch(t){i(t)}})},7094(t,e,s){s.d(e,{q:()=>o});var i=s(1087);const a=()=>s.e(19910).then(s.bind(s,20325)),o=(t,e)=>{(0,i.r)(t,"show-dialog",{dialogTag:"dialog-edit-shortcut",dialogImport:a,dialogParams:e})}}};