forked from andrey-git/home-assistant-custom-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
state-card-custom-ui.html
1 lines (1 loc) · 21.7 KB
/
state-card-custom-ui.html
1
<div hidden="" by-polymer-bundler=""><script>window.customUI=window.customUI||{VERSION:"20171129",SUPPORTED_SLIDER_MODES:["single-line","break-slider","break-slider-toggle","hide-slider","no-slider"],domHost:function(t){if(t===document)return null;const e=t.getRootNode();return e instanceof DocumentFragment?e.host:e},lightOrShadow:function(t,e){return t.shadowRoot?t.shadowRoot.querySelector(e):t.querySelector(e)},getElementHierarchy:function(t,e){if(null===t)return null;const o=e.shift();return o?window.customUI.getElementHierarchy(window.customUI.lightOrShadow(t,o),e):t},getContext:function(t){if(void 0===t._context){t._context=[];for(let e="HA-ENTITIES-CARD"===t.tagName?window.customUI.domHost(t):t;e;e=window.customUI.domHost(e))switch(e.tagName){case"HA-ENTITIES-CARD":e.groupEntity?t._context.push(e.groupEntity.entity_id):!1===e.groupEntity&&e.states&&e.states.length&&t._context.push("group."+window.hassUtil.computeDomain(e.states[0]));break;case"MORE-INFO-GROUP":e.stateObj&&t._context.push(e.stateObj.entity_id);break;case"HA-CARDS":t._context.push(e.getAttribute("data-view")||"default_view")}t._context.reverse()}return t._context},maybeChangeObjectByDevice:function(t){const e=window.customUI.getName();if(!e)return t;if(!t.attributes.device||!t.attributes.device[e])return t;const o=Object.assign({},t.attributes.device[e]);return Object.keys(o).length?window.customUI.applyAttributes(t,o):t},maybeChangeObjectByGroup:function(t,e){const o=window.customUI.getContext(t);if(!o)return e;if(!e.attributes.group)return e;const n={};return o.forEach(t=>{e.attributes.group[t]&&Object.assign(n,e.attributes.group[t])}),Object.keys(n).length?window.customUI.applyAttributes(e,n):e},maybeApplyTemplates:function(t,e){if(!e.attributes.templates)return e;const o={};if(Object.keys(e.attributes.templates).forEach(n=>{const i=e.attributes.templates[n],s=window.customUI.computeTemplate(i,t.hass,t.hass.states,e,e.attributes,e.attributes[n],e.state);o[n]=s}),!Object.keys(o).length)return e;const n=window.customUI.applyAttributes(e,o);return Object.prototype.hasOwnProperty.call(o,"state")&&(n.state=o.state),Object.prototype.hasOwnProperty.call(o,"_stateDisplay")&&(n._stateDisplay=o._stateDisplay),n},applyAttributes:function(t,e){return{entity_id:t.entity_id,state:t.state,attributes:Object.assign({},t.attributes,e),last_changed:t.last_changed}},maybeChangeObject:function(t,e,o,n){if(o)return e;let i=window.customUI.maybeChangeObjectByDevice(e);return i=window.customUI.maybeChangeObjectByGroup(t,i),(i=window.customUI.maybeApplyTemplates(t,i))!==e&&i.attributes.hidden&&n?null:i},fixGroupTitles:function(){const t=window.customUI.getElementHierarchy(document,["home-assistant","home-assistant-main"]);if(null===t)return void window.setTimeout(window.customUI.fixGroupTitles,1e3);const e=window.customUI.getElementHierarchy(t,["partial-cards","ha-cards[view-visible]"]);if(null===e)return;window.customUI.lightOrShadow(e,".main").querySelectorAll("ha-entities-card").forEach(t=>{if(t.groupEntity){const e=window.customUI.maybeChangeObject(t,t.groupEntity,!1,!1);if(e!==t.groupEntity&&e.attributes.friendly_name){window.customUI.lightOrShadow(t,".name").textContent=e.attributes.friendly_name}}})},showVersion:function(){if("/dev-info"!==window.location.pathname)return;const t=window.customUI.getElementHierarchy(document,["home-assistant","home-assistant-main","partial-panel-resolver","ha-panel-dev-info"]);if(null===t)return void window.setTimeout(window.customUI.showVersion,1e3);const e=window.customUI.lightOrShadow(t,".about"),o=e.querySelectorAll("p")[1],n=document.createElement("p");n.textContent="Custom UI "+window.customUI.VERSION,e.insertBefore(n,o)},useCustomizer:function(){const t=window.customUI.lightOrShadow(document,"home-assistant").hass.states["customizer.customizer"];t&&t.attributes.hide_attributes&&(window.hassUtil.LOGIC_STATE_ATTRIBUTES&&Array.prototype.push.apply(window.hassUtil.LOGIC_STATE_ATTRIBUTES,t.attributes.hide_attributes),window.hassAttributeUtil.LOGIC_STATE_ATTRIBUTES&&t.attributes.hide_attributes.forEach(t=>{Object.prototype.hasOwnProperty.call(window.hassAttributeUtil.LOGIC_STATE_ATTRIBUTES,t)||(window.hassAttributeUtil.LOGIC_STATE_ATTRIBUTES[t]=void 0)}))},updateAttributes:function(){const t={group:void 0,device:void 0,templates:void 0,state_card_mode:{type:"array",options:{light:window.customUI.SUPPORTED_SLIDER_MODES.concat("badges"),cover:window.customUI.SUPPORTED_SLIDER_MODES.concat("badges"),"*":["badges"]}},state_card_custom_ui_secondary:{type:"string"},badges_list:{type:"json"},show_last_changed:{type:"boolean"},hide_control:{type:"boolean"},extra_data_template:{type:"string"},extra_badge:{type:"json"},stretch_slider:{type:"boolean"},slider_theme:{type:"json"},theme:{type:"string"},confirm_controls:{type:"boolean"},confirm_controls_show_lock:{type:"boolean"}};window.hassUtil.LOGIC_STATE_ATTRIBUTES&&Array.prototype.push.apply(window.hassUtil.LOGIC_STATE_ATTRIBUTES,Object.keys(t)),window.hassAttributeUtil.LOGIC_STATE_ATTRIBUTES&&Object.assign(window.hassAttributeUtil.LOGIC_STATE_ATTRIBUTES,t)},updateConfigPanel:function(){if(!window.location.pathname.startsWith("/config"))return;const t=window.customUI.getElementHierarchy(document,["home-assistant","home-assistant-main","partial-panel-resolver","ha-panel-config"]);if(!t)return void window.setTimeout(window.customUI.updateConfigPanel,1e3);const e=window.customUI.lightOrShadow(t,"iron-pages");if(!e)return;const o=window.customUI.getElementHierarchy(t,["ha-config-dashboard","ha-config-navigation"]);if(o){if("HA-CONFIG-CUSTOM-UI"!==e.lastElementChild.tagName){const t=document.createElement("ha-config-custom-ui");t.isWide=window.customUI.domHost(e).isWide,t.setAttribute("page-name","customui"),e.appendChild(t),e.addEventListener("iron-items-changed",()=>{window.location.pathname.startsWith("/config/customui")&&e.select("customui")})}o.pages.some(t=>"customui"===t.domain)||o.push("pages",{domain:"customui",caption:"Custom UI",description:"Set UI tweaks.",loaded:!0})}},init:function(){if(window.customUI.initDone)return;const t=window.customUI.lightOrShadow(document,"home-assistant");t.hass&&t.hass.states?(window.customUI.initDone=!0,window.customUI.runHooks(),window.customUI.useCustomizer(),window.addEventListener("location-changed",window.setTimeout.bind(null,window.customUI.runHooks,100)),console.log("Loaded CustomUI "+window.customUI.VERSION)):window.setTimeout(window.customUI.init,1e3)},runHooks:function(){window.customUI.fixGroupTitles(),window.customUI.showVersion(),window.customUI.updateAttributes(),window.customUI.updateConfigPanel()},getName:function(){return window.localStorage.getItem("ha-device-name")||""},setName:function(t){window.localStorage.setItem("ha-device-name",t||"")},computeTemplate:function(t,e,o,n,i,s,a){const r=t.indexOf("return")>=0?t:"return `"+t+"`;";try{return new Function("hass","entities","entity","attributes","attribute","state",r)(e,o,n,i,s,a)}catch(t){if(t instanceof SyntaxError||t instanceof ReferenceError)return console.warn(t.name+": "+t.message+" in template "+r),null;throw t}}},window.customUI.init();</script><dom-module id="ha-config-custom-ui"><template><style include="ha-style"></style><app-header-layout has-scrolling-region=""><app-header slot="header" fixed=""><app-toolbar><paper-icon-button icon="mdi:arrow-left" on-tap="_backTapped"></paper-icon-button><div main-title="">Custom UI settings</div></app-toolbar></app-header><ha-config-section is-wide="[[isWide]]"><paper-card heading="Device name"><div class="card-content">Set device name so that you can reference it in per-device settings<paper-input label="Name" value="{{name}}"></paper-input></div></paper-card></ha-config-section></app-header-layout></template></dom-module><script>class HaConfigCustomUi extends Polymer.Element{static get is(){return"ha-config-custom-ui"}static get properties(){return{isWide:Boolean,name:{type:String,observer:"nameChanged"}}}ready(){super.ready(),this.name=window.customUI.getName()}nameChanged(e){window.customUI.setName(e)}_backTapped(){window.history.back()}}customElements.define(HaConfigCustomUi.is,HaConfigCustomUi);</script><dom-module id="ha-themed-slider"><template><style>.disable-off-when-min{--paper-slider-pin-start-color:var(--paper-slider-pin-color)}.disable-off-when-min.is-on{--paper-slider-knob-start-color:var(--paper-slider-knob-color);--paper-slider-knob-start-border-color:var(--paper-slider-knob-color)}paper-slider{margin:4px 0;max-width:100%;min-width:100px;width:var(--ha-paper-slider-width,200px)}</style><paper-slider min="[[_themedMin]]" max="[[_computeAttribute(theme, "max", max)]]" pin="[[_computeAttribute(theme, "pin", pin)]]" class$="[[computeClass(theme, isOn, _themedMin)]]" value="[[value]]" on-change="valueChanged"></paper-slider></template></dom-module><script>Polymer({is:"ha-themed-slider",ready:function(){this.value=this.value+1,this.value=this.value-1,this.disableOffWhenMin=!this._computeAttribute(this.theme,"off_when_min",!this.disableOffWhenMin),this.computeEnabledThemedReportWhenNotChanged(this.theme,this.disableReportWhenNotChanged)},properties:{min:{type:Number,value:0},max:{type:Number,value:100},pin:{type:Boolean,value:!1},isOn:{type:Boolean,value:!1},disableOffWhenMin:{type:Boolean,value:!1,notify:!0},disableReportWhenNotChanged:{type:Boolean,value:!1},theme:{type:Object},value:{type:Number,notify:!0},_themedMin:{type:Number,computed:'_computeAttribute(theme, "min", min)'}},observers:["computeEnabledThemedReportWhenNotChanged(theme, disableReportWhenNotChanged)"],computeEnabledThemedReportWhenNotChanged:function(e,t){this._enabledThemedReportWhenNotChanged=this._computeAttribute(e,"report_when_not_changed",!t)},_computeAttribute:function(e,t,n){return e&&t in e?e[t]:n},computeClass:function(e,t,n){var h="";return t&&(h+="is-on "),this._computeAttribute(e,"off_when_min",!this.disableOffWhenMin)||0===n?"":h+"disable-off-when-min"},valueChanged:function(e){this._enabledThemedReportWhenNotChanged||this.value!==e.target.value?this.value=e.target.value:e.stopPropagation()}});</script><script>Polymer({is:"dynamic-element",properties:{hass:{type:Object},stateObj:{type:Object},elementName:{type:String},inDialog:{type:Boolean,value:!1}},observers:["observerFunc(hass, stateObj, elementName, inDialog)"],observerFunc:function(e,t,s,a){window.hassUtil.dynamicContentUpdater(this,s?s.toUpperCase():"DIV",{hass:e,stateObj:t,inDialog:a})}});</script><dom-module id="dynamic-with-extra"><template><style is="custom-style" include="iron-flex iron-flex-alignment iron-flex-factors"></style><style>:host{display:inline-block}.control-wrapper{margin-left:16px;position:relative}ha-state-label-badge{margin-left:8px}dynamic-element{display:block}#overlay{position:absolute;left:0;right:0;top:0;bottom:0;text-align:center}#lock{margin-top:8px;opacity:.3}.extra{margin-bottom:-16px;--ha-label-badge-size:36px;--ha-label-badge-font-size:1.2em}.state{@apply(--paper-font-body1);color:var(--primary-text-color);margin-left:16px;text-align:right;line-height:40px}</style><div class$="[[extraClass(extraObjVisible)]] horizontal layout"><template is="dom-if" if="[[extraObjVisible]]"><ha-state-label-badge hass="[[hass]]" state="[[extraObj]]"></ha-state-label-badge></template><template is="dom-if" if="[[_showControl(inDialog, stateObj)]]"><template is="dom-if" if="[[controlElement]]"><div class="control-wrapper"><dynamic-element class="flex" state-obj="[[stateObj]]" hass="[[hass]]" element-name="[[controlElement]]"></dynamic-element><template is="dom-if" if="[[isConfirmControls(stateObj)]]"><div id="overlay" on-tap="tapHandler"><template is="dom-if" if="[[stateObj.attributes.confirm_controls_show_lock]]"><iron-icon id="lock" icon="mdi:lock-outline"></iron-icon></template></div></template></div></template><template is="dom-if" if="[[!controlElement]]"><div class="state">[[computeStateDisplay(stateObj)]]</div></template></template></div></template></dom-module><script>class DynamicWithExtra extends(StateCardDisplay||Polymer.Element){static get is(){return"dynamic-with-extra"}static get properties(){return{hass:Object,inDialog:{type:Boolean,value:!1},stateObj:Object,controlElement:String,extraObj:{type:Object,computed:"computeExtra(hass, stateObj, inDialog)"},extraObjVisible:{type:Boolean,computed:"computeExtraVisible(hass, stateObj, inDialog)"}}}_getObject(t,e){if(!e.attributes.extra_badge)return null;var i=e.attributes.extra_badge;return i.entity_id&&t.states[i.entity_id]?Object.assign({},t.states[i.entity_id]):i.attribute&&e.attributes[i.attribute]?{state:e.attributes[i.attribute],_domain:"none",entity_id:null,attributes:{unit_of_measurement:i.unit}}:null}computeExtra(t,e){var i=this._getObject(t,e);return i?(i._entityDisplay="",i):{_entityDisplay:"",_domain:"none",attributes:{}}}computeExtraVisible(t,e,i){if(i)return!1;var a=this._getObject(t,e);if(!a)return!1;var r=e.attributes.extra_badge.blacklist_states;return!r||(Array.isArray(r)||(r=[r]),!r.some(t=>RegExp(t).test(a.state.toString())))}extraClass(t){return t?"extra":""}_showControl(t,e){return!!t||!e.attributes.hide_control}computeStateDisplay(t){return window.hassUtil.computeStateState?window.hassUtil.computeStateState(t):super.computeStateDisplay(this.haLocalize,t)}isConfirmControls(t){return t.attributes.confirm_controls||t.attributes.confirm_controls_show_lock}tapHandler(t){this.$$("#overlay").style.pointerEvents="none";const e=this.$$("#lock");e&&(e.icon="mdi:lock-open-outline",e.style.opacity="0.1"),window.setTimeout(()=>{this.$$("#overlay").style.pointerEvents="",e&&(e.icon="mdi:lock-outline",e.style.opacity="")},5e3),t.stopPropagation()}}customElements.define(DynamicWithExtra.is,DynamicWithExtra);</script><dom-module id="state-card-with-slider"><template><style is="custom-style" include="iron-flex iron-flex-alignment iron-flex-factors"></style><style>.second-line,.state-and-toggle,.state-info{max-width:100%}.nowrap .state-and-toggle{overflow:hidden;flex-grow:0}.nowrap .second-line{overflow:hidden}.second-line{padding-top:20px;padding-bottom:16px;margin-top:-20px;margin-bottom:-16px}.stretch .second-line,.stretch ha-themed-slider{width:100%;--ha-paper-slider-width:100%}.nowrap .state-info{min-width:initial}.top-wrapper,ha-themed-slider{min-width:100px;max-width:100%}.top-wrapper.stretch{display:block}.hidden{display:none}</style><div id="container" class$="horizontal layout flex top-wrapper [[_computeWrapClass(mode, stretchSlider, lineTooLong, inDialog)]]"><div class="horizontal layout justified flex-auto state-and-toggle"><state-info class="state-info" state-obj="[[stateObj]]" in-dialog="[[showLastChanged(stateObj, inDialog, extra)]]" secondary-line$="[[extra]]"><template is="dom-if" if="[[extra]]"><span>[[extra]]</span></template></state-info><template is="dom-if" if="[[breakSlider]]" class="hidden"><dynamic-with-extra hass="[[hass]]" state-obj="[[stateObj]]" control-element="[[controlElement]]" in-dialog="[[inDialog]]"></dynamic-with-extra></template></div><template is="dom-if" if="[[showSlider]]"><div class="horizontal layout flex-auto end-justified second-line"><ha-themed-slider id="slider" max="[[max]]" min="[[min]]" theme="[[stateObj.attributes.slider_theme]]" is-on="[[isOn(stateObj, nameOn)]]" value="{{sliderValue}}" disable-off-when-min="{{disableOffWhenMin}}" on-change="sliderChanged" on-tap="stopPropagation"></ha-themed-slider><template is="dom-if" if="[[!breakSlider]]"><dynamic-with-extra hass="[[hass]]" state-obj="[[stateObj]]" control-element="[[controlElement]]" in-dialog="[[inDialog]]"></dynamic-with-extra></template></div></template></div></template></dom-module><script>var DEFAULT_MODE="no-slider";Polymer({is:"state-card-with-slider",attached:function(){this.async(()=>{this.readyToCompute=!0,this._onIronResize()},1)},behaviors:[Polymer.IronResizableBehavior],properties:{hass:{type:Object},inDialog:{type:Boolean,value:!1},stateObj:{type:Object},controlElement:{type:String},domain:{type:String},serviceMin:{type:String},serviceMax:{type:String},valueName:{type:String,value:"___"},setValueName:{type:String},nameOn:{type:String,value:"on"},min:{type:Number,value:0},max:{type:Number,value:255},sliderValue:{type:Number,value:0},disableOffWhenMin:{type:Boolean},mode:{type:String},stretchSlider:{type:Boolean,value:!1},breakSlider:{type:Boolean,value:!1},hideSlider:{type:Boolean,value:!1},lineTooLong:{type:Boolean,value:!1},minLineBreak:{type:Number,value:0},maxLineBreak:{type:Number,value:999},showSlider:{type:Number,computed:"_showSlider(inDialog, stateObj, hideSlider)"},extra:{type:String,computed:"computeExtra(hass, stateObj)"}},observers:["stateObjChanged(stateObj, nameOn, valueName)"],listeners:{"iron-resize":"_onIronResize"},_onIronResize:function(){if(this.readyToCompute){if("no-slider"===this.mode)return this.hideSlider=!0,void(this.breakSlider=!0);var e=this.breakSlider;this.lineTooLong=!1,this.hideSlider=!1,this.breakSlider=!1;var t=this.$.container,i=t.clientWidth;if(i<=this.minLineBreak)this.lineTooLong=!0;else if(i>=this.maxLineBreak)this.lineTooLong=!1;else{var a=t.clientHeight,s=this.$$(".state-info").clientHeight;this.lineTooLong=a>1.5*s,this.lineTooLong?this.minLineBreak=i:e||(this.maxLineBreak=i)}this.hideSlider="hide-slider"===this.mode&&this.lineTooLong,this.breakSlider=("break-slider"===this.mode||"hide-slider"===this.mode)&&this.lineTooLong,this.showSlider||(this.breakSlider=!0)}},_computeWrapClass:function(e,t,i,a){return a?"":"single-line"===e?"nowrap":t&&i?"stretch wrap":"wrap"},_showSlider:function(e,t,i){return!e&&!i&&1&t.attributes.supported_features},sliderChanged:function(e){var t=parseInt(e.target.value,10),i={entity_id:this.stateObj.entity_id};if(!Number.isNaN(t)){var a=this.$$("#slider");e.target!==a?a=e.target:e.path?a=e.path[0]:e.composedPath&&(a=e.composedPath()[0]),0===t||t<=a.min&&!this.disableOffWhenMin?this.hass.callService(this.domain,this.serviceMin,i):(i[this.setValueName||this.valueName]=t,this.hass.callService(this.domain,this.serviceMax,i))}},stateObjChanged:function(e,t,i){this.isOn(e,t)?this.sliderValue=e.attributes[i]:this.sliderValue=0,e&&(-1!==window.customUI.SUPPORTED_SLIDER_MODES.indexOf(e.attributes.state_card_mode)?this.mode=e.attributes.state_card_mode:this.mode=DEFAULT_MODE,e.attributes.stretch_slider&&(this.stretchSlider=!0))},isOn:function(e,t){return e&&e.state===t},stopPropagation:function(e){e.stopPropagation()},computeExtra:function(e,t){return t.attributes.extra_data_template?window.customUI.computeTemplate(t.attributes.extra_data_template,e,e.states,t,t.attributes,void 0,t.state):null},showLastChanged:function(e,t,i){return!!t||!i&&!!e.attributes.show_last_changed}});</script><script>const SHOW_LAST_CHANGED_BLACKLISTED_CARDS=["configurator"];class StateCardCustomUi extends Polymer.Element{static get is(){return"state-card-custom-ui"}static get properties(){return{hass:Object,inDialog:{type:Boolean,value:!1},stateObj:Object}}static get observers(){return["inputChanged(hass, inDialog, stateObj)"]}connectedCallback(){super.connectedCallback();const t=this.parentNode.parentNode;"DIV"===t.tagName&&(t.classList.contains("state")||t.classList.contains("child-card"))&&(this._container=t,t.style.setProperty("background-color","var(--paper-card-background-color, inherit)"),t.updateStyles||(t.updateStyles=(e=>{Object.keys(e).forEach(s=>{t.style.setProperty(s,e[s])})}))),this._isAttached=!0,this.inputChanged(this.hass,this.inDialog,this.stateObj)}disconnectedCallback(){this._isAttached=!1,this._container&&(this._container.updateStyles({display:"",margin:"",padding:""}),window.hassUtil.applyThemesOnElement(this._container,this.hass.themes||{default_theme:"default",themes:{}},"default"),this._container=null),super.disconnectedCallback()}badgeMode(t,e,s){const i=[];if("group"===s)e.attributes.entity_id.forEach(s=>{const a=t.states[s];a?(!e.attributes.badges_list||e.attributes.badges_list.indexOf(a.entity_id)>=0)&&i.push(window.customUI.maybeChangeObject(this,a,!1,!1)):console.warn("Unknown ID "+s+" in group "+e.entity_id)});else if(i.push(e),this._container){this._container.style.display="inline-block";const t={display:"inline-block"};this._container.classList.contains("state")&&(t.margin="0 -6px"),this.updateStyles(t)}window.hassUtil.dynamicContentUpdater(this,"HA-BADGES-CARD",{hass:t,states:i}),this.style.setProperty("--ha-state-label-badge-margin-bottom","0")}cleanBadgeStyle(){this._container&&(this._container.style.display=""),this.updateStyles({display:"",margin:""})}applyThemes(t,e){let s=this,i="default";this._container&&(s=this._container),e.attributes.theme&&(i=e.attributes.theme),window.hassUtil.applyThemesOnElement(s,t.themes||{default_theme:"default",themes:{}},i)}maybeHideEntity(t){return t?(this._container&&this._container.updateStyles({margin:"",padding:""}),!1):(this.lastChild&&this.removeChild(this.lastChild),this._container&&this._container.updateStyles({margin:"0",padding:"0"}),!0)}inputChanged(t,e,s){if(!s||!t||!this._isAttached)return;const i=window.hassUtil.computeDomain(s),a=window.customUI.maybeChangeObject(this,s,e,!0);if(this.maybeHideEntity(a))return;if(this.applyThemes(t,a),!e&&"badges"===a.attributes.state_card_mode)return void this.badgeMode(t,a,i);this.cleanBadgeStyle();const n={hass:t,stateObj:a,inDialog:e};let o=window.hassUtil.stateCardType(t,s);const l=a.attributes.state_card_custom_ui_secondary;"light"===i?Object.assign(n,{controlElement:"ha-entity-toggle",serviceMin:"turn_off",serviceMax:"turn_on",valueName:"brightness"}):"cover"===i?Object.assign(n,{controlElement:"ha-cover-controls",max:100,serviceMin:"close_cover",serviceMax:"set_cover_position",setValueName:"position",valueName:"current_position",nameOn:"open"}):"toggle"===o?Object.assign(n,{controlElement:"ha-entity-toggle"}):"display"===o&&Object.assign(n,{controlElement:""}),l||"light"!==i&&"cover"!==i&&"toggle"!==o&&"display"!==o?a.attributes.show_last_changed&&-1===SHOW_LAST_CHANGED_BLACKLISTED_CARDS.indexOf(o)&&(n.inDialog=!0):(o="with-slider",Object.assign(n,{domain:i}),"unavailable"===s.state&&Object.assign(n,{controlElement:""})),window.hassUtil.dynamicContentUpdater(this,l||"STATE-CARD-"+o.toUpperCase(),n)}}customElements.define(StateCardCustomUi.is,StateCardCustomUi);</script></div>