UNPKG

iobroker.lovelace

Version:

With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI

6 lines 72.5 kB
"use strict";(self.rspackChunkhome_assistant_frontend=self.rspackChunkhome_assistant_frontend||[]).push([[1667],{885:function(t,i,a){a.a(t,async function(t,i){try{a(89463),a(3362),a(62953);var e=a(40445),s=a(5124),o=a(67576),n=a(1087),l=a(38962),r=a(18350),h=(a(3587),a(35891)),d=a(38119),c=a(57116),u=t([l,r,d]);[l,r,d]=u.then?(await u)():u;let g,p,m,_,f=t=>t;const v="M15,9H5V5H15M12,19A3,3 0 0,1 9,16A3,3 0 0,1 12,13A3,3 0 0,1 15,16A3,3 0 0,1 12,19M17,3H5C3.89,3 3,3.9 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V7L17,3Z";class b extends d.D{get _config(){return this.config}render(){var t;return(0,s.qy)(g||(g=f` ${0} ${0} ${0} <ha-button slot="fab" size="large" class="${0}" .disabled="${0}" @click="${0}"> <ha-svg-icon slot="start" .path="${0}"></ha-svg-icon> ${0} </ha-button> `),"off"===(null===(t=this.stateObj)||void 0===t?void 0:t.state)?(0,s.qy)(p||(p=f` <ha-alert alert-type="info"> ${0} <ha-button appearance="plain" size="small" slot="action" @click="${0}"> ${0} </ha-button> </ha-alert> `),this.hass.localize("ui.panel.config.automation.editor.disabled"),this._enable,this.hass.localize("ui.panel.config.automation.editor.enable")):"",this.config.description?(0,s.qy)(m||(m=f`<ha-markdown class="description" breaks .content="${0}"></ha-markdown>`),this.config.description):s.s6,this.renderCard(),this.dirty?"dirty":"",this.saving,this._saveAutomation,v,this.hass.localize("ui.common.save"))}_saveAutomation(){(0,n.r)(this,"save-automation")}async _getBlueprints(){this._blueprints=await(0,h.Xg)(this.hass,"automation")}async _enable(){this.hass&&this.stateObj&&await this.hass.callService("automation","turn_on",{entity_id:this.stateObj.entity_id})}static get styles(){return[d.D.styles,c.T_,(0,s.AH)(_||(_=f`:host{position:relative;height:100%;min-height:calc(100vh - 134px - var(--safe-area-inset-top,0px) - var(--safe-area-inset-bottom,0px));min-height:calc(100dvh - 134px - var(--safe-area-inset-top,0px) - var(--safe-area-inset-bottom,0px))}ha-button[slot=fab]{position:fixed;--ha-button-box-shadow:var(--ha-box-shadow-l)}`))]}constructor(...t){super(...t),this.saving=!1,this.dirty=!1}}(0,e.Cg)([(0,o.MZ)({attribute:!1})],b.prototype,"config",void 0),(0,e.Cg)([(0,o.MZ)({attribute:!1})],b.prototype,"stateObj",void 0),(0,e.Cg)([(0,o.MZ)({type:Boolean})],b.prototype,"saving",void 0),(0,e.Cg)([(0,o.MZ)({type:Boolean})],b.prototype,"dirty",void 0),b=(0,e.Cg)([(0,o.EM)("blueprint-automation-editor")],b),i()}catch(g){i(g)}})},96259:function(t,i,a){a.a(t,async function(t,i){try{a(89463),a(16280),a(18111),a(20116),a(7588),a(61701),a(3362),a(27495),a(62953),a(48408),a(14603),a(47566),a(98721);var e=a(40445),s=(a(68825),a(5124)),o=a(67576),n=a(6412),l=a(17079),r=a(1087),h=a(91926),d=a(7553),c=a(18350),u=a(29823),g=(a(70947),a(47680),a(26300)),p=(a(67094),a(10763)),m=a(88249),_=a(35891),f=a(12596),v=a(22675),b=a(59241),y=a(65063),$=a(81310),w=a(79172),C=a(39359),A=a(14503),k=a(41570),H=a(49053),z=a(55270),M=a(37325),V=a(64265),x=a(60109),L=a(82405),I=a(885),O=a(70043),E=a(78614),S=t([c,u,g,p,$,I,E,O]);[c,u,g,p,$,I,E,O]=S.then?(await S)():S;let q,j,R,Z,P,U,B,F,D,T,W,Y,G,N,X,K,J,Q,tt,it,at,et,st=t=>t;const ot="M6,2A4,4 0 0,1 10,6V8H14V6A4,4 0 0,1 18,2A4,4 0 0,1 22,6A4,4 0 0,1 18,10H16V14H18A4,4 0 0,1 22,18A4,4 0 0,1 18,22A4,4 0 0,1 14,18V16H10V18A4,4 0 0,1 6,22A4,4 0 0,1 2,18A4,4 0 0,1 6,14H8V10H6A4,4 0 0,1 2,6A4,4 0 0,1 6,2M16,18A2,2 0 0,0 18,20A2,2 0 0,0 20,18A2,2 0 0,0 18,16H16V18M14,10H10V14H14V10M6,16A2,2 0 0,0 4,18A2,2 0 0,0 6,20A2,2 0 0,0 8,18V16H6M8,6A2,2 0 0,0 6,4A2,2 0 0,0 4,6A2,2 0 0,0 6,8H8V6M18,8A2,2 0 0,0 20,6A2,2 0 0,0 18,4A2,2 0 0,0 16,6V8H18Z",nt="M12,15.5A3.5,3.5 0 0,1 8.5,12A3.5,3.5 0 0,1 12,8.5A3.5,3.5 0 0,1 15.5,12A3.5,3.5 0 0,1 12,15.5M19.43,12.97C19.47,12.65 19.5,12.33 19.5,12C19.5,11.67 19.47,11.34 19.43,11L21.54,9.37C21.73,9.22 21.78,8.95 21.66,8.73L19.66,5.27C19.54,5.05 19.27,4.96 19.05,5.05L16.56,6.05C16.04,5.66 15.5,5.32 14.87,5.07L14.5,2.42C14.46,2.18 14.25,2 14,2H10C9.75,2 9.54,2.18 9.5,2.42L9.13,5.07C8.5,5.32 7.96,5.66 7.44,6.05L4.95,5.05C4.73,4.96 4.46,5.05 4.34,5.27L2.34,8.73C2.21,8.95 2.27,9.22 2.46,9.37L4.57,11C4.53,11.34 4.5,11.67 4.5,12C4.5,12.33 4.53,12.65 4.57,12.97L2.46,14.63C2.27,14.78 2.21,15.05 2.34,15.27L4.34,18.73C4.46,18.95 4.73,19.03 4.95,18.95L7.44,17.94C7.96,18.34 8.5,18.68 9.13,18.93L9.5,21.58C9.54,21.82 9.75,22 10,22H14C14.25,22 14.46,21.82 14.5,21.58L14.87,18.93C15.5,18.67 16.04,18.34 16.56,17.94L19.05,18.95C19.27,19.03 19.54,18.95 19.66,18.73L21.66,15.27C21.78,15.05 21.73,14.78 21.54,14.63L19.43,12.97Z",lt="M15,9H5V5H15M12,19A3,3 0 0,1 9,16A3,3 0 0,1 12,13A3,3 0 0,1 15,16A3,3 0 0,1 12,19M17,3H5C3.89,3 3,3.9 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V7L17,3Z",rt="M12,14A2,2 0 0,1 14,16A2,2 0 0,1 12,18A2,2 0 0,1 10,16A2,2 0 0,1 12,14M23.46,8.86L21.87,15.75L15,14.16L18.8,11.78C17.39,9.5 14.87,8 12,8C8.05,8 4.77,10.86 4.12,14.63L2.15,14.28C2.96,9.58 7.06,6 12,6C15.58,6 18.73,7.89 20.5,10.72L23.46,8.86Z",ht="M19,4H15.5L14.5,3H9.5L8.5,4H5V6H19M6,19A2,2 0 0,0 8,21H16A2,2 0 0,0 18,19V7H6V19Z",dt="M12,16A2,2 0 0,1 14,18A2,2 0 0,1 12,20A2,2 0 0,1 10,18A2,2 0 0,1 12,16M12,10A2,2 0 0,1 14,12A2,2 0 0,1 12,14A2,2 0 0,1 10,12A2,2 0 0,1 12,10M12,4A2,2 0 0,1 14,6A2,2 0 0,1 12,8A2,2 0 0,1 10,6A2,2 0 0,1 12,4Z",ct="M6 2C4.9 2 4 2.9 4 4V20C4 21.1 4.9 22 6 22H10V20.1L20 10.1V8L14 2H6M13 3.5L18.5 9H13V3.5M20.1 13C20 13 19.8 13.1 19.7 13.2L18.7 14.2L20.8 16.3L21.8 15.3C22 15.1 22 14.7 21.8 14.5L20.5 13.2C20.4 13.1 20.3 13 20.1 13M18.1 14.8L12 20.9V23H14.1L20.2 16.9L18.1 14.8Z",ut="M11,9H13V7H11M12,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,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2M11,17H13V11H11V17Z",gt="M8,5.14V19.14L19,12.14L8,5.14Z",pt="M12,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,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2M10,16.5L16,12L10,7.5V16.5Z",mt="M3 6V8H14V6H3M3 10V12H14V10H3M20 10.1C19.9 10.1 19.7 10.2 19.6 10.3L18.6 11.3L20.7 13.4L21.7 12.4C21.9 12.2 21.9 11.8 21.7 11.6L20.4 10.3C20.3 10.2 20.2 10.1 20 10.1M18.1 11.9L12 17.9V20H14.1L20.2 13.9L18.1 11.9M3 14V16H10V14H3Z",_t="M16,8H14V11H11V13H14V16H16V13H19V11H16M2,12C2,9.21 3.64,6.8 6,5.68V3.5C2.5,4.76 0,8.09 0,12C0,15.91 2.5,19.24 6,20.5V18.32C3.64,17.2 2,14.79 2,12M15,3C10.04,3 6,7.04 6,12C6,16.96 10.04,21 15,21C19.96,21 24,16.96 24,12C24,7.04 19.96,3 15,3M15,19C11.14,19 8,15.86 8,12C8,8.14 11.14,5 15,5C18.86,5 22,8.14 22,12C22,15.86 18.86,19 15,19Z",ft="M18.4,10.6C16.55,9 14.15,8 11.5,8C6.85,8 2.92,11.03 1.54,15.22L3.9,16C4.95,12.81 7.95,10.5 11.5,10.5C13.45,10.5 15.23,11.22 16.62,12.38L13,16H22V7L18.4,10.6Z",vt="M18,17H10.5L12.5,15H18M6,17V14.5L13.88,6.65C14.07,6.45 14.39,6.45 14.59,6.65L16.35,8.41C16.55,8.61 16.55,8.92 16.35,9.12L8.47,17M19,3H5C3.89,3 3,3.89 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V5C21,3.89 20.1,3 19,3Z",bt="M20 4H18V3H20.5C20.78 3 21 3.22 21 3.5V5.5C21 5.78 20.78 6 20.5 6H20V7H19V5H20V4M19 9H20V8H19V9M17 3H16V7H17V3M23 15V18C23 18.55 22.55 19 22 19H21V20C21 21.11 20.11 22 19 22H5C3.9 22 3 21.11 3 20V19H2C1.45 19 1 18.55 1 18V15C1 14.45 1.45 14 2 14H3C3 10.13 6.13 7 10 7H11V5.73C10.4 5.39 10 4.74 10 4C10 2.9 10.9 2 12 2S14 2.9 14 4C14 4.74 13.6 5.39 13 5.73V7H14C14.34 7 14.67 7.03 15 7.08V10H19.74C20.53 11.13 21 12.5 21 14H22C22.55 14 23 14.45 23 15M10 15.5C10 14.12 8.88 13 7.5 13S5 14.12 5 15.5 6.12 18 7.5 18 10 16.88 10 15.5M19 15.5C19 14.12 17.88 13 16.5 13S14 14.12 14 15.5 15.12 18 16.5 18 19 16.88 19 15.5M17 8H16V9H17V8Z",yt="M12,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,4C16.41,4 20,7.59 20,12C20,16.41 16.41,20 12,20C7.59,20 4,16.41 4,12C4,7.59 7.59,4 12,4M9,9V15H15V9",$t="M5.5,7A1.5,1.5 0 0,1 4,5.5A1.5,1.5 0 0,1 5.5,4A1.5,1.5 0 0,1 7,5.5A1.5,1.5 0 0,1 5.5,7M21.41,11.58L12.41,2.58C12.05,2.22 11.55,2 11,2H4C2.89,2 2,2.89 2,4V11C2,11.55 2.22,12.05 2.59,12.41L11.58,21.41C11.95,21.77 12.45,22 13,22C13.55,22 14.05,21.77 14.41,21.41L21.41,14.41C21.78,14.05 22,13.55 22,13C22,12.44 21.77,11.94 21.41,11.58Z",wt="M15,12C15,10.7 14.16,9.6 13,9.18V6.82C14.16,6.4 15,5.3 15,4A3,3 0 0,0 12,1A3,3 0 0,0 9,4C9,5.3 9.84,6.4 11,6.82V9.19C9.84,9.6 9,10.7 9,12C9,13.3 9.84,14.4 11,14.82V17.18C9.84,17.6 9,18.7 9,20A3,3 0 0,0 12,23A3,3 0 0,0 15,20C15,18.7 14.16,17.6 13,17.18V14.82C14.16,14.4 15,13.3 15,12M12,3A1,1 0 0,1 13,4A1,1 0 0,1 12,5A1,1 0 0,1 11,4A1,1 0 0,1 12,3M12,21A1,1 0 0,1 11,20A1,1 0 0,1 12,19A1,1 0 0,1 13,20A1,1 0 0,1 12,21Z",Ct="M12.5,8C9.85,8 7.45,9 5.6,10.6L2,7V16H11L7.38,12.38C8.77,11.22 10.54,10.5 12.5,10.5C16.04,10.5 19.05,12.81 20.1,16L22.47,15.22C21.08,11.03 17.15,8 12.5,8Z";class At extends((0,O.j)((0,C._)((0,w.b)(s.WF)))){willUpdate(t){if(super.willUpdate(t),this.entityRegCreated&&this._newAutomationId&&t.has("entityRegistry")){var i;const t=null===(i=this.entityRegistry)||void 0===i?void 0:i.find(t=>"automation"===t.platform&&t.unique_id===this._newAutomationId);t&&(this.entityRegCreated(t),this.entityRegCreated=void 0)}}render(){var t,i;if(!this.config)return this.renderLoading();const a=this.currentEntityId?this.hass.states[this.currentEntityId]:void 0,e="use_blueprint"in this.config,o=k.c?(0,s.qy)(q||(q=st`<ha-svg-icon .path="${0}"></ha-svg-icon>`),ot):this.hass.localize("ui.panel.config.automation.editor.ctrl");return(0,s.qy)(j||(j=st` <hass-subpage .hass="${0}" .narrow="${0}" .route="${0}" .backCallback="${0}" .header="${0}"> ${0} ${0} <ha-dropdown slot="toolbar-icon" @wa-select="${0}"> <ha-icon-button slot="trigger" .label="${0}" .path="${0}"></ha-icon-button> ${0} <ha-dropdown-item .disabled="${0}" value="info"> ${0} <ha-svg-icon slot="icon" .path="${0}"></ha-svg-icon> </ha-dropdown-item> <ha-dropdown-item .disabled="${0}" value="settings"> ${0} <ha-svg-icon slot="icon" .path="${0}"></ha-svg-icon> </ha-dropdown-item> <ha-dropdown-item .disabled="${0}" value="category"> ${0} <ha-svg-icon slot="icon" .path="${0}"></ha-svg-icon> </ha-dropdown-item> <ha-dropdown-item .disabled="${0}" value="run"> ${0} <ha-svg-icon slot="icon" .path="${0}"></ha-svg-icon> </ha-dropdown-item> ${0} <ha-dropdown-item value="rename" .disabled="${0}"> ${0} <ha-svg-icon slot="icon" .path="${0}"></ha-svg-icon> </ha-dropdown-item> ${0} <ha-dropdown-item .disabled="${0}" value="duplicate"> ${0} <ha-svg-icon slot="icon" .path="${0}"></ha-svg-icon> </ha-dropdown-item> ${0} <ha-dropdown-item value="toggle_yaml_mode"> ${0} <ha-svg-icon slot="icon" .path="${0}"></ha-svg-icon> </ha-dropdown-item> <wa-divider></wa-divider> <ha-dropdown-item .disabled="${0}" value="disable"> ${0} <ha-svg-icon slot="icon" .path="${0}"></ha-svg-icon> </ha-dropdown-item> <ha-dropdown-item .disabled="${0}" .variant="${0}" value="delete"> ${0} <ha-svg-icon class="${0}" slot="icon" .path="${0}"> </ha-svg-icon> </ha-dropdown-item> </ha-dropdown> <div class="${0}" @subscribe-automation-config="${0}"> ${0} </div> </hass-subpage> `),this.hass,this.narrow,this.route,this.backTapped,this.config.alias||this.hass.localize("ui.panel.config.automation.editor.default_name"),"gui"!==this.mode||this.narrow?s.s6:(0,s.qy)(R||(R=st`<ha-icon-button slot="toolbar-icon" .label="${0}" .path="${0}" @click="${0}" .disabled="${0}" id="button-undo"> </ha-icon-button> <ha-tooltip placement="bottom" for="button-undo"> ${0} <span class="shortcut">( <span>${0}</span> <span>+</span> <span>Z</span>) </span> </ha-tooltip> <ha-icon-button slot="toolbar-icon" .label="${0}" .path="${0}" @click="${0}" .disabled="${0}" id="button-redo"> </ha-icon-button> <ha-tooltip placement="bottom" for="button-redo"> ${0} <span class="shortcut"> ( ${0}) </span> </ha-tooltip>`),this.hass.localize("ui.common.undo"),Ct,this._undo,!this._undoRedoController.canUndo,this.hass.localize("ui.common.undo"),o,this.hass.localize("ui.common.redo"),ft,this._redo,!this._undoRedoController.canRedo,this.hass.localize("ui.common.redo"),k.c?(0,s.qy)(Z||(Z=st`<span>${0}</span> <span>+</span> <span>Shift</span> <span>+</span> <span>Z</span>`),o):(0,s.qy)(P||(P=st`<span>${0}</span> <span>+</span> <span>Y</span>`),o)),null!==(t=this.config)&&void 0!==t&&t.id&&!this.narrow?(0,s.qy)(U||(U=st` <ha-button appearance="plain" size="small" @click="${0}" slot="toolbar-icon"> ${0} </ha-button> `),this._showTrace,this.hass.localize("ui.panel.config.automation.editor.show_trace")):"",this._handleDropdownSelect,this.hass.localize("ui.common.menu"),dt,"gui"===this.mode&&this.narrow?(0,s.qy)(B||(B=st`<ha-dropdown-item value="undo" .disabled="${0}"> ${0} <ha-svg-icon slot="icon" .path="${0}"></ha-svg-icon> </ha-dropdown-item> <ha-dropdown-item value="redo" .disabled="${0}"> ${0} <ha-svg-icon slot="icon" .path="${0}"></ha-svg-icon> </ha-dropdown-item>`),!this._undoRedoController.canUndo,this.hass.localize("ui.common.undo"),Ct,!this._undoRedoController.canRedo,this.hass.localize("ui.common.redo"),ft):s.s6,!a,this.hass.localize("ui.panel.config.automation.editor.show_info"),ut,!a,this.hass.localize("ui.panel.config.automation.picker.show_settings"),nt,!a,this.hass.localize("ui.panel.config.scene.picker."+(null!==(i=this.registryEntry)&&void 0!==i&&null!==(i=i.categories)&&void 0!==i&&i.automation?"edit_category":"assign_category")),$t,!a,this.hass.localize("ui.panel.config.automation.editor.run"),gt,a&&this.narrow?(0,s.qy)(F||(F=st`<ha-dropdown-item value="trace"> ${0} <ha-svg-icon slot="icon" .path="${0}"></ha-svg-icon> </ha-dropdown-item>`),this.hass.localize("ui.panel.config.automation.editor.show_trace"),wt):s.s6,this.readOnly||!this.automationId||"yaml"===this.mode,this.hass.localize("ui.panel.config.automation.editor.rename"),vt,e?s.s6:(0,s.qy)(D||(D=st` <ha-dropdown-item @click="${0}" .disabled="${0}"> ${0} <ha-svg-icon slot="icon" .path="${0}"></ha-svg-icon> </ha-dropdown-item> `),this._promptAutomationMode,this.readOnly||"yaml"===this.mode,this.hass.localize("ui.panel.config.automation.editor.change_mode"),rt),!!this.blueprintConfig||!this.readOnly&&!this.automationId,this.hass.localize(this.readOnly?"ui.panel.config.automation.editor.migrate":"ui.panel.config.automation.editor.duplicate"),_t,e?(0,s.qy)(T||(T=st` <ha-dropdown-item value="take_control" .disabled="${0}"> ${0} <ha-svg-icon slot="icon" .path="${0}"></ha-svg-icon> </ha-dropdown-item> `),this.readOnly,this.hass.localize("ui.panel.config.automation.editor.take_control"),ct):s.s6,this.hass.localize("ui.panel.config.automation.editor.edit_"+("gui"===this.mode?"yaml":"ui")),mt,!a,"off"===(null==a?void 0:a.state)?this.hass.localize("ui.panel.config.automation.editor.enable"):this.hass.localize("ui.panel.config.automation.editor.disable"),"off"===(null==a?void 0:a.state)?pt:yt,!this.automationId,this.automationId?"danger":"default",this.hass.localize("ui.panel.config.automation.picker.delete"),(0,n.H)({warning:Boolean(this.automationId)}),ht,"yaml"===this.mode?"yaml-mode":"",this._subscribeAutomationConfig,"gui"===this.mode?(0,s.qy)(W||(W=st` <div> ${0} </div> `),e?(0,s.qy)(Y||(Y=st` <blueprint-automation-editor .hass="${0}" .narrow="${0}" .isWide="${0}" .stateObj="${0}" .config="${0}" .disabled="${0}" .saving="${0}" .dirty="${0}" @value-changed="${0}" @save-automation="${0}"></blueprint-automation-editor> `),this.hass,this.narrow,this.isWide,a,this.config,this.readOnly,this.saving,this.dirty,this._valueChanged,this._handleSaveAutomation):(0,s.qy)(G||(G=st` <manual-automation-editor .hass="${0}" .narrow="${0}" .isWide="${0}" .stateObj="${0}" .config="${0}" .disabled="${0}" .dirty="${0}" .saving="${0}" @value-changed="${0}" @save-automation="${0}" @editor-save="${0}"> <div class="alert-wrapper" slot="alerts"> ${0} ${0} ${0} </div> </manual-automation-editor> `),this.hass,this.narrow,this.isWide,a,this.config,this.readOnly,this.dirty,this.saving,this._valueChanged,this._handleSaveAutomation,this._handleSaveAutomation,this.errors||(null==a?void 0:a.state)===v.Hh?(0,s.qy)(N||(N=st`<ha-alert alert-type="error" .title="${0}"> ${0} ${0} </ha-alert>`),(null==a?void 0:a.state)===v.Hh?this.hass.localize("ui.panel.config.automation.editor.unavailable"):void 0,this.errors||this.validationErrors,(null==a?void 0:a.state)===v.Hh?(0,s.qy)(X||(X=st`<ha-svg-icon slot="icon" .path="${0}"></ha-svg-icon>`),bt):s.s6):s.s6,this.blueprintConfig?(0,s.qy)(K||(K=st`<ha-alert alert-type="info"> ${0} <div slot="action" style="display:flex"> <ha-button appearance="plain" @click="${0}">${0}</ha-button> <ha-button appearance="plain" @click="${0}">${0}</ha-button> </div> </ha-alert>`),this.hass.localize("ui.panel.config.automation.editor.confirm_take_control"),this.takeControlSave,this.hass.localize("ui.common.yes"),this.revertBlueprint,this.hass.localize("ui.common.no")):this.readOnly?(0,s.qy)(J||(J=st`<ha-alert alert-type="warning" dismissable>${0} <ha-button appearance="filled" size="small" variant="warning" slot="action" @click="${0}"> ${0} </ha-button> </ha-alert>`),this.hass.localize("ui.panel.config.automation.editor.read_only"),this._duplicate,this.hass.localize("ui.panel.config.automation.editor.migrate")):s.s6,"off"===(null==a?void 0:a.state)?(0,s.qy)(Q||(Q=st` <ha-alert alert-type="info"> ${0} <ha-button size="small" slot="action" @click="${0}"> ${0} </ha-button> </ha-alert> `),this.hass.localize("ui.panel.config.automation.editor.disabled"),this._toggle,this.hass.localize("ui.panel.config.automation.editor.enable")):s.s6)):"yaml"===this.mode?(0,s.qy)(tt||(tt=st`${0} <ha-yaml-editor .defaultValue="${0}" .readOnly="${0}" @value-changed="${0}" @editor-save="${0}" disable-fullscreen></ha-yaml-editor> <ha-button slot="fab" size="large" class="${0}" .disabled="${0}" @click="${0}"> <ha-svg-icon slot="start" .path="${0}"></ha-svg-icon> ${0} </ha-button>`),"off"===(null==a?void 0:a.state)?(0,s.qy)(it||(it=st` <ha-alert alert-type="info"> ${0} <ha-button appearance="filled" size="small" slot="action" @click="${0}"> ${0} </ha-button> </ha-alert> `),this.hass.localize("ui.panel.config.automation.editor.disabled"),this._toggle,this.hass.localize("ui.panel.config.automation.editor.enable")):s.s6,this._preprocessYaml(),this.readOnly,this._yamlChanged,this._handleSaveAutomation,this.dirty?"dirty":"",this.saving,this._handleSaveAutomation,lt,this.hass.localize("ui.common.save")):s.s6)}updated(t){var i;if(super.updated(t),!this.hass)return;const a=t.has("route")&&"/new"===(null===(i=this.route)||void 0===i?void 0:i.path)&&new URLSearchParams(window.location.search).has(L.Ku),e=t.get("automationId");if(t.has("automationId")&&this.automationId&&e!==this.automationId&&(this._setEntityId(),this.loadConfig(this.automationId)),(t.has("automationId")||a)&&!this.automationId&&!this.entityId){const t=(0,m.rY)();this.dirty=!!t;let i={description:""};t&&"use_blueprint"in t||(i=Object.assign(Object.assign({},i),{},{mode:"single",triggers:[],conditions:[],actions:[]})),this.config=Object.assign(Object.assign({},i),t?(0,m.HB)(t):t),this.currentEntityId=void 0,this.readOnly=!1}t.has("entityId")&&this.entityId&&((0,m.$W)(this.hass,this.entityId).then(t=>{this.config=(0,m.HB)(t.config),this._checkValidation()}),this.currentEntityId=this.entityId,this.dirty=!1,this.readOnly=!0),t.has("automations")&&this.automationId&&!this.currentEntityId&&this._setEntityId(),t.has("config")&&Object.values(this._configSubscriptions).forEach(t=>t(this.config))}_setEntityId(){const t=this.automations.find(t=>t.attributes.id===this.automationId);this.currentEntityId=null==t?void 0:t.entity_id}async _checkValidation(){if(this.validationErrors=void 0,!this.currentEntityId||!this.config)return;const t=this.hass.states[this.currentEntityId];if((null==t?void 0:t.state)!==v.Hh)return;const i=await(0,f.$)(this.hass,{triggers:this.config.triggers,conditions:this.config.conditions,actions:this.config.actions});this.validationErrors=Object.entries(i).map(([t,i])=>i.valid?"":(0,s.qy)(at||(at=st`${0}: ${0}<br>`),this.hass.localize(`ui.panel.config.automation.editor.${t}.name`),i.error))}_valueChanged(t){t.stopPropagation(),this.config&&this._undoRedoController.commit(this.config),this.config=t.detail.value,this.readOnly||(this.dirty=!0,this.errors=void 0)}_showInfo(){this.hass&&this.currentEntityId&&(0,r.r)(this,"hass-more-info",{entityId:this.currentEntityId})}_editCategory(){this.registryEntry?(0,z.j)(this,{scope:"automation",entityReg:this.registryEntry}):(0,y.showAlertDialog)(this,{title:this.hass.localize("ui.panel.config.scene.picker.no_category_support"),text:this.hass.localize("ui.panel.config.scene.picker.no_category_entity_reg")})}async _showTrace(){var t;if(null!==(t=this.config)&&void 0!==t&&t.id){await this.confirmUnsavedChanged()&&(0,h.oo)(`/config/automation/trace/${encodeURIComponent(this.config.id)}`)}}_runActions(){this.hass&&this.currentEntityId&&(0,m.lB)(this.hass,this.hass.states[this.currentEntityId].entity_id)}async _toggle(){if(!this.hass||!this.currentEntityId)return;const t=this.hass.states[this.currentEntityId],i="off"===t.state?"turn_on":"turn_off";await this.hass.callService("automation",i,{entity_id:t.entity_id})}_preprocessYaml(){if(!this.config)return{};const t=Object.assign({},this.config);return delete t.id,t}_yamlChanged(t){var i;t.stopPropagation(),this.dirty=!0,t.detail.isValid?(this.yamlErrors=void 0,this.config=Object.assign({id:null===(i=this.config)||void 0===i?void 0:i.id},(0,m.HB)(t.detail.value)),this.errors=void 0):this.yamlErrors=t.detail.errorMsg}async confirmUnsavedChanged(){return!this.dirty||new Promise(t=>{(0,V._)(this,{config:this.config,domain:"automation",updateConfig:async(i,a)=>{this.config=i,this.entityRegistryUpdate=a,this.dirty=!0,this.requestUpdate();const e=this.automationId||String(Date.now());try{await this._saveAutomation(e)}catch(s){return this.requestUpdate(),void t(!1)}t(!0)},onClose:()=>t(!1),onDiscard:()=>t(!0),entityRegistryUpdate:this.entityRegistryUpdate,entityRegistryEntry:this.registryEntry,title:this.hass.localize(this.automationId?"ui.panel.config.automation.editor.leave.unsaved_confirm_title":"ui.panel.config.automation.editor.leave.unsaved_new_title"),description:this.hass.localize(this.automationId?"ui.panel.config.automation.editor.leave.unsaved_confirm_text":"ui.panel.config.automation.editor.leave.unsaved_new_text"),hideInputs:null!==this.automationId})})}async _takeControl(){const t=this.config;try{const a=await(0,_.oz)(this.hass,"automation",t.use_blueprint.path,t.use_blueprint.input||{}),e=Object.assign(Object.assign({},(0,m.HB)(a.substituted_config)),{},{id:t.id,alias:t.alias,description:t.description});var i;if(this.blueprintConfig=t,this.config=e,"yaml"===this.mode)null===(i=this._yamlEditor)||void 0===i||i.setValue(this.config);this.readOnly=!0,this.errors=void 0}catch(a){this.errors=a.message}}async _duplicate(){var t;(this.readOnly?await(0,y.dk)(this,{title:this.hass.localize("ui.panel.config.automation.picker.migrate_automation"),text:this.hass.localize("ui.panel.config.automation.picker.migrate_automation_description")}):await this.confirmUnsavedChanged())&&(0,m.mX)(Object.assign(Object.assign({},this.config),{},{id:void 0,alias:this.readOnly?null===(t=this.config)||void 0===t?void 0:t.alias:void 0}))}async _deleteConfirm(){var t;(0,y.dk)(this,{title:this.hass.localize("ui.panel.config.automation.picker.delete_confirm_title"),text:this.hass.localize("ui.panel.config.automation.picker.delete_confirm_text",{name:null===(t=this.config)||void 0===t?void 0:t.alias}),confirmText:this.hass.localize("ui.common.delete"),destructive:!0,dismissText:this.hass.localize("ui.common.cancel"),confirm:()=>this._delete()})}async _delete(){this.automationId&&(await(0,m.lg)(this.hass,this.automationId),(0,h.OE)("/config"))}async _promptAutomationAlias(){return new Promise(t=>{(0,V._)(this,{config:this.config,domain:"automation",updateConfig:async(i,a)=>{this.config=i,this.entityRegistryUpdate=a,this.dirty=!0,this.requestUpdate(),t(!0)},onClose:()=>t(!1),entityRegistryUpdate:this.entityRegistryUpdate,entityRegistryEntry:this.registryEntry})})}async _promptAutomationMode(){return new Promise(t=>{(0,M.e)(this,{config:this.config,updateConfig:i=>{this.config=i,this.dirty=!0,this.requestUpdate(),t()},onClose:()=>t()})})}async _handleSaveAutomation(){var t;if(this.yamlErrors)return void(0,H.c)(this,{message:this.yamlErrors});null===(t=this._manualEditor)||void 0===t||t.resetPastedConfig();const i=this.automationId||String(Date.now());if(!this.automationId){if(!(await this._promptAutomationAlias()))return}await this._saveAutomation(i),this.automationId||(0,h.oo)(`/config/automation/edit/${i}`,{replace:!0})}async _saveAutomation(t){let i;this.saving=!0,this.validationErrors=void 0,void 0===this.entityRegistryUpdate||this.currentEntityId||(this._newAutomationId=t,i=new Promise(t=>{this.entityRegCreated=t}));try{if(await(0,m.b1)(this.hass,t,this.config),void 0!==this.entityRegistryUpdate){let t=this.currentEntityId;if(i)try{t=(await(0,d.h)(5e3,i)).entity_id}catch(s){if(!(s instanceof Error&&"TimeoutError"===s.name))throw s;await(0,x.j)(this,{savedPromise:i,type:"automation"});try{t=(await(0,d.h)(0,i)).entity_id}catch(o){if(!(o instanceof Error&&"TimeoutError"===o.name))throw o}}t&&await(0,b.G_)(this.hass,t,{categories:{automation:this.entityRegistryUpdate.category||null},labels:this.entityRegistryUpdate.labels||[],area_id:this.entityRegistryUpdate.area||null})}this.dirty=!1}catch(n){var a,e;throw this.errors=(null===(a=n.body)||void 0===a?void 0:a.message)||n.error||n.body,(0,H.c)(this,{message:(null===(e=n.body)||void 0===e?void 0:e.message)||n.error||n.body}),n}finally{this.saving=!1}}_subscribeAutomationConfig(t){const i=this._configSubscriptionsId++;this._configSubscriptions[i]=t.detail.callback,t.detail.unsub=()=>{delete this._configSubscriptions[i]},t.detail.callback(this.config)}supportedShortcuts(){return{s:()=>this._handleSaveAutomation(),c:()=>this._copySelectedRow(),x:()=>this._cutSelectedRow(),Delete:()=>this._deleteSelectedRow(),Backspace:()=>this._deleteSelectedRow(),z:()=>this._undo(),Z:()=>this._redo(),y:()=>this._redo()}}_collapseAll(){var t;null===(t=this._manualEditor)||void 0===t||t.collapseAll()}_expandAll(){var t;null===(t=this._manualEditor)||void 0===t||t.expandAll()}_copySelectedRow(){var t;null===(t=this._manualEditor)||void 0===t||t.copySelectedRow()}_cutSelectedRow(){var t;null===(t=this._manualEditor)||void 0===t||t.cutSelectedRow()}_deleteSelectedRow(){var t;null===(t=this._manualEditor)||void 0===t||t.deleteSelectedRow()}_applyUndoRedo(t){var i;null===(i=this._manualEditor)||void 0===i||i.triggerCloseSidebar(),this.config=t,this.dirty=!0}_undo(){this._undoRedoController.undo()}_redo(){this._undoRedoController.redo()}_handleDropdownSelect(t){var i;const a=null===(i=t.detail)||void 0===i||null===(i=i.item)||void 0===i?void 0:i.value;if(a)switch(a){case"undo":this._undo();break;case"redo":this._redo();break;case"info":this._showInfo();break;case"settings":this.showSettings();break;case"category":this._editCategory();break;case"run":this._runActions();break;case"rename":this._promptAutomationAlias();break;case"change_mode":this._promptAutomationMode();break;case"duplicate":this._duplicate();break;case"take_control":this._takeControl();break;case"toggle_yaml_mode":if("gui"===this.mode){this.switchYamlMode();break}this.switchUiMode();break;case"disable":this._toggle();break;case"delete":this._deleteConfirm();break;case"trace":this._showTrace()}}static get styles(){return[A.RF,O.m,(0,s.AH)(et||(et=st`blueprint-automation-editor,manual-automation-editor{margin:0 auto;max-width:1040px;padding:28px 20px 0;display:block}manual-automation-editor{max-width:var(--ha-automation-editor-max-width);padding:0 12px}ha-entity-toggle{margin-right:8px;margin-inline-end:8px;margin-inline-start:initial}h1{margin:0}.header-name{display:flex;align-items:center;margin:0 auto;max-width:1040px;padding:28px 20px 0}`))]}constructor(...t){super(...t),this.automationId=null,this._configSubscriptions={},this._configSubscriptionsId=1,this.domainHooks={domain:"automation",fetchFileConfig:m.oj,normalizeConfig:m.HB,checkValidation:()=>this._checkValidation()},this._undoRedoController=new l.X(this,{apply:t=>this._applyUndoRedo(t),currentConfig:()=>this.config})}}(0,e.Cg)([(0,o.MZ)({attribute:!1})],At.prototype,"automationId",void 0),(0,e.Cg)([(0,o.MZ)({attribute:!1})],At.prototype,"automations",void 0),(0,e.Cg)([(0,o.P)("manual-automation-editor")],At.prototype,"_manualEditor",void 0),(0,e.Cg)([(0,o.P)("ha-yaml-editor")],At.prototype,"_yamlEditor",void 0),At=(0,e.Cg)([(0,o.EM)("ha-automation-editor")],At),i()}catch(q){i(q)}})},34532:function(t,i,a){a.a(t,async function(t,i){try{a(89463),a(74423),a(44114),a(18111),a(81148),a(22489),a(20116),a(7588),a(61701),a(13579),a(3362),a(96167),a(27495),a(17642),a(58004),a(33853),a(45876),a(32475),a(15024),a(31698),a(62953),a(48408),a(14603),a(47566),a(98721);var e=a(40445),s=(a(68825),a(88696)),o=a(35211),n=a(5124),l=a(67576),r=a(89784),h=a(22786),d=a(36312),c=a(93905),u=a(1087),g=a(57237),p=a(28978),m=a(91926),_=a(87710),f=(a(34296),a(86171)),v=a(18350),b=(a(9503),a(29823)),y=(a(70947),a(645)),$=a(41113),w=a(52190),C=a(66702),A=a(72644),k=a(138),H=a(2617),z=a(26300),M=(a(82988),a(67094),a(59646)),V=a(34127),x=a(53641),L=a(88249),I=a(76570),O=a(22792),E=a(77001),S=a(22675),q=a(59241),j=a(14782),R=a(92557),Z=a(71606),P=a(65063),U=a(72553),B=a(54706),F=a(14503),D=a(36918),T=a(95048),W=a(34023),Y=a(55270),G=a(90986),N=a(29303),X=a(25635),K=a(69569),J=a(94017),Q=a(19661),tt=a(14839),it=t([f,v,b,y,$,w,C,A,k,H,z,M,V,U,s,N,J]);[f,v,b,y,$,w,C,A,k,H,z,M,V,U,s,N,J]=it.then?(await it)():it;let at,et,st,ot,nt,lt,rt,ht,dt,ct,ut,gt,pt,mt,_t,ft,vt,bt,yt,$t,wt,Ct,At,kt,Ht,zt,Mt,Vt,xt,Lt,It,Ot,Et=t=>t;const St="M12,15.5A3.5,3.5 0 0,1 8.5,12A3.5,3.5 0 0,1 12,8.5A3.5,3.5 0 0,1 15.5,12A3.5,3.5 0 0,1 12,15.5M19.43,12.97C19.47,12.65 19.5,12.33 19.5,12C19.5,11.67 19.47,11.34 19.43,11L21.54,9.37C21.73,9.22 21.78,8.95 21.66,8.73L19.66,5.27C19.54,5.05 19.27,4.96 19.05,5.05L16.56,6.05C16.04,5.66 15.5,5.32 14.87,5.07L14.5,2.42C14.46,2.18 14.25,2 14,2H10C9.75,2 9.54,2.18 9.5,2.42L9.13,5.07C8.5,5.32 7.96,5.66 7.44,6.05L4.95,5.05C4.73,4.96 4.46,5.05 4.34,5.27L2.34,8.73C2.21,8.95 2.27,9.22 2.46,9.37L4.57,11C4.53,11.34 4.5,11.67 4.5,12C4.5,12.33 4.53,12.65 4.57,12.97L2.46,14.63C2.27,14.78 2.21,15.05 2.34,15.27L4.34,18.73C4.46,18.95 4.73,19.03 4.95,18.95L7.44,17.94C7.96,18.34 8.5,18.68 9.13,18.93L9.5,21.58C9.54,21.82 9.75,22 10,22H14C14.25,22 14.46,21.82 14.5,21.58L14.87,18.93C15.5,18.67 16.04,18.34 16.56,17.94L19.05,18.95C19.27,19.03 19.54,18.95 19.66,18.73L21.66,15.27C21.78,15.05 21.73,14.78 21.54,14.63L19.43,12.97Z",qt="M11,17H4A2,2 0 0,1 2,15V3A2,2 0 0,1 4,1H16V3H4V15H11V13L15,16L11,19V17M19,21V7H8V13H6V7A2,2 0 0,1 8,5H19A2,2 0 0,1 21,7V21A2,2 0 0,1 19,23H8A2,2 0 0,1 6,21V19H8V21H19Z",jt="M19,4H15.5L14.5,3H9.5L8.5,4H5V6H19M6,19A2,2 0 0,0 8,21H16A2,2 0 0,0 18,19V7H6V19Z",Rt="M12,16A2,2 0 0,1 14,18A2,2 0 0,1 12,20A2,2 0 0,1 10,18A2,2 0 0,1 12,16M12,10A2,2 0 0,1 14,12A2,2 0 0,1 12,14A2,2 0 0,1 10,12A2,2 0 0,1 12,10M12,4A2,2 0 0,1 14,6A2,2 0 0,1 12,8A2,2 0 0,1 10,6A2,2 0 0,1 12,4Z",Zt="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",Pt="M11,9H13V7H11M12,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,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2M11,17H13V11H11V17Z",Ut="M7,10L12,15L17,10H7Z",Bt="M14,3V5H17.59L7.76,14.83L9.17,16.24L19,6.41V10H21V3M19,19H5V5H12V3H5C3.89,3 3,3.9 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V12H19V19Z",Ft="M8,5.14V19.14L19,12.14L8,5.14Z",Dt="M19,13H13V19H11V13H5V11H11V5H13V11H19V13Z",Tt="M22 14H21C21 10.13 17.87 7 14 7H13V5.73C13.6 5.39 14 4.74 14 4C14 2.9 13.11 2 12 2S10 2.9 10 4C10 4.74 10.4 5.39 11 5.73V7H10C6.13 7 3 10.13 3 14H2C1.45 14 1 14.45 1 15V18C1 18.55 1.45 19 2 19H3V20C3 21.11 3.9 22 5 22H19C20.11 22 21 21.11 21 20V19H22C22.55 19 23 18.55 23 18V15C23 14.45 22.55 14 22 14M9.79 16.5C9.4 15.62 8.53 15 7.5 15S5.6 15.62 5.21 16.5C5.08 16.19 5 15.86 5 15.5C5 14.12 6.12 13 7.5 13S10 14.12 10 15.5C10 15.86 9.92 16.19 9.79 16.5M18.79 16.5C18.4 15.62 17.5 15 16.5 15S14.6 15.62 14.21 16.5C14.08 16.19 14 15.86 14 15.5C14 14.12 15.12 13 16.5 13S19 14.12 19 15.5C19 15.86 18.92 16.19 18.79 16.5Z",Wt="M5.5,7A1.5,1.5 0 0,1 4,5.5A1.5,1.5 0 0,1 5.5,4A1.5,1.5 0 0,1 7,5.5A1.5,1.5 0 0,1 5.5,7M21.41,11.58L12.41,2.58C12.05,2.22 11.55,2 11,2H4C2.89,2 2,2.89 2,4V11C2,11.55 2.22,12.05 2.59,12.41L11.58,21.41C11.95,21.77 12.45,22 13,22C13.55,22 14.05,21.77 14.41,21.41L21.41,14.41C21.78,14.05 22,13.55 22,13C22,12.44 21.77,11.94 21.41,11.58Z",Yt="M20 2H4C2.9 2 2 2.9 2 4V20C2 21.11 2.9 22 4 22H20C21.11 22 22 21.11 22 20V4C22 2.9 21.11 2 20 2M4 6L6 4H10.9L4 10.9V6M4 13.7L13.7 4H18.6L4 18.6V13.7M20 18L18 20H13.1L20 13.1V18M20 10.3L10.3 20H5.4L20 5.4V10.3Z",Gt="M17,7H7A5,5 0 0,0 2,12A5,5 0 0,0 7,17H17A5,5 0 0,0 22,12A5,5 0 0,0 17,7M17,15A3,3 0 0,1 14,12A3,3 0 0,1 17,9A3,3 0 0,1 20,12A3,3 0 0,1 17,15Z",Nt="M17 6H7c-3.31 0-6 2.69-6 6s2.69 6 6 6h10c3.31 0 6-2.69 6-6s-2.69-6-6-6zm0 10H7c-2.21 0-4-1.79-4-4s1.79-4 4-4h10c2.21 0 4 1.79 4 4s-1.79 4-4 4zM7 9c-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3z",Xt="M15,12C15,10.7 14.16,9.6 13,9.18V6.82C14.16,6.4 15,5.3 15,4A3,3 0 0,0 12,1A3,3 0 0,0 9,4C9,5.3 9.84,6.4 11,6.82V9.19C9.84,9.6 9,10.7 9,12C9,13.3 9.84,14.4 11,14.82V17.18C9.84,17.6 9,18.7 9,20A3,3 0 0,0 12,23A3,3 0 0,0 15,20C15,18.7 14.16,17.6 13,17.18V14.82C14.16,14.4 15,13.3 15,12M12,3A1,1 0 0,1 13,4A1,1 0 0,1 12,5A1,1 0 0,1 11,4A1,1 0 0,1 12,3M12,21A1,1 0 0,1 11,20A1,1 0 0,1 12,19A1,1 0 0,1 13,20A1,1 0 0,1 12,21Z";class Kt extends((0,B.E)(n.WF)){get _availableAssistants(){return(0,Q.V)(this.cloudStatus,this.hass)}hassSubscribe(){return[(0,I.Ar)(this.hass.connection,"automation",t=>{this._categories=t})]}render(){var t,i,a,e,s,o,l,r,h,d,c,u;const g=this._sizeController.value&&this._sizeController.value<900||!this._sizeController.value&&"docked"===this.hass.dockedSidebar,p=g&&(!this._sizeController.value||this._sizeController.value<700),m=this._automations(this.automations,this._entityReg,this.hass.areas,this._categories,this._labels,this._filteredEntityIds);return(0,n.qy)(at||(at=Et` <hass-tabs-subpage-data-table .hass="${0}" .narrow="${0}" .backPath="${0}" id="entity_id" .route="${0}" .tabs="${0}" .searchLabel="${0}" selectable .selected="${0}" @selection-changed="${0}" has-filters .filters="${0}" .columns="${0}" .initialGroupColumn="${0}" .initialCollapsedGroups="${0}" .initialSorting="${0}" .columnOrder="${0}" .hiddenColumns="${0}" @columns-changed="${0}" @sorting-changed="${0}" @grouping-changed="${0}" @collapsed-changed="${0}" .data="${0}" .empty="${0}" @row-click="${0}" .noDataText="${0}" @clear-filter="${0}" .filter="${0}" @search-changed="${0}" has-fab clickable class="${0}"> <ha-icon-button slot="toolbar-icon" .label="${0}" .path="${0}" @click="${0}"></ha-icon-button> <ha-filter-floor-areas .hass="${0}" .type="${0}" .value="${0}" @data-table-filter-changed="${0}" slot="filter-pane" .expanded="${0}" .narrow="${0}" @expanded-changed="${0}"></ha-filter-floor-areas> <ha-filter-devices .hass="${0}" .type="${0}" .value="${0}" @data-table-filter-changed="${0}" slot="filter-pane" .expanded="${0}" .narrow="${0}" @expanded-changed="${0}"></ha-filter-devices> <ha-filter-entities .hass="${0}" .type="${0}" .value="${0}" @data-table-filter-changed="${0}" slot="filter-pane" .expanded="${0}" .narrow="${0}" @expanded-changed="${0}"></ha-filter-entities> <ha-filter-labels .hass="${0}" .value="${0}" @data-table-filter-changed="${0}" slot="filter-pane" .expanded="${0}" .narrow="${0}" @expanded-changed="${0}"></ha-filter-labels> <ha-filter-categories .hass="${0}" scope="automation" .value="${0}" @data-table-filter-changed="${0}" slot="filter-pane" .expanded="${0}" .narrow="${0}" @expanded-changed="${0}"></ha-filter-categories> <ha-filter-voice-assistants .hass="${0}" .value="${0}" @data-table-filter-changed="${0}" slot="filter-pane" .expanded="${0}" .narrow="${0}" @expanded-changed="${0}"></ha-filter-voice-assistants> <ha-filter-blueprints .hass="${0}" .type="${0}" .value="${0}" @data-table-filter-changed="${0}" slot="filter-pane" .expanded="${0}" .narrow="${0}" @expanded-changed="${0}"></ha-filter-blueprints> ${0} <ha-dropdown slot="selection-bar" @wa-select="${0}"> ${0} ${0} ${0} ${0} <ha-dropdown-item value="enable"> <ha-svg-icon slot="icon" .path="${0}"></ha-svg-icon> ${0} </ha-dropdown-item> <ha-dropdown-item value="disable"> <ha-svg-icon slot="icon" .path="${0}"></ha-svg-icon> ${0} </ha-dropdown-item> </ha-dropdown> ${0} <ha-button slot="fab" size="large" @click="${0}"> <ha-svg-icon slot="start" .path="${0}"></ha-svg-icon> ${0} </ha-button> </hass-tabs-subpage-data-table> <ha-dropdown id="overflow-menu" @wa-select="${0}" @wa-after-show="${0}" @wa-after-hide="${0}"> <ha-dropdown-item value="show_info"> <ha-svg-icon .path="${0}" slot="icon"></ha-svg-icon> ${0} </ha-dropdown-item> <ha-dropdown-item value="show_settings"> <ha-svg-icon .path="${0}" slot="icon"></ha-svg-icon> ${0} </ha-dropdown-item> <ha-dropdown-item value="edit_category"> <ha-svg-icon .path="${0}" slot="icon"></ha-svg-icon> ${0} </ha-dropdown-item> <ha-dropdown-item value="run_actions"> <ha-svg-icon .path="${0}" slot="icon"></ha-svg-icon> ${0} </ha-dropdown-item> <ha-dropdown-item value="show_trace"> <ha-svg-icon .path="${0}" slot="icon"></ha-svg-icon> ${0} </ha-dropdown-item> <wa-divider></wa-divider> <ha-dropdown-item value="duplicate"> <ha-svg-icon .path="${0}" slot="icon"></ha-svg-icon> ${0} </ha-dropdown-item> <ha-dropdown-item value="toggle"> <ha-svg-icon .path="${0}" slot="icon"></ha-svg-icon> ${0} </ha-dropdown-item> <ha-dropdown-item value="delete" variant="danger"> <ha-svg-icon .path="${0}" slot="icon"></ha-svg-icon> ${0} </ha-dropdown-item> </ha-dropdown> `),this.hass,this.narrow,this._searchParms.has("historyBack")?void 0:"/config",this.route,X.configSections.automations,this.hass.localize("ui.panel.config.automation.picker.search",{number:m.length}),this._selected.length,this._handleSelectionChanged,Object.values(this._filters).filter(t=>Array.isArray(t.value)?t.value.length:t.value&&Object.values(t.value).some(t=>Array.isArray(t)?t.length:t)).length,this._columns(this.narrow,this.hass.localize,m),null!==(t=this._activeGrouping)&&void 0!==t?t:"category",this._activeCollapsed,this._activeSorting,this._activeColumnOrder,this._activeHiddenColumns,this._handleColumnsChanged,this._handleSortingChanged,this._handleGroupingChanged,this._handleCollapseChanged,m,!this.automations.length,this._handleRowClicked,this.hass.localize("ui.panel.config.automation.picker.no_automations"),this._clearFilter,this._filter,this._handleSearchChange,this.narrow?"narrow":"",this.hass.localize("ui.common.help"),Zt,this._showHelp,this.hass,"automation",null===(i=this._filters["ha-filter-floor-areas"])||void 0===i?void 0:i.value,this._filterChanged,"ha-filter-floor-areas"===this._expandedFilter,this.narrow,this._filterExpanded,this.hass,"automation",null===(a=this._filters["ha-filter-devices"])||void 0===a?void 0:a.value,this._filterChanged,"ha-filter-devices"===this._expandedFilter,this.narrow,this._filterExpanded,this.hass,"automation",null===(e=this._filters["ha-filter-entities"])||void 0===e?void 0:e.value,this._filterChanged,"ha-filter-entities"===this._expandedFilter,this.narrow,this._filterExpanded,this.hass,null===(s=this._filters["ha-filter-labels"])||void 0===s?void 0:s.value,this._filterChanged,"ha-filter-labels"===this._expandedFilter,this.narrow,this._filterExpanded,this.hass,null===(o=this._filters["ha-filter-categories"])||void 0===o?void 0:o.value,this._filterChanged,"ha-filter-categories"===this._expandedFilter,this.narrow,this._filterExpanded,this.hass,null===(l=this._filters["ha-filter-voice-assistants"])||void 0===l?void 0:l.value,this._filterChanged,"ha-filter-voice-assistants"===this._expandedFilter,this.narrow,this._filterExpanded,this.hass,"automation",null===(r=this._filters["ha-filter-blueprints"])||void 0===r?void 0:r.value,this._filterChanged,"ha-filter-blueprints"===this._expandedFilter,this.narrow,this._filterExpanded,this.narrow?n.s6:(0,n.qy)(et||(et=Et`<ha-dropdown slot="selection-bar" @wa-select="${0}"> <ha-assist-chip slot="trigger" .label="${0}"> <ha-svg-icon slot="trailing-icon" .path="${0}"></ha-svg-icon> </ha-assist-chip> ${0} </ha-dropdown> ${0} ${0}`),this._handleBulkCategory,this.hass.localize("ui.panel.config.automation.picker.bulk_actions.move_category"),Ut,this._renderCategoryItems(),p?n.s6:(0,n.qy)(st||(st=Et`<ha-dropdown slot="selection-bar" @wa-select="${0}"> <ha-assist-chip slot="trigger" .label="${0}"> <ha-svg-icon slot="trailing-icon" .path="${0}"></ha-svg-icon> </ha-assist-chip> ${0} </ha-dropdown>`),this._handleBulkLabel,this.hass.localize("ui.panel.config.automation.picker.bulk_actions.add_label"),Ut,this._renderLabelItems()),g?n.s6:(0,n.qy)(ot||(ot=Et`<ha-dropdown slot="selection-bar" @wa-select="${0}"> <ha-assist-chip slot="trigger" .label="${0}"> <ha-svg-icon slot="trailing-icon" .path="${0}"></ha-svg-icon> </ha-assist-chip> ${0} </ha-dropdown>`),this._handleBulkArea,this.hass.localize("ui.panel.config.devices.picker.bulk_actions.move_area"),Ut,this._renderAreaItems())),this._handleBulkAction,this.narrow?(0,n.qy)(nt||(nt=Et`<ha-assist-chip .label="${0}" slot="trigger"> <ha-svg-icon slot="trailing-icon" .path="${0}"></ha-svg-icon> </ha-assist-chip>`),this.hass.localize("ui.panel.config.automation.picker.bulk_action"),Ut):(0,n.qy)(lt||(lt=Et`<ha-icon-button .path="${0}" .label="${0}" slot="trigger"></ha-icon-button>`),Rt,this.hass.localize("ui.panel.config.automation.picker.bulk_action")),this.narrow?(0,n.qy)(rt||(rt=Et`<ha-dropdown-item> ${0} ${0} </ha-dropdown-item>`),this.hass.localize("ui.panel.config.automation.picker.bulk_actions.move_category"),this._renderCategoryItems("submenu")):n.s6,this.narrow||p?(0,n.qy)(ht||(ht=Et`<ha-dropdown-item> ${0} ${0} </ha-dropdown-item>`),this.hass.localize("ui.panel.config.automation.picker.bulk_actions.add_label"),this._renderLabelItems("submenu")):n.s6,this.narrow||g?(0,n.qy)(dt||(dt=Et`<ha-dropdown-item> ${0} ${0} </ha-dropdown-item>`),this.hass.localize("ui.panel.config.devices.picker.bulk_actions.move_area"),this._renderAreaItems("submenu")):n.s6,Gt,this.hass.localize("ui.panel.config.automation.picker.bulk_actions.enable"),Nt,this.hass.localize("ui.panel.config.automation.picker.bulk_actions.disable"),this.automations.length?n.s6:(0,n.qy)(ct||(ct=Et`<div class="empty" slot="empty"> <ha-svg-icon .path="${0}"></ha-svg-icon> <h1> ${0} </h1> <p> ${0} </p> <p> ${0} </p> <ha-button href="${0}" target="_blank" appearance="plain" rel="noreferrer" size="small"> ${0} <ha-svg-icon slot="end" .path="${0}"> </ha-svg-icon> </ha-button> </div>`),Tt,this.hass.localize("ui.panel.config.automation.picker.empty_header"),this.hass.localize("ui.panel.config.automation.picker.empty_text_1"),this.hass.localize("ui.panel.config.automation.picker.empty_text_2",{user:(null===(h=this.hass.user)||void 0===h?void 0:h.name)||"Alice"}),(0,D.o)(this.hass,"/docs/automation/editor/"),this.hass.localize("ui.panel.config.common.learn_more"),Bt),this._createNew,Dt,this.hass.localize("ui.panel.config.automation.picker.add_automation"),this._handleOverflowAction,this._overflowMenuOpened,this._overflowMenuClosed,Pt,this.hass.localize("ui.panel.config.automation.editor.show_info"),St,this.hass.localize("ui.panel.config.automation.picker.show_settings"),Wt,this.hass.localize("ui.panel.config.automation.picker."+(null!==(d=this._overflowAutomation)&&void 0!==d&&d.category?"edit_category":"assign_category")),Ft,this.hass.localize("ui.panel.config.automation.editor.run"),Xt,this.hass.localize("ui.panel.config.automation.editor.show_trace"),qt,this.hass.localize("ui.panel.config.automation.picker.duplicate"),"off"===(null===(c=this._overflowAutomation)||void 0===c?void 0:c.state)?Gt:Nt,"off"===(null===(u=this._overflowAutomation)||void 0===u?void 0:u.state)?this.hass.localize("ui.panel.config.automation.editor.enable"):this.hass.localize("ui.panel.config.automation.editor.disable"),jt,this.hass.localize("ui.panel.config.automation.picker.delete"))}willUpdate(t){if(super.willUpdate(t),!this.hasUpdated){this._searchParms.has("area")||this._searchParms.has("blueprint")||this._searchParms.has("device")||this._searchParms.has("label")||(this._filters=this._storageFilters),this._searchParms.has("area")&&this._filterArea(),this._searchParms.has("device")&&this._filterDevice(),this._searchParms.has("blueprint")&&this._filterBlueprint(),this._searchParms.has("label")&&this._filterLabel()}}updated(t){super.updated(t),t.has("_entityReg")&&this._applyFilters()}_filterExpanded(t){t.detail.expanded?this._expandedFilter=t.target.localName:this._expandedFilter===t.target.localName&&(this._expandedFilter=void 0)}_handleSearchChange(t){this._filter=t.detail.value}_filterChanged(t){const i=t.target.localName;this._filters=Object.assign(Object.assign({},this._filters),{},{[i]:t.detail}),this._fromUrl||(this._storageFilters=this._filters),this._applyFilters()}_applyFilters(){const t=Object.entries(this._filters);let i=this.automations.map(t=>t.entity_id);for(const[a,e]of t)(0,E.fq)(a,e,["ha-filter-floor-areas","ha-filter-devices","ha-filter-entities","ha-filter-blueprints"])?i=i.filter(t=>e.items.has(t)):(0,E._H)(a,e,"ha-filter-categories")?i=i.filter(t=>{var i;return e.value[0]===(null===(i=this._entityReg.find(i=>i.entity_id===t))||void 0===i?void 0:i.categories.automation)}):(0,E._H)(a,e,"ha-filter-labels")?i=i.filter(t=>{var i;return null===(i=this._entityReg.find(i=>i.entity_id===t))||void 0===i?void 0:i.labels.some(t=>e.value.includes(t))}):(0,E._H)(a,e,"ha-filter-voice-assistants")&&(i=i.filter(t=>(0,j.hB)(this._entityReg||[],t).some(t=>e.value.includes(t))));this._filteredEntityIds=i}_filterArea(){const t=this._searchParms.get("area");t&&(this._fromUrl=!0,this._filters=Object.assign(Object.assign({},this._filters),{},{"ha-filter-floor-areas":{value:{areas:[t]},items:void 0}}),this._applyFilters())}_filterDevice(){const t=this._searchParms.get("device");t&&(this._fromUrl=!0,this._filters=Object.assign(Object.assign({},this._filters),{},{"ha-filter-devices":{value:[t],items:void 0}}),this._applyFilters())}_filterLabel(){const t=this._searchParms.get("label");t&&(this._fromUrl=!0,this._filters=Object.assign(Object.assign({},this._filters),{},{"ha-filter-labels":{value:[t],items:void 0}}),this._applyFilters())}async _filterBlueprint(){const t=this._searchParms.get("blueprint");if(!t)return;this._fromUrl=!0;const i=await(0,Z.f)(this.hass,"automation_blueprint",t);this._filters=Object.assign(Object.assign({},this._filters),{},{"ha-filter-blueprints":{value:[t],items:new Set(i.automation||[])}}),this._applyFilters()}_clearFilter(){this._filters={},this._fromUrl||(this._storageFilters={}),this._applyFilters()}async _delete(t){try{await(0,L.lg)(this.hass,t.attributes.id),this._selected=this._selected.filter(i=>i!==t.entity_id)}catch(i){await(0,P.showAlertDialog)(this,{text:400===i.status_code?this.hass.localize("ui.panel.config.automation.editor.load_error_not_deletable"):this.hass.localize("ui.panel.config.automation.editor.load_error_unknown",{err_no:i.status_code})})}}_showHelp(){(0,P.showAlertDialog)(this,{title:this.hass.localize("ui.panel.config.automation.caption"),text:(0,n.qy)(ut||(ut=Et` ${0} <p> <a href="${0}" target="_blank" rel="noreferrer"> ${0} </a> </p> `),this.hass.localize("ui.panel.config.automation.picker.introduction"),(0,D.o)(this.hass,"/docs/automation/editor/"),this.hass.localize("ui.panel.config.automation.picker.learn_more"))})}_handleRowClicked(t){const i=this.automations.find(i=>i.entity_id===t.detail.id);null!=i&&i.attributes.id?(0,m.oo)(`/config/automation/edit/${encodeURIComponent(i.attributes.id)}`):(0,m.oo)(`/config/automation/show/${encodeURIComponent(t.detail.id)}`)}_handleSelectionChanged(t){this._selected=t.detail.value}_createNew(){(0,d.x)(this.hass.config,"blueprint")?(0,tt.l)(this,{mode:"automation"}):(0,m.oo)("/config/automation/edit/new")}async _bulkAddCategory(t){const i=[];this._selected.forEach(a=>{i.push((0,q.G_)(this.hass,a,{categories:{automation:t}}))});const a=await Promise.allSettled(i);if((0,_.$)(a)){const t=(0,_.N)(a);(0,P.showAlertDialog)(this,{title:this.hass.localize("ui.panel.config.common.multiselect.failed",{number:t.length}),text:(0,n.qy)(gt||(gt=Et`<pre>
${0}</pre>`),t.map(t=>t.reason.message||t.reason.code||t.reason).join("\r\n"))})}}async _bulkLabel(t,i){const a=[];this._selected.forEach(e=>{a.push((0,q.G_)(this.hass,e,{labels:"add"===i?this.hass.entities[e].labels.concat(t):this.hass.entities[e].labels.filter(i=>i!==t)}))});const e=await Promise.allSettled(a);if((0,_.$)(e)){const t=(0,_.N)(e);(0,P.showAlertDialog)(this,{title:this.hass.localize("ui.panel.config.common.multiselect.failed",{number:t.length}),text:(0,n.qy)(pt||(pt=Et`<pre>
${0}</pre>`),t.map(t=>t.reason.message||t.reason.code||t.reason).join("\r\n"))})}}async _bulkAddArea(t){const i=[];this._selected.forEach(a=>{i.push((0,q.G_)(this.hass,a,{area_id:t}))});const a=await Promise.allSettled(i);if((0,_.$)(a)){const t=(0,_.N)(a);(0,P.showAlertDialog)(this,{title:this.hass.localize("ui.panel.config.common.multiselect.failed",{number:t.length}),text:(0,n.qy)(mt||(mt=Et`<pre>
${0}</pre>`),t.map(t=>t.reason.message||t.reason.code||t.reason).join("\r\n"))})}}_handleSortingChanged(t){this._activeSorting=t.detail}_handleGroupingChanged(t){var i;this._activeGrouping=null!==(i=t.detail.value)&&void 0!==i?i:""}_handleCollapseChanged(t){this._activeCollapsed=t.detail.value}_handleColumnsChanged(t){this._activeColumnOrder=t.detail.columnOrder,this._activeHiddenColumns=t.detail.hiddenColumns}static get styles(){return[F.RF,(0,n.AH)(_t||(_t=Et`:host{display:block;height:100%}hass-tabs-subpage-data-table{--data-table-row-height:60px}hass-tabs-subpage-data-table.narrow{--data-table-row-height:72px}.empty{--mdc-icon-size:80px;max-width:500px}.empty ha-button{--mdc-icon-size:24px}.empty h1{font-size:var(--ha-font-size-3xl)}ha-assist-chip{--ha-assist-chip-container-shape:10px}ha-dropdown::part(menu),ha-dropdown::part(submenu){--auto-size-available-width:calc(50vw - var(--ha-space-4))}ha-dropdown ha-assist-chip{--md-assist-chip-trailing-space:8px}`))]}constructor(...t){super(...t),this.isWide=!1,this.narrow=!1,this._searchParms=new URLSearchParams(window.location.search),this._filter="",this._filters={},this._storageFilters={},this._fromUrl=!1,this._selected=[],this._labels=[],this._entityReg=[],this._sizeController=new s.P(this,{callback:t=>{var i;return null===(i=t[0])||void 0===i?void 0:i.contentRect.width}}),this._openingOverflow=!1,this._automations=(0,h.A)((t,i,a,e,s,o)=>null===o?[]:(o?t.filter(t=>o.includes(t.entity_id)):t).map(t=>{var o,n;const l=i.find(i=>i.entity_id===t.entity_id),r=null==l?void 0:l.categories.automation,h=(s&&(null==l?void 0:l.labels)||[]).map(t=>s.find(i=>i.label_id===t)).filter(t=>void 0!==t),d=(0,j.hB)(i,t.entity_id);return Object.assign(Object.assign({},t),{},{name:(0,p.u)(t),area:null!=l&&l.area_id?null===(o=a[null==l?void 0:l.area_id])||void 0===o?void 0:o.name:void 0,last_triggered:t.attributes.last_triggered||void 0,formatted_state:this.hass.formatEntityState(t),category:r?null==e||null===(n=e.find(t=>t.category_id===r))||void 0===n?void 0:n.name:void 0,label_entries:h,labels:h.map(t=>t.name),assistants:d,assistants_sortable_key:(0,J.HX)(d),selectable:void 0!==l})})),this._columns=(0,h.A)((t,i,a)=>({icon:{title:"",label:i("ui.panel.config.automation.picker.headers.icon"),type:"icon",moveable:!1,showNarrow:!0,template:t=>(0,n.qy)(ft||(ft=Et`<ha-state-icon .stateObj="${0}" style="${0}"></ha-state-icon>`),t,(0,r.W)({color:t.state===S.Hh?"var(--error-color)":"unset"}))},entity_id:(0,N.t)(),name:{title:i("ui.panel.config.automation.picker.headers.name"),main:!0,sortable:!0,filterable:!0,direction:"asc",flex:2,extraTemplate:i=>i.label_entries.length?(0,n.qy)(vt||(vt=Et`<ha-data-table-labels @label-clicked="${0}" .labels="${0}"></ha-data-table-labels>`),t?void 0:this._labelClicked,i.label_entries):n.s6},area:(0,N.A7)(i),category:(0,N.Bl)(i),labels:(0,N.AI)(),last_triggered:(0,N.N4)(i,this.hass),formatted_state:{minWidth:"82px",maxWidth:"82px",sortable:!0,groupable:!0,hidden:t,type:"overflow",title:this.hass.localize("ui.panel.config.automation.picker.state"),template:t=>(0,n.qy)(bt||(bt=Et` <ha-switch @click="${0}" @change="${0}" .automation="${0}" .checked="${0}"></ha-switch> `),g.d,this._handleSwitchToggle,t,"on"===t.state)},actions:{lastFixed:!0,title:"",label:this.hass.localize("ui.panel.config.generic.headers.actions"),type:"icon-button",showNarrow:!0,template:t=>(0,n.qy)(yt||(yt=Et` <ha-icon-button .automation="${0}" .label="${0}" .path="${0}" @click="${0}"></ha-icon-button> `),t,this.hass.localize("ui.common.overflow_menu"),Rt,this._showOverflowMenu)},assistants:(0,J.MD)(i,this.hass,this._availableAssistants,a)})),this._showOverflowMenu=t=>{this._overflowMenu.anchorElement!==t.target?(this._openingOverflow=!0,this._overflowMenu.anchorElement=t.target,this._overflowAutomation=t.target.automation,this._overflowMenu.open=!0):this._overflowMenu.anchorElement=void 0},this._overflowMenuOpened=()=>{this._openingOverflow=!1},this._overflowMenuClosed=()=>{this._openingOverflow||(this._overflowMenu.anchorElement=void 0)},this._labelClicked=t=>{const i=t.detail.label;this._filters=Object.assign(Object.assign({},this._filters),{},{"ha-filter-labels":{value:[i.label_id],items:void 0}}),this._fromUrl||(this._storageFilters=this._filters),this._applyFilters()},this._handleOverflowAction=t=>{const i=t.detail.item.value;if(i&&this._overflowAutomation)switch(i){case"show_info":this._showInfo(this._overflowAutomation);break;case"show_settings":this._showSettings(this._overflowAutomation);break;case"edit_category":this._editCategory(this._overflowAutomation);break;case"run_actions":this._runActions(this._overflowAutomation);break;case"show_trace":this._showTrace(this._overflowAutomation);break;case"toggle":this._toggle(this._overflowAutomation);break;case"delete":this._deleteConfirm(this._overflowAutomation);break;case"duplicate":this._duplicate(this._overflowAutomation)}},this._showInfo=t=>{(0,u.r)(this,"hass-more-info",{entityId:t.entity_id})},this._showSettings=t=>{(0,u.r)(this,"hass-more-info",{entityId:t.entity_id,view:"settings"})},this._runActions=t=>{(0,L.lB)(this.hass,t.entity_id)},this._editCategory=t=>{const i=this._entityReg.find(i=>i.entity_id===t.entity_id);i?(0,Y.j)(this,{scope:"automation",entityReg:i}):(0,P.showAlertDialog)(this,{title:this.hass.localize("ui.panel.config.automation.picker.no_category_support"),text:this.hass.localize("ui.panel.config.automation.picker.no_category_entity_reg")})},this._showTrace=t=>{t.attributes.id?(0,m.oo)(`/config/automation/trace/${encodeURIComponent(t.attributes.id)}`):(0,P.showAlertDialog)(this,{text:this.hass.localize("ui.panel.config.automation.picker.traces_not_available")})},this._handleSwitchToggle=t=>{const i=t.currentTarget.automation;this._toggle(i)},this._toggle=async t=>{const i="off"===t.state?"turn_on":"turn_off";await this.hass.callService("automation",i,{entity_id:t.entity_id})},this._deleteConfirm=async t=>{(0,P.dk)(this,{title:this.hass.localize("ui.panel.config.automation.picker.delete_confirm_title"),text:this.hass.localize("ui.panel.config.automation.picker.delete_confirm_text",{name:t.name}),confirmText:this.hass.localize("ui.common.delete"),dismissText:this.hass.localize("ui.common.cancel"),confirm:()=>this._delete(t),destructive:!0})},this._duplicate=async t=>{try{const i=await(0,L.oj)(this.hass,t.attributes.id);(0,L.vH)(i)}catch(i){if(404===i.status_code){const i=await(0,L.$W)(this.hass,t.entity_id);return void(0,L.mX)(Object.assign(Object.assign({},i.config),{},{id:void 0}))}await(0,P.showAlertDialog)(this,{text:this.hass.localize("ui.panel.config.automation.editor.load_error_unknown",{err_no:i.status_code})})}},this._handleBulkCategory=t=>{const i=t.detail.item.value;"category_create"!==i?"category_none"!==i?null!=i&&i.startsWith("category_")&&this._bulkAddCategory(i.substring(9)):this._bulkAddCategory(null):this._bulkCreateCategory()},this._handleBulkLabel=t=>{t.preventDefault();const i=t.detail.item,a=i.value;if("label_create"!==a){if(null!=a&&a.startsWith("label_")){const t=i.action;this._bulkLabel(a.substring(6),t)}}else this._bulkCreateLabel()},this._handleBulkArea=t=>{const i=t.detail.item.value;"area_create"!==i?"area_none"!==i?null!=i&&i.startsWith("area_")&&this._bulkAddArea(i.substring(5)):this._bulkAddArea(null):this._bulkCreateArea()},this._bulkCreateArea=async()=>{(0,W.J)(this,{createEntry:async t=>{const i=await(0,x.L3)(this.hass,t);return this._bulkAddArea(i.area_id),i}})},this._handleBulkEnable=async()=>{const t=[];this._selected.forEach(i=>{t.push((0,T.L)(this.hass,i,!0))});const i=await Promise.allSettled(t);if((0,_.$)(i)){const t=(0,_.N)(i);(0,P.showAlertDialog)(this,{title:this.hass.localize("ui.panel.config.common.multiselect.failed",{number:t.length}),text:(0,n.qy)($t||($t=Et`<pre>
${0}</pre>`),t.map(t=>t.reason.message||t.reason.code||t.reason).join("\r\n"))})}},this._handleBulkDisable=async()=>{const t=[];this._selected.forEach(i=>{t.push((0,T.L)(this.hass,i,!1))});const i=await Promise.allSettled(t);if((0,_.$)(i)){const t=(0,_.N)(i);(0,P.showAlertDialog)(this,{title:this.hass.localize("ui.panel.config.common.multiselect.failed",{number:t.length}),text:(0,n.qy)(wt||(wt=Et`<pre>
${0}</pre>`),t.map(t=>t.reason.message||t.reason.code||t.reason).join("\r\n"))})}},this._bulkCreateCategory=async()=>{(0,G.S)(this,{scope:"automation",createEntry:async t=>{const i=await(0,I.s_)(this.hass,"automation",t);return this._bulkAddCategory(i.category_id),i}})},this._bulkCreateLabel=()=>{(0,K.f)(this,{createEntry:async t=>{const i=await(0,R._9)(this.hass,t);this._bulkLabel(i.label_id,"add")}})},this._renderCategoryItems=(t="")=>{var i;return(0,n.qy)(Ct||(Ct=Et`${0} <ha-dropdown-item .slot="${0}" value="category_none"> ${0} </ha-dropdown-item> <wa-divider .slot="${0}"></wa-divider> <ha-dropdown-item .slot="${0}" value="category_create"> ${0} </ha-dropdown-item>`),null===(i=this._categories)||void 0===i?void 0:i.map(i=>(0,n.qy)(At||(At=Et`<ha-dropdown-item .slot="${0}" .value="${0}"> ${0} ${0} </ha-dropdown-item>`),t,`category_${i.category_id}`,i.icon?(0,n.qy)(kt||(kt=Et`<ha-icon slot="icon" .icon="${0}"></ha-icon>`),i.icon):(0,n.qy)(Ht||(Ht=Et`<ha-svg-icon slot="icon" .path="${0}"></ha-svg-icon>`),Wt),i.name)),t,this.hass.localize("ui.panel.config.automation.picker.bulk_actions.no_category"),t,t,this.hass.localize("ui.panel.config.category.editor.add"))},this._renderLabelItems=(t="")=>{var i;return(0,n.qy)(zt||(zt=Et`${0} <wa-divider .slot="${0}"></wa-divider> <ha-dropdown-item .slot="${0}" value="label_create"> ${0} </ha-dropdown-item>`),null===(i=this._labels)||void 0===i?void 0:i.map(i=>{const a=this._selected.every(t=>{var a;return null===(a=this.hass.entities[t])||void 0===a?void 0:a.labels.includes(i.label_id)}),e=!a&&this._selected.some(t=>{var a;return null===(a=this.hass.entities[t])||void 0===a?void 0:a.labels.includes(i.label_id)});return(0,n.qy)(Mt||(Mt=Et`<ha-dropdown-item .slot="${0}" .value="${0}" .action="${0}"> <ha-checkbox slot="icon" .checked="${0}" .indeterminate="${0}"></ha-checkbox> <ha-label .color="${0}" .description="${0}"> ${0} ${0} </ha-label> </ha-dropdown-item>`),t,`label_${i.label_id}`,a?"remove":"add",a,e,i.color,i.description,i.icon?(0,n.qy)(Vt||(Vt=Et`<ha-icon slot="icon" .icon="${0}"></ha-icon>`),i.icon):n.s6,i.name)}),t,t,this.hass.localize("ui.panel.config.labels.add_label"))},this._renderAreaItems=(t="")=>(0,n.qy)(xt||(xt=Et`${0} <ha-dropdown-item .slot="${0}" value="area_none"> ${0} </ha-dropdown-item> <wa-divider .slot="${0}"></wa-divider> <ha-dropdown-item .slot="${0}" value="area_create"> ${0} </ha-dropdown-item>`),Object.values(this.hass.areas).map(i=>(0,n.qy)(Lt||(Lt=Et`<ha-dropdown-item .slot="${0}" .value="${0}"> ${0} ${0} </ha-dropdown-item>`),t,`area_${i.area_id}`,i.icon?(0,n.qy)(It||(It=Et`<ha-icon slot="icon" .icon="${0}"></ha-icon>`),i.icon):(0,n.qy)(Ot||(Ot=Et`<ha-svg-icon slot="icon" .path="${0}"></ha-svg-icon>`),Yt),i.name)),t,this.hass.localize("ui.panel.config.devices.picker.bulk_actions.no_area"),t,t,this.hass.localize("ui.panel.config.devices.picker.bulk_actions.add_area")),this._handleBulkAction=t=>{const i=t.detail.item,a=i.value;if(a)if("enable"!==a)if("disable"!==a){if(a.startsWith("category_"))return"category_create"===a?void this._bulkCreateCategory():"category_none"===a?void this._bulkAddCategory(null):void this._bulkAddCategory(a.substring(9));if(a.startsWith("label_")){if("label_create"===a)return void this._bulkCreateLabel();const t=i.action;return void this._bulkLabel(a.substring(6),t)}if(a.startsWith("area_")){if("area_create"===a)return void this._bulkCreateArea();if("area_none"===a)return void this._bulkAddArea(null);this._bulkAddArea(a.substring(5))}}else this._handleBulkDisable();else this._handleBulkEnable()}}}(0,e.Cg)([(0,l.MZ)({attribute:!1})],Kt.prototype,"hass",void 0),(0,e.Cg)([(0,l.MZ)({attribute:"is-wide",type:Boolean})],Kt.prototype,"isWide",void 0),(0,e.Cg)([(0,l.MZ)({type:Boolean})],Kt.prototype,"narrow",void 0),(0,e.Cg)([(0,l.MZ)({attribute:!1})],Kt.prototype,"route",void 0),(0,e.Cg)([(0,l.MZ)({attribute:!1})],Kt.prototype,"cloudStatus",void 0),(0,e.Cg)([(0,l.MZ)({attribute:!1})],Kt.prototype,"automations",void 0),(0,e.Cg)([(0,l.wk)()],Kt.prototype,"_searchParms",void 0),(0,e.Cg)([(0,l.wk)()],Kt.prototype,"_filteredEntityIds",void 0),(0,e.Cg)([(0,l.wk)(),(0,c.I)({storage:"sessionStorage",key:"automation-table-search",state:!0,subscribe:!1})],Kt.prototype,"_filter",void 0),(0,e.Cg)([(0,l.wk)()],Kt.prototype,"_filters",void 0),(0,e.Cg)([(0,c.I)({storage:"sessionStorage",key:"automation-table-filters-full",state:!1,subscribe:!1,serializer:E.iS,deserializer:E.Dc})],Kt.prototype,"_storageFilters",void 0),(0,e.Cg)([(0,l.wk)()],Kt.prototype,"_expandedFilter",void 0),(0,e.Cg)([(0,l.wk)()],Kt.prototype,"_selected",void 0),(0,e.Cg)([(0,l.wk)()],Kt.prototype,"_categories",void 0),(0,e.Cg)([(0,o.Fg)({context:O.HD,subscribe:!0}),(0,l.wk)()],Kt.prototype,"_labels",void 0),(0,e.Cg)([(0,l.wk)(),(0,o.Fg)({context:O.ih,subscribe:!0})],Kt.prototype,"_entityReg",void 0),(0,e.Cg)([(0,l.wk)()],Kt.prototype,"_overflowAutomation",void 0),(0,e.Cg)([(0,c.I)({key:"automation-table-sort",state:!1,subscribe:!1})],Kt.prototype,"_activeSorting",void 0),(0,e.Cg)([(0,c.I)({key:"automation-table-grouping",state:!1,subscribe:!1})],Kt.prototype,"_activeGrouping",void 0),(0,e.Cg)([(0,c.I)({key:"automation-table-collapsed",state:!1,subscribe:!1})],Kt.prototype,"_activeCollapsed",void 0),(0,e.Cg)([(0,c.I)({key:"automation-table-column-order",state:!1,subscribe:!1})],Kt.prototype,"_activeColumnOrder",void 0),(0,e.Cg)([(0,c.I)({key:"automation-table-hidden-columns",state:!1,subscribe:!1})],Kt.prototype,"_activeHiddenColumns",void 0),(0,e.Cg)([(0,l.P)("#overflow-menu")],Kt.prototype,"_overflowMenu",void 0),Kt=(0,e.Cg)([(0,l.EM)("ha-automation-picker")],Kt),i()}catch(at){i(at)}})},71470:function(t,i,a){a.a(t,async function(t,e){try{a.r(i);a(18111),a(81148),a(22489),a(3362),a(62953);var s=a(40445),o=a(67576),n=a(22786),l=a(69093),r=a(9899),h=a(324),d=a(96259),c=a(34532),u=t([d,c]);[d,c]=u.then?(await u)():u;const g=(t,i)=>t.length===i.length&&t.every((t,a)=>t===i[a]);class p extends h.a{firstUpdated(t){super.firstUpdated(t),this.hass.loadBackendTranslation("device_automation")}updatePageEl(t,i){if(t.hass=this.hass,t.narrow=this.narrow,t.isWide=this.isWide,t.route=this.routeTail,t.cloudStatus=this.cloudStatus,this.hass&&(t.automations&&i?i.has("hass")&&this._debouncedUpdateAutomations(t):t.automations=this._getAutomations(this.hass.states)),(!i||i.has("route"))&&"show"===this._currentPage){const i=decodeURIComponent(this.routeTail.path.substr(1));return t.automationId=null,void(t.entityId="new"===i?null:i)}if((!i||i.has("route"))&&"dashboard"!==this._currentPage){const i=decodeURIComponent(this.routeTail.path.substr(1));t.automationId="new"===i?null:i,t.entityId=null}}constructor(...t){super(...t),this.narrow=!1,this.isWide=!1,this.automations=[],this._debouncedUpdateAutomations=(0,r.s)(t=>{const i=this._getAutomations(this.hass.states);g(i,t.automations)||(t.automations=i)},10),this.routerOptions={defaultPage:"dashboard",routes:{dashboard:{tag:"ha-automation-picker",cache:!0},edit:{tag:"ha-automation-editor"},show:{tag:"ha-automation-editor"},trace:{tag:"ha-automation-trace",load:()=>Promise.all([a.e(66432),a.e(87857),a.e(82333),a.e(775),a.e(14022)]).then(a.bind(a,64037))}}},this._getAutomations=(0,n.A)(t=>Object.values(t).filter(t=>"automation"===(0,l.t)(t)&&!t.attributes.restored))}}(0,s.Cg)([(0,o.MZ)({attribute:!1})],p.prototype,"hass",void 0),(0,s.Cg)([(0,o.MZ)({type:Boolean})],p.prototype,"narrow",void 0),(0,s.Cg)([(0,o.MZ)({attribute:"is-wide",type:Boolean})],p.prototype,"isWide",void 0),(0,s.Cg)([(0,o.MZ)({attribute:!1})],p.prototype,"cloudStatus",void 0),(0,s.Cg)([(0,o.MZ)({attribute:!1})],p.prototype,"automations",void 0),p=(0,s.Cg)([(0,o.EM)("ha-config-automation")],p),e()}catch(g){e(g)}})},78614:function(t,i,a){a.a(t,async function(t,i){try{a(89463),a(74423),a(44114),a(18111),a(22489),a(7588),a(3362),a(62953);var e=a(40445),s=a(53289),o=a(5124),n=a(67576),l=a(63533),r=a(44537),h=a(68348),d=a(1087),c=a(18350),u=a(26300),g=(a(3587),a(88249)),p=a(84025),m=a(49053),_=a(68469),f=a(40219),v=a(136),b=a(84047),y=a(57116),$=a(53723),w=t([c,u,_,f,$,v]);[c,u,_,f,$,v]=w.then?(await w)():w;let C,A,k,H,z,M,V=t=>t;const x=(0,l.Ik)({alias:(0,l.lq)((0,l.Yj)()),description:(0,l.lq)((0,l.Yj)()),triggers:(0,l.lq)((0,l.YO)((0,l.bz)())),conditions:(0,l.lq)((0,l.YO)((0,l.bz)())),actions:(0,l.lq)((0,l.YO)((0,l.bz)())),mode:(0,l.lq)((0,l.Yj)()),max_exceeded:(0,l.lq)((0,l.Yj)()),id:(0,l.lq)((0,l.Yj)())}),L=(0,l.KC)([(0,l.kp)(x,(0,l.Ik)({triggers:(0,l.YO)((0,l.bz)())})),(0,l.kp)(x,(0,l.Ik)({conditions:(0,l.YO)((0,l.bz)())})),(0,l.kp)(x,(0,l.Ik)({actions:(0,l.YO)((0,l.bz)())}))]);class I extends((0,v.N)(o.WF)){renderContent(){var t,i,a,e,s,n,l;return(0,o.qy)(C||(C=V` ${0} <div class="header"> <h2 id="triggers-heading" class="name"> ${0} </h2> </div> ${0} <ha-automation-trigger role="region" aria-labelledby="triggers-heading" .triggers="${0}" .highlightedTriggers="${0}" @value-changed="${0}" .hass="${0}" .editorDirty="${0}" .disabled="${0}" .narrow="${0}" @open-sidebar="${0}" @request-close-sidebar="${0}" @close-sidebar="${0}" root sidebar></ha-automation-trigger> <div class="header"> <h2 id="conditions-heading" class="name"> ${0} <span class="small">(${0})</span> </h2> </div> ${0} <ha-automation-condition role="region" aria-labelledby="conditions-heading" .conditions="${0}" .highlightedConditions="${0}" @value-changed="${0}" .hass="${0}" .editorDirty="${0}" .disabled="${0}" .narrow="${0}" @open-sidebar="${0}" @request-close-sidebar="${0}" @close-sidebar="${0}" root sidebar></ha-automation-condition> <div class="header"> <h2 id="actions-heading" class="name"> ${0} </h2> </div> ${0} <ha-automation-action role="region" aria-labelledby="actions-heading" .actions="${0}" .highlightedActions="${0}" @value-changed="${0}" @open-sidebar="${0}" @request-close-sidebar="${0}" @close-sidebar="${0}" .hass="${0}" .editorDirty="${0}" .narrow="${0}" .disabled="${0}" root sidebar></ha-automation-action> `),this.config.description?(0,o.qy)(A||(A=V`<ha-markdown class="description" breaks .content="${0}"></ha-markdown>`),this.config.description):o.s6,this.hass.localize("ui.panel.config.automation.editor.triggers.header"),null!==(t=(0,r.e)(this.config.triggers))&&void 0!==t&&t.length?o.s6:(0,o.qy)(k||(k=V`<p> ${0} </p>`),this.hass.localize("ui.panel.config.automation.editor.triggers.description")),this.config.triggers||[],null===(i=this.pastedConfig)||void 0===i?void 0:i.triggers,this._triggerChanged,this.hass,this.dirty,this.disabled||this.saving,this.narrow,this.openSidebar,this.triggerCloseSidebar,this.handleCloseSidebar,this.hass.localize("ui.panel.config.automation.editor.conditions.header"),this.hass.localize("ui.common.optional"),null!==(a=(0,r.e)(this.config.conditions))&&void 0!==a&&a.length?o.s6:(0,o.qy)(H||(H=V`<p> ${0} </p>`),this.hass.localize("ui.panel.config.automation.editor.conditions.description",{user:(null===(e=this.hass.user)||void 0===e?void 0:e.name)||"Alice"})),this.config.conditions||[],null===(s=this.pastedConfig)||void 0===s?void 0:s.conditions,this._conditionChanged,this.hass,this.dirty,this.disabled||this.saving,this.narrow,this.openSidebar,this.triggerCloseSidebar,this.handleCloseSidebar,this.hass.localize("ui.panel.config.automation.editor.actions.header"),null!==(n=(0,r.e)(this.config.actions))&&void 0!==n&&n.length?o.s6:(0,o.qy)(z||(z=V`<p> ${0} </p>`),this.hass.localize("ui.panel.config.automation.editor.actions.description")),this.config.actions||[],null===(l=this.pastedConfig)||void 0===l?void 0:l.actions,this._actionChanged,this.openSidebar,this.triggerCloseSidebar,this.handleCloseSidebar,this.hass,this.dirty,this.narrow,this.disabled||this.saving)}saveConfig(){(0,d.r)(this,"save-automation")}_triggerChanged(t){t.stopPropagation(),this.resetPastedConfig(),(0,d.r)(this,"value-changed",{value:Object.assign(Object.assign({},this.config),{},{triggers:t.detail.value})})}_conditionChanged(t){t.stopPropagation(),this.resetPastedConfig(),(0,d.r)(this,"value-changed",{value:Object.assign(Object.assign({},this.config),{},{conditions:t.detail.value})})}_actionChanged(t){t.stopPropagation(),this.resetPastedConfig(),(0,d.r)(this,"value-changed",{value:Object.assign(Object.assign({},this.config),{},{actions:t.detail.value})})}_appendToExistingConfig(t){this.pastedConfig=t;const i=Object.assign({},this.config);i&&("triggers"in t&&(i.triggers=(0,r.e)(i.triggers||[]).concat((0,r.e)(t.triggers))),"conditions"in t&&(i.conditions=(0,r.e)(i.conditions||[]).concat((0,r.e)(t.conditions))),"actions"in t&&(i.actions=(0,r.e)(i.actions||[]).concat((0,r.e)(t.actions))),this.showPastedToastWithUndo(),(0,d.r)(this,"value-changed",{value:Object.assign({},i)}))}showPastedToastWithUndo(){(0,m.c)(this,{message:this.hass.localize("ui.panel.config.automation.editor.paste_toast_message"),duration:4e3,action:{text:this.hass.localize("ui.common.undo"),action:()=>{(0,d.r)(this,"undo-change"),this.pastedConfig=void 0}}})}static get styles(){return[y.T_,y.qK,(0,o.AH)(M||(M=V`p{margin-top:0}.header{display:flex;align-items:center}.header:first-child{margin-top:-16px}.header .name{font-weight:var(--ha-font-weight-normal);flex:1;margin-bottom:8px}.header .small{font-size:small;font-weight:var(--ha-font-weight-normal);line-height:0}.description{margin-top:16px}`))]}constructor(...t){super(...t),this.handlePaste=async t=>{var i;if(!(0,h.u)(t.composedPath()))return;const a=null===(i=t.clipboardData)||void 0===i?void 0:i.getData("text");if(!a)return;let e;try{e=(0,s.Hh)(a)}catch(_){return void(0,m.c)(this,{message:this.hass.localize("ui.panel.config.automation.editor.paste_invalid_yaml"),duration:4e3,dismissable:!0})}if(!e||"object"!=typeof e)return;let o,n=e;if("automation"in n&&(n=n.automation,Array.isArray(n)&&(n=n[0])),Array.isArray(n))if(1===n.length)n=n[0];else{const t={triggers:[],conditions:[],actions:[]};let i=!1;n.forEach(a=>{(0,g.fo)(a)&&(i=!0,t.triggers.push(a)),(0,g.G3)(a)&&(i=!0,t.conditions.push(a)),"unknown"!==(0,p.pq)(a)&&(i=!0,t.actions.push(a))}),i&&(n=t)}(0,g.fo)(n)&&(n={triggers:[n]}),(0,g.G3)(n)&&(n={conditions:[n]}),"unknown"!==(0,p.pq)(n)&&(n={actions:[n]});try{o=(0,g.HB)(n)}catch(_){return}try{(0,l.vA)(o,L)}catch(_){return void(0,m.c)(this,{message:this.hass.localize("ui.panel.config.automation.editor.paste_invalid_config"),duration:4e3,dismissable:!0})}if(o){var d,c,u;t.preventDefault();const i=Object.keys(o).filter(t=>(0,r.e)(o[t]).length);if(1===i.length&&["triggers","conditions","actions"].includes(i[0])&&this.tryInsertAfterSelected(o[i[0]]))return void this.showPastedToastWithUndo();if(this.dirty||null!==(d=(0,r.e)(this.config.triggers))&&void 0!==d&&d.length||null!==(c=(0,r.e)(this.config.conditions))&&void 0!==c&&c.length||null!==(u=(0,r.e)(this.config.actions))&&void 0!==u&&u.length){if(!(await new Promise(t=>{(0,b.Z)(this,{domain:"automation",pastedConfig:o,onClose:()=>t(!1),onAppend:()=>{this._appendToExistingConfig(o),t(!1)},onReplace:()=>t(!0)})})))return}this.replaceExistingConfig(o)}}}}(0,e.Cg)([(0,n.MZ)({attribute:!1})],I.prototype,"stateObj",void 0),(0,e.Cg)([(0,n.YG)("ha-automation-action, ha-automation-condition")],I.prototype,"collapsableElements",void 0),I=(0,e.Cg)([(0,n.EM)("manual-automation-editor")],I),i()}catch(C){i(C)}})}}]);