diff --git a/www/community/simple-thermostat/simple-thermostat.debug.js b/www/community/simple-thermostat/simple-thermostat.debug.js index 576eeac1..cf75167d 100644 --- a/www/community/simple-thermostat/simple-thermostat.debug.js +++ b/www/community/simple-thermostat/simple-thermostat.debug.js @@ -1,5 +1,5 @@ (function() { - const env = {"DEBUG":true,"BUILD_TIME":"2026-10-02T16:09:58-02:30"}; + const env = {"DEBUG":true,"BUILD_TIME":"2026-10-07T18:06:36-02:30"}; try { if (process) { process.env = Object.assign({}, process.env); @@ -11,7 +11,7 @@ })(); var name = "simple-thermostat"; -var version = "4.5.1"; +var version = "4.5.2"; function __decorate(decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; @@ -4073,6 +4073,37 @@ function isEntityAvailable(entity) { ['button', 'input_button', 'scene'].includes(entity.entity_id?.split('.')[0] ?? '')); } +const TOGGLE_DOMAINS = [ + 'automation', + 'fan', + 'humidifier', + 'input_boolean', + 'light', + 'switch', +]; +const BUTTON_DOMAINS = ['button', 'input_button', 'script', 'scene']; +function callEntityAction(hass, entityId, checked) { + const state = hass.states?.[entityId]; + if (!isEntityAvailable(state)) + return; + const [domain] = entityId.split('.'); + const isToggle = TOGGLE_DOMAINS.includes(domain); + const service = isToggle + ? `turn_${checked ?? (state.state !== 'on') ? 'on' : 'off'}` + : domain === 'button' || domain === 'input_button' + ? 'press' + : 'turn_on'; + const actionDomain = isToggle ? 'homeassistant' : domain; + if (typeof hass.performAction === 'function') { + hass.performAction({ + action: `${actionDomain}.${service}`, + data: { entity_id: entityId }, + }); + } + else { + hass.callService?.(actionDomain, service, { entity_id: entityId }); + } +} function getEntityActionAttribute(entity) { if (typeof entity.entity_id !== 'string') return undefined; @@ -6923,52 +6954,10 @@ function renderTemplateContent(markup, hass) { : o(markup); } -const TOGGLE_DOMAINS = [ - 'automation', - 'fan', - 'humidifier', - 'input_boolean', - 'light', - 'switch', -]; -const BUTTON_DOMAINS = ['button', 'input_button', 'script', 'scene']; const DISPLAY_VALUES = ['row', 'auto', 'button', 'toggle', 'chip']; -function toggleEntity(hass, entityId, checked) { - if (!isEntityAvailable(hass.states?.[entityId])) - return; - const service = `turn_${checked ? 'on' : 'off'}`; - if (typeof hass.performAction === 'function') { - hass.performAction({ - action: `homeassistant.${service}`, - data: { entity_id: entityId }, - }); - } - else { - hass.callService('homeassistant', service, { entity_id: entityId }); - } -} function safeClass$1(value) { return String(value ?? '').replace(/[^a-z0-9_-]/gi, ''); } -function callEntityAction(hass, entityId, domain) { - if (!isEntityAvailable(hass.states?.[entityId])) - return; - if (TOGGLE_DOMAINS.includes(domain)) { - const checked = hass.states?.[entityId]?.state !== 'on'; - toggleEntity(hass, entityId, checked); - return; - } - const service = domain === 'button' || domain === 'input_button' ? 'press' : 'turn_on'; - if (typeof hass.performAction === 'function') { - hass.performAction({ - action: `${domain}.${service}`, - data: { entity_id: entityId }, - }); - } - else { - hass.callService(domain, service, { entity_id: entityId }); - } -} function renderIconTemplate({ icon, state, attribute, hass, config, variables, localize, }) { if (typeof icon !== 'string' || !icon.includes('{{') || @@ -7181,7 +7170,7 @@ function renderInfoItem({ hide = false, hass, state, details, localize, openEnti title=${entityTooltip} aria-pressed=${isToggleEntity ? String(active) : A} @click=${() => supportsAction - ? callEntityAction(hass, state.entity_id, domain) + ? callEntityAction(hass, state.entity_id) : canOpenEntity ? openEntityPopover(state.entity_id) : undefined} @@ -7215,7 +7204,7 @@ function renderInfoItem({ hide = false, hass, state, details, localize, openEnti toggleEntity(hass, state.entity_id, ev.target.checked)} + @change=${(ev) => callEntityAction(hass, state.entity_id, ev.target.checked)} > `; @@ -8114,11 +8103,9 @@ class SimpleThermostat extends i$1 { }); }; this.toggleFooterEntity = (entityId, checked) => { - if (!isEntityAvailable(this._hass?.states?.[entityId])) + if (!this._hass) return; - this._callAction(`homeassistant.turn_${checked ? 'on' : 'off'}`, { - entity_id: entityId, - }); + callEntityAction(this._hass, entityId, checked); fireEvent(this, 'haptic', 'light'); }; this._stopSetpointRepeat = () => { diff --git a/www/community/simple-thermostat/simple-thermostat.debug.js.gz b/www/community/simple-thermostat/simple-thermostat.debug.js.gz index 26acf3c7..c22497d8 100644 Binary files a/www/community/simple-thermostat/simple-thermostat.debug.js.gz and b/www/community/simple-thermostat/simple-thermostat.debug.js.gz differ diff --git a/www/community/simple-thermostat/simple-thermostat.js b/www/community/simple-thermostat/simple-thermostat.js index 328cc941..9d60e9b3 100644 --- a/www/community/simple-thermostat/simple-thermostat.js +++ b/www/community/simple-thermostat/simple-thermostat.js @@ -1,4 +1,4 @@ -!function(){const t={DEBUG:!1,BUILD_TIME:"2026-10-02T16:09:58-02:30"};try{if(process)return process.env=Object.assign({},process.env),void Object.assign(process.env,t)}catch(t){}globalThis.process={env:t}}();var t="simple-thermostat",e="4.5.1";function i(t,e,i,a){var o,n=arguments.length,r=n<3?e:null===a?a=Object.getOwnPropertyDescriptor(e,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,a);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(n<3?o(r):n>3?o(e,i,r):o(e,i))||r);return n>3&&r&&Object.defineProperty(e,i,r),r}"function"==typeof SuppressedError&&SuppressedError;const a=globalThis,o=a.ShadowRoot&&(void 0===a.ShadyCSS||a.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,n=Symbol(),r=new WeakMap;let s=class{constructor(t,e,i){if(this._$cssResult$=!0,i!==n)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o;const e=this.t;if(o&&void 0===t){const i=void 0!==e&&1===e.length;i&&(t=r.get(e)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),i&&r.set(e,t))}return t}toString(){return this.cssText}};const c=(t,...e)=>{const i=1===t.length?t[0]:e.reduce((e,i,a)=>e+(t=>{if(!0===t._$cssResult$)return t.cssText;if("number"==typeof t)return t;throw Error("Value passed to 'css' function must be a 'css' function result: "+t+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(i)+t[a+1],t[0]);return new s(i,t,n)},l=o?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const i of t.cssRules)e+=i.cssText;return(t=>new s("string"==typeof t?t:t+"",void 0,n))(e)})(t):t,{is:d,defineProperty:h,getOwnPropertyDescriptor:u,getOwnPropertyNames:p,getOwnPropertySymbols:m,getPrototypeOf:g}=Object,f=globalThis,v=f.trustedTypes,y=v?v.emptyScript:"",b=f.reactiveElementPolyfillSupport,_=(t,e)=>t,w={toAttribute(t,e){switch(e){case Boolean:t=t?y:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){let i=t;switch(e){case Boolean:i=null!==t;break;case Number:i=null===t?null:Number(t);break;case Object:case Array:try{i=JSON.parse(t)}catch(t){i=null}}return i}},x=(t,e)=>!d(t,e),$={attribute:!0,type:String,converter:w,reflect:!1,useDefault:!1,hasChanged:x};Symbol.metadata??=Symbol("metadata"),f.litPropertyMetadata??=new WeakMap;let S=class extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,e=$){if(e.state&&(e.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(t)&&((e=Object.create(e)).wrapped=!0),this.elementProperties.set(t,e),!e.noAccessor){const i=Symbol(),a=this.getPropertyDescriptor(t,i,e);void 0!==a&&h(this.prototype,t,a)}}static getPropertyDescriptor(t,e,i){const{get:a,set:o}=u(this.prototype,t)??{get(){return this[e]},set(t){this[e]=t}};return{get:a,set(e){const n=a?.call(this);o?.call(this,e),this.requestUpdate(t,n,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??$}static _$Ei(){if(this.hasOwnProperty(_("elementProperties")))return;const t=g(this);t.finalize(),void 0!==t.l&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(_("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(_("properties"))){const t=this.properties,e=[...p(t),...m(t)];for(const i of e)this.createProperty(i,t[i])}const t=this[Symbol.metadata];if(null!==t){const e=litPropertyMetadata.get(t);if(void 0!==e)for(const[t,i]of e)this.elementProperties.set(t,i)}this._$Eh=new Map;for(const[t,e]of this.elementProperties){const i=this._$Eu(t,e);void 0!==i&&this._$Eh.set(i,t)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const i=new Set(t.flat(1/0).reverse());for(const t of i)e.unshift(l(t))}else void 0!==t&&e.push(l(t));return e}static _$Eu(t,e){const i=e.attribute;return!1===i?void 0:"string"==typeof i?i:"string"==typeof t?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise(t=>this.enableUpdating=t),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(t=>t(this))}addController(t){(this._$EO??=new Set).add(t),void 0!==this.renderRoot&&this.isConnected&&t.hostConnected?.()}removeController(t){this._$EO?.delete(t)}_$E_(){const t=new Map,e=this.constructor.elementProperties;for(const i of e.keys())this.hasOwnProperty(i)&&(t.set(i,this[i]),delete this[i]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return((t,e)=>{if(o)t.adoptedStyleSheets=e.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet);else for(const i of e){const e=document.createElement("style"),o=a.litNonce;void 0!==o&&e.setAttribute("nonce",o),e.textContent=i.cssText,t.appendChild(e)}})(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(t=>t.hostConnected?.())}enableUpdating(t){}disconnectedCallback(){this._$EO?.forEach(t=>t.hostDisconnected?.())}attributeChangedCallback(t,e,i){this._$AK(t,i)}_$ET(t,e){const i=this.constructor.elementProperties.get(t),a=this.constructor._$Eu(t,i);if(void 0!==a&&!0===i.reflect){const o=(void 0!==i.converter?.toAttribute?i.converter:w).toAttribute(e,i.type);this._$Em=t,null==o?this.removeAttribute(a):this.setAttribute(a,o),this._$Em=null}}_$AK(t,e){const i=this.constructor,a=i._$Eh.get(t);if(void 0!==a&&this._$Em!==a){const t=i.getPropertyOptions(a),o="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==t.converter?.fromAttribute?t.converter:w;this._$Em=a;const n=o.fromAttribute(e,t.type);this[a]=n??this._$Ej?.get(a)??n,this._$Em=null}}requestUpdate(t,e,i,a=!1,o){if(void 0!==t){const n=this.constructor;if(!1===a&&(o=this[t]),i??=n.getPropertyOptions(t),!((i.hasChanged??x)(o,e)||i.useDefault&&i.reflect&&o===this._$Ej?.get(t)&&!this.hasAttribute(n._$Eu(t,i))))return;this.C(t,e,i)}!1===this.isUpdatePending&&(this._$ES=this._$EP())}C(t,e,{useDefault:i,reflect:a,wrapped:o},n){i&&!(this._$Ej??=new Map).has(t)&&(this._$Ej.set(t,n??e??this[t]),!0!==o||void 0!==n)||(this._$AL.has(t)||(this.hasUpdated||i||(e=void 0),this._$AL.set(t,e)),!0===a&&this._$Em!==t&&(this._$Eq??=new Set).add(t))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(t){Promise.reject(t)}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[t,e]of this._$Ep)this[t]=e;this._$Ep=void 0}const t=this.constructor.elementProperties;if(t.size>0)for(const[e,i]of t){const{wrapped:t}=i,a=this[e];!0!==t||this._$AL.has(e)||void 0===a||this.C(e,void 0,i,a)}}let t=!1;const e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),this._$EO?.forEach(t=>t.hostUpdate?.()),this.update(e)):this._$EM()}catch(e){throw t=!1,this._$EM(),e}t&&this._$AE(e)}willUpdate(t){}_$AE(t){this._$EO?.forEach(t=>t.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Eq&&=this._$Eq.forEach(t=>this._$ET(t,this[t])),this._$EM()}updated(t){}firstUpdated(t){}};S.elementStyles=[],S.shadowRootOptions={mode:"open"},S[_("elementProperties")]=new Map,S[_("finalized")]=new Map,b?.({ReactiveElement:S}),(f.reactiveElementVersions??=[]).push("2.1.2");const A=globalThis,k=t=>t,E=A.trustedTypes,z=E?E.createPolicy("lit-html",{createHTML:t=>t}):void 0,C="$lit$",T=`lit$${Math.random().toFixed(9).slice(2)}$`,R="?"+T,O=`<${R}>`,N=document,M=()=>N.createComment(""),P=t=>null===t||"object"!=typeof t&&"function"!=typeof t,j=Array.isArray,F="[ \t\n\f\r]",I=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,L=/-->/g,H=/>/g,V=RegExp(`>|${F}(?:([^\\s"'>=/]+)(${F}*=${F}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),D=/'/g,U=/"/g,W=/^(?:script|style|textarea|title)$/i,B=(t=>(e,...i)=>({_$litType$:t,strings:e,values:i}))(1),G=Symbol.for("lit-noChange"),q=Symbol.for("lit-nothing"),K=new WeakMap,Z=N.createTreeWalker(N,129);function J(t,e){if(!j(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==z?z.createHTML(e):e}const Y=(t,e)=>{const i=t.length-1,a=[];let o,n=2===e?"":3===e?"":"",r=I;for(let e=0;e"===c[0]?(r=o??I,l=-1):void 0===c[1]?l=-2:(l=r.lastIndex-c[2].length,s=c[1],r=void 0===c[3]?V:'"'===c[3]?U:D):r===U||r===D?r=V:r===L||r===H?r=I:(r=V,o=void 0);const h=r===V&&t[e+1].startsWith("/>")?" ":"";n+=r===I?i+O:l>=0?(a.push(s),i.slice(0,l)+C+i.slice(l)+T+h):i+T+(-2===l?e:h)}return[J(t,n+(t[i]||"")+(2===e?"":3===e?"":"")),a]};class X{constructor({strings:t,_$litType$:e},i){let a;this.parts=[];let o=0,n=0;const r=t.length-1,s=this.parts,[c,l]=Y(t,e);if(this.el=X.createElement(c,i),Z.currentNode=this.el.content,2===e||3===e){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes)}for(;null!==(a=Z.nextNode())&&s.length0){a.textContent=E?E.emptyScript:"";for(let i=0;ij(t)||"function"==typeof t?.[Symbol.iterator])(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==q&&P(this._$AH)?this._$AA.nextSibling.data=t:this.T(N.createTextNode(t)),this._$AH=t}$(t){const{values:e,_$litType$:i}=t,a="number"==typeof i?this._$AC(t):(void 0===i.el&&(i.el=X.createElement(J(i.h,i.h[0]),this.options)),i);if(this._$AH?._$AD===a)this._$AH.p(e);else{const t=new tt(a,this),i=t.u(this.options);t.p(e),this.T(i),this._$AH=t}}_$AC(t){let e=K.get(t.strings);return void 0===e&&K.set(t.strings,e=new X(t)),e}k(t){j(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let i,a=0;for(const o of t)a===e.length?e.push(i=new et(this.O(M()),this.O(M()),this,this.options)):i=e[a],i._$AI(o),a++;a2||""!==i[0]||""!==i[1]?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=q}_$AI(t,e=this,i,a){const o=this.strings;let n=!1;if(void 0===o)t=Q(this,t,e,0),n=!P(t)||t!==this._$AH&&t!==G,n&&(this._$AH=t);else{const a=t;let r,s;for(t=o[0],r=0;r{const a=i?.renderBefore??e;let o=a._$litPart$;if(void 0===o){const t=i?.renderBefore??null;a._$litPart$=o=new et(e.insertBefore(M(),t),t,void 0,i??{})}return o._$AI(t),o})(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return G}};lt._$litElement$=!0,lt.finalized=!0,ct.litElementHydrateSupport?.({LitElement:lt});const dt=ct.litElementPolyfillSupport;dt?.({LitElement:lt}),(ct.litElementVersions??=[]).push("4.2.2");const ht={attribute:!0,type:String,converter:w,reflect:!1,hasChanged:x},ut=(t=ht,e,i)=>{const{kind:a,metadata:o}=i;let n=globalThis.litPropertyMetadata.get(o);if(void 0===n&&globalThis.litPropertyMetadata.set(o,n=new Map),"setter"===a&&((t=Object.create(t)).wrapped=!0),n.set(i.name,t),"accessor"===a){const{name:a}=i;return{set(i){const o=e.get.call(this);e.set.call(this,i),this.requestUpdate(a,o,t,!0,i)},init(e){return void 0!==e&&this.C(a,void 0,t,e),e}}}if("setter"===a){const{name:a}=i;return function(i){const o=this[a];e.call(this,i),this.requestUpdate(a,o,t,!0,i)}}throw Error("Unsupported decorator location: "+a)};function pt(t){return(e,i)=>"object"==typeof i?ut(t,e,i):((t,e,i)=>{const a=e.hasOwnProperty(i);return e.constructor.createProperty(i,t),a?Object.getOwnPropertyDescriptor(e,i):void 0})(t,e,i)}function mt(t){return pt({...t,state:!0,attribute:!1})}var gt="M11,4H13V16L18.5,10.5L19.92,11.92L12,19.84L4.08,11.92L5.5,10.5L11,16V4Z",ft="M13,20H11V8L5.5,13.5L4.08,12.08L12,4.16L19.92,12.08L18.5,13.5L13,8V20Z",vt="M6,19A2,2 0 0,0 8,21H16A2,2 0 0,0 18,19V7H6V19M8,9H16V19H8V9M15.5,4L14.5,3H9.5L8.5,4H5V6H19V4H15.5Z";var yt,bt=c`:host { +!function(){const t={DEBUG:!1,BUILD_TIME:"2026-10-07T18:06:36-02:30"};try{if(process)return process.env=Object.assign({},process.env),void Object.assign(process.env,t)}catch(t){}globalThis.process={env:t}}();var t="simple-thermostat",e="4.5.2";function i(t,e,i,a){var o,n=arguments.length,r=n<3?e:null===a?a=Object.getOwnPropertyDescriptor(e,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,a);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(r=(n<3?o(r):n>3?o(e,i,r):o(e,i))||r);return n>3&&r&&Object.defineProperty(e,i,r),r}"function"==typeof SuppressedError&&SuppressedError;const a=globalThis,o=a.ShadowRoot&&(void 0===a.ShadyCSS||a.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,n=Symbol(),r=new WeakMap;let s=class{constructor(t,e,i){if(this._$cssResult$=!0,i!==n)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o;const e=this.t;if(o&&void 0===t){const i=void 0!==e&&1===e.length;i&&(t=r.get(e)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),i&&r.set(e,t))}return t}toString(){return this.cssText}};const c=(t,...e)=>{const i=1===t.length?t[0]:e.reduce((e,i,a)=>e+(t=>{if(!0===t._$cssResult$)return t.cssText;if("number"==typeof t)return t;throw Error("Value passed to 'css' function must be a 'css' function result: "+t+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(i)+t[a+1],t[0]);return new s(i,t,n)},l=o?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const i of t.cssRules)e+=i.cssText;return(t=>new s("string"==typeof t?t:t+"",void 0,n))(e)})(t):t,{is:d,defineProperty:h,getOwnPropertyDescriptor:u,getOwnPropertyNames:p,getOwnPropertySymbols:m,getPrototypeOf:g}=Object,f=globalThis,v=f.trustedTypes,y=v?v.emptyScript:"",b=f.reactiveElementPolyfillSupport,_=(t,e)=>t,w={toAttribute(t,e){switch(e){case Boolean:t=t?y:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){let i=t;switch(e){case Boolean:i=null!==t;break;case Number:i=null===t?null:Number(t);break;case Object:case Array:try{i=JSON.parse(t)}catch(t){i=null}}return i}},x=(t,e)=>!d(t,e),$={attribute:!0,type:String,converter:w,reflect:!1,useDefault:!1,hasChanged:x};Symbol.metadata??=Symbol("metadata"),f.litPropertyMetadata??=new WeakMap;let S=class extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,e=$){if(e.state&&(e.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(t)&&((e=Object.create(e)).wrapped=!0),this.elementProperties.set(t,e),!e.noAccessor){const i=Symbol(),a=this.getPropertyDescriptor(t,i,e);void 0!==a&&h(this.prototype,t,a)}}static getPropertyDescriptor(t,e,i){const{get:a,set:o}=u(this.prototype,t)??{get(){return this[e]},set(t){this[e]=t}};return{get:a,set(e){const n=a?.call(this);o?.call(this,e),this.requestUpdate(t,n,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??$}static _$Ei(){if(this.hasOwnProperty(_("elementProperties")))return;const t=g(this);t.finalize(),void 0!==t.l&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(_("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(_("properties"))){const t=this.properties,e=[...p(t),...m(t)];for(const i of e)this.createProperty(i,t[i])}const t=this[Symbol.metadata];if(null!==t){const e=litPropertyMetadata.get(t);if(void 0!==e)for(const[t,i]of e)this.elementProperties.set(t,i)}this._$Eh=new Map;for(const[t,e]of this.elementProperties){const i=this._$Eu(t,e);void 0!==i&&this._$Eh.set(i,t)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const i=new Set(t.flat(1/0).reverse());for(const t of i)e.unshift(l(t))}else void 0!==t&&e.push(l(t));return e}static _$Eu(t,e){const i=e.attribute;return!1===i?void 0:"string"==typeof i?i:"string"==typeof t?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise(t=>this.enableUpdating=t),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(t=>t(this))}addController(t){(this._$EO??=new Set).add(t),void 0!==this.renderRoot&&this.isConnected&&t.hostConnected?.()}removeController(t){this._$EO?.delete(t)}_$E_(){const t=new Map,e=this.constructor.elementProperties;for(const i of e.keys())this.hasOwnProperty(i)&&(t.set(i,this[i]),delete this[i]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return((t,e)=>{if(o)t.adoptedStyleSheets=e.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet);else for(const i of e){const e=document.createElement("style"),o=a.litNonce;void 0!==o&&e.setAttribute("nonce",o),e.textContent=i.cssText,t.appendChild(e)}})(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(t=>t.hostConnected?.())}enableUpdating(t){}disconnectedCallback(){this._$EO?.forEach(t=>t.hostDisconnected?.())}attributeChangedCallback(t,e,i){this._$AK(t,i)}_$ET(t,e){const i=this.constructor.elementProperties.get(t),a=this.constructor._$Eu(t,i);if(void 0!==a&&!0===i.reflect){const o=(void 0!==i.converter?.toAttribute?i.converter:w).toAttribute(e,i.type);this._$Em=t,null==o?this.removeAttribute(a):this.setAttribute(a,o),this._$Em=null}}_$AK(t,e){const i=this.constructor,a=i._$Eh.get(t);if(void 0!==a&&this._$Em!==a){const t=i.getPropertyOptions(a),o="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==t.converter?.fromAttribute?t.converter:w;this._$Em=a;const n=o.fromAttribute(e,t.type);this[a]=n??this._$Ej?.get(a)??n,this._$Em=null}}requestUpdate(t,e,i,a=!1,o){if(void 0!==t){const n=this.constructor;if(!1===a&&(o=this[t]),i??=n.getPropertyOptions(t),!((i.hasChanged??x)(o,e)||i.useDefault&&i.reflect&&o===this._$Ej?.get(t)&&!this.hasAttribute(n._$Eu(t,i))))return;this.C(t,e,i)}!1===this.isUpdatePending&&(this._$ES=this._$EP())}C(t,e,{useDefault:i,reflect:a,wrapped:o},n){i&&!(this._$Ej??=new Map).has(t)&&(this._$Ej.set(t,n??e??this[t]),!0!==o||void 0!==n)||(this._$AL.has(t)||(this.hasUpdated||i||(e=void 0),this._$AL.set(t,e)),!0===a&&this._$Em!==t&&(this._$Eq??=new Set).add(t))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(t){Promise.reject(t)}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[t,e]of this._$Ep)this[t]=e;this._$Ep=void 0}const t=this.constructor.elementProperties;if(t.size>0)for(const[e,i]of t){const{wrapped:t}=i,a=this[e];!0!==t||this._$AL.has(e)||void 0===a||this.C(e,void 0,i,a)}}let t=!1;const e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),this._$EO?.forEach(t=>t.hostUpdate?.()),this.update(e)):this._$EM()}catch(e){throw t=!1,this._$EM(),e}t&&this._$AE(e)}willUpdate(t){}_$AE(t){this._$EO?.forEach(t=>t.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Eq&&=this._$Eq.forEach(t=>this._$ET(t,this[t])),this._$EM()}updated(t){}firstUpdated(t){}};S.elementStyles=[],S.shadowRootOptions={mode:"open"},S[_("elementProperties")]=new Map,S[_("finalized")]=new Map,b?.({ReactiveElement:S}),(f.reactiveElementVersions??=[]).push("2.1.2");const A=globalThis,k=t=>t,E=A.trustedTypes,z=E?E.createPolicy("lit-html",{createHTML:t=>t}):void 0,C="$lit$",T=`lit$${Math.random().toFixed(9).slice(2)}$`,R="?"+T,O=`<${R}>`,N=document,M=()=>N.createComment(""),P=t=>null===t||"object"!=typeof t&&"function"!=typeof t,j=Array.isArray,F="[ \t\n\f\r]",I=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,L=/-->/g,H=/>/g,V=RegExp(`>|${F}(?:([^\\s"'>=/]+)(${F}*=${F}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),D=/'/g,U=/"/g,W=/^(?:script|style|textarea|title)$/i,B=(t=>(e,...i)=>({_$litType$:t,strings:e,values:i}))(1),G=Symbol.for("lit-noChange"),q=Symbol.for("lit-nothing"),K=new WeakMap,Z=N.createTreeWalker(N,129);function J(t,e){if(!j(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==z?z.createHTML(e):e}const Y=(t,e)=>{const i=t.length-1,a=[];let o,n=2===e?"":3===e?"":"",r=I;for(let e=0;e"===c[0]?(r=o??I,l=-1):void 0===c[1]?l=-2:(l=r.lastIndex-c[2].length,s=c[1],r=void 0===c[3]?V:'"'===c[3]?U:D):r===U||r===D?r=V:r===L||r===H?r=I:(r=V,o=void 0);const h=r===V&&t[e+1].startsWith("/>")?" ":"";n+=r===I?i+O:l>=0?(a.push(s),i.slice(0,l)+C+i.slice(l)+T+h):i+T+(-2===l?e:h)}return[J(t,n+(t[i]||"")+(2===e?"":3===e?"":"")),a]};class X{constructor({strings:t,_$litType$:e},i){let a;this.parts=[];let o=0,n=0;const r=t.length-1,s=this.parts,[c,l]=Y(t,e);if(this.el=X.createElement(c,i),Z.currentNode=this.el.content,2===e||3===e){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes)}for(;null!==(a=Z.nextNode())&&s.length0){a.textContent=E?E.emptyScript:"";for(let i=0;ij(t)||"function"==typeof t?.[Symbol.iterator])(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==q&&P(this._$AH)?this._$AA.nextSibling.data=t:this.T(N.createTextNode(t)),this._$AH=t}$(t){const{values:e,_$litType$:i}=t,a="number"==typeof i?this._$AC(t):(void 0===i.el&&(i.el=X.createElement(J(i.h,i.h[0]),this.options)),i);if(this._$AH?._$AD===a)this._$AH.p(e);else{const t=new tt(a,this),i=t.u(this.options);t.p(e),this.T(i),this._$AH=t}}_$AC(t){let e=K.get(t.strings);return void 0===e&&K.set(t.strings,e=new X(t)),e}k(t){j(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let i,a=0;for(const o of t)a===e.length?e.push(i=new et(this.O(M()),this.O(M()),this,this.options)):i=e[a],i._$AI(o),a++;a2||""!==i[0]||""!==i[1]?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=q}_$AI(t,e=this,i,a){const o=this.strings;let n=!1;if(void 0===o)t=Q(this,t,e,0),n=!P(t)||t!==this._$AH&&t!==G,n&&(this._$AH=t);else{const a=t;let r,s;for(t=o[0],r=0;r{const a=i?.renderBefore??e;let o=a._$litPart$;if(void 0===o){const t=i?.renderBefore??null;a._$litPart$=o=new et(e.insertBefore(M(),t),t,void 0,i??{})}return o._$AI(t),o})(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return G}};lt._$litElement$=!0,lt.finalized=!0,ct.litElementHydrateSupport?.({LitElement:lt});const dt=ct.litElementPolyfillSupport;dt?.({LitElement:lt}),(ct.litElementVersions??=[]).push("4.2.2");const ht={attribute:!0,type:String,converter:w,reflect:!1,hasChanged:x},ut=(t=ht,e,i)=>{const{kind:a,metadata:o}=i;let n=globalThis.litPropertyMetadata.get(o);if(void 0===n&&globalThis.litPropertyMetadata.set(o,n=new Map),"setter"===a&&((t=Object.create(t)).wrapped=!0),n.set(i.name,t),"accessor"===a){const{name:a}=i;return{set(i){const o=e.get.call(this);e.set.call(this,i),this.requestUpdate(a,o,t,!0,i)},init(e){return void 0!==e&&this.C(a,void 0,t,e),e}}}if("setter"===a){const{name:a}=i;return function(i){const o=this[a];e.call(this,i),this.requestUpdate(a,o,t,!0,i)}}throw Error("Unsupported decorator location: "+a)};function pt(t){return(e,i)=>"object"==typeof i?ut(t,e,i):((t,e,i)=>{const a=e.hasOwnProperty(i);return e.constructor.createProperty(i,t),a?Object.getOwnPropertyDescriptor(e,i):void 0})(t,e,i)}function mt(t){return pt({...t,state:!0,attribute:!1})}var gt="M11,4H13V16L18.5,10.5L19.92,11.92L12,19.84L4.08,11.92L5.5,10.5L11,16V4Z",ft="M13,20H11V8L5.5,13.5L4.08,12.08L12,4.16L19.92,12.08L18.5,13.5L13,8V20Z",vt="M6,19A2,2 0 0,0 8,21H16A2,2 0 0,0 18,19V7H6V19M8,9H16V19H8V9M15.5,4L14.5,3H9.5L8.5,4H5V6H19V4H15.5Z";var yt,bt=c`:host { display: block; isolation: isolate; max-width: 100%; @@ -2348,7 +2348,7 @@ ha-card.standard-visuals .thermostat-trigger:active { @change=${t=>a(t.currentTarget.checked)} > - `}}function be(t){return"string"==typeof t?.state&&"unavailable"!==t.state&&("unknown"!==t.state||["button","input_button","scene"].includes(t.entity_id?.split(".")[0]??""))}function _e(t){if("string"!=typeof t.entity_id)return;const[e]=t.entity_id.split(".");return"climate"===e?"hvac_action":"humidifier"===e?"action":void 0}function we(t){const e=_e(t),i=e?t.attributes?.[e]:void 0;return"string"==typeof i&&i?i:void 0}function xe(t,e,i){if("string"!=typeof t.entity_id)return void 0===t.state?"":String(t.state);const[a]=t.entity_id.split("."),o=we(t),n=_e(t);if(o)return"function"==typeof e.formatEntityAttributeValue&&n?e.formatEntityAttributeValue(t,n):i(o,function(t){if("string"!=typeof t.entity_id)return"";const[e]=t.entity_id.split("."),i=_e(t);return e&&i?`state_attributes.${e}.${i}.`:""}(t));if("fan"===a&&"on"===t.state){if(t.attributes?.preset_mode)return"function"==typeof e.formatEntityAttributeValue?e.formatEntityAttributeValue(t,"preset_mode"):i(t.attributes.preset_mode,"state_attributes.fan.preset_mode.");if("number"==typeof t.attributes?.percentage)return"function"==typeof e.formatEntityAttributeValue?e.formatEntityAttributeValue(t,"percentage"):`${t.attributes.percentage}%`;if(t.attributes?.speed)return String(t.attributes.speed)}return"function"==typeof e.formatEntityState?e.formatEntityState(t):i(String(t.state),`component.${a}.state._.`)}i([pt({attribute:!1})],ye.prototype,"hass",void 0),i([mt()],ye.prototype,"config",void 0),i([mt()],ye.prototype,"expandedTargetIndex",void 0);const $e={auto:"mdi:radiator",cooling:"mdi:snowflake",fan:"mdi:fan",heating:"mdi:radiator",idle:"mdi:radiator-disabled",on:"mdi:power",off:"mdi:radiator-off"},Se={auto:"mdi:air-conditioner",cooling:"mdi:snowflake",fan:"mdi:fan",heating:"mdi:radiator",idle:"mdi:air-conditioner",on:"mdi:air-conditioner",off:"mdi:air-conditioner"},Ae={...$e,auto:"mdi:radiator",idle:$e.idle,off:"mdi:radiator"},ke={fan:{on:"mdi:fan",off:"mdi:fan-off"},humidifier:{on:"mdi:air-humidifier",off:"mdi:air-humidifier-off"}},Ee={auto:"hass:autorenew",cool:"hass:snowflake",dry:"hass:water-percent",fan_only:"hass:fan",heat_cool:"hass:autorenew",heat:"hass:fire",on:"hass:power",off:"hass:power",forward:"mdi:arrow-right",reverse:"mdi:arrow-left",true:"mdi:fan",false:"mdi:fan-off",low:"mdi:fan-speed-1",mid:"mdi:fan-speed-2",medium:"mdi:fan-speed-2",high:"mdi:fan-speed-3",max:"st:fan-speed-4",turbo:"st:fan-speed-5",1:"mdi:fan-speed-1",2:"mdi:fan-speed-2",3:"mdi:fan-speed-3",4:"st:fan-speed-4",5:"st:fan-speed-5",automatic:"mdi:fan-auto",powerful:"mdi:fan-plus",quiet:"mdi:fan-minus",silent:"mdi:fan-minus",normal:"mdi:water-percent",vertical:"mdi:arrow-up-down",top:"mdi:arrow-up","top-middle":"mdi:arrow-top-right",middle:"mdi:arrow-collapse-vertical","middle-bottom":"mdi:arrow-bottom-right",bottom:"mdi:arrow-down",upper:"mdi:arrow-up",lower:"mdi:arrow-down",horizontal:"mdi:arrow-left-right",left:"mdi:arrow-left","center-left":"mdi:arrow-top-left",center:"mdi:arrow-collapse-horizontal","center-right":"mdi:arrow-top-right",right:"mdi:arrow-right",both:"mdi:arrow-all",swing:"mdi:arrow-oscillating",wide:"mdi:arrow-expand-horizontal",narrow:"mdi:arrow-collapse-horizontal",split:"mdi:arrow-split-vertical",none:"mdi:circle-off-outline",frost:"mdi:snowflake",frost_protection:"mdi:snowflake","frost-protection":"mdi:snowflake",frost_protect:"mdi:snowflake",away:"mdi:home-export-outline",eco:"mdi:leaf",boost:"mdi:weather-windy",comfort:"mdi:sofa",auto_comfort:"mdi:sofa","auto-comfort":"mdi:sofa","auto comfort":"mdi:sofa",home:"mdi:home",sleep:"mdi:sleep",activity:"mdi:run"};function ze(t){const e=String(t),i=e.toLowerCase().replace(/\s+/g,"_");return Ee[e]??Ee[i]}function Ce(t){const e=String(t);return{low:"Low",mid:"Mid",medium:"Medium",high:"High",max:"Max",turbo:"Turbo",auto:"Auto"}[e.toLowerCase().replace(/\s+/g,"_")]??e}function Te(t,e,i,a=!0){if(!1===t)return!1;let o;o="string"==typeof t?.name?t.name:!1!==t?.name&&("function"==typeof i.formatEntityName?i.formatEntityName(e):e.attributes.friendly_name);let n=a?function(t){const[e]=t.entity_id.split("."),i=we(t),a=i?Ne(t):void 0;return a??t.attributes.icon??Ne(t)??ke[e]?.[t.state]??(i?$e:Ee)}(e):function(t){return we(t)?$e:Ee}(e);return void 0!==t?.icon&&(n=t.icon),{name:o,icon:n,slashOffIcon:a&&Me(e,n),toggle:t?.toggle?Re(t.toggle,i):null,toggles:Oe(t,i),faults:Pe(t?.faults,i)}}function Re(t,e){const i=e.states[t.entity];if(!i)return null;let a="";return a=!0===t?.name?i.attributes.friendly_name:t?.name??"",{entity:i,label:a,icon:t?.icon??!1,hide_when_off:t?.hide_when_off}}function Oe(t,e){return[...t?.toggle?[t.toggle]:[],...Array.isArray(t?.toggles)?t.toggles:[]].map(t=>Re(t,e)).filter(t=>!!t)}function Ne(t){const[e]=t.entity_id.split(".");if("climate"!==e)return;const i=Array.isArray(t.attributes?.hvac_modes)?t.attributes.hvac_modes:[],a=we(t),o=String(a||t.state);return i.includes("cool")||i.includes("dry")||i.includes("fan_only")||["cool","cooling","dry","fan_only","fan"].includes(o)?Se:Ae}function Me(t,e){if("off"!==t.state)return!1;const i="object"==typeof e?e[we(t)||t.state]??!1:e;if("string"!=typeof i)return!1;const[a]=t.entity_id.split("."),o="climate"===a?$e.off:ke[a]?.off;return Boolean(o)&&i!==o&&!i.endsWith("-off")}function Pe(t,e){return Array.isArray(t)?t.filter(({entity:t})=>Boolean(e.states?.[t])).map(({entity:t,...i})=>({...i,state:e.states[t],entity:t})):[]}const je={style:"header",icons:!0,names:!0,states:!1},Fe=["climate","fan","humidifier"];function Ie(t){return t.split(".")[0]}function Le(t){return"string"==typeof t?t.replace(/[^a-z0-9_-]/gi,""):""}function He(e){if("string"==typeof e){const i=e.trim();return i?{entity:i,config:{type:`custom:${t}`,entity:i}}:null}if(!e?.entity)return null;const{entity:i,name:a,icon:o,...n}=e;let r="object"==typeof n.header&&n.header?{...n.header}:void 0;return a&&!1!==n.header&&void 0===r?.name&&(r??={},r.name=a),o&&!1!==n.header&&void 0===r?.icon&&(r??={},r.icon=o),{entity:i,config:{type:n.type??`custom:${t}`,...n,entity:i,...!1===n.header?{header:!1}:r?{header:r}:{}}}}class Ve extends lt{constructor(){super(...arguments),this.targets=[],this.selectedEntity="",this.menuOpen=!1,this.cardFading=!1,this.embeddedCardEntity="",this.embeddedCardConfigSignature="",this.embeddedCardPendingSignature="",this.fadeInAfterSync=!1,this.activitySignatures=new Map,this.activityRecords=new Map,this.activitySignaturesInitialized=!1,this.persistedActivityApplied=!1,this.lastManualSelectionAt=0,this.presentationResizeListenersAttached=!1,this.handlePresentationResize=()=>{this.syncEmbeddedPresentation()}}static get styles(){return c` + `}}function be(t){return"string"==typeof t?.state&&"unavailable"!==t.state&&("unknown"!==t.state||["button","input_button","scene"].includes(t.entity_id?.split(".")[0]??""))}i([pt({attribute:!1})],ye.prototype,"hass",void 0),i([mt()],ye.prototype,"config",void 0),i([mt()],ye.prototype,"expandedTargetIndex",void 0);const _e=["automation","fan","humidifier","input_boolean","light","switch"],we=["button","input_button","script","scene"];function xe(t,e,i){const a=t.states?.[e];if(!be(a))return;const[o]=e.split("."),n=_e.includes(o),r=n?"turn_"+(i??"on"!==a.state?"on":"off"):"button"===o||"input_button"===o?"press":"turn_on",s=n?"homeassistant":o;"function"==typeof t.performAction?t.performAction({action:`${s}.${r}`,data:{entity_id:e}}):t.callService?.(s,r,{entity_id:e})}function $e(t){if("string"!=typeof t.entity_id)return;const[e]=t.entity_id.split(".");return"climate"===e?"hvac_action":"humidifier"===e?"action":void 0}function Se(t){const e=$e(t),i=e?t.attributes?.[e]:void 0;return"string"==typeof i&&i?i:void 0}function Ae(t,e,i){if("string"!=typeof t.entity_id)return void 0===t.state?"":String(t.state);const[a]=t.entity_id.split("."),o=Se(t),n=$e(t);if(o)return"function"==typeof e.formatEntityAttributeValue&&n?e.formatEntityAttributeValue(t,n):i(o,function(t){if("string"!=typeof t.entity_id)return"";const[e]=t.entity_id.split("."),i=$e(t);return e&&i?`state_attributes.${e}.${i}.`:""}(t));if("fan"===a&&"on"===t.state){if(t.attributes?.preset_mode)return"function"==typeof e.formatEntityAttributeValue?e.formatEntityAttributeValue(t,"preset_mode"):i(t.attributes.preset_mode,"state_attributes.fan.preset_mode.");if("number"==typeof t.attributes?.percentage)return"function"==typeof e.formatEntityAttributeValue?e.formatEntityAttributeValue(t,"percentage"):`${t.attributes.percentage}%`;if(t.attributes?.speed)return String(t.attributes.speed)}return"function"==typeof e.formatEntityState?e.formatEntityState(t):i(String(t.state),`component.${a}.state._.`)}const ke={auto:"mdi:radiator",cooling:"mdi:snowflake",fan:"mdi:fan",heating:"mdi:radiator",idle:"mdi:radiator-disabled",on:"mdi:power",off:"mdi:radiator-off"},Ee={auto:"mdi:air-conditioner",cooling:"mdi:snowflake",fan:"mdi:fan",heating:"mdi:radiator",idle:"mdi:air-conditioner",on:"mdi:air-conditioner",off:"mdi:air-conditioner"},ze={...ke,auto:"mdi:radiator",idle:ke.idle,off:"mdi:radiator"},Ce={fan:{on:"mdi:fan",off:"mdi:fan-off"},humidifier:{on:"mdi:air-humidifier",off:"mdi:air-humidifier-off"}},Te={auto:"hass:autorenew",cool:"hass:snowflake",dry:"hass:water-percent",fan_only:"hass:fan",heat_cool:"hass:autorenew",heat:"hass:fire",on:"hass:power",off:"hass:power",forward:"mdi:arrow-right",reverse:"mdi:arrow-left",true:"mdi:fan",false:"mdi:fan-off",low:"mdi:fan-speed-1",mid:"mdi:fan-speed-2",medium:"mdi:fan-speed-2",high:"mdi:fan-speed-3",max:"st:fan-speed-4",turbo:"st:fan-speed-5",1:"mdi:fan-speed-1",2:"mdi:fan-speed-2",3:"mdi:fan-speed-3",4:"st:fan-speed-4",5:"st:fan-speed-5",automatic:"mdi:fan-auto",powerful:"mdi:fan-plus",quiet:"mdi:fan-minus",silent:"mdi:fan-minus",normal:"mdi:water-percent",vertical:"mdi:arrow-up-down",top:"mdi:arrow-up","top-middle":"mdi:arrow-top-right",middle:"mdi:arrow-collapse-vertical","middle-bottom":"mdi:arrow-bottom-right",bottom:"mdi:arrow-down",upper:"mdi:arrow-up",lower:"mdi:arrow-down",horizontal:"mdi:arrow-left-right",left:"mdi:arrow-left","center-left":"mdi:arrow-top-left",center:"mdi:arrow-collapse-horizontal","center-right":"mdi:arrow-top-right",right:"mdi:arrow-right",both:"mdi:arrow-all",swing:"mdi:arrow-oscillating",wide:"mdi:arrow-expand-horizontal",narrow:"mdi:arrow-collapse-horizontal",split:"mdi:arrow-split-vertical",none:"mdi:circle-off-outline",frost:"mdi:snowflake",frost_protection:"mdi:snowflake","frost-protection":"mdi:snowflake",frost_protect:"mdi:snowflake",away:"mdi:home-export-outline",eco:"mdi:leaf",boost:"mdi:weather-windy",comfort:"mdi:sofa",auto_comfort:"mdi:sofa","auto-comfort":"mdi:sofa","auto comfort":"mdi:sofa",home:"mdi:home",sleep:"mdi:sleep",activity:"mdi:run"};function Re(t){const e=String(t),i=e.toLowerCase().replace(/\s+/g,"_");return Te[e]??Te[i]}function Oe(t){const e=String(t);return{low:"Low",mid:"Mid",medium:"Medium",high:"High",max:"Max",turbo:"Turbo",auto:"Auto"}[e.toLowerCase().replace(/\s+/g,"_")]??e}function Ne(t,e,i,a=!0){if(!1===t)return!1;let o;o="string"==typeof t?.name?t.name:!1!==t?.name&&("function"==typeof i.formatEntityName?i.formatEntityName(e):e.attributes.friendly_name);let n=a?function(t){const[e]=t.entity_id.split("."),i=Se(t),a=i?je(t):void 0;return a??t.attributes.icon??je(t)??Ce[e]?.[t.state]??(i?ke:Te)}(e):function(t){return Se(t)?ke:Te}(e);return void 0!==t?.icon&&(n=t.icon),{name:o,icon:n,slashOffIcon:a&&Fe(e,n),toggle:t?.toggle?Me(t.toggle,i):null,toggles:Pe(t,i),faults:Ie(t?.faults,i)}}function Me(t,e){const i=e.states[t.entity];if(!i)return null;let a="";return a=!0===t?.name?i.attributes.friendly_name:t?.name??"",{entity:i,label:a,icon:t?.icon??!1,hide_when_off:t?.hide_when_off}}function Pe(t,e){return[...t?.toggle?[t.toggle]:[],...Array.isArray(t?.toggles)?t.toggles:[]].map(t=>Me(t,e)).filter(t=>!!t)}function je(t){const[e]=t.entity_id.split(".");if("climate"!==e)return;const i=Array.isArray(t.attributes?.hvac_modes)?t.attributes.hvac_modes:[],a=Se(t),o=String(a||t.state);return i.includes("cool")||i.includes("dry")||i.includes("fan_only")||["cool","cooling","dry","fan_only","fan"].includes(o)?Ee:ze}function Fe(t,e){if("off"!==t.state)return!1;const i="object"==typeof e?e[Se(t)||t.state]??!1:e;if("string"!=typeof i)return!1;const[a]=t.entity_id.split("."),o="climate"===a?ke.off:Ce[a]?.off;return Boolean(o)&&i!==o&&!i.endsWith("-off")}function Ie(t,e){return Array.isArray(t)?t.filter(({entity:t})=>Boolean(e.states?.[t])).map(({entity:t,...i})=>({...i,state:e.states[t],entity:t})):[]}const Le={style:"header",icons:!0,names:!0,states:!1},He=["climate","fan","humidifier"];function Ve(t){return t.split(".")[0]}function De(t){return"string"==typeof t?t.replace(/[^a-z0-9_-]/gi,""):""}function Ue(e){if("string"==typeof e){const i=e.trim();return i?{entity:i,config:{type:`custom:${t}`,entity:i}}:null}if(!e?.entity)return null;const{entity:i,name:a,icon:o,...n}=e;let r="object"==typeof n.header&&n.header?{...n.header}:void 0;return a&&!1!==n.header&&void 0===r?.name&&(r??={},r.name=a),o&&!1!==n.header&&void 0===r?.icon&&(r??={},r.icon=o),{entity:i,config:{type:n.type??`custom:${t}`,...n,entity:i,...!1===n.header?{header:!1}:r?{header:r}:{}}}}class We extends lt{constructor(){super(...arguments),this.targets=[],this.selectedEntity="",this.menuOpen=!1,this.cardFading=!1,this.embeddedCardEntity="",this.embeddedCardConfigSignature="",this.embeddedCardPendingSignature="",this.fadeInAfterSync=!1,this.activitySignatures=new Map,this.activityRecords=new Map,this.activitySignaturesInitialized=!1,this.persistedActivityApplied=!1,this.lastManualSelectionAt=0,this.presentationResizeListenersAttached=!1,this.handlePresentationResize=()=>{this.syncEmbeddedPresentation()}}static get styles(){return c` :host { display: block; } @@ -2993,7 +2993,7 @@ ha-card.standard-visuals .thermostat-trigger:active { animation: st-group-fan-spin var(--st-fan-spin-duration, 2.4s) linear infinite; } - `}static getConfigElement(){return window.document.createElement(`${t}-group-editor`)}static getStubConfig(t){return{entities:Object.keys(t?.states??{}).filter(t=>Fe.includes(Ie(t))).slice(0,2),card:{}}}setConfig(t){this.clearAutoSelectResumeTimer();const e=(t.cards??t.entities??[]).map(He).filter(Boolean);if(!e.length)throw new Error("Simple Thermostat Group requires at least one card");this.config={...t,selector:{...je,...t.selector??{}}},this.targets=e,this.activityRecords.clear();try{const i=JSON.parse(window.localStorage.getItem(`${this.getActivityStorageKey(t)}:v2`)??"[]");Array.isArray(i)&&i.forEach(t=>{e.some(e=>e.entity===t?.entity)&&"string"==typeof t.signature&&Number.isFinite(t.timestamp)&&this.activityRecords.set(t.entity,t)})}catch{}this.selectedEntity=this.getInitialSelection(t,e),this.activitySignatures.clear(),this.activitySignaturesInitialized=!1,this.persistedActivityApplied=!1}updated(){this.reconcileAvailableSelection(),this.syncAutoSelectRecentActivity(),this.syncEmbeddedCard(),this.syncOutsideClickListener(),this.syncTitleFit()}connectedCallback(){super.connectedCallback(),this.attachPresentationResizeListeners(),this.resumeAutoSelectAfterReconnect()}getCardSize(){if(!this.config||!this.getAvailableTargets().length)return 1;const t=this.embeddedCard?.getCardSize?.();if("number"==typeof t&&Number.isFinite(t))return Math.max(1,t);const e=this.getSelectedTarget();if(!e)return 1;const i=this.getTargetCardConfig(e),a=Array.isArray(i.entities)?i.entities.length:0,o=a?Math.max(1,Math.ceil(a/2)):0,n=this.getConfiguredModeRowCount(i),r=!0===i.hide_setpoint?0:1;return Math.max(2,1+o+r+n)}disconnectedCallback(){this.clearOutsideClickListener(),this.clearAutoSelectResumeTimer(),this.clearEmbeddedResizeObserver(),this.detachPresentationResizeListeners(),super.disconnectedCallback()}attachPresentationResizeListeners(){this.presentationResizeListenersAttached||(window.addEventListener("resize",this.handlePresentationResize),window.addEventListener("orientationchange",this.handlePresentationResize),this.presentationResizeListenersAttached=!0)}detachPresentationResizeListeners(){this.presentationResizeListenersAttached&&(window.removeEventListener("resize",this.handlePresentationResize),window.removeEventListener("orientationchange",this.handlePresentationResize),this.presentationResizeListenersAttached=!1)}getInitialSelection(t,e){const i=new Set(e.map(t=>t.entity)),a=!1===t.remember_selection?"":this.readStoredSelection(t);return a&&i.has(a)?a:t.selected&&i.has(t.selected)?t.selected:e[0].entity}readStoredSelection(t){return this.readStoredSelectionRecord(t)?.entity??""}readStoredSelectionRecord(t){try{const e=window.localStorage?.getItem(this.getStorageKey(t));if(!e)return;if(!e.trim().startsWith("{"))return{entity:e,timestamp:0};const i=JSON.parse(e);if("string"==typeof i.entity)return{entity:i.entity,timestamp:Number.isFinite(i.timestamp)?Number(i.timestamp):0}}catch(t){return}}writeStoredSelection(t){if(this.config&&!1!==this.config.remember_selection)try{window.localStorage?.setItem(this.getStorageKey(this.config),JSON.stringify({entity:t,timestamp:Date.now()}))}catch(t){}}readStoredActivity(t){try{const e=window.localStorage?.getItem(this.getActivityStorageKey(t));if(!e)return;const i=JSON.parse(e);if("string"==typeof i.entity&&"string"==typeof i.signature&&Number.isFinite(i.timestamp))return{entity:i.entity,signature:i.signature,timestamp:Number(i.timestamp)}}catch(t){return}}writeStoredActivity(t){if(this.config)try{window.localStorage?.setItem(this.getActivityStorageKey(this.config),JSON.stringify(t))}catch(t){}}getStorageKey(t){if(t.storage_key)return`simple-thermostat-group:${t.storage_key}`;return`simple-thermostat-group:${this.targets.map(t=>t.entity).join("|")}`}getActivityStorageKey(t){return`${this.getStorageKey(t)}:recent-activity`}getConfiguredModeRowCount(t){const e=t.control;return!1===e?0:Array.isArray(e)?e.filter(Boolean).length:e&&"object"==typeof e?Object.entries(e).filter(([t,e])=>!t.startsWith("_")&&!1!==e).length:1}clearAutoSelectResumeTimer(){void 0!==this.autoSelectResumeTimer&&(window.clearTimeout(this.autoSelectResumeTimer),this.autoSelectResumeTimer=void 0)}scheduleAutoSelectResume(t){this.clearAutoSelectResumeTimer(),this.autoSelectResumeTimer=window.setTimeout(()=>{this.autoSelectResumeTimer=void 0,this.lastManualSelectionAt=0,this.isRecentActivityAutoSelectEnabled()&&!this.menuOpen&&this.selectMostRecentStateActivity()},Math.max(0,t))}resumeAutoSelectAfterReconnect(){if(!this.lastManualSelectionAt||!this.isRecentActivityAutoSelectEnabled())return;const t=Date.now()-this.lastManualSelectionAt;this.scheduleAutoSelectResume(this.getAutoSelectManualPauseMs()-t)}getSelectedTarget(){const t=this.getAvailableTargets();return t.find(t=>t.entity===this.selectedEntity)??t[0]}getAvailableTargets(){return this.hass?this.targets.filter(t=>be(this.hass.states?.[t.entity])):this.targets}reconcileAvailableSelection(){const t=this.getAvailableTargets();t.length?t.some(t=>t.entity===this.selectedEntity)||(this.menuOpen=!1,this.cardFading=!1,this.fadeInAfterSync=!1,this.selectedEntity=t[0].entity):this.menuOpen=!1}getSelectedState(){const t=this.getSelectedTarget();return t?this.hass?.states?.[t.entity]:void 0}openSelectedPopover(){const t=this.getSelectedTarget();t?.entity&&_t(this,"hass-more-info",{entityId:t.entity})}onSelectorHeaderKeyDown(t){"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),this.openSelectedPopover())}getGroupCardClasses(){const t=this.getSelectedState();if(!t)return"group-card group-shell";const e=Ie(t.entity_id),i=we(t),a=["unavailable","unknown"].includes(String(t.state));return["group-card","group-shell",`domain-${Le(e)}`,`state-${Le(t.state)}`,Le(i),a&&Le(t.state)].filter(Boolean).join(" ")}getTargetClasses(t){const e=this.hass?.states?.[t.entity];if(!e)return"";const i=Ie(e.entity_id),a=we(e);return[`domain-${Le(i)}`,`state-${Le(e.state)}`,Le(a)].filter(Boolean).join(" ")}getGroupCardStyle(){const t=this.getSelectedState();return t?function(t,e={}){if("fan"!==t)return"";const i=Number(e?.percentage);if(Number.isNaN(i))return"";const a=Math.min(Math.max(i,0),100);return`--st-fan-spin-duration: ${Math.max(.9,3.2-a/100*2.1).toFixed(2)}s;`}(Ie(t.entity_id),t.attributes):""}getSelectedIndex(){const t=this.getAvailableTargets().findIndex(t=>t.entity===this.selectedEntity);return-1===t?0:t}isRecentActivityAutoSelectEnabled(){const t=this.config?.auto_select;return!!t&&(!0===t||"recent_activity"===t||"object"==typeof t&&"recent_activity"===t.mode)}getAutoSelectManualPauseMs(){const t=this.config?.auto_select;if(t&&"object"==typeof t){const e=Number(t.manual_pause_ms??t.cooldown_ms);if(Number.isFinite(e)&&e>=0)return e}return 3e4}pauseAutoSelectAfterManualSelection(){this.lastManualSelectionAt=Date.now(),this.clearAutoSelectResumeTimer(),this.isRecentActivityAutoSelectEnabled()&&this.scheduleAutoSelectResume(this.getAutoSelectManualPauseMs())}getActivitySignature(t){const e=this.hass?.states?.[t.entity];if(!e)return"";const i=Ie(t.entity),a=we(e)??"";return`domain:${i}|state:${e.state}|action:${a}`}getActivityTimestamp(t){const e=this.hass?.states?.[t.entity],i=this.activityRecords.get(t.entity);if(i?.signature===this.getActivitySignature(t))return i.timestamp;const a=e?.last_changed??e?.last_updated,o="string"==typeof a?Date.parse(a):NaN;return Number.isFinite(o)?o:0}getActivityCandidate(t,e=this.getActivityTimestamp(t)){return{target:t,timestamp:e,activeRank:this.getActivityActiveRank(t),observed:!0===this.activityRecords.get(t.entity)?.observed&&this.activityRecords.get(t.entity)?.signature===this.getActivitySignature(t),stateTransition:this.getStateTransitionTimestamp(t)===e}}getStateTransitionTimestamp(t){const e=this.hass?.states?.[t.entity]?.last_changed,i="string"==typeof e?Date.parse(e):NaN;return Number.isFinite(i)?i:0}isBetterActivityCandidate(t,e){return!e||(t.observed||e.observed?t.observed!==e.observed?!!(!t.observed&&t.stateTransition&&t.timestamp>e.timestamp)||!(!e.observed&&e.stateTransition&&e.timestamp>t.timestamp)&&!0===t.observed:t.timestamp>e.timestamp:t.activeRank!==e.activeRank?t.activeRank>e.activeRank:t.timestamp>=e.timestamp)}getMostRecentStateActivityCandidate(){return this.getAvailableTargets().map(t=>this.getActivityCandidate(t)).filter(t=>t.timestamp>0).reduce((t,e)=>this.isBetterActivityCandidate(e,t)?e:t,void 0)}applyPersistedActivitySelection(t){if(this.persistedActivityApplied||!this.config||!this.isRecentActivityAutoSelectEnabled())return;this.persistedActivityApplied=!0;const e=!1===this.config.remember_selection?void 0:this.readStoredSelectionRecord(this.config),i=e&&this.targets.some(t=>t.entity===e.entity),a=this.getMostRecentStateActivityCandidate();if(i&&(!a||a.timestamp<=e.timestamp))return void this.selectEntity(e.entity,!1);const o=this.readStoredActivity(this.config);if(!o)return void this.selectMostRecentStateActivity(t);if(!this.targets.some(t=>t.entity===o.entity))return void this.selectMostRecentStateActivity(t);const n=this.targets.find(t=>t.entity===o.entity),r=t.get(o.entity);if(n&&r&&r===o.signature){const e=this.getActivityCandidate(n,o.timestamp);return a&&this.isBetterActivityCandidate(a,e)?void this.selectMostRecentStateActivity(t):void this.selectEntity(o.entity,!1)}this.selectMostRecentStateActivity(t)}selectMostRecentStateActivity(t){const e=this.getMostRecentStateActivityCandidate();if(e&&e.target.entity!==this.selectedEntity&&this.selectEntity(e.target.entity,!1),e&&t){const i=t.get(e.target.entity);i&&this.writeStoredActivity({entity:e.target.entity,signature:i,timestamp:e.timestamp})}}getActivityActiveRank(t){const e=this.hass?.states?.[t.entity];if(!be(e))return 0;const i=Ie(t.entity),a=we(e)??e.attributes?.action,o="string"==typeof e.state?e.state.toLowerCase():"",n="string"==typeof a?a.toLowerCase():"";if("climate"===i)return["heating","cooling","drying"].includes(n)?2:o&&"off"!==o?1:0;if("fan"===i){const t=Number(e.attributes?.percentage);return"on"===o||t>0?2:0}return"humidifier"===i?["drying","humidifying"].includes(n)?2:o&&!["off","idle"].includes(o)?1:0:o&&"off"!==o?1:0}syncAutoSelectRecentActivity(){if(!this.config||!this.hass||!this.targets.length)return;const t=[],e=new Map;let i=!1;if(this.targets.forEach(a=>{const o=this.getActivitySignature(a);e.set(a.entity,o);const n=this.activityRecords.get(a.entity);if(this.activitySignaturesInitialized&&o&&o!==this.activitySignatures.get(a.entity)){const e={entity:a.entity,signature:o,timestamp:Date.now(),observed:!0};this.activityRecords.set(a.entity,e),i=!0,this.writeStoredActivity(e),t.push(this.getActivityCandidate(a,Date.now()))}else o&&n?.signature!==o&&(i=!0,this.activityRecords.set(a.entity,{entity:a.entity,signature:o,timestamp:this.getActivityTimestamp(a),observed:!1}))}),i)try{window.localStorage.setItem(`${this.getActivityStorageKey(this.config)}:v2`,JSON.stringify([...this.activityRecords.values()]))}catch{}if(this.activitySignatures=e,!this.activitySignaturesInitialized)return this.activitySignaturesInitialized=!0,void this.applyPersistedActivitySelection(e);if(!t.length||!this.isRecentActivityAutoSelectEnabled()||this.menuOpen||Date.now()-this.lastManualSelectionAtthis.getAvailableTargets().some(e=>e.entity===t.target.entity));if(!a.length)return;const o=a.reduce((t,e)=>this.isBetterActivityCandidate(e,t)?e:t);this.selectEntity(o.target.entity,!1)}getTargetLabel(t){const e=this.parseTargetHeader(t);if(e&&"string"==typeof e.name)return e.name;const i=this.hass?.states?.[t.entity];return i&&"function"==typeof this.hass?.formatEntityName?this.hass.formatEntityName(i):i?.attributes?.friendly_name??t.entity}getTargetIcon(t){if(!(this.config?.selector??je).icons)return"";const e=this.parseTargetHeader(t);if(e&&e.icon)return this.resolveHeaderIcon(e.icon,t);const i=this.hass?.states?.[t.entity];if(i?.attributes?.icon)return i.attributes.icon;const a=Ie(t.entity);return"fan"===a?"mdi:fan":"humidifier"===a?"mdi:air-humidifier":"mdi:air-conditioner"}getTargetHeaderData(t){return this.parseTargetHeader(t)}parseTargetHeader(t){const e=this.hass?.states?.[t.entity];if(!e||!this.hass)return null;const i=this.getTargetCardConfig(t);return Te(i.header,e,this.hass,!1!==i.enhanced_visuals)}resolveHeaderIcon(t,e){if("string"==typeof t)return t;if(!t||"object"!=typeof t)return"";const i=this.hass?.states?.[e.entity];if(!i)return"";const a=t[we(i)||String(i.state)];return"string"==typeof a?a:""}getHeaderToggleConfigs(t){const e=t.config.header;return e&&"object"==typeof e?[...e.toggle?[e.toggle]:[],...Array.isArray(e.toggles)?e.toggles:[]].filter(t=>t?.entity&&this.hass?.states?.[t.entity]):[]}getEmbeddedConfig(){const t=this.getSelectedTarget();if(t)return this.getTargetCardConfig(t)}getEmbeddedConfigSignature(t){return JSON.stringify(t)}getTargetCardConfig(e){return{...{...this.config?.card??{},...this.getSourceTargetConfig(e),...e.config},embedded:!0,entity:e.entity,type:e.config.type??`custom:${t}`}}getSourceTargetConfig(t){const e=(this.config?.cards??this.config?.entities??[]).find(e=>!!e&&"object"==typeof e&&e.entity===t.entity);return e&&"object"==typeof e?e:{}}getCardHelpers(){return this.cardHelpersPromise||(this.cardHelpersPromise="function"==typeof window.loadCardHelpers?window.loadCardHelpers():Promise.reject(new Error("Home Assistant card helpers unavailable"))),this.cardHelpersPromise}createFallbackEmbeddedCardElement(e){const i=window.document.createElement(t);if("function"==typeof i.setConfig)return i.setConfig(e),i}installEmbeddedCard(t,e,i,a){if(!this.config||!this.hass)return;if(!e||"function"!=typeof e.setConfig)return void(this.embeddedCardPendingSignature="");const o=this.getEmbeddedConfig();o&&this.getEmbeddedConfigSignature(o)===a&&(this.embeddedCard=e,this.embeddedCardEntity=String(i.entity??""),this.embeddedCardConfigSignature=a,this.embeddedCardPendingSignature="",t.replaceChildren(e),"function"==typeof e.setConfig&&e.setConfig(i),e.hass=this.hass,this.syncEmbeddedPresentation())}syncEmbeddedCard(){if(!this.config||!this.hass)return;const e=this.renderRoot.querySelector(".embedded-card-host"),i=this.getEmbeddedConfig();if(!e||!i)return this.embeddedCard=void 0,this.embeddedCardEntity="",this.embeddedCardConfigSignature="",void(this.embeddedCardPendingSignature="");const a=this.getEmbeddedConfigSignature(i);if(!this.embeddedCard||this.embeddedCardEntity!==i.entity||this.embeddedCardConfigSignature!==a){if("function"!=typeof window.loadCardHelpers){const o=window.customElements.get(t)?this.createFallbackEmbeddedCardElement(i):void 0;return o?void this.installEmbeddedCard(e,o,i,a):void(this.embeddedCardPendingSignature="")}if(this.embeddedCardPendingSignature===a)return;return this.embeddedCardPendingSignature=a,void this.getCardHelpers().then(t=>t.createCardElement(i)).catch(()=>window.customElements.get(t)?this.createFallbackEmbeddedCardElement(i):void 0).then(t=>this.installEmbeddedCard(e,t,i,a))}this.embeddedCard.hass=this.hass,this.syncEmbeddedPresentation()}syncEmbeddedPresentation(){const t=this.embeddedCard;(t?.updateComplete??Promise.resolve()).catch(()=>{}).then(()=>window.requestAnimationFrame(()=>this.applyEmbeddedPresentation()))}clearEmbeddedResizeObserver(){this.embeddedResizeObserver?.disconnect(),this.embeddedResizeObserver=void 0,this.resizeObservedSelector=void 0,this.resizeObservedCard=void 0}syncEmbeddedResizeObserver(t,e){"undefined"!=typeof ResizeObserver&&t?this.embeddedResizeObserver&&this.resizeObservedSelector===t&&this.resizeObservedCard===e||(this.clearEmbeddedResizeObserver(),this.embeddedResizeObserver=new ResizeObserver(()=>this.applyEmbeddedPresentation()),this.embeddedResizeObserver.observe(t),this.embeddedResizeObserver.observe(e),this.resizeObservedSelector=t,this.resizeObservedCard=e):this.clearEmbeddedResizeObserver()}applyEmbeddedPresentation(){const t=this.renderRoot.querySelector(".embedded-card-host"),e=this.renderRoot.querySelector(".group-selector"),i=this.embeddedCard;t&&i&&(this.syncEmbeddedResizeObserver(e,i),t.style.removeProperty("--st-group-cropped-header-height"),i.style.setProperty("--st-group-embedded-header-min-height",this.getEmbeddedHeaderReserve(i,e)),this.fadeInAfterSync&&(this.fadeInAfterSync=!1,window.requestAnimationFrame(()=>{this.cardFading=!1})))}getEmbeddedHeaderReserve(t,e){const i="calc(var(--st-group-header-control-height, 34px) + var(--st-group-header-top-buffer, 2px) + calc(var(--st-spacing, var(--st-default-spacing, 4px)) * 6))",a=this.getEmbeddedHeaderReserveMinimum();if(!e)return i;const o=t.getBoundingClientRect(),n=e.getBoundingClientRect(),r=Math.ceil(n.bottom-o.top+8),s=Math.max(r,a);return Number.isFinite(s)&&s>24?`${s}px`:i}getEmbeddedHeaderReserveMinimum(){const t=getComputedStyle(this),e=parseFloat(t.getPropertyValue("--st-group-header-control-height"))||34,i=parseFloat(t.getPropertyValue("--st-group-header-top-buffer"))||2,a=parseFloat(t.getPropertyValue("--st-spacing"))||parseFloat(t.getPropertyValue("--st-default-spacing"))||4;return Math.ceil(e+i+4*a)}selectEntity(t,e=!0){if(this.menuOpen=!1,t===this.selectedEntity)return;e&&this.pauseAutoSelectAfterManualSelection();const i=window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;if(!this.embeddedCard||i)return this.fadeInAfterSync=!1,this.cardFading=!1,this.selectedEntity=t,void(e&&this.writeStoredSelection(t));this.cardFading=!0,this.fadeInAfterSync=!0,this.selectedEntity=t,e&&this.writeStoredSelection(t)}selectOffset(t){const e=this.getAvailableTargets();if(e.length<2)return;const i=(this.getSelectedIndex()+t+e.length)%e.length;this.selectEntity(e[i].entity)}toggleHeaderEntity(t,e){if(t.stopPropagation(),!be(this.hass?.states?.[e]))return;const i=Boolean(t.target.checked);this.hass?.callService?.("homeassistant","turn_"+(i?"on":"off"),{entity_id:e})}renderHeaderToggles(t){const e=this.getHeaderToggleConfigs(t);return e.length?B` + `}static getConfigElement(){return window.document.createElement(`${t}-group-editor`)}static getStubConfig(t){return{entities:Object.keys(t?.states??{}).filter(t=>He.includes(Ve(t))).slice(0,2),card:{}}}setConfig(t){this.clearAutoSelectResumeTimer();const e=(t.cards??t.entities??[]).map(Ue).filter(Boolean);if(!e.length)throw new Error("Simple Thermostat Group requires at least one card");this.config={...t,selector:{...Le,...t.selector??{}}},this.targets=e,this.activityRecords.clear();try{const i=JSON.parse(window.localStorage.getItem(`${this.getActivityStorageKey(t)}:v2`)??"[]");Array.isArray(i)&&i.forEach(t=>{e.some(e=>e.entity===t?.entity)&&"string"==typeof t.signature&&Number.isFinite(t.timestamp)&&this.activityRecords.set(t.entity,t)})}catch{}this.selectedEntity=this.getInitialSelection(t,e),this.activitySignatures.clear(),this.activitySignaturesInitialized=!1,this.persistedActivityApplied=!1}updated(){this.reconcileAvailableSelection(),this.syncAutoSelectRecentActivity(),this.syncEmbeddedCard(),this.syncOutsideClickListener(),this.syncTitleFit()}connectedCallback(){super.connectedCallback(),this.attachPresentationResizeListeners(),this.resumeAutoSelectAfterReconnect()}getCardSize(){if(!this.config||!this.getAvailableTargets().length)return 1;const t=this.embeddedCard?.getCardSize?.();if("number"==typeof t&&Number.isFinite(t))return Math.max(1,t);const e=this.getSelectedTarget();if(!e)return 1;const i=this.getTargetCardConfig(e),a=Array.isArray(i.entities)?i.entities.length:0,o=a?Math.max(1,Math.ceil(a/2)):0,n=this.getConfiguredModeRowCount(i),r=!0===i.hide_setpoint?0:1;return Math.max(2,1+o+r+n)}disconnectedCallback(){this.clearOutsideClickListener(),this.clearAutoSelectResumeTimer(),this.clearEmbeddedResizeObserver(),this.detachPresentationResizeListeners(),super.disconnectedCallback()}attachPresentationResizeListeners(){this.presentationResizeListenersAttached||(window.addEventListener("resize",this.handlePresentationResize),window.addEventListener("orientationchange",this.handlePresentationResize),this.presentationResizeListenersAttached=!0)}detachPresentationResizeListeners(){this.presentationResizeListenersAttached&&(window.removeEventListener("resize",this.handlePresentationResize),window.removeEventListener("orientationchange",this.handlePresentationResize),this.presentationResizeListenersAttached=!1)}getInitialSelection(t,e){const i=new Set(e.map(t=>t.entity)),a=!1===t.remember_selection?"":this.readStoredSelection(t);return a&&i.has(a)?a:t.selected&&i.has(t.selected)?t.selected:e[0].entity}readStoredSelection(t){return this.readStoredSelectionRecord(t)?.entity??""}readStoredSelectionRecord(t){try{const e=window.localStorage?.getItem(this.getStorageKey(t));if(!e)return;if(!e.trim().startsWith("{"))return{entity:e,timestamp:0};const i=JSON.parse(e);if("string"==typeof i.entity)return{entity:i.entity,timestamp:Number.isFinite(i.timestamp)?Number(i.timestamp):0}}catch(t){return}}writeStoredSelection(t){if(this.config&&!1!==this.config.remember_selection)try{window.localStorage?.setItem(this.getStorageKey(this.config),JSON.stringify({entity:t,timestamp:Date.now()}))}catch(t){}}readStoredActivity(t){try{const e=window.localStorage?.getItem(this.getActivityStorageKey(t));if(!e)return;const i=JSON.parse(e);if("string"==typeof i.entity&&"string"==typeof i.signature&&Number.isFinite(i.timestamp))return{entity:i.entity,signature:i.signature,timestamp:Number(i.timestamp)}}catch(t){return}}writeStoredActivity(t){if(this.config)try{window.localStorage?.setItem(this.getActivityStorageKey(this.config),JSON.stringify(t))}catch(t){}}getStorageKey(t){if(t.storage_key)return`simple-thermostat-group:${t.storage_key}`;return`simple-thermostat-group:${this.targets.map(t=>t.entity).join("|")}`}getActivityStorageKey(t){return`${this.getStorageKey(t)}:recent-activity`}getConfiguredModeRowCount(t){const e=t.control;return!1===e?0:Array.isArray(e)?e.filter(Boolean).length:e&&"object"==typeof e?Object.entries(e).filter(([t,e])=>!t.startsWith("_")&&!1!==e).length:1}clearAutoSelectResumeTimer(){void 0!==this.autoSelectResumeTimer&&(window.clearTimeout(this.autoSelectResumeTimer),this.autoSelectResumeTimer=void 0)}scheduleAutoSelectResume(t){this.clearAutoSelectResumeTimer(),this.autoSelectResumeTimer=window.setTimeout(()=>{this.autoSelectResumeTimer=void 0,this.lastManualSelectionAt=0,this.isRecentActivityAutoSelectEnabled()&&!this.menuOpen&&this.selectMostRecentStateActivity()},Math.max(0,t))}resumeAutoSelectAfterReconnect(){if(!this.lastManualSelectionAt||!this.isRecentActivityAutoSelectEnabled())return;const t=Date.now()-this.lastManualSelectionAt;this.scheduleAutoSelectResume(this.getAutoSelectManualPauseMs()-t)}getSelectedTarget(){const t=this.getAvailableTargets();return t.find(t=>t.entity===this.selectedEntity)??t[0]}getAvailableTargets(){return this.hass?this.targets.filter(t=>be(this.hass.states?.[t.entity])):this.targets}reconcileAvailableSelection(){const t=this.getAvailableTargets();t.length?t.some(t=>t.entity===this.selectedEntity)||(this.menuOpen=!1,this.cardFading=!1,this.fadeInAfterSync=!1,this.selectedEntity=t[0].entity):this.menuOpen=!1}getSelectedState(){const t=this.getSelectedTarget();return t?this.hass?.states?.[t.entity]:void 0}openSelectedPopover(){const t=this.getSelectedTarget();t?.entity&&_t(this,"hass-more-info",{entityId:t.entity})}onSelectorHeaderKeyDown(t){"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),this.openSelectedPopover())}getGroupCardClasses(){const t=this.getSelectedState();if(!t)return"group-card group-shell";const e=Ve(t.entity_id),i=Se(t),a=["unavailable","unknown"].includes(String(t.state));return["group-card","group-shell",`domain-${De(e)}`,`state-${De(t.state)}`,De(i),a&&De(t.state)].filter(Boolean).join(" ")}getTargetClasses(t){const e=this.hass?.states?.[t.entity];if(!e)return"";const i=Ve(e.entity_id),a=Se(e);return[`domain-${De(i)}`,`state-${De(e.state)}`,De(a)].filter(Boolean).join(" ")}getGroupCardStyle(){const t=this.getSelectedState();return t?function(t,e={}){if("fan"!==t)return"";const i=Number(e?.percentage);if(Number.isNaN(i))return"";const a=Math.min(Math.max(i,0),100);return`--st-fan-spin-duration: ${Math.max(.9,3.2-a/100*2.1).toFixed(2)}s;`}(Ve(t.entity_id),t.attributes):""}getSelectedIndex(){const t=this.getAvailableTargets().findIndex(t=>t.entity===this.selectedEntity);return-1===t?0:t}isRecentActivityAutoSelectEnabled(){const t=this.config?.auto_select;return!!t&&(!0===t||"recent_activity"===t||"object"==typeof t&&"recent_activity"===t.mode)}getAutoSelectManualPauseMs(){const t=this.config?.auto_select;if(t&&"object"==typeof t){const e=Number(t.manual_pause_ms??t.cooldown_ms);if(Number.isFinite(e)&&e>=0)return e}return 3e4}pauseAutoSelectAfterManualSelection(){this.lastManualSelectionAt=Date.now(),this.clearAutoSelectResumeTimer(),this.isRecentActivityAutoSelectEnabled()&&this.scheduleAutoSelectResume(this.getAutoSelectManualPauseMs())}getActivitySignature(t){const e=this.hass?.states?.[t.entity];if(!e)return"";const i=Ve(t.entity),a=Se(e)??"";return`domain:${i}|state:${e.state}|action:${a}`}getActivityTimestamp(t){const e=this.hass?.states?.[t.entity],i=this.activityRecords.get(t.entity);if(i?.signature===this.getActivitySignature(t))return i.timestamp;const a=e?.last_changed??e?.last_updated,o="string"==typeof a?Date.parse(a):NaN;return Number.isFinite(o)?o:0}getActivityCandidate(t,e=this.getActivityTimestamp(t)){return{target:t,timestamp:e,activeRank:this.getActivityActiveRank(t),observed:!0===this.activityRecords.get(t.entity)?.observed&&this.activityRecords.get(t.entity)?.signature===this.getActivitySignature(t),stateTransition:this.getStateTransitionTimestamp(t)===e}}getStateTransitionTimestamp(t){const e=this.hass?.states?.[t.entity]?.last_changed,i="string"==typeof e?Date.parse(e):NaN;return Number.isFinite(i)?i:0}isBetterActivityCandidate(t,e){return!e||(t.observed||e.observed?t.observed!==e.observed?!!(!t.observed&&t.stateTransition&&t.timestamp>e.timestamp)||!(!e.observed&&e.stateTransition&&e.timestamp>t.timestamp)&&!0===t.observed:t.timestamp>e.timestamp:t.activeRank!==e.activeRank?t.activeRank>e.activeRank:t.timestamp>=e.timestamp)}getMostRecentStateActivityCandidate(){return this.getAvailableTargets().map(t=>this.getActivityCandidate(t)).filter(t=>t.timestamp>0).reduce((t,e)=>this.isBetterActivityCandidate(e,t)?e:t,void 0)}applyPersistedActivitySelection(t){if(this.persistedActivityApplied||!this.config||!this.isRecentActivityAutoSelectEnabled())return;this.persistedActivityApplied=!0;const e=!1===this.config.remember_selection?void 0:this.readStoredSelectionRecord(this.config),i=e&&this.targets.some(t=>t.entity===e.entity),a=this.getMostRecentStateActivityCandidate();if(i&&(!a||a.timestamp<=e.timestamp))return void this.selectEntity(e.entity,!1);const o=this.readStoredActivity(this.config);if(!o)return void this.selectMostRecentStateActivity(t);if(!this.targets.some(t=>t.entity===o.entity))return void this.selectMostRecentStateActivity(t);const n=this.targets.find(t=>t.entity===o.entity),r=t.get(o.entity);if(n&&r&&r===o.signature){const e=this.getActivityCandidate(n,o.timestamp);return a&&this.isBetterActivityCandidate(a,e)?void this.selectMostRecentStateActivity(t):void this.selectEntity(o.entity,!1)}this.selectMostRecentStateActivity(t)}selectMostRecentStateActivity(t){const e=this.getMostRecentStateActivityCandidate();if(e&&e.target.entity!==this.selectedEntity&&this.selectEntity(e.target.entity,!1),e&&t){const i=t.get(e.target.entity);i&&this.writeStoredActivity({entity:e.target.entity,signature:i,timestamp:e.timestamp})}}getActivityActiveRank(t){const e=this.hass?.states?.[t.entity];if(!be(e))return 0;const i=Ve(t.entity),a=Se(e)??e.attributes?.action,o="string"==typeof e.state?e.state.toLowerCase():"",n="string"==typeof a?a.toLowerCase():"";if("climate"===i)return["heating","cooling","drying"].includes(n)?2:o&&"off"!==o?1:0;if("fan"===i){const t=Number(e.attributes?.percentage);return"on"===o||t>0?2:0}return"humidifier"===i?["drying","humidifying"].includes(n)?2:o&&!["off","idle"].includes(o)?1:0:o&&"off"!==o?1:0}syncAutoSelectRecentActivity(){if(!this.config||!this.hass||!this.targets.length)return;const t=[],e=new Map;let i=!1;if(this.targets.forEach(a=>{const o=this.getActivitySignature(a);e.set(a.entity,o);const n=this.activityRecords.get(a.entity);if(this.activitySignaturesInitialized&&o&&o!==this.activitySignatures.get(a.entity)){const e={entity:a.entity,signature:o,timestamp:Date.now(),observed:!0};this.activityRecords.set(a.entity,e),i=!0,this.writeStoredActivity(e),t.push(this.getActivityCandidate(a,Date.now()))}else o&&n?.signature!==o&&(i=!0,this.activityRecords.set(a.entity,{entity:a.entity,signature:o,timestamp:this.getActivityTimestamp(a),observed:!1}))}),i)try{window.localStorage.setItem(`${this.getActivityStorageKey(this.config)}:v2`,JSON.stringify([...this.activityRecords.values()]))}catch{}if(this.activitySignatures=e,!this.activitySignaturesInitialized)return this.activitySignaturesInitialized=!0,void this.applyPersistedActivitySelection(e);if(!t.length||!this.isRecentActivityAutoSelectEnabled()||this.menuOpen||Date.now()-this.lastManualSelectionAtthis.getAvailableTargets().some(e=>e.entity===t.target.entity));if(!a.length)return;const o=a.reduce((t,e)=>this.isBetterActivityCandidate(e,t)?e:t);this.selectEntity(o.target.entity,!1)}getTargetLabel(t){const e=this.parseTargetHeader(t);if(e&&"string"==typeof e.name)return e.name;const i=this.hass?.states?.[t.entity];return i&&"function"==typeof this.hass?.formatEntityName?this.hass.formatEntityName(i):i?.attributes?.friendly_name??t.entity}getTargetIcon(t){if(!(this.config?.selector??Le).icons)return"";const e=this.parseTargetHeader(t);if(e&&e.icon)return this.resolveHeaderIcon(e.icon,t);const i=this.hass?.states?.[t.entity];if(i?.attributes?.icon)return i.attributes.icon;const a=Ve(t.entity);return"fan"===a?"mdi:fan":"humidifier"===a?"mdi:air-humidifier":"mdi:air-conditioner"}getTargetHeaderData(t){return this.parseTargetHeader(t)}parseTargetHeader(t){const e=this.hass?.states?.[t.entity];if(!e||!this.hass)return null;const i=this.getTargetCardConfig(t);return Ne(i.header,e,this.hass,!1!==i.enhanced_visuals)}resolveHeaderIcon(t,e){if("string"==typeof t)return t;if(!t||"object"!=typeof t)return"";const i=this.hass?.states?.[e.entity];if(!i)return"";const a=t[Se(i)||String(i.state)];return"string"==typeof a?a:""}getHeaderToggleConfigs(t){const e=t.config.header;return e&&"object"==typeof e?[...e.toggle?[e.toggle]:[],...Array.isArray(e.toggles)?e.toggles:[]].filter(t=>t?.entity&&this.hass?.states?.[t.entity]):[]}getEmbeddedConfig(){const t=this.getSelectedTarget();if(t)return this.getTargetCardConfig(t)}getEmbeddedConfigSignature(t){return JSON.stringify(t)}getTargetCardConfig(e){return{...{...this.config?.card??{},...this.getSourceTargetConfig(e),...e.config},embedded:!0,entity:e.entity,type:e.config.type??`custom:${t}`}}getSourceTargetConfig(t){const e=(this.config?.cards??this.config?.entities??[]).find(e=>!!e&&"object"==typeof e&&e.entity===t.entity);return e&&"object"==typeof e?e:{}}getCardHelpers(){return this.cardHelpersPromise||(this.cardHelpersPromise="function"==typeof window.loadCardHelpers?window.loadCardHelpers():Promise.reject(new Error("Home Assistant card helpers unavailable"))),this.cardHelpersPromise}createFallbackEmbeddedCardElement(e){const i=window.document.createElement(t);if("function"==typeof i.setConfig)return i.setConfig(e),i}installEmbeddedCard(t,e,i,a){if(!this.config||!this.hass)return;if(!e||"function"!=typeof e.setConfig)return void(this.embeddedCardPendingSignature="");const o=this.getEmbeddedConfig();o&&this.getEmbeddedConfigSignature(o)===a&&(this.embeddedCard=e,this.embeddedCardEntity=String(i.entity??""),this.embeddedCardConfigSignature=a,this.embeddedCardPendingSignature="",t.replaceChildren(e),"function"==typeof e.setConfig&&e.setConfig(i),e.hass=this.hass,this.syncEmbeddedPresentation())}syncEmbeddedCard(){if(!this.config||!this.hass)return;const e=this.renderRoot.querySelector(".embedded-card-host"),i=this.getEmbeddedConfig();if(!e||!i)return this.embeddedCard=void 0,this.embeddedCardEntity="",this.embeddedCardConfigSignature="",void(this.embeddedCardPendingSignature="");const a=this.getEmbeddedConfigSignature(i);if(!this.embeddedCard||this.embeddedCardEntity!==i.entity||this.embeddedCardConfigSignature!==a){if("function"!=typeof window.loadCardHelpers){const o=window.customElements.get(t)?this.createFallbackEmbeddedCardElement(i):void 0;return o?void this.installEmbeddedCard(e,o,i,a):void(this.embeddedCardPendingSignature="")}if(this.embeddedCardPendingSignature===a)return;return this.embeddedCardPendingSignature=a,void this.getCardHelpers().then(t=>t.createCardElement(i)).catch(()=>window.customElements.get(t)?this.createFallbackEmbeddedCardElement(i):void 0).then(t=>this.installEmbeddedCard(e,t,i,a))}this.embeddedCard.hass=this.hass,this.syncEmbeddedPresentation()}syncEmbeddedPresentation(){const t=this.embeddedCard;(t?.updateComplete??Promise.resolve()).catch(()=>{}).then(()=>window.requestAnimationFrame(()=>this.applyEmbeddedPresentation()))}clearEmbeddedResizeObserver(){this.embeddedResizeObserver?.disconnect(),this.embeddedResizeObserver=void 0,this.resizeObservedSelector=void 0,this.resizeObservedCard=void 0}syncEmbeddedResizeObserver(t,e){"undefined"!=typeof ResizeObserver&&t?this.embeddedResizeObserver&&this.resizeObservedSelector===t&&this.resizeObservedCard===e||(this.clearEmbeddedResizeObserver(),this.embeddedResizeObserver=new ResizeObserver(()=>this.applyEmbeddedPresentation()),this.embeddedResizeObserver.observe(t),this.embeddedResizeObserver.observe(e),this.resizeObservedSelector=t,this.resizeObservedCard=e):this.clearEmbeddedResizeObserver()}applyEmbeddedPresentation(){const t=this.renderRoot.querySelector(".embedded-card-host"),e=this.renderRoot.querySelector(".group-selector"),i=this.embeddedCard;t&&i&&(this.syncEmbeddedResizeObserver(e,i),t.style.removeProperty("--st-group-cropped-header-height"),i.style.setProperty("--st-group-embedded-header-min-height",this.getEmbeddedHeaderReserve(i,e)),this.fadeInAfterSync&&(this.fadeInAfterSync=!1,window.requestAnimationFrame(()=>{this.cardFading=!1})))}getEmbeddedHeaderReserve(t,e){const i="calc(var(--st-group-header-control-height, 34px) + var(--st-group-header-top-buffer, 2px) + calc(var(--st-spacing, var(--st-default-spacing, 4px)) * 6))",a=this.getEmbeddedHeaderReserveMinimum();if(!e)return i;const o=t.getBoundingClientRect(),n=e.getBoundingClientRect(),r=Math.ceil(n.bottom-o.top+8),s=Math.max(r,a);return Number.isFinite(s)&&s>24?`${s}px`:i}getEmbeddedHeaderReserveMinimum(){const t=getComputedStyle(this),e=parseFloat(t.getPropertyValue("--st-group-header-control-height"))||34,i=parseFloat(t.getPropertyValue("--st-group-header-top-buffer"))||2,a=parseFloat(t.getPropertyValue("--st-spacing"))||parseFloat(t.getPropertyValue("--st-default-spacing"))||4;return Math.ceil(e+i+4*a)}selectEntity(t,e=!0){if(this.menuOpen=!1,t===this.selectedEntity)return;e&&this.pauseAutoSelectAfterManualSelection();const i=window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;if(!this.embeddedCard||i)return this.fadeInAfterSync=!1,this.cardFading=!1,this.selectedEntity=t,void(e&&this.writeStoredSelection(t));this.cardFading=!0,this.fadeInAfterSync=!0,this.selectedEntity=t,e&&this.writeStoredSelection(t)}selectOffset(t){const e=this.getAvailableTargets();if(e.length<2)return;const i=(this.getSelectedIndex()+t+e.length)%e.length;this.selectEntity(e[i].entity)}toggleHeaderEntity(t,e){if(t.stopPropagation(),!be(this.hass?.states?.[e]))return;const i=Boolean(t.target.checked);this.hass?.callService?.("homeassistant","turn_"+(i?"on":"off"),{entity_id:e})}renderHeaderToggles(t){const e=this.getHeaderToggleConfigs(t);return e.length?B`
${e.map(t=>{const e=this.hass?.states?.[t.entity],i=!0===t.name?e?.attributes?.friendly_name:"string"==typeof t.name?t.name:e?.attributes?.friendly_name,a=t.icon||e?.attributes?.icon;return B`
@@ -3027,7 +3027,7 @@ ha-card.standard-visuals .thermostat-trigger:active { `})}
- `}renderHeaderIcon(t){const e=this.hass?.states?.[t.entity],i=this.getTargetHeaderData(t);if(!e||!i||!i.icon)return q;const a=we(e)||String(e.state),o="object"==typeof i.icon?i.icon?.[a]??!1:i.icon;if(!o)return q;const n=a&&a!==e.state?` ${Le(a)}`:"",r=Le(e.state);return B` + `}renderHeaderIcon(t){const e=this.hass?.states?.[t.entity],i=this.getTargetHeaderData(t);if(!e||!i||!i.icon)return q;const a=Se(e)||String(e.state),o="object"==typeof i.icon?i.icon?.[a]??!1:i.icon;if(!o)return q;const n=a&&a!==e.state?` ${De(a)}`:"",r=De(e.state);return B` @@ -3036,7 +3036,7 @@ ha-card.standard-visuals .thermostat-trigger:active { .icon=${o} > - `}getTargetStateLabel(t){const e=this.hass?.states?.[t.entity];return e?"function"==typeof this.hass?.formatEntityState?this.hass.formatEntityState(e):String(e.state):""}renderTabSelector(){const t=this.config?.selector??je,e=this.getAvailableTargets();return B` + `}getTargetStateLabel(t){const e=this.hass?.states?.[t.entity];return e?"function"==typeof this.hass?.formatEntityState?this.hass.formatEntityState(e):String(e.state):""}renderTabSelector(){const t=this.config?.selector??Le,e=this.getAvailableTargets();return B`
${e.map(e=>{const i=this.getTargetLabel(e),a=this.getTargetIcon(e),o=e.entity===this.selectedEntity,n=t.states?this.getTargetStateLabel(e):"";return B` @@ -3119,7 +3119,7 @@ ha-card.standard-visuals .thermostat-trigger:active { class=${"embedded-card-host"+(this.cardFading?" fading":"")} >
- `:q:B``}}var De;i([pt({attribute:!1})],Ve.prototype,"hass",void 0),i([mt()],Ve.prototype,"config",void 0),i([mt()],Ve.prototype,"targets",void 0),i([mt()],Ve.prototype,"selectedEntity",void 0),i([mt()],Ve.prototype,"menuOpen",void 0),i([mt()],Ve.prototype,"cardFading",void 0),function(t){t.OFF="off",t.HEAT="heat",t.COOL="cool",t.HEAT_COOL="heat_cool",t.AUTO="auto",t.DRY="dry",t.FAN_ONLY="fan_only"}(De||(De={}));const Ue=["auto","silent","quiet","low","mid","medium","high","max","turbo","full"];const We=["mdi:fan-speed-1","mdi:fan-speed-2","mdi:fan-speed-3","st:fan-speed-4","st:fan-speed-5"],Be=t=>String(t).toLowerCase().replace(/\s+/g,"_"),Ge={low:1,medlow:2,medium_low:2,mid:2,medium:2,medium_high:3,medhigh:3,max:5,turbo:5,full:5};function qe(t,e){const i=Be(t),a=function(t){if(!/^\d+$/.test(t))return;const e=Number(t);return e>=1&&e<=We.length?e:void 0}(i);if(a)return We[a-1];const o=function(t,e){if("high"===t){const t=new Set(e.map(Be));return t.has("medium_high")||t.has("medhigh")||t.has("max")||t.has("turbo")||t.has("full")?4:3}return Ge[t]}(i,e);return o?We[o-1]:void 0}function Ke(t,{decimals:e=1,fallback:i="N/A",locale:a}={}){if(null===t||""===t||["boolean","undefined"].includes(typeof t))return i;const o=Number(t);if(Number.isNaN(o))return i;const n=function(t){if(null===t||""===t||"boolean"==typeof t)return 1;const e=Number(t);return Number.isInteger(e)&&e>=0&&e<=100?e:1}(e);if(!a)return o.toFixed(n);try{return new Intl.NumberFormat("none"===a.number_format?"en-US":function({language:t,number_format:e}){switch(e){case"comma_decimal":return["en-US","en"];case"decimal_comma":return["de","es","it"];case"space_comma":return["fr","sv","cs"];case"quote_decimal":return["de-CH"];case"system":return;default:return t}}(a),{useGrouping:"none"!==a.number_format,minimumFractionDigits:n,maximumFractionDigits:n}).format(o)}catch{return o.toFixed(n)}}const Ze=[["heat",/\b(heat|heater|furnace|radiator|boiler|water[_ -]?heater)\b/],["cool",/\b(cool|cooling|ac|a\/c|air[_ -]?conditioner|snowflake)\b/],["dry",/\b(dry|drying|dehumidifier|dehumidify)\b/],["water-percent",/\b(humidifier|humidify|humidity)\b/],["fan",/\b(fan|blower)\b/],["lightbulb",/\b(light|lamp|bulb)\b/]],Je={heat:["component.climate.state._.heat","state_attributes.climate.hvac_action.heating"],cool:["component.climate.state._.cool","state_attributes.climate.hvac_action.cooling"],dry:["component.climate.state._.dry","state_attributes.humidifier.action.drying"],fan:["component.fan.entity_component._.name"],lightbulb:["component.light.entity_component._.name"],"water-percent":["component.humidifier.entity_component._.name","state_attributes.humidifier.action.humidifying"]};function Ye(t,e){const i=t.toLowerCase().replace(/[.:]/g," "),a=function(t){return"function"!=typeof t?.localize?[]:Object.entries(Je).flatMap(([e,i])=>i.map(e=>t.localize(e)).filter(t=>t&&!i.includes(t)).map(t=>{return[e,(i=String(t),i.toLowerCase().replace(/[.:]/g," "))];var i}))}(e).find(([,t])=>!!t&&(i===t||i.includes(t)));if(a)return a[0];const o=Ze.find(([,t])=>t.test(i));return o?.[0]??""}function Xe(t){if("string"!=typeof t||!t)return"";const e=(i=t.replace(/^[a-z]+:/,""),String(i??"").replace(/[^a-z0-9_-]/gi,""));var i;const a=Ye(e.replace(/-/g," "));return a||(["fire","radiator","heat-wave","heating-coil","water-boiler","water-boiler-auto","water-boiler-off"].includes(e)?"heat":["snowflake","air-conditioner"].includes(e)?"cool":"fan"===e?"fan":e.includes("light")?"lightbulb":["water-percent","air-humidifier"].includes(e)||["air-humidifier-off"].includes(e)?"water-percent":e)}function Qe({icon:t,label:e,entity:i,hass:a}){const o=Xe(t);if(o)return o;const n=function(t){const e=t?.entity_id,i="string"==typeof e?e.split(".")[0]:"",a=t?.attributes?.device_class;return"light"===i?"lightbulb":"fan"===i?"fan":"humidifier"===i?"dehumidifier"===a?"dry":"water-percent":"heat"===a||"heater"===a?"heat":"cold"===a||"cooling"===a?"cool":"moisture"===a||"humidity"===a?"water-percent":""}(i);if(n)return n;return Ye([e,i?.entity_id,i?.attributes?.friendly_name].filter(Boolean).join(" "),a)}function ti(t){return t?`toggle-${t}`:""}function ei({header:t,toggleEntityChanged:e,entity:i,hass:a,openEntityPopover:o}){if(!1===t)return q;const n=we(i)||i.state;let r=t.icon;"object"==typeof t.icon&&(r=r?.[n]??!1);const s=Boolean(t.slashOffIcon),c=t?.name??!1;return B` + `:q:B``}}var Be;i([pt({attribute:!1})],We.prototype,"hass",void 0),i([mt()],We.prototype,"config",void 0),i([mt()],We.prototype,"targets",void 0),i([mt()],We.prototype,"selectedEntity",void 0),i([mt()],We.prototype,"menuOpen",void 0),i([mt()],We.prototype,"cardFading",void 0),function(t){t.OFF="off",t.HEAT="heat",t.COOL="cool",t.HEAT_COOL="heat_cool",t.AUTO="auto",t.DRY="dry",t.FAN_ONLY="fan_only"}(Be||(Be={}));const Ge=["auto","silent","quiet","low","mid","medium","high","max","turbo","full"];const qe=["mdi:fan-speed-1","mdi:fan-speed-2","mdi:fan-speed-3","st:fan-speed-4","st:fan-speed-5"],Ke=t=>String(t).toLowerCase().replace(/\s+/g,"_"),Ze={low:1,medlow:2,medium_low:2,mid:2,medium:2,medium_high:3,medhigh:3,max:5,turbo:5,full:5};function Je(t,e){const i=Ke(t),a=function(t){if(!/^\d+$/.test(t))return;const e=Number(t);return e>=1&&e<=qe.length?e:void 0}(i);if(a)return qe[a-1];const o=function(t,e){if("high"===t){const t=new Set(e.map(Ke));return t.has("medium_high")||t.has("medhigh")||t.has("max")||t.has("turbo")||t.has("full")?4:3}return Ze[t]}(i,e);return o?qe[o-1]:void 0}function Ye(t,{decimals:e=1,fallback:i="N/A",locale:a}={}){if(null===t||""===t||["boolean","undefined"].includes(typeof t))return i;const o=Number(t);if(Number.isNaN(o))return i;const n=function(t){if(null===t||""===t||"boolean"==typeof t)return 1;const e=Number(t);return Number.isInteger(e)&&e>=0&&e<=100?e:1}(e);if(!a)return o.toFixed(n);try{return new Intl.NumberFormat("none"===a.number_format?"en-US":function({language:t,number_format:e}){switch(e){case"comma_decimal":return["en-US","en"];case"decimal_comma":return["de","es","it"];case"space_comma":return["fr","sv","cs"];case"quote_decimal":return["de-CH"];case"system":return;default:return t}}(a),{useGrouping:"none"!==a.number_format,minimumFractionDigits:n,maximumFractionDigits:n}).format(o)}catch{return o.toFixed(n)}}const Xe=[["heat",/\b(heat|heater|furnace|radiator|boiler|water[_ -]?heater)\b/],["cool",/\b(cool|cooling|ac|a\/c|air[_ -]?conditioner|snowflake)\b/],["dry",/\b(dry|drying|dehumidifier|dehumidify)\b/],["water-percent",/\b(humidifier|humidify|humidity)\b/],["fan",/\b(fan|blower)\b/],["lightbulb",/\b(light|lamp|bulb)\b/]],Qe={heat:["component.climate.state._.heat","state_attributes.climate.hvac_action.heating"],cool:["component.climate.state._.cool","state_attributes.climate.hvac_action.cooling"],dry:["component.climate.state._.dry","state_attributes.humidifier.action.drying"],fan:["component.fan.entity_component._.name"],lightbulb:["component.light.entity_component._.name"],"water-percent":["component.humidifier.entity_component._.name","state_attributes.humidifier.action.humidifying"]};function ti(t,e){const i=t.toLowerCase().replace(/[.:]/g," "),a=function(t){return"function"!=typeof t?.localize?[]:Object.entries(Qe).flatMap(([e,i])=>i.map(e=>t.localize(e)).filter(t=>t&&!i.includes(t)).map(t=>{return[e,(i=String(t),i.toLowerCase().replace(/[.:]/g," "))];var i}))}(e).find(([,t])=>!!t&&(i===t||i.includes(t)));if(a)return a[0];const o=Xe.find(([,t])=>t.test(i));return o?.[0]??""}function ei(t){if("string"!=typeof t||!t)return"";const e=(i=t.replace(/^[a-z]+:/,""),String(i??"").replace(/[^a-z0-9_-]/gi,""));var i;const a=ti(e.replace(/-/g," "));return a||(["fire","radiator","heat-wave","heating-coil","water-boiler","water-boiler-auto","water-boiler-off"].includes(e)?"heat":["snowflake","air-conditioner"].includes(e)?"cool":"fan"===e?"fan":e.includes("light")?"lightbulb":["water-percent","air-humidifier"].includes(e)||["air-humidifier-off"].includes(e)?"water-percent":e)}function ii({icon:t,label:e,entity:i,hass:a}){const o=ei(t);if(o)return o;const n=function(t){const e=t?.entity_id,i="string"==typeof e?e.split(".")[0]:"",a=t?.attributes?.device_class;return"light"===i?"lightbulb":"fan"===i?"fan":"humidifier"===i?"dehumidifier"===a?"dry":"water-percent":"heat"===a||"heater"===a?"heat":"cold"===a||"cooling"===a?"cool":"moisture"===a||"humidity"===a?"water-percent":""}(i);if(n)return n;return ti([e,i?.entity_id,i?.attributes?.friendly_name].filter(Boolean).join(" "),a)}function ai(t){return t?`toggle-${t}`:""}function oi({header:t,toggleEntityChanged:e,entity:i,hass:a,openEntityPopover:o}){if(!1===t)return q;const n=Se(i)||i.state;let r=t.icon;"object"==typeof t.icon&&(r=r?.[n]??!1);const s=Boolean(t.slashOffIcon),c=t?.name??!1;return B`
o()}> ${function(t,e,i,a=!1){const o=i&&i!==e?` ${i}`:"";return t?B` @@ -3141,7 +3141,7 @@ ha-card.standard-visuals .thermostat-trigger:active { >`:q);return B`
${i}
`}(t.faults,o)} ${function(t,e,i,a,o){return t?.length?B`
- ${t.map(t=>{if(!0===t.hide_when_off&&"off"===o?.state)return q;const n=t.entity?.entity_id,r=t.entity?.state,s="string"==typeof n?n.split(".")[0]:"",c=ti(Qe({icon:"string"==typeof t.icon?t.icon:t.entity?.attributes?.icon,label:t.label,entity:t.entity,hass:a}));return B` + ${t.map(t=>{if(!0===t.hide_when_off&&"off"===o?.state)return q;const n=t.entity?.entity_id,r=t.entity?.state,s="string"==typeof n?n.split(".")[0]:"",c=ai(ii({icon:"string"==typeof t.icon?t.icon:t.entity?.attributes?.icon,label:t.label,entity:t.entity,hass:a}));return B`
@@ -3161,24 +3161,24 @@ ha-card.standard-visuals .thermostat-trigger:active {
`:q}(t.toggles,o,e,a,i)}
- `}function ii(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ai(t,e,i){if(!e||"string"!=typeof e)return String(t);const a=String(t);return new RegExp(`${ii(e)}$`).test(a)?a:`${a}${function(t,e){if(e){const i=e.match(new RegExp(`(\\s*)${ii(t)}$`));if(i)return i[1]??""}return"%"===t?"":" "}(e,i)}${e}`}var oi,ni={exports:{}};function ri(){return oi||(oi=1,function(t){function e(t){var i,a,o=new Error(t);return i=o,a=e.prototype,Object.setPrototypeOf?Object.setPrototypeOf(i,a):i.__proto__=a,o}function i(t,i,a){var o=i.slice(0,a).split(/\n/),n=o.length,r=o[n-1].length+1;throw e(t+=" at line "+n+" col "+r+":\n\n "+i.split(/\n/)[n-1]+"\n "+Array(r).join(" ")+"^")}e.prototype=Object.create(Error.prototype,{name:{value:"Squirrelly Error",enumerable:!1}});var a=new Function("return this")().Promise,o=!1;try{o=new Function("return (async function(){}).constructor")()}catch(t){if(!(t instanceof SyntaxError))throw t}function n(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function r(t,e,i){for(var a in e)n(e,a)&&(null==e[a]||"object"!=typeof e[a]||"storage"!==a&&"prefixes"!==a||i?t[a]=e[a]:t[a]=r({},e[a]));return t}var s=/^async +/,c=/`(?:\\[\s\S]|\${(?:[^{}]|{(?:[^{}]|{[^}]*})*})*}|(?!\${)[^\\`])*`/g,l=/'(?:\\[\s\w"'\\`]|[^\n\r'\\])*?'/g,d=/"(?:\\[\s\w"'\\`]|[^\n\r"\\])*?"/g,h=/[.*+\-?^${}()|[\]\\]/g;function u(t){return h.test(t)?t.replace(h,"\\$&"):t}function p(t,a){a.rmWhitespace&&(t=t.replace(/[\r\n]+/g,"\n").replace(/^\s+|\s+$/gm,"")),c.lastIndex=0,l.lastIndex=0,d.lastIndex=0;var o=a.prefixes,n=[o.h,o.b,o.i,o.r,o.c,o.e].reduce(function(t,e){return t&&e?t+"|"+u(e):e?u(e):t},""),r=new RegExp("([|()]|=>)|('|\"|`|\\/\\*)|\\s*((\\/)?(-|_)?"+u(a.tags[1])+")","g"),h=new RegExp("([^]*?)"+u(a.tags[0])+"(-|_)?\\s*("+n+")?\\s*","g"),p=0,m=!1;function g(e,o){var n,u={f:[]},g=0,f="c";function v(e){var o=t.slice(p,e),n=o.trim();if("f"===f)"safe"===n?u.raw=!0:a.async&&s.test(n)?(n=n.replace(s,""),u.f.push([n,"",!0])):u.f.push([n,""]);else if("fp"===f)u.f[u.f.length-1][1]+=n;else if("err"===f){if(n){var r=o.search(/\S/);i("invalid syntax",t,p+r)}}else u[f]=n;p=e+1}for("h"===o||"b"===o||"c"===o?f="n":"r"===o&&(u.raw=!0,o="i"),r.lastIndex=p;null!==(n=r.exec(t));){var y=n[1],b=n[2],_=n[3],w=n[4],x=n[5],$=n.index;if(y)"("===y?(0===g&&("n"===f?(v($),f="p"):"f"===f&&(v($),f="fp")),g++):")"===y?0===--g&&"c"!==f&&(v($),f="err"):0===g&&"|"===y?(v($),f="f"):"=>"===y&&(v($),p+=1,f="res");else if(b)if("/*"===b){var S=t.indexOf("*/",r.lastIndex);-1===S&&i("unclosed comment",t,n.index),r.lastIndex=S+2}else"'"===b?(l.lastIndex=n.index,l.exec(t)?r.lastIndex=l.lastIndex:i("unclosed string",t,n.index)):'"'===b?(d.lastIndex=n.index,d.exec(t)?r.lastIndex=d.lastIndex:i("unclosed string",t,n.index)):"`"===b&&(c.lastIndex=n.index,c.exec(t)?r.lastIndex=c.lastIndex:i("unclosed string",t,n.index));else if(_)return v($),p=$+n[0].length,h.lastIndex=p,m=x,w&&"h"===o&&(o="s"),u.t=o,u}return i("unclosed tag",t,e),u}var f=function n(r,c){r.b=[],r.d=[];var l,d=!1,u=[];function f(t,e){t&&(t=function(t,e,i,a){var o,n;return"string"==typeof e.autoTrim?o=n=e.autoTrim:Array.isArray(e.autoTrim)&&(o=e.autoTrim[1],n=e.autoTrim[0]),(i||!1===i)&&(o=i),(a||!1===a)&&(n=a),"slurp"===o&&"slurp"===n?t.trim():("_"===o||"slurp"===o?t=String.prototype.trimLeft?t.trimLeft():t.replace(/^[\s\uFEFF\xA0]+/,""):"-"!==o&&"nl"!==o||(t=t.replace(/^(?:\n|\r|\r\n)/,"")),"_"===n||"slurp"===n?t=String.prototype.trimRight?t.trimRight():t.replace(/[\s\uFEFF\xA0]+$/,""):"-"!==n&&"nl"!==n||(t=t.replace(/(?:\n|\r|\r\n)$/,"")),t)}(t,a,m,e),t&&(t=t.replace(/\\|'/g,"\\$&").replace(/\r\n|\n|\r/g,"\\n"),u.push(t)))}for(;null!==(l=h.exec(t));){var v,y=l[1],b=l[2],_=l[3]||"";for(var w in o)if(o[w]===_){v=w;break}f(y,b),p=l.index+l[0].length,v||i("unrecognized tag type: "+_,t,p);var x=g(l.index,v),$=x.t;if("h"===$){var S=x.n||"";a.async&&s.test(S)&&(x.a=!0,x.n=S.replace(s,"")),x=n(x),u.push(x)}else if("c"===$){if(r.n===x.n)return d?(d.d=u,r.b.push(d)):r.d=u,r;i("Helper start and end don't match",t,l.index+l[0].length)}else if("b"===$){d?(d.d=u,r.b.push(d)):r.d=u;var A=x.n||"";a.async&&s.test(A)&&(x.a=!0,x.n=A.replace(s,"")),d=x,u=[]}else if("s"===$){var k=x.n||"";a.async&&s.test(k)&&(x.a=!0,x.n=k.replace(s,"")),u.push(x)}else u.push(x)}if(!c)throw e('unclosed helper "'+r.n+'"');return f(t.slice(p,t.length),!1),r.d=u,r}({f:[]},!0);if(a.plugins)for(var v=0;v0)throw e((o?"Native":"")+"Helper '"+t+"' doesn't accept blocks");if(a&&a.length>0)throw e((o?"Native":"")+"Helper '"+t+"' doesn't accept filters")}function x(t,e,i,a,o){i(t[e],e).then(function(n){a+=n,e===t.length-1?o(a):x(t,e+1,i,a,o)})}function $(t,e,i,a,o,n){a(e[i],t[e[i]]).then(function(r){o+=r,i===e.length-1?n(o):$(t,e,i+1,a,o,n)})}var S={"&":"&","<":"<",">":">",'"':""","'":"'"};function A(t){return S[t]}var k=new _({}),E=new _({each:function(t,e){var i="",a=t.params[0];if(w("each",e,!1),t.async)return new Promise(function(e){x(a,0,t.exec,i,e)});for(var o=0;o"']/.test(e)?e.replace(/[&<>"']/g,A):e}}),T={varName:"it",autoTrim:[!1,"nl"],autoEscape:!0,defaultFilter:!1,tags:["{{","}}"],l:function(t,i){if("H"===t){var a=this.storage.helpers.get(i);if(a)return a;throw e("Can't find helper '"+i+"'")}if("F"===t){var o=this.storage.filters.get(i);if(o)return o;throw e("Can't find filter '"+i+"'")}},async:!1,storage:{helpers:E,nativeHelpers:z,filters:C,templates:k},prefixes:{h:"@",b:"#",i:"",r:"*",c:"/",e:"!"},cache:!1,plugins:[],useWith:!1};function R(t,e){var i={};return r(i,T),e&&r(i,e),t&&r(i,t),i.l.bind(i),i}function O(t,i){var a,n=R(i||{}),r=Function;if(n.async){if(!o)throw e("This environment doesn't support async/await");r=o}if(n.varName&&!1===(a=n.varName,/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(a)))throw e("options.varName must be a valid JS identifier");try{return new r(n.varName,"c","cb",m(t,n))}catch(i){throw i instanceof SyntaxError?e("Bad template syntax\n\n"+i.message+"\n"+Array(i.message.length+1).join("=")+"\n"+m(t,n)):i}}function N(t,e){var i;return e.cache&&e.name&&e.storage.templates.get(e.name)?e.storage.templates.get(e.name):(i="function"==typeof t?t:O(t,e),e.cache&&e.name&&e.storage.templates.define(e.name,i),i)}T.l.bind(T),t.compile=O,t.compileScope=b,t.compileScopeIntoFunction=y,t.compileToString=m,t.defaultConfig=T,t.filters=C,t.getConfig=R,t.helpers=E,t.nativeHelpers=z,t.parse=p,t.render=function(t,i,o,n){var r=R(o||{});if(!r.async)return N(t,r)(i,r);if(!n){if("function"==typeof a)return new a(function(e,a){try{e(N(t,r)(i,r))}catch(t){a(t)}});throw e("Please provide a callback function, this env doesn't support Promises")}try{N(t,r)(i,r,n)}catch(t){return n(t)}},t.templates=k,Object.defineProperty(t,"__esModule",{value:!0})}(ni.exports)),ni.exports}var si=ri();si.defaultConfig.autoEscape=!1;function ci(t,e=1){if(null===t||""===t||"boolean"==typeof t)return e;const i=Number(t);return Number.isInteger(i)&&i>=0&&i<=100?i:e}function li(t){return String(t??"").replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")}function di(t){return li(t)}function hi(t){return"string"==typeof t?t.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'"):Array.isArray(t)?t.map(hi):t&&"object"==typeof t?Object.fromEntries(Object.entries(t).map(([t,e])=>[t,hi(e)])):t}function ui({template:t,stateObj:e,attribute:i,hass:a,config:o={},variables:n={},localize:r=t=>t}){const[s]=String(e?.entity_id??"").split("."),c=e?.attributes??{},l=i&&Object.prototype.hasOwnProperty.call(c,i)?c[i]:e?.state,d=i&&"function"==typeof a.formatEntityAttributeValue?a.formatEntityAttributeValue(e,i):"function"==typeof a.formatEntityState?a.formatEntityState(e):r(String(l),`component.${s}.state._.`),h=a.selectedLanguage||a.language,u="ui.card.climate.",p=Object.entries(a.resources?.[h]??{}).reduce((t,[e,i])=>(String(e).startsWith(u)&&(t[String(e).replace(u,"")]=i),t),{}),m=new Proxy(p,{get(t,e){if("string"!=typeof e)return Reflect.get(t,e);if(Object.prototype.hasOwnProperty.call(t,e))return t[e];const i=`${u}${e}`,o=a.localize?.(i);return o&&o!==i?o:""}});si.filters.define("formatNumber",(t,e={decimals:o.decimals})=>{const i=ci(o.decimals);return String(Ke(t,{...e,decimals:ci(e?.decimals,i),locale:a.locale}))}),si.filters.define("relativetime",t=>``),si.filters.define("translate",(t,i="")=>!i&&"function"==typeof a.formatEntityAttributeValue&&"string"==typeof t&&t in c?a.formatEntityAttributeValue(e,t):r(t,i||"climate"!==s&&"humidifier"!==s?i:`state_attributes.${s}.${t}`));try{return si.render(t,{...hi(c),state:{raw:hi(l),text:hi(d)},state_attr:(t,e)=>hi(a.states?.[t]?.attributes?.[e]),ui:m,v:n},{useWith:!0})}catch(t){return console.error("simple-thermostat: entity template failed",t),li(d)}}si.filters.define("icon",t=>``),si.filters.define("join",(t,e=", ")=>t.join(e)),si.filters.define("css",(t,e)=>`"'`;{}]/g,"")}(i)};`:t},""))}">${li(t)}`),si.filters.define("debug",t=>{try{return JSON.stringify(t)}catch{return`Not able to read valid JSON object from: ${t}`}});const pi="simple-thermostat-timer-remaining";function mi(t){return String(t).padStart(2,"0")}class gi extends lt{createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),this.syncTicker()}disconnectedCallback(){this.clearTicker(),super.disconnectedCallback()}updated(){this.syncTicker()}clearTicker(){this.tick&&(window.clearInterval(this.tick),this.tick=void 0)}syncTicker(){const t="active"===this.stateObj?.state,e=this.stateObj?.attributes?.finishes_at,i=e?Date.parse(e):NaN,a=!Number.isNaN(i)&&i>Date.now();t&&a&&!this.tick?this.tick=window.setInterval(()=>{i<=Date.now()&&this.clearTicker(),this.requestUpdate()},1e3):t&&a||!this.tick||this.clearTicker()}getValue(){const t=this.stateObj;if(!t)return"";if("active"===t.state&&t.attributes?.finishes_at){const e=Date.parse(t.attributes.finishes_at);if(!Number.isNaN(e))return function(t){const e=Math.max(0,Math.ceil(t)),i=Math.floor(e/3600),a=Math.floor(e%3600/60),o=e%60;return i>0?`${i}:${mi(a)}:${mi(o)}`:`${a}:${mi(o)}`}((e-Date.now())/1e3)}return"paused"===t.state&&t.attributes?.remaining?t.attributes.remaining:"function"==typeof this.hass?.formatEntityState?this.hass.formatEntityState(t):t.state}render(){return B`${this.getValue()}`}}i([pt({attribute:!1})],gi.prototype,"stateObj",void 0),i([pt({attribute:!1})],gi.prototype,"hass",void 0),customElements.get(pi)||customElements.define(pi,gi);class fi extends oe{constructor(t){if(super(t),this.it=q,t.type!==ie)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(t){if(t===q||null==t)return this._t=void 0,this.it=t;if(t===G)return t;if("string"!=typeof t)throw Error(this.constructor.directiveName+"() called with a non-string value");if(t===this.it)return this._t;this.it=t;const e=[t];return e.raw=e,this._t={_$litType$:this.constructor.resultType,strings:e,values:[]}}}fi.directiveName="unsafeHTML",fi.resultType=1;const vi=ae(fi);class yi extends lt{constructor(){super(...arguments),this.markup=""}createRenderRoot(){return this}render(){return vi(this.markup)}updated(){this.querySelectorAll("ha-relative-time").forEach(t=>{const e=t;e.datetime=t.getAttribute("datetime")??void 0,e.hass=this.hass})}}function bi(t,e){return t.includes(")|('|\"|`|\\/\\*)|\\s*((\\/)?(-|_)?"+u(a.tags[1])+")","g"),h=new RegExp("([^]*?)"+u(a.tags[0])+"(-|_)?\\s*("+n+")?\\s*","g"),p=0,m=!1;function g(e,o){var n,u={f:[]},g=0,f="c";function v(e){var o=t.slice(p,e),n=o.trim();if("f"===f)"safe"===n?u.raw=!0:a.async&&s.test(n)?(n=n.replace(s,""),u.f.push([n,"",!0])):u.f.push([n,""]);else if("fp"===f)u.f[u.f.length-1][1]+=n;else if("err"===f){if(n){var r=o.search(/\S/);i("invalid syntax",t,p+r)}}else u[f]=n;p=e+1}for("h"===o||"b"===o||"c"===o?f="n":"r"===o&&(u.raw=!0,o="i"),r.lastIndex=p;null!==(n=r.exec(t));){var y=n[1],b=n[2],_=n[3],w=n[4],x=n[5],$=n.index;if(y)"("===y?(0===g&&("n"===f?(v($),f="p"):"f"===f&&(v($),f="fp")),g++):")"===y?0===--g&&"c"!==f&&(v($),f="err"):0===g&&"|"===y?(v($),f="f"):"=>"===y&&(v($),p+=1,f="res");else if(b)if("/*"===b){var S=t.indexOf("*/",r.lastIndex);-1===S&&i("unclosed comment",t,n.index),r.lastIndex=S+2}else"'"===b?(l.lastIndex=n.index,l.exec(t)?r.lastIndex=l.lastIndex:i("unclosed string",t,n.index)):'"'===b?(d.lastIndex=n.index,d.exec(t)?r.lastIndex=d.lastIndex:i("unclosed string",t,n.index)):"`"===b&&(c.lastIndex=n.index,c.exec(t)?r.lastIndex=c.lastIndex:i("unclosed string",t,n.index));else if(_)return v($),p=$+n[0].length,h.lastIndex=p,m=x,w&&"h"===o&&(o="s"),u.t=o,u}return i("unclosed tag",t,e),u}var f=function n(r,c){r.b=[],r.d=[];var l,d=!1,u=[];function f(t,e){t&&(t=function(t,e,i,a){var o,n;return"string"==typeof e.autoTrim?o=n=e.autoTrim:Array.isArray(e.autoTrim)&&(o=e.autoTrim[1],n=e.autoTrim[0]),(i||!1===i)&&(o=i),(a||!1===a)&&(n=a),"slurp"===o&&"slurp"===n?t.trim():("_"===o||"slurp"===o?t=String.prototype.trimLeft?t.trimLeft():t.replace(/^[\s\uFEFF\xA0]+/,""):"-"!==o&&"nl"!==o||(t=t.replace(/^(?:\n|\r|\r\n)/,"")),"_"===n||"slurp"===n?t=String.prototype.trimRight?t.trimRight():t.replace(/[\s\uFEFF\xA0]+$/,""):"-"!==n&&"nl"!==n||(t=t.replace(/(?:\n|\r|\r\n)$/,"")),t)}(t,a,m,e),t&&(t=t.replace(/\\|'/g,"\\$&").replace(/\r\n|\n|\r/g,"\\n"),u.push(t)))}for(;null!==(l=h.exec(t));){var v,y=l[1],b=l[2],_=l[3]||"";for(var w in o)if(o[w]===_){v=w;break}f(y,b),p=l.index+l[0].length,v||i("unrecognized tag type: "+_,t,p);var x=g(l.index,v),$=x.t;if("h"===$){var S=x.n||"";a.async&&s.test(S)&&(x.a=!0,x.n=S.replace(s,"")),x=n(x),u.push(x)}else if("c"===$){if(r.n===x.n)return d?(d.d=u,r.b.push(d)):r.d=u,r;i("Helper start and end don't match",t,l.index+l[0].length)}else if("b"===$){d?(d.d=u,r.b.push(d)):r.d=u;var A=x.n||"";a.async&&s.test(A)&&(x.a=!0,x.n=A.replace(s,"")),d=x,u=[]}else if("s"===$){var k=x.n||"";a.async&&s.test(k)&&(x.a=!0,x.n=k.replace(s,"")),u.push(x)}else u.push(x)}if(!c)throw e('unclosed helper "'+r.n+'"');return f(t.slice(p,t.length),!1),r.d=u,r}({f:[]},!0);if(a.plugins)for(var v=0;v0)throw e((o?"Native":"")+"Helper '"+t+"' doesn't accept blocks");if(a&&a.length>0)throw e((o?"Native":"")+"Helper '"+t+"' doesn't accept filters")}function x(t,e,i,a,o){i(t[e],e).then(function(n){a+=n,e===t.length-1?o(a):x(t,e+1,i,a,o)})}function $(t,e,i,a,o,n){a(e[i],t[e[i]]).then(function(r){o+=r,i===e.length-1?n(o):$(t,e,i+1,a,o,n)})}var S={"&":"&","<":"<",">":">",'"':""","'":"'"};function A(t){return S[t]}var k=new _({}),E=new _({each:function(t,e){var i="",a=t.params[0];if(w("each",e,!1),t.async)return new Promise(function(e){x(a,0,t.exec,i,e)});for(var o=0;o"']/.test(e)?e.replace(/[&<>"']/g,A):e}}),T={varName:"it",autoTrim:[!1,"nl"],autoEscape:!0,defaultFilter:!1,tags:["{{","}}"],l:function(t,i){if("H"===t){var a=this.storage.helpers.get(i);if(a)return a;throw e("Can't find helper '"+i+"'")}if("F"===t){var o=this.storage.filters.get(i);if(o)return o;throw e("Can't find filter '"+i+"'")}},async:!1,storage:{helpers:E,nativeHelpers:z,filters:C,templates:k},prefixes:{h:"@",b:"#",i:"",r:"*",c:"/",e:"!"},cache:!1,plugins:[],useWith:!1};function R(t,e){var i={};return r(i,T),e&&r(i,e),t&&r(i,t),i.l.bind(i),i}function O(t,i){var a,n=R(i||{}),r=Function;if(n.async){if(!o)throw e("This environment doesn't support async/await");r=o}if(n.varName&&!1===(a=n.varName,/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(a)))throw e("options.varName must be a valid JS identifier");try{return new r(n.varName,"c","cb",m(t,n))}catch(i){throw i instanceof SyntaxError?e("Bad template syntax\n\n"+i.message+"\n"+Array(i.message.length+1).join("=")+"\n"+m(t,n)):i}}function N(t,e){var i;return e.cache&&e.name&&e.storage.templates.get(e.name)?e.storage.templates.get(e.name):(i="function"==typeof t?t:O(t,e),e.cache&&e.name&&e.storage.templates.define(e.name,i),i)}T.l.bind(T),t.compile=O,t.compileScope=b,t.compileScopeIntoFunction=y,t.compileToString=m,t.defaultConfig=T,t.filters=C,t.getConfig=R,t.helpers=E,t.nativeHelpers=z,t.parse=p,t.render=function(t,i,o,n){var r=R(o||{});if(!r.async)return N(t,r)(i,r);if(!n){if("function"==typeof a)return new a(function(e,a){try{e(N(t,r)(i,r))}catch(t){a(t)}});throw e("Please provide a callback function, this env doesn't support Promises")}try{N(t,r)(i,r,n)}catch(t){return n(t)}},t.templates=k,Object.defineProperty(t,"__esModule",{value:!0})}(ci.exports)),ci.exports}var di=li();di.defaultConfig.autoEscape=!1;function hi(t,e=1){if(null===t||""===t||"boolean"==typeof t)return e;const i=Number(t);return Number.isInteger(i)&&i>=0&&i<=100?i:e}function ui(t){return String(t??"").replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")}function pi(t){return ui(t)}function mi(t){return"string"==typeof t?t.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'"):Array.isArray(t)?t.map(mi):t&&"object"==typeof t?Object.fromEntries(Object.entries(t).map(([t,e])=>[t,mi(e)])):t}function gi({template:t,stateObj:e,attribute:i,hass:a,config:o={},variables:n={},localize:r=t=>t}){const[s]=String(e?.entity_id??"").split("."),c=e?.attributes??{},l=i&&Object.prototype.hasOwnProperty.call(c,i)?c[i]:e?.state,d=i&&"function"==typeof a.formatEntityAttributeValue?a.formatEntityAttributeValue(e,i):"function"==typeof a.formatEntityState?a.formatEntityState(e):r(String(l),`component.${s}.state._.`),h=a.selectedLanguage||a.language,u="ui.card.climate.",p=Object.entries(a.resources?.[h]??{}).reduce((t,[e,i])=>(String(e).startsWith(u)&&(t[String(e).replace(u,"")]=i),t),{}),m=new Proxy(p,{get(t,e){if("string"!=typeof e)return Reflect.get(t,e);if(Object.prototype.hasOwnProperty.call(t,e))return t[e];const i=`${u}${e}`,o=a.localize?.(i);return o&&o!==i?o:""}});di.filters.define("formatNumber",(t,e={decimals:o.decimals})=>{const i=hi(o.decimals);return String(Ye(t,{...e,decimals:hi(e?.decimals,i),locale:a.locale}))}),di.filters.define("relativetime",t=>``),di.filters.define("translate",(t,i="")=>!i&&"function"==typeof a.formatEntityAttributeValue&&"string"==typeof t&&t in c?a.formatEntityAttributeValue(e,t):r(t,i||"climate"!==s&&"humidifier"!==s?i:`state_attributes.${s}.${t}`));try{return di.render(t,{...mi(c),state:{raw:mi(l),text:mi(d)},state_attr:(t,e)=>mi(a.states?.[t]?.attributes?.[e]),ui:m,v:n},{useWith:!0})}catch(t){return console.error("simple-thermostat: entity template failed",t),ui(d)}}di.filters.define("icon",t=>``),di.filters.define("join",(t,e=", ")=>t.join(e)),di.filters.define("css",(t,e)=>`"'`;{}]/g,"")}(i)};`:t},""))}">${ui(t)}`),di.filters.define("debug",t=>{try{return JSON.stringify(t)}catch{return`Not able to read valid JSON object from: ${t}`}});const fi="simple-thermostat-timer-remaining";function vi(t){return String(t).padStart(2,"0")}class yi extends lt{createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),this.syncTicker()}disconnectedCallback(){this.clearTicker(),super.disconnectedCallback()}updated(){this.syncTicker()}clearTicker(){this.tick&&(window.clearInterval(this.tick),this.tick=void 0)}syncTicker(){const t="active"===this.stateObj?.state,e=this.stateObj?.attributes?.finishes_at,i=e?Date.parse(e):NaN,a=!Number.isNaN(i)&&i>Date.now();t&&a&&!this.tick?this.tick=window.setInterval(()=>{i<=Date.now()&&this.clearTicker(),this.requestUpdate()},1e3):t&&a||!this.tick||this.clearTicker()}getValue(){const t=this.stateObj;if(!t)return"";if("active"===t.state&&t.attributes?.finishes_at){const e=Date.parse(t.attributes.finishes_at);if(!Number.isNaN(e))return function(t){const e=Math.max(0,Math.ceil(t)),i=Math.floor(e/3600),a=Math.floor(e%3600/60),o=e%60;return i>0?`${i}:${vi(a)}:${vi(o)}`:`${a}:${vi(o)}`}((e-Date.now())/1e3)}return"paused"===t.state&&t.attributes?.remaining?t.attributes.remaining:"function"==typeof this.hass?.formatEntityState?this.hass.formatEntityState(t):t.state}render(){return B`${this.getValue()}`}}i([pt({attribute:!1})],yi.prototype,"stateObj",void 0),i([pt({attribute:!1})],yi.prototype,"hass",void 0),customElements.get(fi)||customElements.define(fi,yi);class bi extends oe{constructor(t){if(super(t),this.it=q,t.type!==ie)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(t){if(t===q||null==t)return this._t=void 0,this.it=t;if(t===G)return t;if("string"!=typeof t)throw Error(this.constructor.directiveName+"() called with a non-string value");if(t===this.it)return this._t;this.it=t;const e=[t];return e.raw=e,this._t={_$litType$:this.constructor.resultType,strings:e,values:[]}}}bi.directiveName="unsafeHTML",bi.resultType=1;const _i=ae(bi);class wi extends lt{constructor(){super(...arguments),this.markup=""}createRenderRoot(){return this}render(){return _i(this.markup)}updated(){this.querySelectorAll("ha-relative-time").forEach(t=>{const e=t;e.datetime=t.getAttribute("datetime")??void 0,e.hass=this.hass})}}function xi(t,e){return t.includes("`:vi(t)}i([pt({attribute:!1})],yi.prototype,"markup",void 0),i([pt({attribute:!1})],yi.prototype,"hass",void 0),customElements.get("simple-thermostat-template-content")||customElements.define("simple-thermostat-template-content",yi);const _i=["automation","fan","humidifier","input_boolean","light","switch"],wi=["button","input_button","script","scene"],xi=["row","auto","button","toggle","chip"];function $i(t,e,i){if(!be(t.states?.[e]))return;const a="turn_"+(i?"on":"off");"function"==typeof t.performAction?t.performAction({action:`homeassistant.${a}`,data:{entity_id:e}}):t.callService("homeassistant",a,{entity_id:e})}function Si(t){return String(t??"").replace(/[^a-z0-9_-]/gi,"")}function Ai(t){return!!t&&"object"==typeof t&&"string"==typeof t.entity_id}function ki(t,e,i,a){const{template:o,attribute:n,decimals:r,unit:s,type:c,config:l,variables:d}=e,h=Ai(t);if(o&&h)return bi(ai(ui({template:o,stateObj:t,attribute:n,hass:i,config:l,variables:d,localize:a}),s||!1),i);const u=h?n?t.attributes?.[n]:t.state:t;if("relativetime"===c)return B``:_i(t)}i([pt({attribute:!1})],wi.prototype,"markup",void 0),i([pt({attribute:!1})],wi.prototype,"hass",void 0),customElements.get("simple-thermostat-template-content")||customElements.define("simple-thermostat-template-content",wi);const $i=["row","auto","button","toggle","chip"];function Si(t){return String(t??"").replace(/[^a-z0-9_-]/gi,"")}function Ai(t){return!!t&&"object"==typeof t&&"string"==typeof t.entity_id}function ki(t,e,i,a){const{template:o,attribute:n,decimals:r,unit:s,type:c,config:l,variables:d}=e,h=Ai(t);if(o&&h)return xi(ri(gi({template:o,stateObj:t,attribute:n,hass:i,config:l,variables:d,localize:a}),s||!1),i);const u=h?n?t.attributes?.[n]:t.state:t;if("relativetime"===c)return B``;if(h&&!n&&t.entity_id.startsWith("timer."))return B``;if(null==u)return l?.fallback??"N/A";if("object"==typeof u)return JSON.stringify(u);let p=u;if("number"==typeof r)p=Ke(u,{decimals:r,locale:i.locale,fallback:l?.fallback});else if(h){const e=t.entity_id.split(".")[0];p=n?"function"==typeof i.formatEntityAttributeValue?i.formatEntityAttributeValue(t,n):u:"function"==typeof i.formatEntityState?i.formatEntityState(s?{...t,attributes:{...t.attributes,unit_of_measurement:void 0}}:t):a?a(String(u),`component.${e}.state.${t.attributes?.device_class??"_"}.`):u}const m=h&&!n?t.attributes?.unit_of_measurement:"",g=!h||n||"humidity"!==t.attributes?.device_class&&!t.entity_id.includes("humidity")&&"mdi:water-percent"!==e.icon?"":"%",f=s?function(t,e){const i=String(t);return e&&"string"==typeof e&&i.endsWith(e)?i.slice(0,-e.length).trimEnd():i}(p,m):p;return ai(f,s||m||g||!1,String(p))}function Ei({hide:t=!1,hass:e,state:i,details:a,localize:o,openEntityPopover:n}){if(t||void 0===i)return;const{type:r,heading:s,icon:c,unit:l,decimals:d,tooltip:h,entity:u,template:p,attribute:m,variables:g,config:f,separator:v=!0,display:y}=a,b=function({icon:t,state:e,attribute:i,hass:a,config:o,variables:n,localize:r}){return"string"==typeof t&&t.includes("{{")&&"object"==typeof e&&null!==e?ui({template:t,stateObj:e,attribute:i,hass:a,config:o,variables:n,localize:r}).trim():t}({icon:c,state:i,attribute:m,hass:e,config:f,variables:g,localize:o}),_=function({heading:t,state:e,attribute:i,hass:a,config:o,variables:n,localize:r}){if("string"==typeof t&&t.includes("{{")&&"object"==typeof e&&null!==e)return ui({template:t,stateObj:e,attribute:i,hass:a,config:o,variables:n,localize:r}).trim()}({heading:s,state:i,attribute:m,hass:e,config:f,variables:g,localize:o}),w=Ai(i),x=w?i.entity_id:u,$=x&&"function"==typeof n,S=h||(w?i?.attributes?.friendly_name||i?.entity_id:u?e.states?.[u]?.attributes?.friendly_name||u:void 0);let A,k="",E="",z=!1,C=!1;const T=ki(i,a,e,o);if(w){const[t]=i.entity_id.split(".");k=t,E=i.state,z=_i.includes(t);const a=function(t,e){return"string"==typeof t&&xi.includes(t)?"auto"!==t?t:_i.includes(e)?"toggle":wi.includes(e)?"button":"chip":"row"}(y,t),o=[z&&"toggle-entity",k&&`domain-${Si(k)}`,E&&`state-${Si(E)}`,"row"!==a&&`display-${a}`,z&&ti(Qe({icon:b||i.attributes?.icon,label:s||i.attributes?.friendly_name,entity:i,hass:e}))].filter(Boolean).join(" ");if("row"!==a){C=!0;const r=z||wi.includes(t),c="on"===i.state,l=void 0!==_?bi(_,e):"string"==typeof s?s:i.attributes?.friendly_name||i.entity_id,d=b||i.attributes?.icon||(z?"mdi:toggle-switch":wi.includes(t)?"mdi:gesture-tap-button":void 0);A=B` + >`;if(null==u)return l?.fallback??"N/A";if("object"==typeof u)return JSON.stringify(u);let p=u;if("number"==typeof r)p=Ye(u,{decimals:r,locale:i.locale,fallback:l?.fallback});else if(h){const e=t.entity_id.split(".")[0];p=n?"function"==typeof i.formatEntityAttributeValue?i.formatEntityAttributeValue(t,n):u:"function"==typeof i.formatEntityState?i.formatEntityState(s?{...t,attributes:{...t.attributes,unit_of_measurement:void 0}}:t):a?a(String(u),`component.${e}.state.${t.attributes?.device_class??"_"}.`):u}const m=h&&!n?t.attributes?.unit_of_measurement:"",g=!h||n||"humidity"!==t.attributes?.device_class&&!t.entity_id.includes("humidity")&&"mdi:water-percent"!==e.icon?"":"%",f=s?function(t,e){const i=String(t);return e&&"string"==typeof e&&i.endsWith(e)?i.slice(0,-e.length).trimEnd():i}(p,m):p;return ri(f,s||m||g||!1,String(p))}function Ei({hide:t=!1,hass:e,state:i,details:a,localize:o,openEntityPopover:n}){if(t||void 0===i)return;const{type:r,heading:s,icon:c,unit:l,decimals:d,tooltip:h,entity:u,template:p,attribute:m,variables:g,config:f,separator:v=!0,display:y}=a,b=function({icon:t,state:e,attribute:i,hass:a,config:o,variables:n,localize:r}){return"string"==typeof t&&t.includes("{{")&&"object"==typeof e&&null!==e?gi({template:t,stateObj:e,attribute:i,hass:a,config:o,variables:n,localize:r}).trim():t}({icon:c,state:i,attribute:m,hass:e,config:f,variables:g,localize:o}),_=function({heading:t,state:e,attribute:i,hass:a,config:o,variables:n,localize:r}){if("string"==typeof t&&t.includes("{{")&&"object"==typeof e&&null!==e)return gi({template:t,stateObj:e,attribute:i,hass:a,config:o,variables:n,localize:r}).trim()}({heading:s,state:i,attribute:m,hass:e,config:f,variables:g,localize:o}),w=Ai(i),x=w?i.entity_id:u,$=x&&"function"==typeof n,S=h||(w?i?.attributes?.friendly_name||i?.entity_id:u?e.states?.[u]?.attributes?.friendly_name||u:void 0);let A,k="",E="",z=!1,C=!1;const T=ki(i,a,e,o);if(w){const[t]=i.entity_id.split(".");k=t,E=i.state,z=_e.includes(t);const a=function(t,e){return"string"==typeof t&&$i.includes(t)?"auto"!==t?t:_e.includes(e)?"toggle":we.includes(e)?"button":"chip":"row"}(y,t),o=[z&&"toggle-entity",k&&`domain-${Si(k)}`,E&&`state-${Si(E)}`,"row"!==a&&`display-${a}`,z&&ai(ii({icon:b||i.attributes?.icon,label:s||i.attributes?.friendly_name,entity:i,hass:e}))].filter(Boolean).join(" ");if("row"!==a){C=!0;const r=z||we.includes(t),c="on"===i.state,l=void 0!==_?xi(_,e):"string"==typeof s?s:i.attributes?.friendly_name||i.entity_id,d=b||i.attributes?.icon||(z?"mdi:toggle-switch":we.includes(t)?"mdi:gesture-tap-button":void 0);A=B`
`)}else A=B`
n(x):null} > ${T} -
`;if(C)return A;if(!1===s)return A;const R=s||S,O=["entity-heading",$&&"clickable",z&&"toggle-entity",k&&`domain-${Si(k)}`,E&&`state-${Si(E)}`,z&&ti(Qe({icon:b||i?.attributes?.icon,label:"string"==typeof s?s:i?.attributes?.friendly_name,entity:i,hass:e}))].filter(Boolean).join(" "),N=b?B` + `;if(C)return A;if(!1===s)return A;const R=s||S,O=["entity-heading",$&&"clickable",z&&"toggle-entity",k&&`domain-${Si(k)}`,E&&`state-${Si(E)}`,z&&ai(ii({icon:b||i?.attributes?.icon,label:"string"==typeof s?s:i?.attributes?.friendly_name,entity:i,hass:e}))].filter(Boolean).join(" "),N=b?B` n(x):null} > - `:"string"==typeof _?bi(_,e):` ${s}${!1===v?"":":"} `;return[B`
n(x):null} > ${N} -
`,A]}function zi({_hide:t,entity:e,unit:i,hass:a,entities:o,config:n,localize:r,openEntityPopover:s,adapter:c}){const l=n.current_value_entity,d=l?a.states[l]:e,h=l?d?.state:c.getCurrentValue(e.attributes),u=l?d?.attributes?.unit_of_measurement??i:c.getCurrentValueUnit?.(e.attributes,a.config)??i,p=n?.layout?.entities?.labels??!0,m=!1!==n?.layout?.entities?.separator,g=n?.state_labels?.[e.state]??xe(e,a,r),f=(!0===n?.hide_current_value_when_off||!0===n?.hide?.current_value_when_off||!0===n?.hide?.temperature_when_off)&&e.state===De.OFF,v=[Ei({hide:t.temperature||f||null==h,state:ai(Ke(h,{...n,locale:a.locale}),u),hass:a,openEntityPopover:s,details:{heading:!!p&&(n?.label?.temperature??r("ui.card.climate.currently")),tooltip:d?.attributes?.friendly_name??l,entity:l??n.entity,separator:m}}),Ei({hide:t.state,state:g,hass:a,openEntityPopover:s,details:{heading:!!p&&(n?.label?.state??r("ui.panel.lovelace.editor.card.generic.state")),entity:n.entity,separator:m}}),...(o??[]).map(({name:t,state:i,show:o,display:c,_hide_when_off:l,hide_when_off:d,...h})=>Ei({hide:!1===o||(!0===l||!0===d)&&e.state===De.OFF,state:i,hass:a,localize:r,openEntityPopover:s,details:{...h,heading:p&&t,tooltip:t,config:n,variables:n.variables,separator:m,display:c??n?.layout?.entities?.display}}))||null].filter(t=>null!==t);return function(t,e){const{type:i="table",labels:a=!0,alignment:o}=t?.layout?.entities??{},n=[a?"with-labels":"without-labels","list"===i?"as-list":"as-table","left"===o?"align-left":"",1===e.filter(t=>null!=t).length?"single-row":""];return B`
${e}
`}(n,v)}const Ci=new Set(["heat_cool","fan_only"]);function Ti(t,e,i){if(!e||!i)return{layout:"inline",lines:e?[e]:[]};const a=e.trim();if(!a)return{layout:"inline",lines:[]};if("heat_cool"===t){const t=a.split(/\s*\/\s*/).filter(Boolean);if(2===t.length&&t.every(t=>t.length>0&&t.length<=12))return{layout:"stacked",lines:t}}if("fan_only"===t){const t=a.split(/\s+/).filter(Boolean);if(2===t.length&&t.every(t=>t.length>0&&t.length<=10))return{layout:"stacked",lines:t}}return Ci.has(t)&&a.length>10?{layout:"column",lines:[a]}:{layout:"inline",lines:[a]}}const Ri={"st:fan-speed-4":{path:"M16 15V21H19V23H21V15H19V19H18V15H16Z"},"st:fan-speed-5":{path:"M16 15H21V17H18V18H19C20.11 18 21 18.89 21 20V21C21 22.11 20.11 23 19 23H16V21H19V20H16V15Z"}};function Oi(t){return t?B` `:null}function Ni({state:t,entity:e,hass:i,mode:a,adapter:o,modeOptions:n,localize:r,setMode:s}){const{type:c,hide_when_off:l,mode:d="none",list:h,name:u,heading:p,icons:m}=a;if(0===h.length||l&&t===De.OFF)return null;const g="hvac"===c?null:o.getModePayloadKey(c),f=a.entity?i?.states?.[a.entity]:void 0,v=!be(a.entity?f:e);let y=g?`state_attributes.${o.getLocalizationDomain()}.${g}.`:"";"hvac"===c?y="component.climate.state._.":"vane_horizontal"===c||"vane_vertical"===c?y="":"direction"!==c&&"oscillating"!==c&&"mode"!==c||(y="");const b=(t,a,o)=>{if(!1!==t&&!0===o||!1!==t&&void 0===o&&t!==a)return t;if(f&&"function"==typeof i?.formatEntityState)return i.formatEntityState({...f,state:a});if(("hvac"===c||"state"===c)&&"function"==typeof i?.formatEntityState)return i.formatEntityState({...e,state:a});if(g&&e&&"function"==typeof i?.formatEntityAttributeValue)return i.formatEntityAttributeValue(e,g,a);const n=y?r(a,y):a;return n&&n!==a?n:!1===t?a:t},_=(t,e)=>{for(const e of Array.isArray(t)?t:[t]){const t=r(e);if(t&&t!==e)return t}return e};let w;w="vane_horizontal"===c?"Vane Horizontal":"vane_vertical"===c?"Vane Vertical":"swing_horizontal"===c?_("ui.panel.lovelace.editor.features.types.climate-swing-horizontal-modes.swing_horizontal_modes","Swing Horizontal"):"swing_vertical"===c?"Swing Vertical":"direction"===c?_("ui.card.fan.direction","Direction"):"oscillating"===c?_("ui.card.fan.oscillate","Oscillating"):"mode"===c?_(`ui.card.${o.getLocalizationDomain()}.mode`,"Mode"):"preset"===c?!0===p&&_("fan"===o.getLocalizationDomain()?"ui.card.fan.preset_mode":"ui.card.climate.preset","Preset"):"state"===c?!0===p&&_(`ui.card.${o.getLocalizationDomain()}.state`,"State"):"fan"===c?_("ui.panel.lovelace.editor.features.types.climate-fan-modes.fan_modes","Mode"):"swing"===c?_("ui.panel.lovelace.editor.features.types.climate-swing-modes.swing_modes","Mode"):_(`ui.card.${o.getLocalizationDomain()}.mode`,"hvac"===c?"Operation":"Mode");const x=!1!==u&&(u||w),$="fan"===c||"preset"===c&&"fan"===o.getLocalizationDomain()?_("ui.panel.lovelace.editor.features.types.climate-fan-modes.fan_modes","Fan speed"):"swing"===c?_("ui.panel.lovelace.editor.features.types.climate-swing-modes.swing_modes","Swing mode"):"swing_horizontal"===c?_("ui.panel.lovelace.editor.features.types.climate-swing-horizontal-modes.swing_horizontal_modes","Horizontal swing"):"swing_vertical"===c?_("ui.card.climate.swing_vertical_mode","Vertical swing"):"vane_horizontal"===c?"Horizontal vane":"vane_vertical"===c?"Vertical vane":"string"==typeof w?w:"",S=x||$||c,A=(!0===n?.headings||!0===p)&&!1!==x,k="preset"===c&&"fan"===o.getLocalizationDomain(),E=("hvac"===c||"state"===c||"fan"===c)&&h.length<=4,z="preset"===c&&h.length<=4||["swing","swing_horizontal","swing_vertical","vane_horizontal","vane_vertical"].includes(c),C=h.length>4||"hvac"===c&&h.length>4||"fan"===c&&h.length>4;return B` + `,A]}function zi({_hide:t,entity:e,unit:i,hass:a,entities:o,config:n,localize:r,openEntityPopover:s,adapter:c}){const l=n.current_value_entity,d=l?a.states[l]:e,h=l?d?.state:c.getCurrentValue(e.attributes),u=l?d?.attributes?.unit_of_measurement??i:c.getCurrentValueUnit?.(e.attributes,a.config)??i,p=n?.layout?.entities?.labels??!0,m=!1!==n?.layout?.entities?.separator,g=n?.state_labels?.[e.state]??Ae(e,a,r),f=(!0===n?.hide_current_value_when_off||!0===n?.hide?.current_value_when_off||!0===n?.hide?.temperature_when_off)&&e.state===Be.OFF,v=[Ei({hide:t.temperature||f||null==h,state:ri(Ye(h,{...n,locale:a.locale}),u),hass:a,openEntityPopover:s,details:{heading:!!p&&(n?.label?.temperature??r("ui.card.climate.currently")),tooltip:d?.attributes?.friendly_name??l,entity:l??n.entity,separator:m}}),Ei({hide:t.state,state:g,hass:a,openEntityPopover:s,details:{heading:!!p&&(n?.label?.state??r("ui.panel.lovelace.editor.card.generic.state")),entity:n.entity,separator:m}}),...(o??[]).map(({name:t,state:i,show:o,display:c,_hide_when_off:l,hide_when_off:d,...h})=>Ei({hide:!1===o||(!0===l||!0===d)&&e.state===Be.OFF,state:i,hass:a,localize:r,openEntityPopover:s,details:{...h,heading:p&&t,tooltip:t,config:n,variables:n.variables,separator:m,display:c??n?.layout?.entities?.display}}))||null].filter(t=>null!==t);return function(t,e){const{type:i="table",labels:a=!0,alignment:o}=t?.layout?.entities??{},n=[a?"with-labels":"without-labels","list"===i?"as-list":"as-table","left"===o?"align-left":"",1===e.filter(t=>null!=t).length?"single-row":""];return B`
${e}
`}(n,v)}const Ci=new Set(["heat_cool","fan_only"]);function Ti(t,e,i){if(!e||!i)return{layout:"inline",lines:e?[e]:[]};const a=e.trim();if(!a)return{layout:"inline",lines:[]};if("heat_cool"===t){const t=a.split(/\s*\/\s*/).filter(Boolean);if(2===t.length&&t.every(t=>t.length>0&&t.length<=12))return{layout:"stacked",lines:t}}if("fan_only"===t){const t=a.split(/\s+/).filter(Boolean);if(2===t.length&&t.every(t=>t.length>0&&t.length<=10))return{layout:"stacked",lines:t}}return Ci.has(t)&&a.length>10?{layout:"column",lines:[a]}:{layout:"inline",lines:[a]}}const Ri={"st:fan-speed-4":{path:"M16 15V21H19V23H21V15H19V19H18V15H16Z"},"st:fan-speed-5":{path:"M16 15H21V17H18V18H19C20.11 18 21 18.89 21 20V21C21 22.11 20.11 23 19 23H16V21H19V20H16V15Z"}};function Oi(t){return t?B` `:null}function Ni({state:t,entity:e,hass:i,mode:a,adapter:o,modeOptions:n,localize:r,setMode:s}){const{type:c,hide_when_off:l,mode:d="none",list:h,name:u,heading:p,icons:m}=a;if(0===h.length||l&&t===Be.OFF)return null;const g="hvac"===c?null:o.getModePayloadKey(c),f=a.entity?i?.states?.[a.entity]:void 0,v=!be(a.entity?f:e);let y=g?`state_attributes.${o.getLocalizationDomain()}.${g}.`:"";"hvac"===c?y="component.climate.state._.":"vane_horizontal"===c||"vane_vertical"===c?y="":"direction"!==c&&"oscillating"!==c&&"mode"!==c||(y="");const b=(t,a,o)=>{if(!1!==t&&!0===o||!1!==t&&void 0===o&&t!==a)return t;if(f&&"function"==typeof i?.formatEntityState)return i.formatEntityState({...f,state:a});if(("hvac"===c||"state"===c)&&"function"==typeof i?.formatEntityState)return i.formatEntityState({...e,state:a});if(g&&e&&"function"==typeof i?.formatEntityAttributeValue)return i.formatEntityAttributeValue(e,g,a);const n=y?r(a,y):a;return n&&n!==a?n:!1===t?a:t},_=(t,e)=>{for(const e of Array.isArray(t)?t:[t]){const t=r(e);if(t&&t!==e)return t}return e};let w;w="vane_horizontal"===c?"Vane Horizontal":"vane_vertical"===c?"Vane Vertical":"swing_horizontal"===c?_("ui.panel.lovelace.editor.features.types.climate-swing-horizontal-modes.swing_horizontal_modes","Swing Horizontal"):"swing_vertical"===c?"Swing Vertical":"direction"===c?_("ui.card.fan.direction","Direction"):"oscillating"===c?_("ui.card.fan.oscillate","Oscillating"):"mode"===c?_(`ui.card.${o.getLocalizationDomain()}.mode`,"Mode"):"preset"===c?!0===p&&_("fan"===o.getLocalizationDomain()?"ui.card.fan.preset_mode":"ui.card.climate.preset","Preset"):"state"===c?!0===p&&_(`ui.card.${o.getLocalizationDomain()}.state`,"State"):"fan"===c?_("ui.panel.lovelace.editor.features.types.climate-fan-modes.fan_modes","Mode"):"swing"===c?_("ui.panel.lovelace.editor.features.types.climate-swing-modes.swing_modes","Mode"):_(`ui.card.${o.getLocalizationDomain()}.mode`,"hvac"===c?"Operation":"Mode");const x=!1!==u&&(u||w),$="fan"===c||"preset"===c&&"fan"===o.getLocalizationDomain()?_("ui.panel.lovelace.editor.features.types.climate-fan-modes.fan_modes","Fan speed"):"swing"===c?_("ui.panel.lovelace.editor.features.types.climate-swing-modes.swing_modes","Swing mode"):"swing_horizontal"===c?_("ui.panel.lovelace.editor.features.types.climate-swing-horizontal-modes.swing_horizontal_modes","Horizontal swing"):"swing_vertical"===c?_("ui.card.climate.swing_vertical_mode","Vertical swing"):"vane_horizontal"===c?"Horizontal vane":"vane_vertical"===c?"Vertical vane":"string"==typeof w?w:"",S=x||$||c,A=(!0===n?.headings||!0===p)&&!1!==x,k="preset"===c&&"fan"===o.getLocalizationDomain(),E=("hvac"===c||"state"===c||"fan"===c)&&h.length<=4,z="preset"===c&&h.length<=4||["swing","swing_horizontal","swing_vertical","vane_horizontal","vane_vertical"].includes(c),C=h.length>4||"hvac"===c&&h.length>4||"fan"===c&&h.length>4;return B`
${A?B`
${x}
`:""} - ${h.map(({value:e,icon:i,iconConfigured:a,name:o,nameConfigured:r,hide_when_off:l})=>{if(!0===l&&t===De.OFF)return q;const h=(t=>String(t).replace(/[^a-z0-9_-]/gi,""))(e),u=((t,e,i)=>!1===t||!1===n?.names?null:b(t,e,i))(o,e,r),p=b(o,e,r),g=Ti(String(e),u,E),f="stacked"===g.layout?"label-stacked":"column"===g.layout?"label-column":"",y=u?q:$||q;return B` + ${h.map(({value:e,icon:i,iconConfigured:a,name:o,nameConfigured:r,hide_when_off:l})=>{if(!0===l&&t===Be.OFF)return q;const h=(t=>String(t).replace(/[^a-z0-9_-]/gi,""))(e),u=((t,e,i)=>!1===t||!1===n?.names?null:b(t,e,i))(o,e,r),p=b(o,e,r),g=Ti(String(e),u,E),f="stacked"===g.layout?"label-stacked":"column"===g.layout?"label-column":"",y=u?q:$||q;return B`
`})}
- `}window.customIconsets=window.customIconsets||{},window.customIconsets.st||(window.customIconsets.st=async t=>{const e=Ri[`st:${t}`];return e?{path:`M13 19C13 17.59 13.5 16.3 14.3 15.28C14.17 14.97 14.03 14.65 13.86 14.34C14.26 14 14.57 13.59 14.77 13.11C15.26 13.21 15.78 13.39 16.25 13.67C17.07 13.25 18 13 19 13C20.05 13 21.03 13.27 21.89 13.74C21.95 13.37 22 12.96 22 12.5C22 8.92 18.03 8.13 14.33 10.13C14 9.73 13.59 9.42 13.11 9.22C13.3 8.29 13.74 7.24 14.73 6.75C17.09 5.57 17 2 12.5 2C8.93 2 8.14 5.96 10.13 9.65C9.72 9.97 9.4 10.39 9.21 10.87C8.28 10.68 7.23 10.25 6.73 9.26C5.56 6.89 2 7 2 11.5C2 15.07 5.95 15.85 9.64 13.87C9.96 14.27 10.39 14.59 10.88 14.79C10.68 15.71 10.24 16.75 9.26 17.24C6.9 18.42 7 22 11.5 22C12.31 22 13 21.78 13.5 21.41C13.19 20.67 13 19.86 13 19M12 13C11.43 13 11 12.55 11 12S11.43 11 12 11C12.54 11 13 11.45 13 12S12.54 13 12 13${e.path}`}:{path:""}});const Mi=t=>String(t).replace(/[^a-z0-9_-]/gi,"");function Pi({toggles:t,mainState:e,toggleFooterEntity:i,openEntityPopover:a}){const o=t.filter(t=>!(!0===t.hide_when_off&&e===De.OFF));return o.length?B` + `}window.customIconsets=window.customIconsets||{},window.customIconsets.st||(window.customIconsets.st=async t=>{const e=Ri[`st:${t}`];return e?{path:`M13 19C13 17.59 13.5 16.3 14.3 15.28C14.17 14.97 14.03 14.65 13.86 14.34C14.26 14 14.57 13.59 14.77 13.11C15.26 13.21 15.78 13.39 16.25 13.67C17.07 13.25 18 13 19 13C20.05 13 21.03 13.27 21.89 13.74C21.95 13.37 22 12.96 22 12.5C22 8.92 18.03 8.13 14.33 10.13C14 9.73 13.59 9.42 13.11 9.22C13.3 8.29 13.74 7.24 14.73 6.75C17.09 5.57 17 2 12.5 2C8.93 2 8.14 5.96 10.13 9.65C9.72 9.97 9.4 10.39 9.21 10.87C8.28 10.68 7.23 10.25 6.73 9.26C5.56 6.89 2 7 2 11.5C2 15.07 5.95 15.85 9.64 13.87C9.96 14.27 10.39 14.59 10.88 14.79C10.68 15.71 10.24 16.75 9.26 17.24C6.9 18.42 7 22 11.5 22C12.31 22 13 21.78 13.5 21.41C13.19 20.67 13 19.86 13 19M12 13C11.43 13 11 12.55 11 12S11.43 11 12 11C12.54 11 13 11.45 13 12S12.54 13 12 13${e.path}`}:{path:""}});const Mi=t=>String(t).replace(/[^a-z0-9_-]/gi,"");function Pi({toggles:t,mainState:e,toggleFooterEntity:i,openEntityPopover:a}){const o=t.filter(t=>!(!0===t.hide_when_off&&e===Be.OFF));return o.length?B` - `:q}const ji={target_temp_low:{field:"target_temp_high",caps:"max"},target_temp_high:{field:"target_temp_low",caps:"min"}},Fi=Object.values(yt),Ii="hass:chevron-up",Li="hass:chevron-down",Hi="mdi:plus",Vi="mdi:minus",Di={temperature:!1,state:!1},Ui=[yt.PRESET,yt.FAN,yt.HVAC,yt.SWING,yt.SWING_HORIZONTAL,yt.SWING_VERTICAL,yt.VANE_HORIZONTAL,yt.VANE_VERTICAL,yt.DIRECTION,yt.OSCILLATING,yt.STATE],Wi=["entity","hide_when_off","hide_off_when_off"];function Bi(t,e=1){if(null===t||""===t||"boolean"==typeof t)return e;const i=Number(t);return Number.isInteger(i)&&i>=0&&i<=100?i:e}function Gi(t,e,i){const a=Ki(String(e),i);if(Zi(a))return!1!==a.include;const o=Object.keys(i).some(t=>!t.startsWith("_")&&!Wi.includes(t)),n=t===yt.PRESET;return a??!(n&&o)}function qi(t){return t.toLowerCase().replace(/\s+/g,"_")}function Ki(t,e){const i=qi(t),a=e[t];if(void 0!==a)return a;if(void 0!==e[i])return e[i];const o=Object.entries(e).find(([t])=>!t.startsWith("_")&&!Wi.includes(t)&&qi(t)===i);return o?.[1]}function Zi(t){return"object"==typeof t&&null!==t&&!Array.isArray(t)}function Ji(t,e){const i=Array.isArray(e._order)?e._order.map(String):Object.keys(e).filter(t=>!t.startsWith("_")&&!Wi.includes(t));if(0===i.length)return t;const a=new Map;t.forEach(t=>{a.set(qi(String(t)),t)});const o=new Set,n=[];return i.forEach(t=>{const e=qi(t);a.has(e)&&!o.has(e)&&(n.push(a.get(e)),o.add(e))}),t.forEach(t=>{const e=qi(String(t));o.has(e)||(n.push(t),o.add(e))}),n}function Yi(t,e,i,a={}){let o=e[i.getModeAttribute(t)];return t===yt.STATE?o=["off","on"]:t===yt.DIRECTION&&e.direction?o=["forward","reverse"]:t===yt.OSCILLATING&&"boolean"==typeof e.oscillating&&(o=[!1,!0]),Array.isArray(o)?Ji(o,a).filter(e=>Gi(t,e,a)).map(e=>{const i=String(e),n=Ki(i,a),r=Zi(n)?n:{},{name:s,...c}=r,l=!0===r.hide_when_off||!0===a.hide_off_when_off&&"off"===qi(i),d=!1!==s&&("string"==typeof s?s:Ce(i));return{...c,hide_when_off:l||void 0,icon:r.icon??(t===yt.FAN?qe(i,o):void 0)??ze(i),iconConfigured:void 0!==r.icon,nameConfigured:void 0!==s,value:i,name:d}}):[]}function Xi(t){return"string"==typeof t?.entity_id&&t.entity_id.startsWith("select.")&&Array.isArray(t.attributes?.options)}function Qi(t,e={}){return Ji(t.attributes.options,e).filter(t=>Gi("select",t,e)).map(t=>{const i=String(t),a=Ki(i,e),o=Zi(a)?a:{},{name:n,...r}=o,s=!0===o.hide_when_off||!0===e.hide_off_when_off&&"off"===qi(i),c=!1!==n&&("string"==typeof n?n:Ce(i));return{...r,hide_when_off:s||void 0,icon:o.icon??ze(i),iconConfigured:void 0!==o.icon,nameConfigured:void 0!==n,value:i,name:c}})}function ta(t,e,i,a){return Fi.includes(t)&&(t===yt.STATE?"fan"===e||"humidifier"===e:void 0!==i[a.getModeAttribute(t)])}function ea(t,e,i,a){return t.filter(t=>ta(t,e,i,a)).map(t=>({type:t,hide_when_off:!1,list:Yi(t,i,a)}))}class ia extends lt{constructor(){super(...arguments),this.modes=[],this._hass={},this.entities=[],this.footer=[],this.showEntities=!0,this.name="",this.stepSize=.5,this._values={},this._updatingValues=!1,this._hide=Di,this._updatingValuesTimeout=null,this._holdTimer=null,this._holdFired=!1,this._clickCount=0,this._clickTimer=null,this._setpointUpdateTimer=null,this._pendingSetpointUpdate=null,this._missingEntityTimer=null,this._stepRepeatDelayTimer=null,this._stepRepeatIntervalTimer=null,this._stepRepeatFired=!1,this._setpointDebounce=500,this.localize=(t,e="")=>{const i=`${e}${t}`;return this._hass.localize?.(i)||t},this.toggleEntityChanged=(t,e)=>{if(!this.header||!e)return;if(!be(this._hass?.states?.[e]))return;const i=t.target;this._callAction("homeassistant.turn_"+(i.checked?"on":"off"),{entity_id:e})},this.toggleFooterEntity=(t,e)=>{be(this._hass?.states?.[t])&&(this._callAction("homeassistant.turn_"+(e?"on":"off"),{entity_id:t}),_t(this,"haptic","light"))},this._stopSetpointRepeat=()=>{this._stepRepeatDelayTimer&&(clearTimeout(this._stepRepeatDelayTimer),this._stepRepeatDelayTimer=null),this._stepRepeatIntervalTimer&&(clearInterval(this._stepRepeatIntervalTimer),this._stepRepeatIntervalTimer=null)},this.setMode=(t,e)=>{if(t&&e){const i=kt(this.config.entity),a=this.modes.find(e=>e.type===t);if(a?.entity){const t=this._hass.states?.[a.entity];if(!Xi(t)||["unknown","unavailable"].includes(String(t.state))||!t.attributes.options.includes(e))return;return this._callAction("select.select_option",{entity_id:a.entity,option:e}),void _t(this,"haptic","light")}if(!be(this._hass?.states?.[this.config.entity]))return;if(t===yt.STATE)return this._callAction(`${i.getLocalizationDomain()}.turn_${e}`,{entity_id:this.config.entity}),void _t(this,"haptic","light");const o=i.transformModePayloadValue?.(t,e)??e;this._callAction(`${i.getLocalizationDomain()}.${i.getModeService(t)}`,{entity_id:this.config.entity,[i.getModePayloadKey(t)]:o}),_t(this,"haptic","light")}else _t(this,"haptic","failure")},this.openEntityPopover=(t=null)=>{_t(this,"hass-more-info",{entityId:t||this.config.entity})},this._onActionPointerDown=t=>{0!==t.button&&"mouse"===t.pointerType||(this._holdFired=!1,this._holdTimer&&clearTimeout(this._holdTimer),this._holdTimer=setTimeout(()=>{this._holdFired=!0,this._holdTimer=null,this._dispatchAction("hold")},ia.HOLD_MS))},this._onActionPointerUp=()=>{this._holdTimer&&(clearTimeout(this._holdTimer),this._holdTimer=null)},this._onActionClick=t=>{t.preventDefault(),this._holdFired?this._holdFired=!1:(this._clickCount+=1,1===this._clickCount?(this._clickTimer&&clearTimeout(this._clickTimer),this._clickTimer=setTimeout(()=>{this._clickCount=0,this._clickTimer=null,this._dispatchSetpointTap()},ia.DOUBLE_TAP_MS)):(this._clickTimer&&clearTimeout(this._clickTimer),this._clickTimer=null,this._clickCount=0,this._dispatchAction("double_tap")))},this._onSetpointKeyDown=t=>{"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),this._dispatchSetpointTap())}}static get styles(){return bt}_sendSetpointValues(t){if(!be(this._hass?.states?.[t.entity]))return;const{domain:e,service:i,data:a={}}=t.service;this._callAction(`${e}.${i}`,{entity_id:t.entity,...a,...t.values})}_flushPendingSetpointValues(){this._setpointUpdateTimer&&(clearTimeout(this._setpointUpdateTimer),this._setpointUpdateTimer=null);const t=this._pendingSetpointUpdate;this._pendingSetpointUpdate=null,t&&this._sendSetpointValues(t)}_cancelPendingSetpointValues(){this._setpointUpdateTimer&&(clearTimeout(this._setpointUpdateTimer),this._setpointUpdateTimer=null),this._pendingSetpointUpdate=null}_scheduleSetpointValues(t){const e=this._setpointDebounce,i=function(t){return Object.fromEntries(Object.entries(t).filter(([,t])=>null!=t))}(t);0!==Object.keys(i).length&&(e<=0?this._sendSetpointValues({entity:this.config.entity,service:this.service,values:i}):(this._pendingSetpointUpdate={entity:this.config.entity,service:this.service,values:i},this._setpointUpdateTimer&&clearTimeout(this._setpointUpdateTimer),this._setpointUpdateTimer=setTimeout(()=>{const t=this._pendingSetpointUpdate;this._setpointUpdateTimer=null,this._pendingSetpointUpdate=null,t&&this._sendSetpointValues(t)},e)))}_getSetpointDebounce(t){const e=Number(t?.setpoint_debounce_ms??500);return Number.isFinite(e)&&e>=0?e:500}_callAction(t,e){let i;if("function"==typeof this._hass.performAction)i=this._hass.performAction({action:t,data:e});else if("function"==typeof this._hass.callService){const[a,o]=t.split(".");i=this._hass.callService(a,o,e)}i&&"function"==typeof i.catch&&i.catch(e=>{console.error(`simple-thermostat: ${t} failed`,e)})}static getConfigElement(){return window.document.createElement(`${t}-editor`)}static getStubConfig(t){return{entity:Object.keys(t.states??{}).find(t=>t.startsWith("climate.")||t.startsWith("fan.")||t.startsWith("humidifier."))??""}}setConfig(t){if(!t?.entity||"string"!=typeof t.entity)throw new Error("Simple Thermostat requires an entity");this._flushPendingSetpointValues();const e=this.config?.entity;this._clearMissingEntityTimer(),this.config=xt({decimals:1,...t}),this.config.decimals=Bi(this.config.decimals);const i=this._getSetpointDebounce(this.config);i!==this._setpointDebounce&&(this._setpointDebounce=i),this.entities=[],this.footer=[],this.showEntities=!0,e&&e!==this.config.entity&&this._clearOptimisticSetpointState(),this.toggleAttribute("embedded",!0===this.config.embedded),this._hass?.states?.[this.config.entity]?this.updateFromHass(this._hass):this._hass?.states&&(this.entity=void 0)}_clearMissingEntityTimer(){this._missingEntityTimer&&(clearTimeout(this._missingEntityTimer),this._missingEntityTimer=null)}_scheduleMissingEntity(){this._missingEntityTimer||(this._missingEntityTimer=setTimeout(()=>{this._missingEntityTimer=null,this.entity=void 0},5e3))}set hass(t){if(t?.states&&(this._hass=t),!this.config?.entity)return;if(!t?.states)return;t.states[this.config.entity]?(this._clearMissingEntityTimer(),this.updateFromHass(t)):this._scheduleMissingEntity()}disconnectedCallback(){this._clearOptimisticSetpointState(),this._holdTimer&&(clearTimeout(this._holdTimer),this._holdTimer=null),this._clickTimer&&(clearTimeout(this._clickTimer),this._clickTimer=null),this._clearMissingEntityTimer(),this._stopSetpointRepeat(),this._flushPendingSetpointValues(),super.disconnectedCallback()}connectedCallback(){super.connectedCallback(),this.config?.entity&&this._hass?.states?.[this.config.entity]&&this.updateFromHass(this._hass)}updateFromHass(t){const e=t.states[this.config.entity];this.entity!==e&&(this.entity=e);const i=kt(this.config.entity);this.header=Te(this.config.header,e,t,!1!==this.config.enhanced_visuals),this.service=function(t,e=St){return t||e.getSetpointService()}(this.config?.service??!1,i);const a=e.attributes;let o=function(t,e,i=St,a){return!1===t?{}:t?Object.entries(t).reduce((t,[i,o])=>{if(o?.hide)return t;const n=Array.isArray(o?.hide_when)?o.hide_when:o?.hide_when?[o.hide_when]:[];return a&&n.includes(a)||(t[i]=e?.[i]),t},{}):i.getSetpoints(e)}(this.config?.setpoints??null,a,i,e.state);this._updatingValues&&!function(t,e){const i=Object.keys(t).sort(),a=Object.keys(e).sort();return i.length===a.length&&i.every((t,e)=>t===a[e])}(o,this._values)?(this._cancelPendingSetpointValues(),this._clearOptimisticSetpointState(),this._values=o):this._updatingValues&&function(t,e){const i=Object.keys(t);return i.length===Object.keys(e).length&&!i.some(i=>t?.[i]!==e?.[i])}(o,this._values)?(this._updatingValues=!1,this._updatingValuesTimeout&&(clearTimeout(this._updatingValuesTimeout),this._updatingValuesTimeout=null)):this._updatingValues||(this._values=o);const n=this.config.entity.split(".")[0],r=function(t){return t.some(({type:t})=>t===yt.STATE)?t.map(t=>t.type&&t.type!==yt.STATE?{...t,list:t.list?.filter(({value:t})=>"off"!==t)??[]}:t):t}(function(t,e,i,a,o){if(!1===t.control)return[];if(Array.isArray(t.control))return ea(t.control,e,i,a);if(t.control&&"object"==typeof t.control){const n=t.control,r=Object.entries(t.control).filter(([t])=>!t.startsWith("_")),s=Array.isArray(n._order)?n._order.map(String):void 0,c=(s?[...s.filter(t=>r.some(([e])=>e===t)),...r.map(([t])=>t).filter(t=>!s.includes(t))]:r.map(([t])=>t)).map(t=>[t,n[t]]);if(c.length>0)return c.filter(([,t])=>!1!==t).filter(([t,o])=>!!(!0===o||!1===o?void 0:o.entity)||ta(t,e,i,a)).map(([t,e])=>{const{_name:n,_hide_when_off:r,hide_when_off:s,hide_off_when_off:c,_icons:l,_heading:d,entity:h,...u}=!0===e?{}:e,p=h?o?.states?.[h]:void 0,m=Xi(p),g={...u,...!0===c?{hide_off_when_off:c}:{}};return{type:t,entity:h,hide_when_off:s??r,icons:l,heading:d,name:n,preserve_option_order:Object.keys(u).length>0,list:h?m&&!["unknown","unavailable"].includes(String(p.state))?Qi(p,g):[]:Yi(t,i,a,g)}})}return ea(a.getDefaultControl(),e,i,a)}(this.config,n,a,i,t)),s=(c=this.config.control,Array.isArray(c)||c&&"object"==typeof c&&(Array.isArray(c._order)||Object.keys(c).some(t=>!t.startsWith("_")))?r:function(t,e){if("fan"!==e&&"climate"!==e)return t;const i=t=>{const e=Ui.indexOf(t);return-1===e?Ui.length:e};return[...t].sort((t,e)=>i(t.type)-i(e.type))}(r,n));var c;this.modes=s.map(o=>{const n=o.preserve_option_order?o.list:o.type===yt.HVAC?function(t){const e=Object.values(De),i=[],a=[];return t.forEach(t=>{const o=e.indexOf(t.value);o>=0?i[o]=t:a.push(t)}),[...i.filter(Boolean),...a]}(o.list):o.type===yt.FAN?function(t){const e=[],i=[];return t.forEach(t=>{const a=Ue.indexOf(t.value.toLowerCase());a>=0?e[a]=t:i.push(t)}),[...e.filter(Boolean),...i]}(o.list):o.list,r=o.entity&&t.states?.[o.entity]?t.states[o.entity].state:o.type===yt.HVAC||o.type===yt.STATE?e.state:a[i.getModePayloadKey(o.type)];return{...o,list:n,mode:r}});const{step:l}=i.getRange(a);this.stepSize=Number(this.config.step_size??l??.5),this._hide={...Di,...this.config.hide??{}};const d=this.config.entities??[];!1===d?(this.showEntities=!1,this.entities=[]):d?(this.showEntities=!0,this.entities=d.map(({name:e,entity:i,attribute:a,template:o,unit:n="",decimals:r,...s})=>{let c;const l=[e];return i?(c=t.states[i],l.push(c?.attributes?.friendly_name)):a&&a in(this.entity.attributes??{})&&(c=this.entity,l.push(a)),l.push(i),{...s,name:l.find(t=>!!t),state:c,entity:i,attribute:a,template:o,unit:n,...void 0!==r?{decimals:Bi(r,this.config.decimals??1)}:{}}})):(this.showEntities=!0,this.entities=[]),this.footer=function(t){return Array.isArray(t.footer)?t.footer:[]}(this.config).map(({entity:e,name:i,icon:a,hide_when_off:o})=>{const n=t.states?.[e];return n?{entity:e,name:i,icon:a,hide_when_off:o,state:n}:null}).filter(t=>!!t)}_localizeFirst(t,e){for(const e of t){const t=this._hass.localize?.(e);if(t&&t!==e)return t}return e}_getSetpointLabel(t){return this.config.label?.setpoint??this._hass.localize?.(`ui.card.${kt(this.config.entity).getLocalizationDomain()}.target`)??this._hass.localize?.("ui.card.climate.target_temperature")??this.localize(t,"state_attributes.climate.")}render({_hide:t,_values:e,_updatingValues:i,config:a,entity:o}=this){if(!a)return B``;const n=[];if(this.modes.filter(t=>t.entity&&0===t.list.length).forEach(t=>{n.push(B`=0&&i<=100?i:e}function Gi(t,e,i){const a=Ki(String(e),i);if(Zi(a))return!1!==a.include;const o=Object.keys(i).some(t=>!t.startsWith("_")&&!Wi.includes(t)),n=t===yt.PRESET;return a??!(n&&o)}function qi(t){return t.toLowerCase().replace(/\s+/g,"_")}function Ki(t,e){const i=qi(t),a=e[t];if(void 0!==a)return a;if(void 0!==e[i])return e[i];const o=Object.entries(e).find(([t])=>!t.startsWith("_")&&!Wi.includes(t)&&qi(t)===i);return o?.[1]}function Zi(t){return"object"==typeof t&&null!==t&&!Array.isArray(t)}function Ji(t,e){const i=Array.isArray(e._order)?e._order.map(String):Object.keys(e).filter(t=>!t.startsWith("_")&&!Wi.includes(t));if(0===i.length)return t;const a=new Map;t.forEach(t=>{a.set(qi(String(t)),t)});const o=new Set,n=[];return i.forEach(t=>{const e=qi(t);a.has(e)&&!o.has(e)&&(n.push(a.get(e)),o.add(e))}),t.forEach(t=>{const e=qi(String(t));o.has(e)||(n.push(t),o.add(e))}),n}function Yi(t,e,i,a={}){let o=e[i.getModeAttribute(t)];return t===yt.STATE?o=["off","on"]:t===yt.DIRECTION&&e.direction?o=["forward","reverse"]:t===yt.OSCILLATING&&"boolean"==typeof e.oscillating&&(o=[!1,!0]),Array.isArray(o)?Ji(o,a).filter(e=>Gi(t,e,a)).map(e=>{const i=String(e),n=Ki(i,a),r=Zi(n)?n:{},{name:s,...c}=r,l=!0===r.hide_when_off||!0===a.hide_off_when_off&&"off"===qi(i),d=!1!==s&&("string"==typeof s?s:Oe(i));return{...c,hide_when_off:l||void 0,icon:r.icon??(t===yt.FAN?Je(i,o):void 0)??Re(i),iconConfigured:void 0!==r.icon,nameConfigured:void 0!==s,value:i,name:d}}):[]}function Xi(t){return"string"==typeof t?.entity_id&&t.entity_id.startsWith("select.")&&Array.isArray(t.attributes?.options)}function Qi(t,e={}){return Ji(t.attributes.options,e).filter(t=>Gi("select",t,e)).map(t=>{const i=String(t),a=Ki(i,e),o=Zi(a)?a:{},{name:n,...r}=o,s=!0===o.hide_when_off||!0===e.hide_off_when_off&&"off"===qi(i),c=!1!==n&&("string"==typeof n?n:Oe(i));return{...r,hide_when_off:s||void 0,icon:o.icon??Re(i),iconConfigured:void 0!==o.icon,nameConfigured:void 0!==n,value:i,name:c}})}function ta(t,e,i,a){return Fi.includes(t)&&(t===yt.STATE?"fan"===e||"humidifier"===e:void 0!==i[a.getModeAttribute(t)])}function ea(t,e,i,a){return t.filter(t=>ta(t,e,i,a)).map(t=>({type:t,hide_when_off:!1,list:Yi(t,i,a)}))}class ia extends lt{constructor(){super(...arguments),this.modes=[],this._hass={},this.entities=[],this.footer=[],this.showEntities=!0,this.name="",this.stepSize=.5,this._values={},this._updatingValues=!1,this._hide=Di,this._updatingValuesTimeout=null,this._holdTimer=null,this._holdFired=!1,this._clickCount=0,this._clickTimer=null,this._setpointUpdateTimer=null,this._pendingSetpointUpdate=null,this._missingEntityTimer=null,this._stepRepeatDelayTimer=null,this._stepRepeatIntervalTimer=null,this._stepRepeatFired=!1,this._setpointDebounce=500,this.localize=(t,e="")=>{const i=`${e}${t}`;return this._hass.localize?.(i)||t},this.toggleEntityChanged=(t,e)=>{if(!this.header||!e)return;if(!be(this._hass?.states?.[e]))return;const i=t.target;this._callAction("homeassistant.turn_"+(i.checked?"on":"off"),{entity_id:e})},this.toggleFooterEntity=(t,e)=>{this._hass&&(xe(this._hass,t,e),_t(this,"haptic","light"))},this._stopSetpointRepeat=()=>{this._stepRepeatDelayTimer&&(clearTimeout(this._stepRepeatDelayTimer),this._stepRepeatDelayTimer=null),this._stepRepeatIntervalTimer&&(clearInterval(this._stepRepeatIntervalTimer),this._stepRepeatIntervalTimer=null)},this.setMode=(t,e)=>{if(t&&e){const i=kt(this.config.entity),a=this.modes.find(e=>e.type===t);if(a?.entity){const t=this._hass.states?.[a.entity];if(!Xi(t)||["unknown","unavailable"].includes(String(t.state))||!t.attributes.options.includes(e))return;return this._callAction("select.select_option",{entity_id:a.entity,option:e}),void _t(this,"haptic","light")}if(!be(this._hass?.states?.[this.config.entity]))return;if(t===yt.STATE)return this._callAction(`${i.getLocalizationDomain()}.turn_${e}`,{entity_id:this.config.entity}),void _t(this,"haptic","light");const o=i.transformModePayloadValue?.(t,e)??e;this._callAction(`${i.getLocalizationDomain()}.${i.getModeService(t)}`,{entity_id:this.config.entity,[i.getModePayloadKey(t)]:o}),_t(this,"haptic","light")}else _t(this,"haptic","failure")},this.openEntityPopover=(t=null)=>{_t(this,"hass-more-info",{entityId:t||this.config.entity})},this._onActionPointerDown=t=>{0!==t.button&&"mouse"===t.pointerType||(this._holdFired=!1,this._holdTimer&&clearTimeout(this._holdTimer),this._holdTimer=setTimeout(()=>{this._holdFired=!0,this._holdTimer=null,this._dispatchAction("hold")},ia.HOLD_MS))},this._onActionPointerUp=()=>{this._holdTimer&&(clearTimeout(this._holdTimer),this._holdTimer=null)},this._onActionClick=t=>{t.preventDefault(),this._holdFired?this._holdFired=!1:(this._clickCount+=1,1===this._clickCount?(this._clickTimer&&clearTimeout(this._clickTimer),this._clickTimer=setTimeout(()=>{this._clickCount=0,this._clickTimer=null,this._dispatchSetpointTap()},ia.DOUBLE_TAP_MS)):(this._clickTimer&&clearTimeout(this._clickTimer),this._clickTimer=null,this._clickCount=0,this._dispatchAction("double_tap")))},this._onSetpointKeyDown=t=>{"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),this._dispatchSetpointTap())}}static get styles(){return bt}_sendSetpointValues(t){if(!be(this._hass?.states?.[t.entity]))return;const{domain:e,service:i,data:a={}}=t.service;this._callAction(`${e}.${i}`,{entity_id:t.entity,...a,...t.values})}_flushPendingSetpointValues(){this._setpointUpdateTimer&&(clearTimeout(this._setpointUpdateTimer),this._setpointUpdateTimer=null);const t=this._pendingSetpointUpdate;this._pendingSetpointUpdate=null,t&&this._sendSetpointValues(t)}_cancelPendingSetpointValues(){this._setpointUpdateTimer&&(clearTimeout(this._setpointUpdateTimer),this._setpointUpdateTimer=null),this._pendingSetpointUpdate=null}_scheduleSetpointValues(t){const e=this._setpointDebounce,i=function(t){return Object.fromEntries(Object.entries(t).filter(([,t])=>null!=t))}(t);0!==Object.keys(i).length&&(e<=0?this._sendSetpointValues({entity:this.config.entity,service:this.service,values:i}):(this._pendingSetpointUpdate={entity:this.config.entity,service:this.service,values:i},this._setpointUpdateTimer&&clearTimeout(this._setpointUpdateTimer),this._setpointUpdateTimer=setTimeout(()=>{const t=this._pendingSetpointUpdate;this._setpointUpdateTimer=null,this._pendingSetpointUpdate=null,t&&this._sendSetpointValues(t)},e)))}_getSetpointDebounce(t){const e=Number(t?.setpoint_debounce_ms??500);return Number.isFinite(e)&&e>=0?e:500}_callAction(t,e){let i;if("function"==typeof this._hass.performAction)i=this._hass.performAction({action:t,data:e});else if("function"==typeof this._hass.callService){const[a,o]=t.split(".");i=this._hass.callService(a,o,e)}i&&"function"==typeof i.catch&&i.catch(e=>{console.error(`simple-thermostat: ${t} failed`,e)})}static getConfigElement(){return window.document.createElement(`${t}-editor`)}static getStubConfig(t){return{entity:Object.keys(t.states??{}).find(t=>t.startsWith("climate.")||t.startsWith("fan.")||t.startsWith("humidifier."))??""}}setConfig(t){if(!t?.entity||"string"!=typeof t.entity)throw new Error("Simple Thermostat requires an entity");this._flushPendingSetpointValues();const e=this.config?.entity;this._clearMissingEntityTimer(),this.config=xt({decimals:1,...t}),this.config.decimals=Bi(this.config.decimals);const i=this._getSetpointDebounce(this.config);i!==this._setpointDebounce&&(this._setpointDebounce=i),this.entities=[],this.footer=[],this.showEntities=!0,e&&e!==this.config.entity&&this._clearOptimisticSetpointState(),this.toggleAttribute("embedded",!0===this.config.embedded),this._hass?.states?.[this.config.entity]?this.updateFromHass(this._hass):this._hass?.states&&(this.entity=void 0)}_clearMissingEntityTimer(){this._missingEntityTimer&&(clearTimeout(this._missingEntityTimer),this._missingEntityTimer=null)}_scheduleMissingEntity(){this._missingEntityTimer||(this._missingEntityTimer=setTimeout(()=>{this._missingEntityTimer=null,this.entity=void 0},5e3))}set hass(t){if(t?.states&&(this._hass=t),!this.config?.entity)return;if(!t?.states)return;t.states[this.config.entity]?(this._clearMissingEntityTimer(),this.updateFromHass(t)):this._scheduleMissingEntity()}disconnectedCallback(){this._clearOptimisticSetpointState(),this._holdTimer&&(clearTimeout(this._holdTimer),this._holdTimer=null),this._clickTimer&&(clearTimeout(this._clickTimer),this._clickTimer=null),this._clearMissingEntityTimer(),this._stopSetpointRepeat(),this._flushPendingSetpointValues(),super.disconnectedCallback()}connectedCallback(){super.connectedCallback(),this.config?.entity&&this._hass?.states?.[this.config.entity]&&this.updateFromHass(this._hass)}updateFromHass(t){const e=t.states[this.config.entity];this.entity!==e&&(this.entity=e);const i=kt(this.config.entity);this.header=Ne(this.config.header,e,t,!1!==this.config.enhanced_visuals),this.service=function(t,e=St){return t||e.getSetpointService()}(this.config?.service??!1,i);const a=e.attributes;let o=function(t,e,i=St,a){return!1===t?{}:t?Object.entries(t).reduce((t,[i,o])=>{if(o?.hide)return t;const n=Array.isArray(o?.hide_when)?o.hide_when:o?.hide_when?[o.hide_when]:[];return a&&n.includes(a)||(t[i]=e?.[i]),t},{}):i.getSetpoints(e)}(this.config?.setpoints??null,a,i,e.state);this._updatingValues&&!function(t,e){const i=Object.keys(t).sort(),a=Object.keys(e).sort();return i.length===a.length&&i.every((t,e)=>t===a[e])}(o,this._values)?(this._cancelPendingSetpointValues(),this._clearOptimisticSetpointState(),this._values=o):this._updatingValues&&function(t,e){const i=Object.keys(t);return i.length===Object.keys(e).length&&!i.some(i=>t?.[i]!==e?.[i])}(o,this._values)?(this._updatingValues=!1,this._updatingValuesTimeout&&(clearTimeout(this._updatingValuesTimeout),this._updatingValuesTimeout=null)):this._updatingValues||(this._values=o);const n=this.config.entity.split(".")[0],r=function(t){return t.some(({type:t})=>t===yt.STATE)?t.map(t=>t.type&&t.type!==yt.STATE?{...t,list:t.list?.filter(({value:t})=>"off"!==t)??[]}:t):t}(function(t,e,i,a,o){if(!1===t.control)return[];if(Array.isArray(t.control))return ea(t.control,e,i,a);if(t.control&&"object"==typeof t.control){const n=t.control,r=Object.entries(t.control).filter(([t])=>!t.startsWith("_")),s=Array.isArray(n._order)?n._order.map(String):void 0,c=(s?[...s.filter(t=>r.some(([e])=>e===t)),...r.map(([t])=>t).filter(t=>!s.includes(t))]:r.map(([t])=>t)).map(t=>[t,n[t]]);if(c.length>0)return c.filter(([,t])=>!1!==t).filter(([t,o])=>!!(!0===o||!1===o?void 0:o.entity)||ta(t,e,i,a)).map(([t,e])=>{const{_name:n,_hide_when_off:r,hide_when_off:s,hide_off_when_off:c,_icons:l,_heading:d,entity:h,...u}=!0===e?{}:e,p=h?o?.states?.[h]:void 0,m=Xi(p),g={...u,...!0===c?{hide_off_when_off:c}:{}};return{type:t,entity:h,hide_when_off:s??r,icons:l,heading:d,name:n,preserve_option_order:Object.keys(u).length>0,list:h?m&&!["unknown","unavailable"].includes(String(p.state))?Qi(p,g):[]:Yi(t,i,a,g)}})}return ea(a.getDefaultControl(),e,i,a)}(this.config,n,a,i,t)),s=(c=this.config.control,Array.isArray(c)||c&&"object"==typeof c&&(Array.isArray(c._order)||Object.keys(c).some(t=>!t.startsWith("_")))?r:function(t,e){if("fan"!==e&&"climate"!==e)return t;const i=t=>{const e=Ui.indexOf(t);return-1===e?Ui.length:e};return[...t].sort((t,e)=>i(t.type)-i(e.type))}(r,n));var c;this.modes=s.map(o=>{const n=o.preserve_option_order?o.list:o.type===yt.HVAC?function(t){const e=Object.values(Be),i=[],a=[];return t.forEach(t=>{const o=e.indexOf(t.value);o>=0?i[o]=t:a.push(t)}),[...i.filter(Boolean),...a]}(o.list):o.type===yt.FAN?function(t){const e=[],i=[];return t.forEach(t=>{const a=Ge.indexOf(t.value.toLowerCase());a>=0?e[a]=t:i.push(t)}),[...e.filter(Boolean),...i]}(o.list):o.list,r=o.entity&&t.states?.[o.entity]?t.states[o.entity].state:o.type===yt.HVAC||o.type===yt.STATE?e.state:a[i.getModePayloadKey(o.type)];return{...o,list:n,mode:r}});const{step:l}=i.getRange(a);this.stepSize=Number(this.config.step_size??l??.5),this._hide={...Di,...this.config.hide??{}};const d=this.config.entities??[];!1===d?(this.showEntities=!1,this.entities=[]):d?(this.showEntities=!0,this.entities=d.map(({name:e,entity:i,attribute:a,template:o,unit:n="",decimals:r,...s})=>{let c;const l=[e];return i?(c=t.states[i],l.push(c?.attributes?.friendly_name)):a&&a in(this.entity.attributes??{})&&(c=this.entity,l.push(a)),l.push(i),{...s,name:l.find(t=>!!t),state:c,entity:i,attribute:a,template:o,unit:n,...void 0!==r?{decimals:Bi(r,this.config.decimals??1)}:{}}})):(this.showEntities=!0,this.entities=[]),this.footer=function(t){return Array.isArray(t.footer)?t.footer:[]}(this.config).map(({entity:e,name:i,icon:a,hide_when_off:o})=>{const n=t.states?.[e];return n?{entity:e,name:i,icon:a,hide_when_off:o,state:n}:null}).filter(t=>!!t)}_localizeFirst(t,e){for(const e of t){const t=this._hass.localize?.(e);if(t&&t!==e)return t}return e}_getSetpointLabel(t){return this.config.label?.setpoint??this._hass.localize?.(`ui.card.${kt(this.config.entity).getLocalizationDomain()}.target`)??this._hass.localize?.("ui.card.climate.target_temperature")??this.localize(t,"state_attributes.climate.")}render({_hide:t,_values:e,_updatingValues:i,config:a,entity:o}=this){if(!a)return B``;const n=[];if(this.modes.filter(t=>t.entity&&0===t.list.length).forEach(t=>{n.push(B`Control entity unavailable or without options: ${t.entity}`)}),this.stepSize<1&&0===this.config.decimals&&n.push(B` @@ -3291,7 +3291,7 @@ ha-card.standard-visuals .thermostat-trigger:active { Entity not available: ${a.entity} - `;const r=kt(a.entity),s=we(o),{min:c,max:l}=r.getRange(o.attributes),d=this.getUnit(),h=a.entity.split(".")[0],u=this.areSetpointsHidden()?0:Object.keys(e).length,p=this.config?.layout?.step,m=!p&&this.showEntities&&u>1,g=p??(!1===this.config.enhanced_visuals||m?"column":"row"),f="row"===g,v=["unavailable","unknown"].includes(o.state),y=t=>"string"==typeof t?t.replace(/[^a-z0-9_-]/gi,""):"",b=[!this.header&&"no-header",`domain-${y(h)}`,`state-${y(o.state)}`,!1===this.config.enhanced_visuals&&"standard-visuals",!0===this.config.embedded&&"embedded",y(s),v&&y(o.state)].filter(t=>!!t),_=["body",this.showEntities&&"has-entities",`step-${g}`,`setpoint-count-${u}`].filter(t=>!!t),w=!0===a.embedded,x=function(t,e){if("fan"!==t)return"";const i=Number(e?.percentage);if(Number.isNaN(i))return"";const a=Math.min(Math.max(i,0),100);return`--st-fan-spin-duration: ${Math.max(.9,3.2-a/100*2.1).toFixed(2)}s;`}(h,o.attributes),$=w?function(t){const e=t?.style,i="string"==typeof e?e:e&&"object"==typeof e?Object.entries(e).flatMap(([t,e])=>"string"!=typeof e?[]:"."===t?[e]:"ha-card"===t?[`ha-card { ${e} }`]:[]).join("\n"):"";return i.includes("{{")||i.includes("{%")?"":i}(a.card_mod):"",S=this.showEntities?zi({_hide:t,unit:d,hass:this._hass,entity:this.entity,entities:this.entities,config:this.config,adapter:r,localize:this.localize,openEntityPopover:this.openEntityPopover}):"",A=w?B``:ei({header:this.header,hass:this._hass,toggleEntityChanged:this.toggleEntityChanged,entity:this.entity,openEntityPopover:this.openEntityPopover});return B` + `;const r=kt(a.entity),s=Se(o),{min:c,max:l}=r.getRange(o.attributes),d=this.getUnit(),h=a.entity.split(".")[0],u=this.areSetpointsHidden()?0:Object.keys(e).length,p=this.config?.layout?.step,m=!p&&this.showEntities&&u>1,g=p??(!1===this.config.enhanced_visuals||m?"column":"row"),f="row"===g,v=["unavailable","unknown"].includes(o.state),y=t=>"string"==typeof t?t.replace(/[^a-z0-9_-]/gi,""):"",b=[!this.header&&"no-header",`domain-${y(h)}`,`state-${y(o.state)}`,!1===this.config.enhanced_visuals&&"standard-visuals",!0===this.config.embedded&&"embedded",y(s),v&&y(o.state)].filter(t=>!!t),_=["body",this.showEntities&&"has-entities",`step-${g}`,`setpoint-count-${u}`].filter(t=>!!t),w=!0===a.embedded,x=function(t,e){if("fan"!==t)return"";const i=Number(e?.percentage);if(Number.isNaN(i))return"";const a=Math.min(Math.max(i,0),100);return`--st-fan-spin-duration: ${Math.max(.9,3.2-a/100*2.1).toFixed(2)}s;`}(h,o.attributes),$=w?function(t){const e=t?.style,i="string"==typeof e?e:e&&"object"==typeof e?Object.entries(e).flatMap(([t,e])=>"string"!=typeof e?[]:"."===t?[e]:"ha-card"===t?[`ha-card { ${e} }`]:[]).join("\n"):"";return i.includes("{{")||i.includes("{%")?"":i}(a.card_mod):"",S=this.showEntities?zi({_hide:t,unit:d,hass:this._hass,entity:this.entity,entities:this.entities,config:this.config,adapter:r,localize:this.localize,openEntityPopover:this.openEntityPopover}):"",A=w?B``:oi({header:this.header,hass:this._hass,toggleEntityChanged:this.toggleEntityChanged,entity:this.entity,openEntityPopover:this.openEntityPopover});return B` ${$?B`