diff --git a/dist/dev/my-cards.js b/dist/dev/my-cards.js index 1352f79..14a2a12 100644 --- a/dist/dev/my-cards.js +++ b/dist/dev/my-cards.js @@ -385,7 +385,7 @@ const Gt=new WeakMap,Kt=S(t=>e=>{if(!(e instanceof A)||e instanceof j||"style"!= * Code distributed by Google as part of the polymer project is also * subject to an additional IP rights grant found at * http://polymer.github.io/PATENTS.txt - */class ve{constructor(t){this.type=pe,this.options=t.options,this.legacyPart=t}get parentNode(){return this.legacyPart.startNode.parentNode}get startNode(){return this.legacyPart.startNode}get endNode(){return this.legacyPart.endNode}}class ye{constructor(t){this.legacyPart=t,this.type=t instanceof j?me:ge}get options(){}get name(){return this.legacyPart.committer.name}get element(){return this.legacyPart.committer.element}get strings(){return this.legacyPart.committer.strings}get tagName(){return this.element.tagName}}class be{constructor(t){this.type=fe,this.legacyPart=t}get options(){}get name(){return this.legacyPart.name}get element(){return this.legacyPart.element}get strings(){return this.legacyPart.strings}get tagName(){return this.element.tagName}}class we{constructor(t){this.type=_e,this.legacyPart=t}get options(){}get name(){return this.legacyPart.eventName}get element(){return this.legacyPart.element}get strings(){}get tagName(){return this.element.tagName}handleEvent(t){this.legacyPart.handleEvent(t)}}const xe="ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0;class Se extends HTMLElement{constructor(){super(),this.holdTime=500,this.held=!1,this.cancelled=!1,this.isRepeating=!1,this.repeatCount=0}connectedCallback(){Object.assign(this.style,{position:"fixed",width:xe?"100px":"50px",height:xe?"100px":"50px",transform:"translate(-50%, -50%)",pointerEvents:"none",zIndex:"999"}),["touchcancel","mouseout","mouseup","touchmove","mousewheel","wheel","scroll"].forEach(t=>{document.addEventListener(t,()=>{this.cancelled=!0,this.timer&&(this.stopAnimation(),clearTimeout(this.timer),this.timer=void 0,this.isRepeating&&this.repeatTimeout&&(clearInterval(this.repeatTimeout),this.isRepeating=!1))},{passive:!0})})}bind(t,e){t.actionHandler&&ae(e,t.actionHandler.options)||(t.actionHandler?(t.removeEventListener("touchstart",t.actionHandler.start),t.removeEventListener("touchend",t.actionHandler.end),t.removeEventListener("touchcancel",t.actionHandler.end),t.removeEventListener("mousedown",t.actionHandler.start),t.removeEventListener("click",t.actionHandler.end),t.removeEventListener("keyup",t.actionHandler.handleEnter)):t.addEventListener("contextmenu",t=>{const e=t||window.event;return e.preventDefault&&e.preventDefault(),e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0,e.returnValue=!1,!1}),t.actionHandler={options:e},e.disabled||(t.actionHandler.start=i=>{let n,s;this.cancelled=!1,i.touches?(n=i.touches[0].clientX,s=i.touches[0].clientY):(n=i.clientX,s=i.clientY),e.hasHold&&(this.held=!1,this.timer=window.setTimeout(()=>{this.startAnimation(n,s),this.held=!0,e.repeat&&!this.isRepeating&&(this.repeatCount=0,this.isRepeating=!0,this.repeatTimeout=setInterval(()=>{ue(t,"action",{action:"hold"}),this.repeatCount++,this.repeatTimeout&&e.repeatLimit&&this.repeatCount>=e.repeatLimit&&(clearInterval(this.repeatTimeout),this.isRepeating=!1)},e.repeat))},this.holdTime))},t.actionHandler.end=t=>{if(["touchend","touchcancel"].includes(t.type)&&this.cancelled)return void(this.isRepeating&&this.repeatTimeout&&(clearInterval(this.repeatTimeout),this.isRepeating=!1));const i=t.target;t.cancelable&&t.preventDefault(),e.hasHold&&(clearTimeout(this.timer),this.isRepeating&&this.repeatTimeout&&clearInterval(this.repeatTimeout),this.isRepeating=!1,this.stopAnimation(),this.timer=void 0),e.hasHold&&this.held?e.repeat||ue(i,"action",{action:"hold"}):e.hasDoubleClick?"click"===t.type&&t.detail<2||!this.dblClickTimeout?this.dblClickTimeout=window.setTimeout(()=>{this.dblClickTimeout=void 0,ue(i,"action",{action:"tap"})},250):(clearTimeout(this.dblClickTimeout),this.dblClickTimeout=void 0,ue(i,"action",{action:"double_tap"})):ue(i,"action",{action:"tap"})},t.actionHandler.handleEnter=t=>{13===t.keyCode&&t.currentTarget.actionHandler.end(t)},t.addEventListener("touchstart",t.actionHandler.start,{passive:!0}),t.addEventListener("touchend",t.actionHandler.end),t.addEventListener("touchcancel",t.actionHandler.end),t.addEventListener("mousedown",t.actionHandler.start,{passive:!0}),t.addEventListener("click",t.actionHandler.end),t.addEventListener("keyup",t.actionHandler.handleEnter)))}startAnimation(t,e){Object.assign(this.style,{left:t+"px",top:e+"px",display:null})}stopAnimation(){}}customElements.define("my-card-action-handler",Se);const ke=(t,e)=>{const i=(()=>{const t=document.body;if(t.querySelector("my-card-action-handler"))return t.querySelector("my-card-action-handler");const e=document.createElement("my-card-action-handler");return t.appendChild(e),e})();i&&i.bind(t,e)},$e=function(t){const e=new WeakMap;return S((...i)=>n=>{const s=e.get(n);let o,r;void 0===s?(o=function(t){if(t instanceof H)return new ve(t);if(t instanceof Y)return new we(t);if(t instanceof L)return new be(t);if(t instanceof j||t instanceof A)return new ye(t);throw new Error("Unknown part type")}(n),r=new t(o),e.set(n,[o,r])):(o=s[0],r=s[1]),n.setValue(r.update(o,i)),n.commit()})}(class extends class{constructor(t){}update(t,e){return this.render(...e)}}{update(t,[e]){return ke(t.element,e),$}render(t){}}),Te=(t,e={})=>{const i=Me[t];return i?Object.assign(Object.assign({},i),e):(console.log(t+": Not found in styles"),e)},Me={card:{height:"125px",width:"100%",background:"var(--card-background-color)",overflow:"hidden",cursor:"pointer",display:"flex","flex-direction":"column"},icon:{"--mdc-icon-size":"100%",height:"35px",width:"35px",display:"inline-block",color:"var(--paper-item-icon-color)","border-radius":"50%",margin:"7px 0px 0px 7px"},stats:{margin:"5px 2px 0px auto",color:"var(--primary-text-color)",display:"inline-block","font-family":'"Arial", sans-serif',"font-size":"11px","text-align":"center","text-shadow":"2px 2px 4px rgba(0, 0, 0, .9)",width:"50px",height:"50px",padding:"0px 3px"},camera:{"border-radius":"3px",overflow:"hidden"},labelContainer:{width:"100%",height:"100%",display:"flex","flex-direction":"column","align-items":"flex-start",overflow:"hidden"},label:{padding:"0",margin:"0 10px",color:"var(--primary-text-color)","font-weight":"bold",cursor:"pointer"},extraText:{margin:"0 10px",color:"var(--primary-text-color)","font-weight":"normal","font-size":"12px","white-space":"nowrap",overflow:"hidden"},row1:{display:"flex","justify-content":"space-between","min-height":"55px"},row2:{},buttonsContainer:{display:"flex","align-items":"flex-start","flex-direction":"row",padding:"0px 5px"},button:{padding:"3px 5px 3px 5px","aspect-ratio":"1 / 1",display:"flex","align-items":"center","justify-content":"center"},buttonText:{padding:"0px",margin:"0px"},buttonIcon:{padding:"0px",margin:"0px",position:"relative","--mdc-icon-size":"100%",display:"flex",height:"20px",width:"20px"},sliderCard:{"border-radius":"0px",background:"transparent","box-shadow":"none",cursor:"default"},sliderContainer:{"border-radius":"0px"},sliderTrack:{background:"transparent"},sliderThumbHor:{height:"20px",width:"3px",top:"6px",right:"2px","border-radius":"50px"},sliderThumbVer:{width:"20px",height:"3px",top:"2px",left:"7px","border-radius":"50px"},sliderProgressHor:{background:"linear-gradient(to top, var(--paper-item-icon-active-color), transparent)"},sliderProgressVer:{background:"linear-gradient(to left, var(--paper-item-icon-active-color), transparent)"},seekbarCard:{"border-radius":"0px",background:"transparent","box-shadow":"none",cursor:"default","margin-left":"30px"},seekbarContainer:{"border-radius":"0px"},seekbarTrack:{background:"transparent"},seekbarThumb:{height:"100%",width:"3px",right:"0px","border-radius":"50px",background:"linear-gradient(to top, var(--paper-item-icon-active-color) -20%, transparent 70%)"},seekbarProgress:{background:"transparent"}};console.info(`%c ---- MY-BUTTON ---- \n%c ${a("common.version")} 1.0.2 `,"color: orange; font-weight: bold; background: black","color: white; font-weight: bold; background: green"),window.customCards=window.customCards||[],window.customCards.push({type:"my-button",name:"My Button Card",description:"Custom Button Card for Lovelace."});let Ce=class extends gt{constructor(){super(...arguments),this.lastAction=0}static getStubConfig(){return{}}static get properties(){return{hass:{},config:{},active:{}}}setConfig(t){const e=["","light","cover","switch","input_boolean","button","lock","media_player"];if(t.entity&&!e.includes(t.entity.split(".")[0]))throw new Error("Entity has to be one of the following: "+e.map(t=>" "+t));this.config=Object.assign({name:"MyButton"},t)}shouldUpdate(t){return!!this.config&&Lt(this,t,!1)}updated(t){super.updated(t),requestAnimationFrame(()=>{var t;const e=null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector('[data-container="label-row"]'),i=null==e?void 0:e.querySelector("p");if(e&&i){const t=window.getComputedStyle(i),n=window.getComputedStyle(e),s=e.offsetWidth,o=i.offsetWidth+parseFloat(t.marginLeft)+parseFloat(t.marginRight),r=s-parseFloat(n.paddingLeft)-parseFloat(n.paddingRight);i.style.animation=o0||navigator.msMaxTouchPoints>0;class Se extends HTMLElement{constructor(){super(),this.holdTime=500,this.held=!1,this.cancelled=!1,this.isRepeating=!1,this.repeatCount=0}connectedCallback(){Object.assign(this.style,{position:"fixed",width:xe?"100px":"50px",height:xe?"100px":"50px",transform:"translate(-50%, -50%)",pointerEvents:"none",zIndex:"999"}),["touchcancel","mouseout","mouseup","touchmove","mousewheel","wheel","scroll"].forEach(t=>{document.addEventListener(t,()=>{this.cancelled=!0,this.timer&&(this.stopAnimation(),clearTimeout(this.timer),this.timer=void 0,this.isRepeating&&this.repeatTimeout&&(clearInterval(this.repeatTimeout),this.isRepeating=!1))},{passive:!0})})}bind(t,e){t.actionHandler&&ae(e,t.actionHandler.options)||(t.actionHandler?(t.removeEventListener("touchstart",t.actionHandler.start),t.removeEventListener("touchend",t.actionHandler.end),t.removeEventListener("touchcancel",t.actionHandler.end),t.removeEventListener("mousedown",t.actionHandler.start),t.removeEventListener("click",t.actionHandler.end),t.removeEventListener("keyup",t.actionHandler.handleEnter)):t.addEventListener("contextmenu",t=>{const e=t||window.event;return e.preventDefault&&e.preventDefault(),e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0,e.returnValue=!1,!1}),t.actionHandler={options:e},e.disabled||(t.actionHandler.start=i=>{let n,s;this.cancelled=!1,i.touches?(n=i.touches[0].clientX,s=i.touches[0].clientY):(n=i.clientX,s=i.clientY),e.hasHold&&(this.held=!1,this.timer=window.setTimeout(()=>{this.startAnimation(n,s),this.held=!0,e.repeat&&!this.isRepeating&&(this.repeatCount=0,this.isRepeating=!0,this.repeatTimeout=setInterval(()=>{ue(t,"action",{action:"hold"}),this.repeatCount++,this.repeatTimeout&&e.repeatLimit&&this.repeatCount>=e.repeatLimit&&(clearInterval(this.repeatTimeout),this.isRepeating=!1)},e.repeat))},this.holdTime))},t.actionHandler.end=t=>{if(["touchend","touchcancel"].includes(t.type)&&this.cancelled)return void(this.isRepeating&&this.repeatTimeout&&(clearInterval(this.repeatTimeout),this.isRepeating=!1));const i=t.target;t.cancelable&&t.preventDefault(),e.hasHold&&(clearTimeout(this.timer),this.isRepeating&&this.repeatTimeout&&clearInterval(this.repeatTimeout),this.isRepeating=!1,this.stopAnimation(),this.timer=void 0),e.hasHold&&this.held?e.repeat||ue(i,"action",{action:"hold"}):e.hasDoubleClick?"click"===t.type&&t.detail<2||!this.dblClickTimeout?this.dblClickTimeout=window.setTimeout(()=>{this.dblClickTimeout=void 0,ue(i,"action",{action:"tap"})},250):(clearTimeout(this.dblClickTimeout),this.dblClickTimeout=void 0,ue(i,"action",{action:"double_tap"})):ue(i,"action",{action:"tap"})},t.actionHandler.handleEnter=t=>{13===t.keyCode&&t.currentTarget.actionHandler.end(t)},t.addEventListener("touchstart",t.actionHandler.start,{passive:!0}),t.addEventListener("touchend",t.actionHandler.end),t.addEventListener("touchcancel",t.actionHandler.end),t.addEventListener("mousedown",t.actionHandler.start,{passive:!0}),t.addEventListener("click",t.actionHandler.end),t.addEventListener("keyup",t.actionHandler.handleEnter)))}startAnimation(t,e){Object.assign(this.style,{left:t+"px",top:e+"px",display:null})}stopAnimation(){}}customElements.define("my-card-action-handler",Se);const ke=(t,e)=>{const i=(()=>{const t=document.body;if(t.querySelector("my-card-action-handler"))return t.querySelector("my-card-action-handler");const e=document.createElement("my-card-action-handler");return t.appendChild(e),e})();i&&i.bind(t,e)},$e=function(t){const e=new WeakMap;return S((...i)=>n=>{const s=e.get(n);let o,r;void 0===s?(o=function(t){if(t instanceof H)return new ve(t);if(t instanceof Y)return new we(t);if(t instanceof L)return new be(t);if(t instanceof j||t instanceof A)return new ye(t);throw new Error("Unknown part type")}(n),r=new t(o),e.set(n,[o,r])):(o=s[0],r=s[1]),n.setValue(r.update(o,i)),n.commit()})}(class extends class{constructor(t){}update(t,e){return this.render(...e)}}{update(t,[e]){return ke(t.element,e),$}render(t){}}),Te=(t,e={})=>{const i=Me[t];return i?se(i,e):(console.log(t+": Not found in styles"),e)},Me={card:{height:"125px",width:"100%",background:"var(--card-background-color)",overflow:"hidden",cursor:"pointer",display:"flex","flex-direction":"column"},icon:{"--mdc-icon-size":"100%",height:"35px",width:"35px",display:"inline-block",color:"var(--paper-item-icon-color)","border-radius":"50%",margin:"7px 0px 0px 7px"},stats:{margin:"5px 2px 0px auto",color:"var(--primary-text-color)",display:"inline-block","font-family":'"Arial", sans-serif',"font-size":"11px","text-align":"center","text-shadow":"2px 2px 4px rgba(0, 0, 0, .9)",width:"50px",height:"50px",padding:"0px 3px"},camera:{"border-radius":"3px",overflow:"hidden"},labelContainer:{width:"100%",height:"100%",display:"flex","flex-direction":"column","align-items":"flex-start",overflow:"hidden"},label:{padding:"0",margin:"0 10px",color:"var(--primary-text-color)","font-weight":"bold",cursor:"pointer"},extraText:{margin:"0 10px",color:"var(--primary-text-color)","font-weight":"normal","font-size":"12px","white-space":"nowrap",overflow:"hidden"},row1:{display:"flex","justify-content":"space-between","min-height":"55px"},row2:{},buttonsContainer:{display:"flex","align-items":"flex-start","flex-direction":"row",padding:"0px 5px"},button:{padding:"3px 5px 3px 5px","aspect-ratio":"1 / 1",display:"flex","align-items":"center","justify-content":"center"},buttonText:{padding:"0px",margin:"0px"},buttonIcon:{padding:"0px",margin:"0px",position:"relative","--mdc-icon-size":"100%",display:"flex",height:"20px",width:"20px"},sliderCard:{"border-radius":"0px",background:"transparent","box-shadow":"none",cursor:"default"},sliderContainer:{"border-radius":"0px"},sliderTrack:{background:"transparent"},sliderThumbHor:{height:"20px",width:"3px",top:"6px",right:"2px","border-radius":"50px"},sliderThumbVer:{width:"20px",height:"3px",top:"2px",left:"7px","border-radius":"50px"},sliderProgressHor:{background:"linear-gradient(to top, var(--paper-item-icon-active-color), transparent)"},sliderProgressVer:{background:"linear-gradient(to left, var(--paper-item-icon-active-color), transparent)"},seekbarCard:{"border-radius":"0px",background:"transparent","box-shadow":"none",cursor:"default","margin-left":"30px"},seekbarContainer:{"border-radius":"0px"},seekbarTrack:{background:"transparent"},seekbarThumb:{height:"100%",width:"3px",right:"0px","border-radius":"50px",background:"linear-gradient(to top, var(--paper-item-icon-active-color) -20%, transparent 70%)"},seekbarProgress:{background:"transparent"}};console.info(`%c ---- MY-BUTTON ---- \n%c ${a("common.version")} 1.0.2 `,"color: orange; font-weight: bold; background: black","color: white; font-weight: bold; background: green"),window.customCards=window.customCards||[],window.customCards.push({type:"my-button",name:"My Button Card",description:"Custom Button Card for Lovelace."});let Ce=class extends gt{constructor(){super(...arguments),this.lastAction=0}static getStubConfig(){return{}}static get properties(){return{hass:{},config:{},active:{}}}setConfig(t){const e=["","light","cover","switch","input_boolean","button","lock","media_player"];if(t.entity&&!e.includes(t.entity.split(".")[0]))throw new Error("Entity has to be one of the following: "+e.map(t=>" "+t));this.config=Object.assign({name:"MyButton"},t)}shouldUpdate(t){return!!this.config&&Lt(this,t,!1)}updated(t){super.updated(t),requestAnimationFrame(()=>{var t;const e=null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector('[data-container="label-row"]'),i=null==e?void 0:e.querySelector("p");if(e&&i){const t=window.getComputedStyle(i),n=window.getComputedStyle(e),s=e.offsetWidth,o=i.offsetWidth+parseFloat(t.marginLeft)+parseFloat(t.marginRight),r=s-parseFloat(n.paddingLeft)-parseFloat(n.paddingRight);i.style.animation=o
e=>{if(!(e instanceof A)||e instanceof j||"style"!=
`}seekbarElement(){return this._config.slider.show?q` - `:q``}initializeConfig(){var t,e;this.entity=this.hass.states[""+this.config.entity],0===this.lastAction&&(this.lastAction=(new Date).getTime());try{this._config=le(this,this.entity,this.config)}catch(t){if(t instanceof Error){t.stack?console.error(t.stack):console.error(t);const e=document.createElement("hui-error-card");return e.setConfig({type:"error",error:t.toString(),origConfig:this.config}),e}console.log("Unexpected error evaluating config on init:",t)}if(!this._config)return q`Error with this._config...`;const i=this._config.entity?null===(t=this._config.entity)||void 0===t?void 0:t.split(".")[0]:"none",n={},s={show:!0,icon:"mdi:power"},o={show:!0},r={show:!1},a={show:!1,vertical:!0,styles:{}},l={show:!0,vertical:!1,entity:this._config.entity,allowTapping:!1,marginOfError:10},c={show:!1,entity:this._config.entity};if("none"!==i){const t="cover"===i,d="cover"===i,h=this.entity.state;o.text=this.entity.attributes.friendly_name,r.text=h.charAt(0).toUpperCase()+h.slice(1),l.entity=this.entity.entity_id,l.vertical=t,l.flipped=d,"light"===i?(n.tap_action={action:"toggle"},n.hold_action={action:"more-info"},this.entity.attributes.brightness&&(n.hold_action={action:"more-info"},r.text=Math.ceil(ie(this.entity.attributes.brightness,256))+"%"),r.show=!0,l.allowSliding=!0,l.slideDistance=15):"cover"===i?(n.hold_action={action:"more-info"},s.icon=(null===(e=this.entity.attributes)||void 0===e?void 0:e.current_position)>=50?"mdi:blinds-open":"mdi:blinds"):"switch"===i||"input_boolean"===i?(n.tap_action={action:"toggle"},n.hold_action={action:"more-info"},r.show=!0,l.show=!1,s.icon="on"===this.entity.state?"mdi:power-plug":"mdi:power-plug-off"):"button"===i?(n.tap_action={action:"call-service",service:"button.press",service_data:{entity_id:this.entity.entity_id}},n.hold_action={action:"more-info"},l.show=!1):"lock"===i?(n.hold_action={action:"more-info"},l.show=!1,r.show=!0,this._config.camera&&"string"==typeof this._config.camera&&(this._config.camera=this.hass.states[this._config.camera],r.entity=this._config.camera.entity_id,r.tap_action={action:"more-info"}),"locked"===this.entity.state?(s.icon="mdi:lock-outline",n.tap_action={action:"call-service",service:"lock.unlock",service_data:{entity_id:this.entity.entity_id}}):"unlocked"===this.entity.state&&(s.icon="mdi:lock-open-variant-outline",n.tap_action={action:"call-service",service:"lock.lock",service_data:{entity_id:this.entity.entity_id}})):"media_player"===i&&(n.tap_action={action:"more-info"},s.icon=re(this.entity,this.entity.state)?"mdi:speaker":"mdi:speaker-off",l.show=re(this.entity,this.entity.state),l.vertical=!0,l.sliderMin=5,l.min=1,l.allowTapping=!1,l.marginOfError=10,c.show=re(this.entity,this.entity.state),c.vertical=!1,c.allowTapping=!1,c.marginOfError=5,c.mode="seekbar",this.entity.attributes.media_title&&(o.extra=this.entity.attributes.media_title+" - "+this.entity.attributes.media_artist),a.vertical=!1,a.show=!0,a.button0={show:!0,icon:"playing"===this.entity.state?"mdi:pause":"mdi:play",styles:{container:{position:"absolute"}},tap_action:{action:"call-service",service:"playing"===this.entity.state?"media_player.media_pause":"media_player.media_play",service_data:{entity_id:this.entity.entity_id}}})}else l.show=!1;const d=se(n,this._config);return this._config=void 0!==d?d:this._config,this._config.icon="string"==typeof this._config.icon?Object.assign(Object.assign({},s),{icon:this._config.icon}):"object"==typeof this._config.icon?se(s,this._config.icon):s,this._config.label="string"==typeof this._config.label?Object.assign(Object.assign({},o),{text:this._config.label}):"object"==typeof this._config.label?se(o,this._config.label):o,this._config.stats="string"==typeof this._config.stats?Object.assign(Object.assign({},r),{text:this._config.stats}):"object"==typeof this._config.stats?se(r,this._config.stats):r,this._config.buttons="object"==typeof this._config.buttons?se(a,this._config.buttons):a,this._config.slider=this._config.slider?se(l,this._config.slider):l,this._config.seekbar=this._config.seekbar?se(c,this._config.seekbar):c,void 0!==this._config.styles&&null!==this._config.styles||(this._config.styles={}),this.initializeStyles(),null}initializeStyles(){var t,e,i,n,s,o,r,a,l,c,d,h,u,g,p,m,f,_,v,y,b,w,x,S,k,$,T,M,C,E,P,N,O,V,A,H,L,D,j,R,Y,I,z,F,U,B,q,W,X,J,Z,G,K,Q,tt,et;if(!this._config)return;const it=this._config.entity?null===(t=this._config.entity)||void 0===t?void 0:t.split(".")[0]:"none",nt={},st={filter:"drop-shadow(3px 3px 2px rgba(0,0,0,0.3)"},ot={card:Te("sliderCard",ee(null===(e=this._config.styles)||void 0===e?void 0:e.sliderCard)?ee(null===(i=this._config.styles)||void 0===i?void 0:i.sliderCard):{}),container:Te("sliderContainer",ee(null===(n=this._config.styles)||void 0===n?void 0:n.sliderContainer)?ee(null===(s=this._config.styles)||void 0===s?void 0:s.sliderContainer):{}),track:Te("sliderTrack",ee(null===(o=this._config.styles)||void 0===o?void 0:o.sliderTrack)?ee(null===(r=this._config.styles)||void 0===r?void 0:r.sliderTrack):{}),progress:this._config.slider.vertical?Te("sliderProgressVer",ee(null===(a=this._config.styles)||void 0===a?void 0:a.sliderProgressVer)?ee(null===(l=this._config.styles)||void 0===l?void 0:l.sliderProgressVer):{}):Te("sliderProgressHor",ee(null===(c=this._config.styles)||void 0===c?void 0:c.sliderProgressHor)?ee(null===(d=this._config.styles)||void 0===d?void 0:d.sliderProgressHor):{}),thumb:this._config.slider.vertical?Te("sliderThumbVer",ee(null===(h=this._config.styles)||void 0===h?void 0:h.sliderThumbVer)?ee(null===(u=this._config.styles)||void 0===u?void 0:u.sliderThumbVer):{}):Te("sliderThumbHor",ee(null===(g=this._config.styles)||void 0===g?void 0:g.sliderThumbHor)?ee(null===(p=this._config.styles)||void 0===p?void 0:p.sliderThumbHor):{})},rt={container:Te("stats",ee(null===(m=this._config.styles)||void 0===m?void 0:m.stats)?ee(null===(f=this._config.styles)||void 0===f?void 0:f.stats):{}),camera:Te("camera",ee(null===(_=this._config.styles)||void 0===_?void 0:_.camera)?ee(null===(v=this._config.styles)||void 0===v?void 0:v.camera):{})},at={container:Te("labelContainer",ee(null===(y=this._config.styles)||void 0===y?void 0:y.labelContainer)?ee(null===(b=this._config.styles)||void 0===b?void 0:b.labelContainer):{}),label:Te("label",ee(null===(w=this._config.styles)||void 0===w?void 0:w.label)?ee(null===(x=this._config.styles)||void 0===x?void 0:x.label):{}),extraText:Te("extraText",ee(null===(S=this._config.styles)||void 0===S?void 0:S.extraText)?ee(null===(k=this._config.styles)||void 0===k?void 0:k.extraText):{})},lt={container:Te("buttonsContainer",ee(null===($=this._config.styles)||void 0===$?void 0:$.buttonsContainer)?ee(null===(T=this._config.styles)||void 0===T?void 0:T.buttonsContainer):{}),button:Te("button",ee(null===(M=this._config.styles)||void 0===M?void 0:M.button)?ee(null===(C=this._config.styles)||void 0===C?void 0:C.button):{}),text:Te("buttonText",ee(null===(E=this._config.styles)||void 0===E?void 0:E.buttonText)?ee(null===(P=this._config.styles)||void 0===P?void 0:P.buttonText):{}),icon:Te("buttonIcon",ee(null===(N=this._config.styles)||void 0===N?void 0:N.buttonIcon)?ee(null===(O=this._config.styles)||void 0===O?void 0:O.buttonIcon):{})},ct={card:Te("seekbarCard",ee(null===(V=this._config.styles)||void 0===V?void 0:V.seekbarCard)?ee(null===(A=this._config.styles)||void 0===A?void 0:A.seekbarCard):{}),container:Te("seekbarContainer",ee(null===(H=this._config.styles)||void 0===H?void 0:H.seekbarContainer)?ee(null===(L=this._config.styles)||void 0===L?void 0:L.seekbarContainer):{}),track:Te("seekbarTrack",ee(null===(D=this._config.styles)||void 0===D?void 0:D.seekbarTrack)?ee(null===(j=this._config.styles)||void 0===j?void 0:j.seekbarTrack):{}),progress:Te("seekbarProgress",ee(null===(R=this._config.styles)||void 0===R?void 0:R.seekbarProgress)?ee(null===(Y=this._config.styles)||void 0===Y?void 0:Y.seekbarProgress):{}),thumb:Te("seekbarThumb",ee(null===(I=this._config.styles)||void 0===I?void 0:I.seekbarThumb)?ee(null===(z=this._config.styles)||void 0===z?void 0:z.seekbarThumb):{})};if(this._config.slider.vertical&&this._config.slider.flipped&&(ot.thumb.top="initial",ot.thumb.bottom="2px"),this._config.buttons.vertical&&(lt.container["flex-direction"]="column"),"none"!==it)if(re(this.entity,this.entity.state)&&(st.color="var(--paper-item-icon-active-color)",st.filter="drop-shadow(2px 2px 2px rgba(0,0,0,0.75)"),"light"===it)if(this.entity.attributes.brightness){let t=1+this.entity.attributes.brightness/256;const e=`radial-gradient(circle at top left, rgba(230, 230, 230, 0.7), var(--card-background-color) ${Math.ceil(ie(this.entity.attributes.brightness,256))/t+"%"})`;nt.background=e}else nt.background="radial-gradient(circle at top left, rgba(230, 230, 230, 0.5), var(--card-background-color) 40%)";else if("switch"===it||"input_boolean"===it){const t="on"===this.entity.state?"radial-gradient(circle at top left, rgba(230, 230, 230, 0.7), var(--card-background-color) 50%)":"radial-gradient(circle at top left, rgba(230, 230, 230, 0.5), var(--card-background-color) 40%)";nt.background=t}else"lock"===it&&("locked"===this.entity.state||"unlocked"===this.entity.state&&(st.color="var(--paper-item-icon-active-color)"));Object.keys(this._config.buttons).filter(t=>t.startsWith("button")).map(t=>(this._config.buttons[t].styles?(this._config.buttons[t].styles.container?this._config.buttons[t].styles.container=se(lt.button,this._config.buttons[t].styles.container?ee(this._config.buttons[t].styles.container):{}):this._config.buttons[t].styles.container=se(lt.button,this._config.buttons.styles.button?ee(this._config.buttons.styles.button):{}),this._config.buttons[t].styles.text?this._config.buttons[t].styles.text=se(lt.text,this._config.buttons[t].styles.text?ee(this._config.buttons[t].styles.text):{}):this._config.buttons[t].styles.text=se(lt.text,this._config.buttons.styles.text?ee(this._config.buttons.styles.text):{}),this._config.buttons[t].styles.icon?this._config.buttons[t].styles.icon=se(lt.text,this._config.buttons[t].styles.text?ee(this._config.buttons[t].styles.text):{}):this._config.buttons[t].styles.icon=se(lt.icon,this._config.buttons.styles.icon?ee(this._config.buttons.styles.icon):{})):this._config.buttons[t].styles={container:se(lt.button,this._config.buttons.styles.button?ee(this._config.buttons.styles.button):{}),text:se(lt.text,this._config.buttons.styles.text?ee(this._config.buttons.styles.text):{}),icon:se(lt.icon,this._config.buttons.styles.icon?ee(this._config.buttons.styles.icon):{})},null));const dt=(null===(F=this._config.styles)||void 0===F?void 0:F.card)?Object.assign(Object.assign({},nt),this._config.styles.card):nt,ht=(null===(U=this._config.styles)||void 0===U?void 0:U.icon)?Object.assign(Object.assign({},st),this._config.styles.icon):st;this._config.styles.card=Te("card",ee(dt)),this._config.styles.icon=Te("icon",ee(ht)),this._config.styles.row1=Te("row1",ee(null===(B=this._config.styles)||void 0===B?void 0:B.row1)?ee(null===(q=this._config.styles)||void 0===q?void 0:q.row1):{}),this._config.styles.row2=Te("row2",ee(null===(W=this._config.styles)||void 0===W?void 0:W.row2)?ee(null===(X=this._config.styles)||void 0===X?void 0:X.row2):{}),this._config.styles.button=Te("button",ee(null===(J=this._config.styles)||void 0===J?void 0:J.button)?ee(null===(Z=this._config.styles)||void 0===Z?void 0:Z.button):{}),this._config.slider.styles=(null===(G=this._config.slider)||void 0===G?void 0:G.styles)?se(ot,this._config.slider.styles):ot,this._config.stats.styles=(null===(K=this._config.stats)||void 0===K?void 0:K.styles)?se(rt,this._config.stats.styles):rt,this._config.label.styles=(null===(Q=this._config.label)||void 0===Q?void 0:Q.styles)?se(at,this._config.label.styles):at,this._config.buttons.styles=(null===(tt=this._config.buttons)||void 0===tt?void 0:tt.styles)?se(lt,this._config.buttons.styles):lt,this._config.seekbar.styles=(null===(et=this._config.seekbar)||void 0===et?void 0:et.styles)?se(ct,this._config.seekbar.styles):ct}_handleAction(t,e){var i;t.stopPropagation(),t.stopImmediatePropagation();if(!((new Date).getTime()-this.lastAction<25)&&(this.lastAction=(new Date).getTime(),e.entity||(e.entity=this._config.entity),null===(i=t.detail)||void 0===i?void 0:i.action))switch(t.detail.action){case"tap":case"hold":case"double_tap":if(!e)return;const i=t.detail.action,n=((t,e,i)=>{const n=JSON.parse(JSON.stringify(e)),s=e=>e?(Object.keys(e).forEach(i=>{"object"==typeof e[i]?e[i]=s(e[i]):e[i]=ce(t,t.entity,e[i])}),e):e;return n[i]=s(n[i]),!n[i].confirmation&&n.confirmation&&(n[i].confirmation=s(n.confirmation)),n})(this,e,i+"_action");(async(t,e,i,n)=>{ue(t,"hass-action",{config:i,action:n})})(this,this.hass,n,i)}}static get styles(){return ht` + `:q``}initializeConfig(){var t,e;this.entity=this.hass.states[""+this.config.entity],0===this.lastAction&&(this.lastAction=(new Date).getTime());try{this._config=le(this,this.entity,this.config)}catch(t){if(t instanceof Error){t.stack?console.error(t.stack):console.error(t);const e=document.createElement("hui-error-card");return e.setConfig({type:"error",error:t.toString(),origConfig:this.config}),e}console.log("Unexpected error evaluating config on init:",t)}if(!this._config)return q`Error with this._config...`;const i=this._config.entity?null===(t=this._config.entity)||void 0===t?void 0:t.split(".")[0]:"none",n={},s={show:!0,icon:"mdi:power"},o={show:!0},r={show:!1},a={show:!1,vertical:!0,styles:{}},l={show:!0,vertical:!1,entity:this._config.entity,allowTapping:!1,marginOfError:10},c={show:!1,entity:this._config.entity};if("none"!==i){const t="cover"===i,d="cover"===i,h=this.entity.state;o.text=this.entity.attributes.friendly_name,r.text=h.charAt(0).toUpperCase()+h.slice(1),l.entity=this.entity.entity_id,l.vertical=t,l.flipped=d,"light"===i?(n.tap_action={action:"toggle"},n.hold_action={action:"more-info"},this.entity.attributes.brightness&&(n.hold_action={action:"more-info"},r.text=Math.ceil(ie(this.entity.attributes.brightness,256))+"%"),r.show=!0,l.allowSliding=!0,l.slideDistance=15):"cover"===i?(n.hold_action={action:"more-info"},s.icon=(null===(e=this.entity.attributes)||void 0===e?void 0:e.current_position)>=50?"mdi:blinds-open":"mdi:blinds"):"switch"===i||"input_boolean"===i?(n.tap_action={action:"toggle"},n.hold_action={action:"more-info"},r.show=!0,l.show=!1,s.icon="on"===this.entity.state?"mdi:power-plug":"mdi:power-plug-off"):"button"===i?(n.tap_action={action:"call-service",service:"button.press",service_data:{entity_id:this.entity.entity_id}},n.hold_action={action:"more-info"},l.show=!1):"lock"===i?(n.hold_action={action:"more-info"},l.show=!1,r.show=!0,this._config.camera&&"string"==typeof this._config.camera&&(this._config.camera=this.hass.states[this._config.camera],r.entity=this._config.camera.entity_id,r.tap_action={action:"more-info"}),"locked"===this.entity.state?(s.icon="mdi:lock-outline",n.tap_action={action:"call-service",service:"lock.unlock",service_data:{entity_id:this.entity.entity_id}}):"unlocked"===this.entity.state&&(s.icon="mdi:lock-open-variant-outline",n.tap_action={action:"call-service",service:"lock.lock",service_data:{entity_id:this.entity.entity_id}})):"media_player"===i&&(n.tap_action={action:"more-info"},"speaker"===this.entity.attributes.device_class?(s.icon=re(this.entity,this.entity.state)?"mdi:speaker":"mdi:speaker-off","playing"===this.entity.state?s.icon="mdi:speaker-play":"paused"===this.entity.state&&(s.icon="mdi:speaker-pause")):"tv"===this.entity.attributes.device_class&&(s.icon=re(this.entity,this.entity.state)?"mdi:television":"mdi:television-off","playing"===this.entity.state?s.icon="mdi:television-play":"paused"===this.entity.state&&(s.icon="mdi:television-pause")),l.show="paused"!==this.entity.state&&re(this.entity,this.entity.state),l.vertical=!0,l.sliderMin=5,l.min=1,l.allowTapping=!1,l.marginOfError=10,c.show=re(this.entity,this.entity.state),c.vertical=!1,c.allowTapping=!1,c.marginOfError=5,c.mode="seekbar",this.entity.attributes.media_title&&(o.extra=this.entity.attributes.media_title+" - "+this.entity.attributes.media_artist),a.vertical=!1,a.show=!0,a.button0={show:!0,icon:"playing"===this.entity.state?"mdi:pause":"mdi:play",styles:{container:{position:"absolute"}},tap_action:{action:"call-service",service:"playing"===this.entity.state?"media_player.media_pause":"media_player.media_play",service_data:{entity_id:this.entity.entity_id}}})}else l.show=!1;const d=se(n,this._config);return this._config=void 0!==d?d:this._config,this._config.icon="string"==typeof this._config.icon?Object.assign(Object.assign({},s),{icon:this._config.icon}):"object"==typeof this._config.icon?se(s,this._config.icon):s,this._config.label="string"==typeof this._config.label?Object.assign(Object.assign({},o),{text:this._config.label}):"object"==typeof this._config.label?se(o,this._config.label):o,this._config.stats="string"==typeof this._config.stats?Object.assign(Object.assign({},r),{text:this._config.stats}):"object"==typeof this._config.stats?se(r,this._config.stats):r,this._config.buttons="object"==typeof this._config.buttons?se(a,this._config.buttons):a,this._config.slider=this._config.slider?se(l,this._config.slider):l,this._config.seekbar=this._config.seekbar?se(c,this._config.seekbar):c,void 0!==this._config.styles&&null!==this._config.styles||(this._config.styles={}),this.initializeStyles(),null}initializeStyles(){var t,e,i,n,s,o,r,a,l,c,d,h,u,g,p,m,f,_,v,y,b,w,x,S,k,$,T,M,C,E,P,N,O,V,A,H,L,D,j,R,Y,I,z,F,U,B,q,W,X,J,Z,G,K,Q,tt,et;if(!this._config)return;const it=this._config.entity?null===(t=this._config.entity)||void 0===t?void 0:t.split(".")[0]:"none",nt={background:"radial-gradient(circle at top left, rgba(230, 230, 230, 0.25), var(--card-background-color) 40%)"},st={filter:"drop-shadow(3px 3px 2px rgba(0,0,0,0.3)"},ot={card:Te("sliderCard",ee(null===(e=this._config.styles)||void 0===e?void 0:e.sliderCard)?ee(null===(i=this._config.styles)||void 0===i?void 0:i.sliderCard):{}),container:Te("sliderContainer",ee(null===(n=this._config.styles)||void 0===n?void 0:n.sliderContainer)?ee(null===(s=this._config.styles)||void 0===s?void 0:s.sliderContainer):{}),track:Te("sliderTrack",ee(null===(o=this._config.styles)||void 0===o?void 0:o.sliderTrack)?ee(null===(r=this._config.styles)||void 0===r?void 0:r.sliderTrack):{}),progress:this._config.slider.vertical?Te("sliderProgressVer",ee(null===(a=this._config.styles)||void 0===a?void 0:a.sliderProgressVer)?ee(null===(l=this._config.styles)||void 0===l?void 0:l.sliderProgressVer):{}):Te("sliderProgressHor",ee(null===(c=this._config.styles)||void 0===c?void 0:c.sliderProgressHor)?ee(null===(d=this._config.styles)||void 0===d?void 0:d.sliderProgressHor):{}),thumb:this._config.slider.vertical?Te("sliderThumbVer",ee(null===(h=this._config.styles)||void 0===h?void 0:h.sliderThumbVer)?ee(null===(u=this._config.styles)||void 0===u?void 0:u.sliderThumbVer):{}):Te("sliderThumbHor",ee(null===(g=this._config.styles)||void 0===g?void 0:g.sliderThumbHor)?ee(null===(p=this._config.styles)||void 0===p?void 0:p.sliderThumbHor):{})},rt={container:Te("stats",ee(null===(m=this._config.styles)||void 0===m?void 0:m.stats)?ee(null===(f=this._config.styles)||void 0===f?void 0:f.stats):{}),camera:Te("camera",ee(null===(_=this._config.styles)||void 0===_?void 0:_.camera)?ee(null===(v=this._config.styles)||void 0===v?void 0:v.camera):{})},at={container:Te("labelContainer",ee(null===(y=this._config.styles)||void 0===y?void 0:y.labelContainer)?ee(null===(b=this._config.styles)||void 0===b?void 0:b.labelContainer):{}),label:Te("label",ee(null===(w=this._config.styles)||void 0===w?void 0:w.label)?ee(null===(x=this._config.styles)||void 0===x?void 0:x.label):{}),extraText:Te("extraText",ee(null===(S=this._config.styles)||void 0===S?void 0:S.extraText)?ee(null===(k=this._config.styles)||void 0===k?void 0:k.extraText):{})},lt={container:Te("buttonsContainer",ee(null===($=this._config.styles)||void 0===$?void 0:$.buttonsContainer)?ee(null===(T=this._config.styles)||void 0===T?void 0:T.buttonsContainer):{}),button:Te("button",ee(null===(M=this._config.styles)||void 0===M?void 0:M.button)?ee(null===(C=this._config.styles)||void 0===C?void 0:C.button):{}),text:Te("buttonText",ee(null===(E=this._config.styles)||void 0===E?void 0:E.buttonText)?ee(null===(P=this._config.styles)||void 0===P?void 0:P.buttonText):{}),icon:Te("buttonIcon",ee(null===(N=this._config.styles)||void 0===N?void 0:N.buttonIcon)?ee(null===(O=this._config.styles)||void 0===O?void 0:O.buttonIcon):{})},ct={card:Te("seekbarCard",ee(null===(V=this._config.styles)||void 0===V?void 0:V.seekbarCard)?ee(null===(A=this._config.styles)||void 0===A?void 0:A.seekbarCard):{}),container:Te("seekbarContainer",ee(null===(H=this._config.styles)||void 0===H?void 0:H.seekbarContainer)?ee(null===(L=this._config.styles)||void 0===L?void 0:L.seekbarContainer):{}),track:Te("seekbarTrack",ee(null===(D=this._config.styles)||void 0===D?void 0:D.seekbarTrack)?ee(null===(j=this._config.styles)||void 0===j?void 0:j.seekbarTrack):{}),progress:Te("seekbarProgress",ee(null===(R=this._config.styles)||void 0===R?void 0:R.seekbarProgress)?ee(null===(Y=this._config.styles)||void 0===Y?void 0:Y.seekbarProgress):{}),thumb:Te("seekbarThumb",ee(null===(I=this._config.styles)||void 0===I?void 0:I.seekbarThumb)?ee(null===(z=this._config.styles)||void 0===z?void 0:z.seekbarThumb):{})};if(this._config.slider.vertical&&this._config.slider.flipped&&(ot.thumb.top="initial",ot.thumb.bottom="2px"),this._config.buttons.vertical&&(lt.container["flex-direction"]="column"),"none"!==it)if(re(this.entity,this.entity.state)&&(st.color="var(--paper-item-icon-active-color)",st.filter="drop-shadow(2px 2px 2px rgba(0,0,0,0.75)",nt.background="radial-gradient(circle at top left, rgba(230, 230, 230, 0.7), var(--card-background-color) 40%)"),"light"===it){if(this.entity.attributes.brightness){let t=1+this.entity.attributes.brightness/256;nt.background=`radial-gradient(circle at top left, rgba(230, 230, 230, 0.7), var(--card-background-color) ${Math.ceil(ie(this.entity.attributes.brightness,256))/t+"%"})`}}else"switch"===it||"input_boolean"===it||("lock"===it?"locked"===this.entity.state||"unlocked"===this.entity.state&&(st.color="var(--paper-item-icon-active-color)",nt.background="radial-gradient(circle at top left, rgba(230, 230, 230, 0.7), var(--card-background-color) 40%)"):"media_player"===it||"cover"===it&&(this.entity.attributes.current_position<=50?nt.background="radial-gradient(circle at top left, rgba(230, 230, 230, 0.25), var(--card-background-color) 40%)":st.color="var(--paper-item-icon-color)"));Object.keys(this._config.buttons).filter(t=>t.startsWith("button")).map(t=>(this._config.buttons[t].styles?(this._config.buttons[t].styles.container?this._config.buttons[t].styles.container=se(lt.button,this._config.buttons[t].styles.container?ee(this._config.buttons[t].styles.container):{}):this._config.buttons[t].styles.container=se(lt.button,this._config.buttons.styles.button?ee(this._config.buttons.styles.button):{}),this._config.buttons[t].styles.text?this._config.buttons[t].styles.text=se(lt.text,this._config.buttons[t].styles.text?ee(this._config.buttons[t].styles.text):{}):this._config.buttons[t].styles.text=se(lt.text,this._config.buttons.styles.text?ee(this._config.buttons.styles.text):{}),this._config.buttons[t].styles.icon?this._config.buttons[t].styles.icon=se(lt.text,this._config.buttons[t].styles.text?ee(this._config.buttons[t].styles.text):{}):this._config.buttons[t].styles.icon=se(lt.icon,this._config.buttons.styles.icon?ee(this._config.buttons.styles.icon):{})):this._config.buttons[t].styles={container:se(lt.button,this._config.buttons.styles.button?ee(this._config.buttons.styles.button):{}),text:se(lt.text,this._config.buttons.styles.text?ee(this._config.buttons.styles.text):{}),icon:se(lt.icon,this._config.buttons.styles.icon?ee(this._config.buttons.styles.icon):{})},null));const dt=(null===(F=this._config.styles)||void 0===F?void 0:F.card)?Object.assign(Object.assign({},nt),ee(this._config.styles.card)):nt,ht=(null===(U=this._config.styles)||void 0===U?void 0:U.icon)?Object.assign(Object.assign({},st),ee(this._config.styles.icon)):st;this._config.styles.card=Te("card",ee(dt)),this._config.styles.icon=Te("icon",ee(ht)),this._config.styles.row1=Te("row1",ee(null===(B=this._config.styles)||void 0===B?void 0:B.row1)?ee(null===(q=this._config.styles)||void 0===q?void 0:q.row1):{}),this._config.styles.row2=Te("row2",ee(null===(W=this._config.styles)||void 0===W?void 0:W.row2)?ee(null===(X=this._config.styles)||void 0===X?void 0:X.row2):{}),this._config.styles.button=Te("button",ee(null===(J=this._config.styles)||void 0===J?void 0:J.button)?ee(null===(Z=this._config.styles)||void 0===Z?void 0:Z.button):{}),this._config.slider.styles=(null===(G=this._config.slider)||void 0===G?void 0:G.styles)?se(ot,this._config.slider.styles):ot,this._config.stats.styles=(null===(K=this._config.stats)||void 0===K?void 0:K.styles)?se(rt,this._config.stats.styles):rt,this._config.label.styles=(null===(Q=this._config.label)||void 0===Q?void 0:Q.styles)?se(at,this._config.label.styles):at,this._config.buttons.styles=(null===(tt=this._config.buttons)||void 0===tt?void 0:tt.styles)?se(lt,this._config.buttons.styles):lt,this._config.seekbar.styles=(null===(et=this._config.seekbar)||void 0===et?void 0:et.styles)?se(ct,this._config.seekbar.styles):ct}_handleAction(t,e){var i;t.stopPropagation(),t.stopImmediatePropagation();if(!((new Date).getTime()-this.lastAction<25)&&(this.lastAction=(new Date).getTime(),e.entity||(e.entity=this._config.entity),null===(i=t.detail)||void 0===i?void 0:i.action))switch(t.detail.action){case"tap":case"hold":case"double_tap":if(!e)return;const i=t.detail.action,n=((t,e,i)=>{const n=JSON.parse(JSON.stringify(e)),s=e=>e?(Object.keys(e).forEach(i=>{"object"==typeof e[i]?e[i]=s(e[i]):e[i]=ce(t,t.entity,e[i])}),e):e;return n[i]=s(n[i]),!n[i].confirmation&&n.confirmation&&(n[i].confirmation=s(n.confirmation)),n})(this,e,i+"_action");(async(t,e,i,n)=>{ue(t,"hass-action",{config:i,action:n})})(this,this.hass,n,i)}}static get styles(){return ht` @keyframes marquee { 0% { text-indent: 100% } 100% { text-indent: -100% } diff --git a/src/cards/my-button.ts b/src/cards/my-button.ts index 2146d91..181544a 100644 --- a/src/cards/my-button.ts +++ b/src/cards/my-button.ts @@ -506,9 +506,26 @@ export class MyButton extends LitElement { defaultCardConfig.tap_action = { action: 'more-info' } - defaultIconAttr.icon = stateActive(this.entity, this.entity.state) ? 'mdi:speaker' : 'mdi:speaker-off' + if (this.entity.attributes.device_class === 'speaker') { + defaultIconAttr.icon = stateActive(this.entity, this.entity.state) ? 'mdi:speaker' : 'mdi:speaker-off' + if (this.entity.state === 'playing') { + defaultIconAttr.icon = 'mdi:speaker-play' + } + else if (this.entity.state === 'paused') { + defaultIconAttr.icon = 'mdi:speaker-pause' + } + } + else if (this.entity.attributes.device_class === 'tv') { + defaultIconAttr.icon = stateActive(this.entity, this.entity.state) ? 'mdi:television' : 'mdi:television-off' + if (this.entity.state === 'playing') { + defaultIconAttr.icon = 'mdi:television-play' + } + else if (this.entity.state === 'paused') { + defaultIconAttr.icon = 'mdi:television-pause' + } + } - defaultSliderConfig.show = stateActive(this.entity, this.entity.state) + defaultSliderConfig.show = this.entity.state === 'paused' ? false : stateActive(this.entity, this.entity.state) defaultSliderConfig.vertical = true defaultSliderConfig.sliderMin = 5 defaultSliderConfig.min = 1 @@ -562,6 +579,7 @@ export class MyButton extends LitElement { if (this._config.styles === undefined || this._config.styles === null) { this._config.styles = {} } + this.initializeStyles() return null // Success in this case } @@ -570,7 +588,9 @@ export class MyButton extends LitElement { if (!this._config) return const entityType = this._config.entity ? this._config.entity?.split('.')[0] : 'none' - const defaultCardStyle: any = {} + const defaultCardStyle: any = { + background: `radial-gradient(circle at top left, rgba(230, 230, 230, 0.25), var(--card-background-color) 40%)`, + } const defaultButtonsContainerStyle: any = {} const defaultIconStyle: any = { filter: 'drop-shadow(3px 3px 2px rgba(0,0,0,0.3)' @@ -626,24 +646,21 @@ export class MyButton extends LitElement { if (stateActive(this.entity, this.entity.state)) { defaultIconStyle.color = 'var(--paper-item-icon-active-color)' defaultIconStyle.filter = 'drop-shadow(2px 2px 2px rgba(0,0,0,0.75)' + defaultCardStyle.background = `radial-gradient(circle at top left, rgba(230, 230, 230, 0.7), var(--card-background-color) 40%)` } if (entityType === 'light') { if (this.entity.attributes.brightness) { let divisor = 1 + (this.entity.attributes.brightness / 256); - const cardBg = `radial-gradient(circle at top left, rgba(230, 230, 230, 0.7), var(--card-background-color) ${Math.ceil(percentage(this.entity.attributes.brightness, 256)) / divisor + '%'})` - defaultCardStyle['background'] = cardBg - } - else { - defaultCardStyle['background'] = `radial-gradient(circle at top left, rgba(230, 230, 230, 0.5), var(--card-background-color) 40%)` + defaultCardStyle['background'] = `radial-gradient(circle at top left, rgba(230, 230, 230, 0.7), var(--card-background-color) ${Math.ceil(percentage(this.entity.attributes.brightness, 256)) / divisor + '%'})` } } else if (entityType === 'switch' || entityType === 'input_boolean') { - const cardBg = this.entity.state === 'on' ? - `radial-gradient(circle at top left, rgba(230, 230, 230, 0.7), var(--card-background-color) 50%)` : - `radial-gradient(circle at top left, rgba(230, 230, 230, 0.5), var(--card-background-color) 40%)` - defaultCardStyle['background'] = cardBg + // if (this.entity.state === 'on') { + // defaultCardStyle['background'] = `radial-gradient(circle at top left, rgba(230, 230, 230, 0.7), var(--card-background-color) 40%)` + // } + } else if (entityType === 'lock') { if (this.entity.state === 'locked') { @@ -651,10 +668,21 @@ export class MyButton extends LitElement { } else if (this.entity.state === 'unlocked') { defaultIconStyle.color = 'var(--paper-item-icon-active-color)' + defaultCardStyle['background'] = `radial-gradient(circle at top left, rgba(230, 230, 230, 0.7), var(--card-background-color) 40%)` } } else if (entityType === 'media_player') { - + // if (this.entity.state === 'paused') { + // defaultIconStyle.color = 'var(--paper-item-icon-color)' + // } + } + else if (entityType === 'cover') { + if (this.entity.attributes.current_position <= 50) { + defaultCardStyle.background = `radial-gradient(circle at top left, rgba(230, 230, 230, 0.25), var(--card-background-color) 40%)` + } + else { + defaultIconStyle.color = 'var(--paper-item-icon-color)' + } } } @@ -694,10 +722,9 @@ export class MyButton extends LitElement { }) - // Merge default styles with the styles given in the specific element configs - const cardStyle = this._config.styles?.card ? { ...defaultCardStyle, ...this._config.styles.card } : defaultCardStyle - const iconStyle = this._config.styles?.icon ? { ...defaultIconStyle, ...this._config.styles.icon } : defaultIconStyle + const cardStyle = this._config.styles?.card ? { ...defaultCardStyle, ...deflate(this._config.styles.card) } : defaultCardStyle + const iconStyle = this._config.styles?.icon ? { ...defaultIconStyle, ...deflate(this._config.styles.icon) } : defaultIconStyle this._config.styles.card = getStyle('card', deflate(cardStyle)) this._config.styles.icon = getStyle('icon', deflate(iconStyle)) this._config.styles.row1 = getStyle('row1', deflate(this._config.styles?.row1) ? deflate(this._config.styles?.row1) : {}) diff --git a/src/cards/styles/my-button.styles.ts b/src/cards/styles/my-button.styles.ts index 6a17549..edc41d0 100644 --- a/src/cards/styles/my-button.styles.ts +++ b/src/cards/styles/my-button.styles.ts @@ -1,6 +1,9 @@ +import { deepMerge } from "../../scripts/helpers" + export const getStyle = (e: string, styleToMerge: any = {}) => { const style = styles[e] if (style) { + return deepMerge(style, styleToMerge) return { ...style, ...styleToMerge