iobroker.lovelace
Version:
With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI
6 lines • 67.6 kB
JavaScript
export const __rspack_esm_id=1667;export const __rspack_esm_ids=[1667];export const __webpack_modules__={885(t,i,e){e.a(t,async function(t,i){try{var a=e(62826),s=e(5124),o=e(22441),n=e(1087),r=e(38962),h=e(18350),l=(e(3587),e(35891)),d=e(38119),c=e(57116),u=t([r,h,d]);[r,h,d]=u.then?(await u)():u;const p="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 g extends d.D{get _config(){return this.config}render(){return s.qy` ${"off"===this.stateObj?.state?s.qy` <ha-alert alert-type="info"> ${this.hass.localize("ui.panel.config.automation.editor.disabled")} <ha-button appearance="plain" size="small" slot="action" @click="${this._enable}"> ${this.hass.localize("ui.panel.config.automation.editor.enable")} </ha-button> </ha-alert> `:""} ${this.config.description?s.qy`<ha-markdown class="description" breaks .content="${this.config.description}"></ha-markdown>`:s.s6} ${this.renderCard()} <ha-button slot="fab" size="large" class="${this.dirty?"dirty":""}" .disabled="${this.saving}" @click="${this._saveAutomation}"> <ha-svg-icon slot="start" .path="${p}"></ha-svg-icon> ${this.hass.localize("ui.common.save")} </ha-button> `}_saveAutomation(){(0,n.r)(this,"save-automation")}async _getBlueprints(){this._blueprints=await(0,l.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_,s.AH`: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,a.Cg)([(0,o.MZ)({attribute:!1})],g.prototype,"config",void 0),(0,a.Cg)([(0,o.MZ)({attribute:!1})],g.prototype,"stateObj",void 0),(0,a.Cg)([(0,o.MZ)({type:Boolean})],g.prototype,"saving",void 0),(0,a.Cg)([(0,o.MZ)({type:Boolean})],g.prototype,"dirty",void 0),g=(0,a.Cg)([(0,o.EM)("blueprint-automation-editor")],g),i()}catch(t){i(t)}})},96259(t,i,e){e.a(t,async function(t,i){try{e(18111),e(20116),e(7588),e(61701),e(14603),e(47566),e(98721);var a=e(62826),s=(e(68825),e(5124)),o=e(22441),n=e(6412),r=e(17079),h=e(1087),l=e(91926),d=e(7553),c=e(18350),u=e(29823),p=(e(70947),e(47680),e(26300)),g=(e(67094),e(10763)),m=e(88249),_=e(35891),f=e(12596),b=e(22675),y=e(59241),v=e(65063),$=e(81310),w=e(79172),C=e(39359),A=e(14503),k=e(41570),H=e(49053),z=e(55270),M=e(37325),V=e(64265),x=e(60109),L=e(82405),I=e(885),E=e(70043),S=e(78614),q=t([c,u,p,g,$,I,S,E]);[c,u,p,g,$,I,S,E]=q.then?(await q)():q;const R="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",Z="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",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",P="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",U="M19,4H15.5L14.5,3H9.5L8.5,4H5V6H19M6,19A2,2 0 0,0 8,21H16A2,2 0 0,0 18,19V7H6V19Z",B="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",F="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",D="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",j="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",W="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",Y="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",G="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",N="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",X="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",K="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",J="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",tt="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 it extends((0,E.j)((0,C._)((0,w.b)(s.WF)))){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 this.renderLoading();const t=this.currentEntityId?this.hass.states[this.currentEntityId]:void 0,i="use_blueprint"in this.config,e=k.c?s.qy`<ha-svg-icon .path="${R}"></ha-svg-icon>`:this.hass.localize("ui.panel.config.automation.editor.ctrl");return s.qy` <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")}"> ${"gui"!==this.mode||this.narrow?s.s6:s.qy`<ha-icon-button slot="toolbar-icon" .label="${this.hass.localize("ui.common.undo")}" .path="${tt}" @click="${this._undo}" .disabled="${!this._undoRedoController.canUndo}" id="button-undo"> </ha-icon-button> <ha-tooltip placement="bottom" for="button-undo"> ${this.hass.localize("ui.common.undo")} <span class="shortcut">( <span>${e}</span> <span>+</span> <span>Z</span>) </span> </ha-tooltip> <ha-icon-button slot="toolbar-icon" .label="${this.hass.localize("ui.common.redo")}" .path="${G}" @click="${this._redo}" .disabled="${!this._undoRedoController.canRedo}" id="button-redo"> </ha-icon-button> <ha-tooltip placement="bottom" for="button-redo"> ${this.hass.localize("ui.common.redo")} <span class="shortcut"> ( ${k.c?s.qy`<span>${e}</span> <span>+</span> <span>Shift</span> <span>+</span> <span>Z</span>`:s.qy`<span>${e}</span> <span>+</span> <span>Y</span>`}) </span> </ha-tooltip>`} ${this.config?.id&&!this.narrow?s.qy` <ha-button appearance="plain" size="small" @click="${this._showTrace}" slot="toolbar-icon"> ${this.hass.localize("ui.panel.config.automation.editor.show_trace")} </ha-button> `:""} <ha-dropdown slot="toolbar-icon" @wa-select="${this._handleDropdownSelect}"> <ha-icon-button slot="trigger" .label="${this.hass.localize("ui.common.menu")}" .path="${B}"></ha-icon-button> ${"gui"===this.mode&&this.narrow?s.qy`<ha-dropdown-item value="undo" .disabled="${!this._undoRedoController.canUndo}"> ${this.hass.localize("ui.common.undo")} <ha-svg-icon slot="icon" .path="${tt}"></ha-svg-icon> </ha-dropdown-item> <ha-dropdown-item value="redo" .disabled="${!this._undoRedoController.canRedo}"> ${this.hass.localize("ui.common.redo")} <ha-svg-icon slot="icon" .path="${G}"></ha-svg-icon> </ha-dropdown-item>`:s.s6} <ha-dropdown-item .disabled="${!t}" value="info"> ${this.hass.localize("ui.panel.config.automation.editor.show_info")} <ha-svg-icon slot="icon" .path="${D}"></ha-svg-icon> </ha-dropdown-item> <ha-dropdown-item .disabled="${!t}" value="settings"> ${this.hass.localize("ui.panel.config.automation.picker.show_settings")} <ha-svg-icon slot="icon" .path="${Z}"></ha-svg-icon> </ha-dropdown-item> <ha-dropdown-item .disabled="${!t}" value="category"> ${this.hass.localize("ui.panel.config.scene.picker."+(this.registryEntry?.categories?.automation?"edit_category":"assign_category"))} <ha-svg-icon slot="icon" .path="${J}"></ha-svg-icon> </ha-dropdown-item> <ha-dropdown-item .disabled="${!t}" value="run"> ${this.hass.localize("ui.panel.config.automation.editor.run")} <ha-svg-icon slot="icon" .path="${j}"></ha-svg-icon> </ha-dropdown-item> ${t&&this.narrow?s.qy`<ha-dropdown-item value="trace"> ${this.hass.localize("ui.panel.config.automation.editor.show_trace")} <ha-svg-icon slot="icon" .path="${Q}"></ha-svg-icon> </ha-dropdown-item>`:s.s6} <ha-dropdown-item value="rename" .disabled="${this.readOnly||!this.automationId||"yaml"===this.mode}"> ${this.hass.localize("ui.panel.config.automation.editor.rename")} <ha-svg-icon slot="icon" .path="${N}"></ha-svg-icon> </ha-dropdown-item> ${i?s.s6:s.qy` <ha-dropdown-item @click="${this._promptAutomationMode}" .disabled="${this.readOnly||"yaml"===this.mode}"> ${this.hass.localize("ui.panel.config.automation.editor.change_mode")} <ha-svg-icon slot="icon" .path="${P}"></ha-svg-icon> </ha-dropdown-item> `} <ha-dropdown-item .disabled="${!!this.blueprintConfig||!this.readOnly&&!this.automationId}" value="duplicate"> ${this.hass.localize(this.readOnly?"ui.panel.config.automation.editor.migrate":"ui.panel.config.automation.editor.duplicate")} <ha-svg-icon slot="icon" .path="${Y}"></ha-svg-icon> </ha-dropdown-item> ${i?s.qy` <ha-dropdown-item value="take_control" .disabled="${this.readOnly}"> ${this.hass.localize("ui.panel.config.automation.editor.take_control")} <ha-svg-icon slot="icon" .path="${F}"></ha-svg-icon> </ha-dropdown-item> `:s.s6} <ha-dropdown-item value="toggle_yaml_mode"> ${this.hass.localize("ui.panel.config.automation.editor.edit_"+("gui"===this.mode?"yaml":"ui"))} <ha-svg-icon slot="icon" .path="${W}"></ha-svg-icon> </ha-dropdown-item> <wa-divider></wa-divider> <ha-dropdown-item .disabled="${!t}" value="disable"> ${"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="icon" .path="${"off"===t?.state?T:K}"></ha-svg-icon> </ha-dropdown-item> <ha-dropdown-item .disabled="${!this.automationId}" .variant="${this.automationId?"danger":"default"}" value="delete"> ${this.hass.localize("ui.panel.config.automation.picker.delete")} <ha-svg-icon class="${(0,n.H)({warning:Boolean(this.automationId)})}" slot="icon" .path="${U}"> </ha-svg-icon> </ha-dropdown-item> </ha-dropdown> <div class="${"yaml"===this.mode?"yaml-mode":""}" @subscribe-automation-config="${this._subscribeAutomationConfig}"> ${"gui"===this.mode?s.qy` <div> ${i?s.qy` <blueprint-automation-editor .hass="${this.hass}" .narrow="${this.narrow}" .isWide="${this.isWide}" .stateObj="${t}" .config="${this.config}" .disabled="${this.readOnly}" .saving="${this.saving}" .dirty="${this.dirty}" @value-changed="${this._valueChanged}" @save-automation="${this._handleSaveAutomation}"></blueprint-automation-editor> `:s.qy` <manual-automation-editor .hass="${this.hass}" .narrow="${this.narrow}" .isWide="${this.isWide}" .stateObj="${t}" .config="${this.config}" .disabled="${this.readOnly}" .dirty="${this.dirty}" .saving="${this.saving}" @value-changed="${this._valueChanged}" @save-automation="${this._handleSaveAutomation}" @editor-save="${this._handleSaveAutomation}"> <div class="alert-wrapper" slot="alerts"> ${this.errors||t?.state===b.Hh?s.qy`<ha-alert alert-type="error" .title="${t?.state===b.Hh?this.hass.localize("ui.panel.config.automation.editor.unavailable"):void 0}"> ${this.errors||this.validationErrors} ${t?.state===b.Hh?s.qy`<ha-svg-icon slot="icon" .path="${X}"></ha-svg-icon>`:s.s6} </ha-alert>`:s.s6} ${this.blueprintConfig?s.qy`<ha-alert alert-type="info"> ${this.hass.localize("ui.panel.config.automation.editor.confirm_take_control")} <div slot="action" style="display:flex"> <ha-button appearance="plain" @click="${this.takeControlSave}">${this.hass.localize("ui.common.yes")}</ha-button> <ha-button appearance="plain" @click="${this.revertBlueprint}">${this.hass.localize("ui.common.no")}</ha-button> </div> </ha-alert>`:this.readOnly?s.qy`<ha-alert alert-type="warning" dismissable>${this.hass.localize("ui.panel.config.automation.editor.read_only")} <ha-button appearance="filled" size="small" variant="warning" slot="action" @click="${this._duplicate}"> ${this.hass.localize("ui.panel.config.automation.editor.migrate")} </ha-button> </ha-alert>`:s.s6} ${"off"===t?.state?s.qy` <ha-alert alert-type="info"> ${this.hass.localize("ui.panel.config.automation.editor.disabled")} <ha-button size="small" slot="action" @click="${this._toggle}"> ${this.hass.localize("ui.panel.config.automation.editor.enable")} </ha-button> </ha-alert> `:s.s6} </div> </manual-automation-editor> `} </div> `:"yaml"===this.mode?s.qy`${"off"===t?.state?s.qy` <ha-alert alert-type="info"> ${this.hass.localize("ui.panel.config.automation.editor.disabled")} <ha-button appearance="filled" size="small" slot="action" @click="${this._toggle}"> ${this.hass.localize("ui.panel.config.automation.editor.enable")} </ha-button> </ha-alert> `:s.s6} <ha-yaml-editor .defaultValue="${this._preprocessYaml()}" .readOnly="${this.readOnly}" @value-changed="${this._yamlChanged}" @editor-save="${this._handleSaveAutomation}" disable-fullscreen></ha-yaml-editor> <ha-button slot="fab" size="large" class="${this.dirty?"dirty":""}" .disabled="${this.saving}" @click="${this._handleSaveAutomation}"> <ha-svg-icon slot="start" .path="${O}"></ha-svg-icon> ${this.hass.localize("ui.common.save")} </ha-button>`:s.s6} </div> </hass-subpage> `}updated(t){if(super.updated(t),!this.hass)return;const i=t.has("route")&&"/new"===this.route?.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")||i)&&!this.automationId&&!this.entityId){const t=(0,m.rY)();this.dirty=!!t;let i={description:""};t&&"use_blueprint"in t||(i={...i,mode:"single",triggers:[],conditions:[],actions:[]}),this.config={...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=t?.entity_id}async _checkValidation(){if(this.validationErrors=void 0,!this.currentEntityId||!this.config)return;const t=this.hass.states[this.currentEntityId];if(t?.state!==b.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?"":s.qy`${this.hass.localize(`ui.panel.config.automation.editor.${t}.name`)}: ${i.error}<br>`)}_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,h.r)(this,"hass-more-info",{entityId:this.currentEntityId})}_editCategory(){this.registryEntry?(0,z.j)(this,{scope:"automation",entityReg:this.registryEntry}):(0,v.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,l.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={...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,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,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,_.oz)(this.hass,"automation",t.use_blueprint.path,t.use_blueprint.input||{}),e={...(0,m.HB)(i.substituted_config),id:t.id,alias:t.alias,description:t.description};this.blueprintConfig=t,this.config=e,"yaml"===this.mode&&this._yamlEditor?.setValue(this.config),this.readOnly=!0,this.errors=void 0}catch(t){this.errors=t.message}}async _duplicate(){(this.readOnly?await(0,v.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)({...this.config,id:void 0,alias:this.readOnly?this.config?.alias:void 0})}async _deleteConfirm(){(0,v.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:this.config?.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,l.OE)("/config"))}async _promptAutomationAlias(){return new Promise(t=>{(0,V._)(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,M.e)(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,H.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,l.oo)(`/config/automation/edit/${t}`,{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(e){if(!(e instanceof Error&&"TimeoutError"===e.name))throw e;await(0,x.j)(this,{savedPromise:i,type:"automation"});try{t=(await(0,d.h)(0,i)).entity_id}catch(t){if(!(t instanceof Error&&"TimeoutError"===t.name))throw t}}t&&await(0,y.G_)(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,H.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(),c:()=>this._copySelectedRow(),x:()=>this._cutSelectedRow(),Delete:()=>this._deleteSelectedRow(),Backspace:()=>this._deleteSelectedRow(),z:()=>this._undo(),Z:()=>this._redo(),y:()=>this._redo()}}_collapseAll(){this._manualEditor?.collapseAll()}_expandAll(){this._manualEditor?.expandAll()}_copySelectedRow(){this._manualEditor?.copySelectedRow()}_cutSelectedRow(){this._manualEditor?.cutSelectedRow()}_deleteSelectedRow(){this._manualEditor?.deleteSelectedRow()}_applyUndoRedo(t){this._manualEditor?.triggerCloseSidebar(),this.config=t,this.dirty=!0}_undo(){this._undoRedoController.undo()}_redo(){this._undoRedoController.redo()}_handleDropdownSelect(t){const i=t.detail?.item?.value;if(i)switch(i){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,E.m,s.AH`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 r.X(this,{apply:t=>this._applyUndoRedo(t),currentConfig:()=>this.config})}}(0,a.Cg)([(0,o.MZ)({attribute:!1})],it.prototype,"automationId",void 0),(0,a.Cg)([(0,o.MZ)({attribute:!1})],it.prototype,"automations",void 0),(0,a.Cg)([(0,o.P)("manual-automation-editor")],it.prototype,"_manualEditor",void 0),(0,a.Cg)([(0,o.P)("ha-yaml-editor")],it.prototype,"_yamlEditor",void 0),it=(0,a.Cg)([(0,o.EM)("ha-automation-editor")],it),i()}catch(t){i(t)}})},34532(t,i,e){e.a(t,async function(t,i){try{e(74423),e(44114),e(18111),e(81148),e(22489),e(20116),e(7588),e(61701),e(13579),e(17642),e(58004),e(33853),e(45876),e(32475),e(15024),e(31698),e(14603),e(47566),e(98721);var a=e(62826),s=(e(68825),e(88696)),o=e(35211),n=e(5124),r=e(22441),h=e(89784),l=e(22786),d=e(36312),c=e(93905),u=e(1087),p=e(57237),g=e(28978),m=e(91926),_=e(87710),f=(e(34296),e(86171)),b=e(18350),y=(e(9503),e(29823)),v=(e(70947),e(645)),$=e(41113),w=e(52190),C=e(66702),A=e(72644),k=e(138),H=e(2617),z=e(26300),M=(e(82988),e(67094),e(59646)),V=e(34127),x=e(2514),L=e(88249),I=e(76570),E=e(22792),S=e(77001),q=e(22675),R=e(59241),Z=e(14782),O=e(92557),P=e(71606),U=e(65063),B=e(72553),F=e(54706),D=e(14503),j=e(36918),T=e(95048),W=e(34023),Y=e(55270),G=e(90986),N=e(29303),X=e(25635),K=e(69569),J=e(94017),Q=e(19661),tt=e(14839),it=t([f,b,y,v,$,w,C,A,k,H,z,M,V,B,N,J]);[f,b,y,v,$,w,C,A,k,H,z,M,V,B,N,J]=it.then?(await it)():it;const et="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",at="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",st="M19,4H15.5L14.5,3H9.5L8.5,4H5V6H19M6,19A2,2 0 0,0 8,21H16A2,2 0 0,0 18,19V7H6V19Z",ot="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",nt="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",rt="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",ht="M7,10L12,15L17,10H7Z",lt="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",dt="M8,5.14V19.14L19,12.14L8,5.14Z",ct="M19,13H13V19H11V13H5V11H11V5H13V11H19V13Z",ut="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",pt="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",gt="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",mt="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",_t="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",ft="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 bt extends((0,F.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(){const t=this._sizeController.value&&this._sizeController.value<900||!this._sizeController.value&&"docked"===this.hass.dockedSidebar,i=t&&(!this._sizeController.value||this._sizeController.value<700),e=this._automations(this.automations,this._entityReg,this.hass.areas,this._categories,this._labels,this._filteredEntityIds);return n.qy` <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="${X.configSections.automations}" .searchLabel="${this.hass.localize("ui.panel.config.automation.picker.search",{number:e.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,e)}" .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="${e}" .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}" @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="${nt}" @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-voice-assistants .hass="${this.hass}" .value="${this._filters["ha-filter-voice-assistants"]?.value}" @data-table-filter-changed="${this._filterChanged}" slot="filter-pane" .expanded="${"ha-filter-voice-assistants"===this._expandedFilter}" .narrow="${this.narrow}" @expanded-changed="${this._filterExpanded}"></ha-filter-voice-assistants> <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?n.s6:n.qy`<ha-dropdown slot="selection-bar" @wa-select="${this._handleBulkCategory}"> <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="${ht}"></ha-svg-icon> </ha-assist-chip> ${this._renderCategoryItems()} </ha-dropdown> ${i?n.s6:n.qy`<ha-dropdown slot="selection-bar" @wa-select="${this._handleBulkLabel}"> <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="${ht}"></ha-svg-icon> </ha-assist-chip> ${this._renderLabelItems()} </ha-dropdown>`} ${t?n.s6:n.qy`<ha-dropdown slot="selection-bar" @wa-select="${this._handleBulkArea}"> <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="${ht}"></ha-svg-icon> </ha-assist-chip> ${this._renderAreaItems()} </ha-dropdown>`}`} <ha-dropdown slot="selection-bar" @wa-select="${this._handleBulkAction}"> ${this.narrow?n.qy`<ha-assist-chip .label="${this.hass.localize("ui.panel.config.automation.picker.bulk_action")}" slot="trigger"> <ha-svg-icon slot="trailing-icon" .path="${ht}"></ha-svg-icon> </ha-assist-chip>`:n.qy`<ha-icon-button .path="${ot}" .label="${this.hass.localize("ui.panel.config.automation.picker.bulk_action")}" slot="trigger"></ha-icon-button>`} ${this.narrow?n.qy`<ha-dropdown-item> ${this.hass.localize("ui.panel.config.automation.picker.bulk_actions.move_category")} ${this._renderCategoryItems("submenu")} </ha-dropdown-item>`:n.s6} ${this.narrow||i?n.qy`<ha-dropdown-item> ${this.hass.localize("ui.panel.config.automation.picker.bulk_actions.add_label")} ${this._renderLabelItems("submenu")} </ha-dropdown-item>`:n.s6} ${this.narrow||t?n.qy`<ha-dropdown-item> ${this.hass.localize("ui.panel.config.devices.picker.bulk_actions.move_area")} ${this._renderAreaItems("submenu")} </ha-dropdown-item>`:n.s6} <ha-dropdown-item value="enable"> <ha-svg-icon slot="icon" .path="${mt}"></ha-svg-icon> ${this.hass.localize("ui.panel.config.automation.picker.bulk_actions.enable")} </ha-dropdown-item> <ha-dropdown-item value="disable"> <ha-svg-icon slot="icon" .path="${_t}"></ha-svg-icon> ${this.hass.localize("ui.panel.config.automation.picker.bulk_actions.disable")} </ha-dropdown-item> </ha-dropdown> ${this.automations.length?n.s6:n.qy`<div class="empty" slot="empty"> <ha-svg-icon .path="${ut}"></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> <ha-button href="${(0,j.o)(this.hass,"/docs/automation/editor/")}" target="_blank" appearance="plain" rel="noreferrer" size="small"> ${this.hass.localize("ui.panel.config.common.learn_more")} <ha-svg-icon slot="end" .path="${lt}"> </ha-svg-icon> </ha-button> </div>`} <ha-button slot="fab" size="large" @click="${this._createNew}"> <ha-svg-icon slot="start" .path="${ct}"></ha-svg-icon> ${this.hass.localize("ui.panel.config.automation.picker.add_automation")} </ha-button> </hass-tabs-subpage-data-table> <ha-dropdown id="overflow-menu" @wa-select="${this._handleOverflowAction}" @wa-after-show="${this._overflowMenuOpened}" @wa-after-hide="${this._overflowMenuClosed}"> <ha-dropdown-item value="show_info"> <ha-svg-icon .path="${rt}" slot="icon"></ha-svg-icon> ${this.hass.localize("ui.panel.config.automation.editor.show_info")} </ha-dropdown-item> <ha-dropdown-item value="show_settings"> <ha-svg-icon .path="${et}" slot="icon"></ha-svg-icon> ${this.hass.localize("ui.panel.config.automation.picker.show_settings")} </ha-dropdown-item> <ha-dropdown-item value="edit_category"> <ha-svg-icon .path="${pt}" slot="icon"></ha-svg-icon> ${this.hass.localize("ui.panel.config.automation.picker."+(this._overflowAutomation?.category?"edit_category":"assign_category"))} </ha-dropdown-item> <ha-dropdown-item value="run_actions"> <ha-svg-icon .path="${dt}" slot="icon"></ha-svg-icon> ${this.hass.localize("ui.panel.config.automation.editor.run")} </ha-dropdown-item> <ha-dropdown-item value="show_trace"> <ha-svg-icon .path="${ft}" slot="icon"></ha-svg-icon> ${this.hass.localize("ui.panel.config.automation.editor.show_trace")} </ha-dropdown-item> <wa-divider></wa-divider> <ha-dropdown-item value="duplicate"> <ha-svg-icon .path="${at}" slot="icon"></ha-svg-icon> ${this.hass.localize("ui.panel.config.automation.picker.duplicate")} </ha-dropdown-item> <ha-dropdown-item value="toggle"> <ha-svg-icon .path="${"off"===this._overflowAutomation?.state?mt:_t}" slot="icon"></ha-svg-icon> ${"off"===this._overflowAutomation?.state?this.hass.localize("ui.panel.config.automation.editor.enable"):this.hass.localize("ui.panel.config.automation.editor.disable")} </ha-dropdown-item> <ha-dropdown-item value="delete" variant="danger"> <ha-svg-icon .path="${st}" slot="icon"></ha-svg-icon> ${this.hass.localize("ui.panel.config.automation.picker.delete")} </ha-dropdown-item> </ha-dropdown> `}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={...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[e,a]of t)(0,S.fq)(e,a,["ha-filter-floor-areas","ha-filter-devices","ha-filter-entities","ha-filter-blueprints"])?i=i.filter(t=>a.items.has(t)):(0,S._H)(e,a,"ha-filter-categories")?i=i.filter(t=>a.value[0]===this._entityReg.find(i=>i.entity_id===t)?.categories.automation):(0,S._H)(e,a,"ha-filter-labels")?i=i.filter(t=>this._entityReg.find(i=>i.entity_id===t)?.labels.some(t=>a.value.includes(t))):(0,S._H)(e,a,"ha-filter-voice-assistants")&&(i=i.filter(t=>(0,Z.hB)(this._entityReg||[],t).some(t=>a.value.includes(t))));this._filteredEntityIds=i}_filterArea(){const t=this._searchParms.get("area");t&&(this._fromUrl=!0,this._filters={...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={...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={...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,P.f)(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._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(t){await(0,U.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,U.showAlertDialog)(this,{title:this.hass.localize("ui.panel.config.automation.caption"),text:n.qy` ${this.hass.localize("ui.panel.config.automation.picker.introduction")} <p> <a href="${(0,j.o)(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,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(e=>{i.push((0,R.G_)(this.hass,e,{categories:{automation:t}}))});const e=await Promise.allSettled(i);if((0,_.$)(e)){const t=(0,_.N)(e);(0,U.showAlertDialog)(this,{title:this.hass.localize("ui.panel.config.common.multiselect.failed",{number:t.length}),text:n.qy`<pre>
${t.map(t=>t.reason.message||t.reason.code||t.reason).join("\r\n")}</pre>`})}}async _bulkLabel(t,i){const e=[];this._selected.forEach(a=>{e.push((0,R.G_)(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,_.$)(a)){const t=(0,_.N)(a);(0,U.showAlertDialog)(this,{title:this.hass.localize("ui.panel.config.common.multiselect.failed",{number:t.length}),text:n.qy`<pre>
${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,R.G_)(this.hass,e,{area_id:t}))});const e=await Promise.allSettled(i);if((0,_.$)(e)){const t=(0,_.N)(e);(0,U.showAlertDialog)(this,{title:this.hass.localize("ui.panel.config.common.multiselect.failed",{number:t.length}),text:n.qy`<pre>
${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[D.RF,n.AH`: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=>t[0]?.contentRect.width}),this._openingOverflow=!1,this._automations=(0,l.A)((t,i,e,a,s,o)=>null===o?[]:(o?t.filter(t=>o.includes(t.entity_id)):t).map(t=>{const o=i.find(i=>i.entity_id===t.entity_id),n=o?.categories.automation,r=(s&&o?.labels||[]).map(t=>s.find(i=>i.label_id===t)).filter(t=>void 0!==t),h=(0,Z.hB)(i,t.entity_id);return{...t,name:(0,g.u)(t),area:o?.area_id?e[o?.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,label_entries:r,labels:r.map(t=>t.name),assistants:h,assistants_sortable_key:(0,J.HX)(h),selectable:void 0!==o}})),this._columns=(0,l.A)((t,i,e)=>({icon:{title:"",label:i("ui.panel.config.automation.picker.headers.icon"),type:"icon",moveable:!1,showNarrow:!0,template:t=>n.qy`<ha-state-icon .stateObj="${t}" style="${(0,h.W)({color:t.state===q.Hh?"var(--error-color)":"unset"})}"></ha-state-icon>`},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?n.qy`<ha-data-table-labels @label-clicked="${t?void 0:this._labelClicked}" .labels="${i.label_entries}"></ha-data-table-labels>`: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=>n.qy` <ha-switch @click="${p.d}" @change="${this._handleSwitchToggle}" .automation="${t}" .checked="${"on"===t.state}"></ha-switch> `},actions:{lastFixed:!0,title:"",label:this.hass.localize("ui.panel.config.generic.headers.actions"),type:"icon-button",showNarrow:!0,template:t=>n.qy` <ha-icon-button .automation="${t}" .label="${this.hass.localize("ui.common.overflow_menu")}" .path="${ot}" @click="${this._showOverflowMenu}"></ha-icon-button> `},assistants:(0,J.MD)(i,this.hass,this._availableAssistants,e)})),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={...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,U.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,U.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,U.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)({...i.config,id:void 0})}await(0,U.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?i?.startsWith("category_")&&this._bulkAddCategory(i.substring(9)):this._bulkAddCategory(null):this._bulkCreateCategory()},this._handleBulkLabel=t=>{t.preventDefault();const i=t.detail.item,e=i.value;if("label_create"!==e){if(e?.startsWith("label_")){const t=i.action;this._bulkLabel(e.substring(6),t)}}else this._bulkCreateLabel()},this._handleBulkArea=t=>{const i=t.detail.item.value;"area_create"!==i?"area_none"!==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,U.showAlertDialog)(this,{title:this.hass.localize("ui.panel.config.common.multiselect.failed",{number:t.length}),text:n.qy`<pre>
${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,T.L)(this.hass,i,!1))});const i=await Promise.allSettled(t);if((0,_.$)(i)){const t=(0,_.N)(i);(0,U.showAlertDialog)(this,{title:this.hass.localize("ui.panel.config.common.multiselect.failed",{number:t.length}),text:n.qy`<pre>
${t.map(t=>t.reason.message||t.reason.code||t.reason).join("\r\n")}</pre>`})}},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,O._9)(this.hass,t);this._bulkLabel(i.label_id,"add")}})},this._renderCategoryItems=(t="")=>n.qy`${this._categories?.map(i=>n.qy`<ha-dropdown-item .slot="${t}" .value="${`category_${i.category_id}`}"> ${i.icon?n.qy`<ha-icon slot="icon" .icon="${i.icon}"></ha-icon>`:n.qy`<ha-svg-icon slot="icon" .path="${pt}"></ha-svg-icon>`} ${i.name} </ha-dropdown-item>`)} <ha-dropdown-item .slot="${t}" value="category_none"> ${this.hass.localize("ui.panel.config.automation.picker.bulk_actions.no_category")} </ha-dropdown-item> <wa-divider .slot="${t}"></wa-divider> <ha-dropdown-item .slot="${t}" value="category_create"> ${this.hass.localize("ui.panel.config.category.editor.add")} </ha-dropdown-item>`,this._renderLabelItems=(t="")=>n.qy`${this._labels?.map(i=>{const e=this._selected.every(t=>this.hass.entities[t]?.labels.includes(i.label_id)),a=!e&&this._selected.some(t=>this.hass.entities[t]?.labels.includes(i.label_id));return n.qy`<ha-dropdown-item .slot="${t}" .value="${`label_${i.label_id}`}" .action="${e?"remove":"add"}"> <ha-checkbox slot="icon" .checked="${e}" .indeterminate="${a}"></ha-checkbox> <ha-label .color="${i.color}" .description="${i.description}"> ${i.icon?n.qy`<ha-icon slot="icon" .icon="${i.icon}"></ha-icon>`:n.s6} ${i.name} </ha-label> </ha-dropdown-item>`})} <wa-divider .slot="${t}"></wa-divider> <ha-dropdown-item .slot="${t}" value="label_create"> ${this.hass.localize("ui.panel.config.labels.add_label")} </ha-dropdown-item>`,this._renderAreaItems=(t="")=>n.qy`${Object.values(this.hass.areas).map(i=>n.qy`<ha-dropdown-item .slot="${t}" .value="${`area_${i.area_id}`}"> ${i.icon?n.qy`<ha-icon slot="icon" .icon="${i.icon}"></ha-icon>`:n.qy`<ha-svg-icon slot="icon" .path="${gt}"></ha-svg-icon>`} ${i.name} </ha-dropdown-item>`)} <ha-dropdown-item .slot="${t}" value="area_none"> ${this.hass.localize("ui.panel.config.devices.picker.bulk_actions.no_area")} </ha-dropdown-item> <wa-divider .slot="${t}"></wa-divider> <ha-dropdown-item .slot="${t}" value="area_create"> ${this.hass.localize("ui.panel.config.devices.picker.bulk_actions.add_area")} </ha-dropdown-item>`,this._handleBulkAction=t=>{const i=t.detail.item,e=i.value;if(e)if("enable"!==e)if("disable"!==e){if(e.startsWith("category_"))return"category_create"===e?void this._bulkCreateCategory():"category_none"===e?void this._bulkAddCategory(null):void this._bulkAddCategory(e.substring(9));if(e.startsWith("label_")){if("label_create"===e)return void this._bulkCreateLabel();const t=i.action;return void this._bulkLabel(e.substring(6),t)}if(e.startsWith("area_")){if("area_create"===e)return void this._bulkCreateArea();if("area_none"===e)return void this._bulkAddArea(null);this._bulkAddArea(e.substring(5))}}else this._handleBulkDisable();else this._handleBulkEnable()}}}(0,a.Cg)([(0,r.MZ)({attribute:!1})],bt.prototype,"hass",void 0),(0,a.Cg)([(0,r.MZ)({attribute:"is-wide",type:Boolean})],bt.prototype,"isWide",void 0),(0,a.Cg)([(0,r.MZ)({type:Boolean})],bt.prototype,"narrow",void 0),(0,a.Cg)([(0,r.MZ)({attribute:!1})],bt.prototype,"route",void 0),(0,a.Cg)([(0,r.MZ)({attribute:!1})],bt.prototype,"cloudStatus",void 0),(0,a.Cg)([(0,r.MZ)({attribute:!1})],bt.prototype,"automations",void 0),(0,a.Cg)([(0,r.wk)()],bt.prototype,"_searchParms",void 0),(0,a.Cg)([(0,r.wk)()],bt.prototype,"_filteredEntityIds",void 0),(0,a.Cg)([(0,r.wk)(),(0,c.I)({storage:"sessionStorage",key:"automation-table-search",state:!0,subscribe:!1})],bt.prototype,"_filter",void 0),(0,a.Cg)([(0,r.wk)()],bt.prototype,"_filters",void 0),(0,a.Cg)([(0,c.I)({storage:"sessionStorage",key:"automation-table-filters-full",state:!1,subscribe:!1,serializer:S.iS,deserializer:S.Dc})],bt.prototype,"_storageFilters",void 0),(0,a.Cg)([(0,r.wk)()],bt.prototype,"_expandedFilter",void 0),(0,a.Cg)([(0,r.wk)()],bt.prototype,"_selected",void 0),(0,a.Cg)([(0,r.wk)()],bt.prototype,"_categories",void 0),(0,a.Cg)([(0,o.Fg)({context:E.HD,subscribe:!0}),(0,r.wk)()],bt.prototype,"_labels",void 0),(0,a.Cg)([(0,r.wk)(),(0,o.Fg)({context:E.ih,subscribe:!0})],bt.prototype,"_entityReg",void 0),(0,a.Cg)([(0,r.wk)()],bt.prototype,"_overflowAutomation",void 0),(0,a.Cg)([(0,c.I)({key:"automation-table-sort",state:!1,subscribe:!1})],bt.prototype,"_activeSorting",void 0),(0,a.Cg)([(0,c.I)({key:"automation-table-grouping",state:!1,subscribe:!1})],bt.prototype,"_activeGrouping",void 0),(0,a.Cg)([(0,c.I)({key:"automation-table-collapsed",state:!1,subscribe:!1})],bt.prototype,"_activeCollapsed",void 0),(0,a.Cg)([(0,c.I)({key:"automation-table-column-order",state:!1,subscribe:!1})],bt.prototype,"_activeColumnOrder",void 0),(0,a.Cg)([(0,c.I)({key:"automation-table-hidden-columns",state:!1,subscribe:!1})],bt.prototype,"_activeHiddenColumns",void 0),(0,a.Cg)([(0,r.P)("#overflow-menu")],bt.prototype,"_overflowMenu",void 0),bt=(0,a.Cg)([(0,r.EM)("ha-automation-picker")],bt),i()}catch(t){i(t)}})},71470(t,i,e){e.a(t,async function(t,a){try{e.r(i);e(18111),e(81148),e(22489);var s=e(62826),o=e(22441),n=e(22786),r=e(69093),h=e(9899),l=e(324),d=e(96259),c=e(34532),u=t([d,c]);[d,c]=u.then?(await u)():u;const p=(t,i)=>t.length===i.length&&t.every((t,e)=>t===i[e]);class g extends l.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,h.s)(t=>{const i=this._getAutomations(this.hass.states);p(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(66432),e.e(87857),e.e(82333),e.e(775),e.e(14022)]).then(e.bind(e,64037))}}},this._getAutomations=(0,n.A)(t=>Object.values(t).filter(t=>"automation"===(0,r.t)(t)&&!t.attributes.restored))}}(0,s.Cg)([(0,o.MZ)({attribute:!1})],g.prototype,"hass",void 0),(0,s.Cg)([(0,o.MZ)({type:Boolean})],g.prototype,"narrow",void 0),(0,s.Cg)([(0,o.MZ)({attribute:"is-wide",type:Boolean})],g.prototype,"isWide",void 0),(0,s.Cg)([(0,o.MZ)({attribute:!1})],g.prototype,"cloudStatus",void 0),(0,s.Cg)([(0,o.MZ)({attribute:!1})],g.prototype,"automations",void 0),g=(0,s.Cg)([(0,o.EM)("ha-config-automation")],g),a()}catch(t){a(t)}})},78614(t,i,e){e.a(t,async function(t,i){try{e(74423),e(44114),e(18111),e(22489),e(7588);var a=e(62826),s=e(53289),o=e(5124),n=e(22441),r=e(63533),h=e(44537),l=e(68348),d=e(1087),c=e(18350),u=e(26300),p=(e(3587),e(88249)),g=e(84025),m=e(49053),_=e(68469),f=e(40219),b=e(136),y=e(84047),v=e(57116),$=e(53723),w=t([c,u,_,f,$,b]);[c,u,_,f,$,b]=w.then?(await w)():w;const C=(0,r.Ik)({alias:(0,r.lq)((0,r.Yj)()),description:(0,r.lq)((0,r.Yj)()),triggers:(0,r.lq)((0,r.YO)((0,r.bz)())),conditions:(0,r.lq)((0,r.YO)((0,r.bz)())),actions:(0,r.lq)((0,r.YO)((0,r.bz)())),mode:(0,r.lq)((0,r.Yj)()),max_exceeded:(0,r.lq)((0,r.Yj)()),id:(0,r.lq)((0,r.Yj)())}),A=(0,r.KC)([(0,r.kp)(C,(0,r.Ik)({triggers:(0,r.YO)((0,r.bz)())})),(0,r.kp)(C,(0,r.Ik)({conditions:(0,r.YO)((0,r.bz)())})),(0,r.kp)(C,(0,r.Ik)({actions:(0,r.YO)((0,r.bz)())}))]);class k extends((0,b.N)(o.WF)){renderContent(){return o.qy` ${this.config.description?o.qy`<ha-markdown class="description" breaks .content="${this.config.description}"></ha-markdown>`:o.s6} <div class="header"> <h2 id="triggers-heading" class="name"> ${this.hass.localize("ui.panel.config.automation.editor.triggers.header")} </h2> </div> ${(0,h.e)(this.config.triggers)?.length?o.s6:o.qy`<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}" @value-changed="${this._triggerChanged}" .hass="${this.hass}" .editorDirty="${this.dirty}" .disabled="${this.disabled||this.saving}" .narrow="${this.narrow}" @open-sidebar="${this.openSidebar}" @request-close-sidebar="${this.triggerCloseSidebar}" @close-sidebar="${this.handleCloseSidebar}" root sidebar></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> </div> ${(0,h.e)(this.config.conditions)?.length?o.s6:o.qy`<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}" @value-changed="${this._conditionChanged}" .hass="${this.hass}" .editorDirty="${this.dirty}" .disabled="${this.disabled||this.saving}" .narrow="${this.narrow}" @open-sidebar="${this.openSidebar}" @request-close-sidebar="${this.triggerCloseSidebar}" @close-sidebar="${this.handleCloseSidebar}" root sidebar></ha-automation-condition> <div class="header"> <h2 id="actions-heading" class="name"> ${this.hass.localize("ui.panel.config.automation.editor.actions.header")} </h2> </div> ${(0,h.e)(this.config.actions)?.length?o.s6:o.qy`<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}" @value-changed="${this._actionChanged}" @open-sidebar="${this.openSidebar}" @request-close-sidebar="${this.triggerCloseSidebar}" @close-sidebar="${this.handleCloseSidebar}" .hass="${this.hass}" .editorDirty="${this.dirty}" .narrow="${this.narrow}" .disabled="${this.disabled||this.saving}" root sidebar></ha-automation-action> `}saveConfig(){(0,d.r)(this,"save-automation")}_triggerChanged(t){t.stopPropagation(),this.resetPastedConfig(),(0,d.r)(this,"value-changed",{value:{...this.config,triggers:t.detail.value}})}_conditionChanged(t){t.stopPropagation(),this.resetPastedConfig(),(0,d.r)(this,"value-changed",{value:{...this.config,conditions:t.detail.value}})}_actionChanged(t){t.stopPropagation(),this.resetPastedConfig(),(0,d.r)(this,"value-changed",{value:{...this.config,actions:t.detail.value}})}_appendToExistingConfig(t){this.pastedConfig=t;const i={...this.config};i&&("triggers"in t&&(i.triggers=(0,h.e)(i.triggers||[]).concat((0,h.e)(t.triggers))),"conditions"in t&&(i.conditions=(0,h.e)(i.conditions||[]).concat((0,h.e)(t.conditions))),"actions"in t&&(i.actions=(0,h.e)(i.actions||[]).concat((0,h.e)(t.actions))),this.showPastedToastWithUndo(),(0,d.r)(this,"value-changed",{value:{...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[v.T_,v.qK,o.AH`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=>{if(!(0,l.u)(t.composedPath()))return;const i=t.clipboardData?.getData("text");if(!i)return;let e;try{e=(0,s.Hh)(i)}catch(t){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 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;o.forEach(e=>{(0,p.fo)(e)&&(i=!0,t.triggers.push(e)),(0,p.G3)(e)&&(i=!0,t.conditions.push(e)),"unknown"!==(0,g.pq)(e)&&(i=!0,t.actions.push(e))}),i&&(o=t)}(0,p.fo)(o)&&(o={triggers:[o]}),(0,p.G3)(o)&&(o={conditions:[o]}),"unknown"!==(0,g.pq)(o)&&(o={actions:[o]});try{a=(0,p.HB)(o)}catch(t){return}try{(0,r.vA)(a,A)}catch(t){return void(0,m.c)(this,{message:this.hass.localize("ui.panel.config.automation.editor.paste_invalid_config"),duration:4e3,dismissable:!0})}if(a){t.preventDefault();const i=Object.keys(a).filter(t=>(0,h.e)(a[t]).length);if(1===i.length&&["triggers","conditions","actions"].includes(i[0])&&this.tryInsertAfterSelected(a[i[0]]))return void this.showPastedToastWithUndo();if(this.dirty||(0,h.e)(this.config.triggers)?.length||(0,h.e)(this.config.conditions)?.length||(0,h.e)(this.config.actions)?.length){if(!await new Promise(t=>{(0,y.Z)(this,{domain:"automation",pastedConfig:a,onClose:()=>t(!1),onAppend:()=>{this._appendToExistingConfig(a),t(!1)},onReplace:()=>t(!0)})}))return}this.replaceExistingConfig(a)}}}}(0,a.Cg)([(0,n.MZ)({attribute:!1})],k.prototype,"stateObj",void 0),(0,a.Cg)([(0,n.YG)("ha-automation-action, ha-automation-condition")],k.prototype,"collapsableElements",void 0),k=(0,a.Cg)([(0,n.EM)("manual-automation-editor")],k),i()}catch(t){i(t)}})}};