UNPKG

iobroker.lovelace

Version:

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

23 lines 70.6 kB
export const __rspack_esm_id=775;export const __rspack_esm_ids=[775];export const __webpack_modules__={90433(e,t,a){a.d(t,{Vy:()=>s,fI:()=>o,ux:()=>n});var r=a(22786),i=a(79468);function s(e,t){const a=e%54+1;return t.getPropertyValue(`--color-${a}`)}function o(e,t){const a=t.getPropertyValue(`--graph-color-${e+1}`)||s(e,t);return(0,i.RQ)(a)}const n=(0,r.A)(e=>Array.from({length:54},(t,a)=>o(a,e)),(e,t)=>e[0].getPropertyValue("--graph-color-1")===t[0].getPropertyValue("--graph-color-1")&&e[0].getPropertyValue("--color-1")===t[0].getPropertyValue("--color-1"))},36356(e,t,a){a.d(t,{q:()=>r});class r{get enabled(){return this._enabled}set enabled(e){e!==this._enabled&&(this._enabled=e,this._enabled?this._attach():this._detach(),this._host.requestUpdate())}hostUpdated(){this.enabled&&!this._scrollContainer&&this._attach()}hostDisconnected(){this._detach()}_attach(){this._scrollContainer=this._host.renderRoot?.querySelector(this._selector),this._scrollContainer&&this._scrollContainer.addEventListener("mousedown",this._mouseDown)}_detach(){window.removeEventListener("mousemove",this._mouseMove),window.removeEventListener("mouseup",this._mouseUp),this._scrollContainer&&(this._scrollContainer.removeEventListener("mousedown",this._mouseDown),this._scrollContainer=void 0),this.scrolled=!1,this.scrolling=!1,this.mouseIsDown=!1,this.scrollStartX=0,this.scrollLeft=0}constructor(e,{selector:t,enabled:a}){this.mouseIsDown=!1,this.scrolled=!1,this.scrolling=!1,this.scrollStartX=0,this.scrollLeft=0,this._enabled=!0,this._mouseDown=e=>{const t=this._scrollContainer;t&&(this.scrollStartX=e.pageX-t.offsetLeft,this.scrollLeft=t.scrollLeft,this.mouseIsDown=!0,this.scrolled=!1,window.addEventListener("mousemove",this._mouseMove),window.addEventListener("mouseup",this._mouseUp,{once:!0}))},this._mouseUp=()=>{this.mouseIsDown=!1,this.scrolling=!1,this._host.requestUpdate(),window.removeEventListener("mousemove",this._mouseMove)},this._mouseMove=e=>{if(!this.mouseIsDown)return;const t=this._scrollContainer;if(!t)return;const a=e.pageX-t.offsetLeft-this.scrollStartX;this.scrolled||(this.scrolled=Math.abs(a)>1,this.scrolling=this.scrolled,this._host.requestUpdate()),t.scrollLeft=this.scrollLeft-a},this._selector=t,this._host=e,this.enabled=a??!0,e.addController(this)}}},17451(e,t,a){a.d(t,{j:()=>r});const r=(e,t,a)=>(void 0!==a&&(a=!!a),e.hasAttribute(t)?!!a||(e.removeAttribute(t),!1):!1!==a&&(e.setAttribute(t,""),!0))},15090(e,t,a){a.d(t,{nP:()=>h,vB:()=>n});a(44114),a(18111),a(22489),a(61701),a(17642),a(58004),a(33853),a(45876),a(32475),a(15024),a(31698);var r=a(22675),i=a(52220),s=a(71727),o=a(69093);const n={alarm_control_panel:["armed_away","armed_custom_bypass","armed_home","armed_night","armed_vacation","arming","disarmed","disarming","pending","triggered"],alert:["on","off","idle"],assist_satellite:["idle","listening","responding","processing"],automation:["on","off"],binary_sensor:["on","off"],button:[],calendar:["on","off"],camera:["idle","recording","streaming"],cover:["closed","closing","open","opening"],device_tracker:["home","not_home"],fan:["on","off"],humidifier:["on","off"],infrared:[],input_boolean:["on","off"],input_button:[],lawn_mower:["error","paused","mowing","returning","docked"],light:["on","off"],lock:["jammed","locked","locking","unlocked","unlocking","opening","open"],media_player:["off","on","idle","playing","paused","standby","buffering"],person:["home","not_home"],plant:["ok","problem"],radio_frequency:[],remote:["on","off"],scene:[],schedule:["on","off"],script:["on","off"],siren:["on","off"],sun:["above_horizon","below_horizon"],switch:["on","off"],timer:["active","idle","paused"],update:["on","off"],vacuum:["cleaning","docked","error","idle","paused","returning"],valve:["closed","closing","open","opening"],weather:["clear-night","cloudy","exceptional","fog","hail","lightning-rainy","lightning","partlycloudy","pouring","rainy","snowy-rainy","snowy","sunny","windy-variant","windy"]},c={alarm_control_panel:{code_format:["number","text"]},binary_sensor:{device_class:["battery","battery_charging","co","cold","connectivity","door","garage_door","gas","heat","light","lock","moisture","motion","moving","occupancy","opening","plug","power","presence","problem","running","safety","smoke","sound","tamper","update","vibration","window"]},button:{device_class:["restart","update"]},camera:{frontend_stream_type:["hls","web_rtc"]},climate:{hvac_action:["off","idle","preheating","defrosting","heating","cooling","drying","fan"]},cover:{device_class:["awning","blind","curtain","damper","door","garage","gate","shade","shutter","window"]},device_tracker:{source_type:["bluetooth","bluetooth_le","gps","router"]},fan:{direction:["forward","reverse"]},humidifier:{device_class:["humidifier","dehumidifier"],action:["off","idle","humidifying","drying"]},media_player:{device_class:["tv","speaker","receiver"],media_content_type:["album","app","artist","channel","channels","composer","contributing_artist","episode","game","genre","image","movie","music","playlist","podcast","season","track","tvshow","url","video"],repeat:["off","one","all"]},number:{device_class:["temperature"]},sensor:{device_class:["apparent_power","aqi","battery","carbon_dioxide","carbon_monoxide","current","date","duration","energy","frequency","gas","humidity","illuminance","monetary","nitrogen_dioxide","nitrogen_monoxide","nitrous_oxide","ozone","ph","pm1","pm10","pm25","pm4","power_factor","power","pressure","reactive_power","signal_strength","sulphur_dioxide","temperature","timestamp","uptime","volatile_organic_compounds","volatile_organic_compounds_parts","voltage","volume_flow_rate"],state_class:["measurement","total","total_increasing"]},switch:{device_class:["outlet","switch"]},update:{device_class:["firmware"]},water_heater:{away_mode:["on","off"]}},h=(e,t,a=void 0)=>{const h=(0,o.t)(t),l=[];switch(l.push(...((e,t,a)=>{const o=[];switch(a||o.push(r.Hh,r.HV),!a&&t in n?o.push(...n[t]):a&&t in c&&a in c[t]&&o.push(...c[t][a]),t){case"device_tracker":case"person":a||o.push(...Object.entries(e.states).filter(([e,t])=>"zone"===(0,s.m)(e)&&"zone.home"!==e&&t.attributes.friendly_name).map(([e,t])=>t.attributes.friendly_name).sort((t,a)=>(0,i.xL)(t,a,e.locale.language)))}return o})(e,h,a)),h){case"climate":a?"fan_mode"===a?l.push(...t.attributes.fan_modes):"preset_mode"===a?l.push(...t.attributes.preset_modes):"swing_mode"===a?l.push(...t.attributes.swing_modes):"swing_horizontal_mode"===a&&l.push(...t.attributes.swing_horizontal_modes):l.push(...t.attributes.hvac_modes);break;case"event":"event_type"===a&&l.push(...t.attributes.event_types);break;case"fan":"preset_mode"===a&&l.push(...t.attributes.preset_modes);break;case"humidifier":"mode"===a&&l.push(...t.attributes.available_modes);break;case"input_select":case"select":a||l.push(...t.attributes.options);break;case"light":"effect"===a&&t.attributes.effect_list?l.push(...t.attributes.effect_list):"color_mode"===a&&t.attributes.supported_color_modes&&l.push(...t.attributes.supported_color_modes);break;case"media_player":"sound_mode"===a?l.push(...t.attributes.sound_mode_list):"source"===a&&l.push(...t.attributes.source_list);break;case"remote":"current_activity"===a&&l.push(...t.attributes.activity_list);break;case"sensor":a||"enum"!==t.attributes.device_class||l.push(...t.attributes.options);break;case"vacuum":"fan_speed"===a&&l.push(...t.attributes.fan_speed_list);break;case"water_heater":a&&"operation_mode"!==a||l.push(...t.attributes.operation_list)}return[...new Set(l)]}},22533(e,t,a){a.d(t,{i:()=>i});var r=a(52943);const i=(e,t)=>(e=>{switch(e){case"de":case"lb":return!0;default:return!1}})(t)?(0,r.Z)(e):e.toLocaleLowerCase(t)},43661(e,t,a){a.r(t),a.d(t,{HaIconNext:()=>n});var r=a(62826),i=a(22441),s=a(63091),o=a(67094);class n extends o.HaSvgIcon{constructor(...e){super(...e),this.path="rtl"===s.G.document.dir?"M15.41,16.58L10.83,12L15.41,7.41L14,6L8,12L14,18L15.41,16.58Z":"M8.59,16.58L13.17,12L8.59,7.41L10,6L16,12L10,18L8.59,16.58Z"}}(0,r.Cg)([(0,i.MZ)()],n.prototype,"path",void 0),n=(0,r.Cg)([(0,i.EM)("ha-icon-next")],n)},36158(e,t,a){a.a(e,async function(e,t){try{var r=a(62826),i=a(25625),s=a(5124),o=a(22441),n=a(98975),c=a(52943),h=e([n]);n=(h.then?(await h)():h)[0];class l extends s.mN{disconnectedCallback(){super.disconnectedCallback(),this._clearInterval()}connectedCallback(){super.connectedCallback(),this.datetime&&this._startInterval()}createRenderRoot(){return this}firstUpdated(e){super.firstUpdated(e),this._updateRelative()}update(e){super.update(e),this._updateRelative()}_clearInterval(){this._interval&&(window.clearInterval(this._interval),this._interval=void 0)}_startInterval(){this._clearInterval(),this._interval=window.setInterval(()=>this._updateRelative(),6e4)}_updateRelative(){if(this.datetime){const e="string"==typeof this.datetime?(0,i.H)(this.datetime):this.datetime,t=(0,n.K)(e,this.hass.locale);this.innerHTML=this.capitalize?(0,c.Z)(t):t}else this.innerHTML=this.hass.localize("ui.components.relative_time.never")}constructor(...e){super(...e),this.capitalize=!1}}(0,r.Cg)([(0,o.MZ)({attribute:!1})],l.prototype,"hass",void 0),(0,r.Cg)([(0,o.MZ)({attribute:!1})],l.prototype,"datetime",void 0),(0,r.Cg)([(0,o.MZ)({type:Boolean})],l.prototype,"capitalize",void 0),l=(0,r.Cg)([(0,o.EM)("ha-relative-time")],l),t()}catch(e){t(e)}})},62647(e,t,a){var r=a(62826),i=a(9866),s=a(5124),o=a(22441);class n extends i.A{static get styles(){return[i.A.styles,s.AH`:host{font-size:var(--ha-font-size-m);--wa-color-brand-on-quiet:var(
            --ha-tab-active-text-color,
            var(--primary-color)
          );--wa-color-neutral-on-quiet:var(--wa-color-brand-on-quiet);opacity:.8;color:inherit;--wa-space-l:16px}:host([active]:not([disabled])){opacity:1}@media (hover:hover){:host(:hover:not([disabled]):not([active])) .tab{color:var(--wa-color-brand-on-quiet)}}`]}}n=(0,r.Cg)([(0,o.EM)("ha-tab-group-tab")],n)},66289(e,t,a){a.a(e,async function(e,t){try{var r=a(62826),i=a(42814),s=a(5124),o=a(22441),n=a(36356),c=e([i]);i=(c.then?(await c)():c)[0];class h extends i.A{connectedCallback(){super.connectedCallback(),this.addEventListener("keydown",this._handleKeyDown,!0)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("keydown",this._handleKeyDown,!0)}handleClick(e){this._dragScrollController.scrolled||super.handleClick(e)}static get styles(){return[i.A.styles,s.AH`:host{--track-width:2px;--track-color:var(--ha-tab-track-color, var(--divider-color));--indicator-color:var(
            --ha-tab-indicator-color,
            var(--primary-color)
          );--wa-color-neutral-on-quiet:var(--indicator-color)}.tab-group-top ::slotted(ha-tab-group-tab[active]){border-block-end:solid var(--track-width) var(--indicator-color);margin-block-end:calc(-1 * var(--track-width))}.tab-group-start ::slotted(ha-tab-group-tab[active]){border-inline-end:solid var(--track-width) var(--indicator-color);margin-inline-end:calc(-1 * var(--track-width))}.tab-group-end ::slotted(ha-tab-group-tab[active]){border-inline-start:solid var(--track-width) var(--indicator-color);margin-inline-start:calc(-1 * var(--track-width))}.scroll-button::part(base):hover{background-color:transparent}`]}constructor(...e){super(...e),this._dragScrollController=new n.q(this,{selector:".nav"}),this.tabTag="ha-tab-group-tab",this.tabOnly=!0,this._handleKeyDown=e=>{(e.altKey||e.metaKey)&&e.stopPropagation()}}}(0,r.Cg)([(0,o.MZ)({attribute:"tab-tag"})],h.prototype,"tabTag",void 0),(0,r.Cg)([(0,o.MZ)({attribute:"tab-only",type:Boolean})],h.prototype,"tabOnly",void 0),h=(0,r.Cg)([(0,o.EM)("ha-tab-group")],h),t()}catch(e){t(e)}})},48240(e,t,a){a.a(e,async function(e,t){try{a(18111),a(20116),a(61701);var r=a(62826),i=a(5124),s=a(22441),o=a(18350),n=a(38508),c=a(95747),h=e([o,n,c]);[o,n,c]=h.then?(await h)():h;const l="M11,15H13V17H11V15M11,7H13V13H11V7M12,2C6.47,2 2,6.5 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2M12,20A8,8 0 0,1 4,12A8,8 0 0,1 12,4A8,8 0 0,1 20,12A8,8 0 0,1 12,20Z",d="M12 2C6.5 2 2 6.5 2 12S6.5 22 12 22 22 17.5 22 12 17.5 2 12 2M12 20C7.59 20 4 16.41 4 12S7.59 4 12 4 20 7.59 20 12 16.41 20 12 20M16.59 7.58L10 14.17L7.41 11.59L6 13L10 17L18 9L16.59 7.58Z",p="M7.41,8.58L12,13.17L16.59,8.58L18,10L12,16L6,10L7.41,8.58Z",u="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",g="M13,2.03V2.05L13,4.05C17.39,4.59 20.5,8.58 19.96,12.97C19.5,16.61 16.64,19.5 13,19.93V21.93C18.5,21.38 22.5,16.5 21.95,11C21.5,6.25 17.73,2.5 13,2.03M11,2.06C9.05,2.25 7.19,3 5.67,4.26L7.1,5.74C8.22,4.84 9.57,4.26 11,4.06V2.06M4.26,5.67C3,7.19 2.25,9.04 2.05,11H4.05C4.24,9.58 4.8,8.23 5.69,7.1L4.26,5.67M2.06,13C2.26,14.96 3.03,16.81 4.27,18.33L5.69,16.9C4.81,15.77 4.24,14.42 4.06,13H2.06M7.1,18.37L5.67,19.74C7.18,21 9.04,21.79 11,22V20C9.58,19.82 8.23,19.25 7.1,18.37M12.5,7V12.25L17,14.92L16.25,16.15L11,13V7H12.5Z",m="M13,2.03V2.05L13,4.05C17.39,4.59 20.5,8.58 19.96,12.97C19.5,16.61 16.64,19.5 13,19.93V21.93C18.5,21.38 22.5,16.5 21.95,11C21.5,6.25 17.73,2.5 13,2.03M11,2.06C9.05,2.25 7.19,3 5.67,4.26L7.1,5.74C8.22,4.84 9.57,4.26 11,4.06V2.06M4.26,5.67C3,7.19 2.25,9.04 2.05,11H4.05C4.24,9.58 4.8,8.23 5.69,7.1L4.26,5.67M2.06,13C2.26,14.96 3.03,16.81 4.27,18.33L5.69,16.9C4.81,15.77 4.24,14.42 4.06,13H2.06M7.1,18.37L5.67,19.74C7.18,21 9.04,21.79 11,22V20C9.58,19.82 8.23,19.25 7.1,18.37M16.82,15.19L12.71,11.08C13.12,10.04 12.89,8.82 12.03,7.97C11.13,7.06 9.78,6.88 8.69,7.38L10.63,9.32L9.28,10.68L7.29,8.73C6.75,9.82 7,11.17 7.88,12.08C8.74,12.94 9.96,13.16 11,12.76L15.11,16.86C15.29,17.05 15.56,17.05 15.74,16.86L16.78,15.83C17,15.65 17,15.33 16.82,15.19Z",_="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";class b extends i.WF{render(){return i.qy` <ha-generic-picker name="trace" .hass="${this.hass}" .label="${this.hass.localize("ui.panel.config.automation.trace.select_trace")}" .value="${this.value}" .getItems="${this._getTraces}" required> <ha-button slot="field" appearance="filled" variant="neutral" size="small" @click="${this._openPicker}"> ${this._renderTracePickerValue(this.value)} <ha-svg-icon slot="end" .path="${p}"></ha-svg-icon> </ha-button> </ha-generic-picker>`}_openPicker(e){e.stopPropagation(),this.tracePicker?.open()}static get styles(){return[i.AH`ha-generic-picker{width:100%}ha-button{width:100%}`]}constructor(...e){super(...e),this._getTraces=()=>this.traces?.map(e=>{const t=()=>((new Date(e.timestamp.finish).getTime()-new Date(e.timestamp.start).getTime())/1e3).toFixed(2),a={id:e.run_id,primary:(0,c.yg)(new Date(e.timestamp.start),this.hass.locale,this.hass.config)};if("running"===e.state)a.secondary=this.hass.localize("ui.panel.config.automation.trace.picker.still_running"),a.icon_path=g;else if("debugged"===e.state)a.secondary=this.hass.localize("ui.panel.config.automation.trace.picker.debugged"),a.icon_path=m;else if("finished"===e.script_execution)a.secondary=this.hass.localize("ui.panel.config.automation.trace.picker.finished",{executiontime:t()}),a.icon_path=d;else if("aborted"===e.script_execution)a.secondary=this.hass.localize("ui.panel.config.automation.trace.picker.aborted",{executiontime:t()}),a.icon_path=l;else if("cancelled"===e.script_execution)a.secondary=this.hass.localize("ui.panel.config.automation.trace.picker.cancelled",{executiontime:t()}),a.icon_path=l;else{let r,i,s;switch(e.script_execution){case"failed_conditions":r="stopped_failed_conditions",s=_;break;case"failed_single":r="stopped_failed_single",s=_;break;case"failed_max_runs":r="stopped_failed_max_runs",s=_;break;case"error":r="stopped_error",i=e.error,s=l;break;default:r="stopped_unknown_reason",s=u}a.secondary=this.hass.localize(`ui.panel.config.automation.trace.picker.${r}`,{error:i,executiontime:t()}),a.icon_path=s}return a})??[],this._renderTracePickerValue=e=>{const t=this.traces?.find(t=>t.run_id===e);return i.qy`${t?(0,c.yg)(new Date(t.timestamp.start),this.hass.locale,this.hass.config):e}`}}}(0,r.Cg)([(0,s.MZ)({attribute:!1})],b.prototype,"hass",void 0),(0,r.Cg)([(0,s.MZ)({attribute:!1})],b.prototype,"traces",void 0),(0,r.Cg)([(0,s.MZ)({attribute:!1})],b.prototype,"value",void 0),(0,r.Cg)([(0,s.P)("ha-generic-picker")],b.prototype,"tracePicker",void 0),b=(0,r.Cg)([(0,s.EM)("ha-trace-picker")],b),t()}catch(e){t(e)}})},46279(e,t,a){var r=a(62826),i=a(5124),s=a(22441),o=a(14503);a(67094);class n extends i.WF{render(){return i.qy` <div class="timeline-start"> ${this.label?"":i.qy` <ha-svg-icon .path="${this.icon||"M12,20A8,8 0 0,1 4,12A8,8 0 0,1 12,4A8,8 0 0,1 20,12A8,8 0 0,1 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,2Z"}"></ha-svg-icon> `} ${this.lastItem?"":i.qy`<div class="line"></div>`} </div> <div class="content"> <slot></slot> ${this.moreItems?i.qy` <div> ${this._showMore||1===this.moreItems.length?this.moreItems:i.qy` <button class="link" @click="${this._handleShowMore}"> Show ${this.moreItems.length} more items </button> `} </div> `:""} </div> `}_handleShowMore(){this._showMore=!0}static get styles(){return[i.AH`:host{display:flex;flex-direction:row}:host(:not([lastItem])){min-height:50px}:host([label]){margin-top:-8px;font-style:italic;color:var(--timeline-label-color,var(--secondary-text-color))}.timeline-start{display:flex;flex-direction:column;align-items:center;margin-right:8px;margin-inline-end:8px;margin-inline-start:initial;width:24px}:host([not-enabled]) ha-svg-icon{opacity:.5}ha-svg-icon{color:var(--timeline-ball-color,var(--timeline-color,var(--secondary-text-color)));border-radius:var(--ha-border-radius-circle)}:host([raised]) ha-svg-icon{transform:scale(1.3)}.line{flex:1;width:2px;background-color:var(--timeline-line-color,var(--timeline-color,var(--secondary-text-color)));margin:4px 0}.content{margin-top:2px}:host(:not([lastItem])) .content{padding-bottom:16px}:host([label]) .content{margin-top:0;padding-top:6px}`,o.og]}constructor(...e){super(...e),this.label=!1,this.raised=!1,this.notEnabled=!1,this.lastItem=!1,this._showMore=!1}}(0,r.Cg)([(0,s.MZ)({type:Boolean,reflect:!0})],n.prototype,"label",void 0),(0,r.Cg)([(0,s.MZ)({type:Boolean,reflect:!0})],n.prototype,"raised",void 0),(0,r.Cg)([(0,s.MZ)({attribute:"not-enabled",reflect:!0,type:Boolean})],n.prototype,"notEnabled",void 0),(0,r.Cg)([(0,s.MZ)({attribute:"last-item",type:Boolean})],n.prototype,"lastItem",void 0),(0,r.Cg)([(0,s.MZ)({type:String})],n.prototype,"icon",void 0),(0,r.Cg)([(0,s.MZ)({attribute:!1})],n.prototype,"moreItems",void 0),(0,r.Cg)([(0,s.wk)()],n.prototype,"_showMore",void 0),n=(0,r.Cg)([(0,s.EM)("ha-timeline")],n)},98920(e,t,a){a.a(e,async function(e,t){try{var r=a(62826),i=a(53289),s=a(5124),o=a(22441),n=a(15717),c=a(26300),h=e([n,c]);[n,c]=h.then?(await h)():h;class l extends s.WF{render(){return s.qy` <ha-code-editor .value="${(0,i.dump)(this.trace.blueprint_inputs||"").trimRight()}" read-only dir="ltr"></ha-code-editor> `}}(0,r.Cg)([(0,o.MZ)({attribute:!1})],l.prototype,"trace",void 0),l=(0,r.Cg)([(0,o.EM)("ha-trace-blueprint-config")],l),t()}catch(e){t(e)}})},7370(e,t,a){a.a(e,async function(e,t){try{var r=a(62826),i=a(53289),s=a(5124),o=a(22441),n=a(15717),c=a(26300),h=e([n,c]);[n,c]=h.then?(await h)():h;class l extends s.WF{render(){return s.qy` <ha-code-editor .value="${(0,i.dump)(this.trace.config).trimRight()}" read-only dir="ltr"></ha-code-editor> `}static get styles(){return[s.AH``]}}(0,r.Cg)([(0,o.MZ)({attribute:!1})],l.prototype,"trace",void 0),l=(0,r.Cg)([(0,o.EM)("ha-trace-config")],l),t()}catch(e){t(e)}})},193(e,t,a){a.a(e,async function(e,t){try{var r=a(62826),i=a(5124),s=a(22441),o=(a(67146),a(11184)),n=e([o]);o=(n.then?(await n)():n)[0];class c extends i.WF{render(){return this.logbookEntries.length?i.qy` <ha-logbook-renderer relative-time .hass="${this.hass}" .entries="${this.logbookEntries}" .narrow="${this.narrow}"></ha-logbook-renderer> <hat-logbook-note .hass="${this.hass}" .domain="${this.trace.domain}"></hat-logbook-note> `:i.qy`<div class="padded-box"> ${this.hass.localize("ui.panel.config.automation.trace.path.no_logbook_entries")} </div>`}static get styles(){return[i.AH`.padded-box{padding:16px}`]}constructor(...e){super(...e),this.narrow=!1}}(0,r.Cg)([(0,s.MZ)({attribute:!1})],c.prototype,"hass",void 0),(0,r.Cg)([(0,s.MZ)({type:Boolean,reflect:!0})],c.prototype,"narrow",void 0),(0,r.Cg)([(0,s.MZ)({attribute:!1})],c.prototype,"trace",void 0),(0,r.Cg)([(0,s.MZ)({attribute:!1})],c.prototype,"logbookEntries",void 0),c=(0,r.Cg)([(0,s.EM)("ha-trace-logbook")],c),t()}catch(e){t(e)}})},29804(e,t,a){a.a(e,async function(e,t){try{a(74423),a(44114),a(18111),a(61701);var r=a(62826),i=a(35211),s=a(53289),o=a(5124),n=a(22441),c=a(95747),h=a(88249),l=a(79800),d=a(22792),p=a(45464),u=a(61165),g=a(11184),m=a(15717),_=a(26300),b=a(66289),v=(a(62647),a(67146),e([g,m,_,b,p,l,c]));[g,m,_,b,p,l,c]=v.then?(await v)():v;const f=["step_config","changed_variables","logbook"];class y extends o.WF{render(){return o.qy` <div class="padded-box trace-info"> ${this._renderSelectedTraceInfo()} </div> <ha-tab-group @wa-tab-show="${this._handleTabChanged}"> ${f.map(e=>o.qy` <ha-tab-group-tab slot="nav" .active="${this._view===e}" .panel="${e}"> ${this.hass.localize(`ui.panel.config.automation.trace.tabs.${e}`)} </ha-tab-group-tab> `)} </ha-tab-group> ${"step_config"===this._view?this._renderSelectedConfig():"changed_variables"===this._view?this._renderChangedVars():this._renderLogbook()} `}_renderSelectedTraceInfo(){const e=this.trace.trace;if(!this.selected?.path)return this.hass.localize("ui.panel.config.automation.trace.path.choose");const t=this.selected.path.split("/");if("default"===t[t.length-1]){const a=e[t.slice(0,t.length-1).join("/")];if(a&&"default"===a[0]?.result?.choice)return this.hass.localize("ui.panel.config.automation.trace.path.default_action_executed")}if(!(this.selected.path in e))return this.hass.localize("ui.panel.config.automation.trace.path.no_further_execution");const a=[];let r=!1;for(const i of Object.keys(this.trace.trace)){if(r){if(i in this.renderedNodes)break}else{if(i!==this.selected.path)continue;r=!0}const n=e[i],d=i.substring(this.selected.path.length+1).split("/");let u=this.selected.config;for(const e of d)["undefined","string"].includes(typeof u[e])||(u=u[e]);a.push(n.map((e,a)=>{const{path:r,timestamp:d,result:g,error:m,changed_variables:_,...b}=e;if(!1===g?.enabled)return o.qy`${this.hass.localize("ui.panel.config.automation.trace.path.disabled_step")}`;const v=this.selected.type;return o.qy` ${i===this.selected.path?u.alias?o.qy`<h2>${u.alias}</h2>`:"trigger"===v?o.qy`<h2> ${(0,l.g)((0,h.vO)({...u}),this.hass,this._entityReg)} </h2>`:"condition"===v?o.qy`<h2> ${(0,l.p)(u,this.hass,this._entityReg)} </h2>`:"action"===v?o.qy`<h2> ${(0,p.u)(this.hass,this._entityReg,u)} </h2>`:"chooseOption"===v?o.qy`<h2> ${this.hass.localize("ui.panel.config.automation.editor.actions.type.choose.option",{number:t[t.length-1]})} </h2>`:o.s6:o.qy`<h2> ${i.substring(this.selected.path.length+1)} </h2>`} ${1===n.length?o.s6:o.qy`<h3> ${this.hass.localize("ui.panel.config.automation.trace.path.iteration",{number:a+1})} </h3>`} ${i.substring(this.selected.path.length+1).includes("condition")?o.qy`[${(0,l.p)(u,this.hass,this._entityReg)}]<br>`:o.s6} ${this.hass.localize("ui.panel.config.automation.trace.path.executed",{time:(0,c.yg)(new Date(d),this.hass.locale,this.hass.config)})} <br> ${m?o.qy`<div class="error"> ${this.hass.localize("ui.panel.config.automation.trace.path.error",{error:m})} </div>`:o.s6} ${g?o.qy`${this.hass.localize("ui.panel.config.automation.trace.path.result")} <pre>${(0,s.dump)(g)}</pre>`:o.s6} ${0===Object.keys(b).length?o.s6:o.qy`<pre>${(0,s.dump)(b)}</pre>`} ${u.entity_id&&i.substring(this.selected.path.length+1).includes("entity_id")?o.qy`<pre>entity: ${u.entity_id}</pre>`:o.s6} `}))}return a}_renderSelectedConfig(){if(!this.selected?.path)return o.s6;const e=(0,u.Ci)(this.trace.config,this.selected.path);return e?o.qy`<ha-code-editor .value="${(0,s.dump)(e).trimEnd()}" read-only dir="ltr"></ha-code-editor>`:this.hass.localize("ui.panel.config.automation.trace.path.unable_to_find_config")}_renderChangedVars(){const e=this.trace.trace[this.selected.path];return void 0===e?o.qy`<div class="padded-box"> ${this.hass.localize("ui.panel.config.automation.trace.path.step_not_executed")} </div>`:o.qy` <div class="padded-box"> ${e.map((t,a)=>o.qy` ${e.length>1?o.qy`<p> ${this.hass.localize("ui.panel.config.automation.trace.path.iteration",{number:a+1})} </p>`:""} ${0===Object.keys(t.changed_variables||{}).length?this.hass.localize("ui.panel.config.automation.trace.path.no_variables_changed"):o.qy`<ha-code-editor read-only dir="ltr" .value="${(0,s.dump)(t.changed_variables).trimEnd()}"></ha-code-editor>`} `)} </div> `}_renderLogbook(){const e=this.trace.trace,t=e[this.selected.path],a=Object.keys(this.trackedNodes),r=a.indexOf(this.selected.path);if(-1===r)return o.qy`<div class="padded-box"> ${this.hass.localize("ui.panel.config.automation.trace.path.step_not_executed")} </div>`;let i;if(r===a.length-1){const e=new Date(t[0].timestamp),a=this.logbookEntries.findIndex(t=>new Date(1e3*t.when)>=e);i=-1===a?[]:this.logbookEntries.slice(a)}else{const s=e[a[r+1]],o=new Date(t[0].timestamp),n=new Date(s[0].timestamp);i=[];for(const e of this.logbookEntries||[]){const t=new Date(1e3*e.when);if(t>=o){if(!(t<n))break;i.push(e)}}}return i.length?o.qy` <ha-logbook-renderer relative-time .hass="${this.hass}" .entries="${i}" .narrow="${this.narrow}"></ha-logbook-renderer> <hat-logbook-note .hass="${this.hass}" .domain="${this.trace.domain}"></hat-logbook-note> `:o.qy`<div class="padded-box"> ${this.hass.localize("ui.panel.config.automation.trace.path.no_logbook_entries")} </div>`}_handleTabChanged(e){this._view=e.detail.name}static get styles(){return[o.AH`.padded-box{margin:16px}:host(:not([narrow])) .trace-info{min-height:250px}pre{margin:0}.error{color:var(--error-color)}ha-tab-group{background-color:var(--primary-background-color);border-top:1px solid var(--divider-color);border-bottom:1px solid var(--divider-color)}ha-tab-group-tab::part(base){padding:2px 16px}`]}constructor(...e){super(...e),this.narrow=!1,this.renderedNodes={},this._view="step_config",this._entityReg=[]}}(0,r.Cg)([(0,n.MZ)({attribute:!1})],y.prototype,"hass",void 0),(0,r.Cg)([(0,n.MZ)({type:Boolean,reflect:!0})],y.prototype,"narrow",void 0),(0,r.Cg)([(0,n.MZ)({attribute:!1})],y.prototype,"trace",void 0),(0,r.Cg)([(0,n.MZ)({attribute:!1})],y.prototype,"logbookEntries",void 0),(0,r.Cg)([(0,n.MZ)({attribute:!1})],y.prototype,"selected",void 0),(0,r.Cg)([(0,n.MZ)({attribute:!1})],y.prototype,"renderedNodes",void 0),(0,r.Cg)([(0,n.MZ)({attribute:!1})],y.prototype,"trackedNodes",void 0),(0,r.Cg)([(0,n.wk)()],y.prototype,"_view",void 0),(0,r.Cg)([(0,n.wk)(),(0,i.Fg)({context:d.ih,subscribe:!0})],y.prototype,"_entityReg",void 0),(0,r.Cg)([(0,n.wk)(),(0,i.Fg)({context:d.HD,subscribe:!0})],y.prototype,"_labelReg",void 0),y=(0,r.Cg)([(0,n.EM)("ha-trace-path-details")],y),t()}catch(e){t(e)}})},73003(e,t,a){a.a(e,async function(e,t){try{var r=a(62826),i=a(5124),s=a(22441),o=(a(67146),a(91819)),n=e([o]);o=(n.then?(await n)():n)[0];class c extends i.WF{render(){return i.qy` <hat-trace-timeline .hass="${this.hass}" .trace="${this.trace}" .logbookEntries="${this.logbookEntries}" .selectedPath="${this.selected.path}" allow-pick> </hat-trace-timeline> <hat-logbook-note .hass="${this.hass}" .domain="${this.trace.domain}"></hat-logbook-note> `}static get styles(){return[i.AH`:host{display:block;padding:16px}`]}}(0,r.Cg)([(0,s.MZ)({attribute:!1})],c.prototype,"hass",void 0),(0,r.Cg)([(0,s.MZ)({attribute:!1})],c.prototype,"trace",void 0),(0,r.Cg)([(0,s.MZ)({attribute:!1})],c.prototype,"logbookEntries",void 0),(0,r.Cg)([(0,s.MZ)({attribute:!1})],c.prototype,"selected",void 0),c=(0,r.Cg)([(0,s.EM)("ha-trace-timeline")],c),t()}catch(e){t(e)}})},2271(e,t,a){a(44114),a(18111),a(7588),a(61701);var r=a(62826),i=a(5124),s=a(22441),o=a(6412);class n extends i.WF{_updateBranches(e){let t=0;const a=[],r=[];e.target.assignedElements().forEach(e=>{const i=e.clientWidth,s=e.clientHeight;r.push({x:i/2+t,height:s,start:e.hasAttribute("graph-start"),end:e.hasAttribute("graph-end"),track:e.hasAttribute("track")}),t+=i,a.push(s)}),this._totalWidth=t,this._maxHeight=Math.max(...a),this._branches=r.sort((e,t)=>e.track&&!t.track?1:e.track&&t.track?0:-1)}render(){return i.qy` <slot name="head"></slot> ${this.start?i.s6:i.qy` <svg id="top" width="${this._totalWidth}"> ${this._branches.map(e=>e.start?"":i.JW` <path class="${(0,o.H)({track:e.track})}" d="
                      M ${this._totalWidth/2} 0
                      L ${e.x} ${20}
                      "/> `)} </svg> `} <div id="branches"> <svg id="lines" width="${this._totalWidth}" height="${this._maxHeight}"> ${this._branches.map(e=>e.end?"":i.JW` <path class="${(0,o.H)({track:e.track})}" d="
                        M ${e.x} ${e.height}
                        v ${this._maxHeight-e.height}
                        "/> `)} </svg> <slot @slotchange="${this._updateBranches}"></slot> </div> ${this.short?i.s6:i.qy` <svg id="bottom" width="${this._totalWidth}"> ${this._branches.map(e=>e.end?"":i.JW` <path class="${(0,o.H)({track:e.track})}" d="
                      M ${e.x} 0
                      V ${10}
                      L ${this._totalWidth/2} ${30}
                      "/> `)} </svg> `} `}constructor(...e){super(...e),this.disabled=!1,this.selected=!1,this.start=!1,this.short=!1,this._branches=[],this._totalWidth=0,this._maxHeight=0}}n.styles=i.AH`:host{position:relative;display:flex;flex-direction:column;align-items:center}:host(:focus){outline:0}#branches{position:relative;display:flex;flex-direction:row;align-items:start}::slotted(*){z-index:1}::slotted([slot=head]){margin-bottom:calc(var(--hat-graph-branch-height)/ -2)}#lines{position:absolute}#top{height:var(--hat-graph-branch-height)}#bottom{height:calc(var(--hat-graph-branch-height) + var(--hat-graph-spacing))}path{stroke:var(--stroke-clr);stroke-width:2;fill:none}path.track{stroke:var(--track-clr)}:host([disabled]) path{stroke:var(--disabled-clr)}`,(0,r.Cg)([(0,s.MZ)({type:Boolean,reflect:!0})],n.prototype,"disabled",void 0),(0,r.Cg)([(0,s.MZ)({type:Boolean})],n.prototype,"selected",void 0),(0,r.Cg)([(0,s.MZ)({type:Boolean})],n.prototype,"start",void 0),(0,r.Cg)([(0,s.MZ)({type:Boolean})],n.prototype,"short",void 0),(0,r.Cg)([(0,s.wk)()],n.prototype,"_branches",void 0),n=(0,r.Cg)([(0,s.EM)("hat-graph-branch")],n)},74091(e,t,a){var r=a(62826),i=a(5124),s=a(22441),o=a(37177);class n extends i.WF{updated(e){e.has("noFocus")&&(this.hasAttribute("tabindex")||this.noFocus?void 0!==e.get("noFocus")&&this.noFocus&&this.removeAttribute("tabindex"):this.setAttribute("tabindex","0"))}render(){const e=30+(this.graphStart?2:11);return i.qy` <svg class="${o.n?"safari":""}" width="${40}px" height="${e}px" viewBox="-${Math.ceil(20)} -${this.graphStart?Math.ceil(e/2):Math.ceil(25)} ${40} ${e}"> ${this.graphStart?i.s6:i.JW` <path class="connector" d="
              M 0 ${-25}
              L 0 0
            " line-caps="round"/> `} <g class="node"> <circle cx="0" cy="0" r="${15}"/> ${this.error?i.JW` <g class="error"> <circle cx="-12" cy="${-15}" r="8"></circle> <path transform="translate(-18 -21) scale(.5)" class="exclamation" d="${"M10 3H14V14H10V3M10 21V17H14V21H10Z"}/"> </path></g> `:i.s6} ${this.badge?i.JW` <g class="number"> <circle cx="12" cy="${-15}" r="8"></circle> <text x="12" y="${-15}" text-anchor="middle" alignment-baseline="middle">${this.badge>9?"9+":this.badge}</text> </g> `:i.s6} <g style="pointer-events:none" transform="translate(-12 -12)"> ${this.iconPath?i.JW`<path class="icon" d="${this.iconPath}/"></path>`:i.JW`<foreignObject><span class="icon"><slot name="icon"></slot></span></foreignObject>`} </g> </g> </svg> `}constructor(...e){super(...e),this.disabled=!1,this.error=!1,this.notEnabled=!1,this.graphStart=!1,this.noFocus=!1}}n.styles=i.AH`:host{display:flex;flex-direction:column;min-width:calc(var(--hat-graph-node-size) + var(--hat-graph-spacing));height:calc(var(--hat-graph-node-size) + var(--hat-graph-spacing) + 1px)}:host([graph-start]){height:calc(var(--hat-graph-node-size) + 2px)}:host([track]){--stroke-clr:var(--track-clr);--icon-clr:var(--default-icon-clr)}:host([active]) circle{--stroke-clr:var(--active-clr);--icon-clr:var(--default-icon-clr)}:host(:focus){outline:0}:host(:hover) circle{--stroke-clr:var(--hover-clr);--icon-clr:var(--default-icon-clr)}:host([not-enabled]) circle{--stroke-clr:var(--disabled-clr)}:host([not-enabled][active]) circle{--stroke-clr:var(--disabled-active-clr)}:host([not-enabled]:hover) circle{--stroke-clr:var(--disabled-hover-clr)}svg:not(.safari){width:100%;height:100%}circle,path.connector{stroke:var(--stroke-clr);stroke-width:2;fill:none}circle{fill:var(--background-clr);stroke:var(--circle-clr,var(--stroke-clr))}.error circle{fill:var(--error-color);stroke:none;stroke-width:0}.error .exclamation{fill:var(--text-primary-color)}.number circle{fill:var(--track-clr);stroke:none;stroke-width:0}.number text{font-size:var(--ha-font-size-xs);fill:var(--text-primary-color)}path.icon{fill:var(--icon-clr)}foreignObject{width:24px;height:24px}.icon{color:var(--icon-clr)}`,(0,r.Cg)([(0,s.MZ)({attribute:!1})],n.prototype,"iconPath",void 0),(0,r.Cg)([(0,s.MZ)({type:Boolean,reflect:!0})],n.prototype,"disabled",void 0),(0,r.Cg)([(0,s.MZ)({type:Boolean})],n.prototype,"error",void 0),(0,r.Cg)([(0,s.MZ)({attribute:"not-enabled",reflect:!0,type:Boolean})],n.prototype,"notEnabled",void 0),(0,r.Cg)([(0,s.MZ)({attribute:"graph-start",reflect:!0,type:Boolean})],n.prototype,"graphStart",void 0),(0,r.Cg)([(0,s.MZ)({type:Boolean,attribute:"nofocus"})],n.prototype,"noFocus",void 0),(0,r.Cg)([(0,s.MZ)({reflect:!0,type:Number})],n.prototype,"badge",void 0),n=(0,r.Cg)([(0,s.EM)("hat-graph-node")],n)},3903(e,t,a){var r=a(62826),i=a(5124),s=a(22441);class o extends i.WF{render(){return i.qy` <svg viewBox="-${5} 0 10 ${41}"> <path d="
              M 0 ${41}
              V 0
            " line-caps="round"/> } </svg> `}constructor(...e){super(...e),this.disabled=!1}}o.styles=i.AH`:host{display:flex;flex-direction:column;align-items:center}svg{width:var(--hat-graph-spacing);height:calc(var(--hat-graph-spacing) + var(--hat-graph-node-size) + 1px)}:host([track]){--stroke-clr:var(--track-clr)}:host-context([disabled]){--stroke-clr:var(--disabled-clr)}path{stroke:var(--stroke-clr);stroke-width:2;fill:none}`,(0,r.Cg)([(0,s.MZ)({reflect:!0,type:Boolean})],o.prototype,"disabled",void 0),o=(0,r.Cg)([(0,s.EM)("hat-graph-spacer")],o)},67146(e,t,a){var r=a(62826),i=a(5124),s=a(22441);class o extends i.WF{render(){return"script"===this.domain?this.hass.localize("ui.panel.config.automation.trace.messages.not_all_entries_are_related_script_note"):this.hass.localize("ui.panel.config.automation.trace.messages.not_all_entries_are_related_automation_note")}constructor(...e){super(...e),this.domain="automation"}}o.styles=i.AH`:host{display:block;text-align:center;font-style:italic;padding:16px;margin-top:8px}`,(0,r.Cg)([(0,s.MZ)({attribute:!1})],o.prototype,"hass",void 0),(0,r.Cg)([(0,s.MZ)()],o.prototype,"domain",void 0),o=(0,r.Cg)([(0,s.EM)("hat-logbook-note")],o)},68886(e,t,a){a.a(e,async function(e,t){try{a(74423),a(18111),a(20116),a(61701),a(13579);var r=a(62826),i=a(5124),s=a(22441),o=a(44537),n=a(1087),c=a(88249),h=a(84025),l=a(26300),d=a(65329),p=(a(2271),a(74091),a(3903),a(30780)),u=e([l,d]);[l,d]=u.then?(await u)():u;const g="M4 2A2 2 0 0 0 2 4V12H4V8H6V12H8V4A2 2 0 0 0 6 2H4M4 4H6V6H4M22 15.5V14A2 2 0 0 0 20 12H16V22H20A2 2 0 0 0 22 20V18.5A1.54 1.54 0 0 0 20.5 17A1.54 1.54 0 0 0 22 15.5M20 20H18V18H20V20M20 16H18V14H20M5.79 21.61L4.21 20.39L18.21 2.39L19.79 3.61Z",m="M11,5H8L12,1L16,5H13V9.43C12.25,9.89 11.58,10.46 11,11.12V5M22,11L18,7V10C14.39,9.85 11.31,12.57 11,16.17C9.44,16.72 8.62,18.44 9.17,20C9.72,21.56 11.44,22.38 13,21.83C14.56,21.27 15.38,19.56 14.83,18C14.53,17.14 13.85,16.47 13,16.17C13.47,12.17 17.47,11.97 17.95,11.97V14.97L22,11M10.63,11.59C9.3,10.57 7.67,10 6,10V7L2,11L6,15V12C7.34,12.03 8.63,12.5 9.64,13.4C9.89,12.76 10.22,12.15 10.63,11.59Z",_="M13,20H11V8L5.5,13.5L4.08,12.08L12,4.16L19.92,12.08L18.5,13.5L13,8V20Z",b="M21 13H14.4L19.1 17.7L17.7 19.1L13 14.4V21H11V14.3L6.3 19L4.9 17.6L9.4 13H3V11H9.6L4.9 6.3L6.3 4.9L11 9.6V3H13V9.4L17.6 4.8L19 6.3L14.3 11H21V13Z",v="M19.59,7L12,14.59L6.41,9H11V7H3V15H5V10.41L12,17.41L21,8.41",f="M20,5.41L18.59,4L7,15.59V9H5V19H15V17H8.41",y="M14,4L16.29,6.29L13.41,9.17L14.83,10.59L17.71,7.71L20,10V4M10,4H4V10L6.29,7.71L11,12.41V20H13V11.59L7.71,6.29",$="M19,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,3M19,5V19H5V5H19Z",k="M19,19H5V5H15V3H5C3.89,3 3,3.89 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V11H19M7.91,10.08L6.5,11.5L11,16L21,6L19.59,4.58L11,13.17L7.91,10.08Z",w="M7.41,8.58L12,13.17L16.59,8.58L18,10L12,16L6,10L7.41,8.58Z",C="M7.41,15.41L12,10.83L16.59,15.41L18,14L12,8L6,14L7.41,15.41Z",x="M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z",M="M8,3A2,2 0 0,0 6,5V9A2,2 0 0,1 4,11H3V13H4A2,2 0 0,1 6,15V19A2,2 0 0,0 8,21H10V19H8V14A2,2 0 0,0 6,12A2,2 0 0,0 8,10V5H10V3M16,3A2,2 0 0,1 18,5V9A2,2 0 0,0 20,11H21V13H20A2,2 0 0,0 18,15V19A2,2 0 0,1 16,21H14V19H16V14A2,2 0 0,1 18,12A2,2 0 0,1 16,10V5H14V3H16Z",L="M15,4V6H18V18H15V20H20V4M4,4V20H9V18H6V6H9V4H4Z",H="M7,13V11H21V13H7M7,19V17H21V19H7M7,7V5H21V7H7M3,8V5H2V4H4V8H3M2,17V16H5V20H2V19H4V18.5H3V17.5H4V17H2M4.25,10A0.75,0.75 0 0,1 5,10.75C5,10.95 4.92,11.14 4.79,11.27L3.12,13H5V14H2V13.08L4,11H2V10H4.25Z",V="M17.65,6.35C16.2,4.9 14.21,4 12,4A8,8 0 0,0 4,12A8,8 0 0,0 12,20C15.73,20 18.84,17.45 19.73,14H17.65C16.83,16.33 14.61,18 12,18A6,6 0 0,1 6,12A6,6 0 0,1 12,6C13.66,6 15.14,6.69 16.22,7.78L13,11H20V4L17.65,6.35Z",A="M12,5A2,2 0 0,1 14,7C14,7.24 13.96,7.47 13.88,7.69C17.95,8.5 21,11.91 21,16H3C3,11.91 6.05,8.5 10.12,7.69C10.04,7.47 10,7.24 10,7A2,2 0 0,1 12,5M22,19H2V17H22V19Z",N="M16,4.5V7H5V9H16V11.5L19.5,8M16,12.5V15H5V17H16V19.5L19.5,16";class q extends i.WF{_selectNode(e,t,a){return()=>{(0,n.r)(this,"graph-node-selected",{config:e,path:t,type:a})}}_renderTrigger(e,t){const a=`trigger/${t}`,r=this.trace&&a in this.trace.trace;return this.renderedNodes[a]={config:e,path:a,type:"trigger"},r&&(this.trackedNodes[a]=this.renderedNodes[a]),i.qy` <hat-graph-node graph-start ?track="${r}" @focus="${this._selectNode(e,a,"trigger")}" ?active="${this.selected===a}" .iconPath="${b}" .notEnabled="${"enabled"in e&&!1===e.enabled}" .error="${this.trace.trace[a]?.some(e=>e.error)}" tabindex="${r?"0":"-1"}"></hat-graph-node> `}_renderCondition(e,t){const a=`condition/${t}`;return this.renderedNodes[a]={config:e,path:a,type:"condition"},this.trace&&a in this.trace.trace&&(this.trackedNodes[a]=this.renderedNodes[a]),this._renderConditionNode(e,a)}_renderActionNode(e,t,a=!1,r=!1){const i=Object.keys(this._typeRenderers).find(t=>t in e)||"other";return this.renderedNodes[t]={config:e,path:t,type:"action"},this.trace&&t in this.trace.trace&&(this.trackedNodes[t]=this.renderedNodes[t]),this._typeRenderers[i].bind(this)(e,t,a,r)}_renderChooseNode(e,t,a=!1,r=!1){const s=this.trace.trace[t],n=s?s.map(e=>void 0===e.result||"default"===e.result.choice?"default":e.result.choice):[],c=n.includes("default");return i.qy` <hat-graph-branch tabindex="${void 0===s?"-1":"0"}" @focus="${this._selectNode(e,t,"action")}" ?track="${void 0!==s}" ?active="${this.selected===t}" .notEnabled="${r||!1===e.enabled}"> <hat-graph-node .graphStart="${a}" .iconPath="${m}" ?track="${void 0!==s}" ?active="${this.selected===t}" .notEnabled="${r||!1===e.enabled}" .error="${this.trace.trace[t]?.some(e=>e.error)}" slot="head" nofocus></hat-graph-node> ${e.choose?(0,o.e)(e.choose)?.map((a,c)=>{const h=`${t}/choose/${c}`,l=n.includes(c);return this.renderedNodes[h]={config:a,path:h,type:"chooseOption"},l&&(this.trackedNodes[h]=this.renderedNodes[h]),i.qy` <div class="graph-container" ?track="${l}"> <hat-graph-node .iconPath="${!s||l?k:$}" @focus="${this._selectNode(a,h,"chooseOption")}" ?track="${l}" ?active="${this.selected===h}" .notEnabled="${r||!1===e.enabled}"></hat-graph-node> ${null!==a.sequence?(0,o.e)(a.sequence).map((t,a)=>this._renderActionNode(t,`${h}/sequence/${a}`,!1,r||!1===e.enabled)):""} </div> `}):""} <div ?track="${c}"> <hat-graph-spacer ?track="${c}"></hat-graph-spacer> ${null!==e.default?(0,o.e)(e.default)?.map((a,i)=>this._renderActionNode(a,`${t}/default/${i}`,!1,r||!1===e.enabled)):""} </div> </hat-graph-branch> `}_renderIfNode(e,t,a=!1,r=!1){const s=this.trace.trace[t];let n=!1,c=!1;for(const e of s||[])if(n||"then"!==e.result?.choice||(n=!0),(c||"else"!==e.result?.choice)&&e.result||(c=!0),c&&n)break;return i.qy` <hat-graph-branch tabindex="${void 0===s?"-1":"0"}" @focus="${this._selectNode(e,t,"action")}" ?track="${void 0!==s}" ?active="${this.selected===t}" .notEnabled="${r||!1===e.enabled}"> <hat-graph-node .graphStart="${a}" .iconPath="${y}" ?track="${void 0!==s}" ?active="${this.selected===t}" .notEnabled="${r||!1===e.enabled}" slot="head" nofocus></hat-graph-node> ${e.else?i.qy`<div class="graph-container" ?track="${c}"> <hat-graph-node .iconPath="${v}" ?track="${c}" ?active="${this.selected===t}" .notEnabled="${r||!1===e.enabled}" nofocus></hat-graph-node>${(0,o.e)(e.else).map((a,i)=>this._renderActionNode(a,`${t}/else/${i}`,!1,r||!1===e.enabled))} </div>`:i.qy`<hat-graph-spacer ?track="${c}"></hat-graph-spacer>`} <div class="graph-container" ?track="${n}"> <hat-graph-node .iconPath="${f}" ?track="${n}" ?active="${this.selected===t}" .notEnabled="${r||!1===e.enabled}" nofocus></hat-graph-node> ${(0,o.e)(e.then??[]).map((a,i)=>this._renderActionNode(a,`${t}/then/${i}`,!1,r||!1===e.enabled))} </div> </hat-graph-branch> `}_renderConditionNode(e,t,a=!1,r=!1){const s=this.trace.trace[t];let o=!1,n=!1,c=!1;if(s)for(const e of s)if(e.result&&(o=!0,e.result.result?n=!0:c=!0),n&&c)break;return i.qy` <hat-graph-branch @focus="${this._selectNode(e,t,"condition")}" ?track="${o}" ?active="${this.selected===t}" .notEnabled="${r||!1===e.enabled}" tabindex="${void 0===s?"-1":"0"}" short> <hat-graph-node .graphStart="${a}" slot="head" ?track="${o}" ?active="${this.selected===t}" .notEnabled="${r||!1===e.enabled}" .iconPath="${g}" nofocus></hat-graph-node> <div style="${"width: 40px;"}" graph-start graph-end></div> <div ?track="${n}"></div> <hat-graph-node .iconPath="${x}" nofocus ?track="${c}" ?active="${this.selected===t}" .notEnabled="${r||!1===e.enabled}"></hat-graph-node> </hat-graph-branch> `}_renderRepeatNode(e,t,a=!1,r=!1){const s=this.trace.trace[t],n=this.trace?.trace[`${t}/repeat/sequence/0`]?.length;return i.qy` <hat-graph-branch tabindex="${void 0===s?"-1":"0"}" @focus="${this._selectNode(e,t,"action")}" ?track="${t in this.trace.trace}" ?active="${this.selected===t}" .notEnabled="${r||!1===e.enabled}"> <hat-graph-node .graphStart="${a}" .iconPath="${V}" ?track="${t in this.trace.trace}" ?active="${this.selected===t}" .notEnabled="${r||!1===e.enabled}" slot="head" nofocus></hat-graph-node> <hat-graph-node .iconPath="${_}" ?track="${n>1}" ?active="${this.selected===t}" .notEnabled="${r||!1===e.enabled}" nofocus .badge="${n>1?n:void 0}"></hat-graph-node> <div ?track="${s}"> ${(0,o.e)(e.repeat.sequence).map((a,i)=>this._renderActionNode(a,`${t}/repeat/sequence/${i}`,!1,r||!1===e.enabled))} </div> </hat-graph-branch> `}_renderServiceNode(e,t,a=!1,r=!1){return i.qy` <hat-graph-node .graphStart="${a}" .iconPath="${e.action?void 0:A}" @focus="${this._selectNode(e,t,"action")}" ?track="${t in this.trace.trace}" ?active="${this.selected===t}" .notEnabled="${r||!1===e.enabled}" .error="${this.trace.trace[t]?.some(e=>e.error)}" tabindex="${this.trace&&t in this.trace.trace?"0":"-1"}"> ${e.action?i.qy`<ha-service-icon slot="icon" .hass="${this.hass}" .service="${e.action}"></ha-service-icon>`:i.s6} </hat-graph-node> `}_renderWaitNode(e,t,a=!1,r=!1){return i.qy` <hat-graph-node .graphStart="${a}" .iconPath="${M}" @focus="${this._selectNode(e,t,"action")}" ?track="${t in this.trace.trace}" ?active="${this.selected===t}" .notEnabled="${r||!1===e.enabled}" .error="${this.trace.trace[t]?.some(e=>e.error)}" tabindex="${this.trace&&t in this.trace.trace?"0":"-1"}"></hat-graph-node> `}_renderSequenceNode(e,t,a=!1,r=!1){const s=this.trace.trace[t];return i.qy` <hat-graph-branch tabindex="${void 0===s?"-1":"0"}" @focus="${this._selectNode(e,t,"action")}" ?track="${t in this.trace.trace}" ?active="${this.selected===t}" .notEnabled="${r||!1===e.enabled}"> <div class="graph-container" ?track="${t in this.trace.trace}"> <hat-graph-node .graphStart="${a}" .iconPath="${H}" ?track="${t in this.trace.trace}" ?active="${this.selected===t}" .notEnabled="${r||!1===e.enabled}" slot="head" nofocus></hat-graph-node> ${(0,o.e)(e.sequence).map((a,i)=>this._renderActionNode(a,`${t}/sequence/${i}`,!1,r||!1===e.enabled))} </div> </hat-graph-branch> `}_renderParallelNode(e,t,a=!1,r=!1){const s=this.trace.trace[t];return i.qy` <hat-graph-branch tabindex="${void 0===s?"-1":"0"}" @focus="${this._selectNode(e,t,"action")}" ?track="${t in this.trace.trace}" ?active="${this.selected===t}" .notEnabled="${r||!1===e.enabled}"> <hat-graph-node .graphStart="${a}" .iconPath="${N}" ?track="${t in this.trace.trace}" ?active="${this.selected===t}" .notEnabled="${r||!1===e.enabled}" slot="head" nofocus></hat-graph-node> ${(0,o.e)(e.parallel).map((a,s)=>"sequence"in a?i.qy`<div ?track="${t in this.trace.trace}"> ${(0,o.e)(a.sequence).map((a,i)=>this._renderActionNode(a,`${t}/parallel/${s}/sequence/${i}`,!1,r||!1===e.enabled))} </div>`:this._renderActionNode(a,`${t}/parallel/${s}/sequence/0`,!1,r||!1===e.enabled))} </hat-graph-branch> `}_renderOtherNode(e,t,a=!1,r=!1){return i.qy` <hat-graph-node .graphStart="${a}" .iconPath="${p.O$[(0,h.pq)(e)]||L}" @focus="${this._selectNode(e,t,"action")}" ?track="${t in this.trace.trace}" ?active="${this.selected===t}" .error="${this.trace.trace[t]?.some(e=>e.error)}" .notEnabled="${r||!1===e.enabled}"></hat-graph-node> `}render(){const e="triggers"in this.trace.config?"triggers":"trigger",t="conditions"in this.trace.config?"conditions":"condition",a="actions"in this.trace.config?"actions":"action",r=Object.keys(this.trackedNodes),s=e in this.trace.config?(0,c.aI)((0,o.e)(this.trace.config[e])).map((e,t)=>this._renderTrigger(e,t)):void 0;try{return i.qy` <div class="graph-scroll ha-scrollbar"> <div class="parent graph-container"> ${s?i.qy`<hat-graph-branch start .short="${s.length<2}"> ${s} </hat-graph-branch>`:""} ${t in this.trace.config?i.qy`${(0,o.e)(this.trace.config[t])?.map((e,t)=>this._renderCondition(e,t))}`:""} ${a in this.trace.config?i.qy`${(0,o.e)(this.trace.config[a]).map((e,t)=>this._renderActionNode(e,`action/${t}`))}`:""} ${"sequence"in this.trace.config?i.qy`${(0,o.e)(this.trace.config.sequence).map((e,t)=>this._renderActionNode(e,`sequence/${t}`,0===t))}`:""} </div> </div> <div class="actions"> <ha-icon-button .disabled="${0===r.length||r[0]===this.selected}" @click="${this._previousTrackedNode}" .path="${C}"></ha-icon-button> <ha-icon-button .disabled="${0===r.length||r[r.length-1]===this.selected}" @click="${this._nextTrackedNode}" .path="${w}"></ha-icon-button> </div> `}catch(e){return i.qy` <div class="error"> Error rendering graph. Please download trace and share with the developers. </div> `}}willUpdate(e){super.willUpdate(e),e.has("trace")&&(this.renderedNodes={},this.trackedNodes={})}updated(e){if(super.updated(e),(e.has("trace")||e.has("selected"))&&(e.has("selected")&&this._activeNode?.scrollIntoView({behavior:"smooth",block:"nearest"}),e.has("trace"))){if(!this.selected||!(this.selected in this.trackedNodes)){const e=this.trackedNodes[Object.keys(this.trackedNodes)[0]];e&&(0,n.r)(this,"graph-node-selected",e)}if(this.trace){const e=Object.keys(this.trace.trace),t=Object.keys(this.renderedNodes).sort((t,a)=>e.indexOf(t)-e.indexOf(a)),a={},r={};for(const e of t)r[e]=this.renderedNodes[e],e in this.trackedNodes&&(a[e]=this.trackedNodes[e]);this.renderedNodes=r,this.trackedNodes=a}}}_previousTrackedNode(){const e=Object.keys(this.trackedNodes),t=e.indexOf(this.selected)-1;t>=0&&(0,n.r)(this,"graph-node-selected",this.trackedNodes[e[t]])}_nextTrackedNode(){const e=Object.keys(this.trackedNodes),t=e.indexOf(this.selected)+1;t<e.length&&(0,n.r)(this,"graph-node-selected",this.trackedNodes[e[t]])}static get styles(){return i.AH`:host{display:flex;flex-direction:row;overflow:hidden;--stroke-clr:var(--stroke-color, var(--secondary-text-color));--active-clr:var(--active-color, var(--primary-color));--track-clr:var(--track-color, var(--accent-color));--hover-clr:var(--hover-color, var(--primary-color));--disabled-clr:var(--disabled-color, var(--disabled-text-color));--disabled-active-clr:rgba(var(--rgb-primary-color), 0.5);--disabled-hover-clr:rgba(var(--rgb-primary-color), 0.7);--default-trigger-color:3,169,244;--rgb-trigger-color:var(--trigger-color, var(--default-trigger-color));--background-clr:var(--background-color, white);--default-icon-clr:var(--icon-color, black);--icon-clr:var(--stroke-clr);--hat-graph-spacing:${10}px;--hat-graph-node-size:${30}px;--hat-graph-branch-height:${20}px}.graph-scroll{flex:1;overflow:auto;min-width:0}.graph-container{display:flex;flex-direction:column;align-items:center;min-width:fit-content}.actions{display:flex;flex-direction:column}.parent{margin-left:8px;margin-top:16px}.error{padding:16px;max-width:300px}`}constructor(...e){super(...e),this.renderedNodes={},this.trackedNodes={},this._typeRenderers={condition:this._renderConditionNode,and:this._renderConditionNode,or:this._renderConditionNode,not:this._renderConditionNode,service:this._renderServiceNode,wait_template:this._renderWaitNode,wait_for_trigger:this._renderWaitNode,repeat:this._renderRepeatNode,choose:this._renderChooseNode,if:this._renderIfNode,sequence:this._renderSequenceNode,parallel:this._renderParallelNode,other:this._renderOtherNode}}}(0,r.Cg)([(0,s.MZ)({attribute:!1})],q.prototype,"trace",void 0),(0,r.Cg)([(0,s.MZ)({attribute:!1})],q.prototype,"selected",void 0),(0,r.Cg)([(0,s.P)("hat-graph-node[active], hat-graph-branch[active]")],q.prototype,"_activeNode",void 0),q=(0,r.Cg)([(0,s.EM)("hat-script-graph")],q),t()}catch(e){t(e)}})},91819(e,t,a){a.a(e,async function(e,t){try{a(44114),a(18111),a(7588);var r=a(62826),i=a(35211),s=a(5124),o=a(22441),n=a(63672),c=a(95747),h=a(98975),l=a(1087),d=a(17451),p=a(22792),u=a(86531),g=a(84025),m=a(45464),_=a(61165),b=(a(46279),e([h,u,m,c]));[h,u,m,c]=b.then?(await b)():b;const v="M13,13H11V7H13M13,17H11V15H13M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2Z",f="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,2Z",y="M12,20A8,8 0 0,1 4,12A8,8 0 0,1 12,4A8,8 0 0,1 20,12A8,8 0 0,1 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,2Z",$="M13,2.03V2.05L13,4.05C17.39,4.59 20.5,8.58 19.96,12.97C19.5,16.61 16.64,19.5 13,19.93V21.93C18.5,21.38 22.5,16.5 21.95,11C21.5,6.25 17.73,2.5 13,2.03M11,2.06C9.05,2.25 7.19,3 5.67,4.26L7.1,5.74C8.22,4.84 9.57,4.26 11,4.06V2.06M4.26,5.67C3,7.19 2.25,9.04 2.05,11H4.05C4.24,9.58 4.8,8.23 5.69,7.1L4.26,5.67M2.06,13C2.26,14.96 3.03,16.81 4.27,18.33L5.69,16.9C4.81,15.77 4.24,14.42 4.06,13H2.06M7.1,18.37L5.67,19.74C7.18,21 9.04,21.79 11,22V20C9.58,19.82 8.23,19.25 7.1,18.37M12.5,7V12.25L17,14.92L16.25,16.15L11,13V7H12.5Z",k="M13,2.03V2.05L13,4.05C17.39,4.59 20.5,8.58 19.96,12.97C19.5,16.61 16.64,19.5 13,19.93V21.93C18.5,21.38 22.5,16.5 21.95,11C21.5,6.25 17.73,2.5 13,2.03M11,2.06C9.05,2.25 7.19,3 5.67,4.26L7.1,5.74C8.22,4.84 9.57,4.26 11,4.06V2.06M4.26,5.67C3,7.19 2.25,9.04 2.05,11H4.05C4.24,9.58 4.8,8.23 5.69,7.1L4.26,5.67M2.06,13C2.26,14.96 3.03,16.81 4.27,18.33L5.69,16.9C4.81,15.77 4.24,14.42 4.06,13H2.06M7.1,18.37L5.67,19.74C7.18,21 9.04,21.79 11,22V20C9.58,19.82 8.23,19.25 7.1,18.37M16.82,15.19L12.71,11.08C13.12,10.04 12.89,8.82 12.03,7.97C11.13,7.06 9.78,6.88 8.69,7.38L10.63,9.32L9.28,10.68L7.29,8.73C6.75,9.82 7,11.17 7.88,12.08C8.74,12.94 9.96,13.16 11,12.76L15.11,16.86C15.29,17.05 15.56,17.05 15.74,16.86L16.78,15.83C17,15.65 17,15.33 16.82,15.19Z",w="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,4A8,8 0 0,1 20,12A8,8 0 0,1 12,20A8,8 0 0,1 4,12A8,8 0 0,1 12,4M12,9A3,3 0 0,0 9,12A3,3 0 0,0 12,15A3,3 0 0,0 15,12A3,3 0 0,0 12,9Z",C=2,x=1e3,M=(e,t)=>Math.abs(t.getTime()-e.getTime())>x;class L{setLastReportedTime(e){this.lastReportedTime=e}renderTime(e,t){this.entries.push(s.qy` <ha-timeline label> ${(0,h.K)(e,this.hass.locale,t,!1)} later </ha-timeline> `),this.lastReportedTime=t}maybeRenderTime(e){return M(e,this.lastReportedTime)?(this.renderTime(this.lastReportedTime,e),!0):(this.lastReportedTime=e,!1)}constructor(e,t,a){this.hass=e,this.entries=t,this.lastReportedTime=new Date(a.timestamp.start)}}class H{get curItem(){return this.logbookEntries[this.curIndex]}get hasNext(){return this.curIndex<this.logbookEntries.length}maybeRenderItem(){const e=this.curItem;this.curIndex++;const t=new Date(1e3*e.when);if(0===this.pendingItems.length)return void this.pendingItems.push([t,e]);const a=this.pendingItems[this.pendingItems.length-1][0];M(a,t)&&(this._renderLogbookEntries(),this.timeTracker.renderTime(a,t)),this.pendingItems.push([t,e])}flush(){this.pendingItems.length>0&&this._renderLogbookEntries()}_renderLogbookEntries(){this.timeTracker.maybeRenderTime(this.pendingItems[0][0]);const e=[];let t,a;for(t=0;t<Math.min(this.pendingItems.length,C);t++)e.push(this._renderLogbookEntryHelper(this.pendingItems[t][1]));if(t<this.pendingItems.length)for(a=[];t<this.pendingItems.length;t++)a.push(this._renderLogbookEntryHelper(this.pendingItems[t][1]));this.entries.push(s.qy` <ha-timeline .icon="${y}" .moreItems="${a}"> ${e} </ha-timeline> `),this.timeTracker.setLastReportedTime(this.pendingItems[this.pendingItems.length-1][0]),this.pendingItems=[]}_renderLogbookEntryHelper(e){return s.qy`${e.name} (${e.entity_id}) ${e.message||`turned ${e.state}`}<br>`}constructor(e,t,a){this.entries=e,this.timeTracker=t,this.logbookEntries=a,this.pendingItems=[],this.curIndex=a.length>0&&"automation"===a[0].domain?1:0}}class V{get curItem(){return this._getItem(this.curIndex)}get hasNext(){return this.curIndex<this.keys.length}renderItem(){this.curIndex=this._renderItem(this.curIndex)}_getItem(e){return this.trace.trace[this.keys[e]]}_renderItem(e,t,a){const r=this._getItem(e);if(a){let a=0;return r.forEach(r=>{a=this._renderIteration(e,r,t)}),a}return this._renderIteration(e,r[0],t)}_renderIteration(e,t,a){if((0,_.AB)(t.path))return this._handleTrigger(e,t);const r=new Date(t.timestamp);for(;this.logbookRenderer.hasNext&&new Date(1e3*this.logbookRenderer.curItem.when)<r;)this.logbookRenderer.maybeRenderItem();this.logbookRenderer.flush(),this.timeTracker.maybeRenderTime(r);const i=t.path;let s;try{s=(0,_.Ci)(this.trace.config,i)}catch(t){return this._renderEntry(i,this.hass.localize("ui.panel.config.automation.trace.messages.path_error",{path:i})),e+1}const o=i.split("/");if(!(2===o.length)&&!a)return this._renderEntry(i,i.replace(/\//g," ")),e+1;if(a||(a=(0,g.pq)(s)),"choose"===a)return this._handleChoose(e);if("repeat"===a)return this._handleRepeat(e);if("if"===a)return this._handleIf(e);if("sequence"===a)return this._handleSequence(e);if("parallel"===a)return this._handleParallel(e);this._renderEntry(i,(0,m.u)(this.hass,this.entityReg,s,a),void 0,!1===s.enabled);let n=e+1;for(;n<this.keys.length&&this.keys[n].split("/").length!==o.length;n++);return n}_handleTrigger(e,t){return this._renderEntry(t.path,this.hass.localize("ui.panel.config.automation.trace.messages.triggered_by",{triggeredBy:t.changed_variables.trigger?.alias?"alias":"other",alias:t.changed_variables.trigger?.alias,triggeredPath:"trigger"===t.path?"manual":"trigger",trigger:(0,u.k$)(this.hass.localize,this.trace.trigger),time:(0,c.yg)(new Date(t.timestamp),this.hass.locale,this.hass.config)}),f),e+1}_handleChoose(e){const t=this.keys[e],a=t.split("/").length,r=this._getItem(e)[0],i="default"===r.result?.choice,s=this._getDataFromPath(this.keys[e]),o=!1===s.enabled,n=s.alias||this.hass.localize("ui.panel.config.automation.trace.messages.choose");if(i)this._renderEntry(t,this.hass.localize("ui.panel.config.automation.trace.messages.default_action_executed",{name:n}),void 0,o);else if(r.result){const a="default"!==r.result.choice?r.result.choice+1:void 0,i=this._getDataFromPath(`${this.keys[e]}/choose/${r.result.choice}`),s=i?`${i.alias||this.hass.localize("ui.panel.config.automation.trace.messages.option_executed",{option:a})}`:this.hass.localize("ui.panel.config.automation.trace.messages.error",{error:r.error});this._renderEntry(t,`${n}: ${s}`,void 0,o)}else this._renderEntry(t,this.hass.localize("ui.panel.config.automation.trace.messages.no_action_executed",{name:n}),void 0,o);let c;for(c=e+1;c<this.keys.length;c++){const e=this.keys[c].split("/");if(e.length<=a)return c;if(i&&"default"===e[a+1]||!i&&"sequence"===e[a+3])break}for(;c<this.keys.length;){const e=this.keys[c];if(e.split("/").length<=a)return c;c=this._renderItem(c,(0,g.pq)(this._getDataFromPath(e)))}return c}_handleRepeat(e){const t=this.keys[e],a=t.split("/").length,r=this._getDataFromPath(this.keys[e]),i=!1===r.enabled,s=r.alias||(0,m.u)(this.hass,this.entityReg,r);let o;for(this._renderEntry(t,s,void 0,i),o=e+1;o<this.keys.length;o++){const e=this.keys[o];if(e.split("/").length<=a)return o;o=this._renderItem(o,(0,g.pq)(this._getDataFromPath(e)),!0)}return o}_handleIf(e){const t=this.keys[e],a=t.split("/").length,r=this._getItem(e)[0],i=this._getDataFromPath(this.keys[e]),s=!1===i.enabled,o=i.alias||this.hass.localize("ui.panel.config.automation.trace.messages.if");if(r.result?.choice){const a=this._getDataFromPath(`${this.keys[e]}/${r.result.choice}/`),i=a?a.alias||this.hass.localize("ui.panel.config.automation.trace.messages.action_executed",{action:r.result.choice}):this.hass.localize("ui.panel.config.automation.trace.messages.error",{error:r.error});this._renderEntry(t,`${o}: ${i}`,void 0,s)}else this._renderEntry(t,this.hass.localize("ui.panel.config.automation.trace.messages.no_action_executed",{name:o}),void 0,s);let n;for(n=e+1;n<this.keys.length;n++){const e=this.keys[n],t=this.keys[n].split("/");if(t.length<=a)return n;"condition"===t[a+1]||t.length<a+2||(n=this._renderItem(n,(0,g.pq)(this._getDataFromPath(e))))}return n}_handleSequence(e){const t=this.keys[e],a=this._getDataFromPath(this.keys[e]);let r;for(this._renderEntry(t,a.alias||(0,m.u)(this.hass,this.entityReg,a,"sequence"),void 0,!1===a.enabled),r=e+1;r<this.keys.length;r++){const e=this.keys[r];this._renderItem(r,(0,g.pq)(this._getDataFromPath(e)))}return r}_handleParallel(e){const t=this.keys[e],a=t.split("/").length,r=this._getDataFromPath(this.keys[e]),i=!1===r.enabled,s=r.alias||this.hass.localize("ui.panel.config.automation.trace.messages.execute_in_parallel");let o;for(this._renderEntry(t,s,void 0,i),o=e+1;o<this.keys.length;o++){const e=this.keys[o];if(e.split("/").length<=a)return o;o=this._renderItem(o,(0,g.pq)(this._getDataFromPath(e)))}return o}_renderEntry(e,t,a=w,r=!1){this.entries.push(s.qy` <ha-timeline .icon="${a}" data-path="${e}" .notEnabled="${r}"> ${t}${r?s.qy`<span class="disabled"> ${this.hass.localize("ui.panel.config.automation.trace.messages.disabled")}</span>`:""} </ha-timeline> `)}_getDataFromPath(e){return(0,_.Ci)(this.trace.config,e)}constructor(e,t,a,r,i,s){this.hass=e,this.entityReg=t,this.entries=a,this.trace=r,this.logbookRenderer=i,this.timeTracker=s,this.curIndex=0,this.keys=Object.keys(r.trace)}}class A extends s.WF{render(){if(!this.trace)return s.s6;const e=[],t=new L(this.hass,e,this.trace),a=new H(e,t,this.logbookEntries||[]),r=new V(this.hass,this._entityReg,e,this.trace,a,t);for(;r.hasNext;)r.renderItem();for(;a.hasNext;)a.maybeRenderItem();a.flush();const i=()=>(0,c.yg)(new Date(this.trace.timestamp.finish),this.hass.locale,this.hass.config),o=()=>((new Date(this.trace.timestamp.finish).getTime()-new Date(this.trace.timestamp.start).getTime())/1e3).toFixed(2);let h;if("running"===this.trace.state)h={description:this.hass.localize("ui.panel.config.automation.trace.messages.still_running"),icon:$};else if("debugged"===this.trace.state)h={description:this.hass.localize("ui.panel.config.automation.trace.messages.debugged"),icon:k};else if("finished"===this.trace.script_execution)h={description:this.hass.localize("ui.panel.config.automation.trace.messages.finished",{time:i(),executiontime:o()}),icon:f};else if("aborted"===this.trace.script_execution)h={description:this.hass.localize("ui.panel.config.automation.trace.messages.aborted",{time:i(),executiontime:o()}),icon:v};else if("cancelled"===this.trace.script_execution)h={description:this.hass.localize("ui.panel.config.automation.trace.messages.cancelled",{time:i(),executiontime:o()}),icon:v};else{let e,t,a=!1;switch(this.trace.script_execution){case"failed_conditions":e="stopped_failed_conditions";break;case"failed_single":e="stopped_failed_single";break;case"failed_max_runs":e="stopped_failed_max_runs";break;case"error":a=!0,e="stopped_error",t=s.qy`<br><br>${this.trace.error}`;break;default:a=!0,e="stopped_unknown_reason"}h={description:s.qy`${this.hass.localize(`ui.panel.config.automation.trace.messages.${e}`,{reason:this.trace.script_execution,time:i(),executiontime:o()})} ${t||""}`,icon:v,className:a?"error":void 0}}return e.push(s.qy` <ha-timeline last-item .icon="${h.icon}" class="${(0,n.J)(h.className)}"> ${h.description} </ha-timeline> `),s.qy`${e}`}updated(e){if(super.updated(e),this.allowPick&&e.has("trace")&&this.trace&&this.selectedPath&&!(this.selectedPath in this.trace.trace)){const e=this.shadowRoot.querySelector("ha-timeline[data-path]");e&&((0,l.r)(this,"value-changed",{value:e.dataset.path}),this.selectedPath=e.dataset.path)}(e.has("trace")||e.has("selectedPath"))&&this.shadowRoot.querySelectorAll("ha-timeline[data-path]").forEach(e=>{if((0,d.j)(e,"selected",this.selectedPath===e.dataset.path),!this.allowPick||0===e.tabIndex)return;e.tabIndex=0;const t=()=>{this.selectedPath=e.dataset.path,(0,l.r)(this,"value-changed",{value:e.dataset.path})};e.addEventListener("click",t),e.addEventListener("keydown",e=>{"Enter"!==e.key&&" "!==e.key||t()}),e.addEventListener("mouseover",()=>{e.raised=!0}),e.addEventListener("mouseout",()=>{e.raised=!1})})}static get styles(){return[s.AH`ha-timeline[lastItem].condition{--timeline-ball-color:var(--error-color)}ha-timeline[data-path]{cursor:pointer}ha-timeline[selected]{--timeline-ball-color:var(--primary-color)}ha-timeline:focus{outline:0;--timeline-ball-color:var(--accent-color)}.error{--timeline-ball-color:var(--error-color);color:var(--error-color)}`]}constructor(...e){super(...e),this.allowPick=!1,this._entityReg=[]}}(0,r.Cg)([(0,o.MZ)({attribute:!1})],A.prototype,"hass",void 0),(0,r.Cg)([(0,o.MZ)({attribute:!1})],A.prototype,"trace",void 0),(0,r.Cg)([(0,o.MZ)({attribute:!1})],A.prototype,"logbookEntries",void 0),(0,r.Cg)([(0,o.MZ)({attribute:!1})],A.prototype,"selectedPath",void 0),(0,r.Cg)([(0,o.MZ)({attribute:"allow-pick",type:Boolean})],A.prototype,"allowPick",void 0),(0,r.Cg)([(0,o.wk)(),(0,i.Fg)({context:p.ih,subscribe:!0})],A.prototype,"_entityReg",void 0),A=(0,r.Cg)([(0,o.EM)("hat-trace-timeline")],A),t()}catch(e){t(e)}})},16869(e,t,a){a.d(t,{B:()=>i,g:()=>r});a(74423);const r=window.externalAppV2||window.externalApp||window.webkit?.messageHandlers?.getExternalAuth||location.search.includes("external_auth=1"),i=window.externalApp||window.externalAppV2},86531(e,t,a){a.a(e,async function(e,r){try{a.d(t,{$O:()=>v,a$:()=>$,cj:()=>p,dG:()=>b,gM:()=>_,gd:()=>g,k$:()=>y,rc:()=>k});a(74423);var i=a(46190),s=a(71727),o=a(69093),n=a(22533),c=a(22675),h=a(25064),l=e([h]);h=(l.then?(await l)():l)[0];const d="ui.components.logbook.messages",p=["counter","proximity"],u={triggered_by_numeric_state_of:"numeric state of",triggered_by_state_of:"state of",triggered_by_event:"event",triggered_by_time_pattern:"time pattern",triggered_by_time:"time",triggered_by_homeassistant_stopping:"ioBroker stopping",triggered_by_homeassistant_starting:"ioBroker starting"},g=async(e,t,a)=>m(e,t,void 0,void 0,a),m=(e,t,a,r,i,s)=>{if((r||s)&&(!r||0===r.length)&&(!s||0===s.length))return Promise.resolve([]);const o={type:"logbook/get_events",start_time:t};return a&&(o.end_time=a),r?.length&&(o.entity_ids=r),s?.length&&(o.device_ids=s),i&&(o.context_id=i),e.callWS(o)},_=(e,t,a,r,i,s,o)=>{if((s||o)&&(!s||0===s.length)&&(!o||0===o.length))return Promise.reject("No entities or devices");const n={type:"logbook/event_stream",start_time:a,end_time:r};return s?.length&&(n.entity_ids=s),o?.length&&(n.device_ids=o),e.connection.subscribeMessage(e=>t(e,i),n)},b=(e,t)=>({entity_id:e.entity_id,state:t,attributes:{device_class:e?.attributes.device_class,source_type:e?.attributes.source_type,has_date:e?.attributes.has_date,has_time:e?.attributes.has_time,entity_picture_local:i.oL.has((0,s.m)(e.entity_id))?void 0:e?.attributes.entity_picture_local,entity_picture:i.oL.has((0,s.m)(e.entity_id))?void 0:e?.attributes.entity_picture}}),v=(e,t)=>{for(const a of Object.keys(u)){const r=u[a];if(t.startsWith(r))return t.replace(r,`${e(`ui.components.logbook.${a}`)}`)}return t},f={triggered_by_numeric_state_of:"numeric_state_of",triggered_by_state_of:"state_of",triggered_by_event:"event",triggered_by_time_pattern:"time_pattern",triggered_by_time:"time",triggered_by_homeassistant_stopping:"homeassistant_stopping",triggered_by_homeassistant_starting:"homeassistant_starting"},y=(e,t)=>{for(const a of Object.keys(u)){const r=u[a];if(t.startsWith(r)){const i=f[a];return t.replace(r,`${e(`ui.components.logbook.${i}`)}`)}}return t},$=(e,t,a,r,i)=>{switch(i){case"device_tracker":case"person":return"not_home"===a?t(`${d}.was_away`):"home"===a?t(`${d}.was_at_home`):t(`${d}.was_at_state`,{state:a});case"sun":return t("above_horizon"===a?`${d}.rose`:`${d}.set`);case"binary_sensor":{const i="on"===a,s="off"===a,o=r.attributes.device_class;if(o&&(i||s))return t(`${d}.${i?"detected_device_classes":"cleared_device_classes"}.${o}`,{device_class:(0,n.i)(t(`component.binary_sensor.entity_component.${o}.name`)||o,e.language)})||t(`${d}.${i?"detected_device_class":"cleared_device_class"}`,{device_class:(0,n.i)(t(`component.binary_sensor.entity_component.${o}.name`)||o,e.language)});break}case"cover":switch(a){case"open":return t(`${d}.was_opened`);case"opening":return t(`${d}.is_opening`);case"closing":return t(`${d}.is_closing`);case"closed":return t(`${d}.was_closed`)}break;case"event":return t(`${d}.detected_event_no_type`);case"lock":switch(a){case"unlocked":return t(`${d}.was_unlocked`);case"locking":return t(`${d}.is_locking`);case"unlocking":return t(`${d}.is_unlocking`);case"opening":return t(`${d}.is_opening`);case"open":return t(`${d}.is_opened`);case"locked":return t(`${d}.was_locked`);case"jammed":return t(`${d}.is_jammed`)}}return"on"===a?t(`${d}.turned_on`):"off"===a?t(`${d}.turned_off`):a===c.HV?t(`${d}.became_unknown`):a===c.Hh?t(`${d}.became_unavailable`):e.localize(`${d}.changed_to_state`,{state:r?e.formatEntityState(r,a):a})},k=(e,t=[])=>{const a=(0,o.t)(e);return!(p.includes(a)||"sensor"===a&&(0,h.Fp)(a,e,void 0,t))};r()}catch(e){r(e)}})},30039(e,t,a){a.d(t,{R:()=>i});a(14603),a(47566),a(98721);var r=a(16869);const i=(e,t="")=>{const a=document.createElement("a");a.target="_blank",a.href=e,a.download=t,a.style.display="none",document.body.appendChild(a),a.dispatchEvent(new MouseEvent("click")),document.body.removeChild(a),e.startsWith("blob:")&&(r.B?setTimeout(()=>URL.revokeObjectURL(e),1e4):URL.revokeObjectURL(e))}},25625(e,t,a){a.d(t,{H:()=>o});var r=a(9160),i=a(73420),s=a(83504);function o(e,t){const a=()=>(0,i.w)(t?.in,NaN),o=t?.additionalDigits??2,m=function(e){const t={},a=e.split(n.dateTimeDelimiter);let r;if(a.length>2)return t;/:/.test(a[0])?r=a[0]:(t.date=a[0],r=a[1],n.timeZoneDelimiter.test(t.date)&&(t.date=e.split(n.timeZoneDelimiter)[0],r=e.substr(t.date.length,e.length)));if(r){const e=n.timezone.exec(r);e?(t.time=r.replace(e[1],""),t.timezone=e[1]):t.time=r}return t}(e);let _;if(m.date){const e=function(e,t){const a=new RegExp("^(?:(\\d{4}|[+-]\\d{"+(4+t)+"})|(\\d{2}|[+-]\\d{"+(2+t)+"})$)"),r=e.match(a);if(!r)return{year:NaN,restDateString:""};const i=r[1]?parseInt(r[1]):null,s=r[2]?parseInt(r[2]):null;return{year:null===s?i:100*s,restDateString:e.slice((r[1]||r[2]).length)}}(m.date,o);_=function(e,t){if(null===t)return new Date(NaN);const a=e.match(c);if(!a)return new Date(NaN);const r=!!a[4],i=d(a[1]),s=d(a[2])-1,o=d(a[3]),n=d(a[4]),h=d(a[5])-1;if(r)return function(e,t,a){return t>=1&&t<=53&&a>=0&&a<=6}(0,n,h)?function(e,t,a){const r=new Date(0);r.setUTCFullYear(e,0,4);const i=r.getUTCDay()||7,s=7*(t-1)+a+1-i;return r.setUTCDate(r.getUTCDate()+s),r}(t,n,h):new Date(NaN);{const e=new Date(0);return function(e,t,a){return t>=0&&t<=11&&a>=1&&a<=(u[t]||(g(e)?29:28))}(t,s,o)&&function(e,t){return t>=1&&t<=(g(e)?366:365)}(t,i)?(e.setUTCFullYear(t,s,Math.max(i,o)),e):new Date(NaN)}}(e.restDateString,e.year)}if(!_||isNaN(+_))return a();const b=+_;let v,f=0;if(m.time&&(f=function(e){const t=e.match(h);if(!t)return NaN;const a=p(t[1]),i=p(t[2]),s=p(t[3]);if(!function(e,t,a){if(24===e)return 0===t&&0===a;return a>=0&&a<60&&t>=0&&t<60&&e>=0&&e<25}(a,i,s))return NaN;return a*r.s0+6e4*i+1e3*s}(m.time),isNaN(f)))return a();if(!m.timezone){const e=new Date(b+f),a=(0,s.a)(0,t?.in);return a.setFullYear(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()),a.setHours(e.getUTCHours(),e.getUTCMinutes(),e.getUTCSeconds(),e.getUTCMilliseconds()),a}return v=function(e){if("Z"===e)return 0;const t=e.match(l);if(!t)return 0;const a="+"===t[1]?-1:1,i=parseInt(t[2]),s=t[3]&&parseInt(t[3])||0;if(!function(e,t){return t>=0&&t<=59}(0,s))return NaN;return a*(i*r.s0+6e4*s)}(m.timezone),isNaN(v)?a():(0,s.a)(b+f+v,t?.in)}const n={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},c=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,h=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,l=/^([+-])(\d{2})(?::?(\d{2}))?$/;function d(e){return e?parseInt(e):1}function p(e){return e&&parseFloat(e.replace(",","."))||0}const u=[31,null,31,30,31,30,31,31,30,31,30,31];function g(e){return e%400==0||e%4==0&&e%100!=0}}};