1export const __webpack_ids__=["19094"];export const __webpack_modules__={54890:function(t,i,e){var a=e(73742),o=e(59048),s=e(26292),n=e(40141),r=e(6219),h=e(15459),l=e(16230),c=e(21202);e(53166),e(48017),e(86699);const d=t=>void 0!==t&&!n.tj.includes(t.state)&&!(0,l.rk)(t.state);class u extends o.oi{render(){if(!this.stateObj)return o.dy` <ha-switch disabled="disabled"></ha-switch> `;if(this.stateObj.attributes.assumed_state||this.stateObj.state===l.lz)return o.dy` <ha-icon-button .label="${`Turn ${(0,h.C)(this.stateObj)} off`}" .path="${"M17,10H13L17,2H7V4.18L15.46,12.64M3.27,3L2,4.27L7,9.27V13H10V22L13.58,15.86L17.73,20L19,18.73L3.27,3Z"}" .disabled="${this.stateObj.state===l.nZ}" @click="${this._turnOff}" class="${this._isOn||this.stateObj.state===l.lz?"":"state-active"}"></ha-icon-button> <ha-icon-button .label="${`Turn ${(0,h.C)(this.stateObj)} on`}" .path="${"M7,2V13H10V22L17,10H13L17,2H7Z"}" .disabled="${this.stateObj.state===l.nZ}" @click="${this._turnOn}" class="${this._isOn?"state-active":""}"></ha-icon-button> `;const t=o.dy`<ha-switch aria-label="${`Toggle ${(0,h.C)(this.stateObj)} ${this._isOn?"off":"on"}`}" .checked="${this._isOn}" .disabled="${this.stateObj.state===l.nZ}" @change="${this._toggleChanged}"></ha-switch>`;return this.label?o.dy` <ha-formfield .label="${this.label}">${t}</ha-formfield> `:t}firstUpdated(t){super.firstUpdated(t),this.addEventListener("click",t=>t.stopPropagation())}willUpdate(t){super.willUpdate(t),t.has("stateObj")&&(this._isOn=d(this.stateObj))}_toggleChanged(t){const i=t.target.checked;i!==this._isOn&&this._callService(i)}_turnOn(){this._callService(!0)}_turnOff(){this._callService(!1)}async _callService(t){if(!this.hass||!this.stateObj)return;(0,c.j)("light");const i=(0,r.N)(this.stateObj);let e,a;"lock"===i?(e="lock",a=t?"unlock":"lock"):"cover"===i?(e="cover",a=t?"open_cover":"close_cover"):"valve"===i?(e="valve",a=t?"open_valve":"close_valve"):"group"===i?(e="homeassistant",a=t?"turn_on":"turn_off"):(e=i,a=t?"turn_on":"turn_off");const o=this.stateObj;this._isOn=t,await this.hass.callService(e,a,{entity_id:this.stateObj.entity_id}),setTimeout(async()=>{this.stateObj===o&&(this._isOn=d(this.stateObj))},2e3)}constructor(...t){super(...t),this._isOn=!1}}u.styles=o.iv`:host{white-space:nowrap;min-width:38px}ha-icon-button{--mdc-icon-button-size:40px;color:var(--ha-icon-button-inactive-color,var(--primary-text-color));transition:color .5s}ha-icon-button.state-active{color:var(--ha-icon-button-active-color,var(--primary-color))}ha-switch{padding:13px 5px}`,(0,a.__decorate)([(0,s.Cb)({attribute:!1})],u.prototype,"stateObj",void 0),(0,a.__decorate)([(0,s.Cb)()],u.prototype,"label",void 0),(0,a.__decorate)([(0,s.SB)()],u.prototype,"_isOn",void 0),u=(0,a.__decorate)([(0,s.Mo)("ha-entity-toggle")],u)},39046:function(t,i,e){var a=e(73742),o=e(50604),s=e(26292);class n extends o.Z{constructor(...t){super(...t),this.name="fadeIn",this.fill="both",this.play=!0,this.iterations=1}}(0,a.__decorate)([(0,s.Cb)()],n.prototype,"name",void 0),(0,a.__decorate)([(0,s.Cb)()],n.prototype,"fill",void 0),(0,a.__decorate)([(0,s.Cb)({type:Boolean})],n.prototype,"play",void 0),(0,a.__decorate)([(0,s.Cb)({type:Number})],n.prototype,"iterations",void 0),n=(0,a.__decorate)([(0,s.Mo)("ha-fade-in")],n)},14737:function(t,i,e){e.a(t,async function(t,i){try{var a=e(73742),o=(e(98334),e(59048)),s=e(26292),n=(e(12942),e(45861),e(80972)),r=e(44139),h=t([r]);r=(h.then?(await h)():h)[0];class l extends r.k{get _config(){return this.config}render(){return o.dy` ${"off"===this.stateObj?.state?o.dy` <ha-alert alert-type="info"> ${this.hass.localize("ui.panel.config.automation.editor.disabled")} <mwc-button slot="action" @click="${this._enable}"> ${this.hass.localize("ui.panel.config.automation.editor.enable")} </mwc-button> </ha-alert> `:""} ${this.config.description?o.dy`<ha-markdown class="description" breaks .content="${this.config.description}"></ha-markdown>`:o.Ld} ${this.renderCard()} `}async _getBlueprints(){this._blueprints=await(0,n.wc)(this.hass,"automation")}async _enable(){this.hass&&this.stateObj&&await this.hass.callService("automation","turn_on",{entity_id:this.stateObj.entity_id})}}(0,a.__decorate)([(0,s.Cb)({attribute:!1})],l.prototype,"config",void 0),(0,a.__decorate)([(0,s.Cb)({attribute:!1})],l.prototype,"stateObj",void 0),l=(0,a.__decorate)([(0,s.Mo)("blueprint-automation-editor")],l),i()}catch(t){i(t)}})},93841:function(t,i,e){e.a(t,async function(t,i){try{e(81738),e(29981),e(22960),e(6989);var a=e(73742),o=e(72644),s=(e(98334),e(59048)),n=e(26292),r=e(31733),h=e(95068),l=e(39884),c=e(67050),d=e(97050),u=e(61036),m=e(65863),p=(e(41037),e(80471),e(39046),e(46358),e(48017),e(69760),e(6514)),_=(e(993),e(43109),e(10142)),g=e(80972),f=e(13080),y=e(97133),b=e(16230),v=e(70947),$=e(72242),C=e(99469),w=(e(51869),e(43698)),A=e(27295),k=e(95814),x=e(35982),z=e(48753),L=(e(3301),e(71541)),H=e(18942),M=e(14737),V=e(37373),S=t([p,M,V]);[p,M,V]=S.then?(await S)():S;const I="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",E="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",O="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",B="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",j="M19,4H15.5L14.5,3H9.5L8.5,4H5V6H19M6,19A2,2 0 0,0 8,21H16A2,2 0 0,0 18,19V7H6V19Z",R="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",U="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",Z="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",P="M8,5.14V19.14L19,12.14L8,5.14Z",T="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",D="M3 6V8H14V6H3M3 10V12H14V10H3M20 10.
11C19.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",W="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",F="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",N="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",q="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",Q="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 Y extends((0,A.C)((0,w.U)(s.oi))){willUpdate(t){if(super.willUpdate(t),this._entityRegCreated&&this._newAutomationId&&t.has("_entityRegistry")){const t=this._entityRegistry.find(t=>"automation"===t.platform&&t.unique_id===this._newAutomationId);t&&(this._entityRegCreated(t),this._entityRegCreated=void 0)}}render(){if(!this._config)return s.dy` <ha-fade-in .delay="${500}"> <ha-spinner size="large"></ha-spinner> </ha-fade-in> `;const t=this._entityId?this.hass.states[this._entityId]:void 0,i="use_blueprint"in this._config;return s.dy` <hass-subpage .hass="${this.hass}" .narrow="${this.narrow}" .route="${this.route}" .backCallback="${this._backTapped}" .header="${this._config.alias||this.hass.localize("ui.panel.config.automation.editor.default_name")}"> ${this._config?.id&&!this.narrow?s.dy` <mwc-button @click="${this._showTrace}" slot="toolbar-icon"> ${this.hass.localize("ui.panel.config.automation.editor.show_trace")} </mwc-button> `:""} <ha-button-menu slot="toolbar-icon"> <ha-icon-button slot="trigger" .label="${this.hass.localize("ui.common.menu")}" .path="${R}"></ha-icon-button> <ha-list-item graphic="icon" .disabled="${!t}" @click="${this._showInfo}"> ${this.hass.localize("ui.panel.config.automation.editor.show_info")} <ha-svg-icon slot="graphic" .path="${Z}"></ha-svg-icon> </ha-list-item> <ha-list-item graphic="icon" .disabled="${!t}" @click="${this._showSettings}"> ${this.hass.localize("ui.panel.config.automation.picker.show_settings")} <ha-svg-icon slot="graphic" .path="${I}"></ha-svg-icon> </ha-list-item> <ha-list-item graphic="icon" .disabled="${!t}" @click="${this._editCategory}"> ${this.hass.localize("ui.panel.config.scene.picker."+(this._registryEntry?.categories?.automation?"edit_category":"assign_category"))} <ha-svg-icon slot="graphic" .path="${q}"></ha-svg-icon> </ha-list-item> <ha-list-item graphic="icon" .disabled="${!t}" @click="${this._runActions}"> ${this.hass.localize("ui.panel.config.automation.editor.run")} <ha-svg-icon slot="graphic" .path="${P}"></ha-svg-icon> </ha-list-item> ${t&&this.narrow?s.dy`<a href="/config/automation/trace/${encodeURIComponent(this._config.id)}"> <ha-list-item graphic="icon"> ${this.hass.localize("ui.panel.config.automation.editor.show_trace")} <ha-svg-icon slot="graphic" .path="${Q}"></ha-svg-icon> </ha-list-item> </a>`:s.Ld} <ha-list-item graphic="icon" @click="${this._promptAutomationAlias}" .disabled="${this._readOnly||!this.automationId||"yaml"===this._mode}"> ${this.hass.localize("ui.panel.config.automation.editor.rename")} <ha-svg-icon slot="graphic" .path="${W}"></ha-svg-icon> </ha-list-item>
1 ${i?s.Ld:s.dy` <ha-list-item graphic="icon" @click="${this._promptAutomationMode}" .disabled="${this._readOnly||"yaml"===this._mode}"> ${this.hass.localize("ui.panel.config.automation.editor.change_mode")} <ha-svg-icon slot="graphic" .path="${B}"></ha-svg-icon> </ha-list-item> `} <ha-list-item .disabled="${this._blueprintConfig||!this._readOnly&&!this.automationId}" graphic="icon" @click="${this._duplicate}"> ${this.hass.localize(this._readOnly?"ui.panel.config.automation.editor.migrate":"ui.panel.config.automation.editor.duplicate")} <ha-svg-icon slot="graphic" .path="${E}"></ha-svg-icon> </ha-list-item> ${i?s.dy` <ha-list-item graphic="icon" @click="${this._takeControl}" .disabled="${this._readOnly}"> ${this.hass.localize("ui.panel.config.automation.editor.take_control")} <ha-svg-icon slot="graphic" .path="${U}"></ha-svg-icon> </ha-list-item> `:s.Ld} <ha-list-item graphic="icon" @click="${"gui"===this._mode?this._switchYamlMode:this._switchUiMode}"> ${this.hass.localize("ui.panel.config.automation.editor.edit_"+("gui"===this._mode?"yaml":"ui"))} <ha-svg-icon slot="graphic" .path="${D}"></ha-svg-icon> </ha-list-item> <li divider role="separator"></li> <ha-list-item graphic="icon" .disabled="${!t}" @click="${this._toggle}"> ${"off"===t?.state?this.hass.localize("ui.panel.config.automation.editor.enable"):this.hass.localize("ui.panel.config.automation.editor.disable")} <ha-svg-icon slot="graphic" .path="${"off"===t?.state?T:N}"></ha-svg-icon> </ha-list-item> <ha-list-item .disabled="${!this.automationId}" class="${(0,r.$)({warning:Boolean(this.automationId)})}" graphic="icon" @click="${this._deleteConfirm}"> ${this.hass.localize("ui.panel.config.automation.picker.delete")} <ha-svg-icon class="${(0,r.$)({warning:Boolean(this.automationId)})}" slot="graphic" .path="${j}"> </ha-svg-icon> </ha-list-item> </ha-button-menu> <div class="content ${(0,r.$)({"yaml-mode":"yaml"===this._mode})}" @subscribe-automation-config="${this._subscribeAutomationConfig}"> ${this._errors||t?.state===b.nZ?s.dy`<ha-alert alert-type="error" .title="${t?.state===b.nZ?this.hass.localize("ui.panel.config.automation.editor.unavailable"):void 0}"> ${this._errors||this._validationErrors} ${t?.state===b.nZ?s.dy`<ha-svg-icon slot="icon" .path="${F}"></ha-svg-icon>`:s.Ld} </ha-alert>`:""} ${this._blueprintConfig?s.dy`<ha-alert alert-type="info"> ${this.hass.localize("ui.panel.config.automation.editor.confirm_take_control")} <div slot="action" style="display:flex"> <mwc-button @click="${this._takeControlSave}">${this.hass.localize("ui.common.yes")}</mwc-button> <mwc-button @click="${this._revertBlueprint}">${this.hass.localize("ui.common.no")}</mwc-button> </div> </ha-alert>`:this._readOnly?s.dy`<ha-alert alert-type="warning" dismissable>${this.hass.localize("ui.panel.config.automation.editor.read_only")} <mwc-button slot="action" @click="${this._duplicate}"> ${this.hass.localize("ui.panel.config.automation.editor.migrate")} </mwc-button> </ha-alert>`:s.Ld} ${"gui"===this._mode?s.dy` <div class="${(0,r.$)({rtl:(0,d.HE)(this.hass)})}"> ${i?s.dy` <blueprint-automation-editor .hass="${this.hass}" .narrow="${this.narrow}" .isWide="${this.isWide}" .stateObj="${t}" .config="${this._config}" .disabled="${Boolean(this._readOnly)}" @value-changed="${this._valueChanged}"></blueprint-automation-editor> `:s.dy` <manual-automation-editor .hass="${this.hass}" .narrow="${this.narrow}" .isWide="${this.isWide}" .stateObj="${t}" .config="${this._config}" .disabled="${Boolean(this._readOnly)}" .dirty="${this._dirty}" @value-changed="${this._valueChanged}"></manual-automation-editor> `} </div> `:"yaml"===this._mode?s.dy`${"off"===t?.state?s.dy` <ha-alert alert-type="info"> ${this.hass.localize("ui.panel.config.automation.editor.disabled")} <mwc-button slot="action" @click="${this._toggle}"> ${this.hass.localize("ui.panel.config.automation.editor.enable")} </mwc-button> </ha-alert> `:""} <ha-yaml-editor copy-clipboard .hass="${this.hass}" .defaultValue="${this._preprocessYaml()}" .readOnly="${this._readOnly}" @value-changed="${this._yamlChanged}" .showErrors="${!1}" disable-fullscreen></ha-yaml-editor>`:s.Ld} </div> <ha-fab slot="fab" class="${(0,r.$)({dirty:!this._readOnly&&this._dirty})}" .label="${this.hass.localize("ui.panel.config.automation.editor.save")}" .disabled="${this._saving}" extended @click="${this._handleSaveAutomation}"> <ha-svg-icon slot="icon" .path="${O}"></ha-svg-icon> </ha-fab> </hass-subpage> `}updated(t){super.updated(t);const i=t.get("automationId");if(t.has("automationId")&&this.automationId&&this.hass&&i!==this.automationId&&(this._setEntityId(),this._loadConfig()),t.has("automationId")&&!this.automationId&&!this.entity
1Id&&this.hass){const t=(0,_.Pl)();let i={description:""};t&&"use_blueprint"in t||(i={...i,mode:"single",triggers:[],conditions:[],actions:[]}),this._config={...i,...t?(0,_.EQ)(t):t},this._entityId=void 0,this._readOnly=!1}t.has("entityId")&&this.entityId&&((0,_.SQ)(this.hass,this.entityId).then(t=>{this._config=(0,_.EQ)(t.config),this._checkValidation()}),this._entityId=this.entityId,this._dirty=!1,this._readOnly=!0),t.has("automations")&&this.automationId&&!this._entityId&&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._entityId=t?.entity_id}async _checkValidation(){if(this._validationErrors=void 0,!this._entityId||!this._config)return;const t=this.hass.states[this._entityId];if(t?.state!==b.nZ)return;const i=await(0,f.w)(this.hass,{triggers:this._config.triggers,conditions:this._config.conditions,actions:this._config.actions});this._validationErrors=Object.entries(i).map(([t,i])=>i.valid?"":s.dy`${this.hass.localize(`ui.panel.config.automation.editor.${t}.name`)}: ${i.error}<br>`)}async _loadConfig(){try{const t=await(0,_.r4)(this.hass,this.automationId);this._dirty=!1,this._readOnly=!1,this._config=(0,_.EQ)(t),this._checkValidation()}catch(t){const i=this._entityRegistry.find(t=>"automation"===t.platform&&t.unique_id===this.automationId);if(i)return void(0,c.c)(`/config/automation/show/${i.entity_id}`,{replace:!0});await(0,$.showAlertDialog)(this,{text:404===t.status_code?this.hass.localize("ui.panel.config.automation.editor.load_error_not_editable"):this.hass.localize("ui.panel.config.automation.editor.load_error_unknown",{err_no:t.status_code})}),history.back()}}_valueChanged(t){t.stopPropagation(),this._config=t.detail.value,this._readOnly||(this._dirty=!0,this._errors=void 0)}_showInfo(){this.hass&&this._entityId&&(0,l.B)(this,"hass-more-info",{entityId:this._entityId})}_showSettings(){(0,C.A)(this,{entityId:this._entityId,view:"settings"})}_editCategory(){this._registryEntry?(0,z.U)(this,{scope:"automation",entityReg:this._registryEntry}):(0,$.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(){if(this._config?.id){await this._confirmUnsavedChanged()&&(0,c.c)(`/config/automation/trace/${encodeURIComponent(this._config.id)}`)}}_runActions(){this.hass&&this._entityId&&(0,_.Es)(this.hass,this.hass.states[this._entityId].entity_id)}async _toggle(){if(!this.hass||!this._entityId)return;const t=this.hass.states[this._entityId],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={...this._config};return delete t.id,t}_yamlChanged(t){t.stopPropagation(),this._dirty=!0,t.detail.isValid?(this._yamlErrors=void 0,this._config={id:this._config?.id,...(0,_.EQ)(t.detail.value)},this._errors=void 0):this._yamlErrors=t.detail.errorMsg}async _confirmUnsavedChanged(){return!this._dirty||new Promise(t=>{(0,H.h)(this,{config:this._config,domain:"automation",updateConfig:async(i,e)=>{this._config=i,this._entityRegistryUpdate=e,this._dirty=!0,this.requestUpdate();const a=this.automationId||String(Date.now());try{await this._saveAutomation(a)}catch(i){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 i=await(0,g.Uk)(this.hass,"automation",t.use_blueprint.path,t.use_blueprint.input||{}),e={...(0,_.EQ)(i.substituted_config),id:t.id,alias:t.alias,description:t.description};this._blueprintConfig=t,this._config=e,"yaml"===this._mode&&this.renderRoot.querySelector("ha-yaml-editor")?.setValue(this._config),this._readOnly=!0,this._errors=void 0}catch(t){this._errors=t.message}}_revertBlueprint(){this._config=this._blueprintConfig,"yaml"===this._mode&&this.renderRoot.querySelector("ha-yaml-editor")?.setValue(this._config),this._blueprintConfig=void 0,this._readOnly=!1}_takeControlSave(){this._readOnly=!1,this._dirty=!0,this._blueprintConfig=void 0}async _duplicate(){(this._readOnly?await(0,$.showConfirmationDialog)(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,_.Ip)({...this._config,id:void 0,alias:this._readOnly?this._config?.alias:void 0})}async _deleteConfirm(){(0,$.showConfirmationDialog)(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:this._config?.alias}
1),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,_.SC)(this.hass,this.automationId),history.back())}async _switchUiMode(){if(this._yamlErrors){if(!await(0,$.showConfirmationDialog)(this,{text:s.dy`${this.hass.localize("ui.panel.config.automation.editor.switch_ui_yaml_error")}<br><br>${this._yamlErrors}`,confirmText:this.hass.localize("ui.common.continue"),destructive:!0,dismissText:this.hass.localize("ui.common.cancel")}))return}this._yamlErrors=void 0,this._mode="gui"}_switchYamlMode(){this._mode="yaml"}async _promptAutomationAlias(){return new Promise(t=>{(0,H.h)(this,{config:this._config,domain:"automation",updateConfig:async(i,e)=>{this._config=i,this._entityRegistryUpdate=e,this._dirty=!0,this.requestUpdate(),t(!0)},onClose:()=>t(!1),entityRegistryUpdate:this._entityRegistryUpdate,entityRegistryEntry:this._registryEntry})})}async _promptAutomationMode(){return new Promise(t=>{(0,L.q)(this,{config:this._config,updateConfig:i=>{this._config=i,this._dirty=!0,this.requestUpdate(),t()},onClose:()=>t()})})}async _handleSaveAutomation(){if(this._yamlErrors)return void(0,x.C)(this,{message:this._yamlErrors});this._manualEditor?.resetPastedConfig();const t=this.automationId||String(Date.now());if(!this.automationId){if(!await this._promptAutomationAlias())return}await this._saveAutomation(t),this.automationId||(0,c.c)(`/config/automation/edit/${t}`,{replace:!0})}async _saveAutomation(t){let i;this._saving=!0,this._validationErrors=void 0,void 0===this._entityRegistryUpdate||this._entityId||(this._newAutomationId=t,i=new Promise(t=>{this._entityRegCreated=t}));try{if(await(0,_.sq)(this.hass,t,this._config),void 0!==this._entityRegistryUpdate){let t=this._entityId;if(i)try{t=(await(0,u.n)(5e3,i)).entity_id}catch(t){if(!(t instanceof Error&&"TimeoutError"===t.name))throw t;(0,$.showAlertDialog)(this,{title:this.hass.localize("ui.panel.config.automation.editor.new_automation_setup_failed_title",{type:this.hass.localize("ui.panel.config.automation.editor.type_automation")}),text:this.hass.localize("ui.panel.config.automation.editor.new_automation_setup_failed_text",{type:this.hass.localize("ui.panel.config.automation.editor.type_automation"),types:this.hass.localize("ui.panel.config.automation.editor.type_automation_plural")}),warning:!0})}t&&await(0,v.Nv)(this.hass,t,{categories:{automation:this._entityRegistryUpdate.category||null},labels:this._entityRegistryUpdate.labels||[],area_id:this._entityRegistryUpdate.area||null})}this._dirty=!1}catch(t){throw this._errors=t.body?.message||t.error||t.body,(0,x.C)(this,{message:t.body?.message||t.error||t.body}),t}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()}}get isDirty(){return this._dirty}async promptDiscardChanges(){return this._confirmUnsavedChanged()}static get styles(){return[k.Qx,s.iv`ha-fade-in{display:flex;justify-content:center;align-items:center;height:100%}.content{padding-bottom:20px}.yaml-mode{height:100%;display:flex;flex-direction:column;padding-bottom:0}:not(.yaml-mode)>ha-alert,blueprint-automation-editor,manual-automation-editor{margin:0 auto;max-width:1040px;padding:28px 20px 0;display:block}ha-yaml-editor{flex-grow:1;--actions-border-radius:0;--code-mirror-height:100%;min-height:0;display:flex;flex-direction:column}p{margin-bottom:0}ha-entity-toggle{margin-right:8px;margin-inline-end:8px;margin-inline-start:initial}ha-fab{position:relative;bottom:calc(-80px - var(--safe-area-inset-bottom));transition:bottom .3s}ha-fab.dirty{bottom:0}li[role=separator]{border-bottom-color:var(--divider-color)}ha-button-menu a{text-decoration:none;color:var(--primary-color)}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.entity
1Id=null,this.isWide=!1,this.narrow=!1,this._dirty=!1,this._mode="gui",this._readOnly=!1,this._saving=!1,this._configSubscriptions={},this._configSubscriptionsId=1,this._backTapped=async()=>{await this._confirmUnsavedChanged()&&(0,m.T)(()=>history.back())}}}(0,a.__decorate)([(0,n.Cb)({attribute:!1})],Y.prototype,"hass",void 0),(0,a.__decorate)([(0,n.Cb)({attribute:!1})],Y.prototype,"automationId",void 0),(0,a.__decorate)([(0,n.Cb)({attribute:!1})],Y.prototype,"entityId",void 0),(0,a.__decorate)([(0,n.Cb)({attribute:!1})],Y.prototype,"automations",void 0),(0,a.__decorate)([(0,n.Cb)({attribute:"is-wide",type:Boolean})],Y.prototype,"isWide",void 0),(0,a.__decorate)([(0,n.Cb)({type:Boolean})],Y.prototype,"narrow",void 0),(0,a.__decorate)([(0,n.Cb)({attribute:!1})],Y.prototype,"route",void 0),(0,a.__decorate)([(0,n.SB)()],Y.prototype,"_config",void 0),(0,a.__decorate)([(0,n.SB)()],Y.prototype,"_dirty",void 0),(0,a.__decorate)([(0,n.SB)()],Y.prototype,"_errors",void 0),(0,a.__decorate)([(0,n.SB)()],Y.prototype,"_yamlErrors",void 0),(0,a.__decorate)([(0,n.SB)()],Y.prototype,"_entity
1Id",void 0),(0,a.__decorate)([(0,n.SB)()],Y.prototype,"_mode",void 0),(0,a.__decorate)([(0,n.SB)()],Y.prototype,"_readOnly",void 0),(0,a.__decorate)([(0,n.SB)()],Y.prototype,"_validationErrors",void 0),(0,a.__decorate)([(0,n.SB)()],Y.prototype,"_blueprintConfig",void 0),(0,a.__decorate)([(0,n.SB)(),(0,o.F_)({context:y.we,subscribe:!0}),(0,h.v)({transformer:function(t){return t.find(({entity_id:t})=>t===this._entityId)},watch:["_entityId"]})],Y.prototype,"_registryEntry",void 0),(0,a.__decorate)([(0,n.SB)()],Y.prototype,"_saving",void 0),(0,a.__decorate)([(0,n.SB)(),(0,o.F_)({context:y.we,subscribe:!0})],Y.prototype,"_entityRegistry",void 0),(0,a.__decorate)([(0,n.IO)("manual-automation-editor")],Y.prototype,"_manualEditor",void 0),customElements.define("ha-automation-editor",Y),i()}catch(t){i(t)}})},58025:function(t,i,e){e.a(t,async function(t,i){try{e(2394),e(81738),e(33480),e(94814),e(29981),e(22960),e(6989),e(72489),e(67886),e(65451),e(46015),e(38334),e(94880),e(75643),e(29761),e(36330),e(38221),e(75863);var a=e(73742),o=e(64346),s=e(72644),n=e(7722),r=e(59048),h=e(26292),l=e(20480),c=e(28105),d=e(34394),u=e(37528),m=e(74266),p=e(68135),_=e(9924),g=e(39884),f=e(15459),y=e(67050),b=e(64264),v=(e(84447),e(11840),e(54890),e(80471),e(42946),e(64936),e(57894),e(23390)),$=(e(52036),e(81299),e(48017),e(57701),e(94092),e(92952),e(85775),e(993),e(85993)),C=e(10142),w=e(87932),A=e(97133),k=e(69992),x=e(16230),z=e(70947),L=e(27831),H=e(2528),M=e(72242),V=(e(42497),e(6291)),S=e(95814),I=e(42399),E=e(35390),O=e(2609),B=e(48753),j=e(65627),R=e(94590),U=e(54614),Z=e(74380),P=t([v,m,p]);[v,m,p]=P.then?(await P)():P;const T="M8.59,16.58L13.17,12L8.59,7.41L10,6L16,12L10,18L8.59,16.58Z",D="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",W="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",F="M19,4H15.5L14.5,3H9.5L8.5,4H5V6H19M6,19A2,2 0 0,0 8,21H16A2,2 0 0,0 18,19V7H6V19Z",N="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",q="M15.07,11.25L14.17,12.17C13.45,12.89 13,13.5 13,15H11V14.5C11,13.39 11.45,12.39 12.17,11.67L13.41,10.41C13.78,10.05 14,9.55 14,9C14,7.89 13.1,7 12,7A2,2 0 0,0 10,9H8A4,4 0 0,1 12,5A4,4 0 0,1 16,9C16,9.88 15.64,10.67 15.07,11.25M13,19H11V17H13M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12C22,6.47 17.5,2 12,2Z",Q="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",Y="M7,10L12,15L17,10H7Z",G="M8,5.14V19.14L19,12.14L8,5.14Z",X="M19,13H13V19H11V13H5V11H11V5H13V11H19V13Z",J="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 13
1S10 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",K="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",tt="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",it="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",et="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",at="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 ot extends((0,V.f)(r.oi)){hassSubscribe(){return[(0,w.U)(this.hass.connection,"automation",t=>{this._categories=t}),(0,L.f4)(this.hass.connection,t=>{this._labels=t})]}render(){const t=r.dy`${this._categories?.map(t=>r.dy`<ha-md-menu-item .value="${t.category_id}" .clickAction="${this._handleBulkCategory}"> ${t.icon?r.dy`<ha-icon slot="start" .icon="${t.icon}"></ha-icon>`:r.dy`<ha-svg-icon slot="start" .path="${K}"></ha-svg-icon>`} <div slot="headline">${t.name}</div> </ha-md-menu-item>`)} <ha-md-menu-item .value="${null}" .clickAction="${this._handleBulkCategory}"> <div slot="headline"> ${this.hass.localize("ui.panel.config.automation.picker.bulk_actions.no_category")} </div> </ha-md-menu-item> <ha-md-divider role="separator" tabindex="-1"></ha-md-divider> <ha-md-menu-item .clickAction="${this._bulkCreateCategory}"> <div slot="headline"> ${this.hass.localize("ui.panel.config.category.editor.add")} </div> </ha-md-menu-item>`,i=r.dy`${this._labels?.map(t=>{const i=t.color?(0,d.I)(t.color):void 0,e=this._selected.every(i=>this.hass.entities[i]?.labels.includes(t.label_id)),a=!e&&this._selected.some(i=>this.hass.entities[i]?.labels.includes(t.label_id));return r.dy`<ha-md-menu-item .value="${t.label_id}" .action="${e?"remove":"add"}" @click="${this._handleBulkLabel}" keep-open> <ha-checkbox slot="start" .checked="${e}" .indeterminate="${a}" reducedTouchTarget></ha-checkbox> <ha-label style="${i?`--color: ${i}`:""}"> ${t.icon?r.dy`<ha-icon slot="icon" .icon="${t.icon}"></ha-icon>`:r.Ld} ${t.name} </ha-label> </ha-md-menu-item>`})} <ha-md-divider role="separator" tabindex="-1"></ha-md-divider> <ha-md-menu-item .clickAction="${this._bulkCreateLabel}"> <div slot="headline"> ${this.hass.localize("ui.panel.config.labels.add_label")} </div></ha-md-menu-item>`,e=r.dy`${Object.values(this.hass.areas).map(t=>r.dy`<ha-md-menu-item .value="${t.area_id}" .clickAction="${this._handleBulkArea}"> ${t.icon?r.dy`<ha-icon slot="start" .icon="${t.icon}"></ha-icon>`:r.dy`<ha-svg-icon slot="start" .path="${tt}"></ha-svg-icon>`} <div slot="headline">${t.name}</div> </ha-md-menu-item>`)} <ha-md-menu-item .value="${null}" .clickAction="${this._handleBulkArea}"> <div slot="headline"> ${this.hass.localize("ui.panel.config.devices.picker.bulk_actions.no_area")} </div> </ha-md-menu-item> <ha-md-divider role="separator" tabindex="-1"></ha-md-divider> <ha-md-menu-item .clickAction="${this._bulkCreateArea}"> <div slot="headline"> ${this.hass.localize("ui.panel.config.devices.picker.bulk_actions.add_area")} </div> </ha-md-menu-item>`,a=this._sizeController.value&&this._sizeController.value<900||!this._sizeController.value&&"docked"===this.hass.dockedSidebar,o=a&&(!this._sizeController.value||this._sizeController.value<700),s=this._automations(this.automations,this._entityReg,this.hass.areas,this._categories,this._labels,this._filteredAutomations);return r.dy` <hass-tabs-subpage-data-table .hass="${this.hass}" .narrow="${this.narrow}" .backPath="${this._searchParms.has("historyBack")?void 0:"/config"}" id="entity_id" .route="${this.route}" .tabs="${R.configSections.automations}" .searchLabel="${this.hass.localize("ui.panel.config.automation.picker.search",{number:s.length})}" selectable .selected="${this._selected.length}" @selection-changed="${this._handleSelectionChanged}" has-filters .filters="${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}" .columns="${this._columns(this.narrow,this.hass.localize,this.hass.locale)}" .initialGroupColumn="${this._activeGrouping??"category"}" .initialCollapsedGroups="${this._activeCollapsed}" .initialSorting="${this._activeSorting}" .columnOrder="${this._activeColumnOrder}" .hiddenColumns="${this._activeHiddenColumns}" @columns-changed="${this._handleColumnsChanged}" @sorting-changed="${this._handleSortingChanged}" @grouping-changed="${this._handleGroupingChanged}" @collapsed-changed="${this._handleCollapseChanged}" .data="${s}" .empty="${!this.automations.length}" @row-click="${this._handleRowClicked}" .noDataText="${this.hass.localize("ui.panel.config.automation.picker.no_automations")}" @clear-filter="${this._clearFilter}" .filter="${this._filter}
1" @search-changed="${this._handleSearchChange}" has-fab clickable class="${this.narrow?"narrow":""}"> <ha-icon-button slot="toolbar-icon" .label="${this.hass.localize("ui.common.help")}" .path="${q}" @click="${this._showHelp}"></ha-icon-button> <ha-filter-floor-areas .hass="${this.hass}" .type="${"automation"}" .value="${this._filters["ha-filter-floor-areas"]?.value}" @data-table-filter-changed="${this._filterChanged}" slot="filter-pane" .expanded="${"ha-filter-floor-areas"===this._expandedFilter}" .narrow="${this.narrow}" @expanded-changed="${this._filterExpanded}"></ha-filter-floor-areas> <ha-filter-devices .hass="${this.hass}" .type="${"automation"}" .value="${this._filters["ha-filter-devices"]?.value}" @data-table-filter-changed="${this._filterChanged}" slot="filter-pane" .expanded="${"ha-filter-devices"===this._expandedFilter}" .narrow="${this.narrow}" @expanded-changed="${this._filterExpanded}"></ha-filter-devices> <ha-filter-entities .hass="${this.hass}" .type="${"automation"}" .value="${this._filters["ha-filter-entities"]?.value}" @data-table-filter-changed="${this._filterChanged}" slot="filter-pane" .expanded="${"ha-filter-entities"===this._expandedFilter}" .narrow="${this.narrow}" @expanded-changed="${this._filterExpanded}"></ha-filter-entities> <ha-filter-labels .hass="${this.hass}" .value="${this._filters["ha-filter-labels"]?.value}" @data-table-filter-changed="${this._filterChanged}" slot="filter-pane" .expanded="${"ha-filter-labels"===this._expandedFilter}" .narrow="${this.narrow}" @expanded-changed="${this._filterExpanded}"></ha-filter-labels> <ha-filter-categories .hass="${this.hass}" scope="automation" .value="${this._filters["ha-filter-categories"]?.value}" @data-table-filter-changed="${this._filterChanged}" slot="filter-pane" .expanded="${"ha-filter-categories"===this._expandedFilter}" .narrow="${this.narrow}" @expanded-changed="${this._filterExpanded}"></ha-filter-categories> <ha-filter-blueprints .hass="${this.hass}" .type="${"automation"}" .value="${this._filters["ha-filter-blueprints"]?.value}" @data-table-filter-changed="${this._filterChanged}" slot="filter-pane" .expanded="${"ha-filter-blueprints"===this._expandedFilter}" .narrow="${this.narrow}" @expanded-changed="${this._filterExpanded}"></ha-filter-blueprints> ${this.narrow?r.Ld:r.dy`<ha-md-button-menu slot="selection-bar"> <ha-assist-chip slot="trigger" .label="${this.hass.localize("ui.panel.config.automation.picker.bulk_actions.move_category")}"> <ha-svg-icon slot="trailing-icon" .path="${Y}"></ha-svg-icon> </ha-assist-chip> ${t} </ha-md-button-menu> ${o?r.Ld:r.dy`<ha-md-button-menu slot="selection-bar"> <ha-assist-chip slot="trigger" .label="${this.hass.localize("ui.panel.config.automation.picker.bulk_actions.add_label")}"> <ha-svg-icon slot="trailing-icon" .path="${Y}"></ha-svg-icon> </ha-assist-chip> ${i} </ha-md-button-menu>`} ${a?r.Ld:r.dy`<ha-md-button-menu slot="selection-bar"> <ha-assist-chip slot="trigger" .label="${this.hass.localize("ui.panel.config.devices.picker.bulk_actions.move_area")}"> <ha-svg-icon slot="trailing-icon" .path="${Y}"></ha-svg-icon> </ha-assist-chip> ${e} </ha-md-button-menu>`}`} <ha-md-button-menu has-overflow slot="selection-bar"> ${this.narrow?r.dy`<ha-assist-chip .label="${this.hass.localize("ui.panel.config.automation.picker.bulk_action")}" slot="trigger"> <ha-svg-icon slot="trailing-icon" .path="${Y}"></ha-svg-icon> </ha-assist-chip>`:r.dy`<ha-icon-button .path="${N}" .label="${this.hass.localize("ui.panel.config.automation.picker.bulk_action")}" slot="trigger"></ha-icon-button>`} <ha-svg-icon slot="trailing-icon" .path="${Y}"></ha-svg-icon> ${this.narrow?r.dy`<ha-sub-menu> <ha-md-menu-item slot="item"> <div slot="headline"> ${this.hass.localize("ui.panel.config.automation.picker.bulk_actions.move_category")} </div> <ha-svg-icon slot="end" .path="${T}"></ha-svg-icon> </ha-md-menu-item> <ha-md-menu slot="menu">${t}</ha-md-menu> </ha-sub-menu>`:r.Ld} ${this.narrow||o?r.dy`<ha-sub-menu> <ha-md-menu-item slot="item"> <div slot="headline"> ${this.hass.localize("ui.panel.config.automation.picker.bulk_actions.add_label")} </div> <ha-svg-icon slot="end" .path="${T}"></ha-svg-icon> </ha-md-menu-item> <ha-md-menu slot="menu">${i}</ha-md-menu> </ha-sub-menu>`:r.Ld} ${this.narrow||a?r.dy`<ha-sub-menu> <ha-md-menu-item slot="item"> <div slot="headline"> ${this.hass.localize("ui.panel.config.devices.picker.bulk_actions.move_area")} </div> <ha-svg-icon slot="end" .path="${T}"></ha-svg-icon> </ha-md-menu-item> <ha-md-menu slot="menu">${e}</ha-md-menu> </ha-sub-menu>`:r.Ld} <ha-md-menu-item .clickAction="${this._handleBulkEnable}"> <ha-svg-icon slot="start" .path="${it}"></ha-svg-icon> <div slot="headline"> ${this.hass.localize("ui.panel.config.automation.picker.bulk_actions.enable")} </div> </ha-md-menu-item> <ha-md-menu-item .clickAction="${this._handleBulkDisable}"> <ha-svg-icon slot="start" .path="${et}"></ha-svg-icon> <div slot="headline"> ${this.hass.localize("ui.panel.config.automation.picker.bulk_actions.disable")} </div> </ha-md-menu-item> </ha-md-button-menu> ${this.automations.length?r.Ld:r.dy`<div class="empty" slot="empty"> <ha-svg-icon .path="${J}"></ha-svg-icon> <h1> ${this.hass.localize("ui.panel.config.automation.picker.empty_header")} </h1> <p> ${this.hass.localize("ui.panel.config.automation.picker.empty_text_1")} </p> <p> ${this.hass.localize("ui.panel.config.automation.picker.empty_text_2",{user:this.hass.user?.name||"Alice"})} </p> <a href="${(0,I.R)(this.hass,"/docs/automation/editor/")}" target="_blank" rel="noreferrer"> <ha-button>
1 ${this.hass.localize("ui.panel.config.common.learn_more")} </ha-button> </a> </div>`} <ha-fab slot="fab" .label="${this.hass.localize("ui.panel.config.automation.picker.add_automation")}" extended @click="${this._createNew}"> <ha-svg-icon slot="icon" .path="${X}"></ha-svg-icon> </ha-fab> </hass-tabs-subpage-data-table> <ha-md-menu id="overflow-menu" positioning="fixed"> <ha-md-menu-item .clickAction="${this._showInfo}"> <ha-svg-icon .path="${Q}" slot="start"></ha-svg-icon> <div slot="headline"> ${this.hass.localize("ui.panel.config.automation.editor.show_info")} </div> </ha-md-menu-item> <ha-md-menu-item .clickAction="${this._showSettings}"> <ha-svg-icon .path="${D}" slot="start"></ha-svg-icon> <div slot="headline"> ${this.hass.localize("ui.panel.config.automation.picker.show_settings")} </div> </ha-md-menu-item> <ha-md-menu-item .clickAction="${this._editCategory}"> <ha-svg-icon .path="${K}" slot="start"></ha-svg-icon> <div slot="headline"> ${this.hass.localize("ui.panel.config.automation.picker."+(this._overflowAutomation?.category?"edit_category":"assign_category"))} </div> </ha-md-menu-item> <ha-md-menu-item .clickAction="${this._runActions}"> <ha-svg-icon .path="${G}" slot="start"></ha-svg-icon> <div slot="headline"> ${this.hass.localize("ui.panel.config.automation.editor.run")} </div> </ha-md-menu-item> <ha-md-menu-item .clickAction="${this._showTrace}"> <ha-svg-icon .path="${at}" slot="start"></ha-svg-icon> <div slot="headline"> ${this.hass.localize("ui.panel.config.automation.editor.show_trace")} </div> </ha-md-menu-item> <ha-md-divider role="separator" tabindex="-1"></ha-md-divider> <ha-md-menu-item .clickAction="${this._duplicate}"> <ha-svg-icon .path="${W}" slot="start"></ha-svg-icon> <div slot="headline"> ${this.hass.localize("ui.panel.config.automation.picker.duplicate")} </div> </ha-md-menu-item> <ha-md-menu-item .clickAction="${this._toggle}"> <ha-svg-icon .path="${"off"===this._overflowAutomation?.state?it:et}" slot="start"></ha-svg-icon> <div slot="headline"> ${"off"===this._overflowAutomation?.state?this.hass.localize("ui.panel.config.automation.editor.enable"):this.hass.localize("ui.panel.config.automation.editor.disable")} </div> </ha-md-menu-item> <ha-md-menu-item .clickAction="${this._deleteConfirm}" class="warning"> <ha-svg-icon .path="${F}" slot="start"></ha-svg-icon> <div slot="headline"> ${this.hass.localize("ui.panel.config.automation.picker.delete")} </div> </ha-md-menu-item> </ha-md-menu> `}updated(t){super.updated(t),t.has("_entityReg")&&this._applyFilters()}firstUpdated(){this._searchParms.has("blueprint")&&this._filterBlueprint(),this._searchParms.has("label")&&this._filterLabel()}_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={...this._filters,[i]:t.detail},this._applyFilters()}_applyFilters(){const t=Object.entries(this._filters);let i;for(const[e,a]of t){if(a.items){if(!i){i=a.items;continue}i="intersection"in i?i.intersection(a.items):new Set([...i].filter(t=>a.items.has(t)))}if("ha-filter-categories"===e&&Array.isArray(a.value)&&a.value.length){const t=new Set;if(this.automations.filter(t=>a.value[0]===this._entityReg.find(i=>i.entity_id===t.entity_id)?.categories.automation).forEach(i=>t.add(i.entity_id)),!i){i=t;continue}i="intersection"in i?i.intersection(t):new Set([...i].filter(i=>t.has(i)))}if("ha-filter-labels"===e&&Array.isArray(a.value)&&a.value.length){const t=new Set;if(this.automations.filter(t=>this._entityReg.find(i=>i.entity_id===t.entity_id)?.labels.some(t=>a.value.includes(t))).forEach(i=>t.add(i.entity_id)),!i){i=t;continue}i="intersection"in i?i.intersection(t):new Set([...i].filter(i=>t.has(i)))}}this._filteredAutomations=i?[...i]:void 0}_filterLabel(){const t=this._searchParms.get("label");t&&(this._filters={...this._filters,"ha-filter-labels":{value:[t],items:void 0}},this._applyFilters())}async _filterBlueprint(){const t=this._searchParms.get("blueprint");if(!t)return;const i=await(0,H.K)(this.hass,"automation_blueprint",t);this._filters={...this._filters,"ha-filter-blueprints":{value:[t],items:new Set(i.automation||[])}},this._applyFilters()}_clearFilter(){this._filters={},this._applyFilters()}async _delete(t){try{await(0,C.SC)(this.hass,t.attributes.id)}catch(t){await(0,M.showAlertDialog)(this,{text:400===t.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:t.status_code})})}}_showHelp(){(0,M.showAlertDialog)(this,{title:this.hass.localize("ui.panel.config.automation.caption"),text:r.dy` ${this.hass.localize("ui.panel.config.automation.picker.introduction")} <p> <a href="${(0,I.R)(this.hass,"/docs/automation/editor/")}" target="_blank" rel="noreferrer"> ${this.hass.localize("ui.panel.config.automation.picker.learn_more")} </a> </p> `})}_handleRowClicked(t){const i=this.automations.find(i=>i.entity_id===t.detail.id);i?.attributes.id?(0,y.c)(`/config/automation/edit/${encodeURIComponent(i.attributes.id)}`):(0,y.c)(`/config/automation/show/${encodeURIComponent(t.detail.id)}`)}_handleSelectionChanged(t){this._selected=t.detail.value}_createNew(){(0,u.p)(this.hass,"blueprint")?(0,Z.X)(this,{mode:"automation"}):(0,y.c)("/config/automation/edit/new")}async _bulkAddCategory(t){const i=[];
1this._selected.forEach(e=>{i.push((0,z.Nv)(this.hass,e,{categories:{automation:t}}))});const e=await Promise.allSettled(i);if((0,b.M)(e)){const t=(0,b.a)(e);(0,M.showAlertDialog)(this,{title:this.hass.localize("ui.panel.config.common.multiselect.failed",{number:t.length}),text:r.dy`<pre> 2${t.map(t=>t.reason.message||t.reason.code||t.reason).join("\r\n")}</pre>`})}}async _handleBulkLabel(t){const i=t.currentTarget.value,e=t.currentTarget.action;this._bulkLabel(i,e)}async _bulkLabel(t,i){const e=[];this._selected.forEach(a=>{e.push((0,z.Nv)(this.hass,a,{labels:"add"===i?this.hass.entities[a].labels.concat(t):this.hass.entities[a].labels.filter(i=>i!==t)}))});const a=await Promise.allSettled(e);if((0,b.M)(a)){const t=(0,b.a)(a);(0,M.showAlertDialog)(this,{title:this.hass.localize("ui.panel.config.common.multiselect.failed",{number:t.length}),text:r.dy`<pre> 3${t.map(t=>t.reason.message||t.reason.code||t.reason).join("\r\n")}</pre>`})}}async _bulkAddArea(t){const i=[];this._selected.forEach(e=>{i.push((0,z.Nv)(this.hass,e,{area_id:t}))});const e=await Promise.allSettled(i);if((0,b.M)(e)){const t=(0,b.a)(e);(0,M.showAlertDialog)(this,{title:this.hass.localize("ui.panel.config.common.multiselect.failed",{number:t.length}),text:r.dy`<pre> 4${t.map(t=>t.reason.message||t.reason.code||t.reason).join("\r\n")}</pre>`})}}_handleSortingChanged(t){this._activeSorting=t.detail}_handleGroupingChanged(t){this._activeGrouping=t.detail.value??""}_handleCollapseChanged(t){this._activeCollapsed=t.detail.value}_handleColumnsChanged(t){this._activeColumnOrder=t.detail.columnOrder,this._activeHiddenColumns=t.detail.hiddenColumns}static get styles(){return[S.Qx,r.iv`: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 h1{font-size:var(--ha-font-size-3xl)}ha-assist-chip{--ha-assist-chip-container-shape:10px}ha-md-button-menu ha-assist-chip{--md-assist-chip-trailing-space:8px}ha-label{--ha-label-background-color:var(--color, var(--grey-color));--ha-label-background-opacity:0.5}`]}constructor(...t){super(...t),this.isWide=!1,this.narrow=!1,this._searchParms=new URLSearchParams(window.location.search),this._filter="",this._filters={},this._selected=[],this._sizeController=new o.Z(this,{callback:t=>t[0]?.contentRect.width}),this._automations=(0,c.Z)((t,i,e,a,o,s)=>null===s?[]:(s?t.filter(t=>s.includes(t.entity_id)):t).map(t=>{const s=i.find(i=>i.entity_id===t.entity_id),n=s?.categories.automation,r=o&&s?.labels;return{...t,name:(0,f.C)(t),area:s?.area_id?e[s?.area_id]?.name:void 0,last_triggered:t.attributes.last_triggered||void 0,formatted_state:this.hass.formatEntityState(t),category:n?a?.find(t=>t.category_id===n)?.name:void 0,labels:(r||[]).map(t=>o.find(i=>i.label_id===t)),selectable:void 0!==s}})),this._columns=(0,c.Z)((t,i,e)=>({icon:{title:"",label:i("ui.panel.config.automation.picker.headers.icon"),type:"icon",moveable:!1,showNarrow:!0,template:t=>r.dy`<ha-state-icon .hass="${this.hass}" .stateObj="${t}" style="${(0,l.V)({color:t.state===x.nZ?"var(--error-color)":"unset"})}"></ha-state-icon>`},entity_id:{title:"",hidden:!0,filterable:!0},name:{title:i("ui.panel.config.automation.picker.headers.name"),main:!0,sortable:!0,filterable:!0,direction:"asc",flex:2,extraTemplate:t=>t.labels.length?r.dy`<ha-data-table-labels @label-clicked="${this._labelClicked}" .labels="${t.labels}"></ha-data-table-labels>`:r.Ld},area:{title:i("ui.panel.config.automation.picker.headers.area"),defaultHidden:!0,groupable:!0,filterable:!0,sortable:!0},category:{title:i("ui.panel.config.automation.picker.headers.category"),defaultHidden:!0,groupable:!0,filterable:!0,sortable:!0},labels:{title:"",hidden:!0,filterable:!0,template:t=>t.labels.map(t=>t.name).join(" ")},last_triggered:{sortable:!0,title:i("ui.card.automation.last_triggered"),template:t=>{if(!t.last_triggered)return this.hass.localize("ui.components.relative_time.never");const i=new Date(t.last_triggered),a=new Date,o=(0,n.j)(a,i);return r.dy` ${o>3?(0,m.Fu)(i,this.hass.locale,this.hass.config):(0,p.G)(i,e)} `}},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=>r.dy` <ha-entity-toggle .stateObj="${t}" .hass="${this.hass}"></ha-entity-toggle> `},actions:{title:"",label:this.hass.localize("ui.panel.config.generic.headers.actions"),type:"icon-button",showNarrow:!0,moveable:!1,hideable:!1,template:t=>r.dy` <ha-icon-button .automation="${t}" .label="${this.hass.localize("ui.common.overflow_menu")}" .path="${N}" @click="${this._showOverflowMenu}"></ha-icon-button> `}})),this._showOverflowMenu=t=>{this._overflowMenu.open&&t.target===this._overflowMenu.anchorElement?this._overflowMenu.close():(this._overflowAutomation=t.target.automation,this._overflowMenu.anchorElement=t.target,this._overflowMenu.show())},this._labelClicked=t=>{const i=t.detail.label;this._filters={...this._filters,"ha-filter-labels":{value:[i.label_id],items:void 0}},this._applyFilters()},this._showInfo=t=>{const i=t.parentElement.anchorElement.automation;(0,g.B)(this,"hass-more-info",{entityId:i.entity_id})},this._showSettings=t=>{const i=t.parentElement.anchorElement.automation;(0,g.B)(this,"hass-more-info",{entityId:i.entity_id,view:"settings"})},this._runActions=t=>{const i=t.parentElement.anchorElement.automation;(0,C.Es)(this.hass,i.entity_id)},this._editCategory=t=>{const i=t.parentElement.anchorElement.automation,e=this._entityReg.f
4ind(t=>t.entity_id===i.entity_id);e?(0,B.U)(this,{scope:"automation",entityReg:e}):(0,M.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=>{const i=t.parentElement.anchorElement.automation;i.attributes.id?(0,y.c)(`/config/automation/trace/${encodeURIComponent(i.attributes.id)}`):(0,M.showAlertDialog)(this,{text:this.hass.localize("ui.panel.config.automation.picker.traces_not_available")})},this._toggle=async t=>{const i=t.parentElement.anchorElement.automation,e="off"===i.state?"turn_on":"turn_off";await this.hass.callService("automation",e,{entity_id:i.entity_id})},this._deleteConfirm=async t=>{const i=t.parentElement.anchorElement.automation;(0,M.showConfirmationDialog)(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:i.name}),confirmText:this.hass.localize("ui.common.delete"),dismissText:this.hass.localize("ui.common.cancel"),confirm:()=>this._delete(i),destructive:!0})},this._duplicate=async t=>{const i=t.parentElement.anchorElement.automation;try{const t=await(0,C.r4)(this.hass,i.attributes.id);(0,C.HF)(t)}catch(t){if(404===t.status_code){const t=await(0,C.SQ)(this.hass,i.entity_id);return void(0,C.Ip)({...t.config,id:void 0})}await(0,M.showAlertDialog)(this,{text:this.hass.localize("ui.panel.config.automation.editor.load_error_unknown",{err_no:t.status_code})})}},this._handleBulkCategory=async t=>{const i=t.value;this._bulkAddCategory(i)},this._handleBulkArea=t=>{const i=t.value;this._bulkAddArea(i)},this._bulkCreateArea=async()=>{(0,O.E)(this,{createEntry:async t=>{const i=await(0,$.Lo)(this.hass,t);return this._bulkAddArea(i.area_id),i}})},this._handleBulkEnable=async()=>{const t=[];this._selected.forEach(i=>{t.push((0,E.S)(this.hass,i,!0))});const i=await Promise.allSettled(t);if((0,b.M)(i)){const t=(0,b.a)(i);(0,M.showAlertDialog)(this,{title:this.hass.localize("ui.panel.config.common.multiselect.failed",{number:t.length}),text:r.dy`<pre> 5${t.map(t=>t.reason.message||t.reason.code||t.reason).join("\r\n")}</pre>`})}},this._handleBulkDisable=async()=>{const t=[];this._selected.forEach(i=>{t.push((0,E.S)(this.hass,i,!1))});const i=await Promise.allSettled(t);if((0,b.M)(i)){const t=(0,b.a)(i);(0,M.showAlertDialog)(this,{title:this.hass.localize("ui.panel.config.common.multiselect.failed",{number:t.length}),text:r.dy`<pre> 6${t.map(t=>t.reason.message||t.reason.code||t.reason).join("\r\n")}</pre>`})}},this._bulkCreateCategory=async()=>{(0,j.n)(this,{scope:"automation",createEntry:async t=>{const i=await(0,w.DM)(this.hass,"automation",t);return this._bulkAddCategory(i.category_id),i}})},this._bulkCreateLabel=()=>{(0,U.T)(this,{createEntry:async t=>{const i=await(0,L.jo)(this.hass,t);this._bulkLabel(i.label_id,"add")}})}}}(0,a.__decorate)([(0,h.Cb)({attribute:!1})],ot.prototype,"hass",void 0),(0,a.__decorate)([(0,h.Cb)({attribute:"is-wide",type:Boolean})],ot.prototype,"isWide",void 0),(0,a.__decorate)([(0,h.Cb)({type:Boolean})],ot.prototype,"narrow",void 0),(0,a.__decorate)([(0,h.Cb)({attribute:!1})],ot.prototype,"route",void 0),(0,a.__decorate)([(0,h.Cb)({attribute:!1})],ot.prototype,"automations",void 0),(0,a.__decorate)([(0,h.SB)()],ot.prototype,"_searchParms",void 0),(0,a.__decorate)([(0,h.SB)()],ot.prototype,"_filteredAutomations",void 0),(0,a.__decorate)([(0,h.SB)(),(0,_.t)({storage:"sessionStorage",key:"automation-table-search",state:!0,subscribe:!1})],ot.prototype,"_filter",void 0),(0,a.__decorate)([(0,h.SB)(),(0,_.t)({storage:"sessionStorage",key:"automation-table-filters-full",state:!0,subscribe:!1,serializer:k.B,deserializer:k.l})],ot.prototype,"_filters",void 0),(0,a.__decorate)([(0,h.SB)()],ot.prototype,"_expandedFilter",void 0),(0,a.__decorate)([(0,h.SB)()],ot.prototype,"_selected",void 0),(0,a.__decorate)([(0,h.SB)()],ot.prototype,"_categories",void 0),(0,a.__decorate)([(0,h.SB)()],ot.prototype,"_labels",void 0),(0,a.__decorate)([(0,h.SB)(),(0,s.F_)({context:A.we,subscribe:!0})],ot.prototype,"_entityReg",void 0),(0,a.__decorate)([(0,h.SB)()],ot.prototype,"_overflowAutomation",void 0),(0,a.__decorate)([(0,_.t)({key:"automation-table-sort",state:!1,subscribe:!1})],ot.prototype,"_activeSorting",void 0),(0,a.__decorate)([(0,_.t)({key:"automation-table-grouping",state:!1,subscribe:!1})],ot.prototype,"_activeGrouping",void 0),(0,a.__decorate)([(0,_.t)({key:"automation-table-collapsed",state:!1,subscribe:!1})],ot.prototype,"_activeCollapsed",void 0),(0,a.__decorate)([(0,_.t)({key:"automation-table-column-order",state:!1,subscribe:!1})],ot.prototype,"_activeColumnOrder",void 0),(0,a.__decorate)([(0,_.t)({key:"automation-table-hidden-columns",state:!1,subscribe:!1})],ot.prototype,"_activeHiddenColumns",void 0),(0,a.__decorate)([(0,h.IO)("#overflow-menu")],ot.prototype,"_overflowMenu",void 0),ot=(0,a.__decorate)([(0,h.Mo)("ha-automation-picker")],ot),i()}catch(t){i(t)}})},30045:function(t,i,e){e.a(t,async function(t,a){try{e.r(i);e(81738),e(33480),e(94814);var o=e(73742),s=e(26292),n=e(28105),r=e(6219),h=e(87639),l=e(407),c=e(93841),d=e(58025),u=t([c,d]);[c,d]=u.then?(await u)():u;const m=(t,i)=>t.length===i.length&&t.every((t,e)=>t===i[e]);class p extends l.n{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.showAdvanced=this.showAdvanced,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.showAdvanced=!1,this.automations=[],this._debouncedUpdateAutomations=(0,h.D)(t=>{const i=this._getAutomations(this.hass.states);m(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([e.e("29425"),e.e("16462"),e.e("68571")]).then(e.bind(e,76150))}}},this._getAutomations=(0,n.Z)(t=>Object.values(t).filter(t=>"automation"===(0,r.N)(t)&&!t.attributes.restored))}}(0,o.__decorate)([(0,s.Cb)({attribute:!1})],p.prototype,"hass",void 0),(0,o.__decorate)([(0,s.Cb)({type:Boolean})],p.prototype,"narrow",void 0),(0,o.__decorate)([(0,s.Cb)({attribute:"is-wide",type:Boolean})],p.prototype,"isWide",void 0),(0,o.__decorate)([(0,s.Cb)({attribute:!1})],p.prototype,"showAdvanced",void 0),(0,o.__decorate)([(0,s.Cb)({attribute:!1})],p.prototype,"automations",void 0),p=(0,o.__decorate)([(0,s.Mo)("ha-config-automation")],p),a()}catch(t){a(t)}})},37373:function(t,i,e){e.a(t,async function(t,i){try{e(2394),e(81738),e(22960);var a=e(73742),o=(e(98334),e(59048)),s=e(26292),n=e(24110),r=e(95632),h=e(45332),l=e(39884),c=(e(31138),e(48017),e(45861),e(10142)),d=e(66095),u=e(95814),m=e(42399),p=e(21011),_=e(48307),g=e(19747),f=e(64637),y=e(21682),b=e(58577),v=e(35982),$=e(96346),C=t([p,_,g]);[p,_,g]=C.then?(await C)():C;const w="M15.07,11.25L14.17,12.17C13.45,12.89 13,13.5 13,15H11V14.5C11,13.39 11.45,12.39 12.17,11.67L13.41,10.41C13.78,10.05 14,9.55 14,9C14,7.89 13.1,7 12,7A2,2 0 0,0 10,9H8A4,4 0 0,1 12,5A4,4 0 0,1 16,9C16,9.88 15.64,10.67 15.07,11.25M13,19H11V17H13M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12C22,6.47 17.5,2 12,2Z",A=(0,r.Ry)({alias:(0,r.jt)((0,r.Z_)()),description:(0,r.jt)((0,r.Z_)()),triggers:(0,r.jt)((0,r.IX)((0,r.Yj)())),conditions:(0,r.jt)((0,r.IX)((0,r.Yj)())),actions:(0,r.jt)((0,r.IX)((0,r.Yj)())),mode:(0,r.jt)((0,r.Z_)()),max_exceeded:(0,r.jt)((0,r.Z_)()),id:(0,r.jt)((0,r.Z_)())}),k=(0,r.G0)([(0,r.f0)(A,(0,r.Ry)({triggers:(0,r.IX)((0,r.Yj)())})),(0,r.f0)(A,(0,r.Ry)({conditions:(0,r.IX)((0,r.Yj)())})),(0,r.f0)(A,(0,r.Ry)({actions:(0,r.IX)((0,r.Yj)())}))]);class x extends o.oi{connectedCallback(){super.connectedCallback(),window.addEventListener("paste",this._handlePaste)}disconnectedCallback(){window.removeEventListener("paste",this._handlePaste),super.disconnectedCallback()}firstUpdated(t){super.firstUpdated(t);if("1"===(0,f.io)("expanded")){this._clearParam("expanded");this.shadowRoot.querySelectorAll("ha-automation-trigger, ha-automation-condition, ha-automation-action").forEach(t=>{t.updateComplete.then(()=>
6{t.expandAll()})})}}_clearParam(t){window.history.replaceState(null,"",(0,y.q)((0,f.pc)(t)))}render(){return o.dy` ${"off"===this.stateObj?.state?o.dy` <ha-alert alert-type="info"> ${this.hass.localize("ui.panel.config.automation.editor.disabled")} <mwc-button slot="action" @click="${this._enable}"> ${this.hass.localize("ui.panel.config.automation.editor.enable")} </mwc-button> </ha-alert> `:o.Ld} ${this.config.description?o.dy`<ha-markdown class="description" breaks .content="${this.config.description}"></ha-markdown>`:o.Ld} <div class="header"> <h2 id="triggers-heading" class="name"> ${this.hass.localize("ui.panel.config.automation.editor.triggers.header")} </h2> <a href="${(0,m.R)(this.hass,"/docs/automation/trigger/")}" target="_blank" rel="noreferrer"> <ha-icon-button .path="${w}" .label="${this.hass.localize("ui.panel.config.automation.editor.triggers.learn_more")}"></ha-icon-button> </a> </div> ${(0,h.r)(this.config.triggers)?.length?o.Ld:o.dy`<p> ${this.hass.localize("ui.panel.config.automation.editor.triggers.description")} </p>`} <ha-automation-trigger role="region" aria-labelledby="triggers-heading" .triggers="${this.config.triggers||[]}" .highlightedTriggers="${this._pastedConfig?.triggers||[]}" .path="${["triggers"]}" @value-changed="${this._triggerChanged}" .hass="${this.hass}" .disabled="${this.disabled}"></ha-automation-trigger> <div class="header"> <h2 id="conditions-heading" class="name"> ${this.hass.localize("ui.panel.config.automation.editor.conditions.header")} <span class="small">(${this.hass.localize("ui.common.optional")})</span> </h2> <a href="${(0,m.R)(this.hass,"/docs/automation/condition/")}" target="_blank" rel="noreferrer"> <ha-icon-button .path="${w}" .label="${this.hass.localize("ui.panel.config.automation.editor.conditions.learn_more")}"></ha-icon-button> </a> </div> ${(0,h.r)(this.config.conditions)?.length?o.Ld:o.dy`<p> ${this.hass.localize("ui.panel.config.automation.editor.conditions.description",{user:this.hass.user?.name||"Alice"})} </p>`} <ha-automation-condition role="region" aria-labelledby="conditions-heading" .conditions="${this.config.conditions||[]}" .highlightedConditions="${this._pastedConfig?.conditions||[]}" .path="${["conditions"]}" @value-changed="${this._conditionChanged}" .hass="${this.hass}" .disabled="${this.disabled}"></ha-automation-condition> <div class="header"> <h2 id="actions-heading" class="name"> ${this.hass.localize("ui.panel.config.automation.editor.actions.header")} </h2> <div> <a href="${(0,m.R)(this.hass,"/docs/automation/action/")}" target="_blank" rel="noreferrer"> <ha-icon-button .path="${w}" .label="${this.hass.localize("ui.panel.config.automation.editor.actions.learn_more")}"></ha-icon-button> </a> </div> </div> ${(0,h.r)(this.config.actions)?.length?o.Ld:o.dy`<p> ${this.hass.localize("ui.panel.config.automation.editor.actions.description")} </p>`} <ha-automation-action role="region" aria-labelledby="actions-heading" .actions="${this.config.actions||[]}" .highlightedActions="${this._pastedConfig?.actions||[]}" .path="${["actions"]}" @value-changed="${this._actionChanged}" .hass="${this.hass}" .narrow="${this.narrow}" .disabled="${this.disabled}"></ha-automation-action> `}_triggerChanged(t){t.stopPropagation(),this.resetPastedConfig(),(0,l.B)(this,"value-changed",{value:{...this.config,triggers:t.detail.value}})}_conditionChanged(t){t.stopPropagation(),this.resetPastedConfig(),(0,l.B)(this,"value-changed",{value:{...this.config,conditions:t.detail.value}})}_actionChanged(t){t.stopPropagation(),this.resetPastedConfig(),(0,l.B)(this,"value-changed",{value:{...this.config,actions:t.detail.value}})}async _enable(){this.hass&&this.stateObj&&await this.hass.callService("automation","turn_on",{entity_id:this.stateObj.entity_id})}_appendToExistingConfig(t){this._previousConfig={...this.config},this._pastedConfig=t,this.config&&("triggers"in t&&(this.config.triggers=(0,h.r)(this.config.triggers||[]).concat((0,h.r)(t.triggers))),"conditions"in t&&(this.config.conditions=(0,h.r)(this.config.conditions||[]).concat((0,h.r)(t.conditions))),"actions"in t&&(this.config.actions=(0,h.r)(this.config.actions||[]).concat((0,h.r)(t.actions))),this._showPastedToastWithUndo(),(0,l.B)(this,"value-changed",{value:{...this.config}}))}_replaceExistingConfig(t){this._previousConfig={...this.config},this._pastedConfig=t,this.config=t,this._showPastedToastWithUndo(),(0,l.B)(this,"value-changed",{value:{...this.config}})}_showPastedToastWithUndo(){(0,v.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,l.B)(this,"value-changed",{value:{...this._previousConfig}}),this._previousConfig=void 0,this._pastedConfig=void 0}}})}resetPastedConfig(){this._previousConfig&&(this._pastedConfig=void 0,this._previousConfig=void 0,(0,v.C)(this,{message:"",duration:0}))}static get styles(){return[u.Qx,o.iv`:host{display:block}ha-card{overflow:hidden}.description{margin:0}p{margin-top:0}.header{margin-top:16px;display:flex;align-items:center}.header:first-child{margin-top:-16px}.header .name{font-weight:var(--ha-font-weight-normal);flex:1;margin-bottom:16px}.header a{color:var(--secondary-text-color)}.header .small{font-size:small;font-weight:var(--ha-font-weight-normal);line-height:0}`]}constructor(...t){super(...t),this.isWide=!1,this.narrow=!1,this.disabled=!1,this.dirty=!1,this._handlePaste=async t=>{if(!(0,b.I)(t.composedPath()))return;const i=t.clipboardData?.getData("text");if(!i)return;let e;try{e=(0,n.load)(i)}catch(t){return void(0,v.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 a,o=e;if("automation"in o&&(o=o.automation,Array.isArray(o)&&(o=o[0])),Array.isArray(o))if(1===o.length)o=o[0];else{const t={triggers:[],conditions:[],actions:[]};let i=!1;
6o.forEach(e=>{(0,c.Jd)(e)&&(i=!0,t.triggers.push(e)),(0,c.T5)(e)&&(i=!0,t.conditions.push(e)),"unknown"!==(0,d.Pw)(e)&&(i=!0,t.actions.push(e))}),i&&(o=t)}(0,c.Jd)(o)&&(o={triggers:[o]}),(0,c.T5)(o)&&(o={conditions:[o]}),"unknown"!==(0,d.Pw)(o)&&(o={actions:[o]});try{a=(0,c.EQ)(o)}catch(t){return}try{(0,r.hu)(a,k)}catch(t){return void(0,v.C)(this,{message:this.hass.localize("ui.panel.config.automation.editor.paste_invalid_config"),duration:4e3,dismissable:!0})}if(a){if(t.preventDefault(),this.dirty){if(!await new Promise(t=>{(0,$.J)(this,{domain:"automation",pastedConfig:a,onClose:()=>t(!1),onAppend:()=>{this._appendToExistingConfig(a),t(!1)},onReplace:()=>t(!0)})}))return}this._replaceExistingConfig(a)}}}}(0,a.__decorate)([(0,s.Cb)({attribute:!1})],x.prototype,"hass",void 0),(0,a.__decorate)([(0,s.Cb)({attribute:"is-wide",type:Boolean})],x.prototype,"isWide",void 0),(0,a.__decorate)([(0,s.Cb)({type:Boolean})],x.prototype,"narrow",void 0),(0,a.__decorate)([(0,s.Cb)({type:Boolean})],x.prototype,"disabled",void 0),(0,a.__decorate)([(0,s.Cb)({attribute:!1})],x.prototype,"config",void 0),(0,a.__decorate)([(0,s.Cb)({attribute:!1})],x.prototype,"stateObj",void 0),(0,a.__decorate)([(0,s.Cb)({attribute:!1})],x.prototype,"dirty",void 0),(0,a.__decorate)([(0,s.SB)()],x.prototype,"_pastedConfig",void 0),x=(0,a.__decorate)([(0,s.Mo)("manual-automation-editor")],x),i()}catch(t){i(t)}})},3301:function(t,i,e){var a=e(73742),o=e(59048),s=e(26292),n=e(31733);class r extends o.oi{render(){return o.dy` <div class="content ${(0,n.$)({narrow:!this.isWide,"full-width":this.fullWidth})}"> <div class="header"><slot name="header"></slot></div> <div class="together layout ${(0,n.$)({narrow:!this.isWide,vertical:this.vertical||!this.isWide,horizontal:!this.vertical&&this.isWide})}"> <div class="intro"><slot name="introduction"></slot></div> <div class="panel flex-auto"><slot></slot></div> </div> </div> `}constructor(...t){super(...t),this.isWide=!1,this.vertical=!1,this.fullWidth=!1}}r.styles=o.iv`:host{display:block}.content{padding:28px 20px 0;max-width:1040px;margin:0 auto}.layout{display:flex}.horizontal{flex-direction:row}.vertical{flex-direction:column}.flex-auto{flex:1 1 auto}.header{font-family:var(--ha-font-family-body);-webkit-font-smoothing:var(--ha-font-smoothing);-moz-osx-font-smoothing:var(--ha-moz-osx-font-smoothing);font-size:var(--ha-font-size-2xl);font-weight:var(--ha-font-weight-normal);line-height:var(--ha-line-height-condensed);opacity:var(--dark-primary-opacity)}.together{margin-top:var(--config-section-content-together-margin-top,32px)}.intro{font-family:var(--ha-font-family-body);-webkit-font-smoothing:var(--ha-font-smoothing);-moz-osx-font-smoothing:var(--ha-moz-osx-font-smoothing);font-weight:var(--ha-font-weight-normal);line-height:var(--ha-line-height-normal);width:100%;opacity:var(--dark-primary-opacity);font-size:var(--ha-font-size-m);padding-bottom:20px}.horizontal .intro{max-width:400px;margin-right:40px;margin-inline-end:40px;margin-inline-start:initial}.panel{margin-top:-24px}.panel ::slotted(*){margin-top:24px;display:block}.narrow.content{max-width:640px}.narrow .together{margin-top:var(--config-section-narrow-content-together-margin-top,var(--config-section-content-together-margin-top,20px))}.narrow .intro{padding-bottom:20px;margin-right:0;margin-inline-end:0;margin-inline-start:initial;max-width:500px}.full-width{padding:0}.full-width .layout{flex-direction:column}`,(0,a.__decorate)([(0,s.Cb)({attribute:"is-wide",type:Boolean})],r.prototype,"isWide",void 0),(0,a.__decorate)([(0,s.Cb)({type:Boolean})],r.prototype,"vertical",void 0),(0,a.__decorate)([(0,s.Cb)({type:Boolean,attribute:"full-width"})],r.prototype,"fullWidth",void 0),r=(0,a.__decorate)([(0,s.Mo)("ha-config-section")],r)}}; 7//# sourceMappingURL=19094.2ab967102399627f.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.