From 34ef80130172c58a568db904d662c446ab84e06c Mon Sep 17 00:00:00 2001 From: Cloos <36499953+Clooos@users.noreply.github.com> Date: Mon, 11 Sep 2023 16:20:58 +0200 Subject: [PATCH] BETA 7 is in the place! --- bubble-card.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bubble-card.js b/bubble-card.js index db66e7af..54661ef4 100644 --- a/bubble-card.js +++ b/bubble-card.js @@ -1 +1 @@ -const version="v0.0.1-beta.6";class BubbleCard extends HTMLElement{set hass(t){var e;function n(e){t.callService("homeassistant","toggle",{entity_id:e})}if(this.content||(this.attachShadow({mode:"open"}),this.shadowRoot.innerHTML='\n \n
\n
\n
\n ',this.card=this.shadowRoot.querySelector("ha-card"),this.content=this.shadowRoot.querySelector("div")),e=this,"?edit=1"!==window.location.search?e.editor=!1:e.editor=!0,"pop-up"!==this.config.card_type||this.getRootNode().host){if("pop-up"===this.config.card_type){this.popUp||(this.card.style.marginTop="0",this.popUp=this.getRootNode().querySelector("#root"));const i=this.config.hash,o=this.popUp,a=this.config.entity||"",r=this.config.icon||"",s=this.config.name||"",c=this.config.state_unit||"",d=this.config.state?t.states[this.config.state].state+c:"",l=this.config.margin_top_mobile&&"0"!==this.config.margin_top_mobile?this.config.margin_top_mobile:"0px",h=this.config.margin_top_desktop&&"0"!==this.config.margin_top_desktop?this.config.margin_top_desktop:"0px",p=this.config.width_desktop||"600px",u=this.config.is_sidebar_hidden||"false",g=p.match(/(\d+)(\D+)/),m=this.config.entity?"flex":"none";if(!this.headerAdded){const _=document.createElement("div");_.setAttribute("id","header-container");const x=document.createElement("div");_.appendChild(x);const k=document.createElement("ha-icon");k.setAttribute("class","header-icon"),k.setAttribute("icon",r),x.appendChild(k);const w=document.createElement("h2");w.textContent=s,x.appendChild(w);const $=document.createElement("p");$.textContent=d,x.appendChild($);const C=document.createElement("ha-icon");C.setAttribute("class","power-button"),C.setAttribute("icon","mdi:power"),C.setAttribute("style",`display: ${m};`),x.appendChild(C);const E=document.createElement("button");E.setAttribute("class","close-pop-up"),E.setAttribute("onclick","history.replaceState(null, null, location.href.split('#')[0]);"),_.appendChild(E);const L=document.createElement("ha-icon");L.setAttribute("icon","mdi:close"),E.appendChild(L),this.content.appendChild(_),this.header=x,this.headerAdded=!0}if(this.headerAdded){const A=this.content.querySelector("#header-container .header-icon");A.setAttribute("icon",r),this.haIcon1=A;this.content.querySelector("#header-container h2").textContent=s;this.content.querySelector("#header-container p").textContent=d;this.content.querySelector("#header-container .power-button").setAttribute("style",`display: ${m};`)}if(!this.eventAdded){let S,z;["click","touchend","popstate"].forEach((t=>{window["checkHashRef_"+i]&&window.removeEventListener(t,window["checkHashRef_"+i]),window["checkHashRef_"+i]=f,window.addEventListener(t,window["checkHashRef_"+i])})),this.content.querySelector(".power-button").addEventListener("click",(()=>{n(a)})),document.addEventListener("mousedown",(function(t){location.hash!==i||t.composedPath().some((t=>"HA-MORE-INFO-DIALOG"===t.nodeName))||t.composedPath().some((t=>"root"===t.id&&!t.classList.contains("close-pop-up")))||history.replaceState(null,null,location.href.split("#")[0])})),window.addEventListener("keydown",(function(t){"Escape"===t.key&&history.replaceState(null,null,location.href.split("#")[0])})),this.haIcon1.addEventListener("click",(t=>{fireEvent(this,"hass-more-info",{entityId:a})})),o.addEventListener("touchstart",(function(t){S=t.touches[0].clientY,z=S})),o.addEventListener("touchmove",(function(t){t.touches[0].clientY-S>200&&t.touches[0].clientY>z&&history.replaceState(null,null,location.href.split("#")[0]),z=t.touches[0].clientY})),this.eventAdded=!0}if(""!==a){const I=t.states[a].attributes.rgb_color,T=I?`rgba(${I[0]}, ${I[1]}, ${I[2]}, 0.5)`:"off"!==t.states[a].state?"var(--accent-color)":"var(--background-color,var(--secondary-background-color))";this.header.style.backgroundColor=T}function f(t){location.hash===i?b():o.classList.contains("open-pop-up")&&v()}function b(){o.classList.remove("close-pop-up"),o.classList.add("open-pop-up")}function v(){o.classList.remove("open-pop-up"),o.classList.add("close-pop-up")}const y="\n #header-container {\n display: inline-flex;\n width: 100%;\n margin: 0;\n padding: 0;\n }\n #header-container > div {\n display: inline-flex;\n align-items: center;\n position: relative;\n padding: 6px;\n z-index: 2;\n flex-grow: 1;\n background-color: var(--background-color,var(--secondary-background-color));\n transition: background 1s;\n border-radius: 25px;\n margin-right: 14px;\n }\n .header-icon {\n display: inline-flex;\n width: 22px;\n height: 22px;\n padding: 8px;\n background-color: var(--card-background-color,var(--ha-card-background));\n border-radius: 100%;\n margin: 0 10px 0 0;\n cursor: pointer; \n }\n #header-container h2 {\n display: inline-flex;\n margin: 0 18px 0 0;\n /*line-height: 0px;*/\n z-index: 100;\n font-size: 20px;\n }\n #header-container p {\n display: inline-flex;\n line-height: 0px;\n font-size: 16px;\n }\n .power-button {\n cursor: pointer; \n flex-grow: inherit; \n width: 24px;\n height: 24px;\n border-radius: 12px;\n margin: 0 10px;\n background: none !important;\n justify-content: flex-end;\n background-color: var(--background-color,var(--secondary-background-color));\n }\n .close-pop-up {\n height: 50px;\n width: 50px;\n border: none;\n border-radius: 50%;\n z-index: 2;\n background: var(--background-color,var(--secondary-background-color));\n color: var(--primary-text-color);\n flex-shrink: 0;\n }\n ";if(this.styleAdded||!0===this.editor){if(!0===this.editor){const V=this.getRootNode().querySelector("#root").querySelector("style");V&&o.removeChild(V),o.style.backgroundColor="var(--ha-card-background,var(--card-background-color))",o.style.padding="16px",o.style.borderRadius="42px",o.style.gridGap="12px",o.style.gap="12px";const H=document.createElement("style");H.innerHTML=y,this.content.appendChild(H),this.styleAdded=!1}}else{const q=document.createElement("style"),M=document.createElement("style"),D=`\n ha-card {\n margin-top: 0 !important;\n background: none !important;\n border: none !important;\n }\n .card-content {\n width: 100% !important;\n padding: 0 !important;\n }\n #root {\n position: fixed !important;\n margin: 0 -7px;\n width: calc(100% - 38px);\n background-color: var(--ha-card-background,var(--card-background-color));\n border-radius: 42px;\n top: calc(100% + ${l} + 54px); /*136px*/\n display: grid !important;\n grid-gap: 12px !important;\n gap: 12px !important;\n grid-auto-rows: min-content;\n padding: 18px 18px 220px 18px !important;\n height: calc(100% - 240px) !important;\n -ms-overflow-style: none; /* for Internet Explorer, Edge */\n scrollbar-width: none; /* for Firefox */\n overflow-y: auto; \n overflow-x: hidden; \n z-index: 1 !important; /* Higher value hide the more-info panel */\n }\n #root > bubble-card:first-child::after {\n content: '';\n display: block;\n position: sticky;\n top: 0;\n left: -50px;\n margin: -70px 0 -35px 0;\n width: 200%;\n height: 100px;\n background: linear-gradient(0deg, rgba(79, 69, 87, 0) 0%, var(--ha-card-background,var(--card-background-color)) 80%);\n z-index: 0;\n }\n #root::-webkit-scrollbar {\n display: none; /* for Chrome, Safari, and Opera */\n }\n #root > bubble-card:first-child {\n position: sticky;\n top: 0;\n z-index: 5;\n background: none !important;\n }\n #root.open-pop-up {\n transform: translateY(-100%);\n transition: transform .4s !important;\n }\n #root.open-pop-up > * {\n /* Block child items to overflow and if they do clip them */\n max-width: calc(100vw - 38px);\n overflow-x: clip;\n }\n #root.close-pop-up { \n transform: translateY(0%);\n transition: transform .4s !important;\n /* animation: hide 1s forwards; */\n }\n @media only screen and (min-width: 768px) {\n #root {\n top: calc(100% + ${h} + 54px);\n width: calc(${p} - 36px) !important;\n left: calc(50% - ${g[1]/2}${g[2]});\n margin: 0 !important;\n }\n } \n @media only screen and (min-width: 870px) {\n #root {\n top: calc(100% + ${h} + 54px);\n width: calc(${p} - ${!0===u?"0px":"92px"}) !important; \n left: calc(50% - ${g[1]/2}${g[2]} + ${!0===u?"0px":"56px"});\n margin: 0 !important;\n }\n } \n `;q.innerHTML=D,M.innerHTML=y,o.appendChild(q),this.content.appendChild(M),this.styleAdded=!0}}}else!0!==this.editor&&(this.card.style.marginTop="2000px");if("horizontal-buttons-stack"===this.config.card_type){const B=(t,e,n)=>{const i=document.createElement("button");return i.setAttribute("onclick",`window.location.href='${e}';`),i.setAttribute("class","button"),i.innerHTML=`\n

${t}

\n `,i},Y=(e,n)=>{if(t.states[n].attributes.rgb_color){const i=t.states[n].attributes.rgb_color,o=`rgba(${i[0]}, ${i[1]}, ${i[2]}, 0.5)`;e.style.backgroundColor=o,e.style.border="1px solid rgba(0,0,0,0)"}else t.states[n].attributes.rgb_color||"on"!=t.states[n].state?(e.style.backgroundColor="rgba(0,0,0,0)",e.style.border="1px solid var(--primary-text-color)"):(e.style.backgroundColor="rgba(255,255,255,0.5)",e.style.border="1px solid rgba(0,0,0,0)")};if(!this.buttonsAdded){const O=document.createElement("div");O.setAttribute("class","horizontal-buttons-stack-container"),this.content.appendChild(O)}if((()=>{let e=[],n=1;for(;this.config[n+"_name"];){const t=n+"_",i=this.config[t+"name"],o=this.config[t+"pir_sensor"],a=this.config[t+"icon"],r=this.config[t+"link"],s=this.config[t+"entity"];e.push({button:i,pirSensor:o,icon:a,link:r,lightEntity:s}),n++}if(this.config.auto_order&&e.sort(((e,n)=>{if(e.pirSensor&&n.pirSensor){if("on"===t.states[e.pirSensor].state&&"on"===t.states[n.pirSensor].state){return t.states[e.pirSensor].last_updated{const i=B(e.button,e.link,e.icon);n[e.link]=i,t.appendChild(i)})),this.buttonsAdded=!0,this.buttons=n}let i=0;e.forEach(((t,e)=>{let n=this.buttons[t.link];if(n){let e=localStorage.getItem(`buttonWidth-${t.link}`),o=localStorage.getItem(`buttonContent-${t.link}`);e&&"0"!==e&&o===n.innerHTML&&!0!==this.editor||(e=n.offsetWidth,localStorage.setItem(`buttonWidth-${t.link}`,e),localStorage.setItem(`buttonContent-${t.link}`,n.innerHTML)),n.style.transform=`translateX(${i}px)`,i+=parseInt(e)+12}t.lightEntity&&Y(n,t.lightEntity)}))})(),!this.styleAdded){const R=document.createElement("style"),X="\n .horizontal-buttons-stack {\n width: 100%;\n margin-top: 0 !important;\n background: none !important;\n position: fixed;\n height: 51px;\n bottom: 16px;\n /* transform: translateY(200px); */\n /* animation: from-bottom 1.3s forwards; */\n z-index: 1 !important; /* Higher value hide the more-info panel */\n }\n @keyframes from-bottom {\n 0% {transform: translateY(200px);}\n 20% {transform: translateY(200px);}\n 46% {transform: translateY(-8px);}\n 56% {transform: translateY(1px);}\n 62% {transform: translateY(-2px);}\n 70% {transform: translateY(0);}\n 100% {transform: translateY(0);}\n }\n .horizontal-buttons-stack-container {\n width: max-content;\n position: relative;\n height: 51px;\n }\n .button {\n display: flex;\n position: absolute;\n box-sizing: border-box;\n border: 1px solid var(--primary-text-color);\n align-items: center;\n height: 50px;\n white-space: nowrap;\n width: auto;\n border-radius: 25px;\n z-index: 2;\n padding: 16px;\n transition: background-color 1s, border 1s, transform 1s;\n color: var(--primary-text-color);\n }\n .icon {\n height: 24px;\n margin-right: 8px;\n }\n .card-content {\n width: 100%;\n box-sizing: border-box;\n margin: 0 -36px !important;\n padding: 0 36px !important;\n overflow: scroll !important;\n -ms-overflow-style: none;\n scrollbar-width: none;\n mask-image: linear-gradient(90deg, transparent 2%, rgba(0, 0, 0, 1) 6%, rgba(0, 0, 0, 1) 96%, transparent 100%);\n -webkit-mask-image: linear-gradient(90deg, transparent 2%, rgba(0, 0, 0, 1) 6%, rgba(0, 0, 0, 1) 96%, transparent 100%);\n }\n .horizontal-buttons-stack::before {\n content: '';\n position: absolute;\n top: -32px;\n left: -100%;\n display: block;\n background: linear-gradient(0deg, var(--background-color, var(--primary-background-color)) 50%, rgba(79, 69, 87, 0));\n width: 200%;\n height: 100px;\n }\n .card-content::-webkit-scrollbar {\n display: none;\n }\n @media only screen and (min-width: 768px) {\n .card-content {\n position: fixed;\n width: 538px !important;\n left: calc(50% - 246px);\n padding: 0 26px !important;\n }\n }\n @media only screen and (min-width: 870px) {\n .card-content {\n position: fixed;\n width: 538px !important;\n left: calc(50% - 218px);\n padding: 0 26px !important;\n }\n }\n ";R.innerHTML=X,this.card.classList.add("horizontal-buttons-stack"),this.content.querySelector(".horizontal-buttons-stack-container").appendChild(R),this.styleAdded=!0}if(!0===this.editor){if(!this.editorStyleAdded){const W=document.createElement("style"),j="\n .horizontal-buttons-stack {\n position: relative;\n height: 51px;\n bottom: 0px;\n overflow: hidden;\n }\n .horizontal-buttons-stack::before {\n top: -32px;\n left: -100%;\n background: none;\n width: 100%;\n height: 0;\n }\n .card-content {\n position: relative;\n mask-image: linear-gradient(90deg, transparent 2%, rgba(0, 0, 0, 1) 6%, rgba(0, 0, 0, 1) 96%, transparent 100%);\n -webkit-mask-image: linear-gradient(90deg, transparent 2%, rgba(0, 0, 0, 1) 6%, rgba(0, 0, 0, 1) 96%, transparent 100%);\n }\n @media only screen and (min-width: 870px) {\n .card-content {\n left: calc(50% - 230px);\n }\n }\n ";W.innerHTML=j,this.card.appendChild(W),this.editorStyleAdded=!0}}else if(this.card.querySelector("ha-card > style")){const F=this.card.querySelector("ha-card > style");this.card.removeChild(F)}}if("button"===this.config.card_type){if(!this.buttonAdded){const ut=document.createElement("div");ut.setAttribute("class","button-container"),this.content.appendChild(ut)}const N=this.config.entity,P=this.config.icon?this.config.icon:t.states[N].attributes.icon||"",U=this.config.name?this.config.name:t.states[N].attributes.friendly_name||"",G=this.config.button_type||"switch",J=N?t.states[N].state:"";let Z=N?t.states[N].attributes.brightness||0:"",K=N?t.states[N].attributes.volume_level||0:"";const Q=document.createElement("div");Q.setAttribute("class","icon-container");const tt=document.createElement("div");tt.setAttribute("class","nameContainer");const et=document.createElement("div");et.setAttribute("class","switch-button");const nt=document.createElement("div");nt.setAttribute("class","range-slider");const it=document.createElement("div");it.setAttribute("class","range-fill"),N&&N.startsWith("light.")&&"slider"===G?it.style.transform=`translateX(${Z/255*100}%)`:N&&N.startsWith("media_player.")&&"slider"===G&&(it.style.transform=`translateX(${100*K}%)`),this.buttonContainer||(this.buttonContainer=this.content.querySelector(".button-container"),"slider"!==G||this.buttonAdded?"switch"===G&&(this.buttonContainer.appendChild(et),et.appendChild(Q),et.appendChild(tt),this.switchButton=this.content.querySelector(".switch-button")):(this.buttonContainer.appendChild(nt),nt.appendChild(Q),nt.appendChild(tt),nt.appendChild(it),this.rangeFill=this.content.querySelector(".range-fill")),Q.innerHTML=``,tt.innerHTML=`

${U}

`,this.buttonAdded=!0);let ot=!1,at=Z,rt=K;function st(t){let e=t.querySelector(".feedback-element");e||(e=document.createElement("div"),e.setAttribute("class","feedback-element"),t.appendChild(e)),e.style.animation="tap-feedback .5s",setTimeout((()=>{e.style.animation="none",t.removeChild(e)}),500)}function ct(t){t.target===Q.querySelector("ha-icon")?(ot=!1,Q.addEventListener("click",(t=>{fireEvent(this,"hass-more-info",{entityId:N})}))):(ot=!0,pt(t.pageX||t.touches[0].pageX),document.addEventListener("mouseup",dt),document.addEventListener("touchend",dt),document.addEventListener("mousemove",lt),document.addEventListener("touchmove",lt))}function dt(){ot=!1,N.startsWith("light.")?(Z=at,t.callService("light","turn_on",{entity_id:N,brightness:Z})):K!==rt&&N.startsWith("media_player.")&&(K=rt,t.callService("media_player","volume_set",{entity_id:N,volume_level:K})),document.removeEventListener("mouseup",dt),document.removeEventListener("touchend",dt),document.removeEventListener("mousemove",lt),document.removeEventListener("touchmove",lt)}function lt(t){ot&&pt(t.pageX||t.touches[0].pageX)}function ht(t,e){if(e.buttonContainer.style.opacity="unavailable"!==t?"1":"0.5","switch"===G){const n="on"===t?"var(--accent-color)":"rgba(0,0,0,0)";e.switchButton.style.backgroundColor=n}}function pt(t){const e=nt.getBoundingClientRect(),n=Math.min(Math.max(t-e.left,0),e.width)/e.width;N.startsWith("light.")?at=Math.round(255*n):N.startsWith("media_player.")&&(rt=n),it.style.transition="none",it.style.transform=`translateX(${100*n}%)`}if(this.eventAdded||"switch"!==G?this.eventAdded||"slider"!==G||(nt.addEventListener("mousedown",ct),nt.addEventListener("touchstart",ct),this.eventAdded=!0):(et.addEventListener("click",(()=>st(this.switchButton))),et.addEventListener("click",(function(t){t.target.closest("ha-icon")?fireEvent(this,"hass-more-info",{entityId:N}):n(N)})),this.eventAdded=!0),this.isDragging||"slider"!==G||(this.rangeFill.style.transition="all .2s",N.startsWith("light.")?this.rangeFill.style.transform=`translateX(${Z/255*100}%)`:N.startsWith("media_player.")&&(this.rangeFill.style.transform=`translateX(${100*K}%)`)),ht(J,this),"slider"===G){const gt=t.states[N].attributes.rgb_color,mt=gt?`rgba(${gt[0]}, ${gt[1]}, ${gt[2]}, 0.5)`:"rgba(255, 255, 255, 0.5)";it.style.backgroundColor=mt,this.rangeFill.style.backgroundColor=mt}if(!this.styleAdded){const ft=document.createElement("style"),bt="\n ha-card {\n margin-top: 0 !important;\n background: none !important;\n }\n \n .button-container {\n position: relative;\n width: 100%;\n height: 50px;\n z-index: 0;\n background-color: var(--background-color-2,var(--secondary-background-color));\n border-radius: 25px;\n mask-image: radial-gradient(white, black);\n -webkit-mask-image: radial-gradient(white, black);\n -webkit-backface-visibility: hidden;\n -moz-backface-visibility: hidden;\n -webkit-transform: translateZ(0);\n overflow: hidden;\n }\n \n .switch-button,\n .range-slider {\n display: inline-flex;\n position: absolute;\n height: 100%;\n width: 100%;\n transition: background-color 1.5s;\n }\n \n .range-fill {\n position: absolute;\n top: 0;\n bottom: 0;\n left: 0;\n }\n \n .switch-button {\n cursor: pointer !important;\n }\n \n .range-slider {\n cursor: ew-resize;\n }\n \n .range-fill {\n z-index: 1;\n width: 100%;\n left: -100%;\n }\n \n .icon-container {\n position: absolute;\n z-index: 2;\n width: 38px;\n height: 38px;\n margin: 6px;\n border-radius: 50%;\n background-color: var(--card-background-color,var(--ha-card-background));\n }\n \n ha-icon {\n display: flex;\n position: absolute;\n margin: inherit;\n padding: 1px 2px;\n width: 22px; \n height: 22px;\n cursor: pointer !important;\n }\n \n .nameContainer {\n position: relative;\n display: inline-flex;\n margin-left: 58px;\n z-index: 2;\n font-weight: 600;\n align-items: center;\n }\n \n .nameContainer p {\n display: inline-flex;\n }\n \n .feedback-element {\n position: absolute;\n top: 0;\n left: 0;\n opacity: 0;\n width: 100%;\n height: 100%;\n background-color: rgb(0,0,0);\n }\n \n @keyframes tap-feedback {\n 0% {transform: translateX(-100%); opacity: 0;}\n 64% {transform: translateX(0); opacity: 0.1;}\n 100% {transform: translateX(100%); opacity: 0;}\n }\n ";ft.innerHTML=bt,this.content.appendChild(ft),this.styleAdded=!0}}if("separator"===this.config.card_type){const vt=this.config.icon?this.config.icon:"",yt=this.config.name?this.config.name:"";if(!this.separatorAdded){const _t=document.createElement("div");if(_t.setAttribute("class","separator-container"),_t.innerHTML=`\n
\n \n

${yt}

\n
\n
\n `,this.content.appendChild(_t),this.separatorAdded=!0,!this.styleAdded){const xt=document.createElement("style"),kt="\n .separator-container {\n display: inline-flex;\n width: 100%;\n }\n .separator-container div:first-child {\n display: inline-flex;\n max-width: calc(100% - 38px);\n }\n .separator-container div ha-icon{\n display: inline-flex;\n height: 24px;\n width: 24px;\n margin: 0 20px 0 8px;\n transform: translateY(-2px);\n }\n .separator-container div h4{\n display: inline-flex;\n margin: 0 20px 0 0;\n font-size: 17px;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n }\n .separator-container div:last-child{\n display: inline-flex; \n border-radius: 6px; \n opacity: 0.3; \n margin-left: 10px; \n flex-grow: 1; \n height: 6px; \n align-self: center; \n background-color: var(--background-color,var(--secondary-background-color));\n ";xt.innerHTML=kt,this.content.appendChild(xt),this.styleAdded=!0}}}if("cover"===this.config.card_type){const wt=this.config.entity,$t=this.config.icon_open?this.config.icon_open:"mdi:window-shutter-open",Ct=this.config.icon_close?this.config.icon_close:"mdi:window-shutter",Et="open"===t.states[this.config.entity].state?$t:Ct,Lt=this.config.name?this.config.name:t.states[entityId].attributes.friendly_name||"",At=this.config.open_service?this.config.open_service:"cover.open_cover",St=this.config.close_service?this.config.close_service:"cover.close_cover",zt=this.config.stop_service?this.config.stop_service:"cover.stop_cover";if(!this.coverAdded){const It=document.createElement("div");It.setAttribute("class","cover-container"),It.innerHTML=`\n
\n
\n
\n

${Lt}

\n
\n
\n \n \n \n
\n `,this.content.appendChild(It);const Tt=It.querySelector(".open"),Vt=It.querySelector(".stop"),Ht=It.querySelector(".close");Tt.addEventListener("click",(()=>{t.callService(At.split(".")[0],At.split(".")[1],{entity_id:wt})})),Vt.addEventListener("click",(()=>{t.callService(zt.split(".")[0],zt.split(".")[1],{entity_id:wt})})),Ht.addEventListener("click",(()=>{t.callService(St.split(".")[0],St.split(".")[1],{entity_id:wt})})),this.content.querySelector(".icon-container").addEventListener("mouseup",(t=>{fireEvent(this,"hass-more-info",{entityId:wt})})),this.coverAdded=!0}if(this.content.querySelector(".icon-container").innerHTML=``,!this.styleAdded){const qt=document.createElement("style"),Mt="\n ha-card {\n margin-top: 0 !important;\n background: none !important;\n }\n \n .header-container {\n display: flex;\n align-items: center;\n margin-bottom: 10px;\n }\n \n .name {\n display: inline-block; \n margin-left: 10px;\n font-weight: 600;\n }\n \n .cover-container {\n display: grid;\n }\n \n .icon-container {\n display: flex;\n margin: 0 !important;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n z-index: 2;\n width: 48px;\n height: 48px;\n margin: 6px;\n border-radius: 50%;\n background-color: var(--card-background-color,var(--ha-card-background));\n border: 6px solid var(--background-color-2,var(--secondary-background-color));\n box-sizing: border-box;\n }\n \n .buttons-container {\n display: grid;\n align-self: center;\n grid-auto-flow: column;\n grid-gap: 18px; \n }\n \n ha-icon {\n display: flex; \n height: 24px; \n width: 24px; \n color: var(--primary-text-color);\n }\n \n .button {\n display: flex;\n background: var(--background-color-2,var(--secondary-background-color));\n height: 42px;\n border-radius: 32px;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n border: none;\n }\n ";qt.innerHTML=Mt,this.content.appendChild(qt),this.styleAdded=!0}}if("empty-column"===this.config.card_type&&!this.emptyCollumnAdded){const Dt=document.createElement("div");Dt.setAttribute("class","empty-column"),Dt.innerHTML='\n
\n
\n ',this.content.appendChild(Dt),this.emptyColumnAdded=!0}}setConfig(t){if("pop-up"===t.card_type){if(!t.hash)throw new Error("You need to define an hash");if(!t.icon)throw new Error("You need to define an icon");if(!t.name)throw new Error("You need to define a name")}else if(("button"===t.card_type||"cover"===t.card_type)&&!t.entity)throw new Error("You need to define an entity");this.config=t}getCardSize(){return 1}static getConfigElement(){return document.createElement("bubble-card-editor")}}customElements.define("bubble-card",BubbleCard);const fireEvent=(t,e,n,i)=>{i=i||{},n=null==n?{}:n;const o=new Event(e,{bubbles:void 0===i.bubbles||i.bubbles,cancelable:Boolean(i.cancelable),composed:void 0===i.composed||i.composed});return o.detail=n,t.dispatchEvent(o),o};customElements.get("ha-switch");const LitElement=Object.getPrototypeOf(customElements.get("ha-panel-lovelace")),html=LitElement.prototype.html,css=LitElement.prototype.css;class BubbleCardEditor extends LitElement{setConfig(t){this._config={...t}}static get properties(){return{hass:{},_config:{}}}get _card_type(){return this._config.card_type||""}get _button_type(){return this._config.button_type||"switch"}get _entity(){return this._config.entity||""}get _name(){return this._config.name||""}get _icon(){return this._config.icon||""}get _state(){return this._config.state||""}get _state_unit(){return this._config.state_unit||""}get _hash(){return this._config.hash||"#pop-up-name"}get _margin_top_mobile(){return this._config.margin_top_mobile||"0px"}get _margin_top_desktop(){return this._config.margin_top_desktop||"0px"}get _width_desktop(){return this._config.width_desktop||"600px"}get _is_sidebar_hidden(){return this._config.is_sidebar_hidden||!1}get _icon_open(){return this._config.icon_open||""}get _icon_close(){return this._config.icon_close||""}get _open_service(){return this._config.open_service||"cover.open_cover"}get _close_service(){return this._config.open_service||"cover.close_cover"}get _stop_service(){return this._config.open_service||"cover.stop_cover"}get _auto_order(){return this._config.auto_order||!1}render(){if(!this.hass)return html``;if(!this.listsUpdated){const t=t=>({label:t,value:t});this.allEntitiesList=Object.keys(this.hass.states).map(t),this.lightList=Object.keys(this.hass.states).filter((t=>"light"===t.substr(0,t.indexOf(".")))).map(t),this.sensorList=Object.keys(this.hass.states).filter((t=>"sensor"===t.substr(0,t.indexOf(".")))).map(t),this.binarySensorList=Object.keys(this.hass.states).filter((t=>"binary_sensor"===t.substr(0,t.indexOf(".")))).map(t),this.coverList=Object.keys(this.hass.states).filter((t=>"cover"===t.substr(0,t.indexOf(".")))).map(t),this.cardTypeList=[{label:"Button",value:"button"},{label:"Cover",value:"cover"},{label:"Empty column",value:"empty-column"},{label:"Horizontal buttons stack",value:"horizontal-buttons-stack"},{label:"Pop-up",value:"pop-up"},{label:"Separator",value:"separator"}],this.buttonTypeList=[{label:"Switch",value:"switch"},{label:"Slider",value:"slider"}],this.listsUpdated=!0}const t=this.allEntitiesList,e=(this.lightList,this.sensorList,this.coverList),n=this.cardTypeList,i=this.buttonTypeList;if("pop-up"===this._config.card_type)return html`
${this.makeDropdown("Card type","card_type",n)} This card allows you to convert any vertical-stack into a pop-up. Each pop-up can be opened by targeting its link (e.g. '#pop-up-name'), with navigation_path or with the horizontal buttons stack that is included.

It must be placed within a vertical-stack card at the top most position to function properly.
${this.makeDropdown("Icon","icon")} ${this.makeDropdown("Entity to toggle (e.g. room light group)","entity",t)} ${this.makeDropdown("Entity state to display (e.g. room temperature)","state",t)}
${this.makeVersion()}
`;if("button"===this._config.card_type)return html`
${this.makeDropdown("Card type","card_type",n)} This card can be a slider or a button, allowing you to toggle your entities, control the brightness of your lights and the volume of your media players. To access color / control of an entity, simply tap on the icon. ${this.makeDropdown("slider"!==this._button_type?"Entity (toggle)":"Entity (light or media_player)","entity",t)} ${this.makeDropdown("Button type","button_type",i)} ${this.makeDropdown("Icon","icon")} ${this.makeVersion()}
`;if("separator"===this._config.card_type)return html`
${this.makeDropdown("Card type","card_type",n)} This card is a simple separator for dividing your pop-up into categories / sections. e.g. Lights, Devices, Covers, Settings, Automations... ${this.makeDropdown("Icon","icon")} ${this.makeVersion()}
`;if("horizontal-buttons-stack"===this._config.card_type){if(!this.buttonAdded&&this.shadowRoot.querySelector("#add-button")){const t=this.shadowRoot.querySelector("#add-button");for(this.buttonIndex=0;this._config[this.buttonIndex+1+"_name"];)this.buttonIndex++;t.addEventListener("click",(()=>{this.buttonIndex++,fireEvent(this,"config-changed",{config:this._config})})),this.buttonAdded=!0}return fireEvent(this,"config-changed",{config:this._config}),html`
${this.makeDropdown("Card type","card_type",n)} This card is the companion to the pop-up card, allowing you to open the corresponding pop-ups. It also allows you to open any page of your dashboard. In addition, you can add your motion sensors so that the order of the buttons adapts according to the room you just entered. This card is scrollable, remains visible and acts as a footer.

Please note that this card may take some time to load in edit mode.
${this.makeButton()}
${this.makeVersion()}
`}return"cover"===this._config.card_type?html`
${this.makeDropdown("Card type","card_type",n)} This card allows you to control your covers. ${this.makeDropdown("Entity","entity",e)} ${this.makeDropdown("Open icon","icon_open")} ${this.makeDropdown("Closed icon","icon_close")} ${this.makeVersion()}
`:"empty-column"===this._config.card_type?html`
${this.makeDropdown("Card type","card_type",n)} Just an empty card to fill any empty column. ${this.makeVersion()}
`:this._config.card_type?void 0:html`
${this.makeDropdown("Card type","card_type",n)} You need to add a card type first. ${this.makeVersion()}
`}makeDropdown(t,e,n){this.hass;return"Icon"===t||"Open icon"===t||"Closed icon"===t?html`
`:html`
`}makeButton(){let t=[];for(let e=1;e<=this.buttonIndex;e++)t.push(html`
this.removeButton(e)}> Button ${e}
`);return fireEvent(this,"config-changed",{config:this._config}),t}makeVersion(){return html`

Bubble Card ${version}

`}removeButton(t){delete this._config[t+"_name"],delete this._config[t+"_icon"],delete this._config[t+"_link"],delete this._config[t+"_entity"],delete this._config[t+"_pir_sensor"];for(let e=t;e{fireEvent(window,"haptic",t)},o=(t,e,o,a)=>{if(!a.confirmation||a.confirmation.exemptions&&a.confirmation.exemptions.some((t=>t.user===e.user.id))||(i("warning"),confirm(a.confirmation.text||`Are you sure you want to ${a.action}?`)))switch(a.action){case"more-info":(this.config.entity||this.config.camera_image)&&fireEvent(t,"hass-more-info",{entityId:this.config.entity?this.config.entity:this.config.camera_image});break;case"navigate":a.navigation_path&&((t,e,n=!1)=>{n?history.replaceState(null,"",e):history.pushState(null,"",e),fireEvent(window,"location-changed",{replace:n})})(0,a.navigation_path);break;case"url":a.url_path&&window.open(a.url_path);break;case"toggle":this.config.entity&&(n(this.config.entity),i("success"));break;case"call-service":{if(!a.service)return void i("failure");const[t,n]=a.service.split(".",2);e.callService(t,n,a.service_data,a.target),i("success");break}case"fire-dom-event":fireEvent(t,"ll-custom",a)}},a=(t,e,n,i)=>{let a;"double_tap"===i&&this.config.double_tap_action?a=this.config.double_tap_action:"hold"===i&&this.config.hold_action?a=this.config.hold_action:"tap"===i&&this.config.tap_action?a=this.config.tap_action:"double_tap"!==i||this.config.double_tap_action?("hold"!==i||this.config.hold_action)&&("tap"!==i||this.config.tap_action)||(a={action:"more-info"}):a={action:"toggle"},o(t,e,0,a)},r=function(){let e,n;return function(i,o,r,s){r.addEventListener(i,(()=>{const o=(new Date).getTime();"click"===i?o-(n||0)<250?(clearTimeout(e),a(s,t,0,"double_tap")):e=setTimeout((()=>{a(s,t,0,"tap")}),250):a(s,t,0,"hold"),n=o}))}}();function s(t,e){r("click","tap",e,t),r("contextmenu","hold",e,t)}const c=this.config.styles?this.config.styles:"";if("pop-up"!==this.config.card_type||this.getRootNode().host){if("pop-up"===this.config.card_type){this.popUp||(this.card.style.marginTop="0",this.popUp=this.getRootNode().querySelector("#root"));const d=this.config.hash,l=this.popUp,h=this.config.entity||"",p=this.config.icon||"",u=this.config.name||"",g=this.config.state_unit||"",f=this.config.state?t.states[this.config.state].state+g:"",m=this.config.margin_top_mobile&&"0"!==this.config.margin_top_mobile?this.config.margin_top_mobile:"0px",b=this.config.margin_top_desktop&&"0"!==this.config.margin_top_desktop?this.config.margin_top_desktop:"0px",v=this.config.width_desktop||"600px",_=this.config.is_sidebar_hidden||"false",y=v.match(/(\d+)(\D+)/),x=this.config.entity?"flex":"none";if(!this.headerAdded){const E=document.createElement("div");E.setAttribute("id","header-container");const L=document.createElement("div");E.appendChild(L);const S=document.createElement("ha-icon");S.setAttribute("class","header-icon"),S.setAttribute("icon",p),L.appendChild(S),s(this,S);const A=document.createElement("h2");A.textContent=u,L.appendChild(A);const T=document.createElement("p");T.textContent=f,L.appendChild(T);const z=document.createElement("ha-icon");z.setAttribute("class","power-button"),z.setAttribute("icon","mdi:power"),z.setAttribute("style",`display: ${x};`),L.appendChild(z);const V=document.createElement("button");V.setAttribute("class","close-pop-up"),V.setAttribute("onclick","history.replaceState(null, null, location.href.split('#')[0]);"),E.appendChild(V);const I=document.createElement("ha-icon");I.setAttribute("icon","mdi:close"),V.appendChild(I),this.content.appendChild(E),this.header=L,this.headerAdded=!0}if(this.headerAdded){const H=this.content.querySelector("#header-container .header-icon");H.setAttribute("icon",p),this.haIcon1=H;this.content.querySelector("#header-container h2").textContent=u;this.content.querySelector("#header-container p").textContent=f;this.content.querySelector("#header-container .power-button").setAttribute("style",`display: ${x};`)}if(!this.eventAdded){let q,D;["click","touchend","popstate"].forEach((t=>{window["checkHashRef_"+d]&&window.removeEventListener(t,window["checkHashRef_"+d]),window["checkHashRef_"+d]=k,window.addEventListener(t,window["checkHashRef_"+d])})),this.content.querySelector(".power-button").addEventListener("click",(()=>{n(h)})),document.addEventListener("mousedown",(function(t){location.hash!==d||t.composedPath().some((t=>"HA-MORE-INFO-DIALOG"===t.nodeName))||t.composedPath().some((t=>"root"===t.id&&!t.classList.contains("close-pop-up")))||history.replaceState(null,null,location.href.split("#")[0])})),window.addEventListener("keydown",(function(t){"Escape"===t.key&&history.replaceState(null,null,location.href.split("#")[0])})),l.addEventListener("touchstart",(function(t){q=t.touches[0].clientY,D=q})),l.addEventListener("touchmove",(function(t){t.touches[0].clientY-q>300&&t.touches[0].clientY>D&&history.replaceState(null,null,location.href.split("#")[0]),D=t.touches[0].clientY})),this.eventAdded=!0}if(""!==h){const B=t.states[h].attributes.rgb_color,M=B?`rgba(${B[0]}, ${B[1]}, ${B[2]}, 0.5)`:"off"!==t.states[h].state?"var(--accent-color)":"var(--background-color,var(--secondary-background-color))";this.header.style.backgroundColor=M}function k(t){location.hash===d?w():l.classList.contains("open-pop-up")&&$()}function w(){l.classList.remove("close-pop-up"),l.classList.add("open-pop-up")}function $(){l.classList.remove("open-pop-up"),l.classList.add("close-pop-up")}const C=`\n ${c}\n #header-container {\n display: inline-flex;\n width: 100%;\n margin: 0;\n padding: 0;\n }\n #header-container > div {\n display: inline-flex;\n align-items: center;\n position: relative;\n padding: 6px;\n z-index: 2;\n flex-grow: 1;\n background-color: var(--background-color,var(--secondary-background-color));\n transition: background 1s;\n border-radius: 25px;\n margin-right: 14px;\n }\n .header-icon {\n display: inline-flex;\n width: 22px;\n height: 22px;\n padding: 8px;\n background-color: var(--card-background-color,var(--ha-card-background));\n border-radius: 100%;\n margin: 0 10px 0 0;\n cursor: ${this.config.entity||this.config.double_tap_action||this.config.tap_action||this.config.hold_action?"pointer":"default"}; \n }\n #header-container h2 {\n display: inline-flex;\n margin: 0 18px 0 0;\n /*line-height: 0px;*/\n z-index: 100;\n font-size: 20px;\n }\n #header-container p {\n display: inline-flex;\n line-height: 0px;\n font-size: 16px;\n }\n .power-button {\n cursor: pointer; \n flex-grow: inherit; \n width: 24px;\n height: 24px;\n border-radius: 12px;\n margin: 0 10px;\n background: none !important;\n justify-content: flex-end;\n background-color: var(--background-color,var(--secondary-background-color));\n }\n .close-pop-up {\n height: 50px;\n width: 50px;\n border: none;\n border-radius: 50%;\n z-index: 2;\n background: var(--background-color,var(--secondary-background-color));\n color: var(--primary-text-color);\n flex-shrink: 0;\n cursor: pointer;\n }\n `;if(this.styleAdded||!0===this.editor){if(!0===this.editor){const Y=this.getRootNode().querySelector("#root").querySelector("style");Y&&l.removeChild(Y),l.style.backgroundColor="var(--ha-card-background,var(--card-background-color))",l.style.padding="16px",l.style.borderRadius="42px",l.style.gridGap="12px",l.style.gap="12px";const O=document.createElement("style");O.innerHTML=C,this.content.appendChild(O),this.styleAdded=!1}}else{const R=document.createElement("style"),X=document.createElement("style"),j=`\n ${c}\n ha-card {\n margin-top: 0 !important;\n background: none !important;\n border: none !important;\n }\n .card-content {\n width: 100% !important;\n padding: 0 !important;\n }\n #root {\n position: fixed !important;\n margin: 0 -7px;\n width: calc(100% - 38px);\n background-color: var(--ha-card-background,var(--card-background-color));\n border-radius: 42px;\n top: calc(100% + ${m} + 54px); /*136px*/\n grid-gap: 12px !important;\n gap: 12px !important;\n grid-auto-rows: min-content;\n padding: 18px 18px 220px 18px !important;\n height: calc(100% - 240px) !important;\n -ms-overflow-style: none; /* for Internet Explorer, Edge */\n scrollbar-width: none; /* for Firefox */\n overflow-y: auto; \n overflow-x: hidden; \n z-index: 1 !important; /* Higher value hide the more-info panel */\n /* For older Safari but not working with Firefox */\n /* display: grid !important; */ \n }\n #root > bubble-card:first-child::after {\n content: '';\n display: block;\n position: sticky;\n top: 0;\n left: -50px;\n margin: -70px 0 -35px 0;\n width: 200%;\n height: 100px;\n background: linear-gradient(0deg, rgba(79, 69, 87, 0) 0%, var(--ha-card-background,var(--card-background-color)) 80%);\n z-index: 0;\n }\n #root::-webkit-scrollbar {\n display: none; /* for Chrome, Safari, and Opera */\n }\n #root > bubble-card:first-child {\n position: sticky;\n top: 0;\n z-index: 5;\n background: none !important;\n }\n #root.open-pop-up {\n transform: translateY(-100%);\n transition: transform .4s !important;\n }\n #root.open-pop-up > * {\n /* Block child items to overflow and if they do clip them */\n max-width: calc(100vw - 38px);\n overflow-x: clip;\n }\n #root.close-pop-up { \n transform: translateY(0%);\n transition: transform .4s !important;\n /* animation: hide 1s forwards; */\n }\n @media only screen and (min-width: 768px) {\n #root {\n top: calc(100% + ${b} + 54px);\n width: calc(${v} - 36px) !important;\n left: calc(50% - ${y[1]/2}${y[2]});\n margin: 0 !important;\n }\n } \n @media only screen and (min-width: 870px) {\n #root {\n top: calc(100% + ${b} + 54px);\n width: calc(${v} - ${!0===_?"0px":"92px"}) !important; \n left: calc(50% - ${y[1]/2}${y[2]} + ${!0===_?"0px":"56px"});\n margin: 0 !important;\n }\n } \n `;R.innerHTML=j,X.innerHTML=C,l.appendChild(R),this.content.appendChild(X),this.styleAdded=!0}}}else!0!==this.editor&&(this.card.style.marginTop="2000px");if("horizontal-buttons-stack"===this.config.card_type){const F=(t,e,n)=>{const i=document.createElement("button");return i.setAttribute("onclick",`window.location.href='${e}';`),i.setAttribute("class","button"),i.innerHTML=`\n

${t}

\n `,i},W=(e,n)=>{if(t.states[n].attributes.rgb_color){const i=t.states[n].attributes.rgb_color,o=`rgba(${i[0]}, ${i[1]}, ${i[2]}, 0.5)`;e.style.backgroundColor=o,e.style.border="1px solid rgba(0,0,0,0)"}else t.states[n].attributes.rgb_color||"on"!=t.states[n].state?(e.style.backgroundColor="rgba(0,0,0,0)",e.style.border="1px solid var(--primary-text-color)"):(e.style.backgroundColor="rgba(255,255,255,0.5)",e.style.border="1px solid rgba(0,0,0,0)")};if(!this.buttonsAdded){const N=document.createElement("div");N.setAttribute("class","horizontal-buttons-stack-container"),this.content.appendChild(N)}if((()=>{let e=[],n=1;for(;this.config[n+"_name"];){const t=n+"_",i=this.config[t+"name"],o=this.config[t+"pir_sensor"],a=this.config[t+"icon"],r=this.config[t+"link"],s=this.config[t+"entity"];e.push({button:i,pirSensor:o,icon:a,link:r,lightEntity:s}),n++}if(this.config.auto_order&&e.sort(((e,n)=>{if(e.pirSensor&&n.pirSensor){if("on"===t.states[e.pirSensor].state&&"on"===t.states[n.pirSensor].state){return t.states[e.pirSensor].last_updated{const i=F(e.button,e.link,e.icon);n[e.link]=i,t.appendChild(i)})),this.buttonsAdded=!0,this.buttons=n}let i=0;e.forEach(((t,e)=>{let n=this.buttons[t.link];if(n){let e=localStorage.getItem(`buttonWidth-${t.link}`),o=localStorage.getItem(`buttonContent-${t.link}`);e&&"0"!==e&&o===n.innerHTML&&!0!==this.editor||(e=n.offsetWidth,localStorage.setItem(`buttonWidth-${t.link}`,e),localStorage.setItem(`buttonContent-${t.link}`,n.innerHTML)),n.style.transform=`translateX(${i}px)`,i+=parseInt(e)+12}t.lightEntity&&W(n,t.lightEntity)}))})(),!this.styleAdded){const P=document.createElement("style"),U=`\n ${c}\n .horizontal-buttons-stack {\n width: 100%;\n margin-top: 0 !important;\n background: none !important;\n position: fixed;\n height: 51px;\n bottom: 16px;\n /* transform: translateY(200px); */\n /* animation: from-bottom 1.3s forwards; */\n z-index: 1 !important; /* Higher value hide the more-info panel */\n }\n @keyframes from-bottom {\n 0% {transform: translateY(200px);}\n 20% {transform: translateY(200px);}\n 46% {transform: translateY(-8px);}\n 56% {transform: translateY(1px);}\n 62% {transform: translateY(-2px);}\n 70% {transform: translateY(0);}\n 100% {transform: translateY(0);}\n }\n .horizontal-buttons-stack-container {\n width: max-content;\n position: relative;\n height: 51px;\n }\n .button {\n display: flex;\n position: absolute;\n box-sizing: border-box;\n border: 1px solid var(--primary-text-color);\n align-items: center;\n height: 50px;\n white-space: nowrap;\n width: auto;\n border-radius: 25px;\n z-index: 2;\n padding: 16px;\n transition: background-color 1s, border 1s, transform 1s;\n color: var(--primary-text-color);\n }\n .icon {\n height: 24px;\n margin-right: 8px;\n }\n .card-content {\n width: 100%;\n box-sizing: border-box;\n margin: 0 -36px !important;\n padding: 0 36px !important;\n overflow: scroll !important;\n -ms-overflow-style: none;\n scrollbar-width: none;\n mask-image: linear-gradient(90deg, transparent 2%, rgba(0, 0, 0, 1) 6%, rgba(0, 0, 0, 1) 96%, transparent 100%);\n -webkit-mask-image: linear-gradient(90deg, transparent 2%, rgba(0, 0, 0, 1) 6%, rgba(0, 0, 0, 1) 96%, transparent 100%);\n }\n .horizontal-buttons-stack::before {\n content: '';\n position: absolute;\n top: -32px;\n left: -100%;\n display: block;\n background: linear-gradient(0deg, var(--background-color, var(--primary-background-color)) 50%, rgba(79, 69, 87, 0));\n width: 200%;\n height: 100px;\n }\n .card-content::-webkit-scrollbar {\n display: none;\n }\n @media only screen and (min-width: 768px) {\n .card-content {\n position: fixed;\n width: 538px !important;\n left: calc(50% - 246px);\n padding: 0 26px !important;\n }\n }\n @media only screen and (min-width: 870px) {\n .card-content {\n position: fixed;\n width: 538px !important;\n left: calc(50% - 218px);\n padding: 0 26px !important;\n }\n }\n `;P.innerHTML=U,this.card.classList.add("horizontal-buttons-stack"),this.content.querySelector(".horizontal-buttons-stack-container").appendChild(P),this.styleAdded=!0}if(!0===this.editor){if(!this.editorStyleAdded){const G=document.createElement("style"),J=`\n ${c}\n .horizontal-buttons-stack {\n position: relative;\n height: 51px;\n bottom: 0px;\n overflow: hidden;\n }\n .horizontal-buttons-stack::before {\n top: -32px;\n left: -100%;\n background: none;\n width: 100%;\n height: 0;\n }\n .card-content {\n position: relative;\n mask-image: linear-gradient(90deg, transparent 2%, rgba(0, 0, 0, 1) 6%, rgba(0, 0, 0, 1) 96%, transparent 100%);\n -webkit-mask-image: linear-gradient(90deg, transparent 2%, rgba(0, 0, 0, 1) 6%, rgba(0, 0, 0, 1) 96%, transparent 100%);\n }\n @media only screen and (min-width: 870px) {\n .card-content {\n left: calc(50% - 230px);\n }\n }\n `;G.innerHTML=J,this.card.appendChild(G),this.editorStyleAdded=!0}}else if(this.card.querySelector("ha-card > style")){const Z=this.card.querySelector("ha-card > style");this.card.removeChild(Z)}}if("button"===this.config.card_type){if(!this.buttonAdded){const _t=document.createElement("div");_t.setAttribute("class","button-container"),this.content.appendChild(_t)}const K=this.config.entity,Q=this.config.icon?this.config.icon:t.states[K].attributes.icon||"",tt=this.config.name?this.config.name:t.states[K].attributes.friendly_name||"",et=this.config.button_type||"switch",nt=K?t.states[K].state:"";let it=K?t.states[K].attributes.brightness||0:"",ot=K?t.states[K].attributes.volume_level||0:"";const at=document.createElement("div");at.setAttribute("class","icon-container"),this.iconContainer=at;const rt=document.createElement("div");rt.setAttribute("class","nameContainer");const st=document.createElement("div");st.setAttribute("class","switch-button");const ct=document.createElement("div");ct.setAttribute("class","range-slider");const dt=document.createElement("div");dt.setAttribute("class","range-fill"),K&&K.startsWith("light.")&&"slider"===et?dt.style.transform=`translateX(${it/255*100}%)`:K&&K.startsWith("media_player.")&&"slider"===et&&(dt.style.transform=`translateX(${100*ot}%)`),this.buttonContainer||(this.buttonContainer=this.content.querySelector(".button-container"),"slider"!==et||this.buttonAdded?"switch"!==et&&"custom"!==et||(this.buttonContainer.appendChild(st),st.appendChild(at),st.appendChild(rt),this.switchButton=this.content.querySelector(".switch-button")):(this.buttonContainer.appendChild(ct),ct.appendChild(at),ct.appendChild(rt),ct.appendChild(dt),this.rangeFill=this.content.querySelector(".range-fill")),at.innerHTML=``,rt.innerHTML=`

${tt}

`,this.buttonAdded=!0);let lt=!1,ht=it,pt=ot;function ut(t){let e=t.querySelector(".feedback-element");e||(e=document.createElement("div"),e.setAttribute("class","feedback-element"),t.appendChild(e)),e.style.animation="tap-feedback .5s",setTimeout((()=>{e.style.animation="none",t.removeChild(e)}),500)}function gt(t){t.target!==at.querySelector("ha-icon")&&(lt=!0,vt(t.pageX||t.touches[0].pageX),document.addEventListener("mouseup",ft),document.addEventListener("touchend",ft),document.addEventListener("mousemove",mt),document.addEventListener("touchmove",mt))}function ft(){lt=!1,K.startsWith("light.")?(it=ht,t.callService("light","turn_on",{entity_id:K,brightness:it})):ot!==pt&&K.startsWith("media_player.")&&(ot=pt,t.callService("media_player","volume_set",{entity_id:K,volume_level:ot})),document.removeEventListener("mouseup",ft),document.removeEventListener("touchend",ft),document.removeEventListener("mousemove",mt),document.removeEventListener("touchmove",mt)}function mt(t){lt&&vt(t.pageX||t.touches[0].pageX)}function bt(t,e){if(e.buttonContainer.style.opacity="unavailable"!==t?"1":"0.5","switch"===et||"custom"===et){const n="on"===t?"var(--accent-color)":"rgba(0,0,0,0)";e.switchButton.style.backgroundColor=n}}function vt(t){const e=ct.getBoundingClientRect(),n=Math.min(Math.max(t-e.left,0),e.width)/e.width;K.startsWith("light.")?ht=Math.round(255*n):K.startsWith("media_player.")&&(pt=n),dt.style.transition="none",dt.style.transform=`translateX(${100*n}%)`}if(this.eventAdded||"switch"!==et?this.eventAdded||"slider"!==et?this.eventAdded||"custom"!==et||(st.addEventListener("click",(()=>ut(this.switchButton))),s(this,this.switchButton),this.eventAdded=!0):(ct.addEventListener("mousedown",gt),ct.addEventListener("touchstart",gt),s(this,this.iconContainer),this.eventAdded=!0):(st.addEventListener("click",(()=>ut(this.switchButton))),st.addEventListener("click",(function(t){t.target.closest("ha-icon")||n(K)})),s(this,this.iconContainer),this.eventAdded=!0),this.isDragging||"slider"!==et||(this.rangeFill.style.transition="all .2s",K.startsWith("light.")?this.rangeFill.style.transform=`translateX(${it/255*100}%)`:K.startsWith("media_player.")&&(this.rangeFill.style.transform=`translateX(${100*ot}%)`)),bt(nt,this),"slider"===et){const yt=t.states[K].attributes.rgb_color,xt=yt?`rgba(${yt[0]}, ${yt[1]}, ${yt[2]}, 0.5)`:"rgba(255, 255, 255, 0.5)";dt.style.backgroundColor=xt,this.rangeFill.style.backgroundColor=xt}if(!this.styleAdded){const kt=document.createElement("style"),wt=`\n ${c}\n ha-card {\n margin-top: 0 !important;\n background: none !important;\n }\n \n .button-container {\n position: relative;\n width: 100%;\n height: 50px;\n z-index: 0;\n background-color: var(--background-color-2,var(--secondary-background-color));\n border-radius: 25px;\n mask-image: radial-gradient(white, black);\n -webkit-mask-image: radial-gradient(white, black);\n -webkit-backface-visibility: hidden;\n -moz-backface-visibility: hidden;\n -webkit-transform: translateZ(0);\n overflow: hidden;\n }\n \n .switch-button,\n .range-slider {\n display: inline-flex;\n position: absolute;\n height: 100%;\n width: 100%;\n transition: background-color 1.5s;\n }\n \n .range-fill {\n position: absolute;\n top: 0;\n bottom: 0;\n left: 0;\n }\n \n .switch-button {\n cursor: pointer !important;\n }\n \n .range-slider {\n cursor: ew-resize;\n }\n \n .range-fill {\n z-index: 1;\n width: 100%;\n left: -100%;\n }\n \n .icon-container {\n position: absolute;\n z-index: 2;\n width: 38px;\n height: 38px;\n margin: 6px;\n border-radius: 50%;\n background-color: var(--card-background-color,var(--ha-card-background));\n }\n \n ha-icon {\n display: flex;\n position: absolute;\n margin: inherit;\n padding: 1px 2px;\n width: 22px; \n height: 22px;\n cursor: pointer !important;\n }\n \n .nameContainer {\n position: relative;\n display: inline-flex;\n margin-left: 58px;\n z-index: 2;\n font-weight: 600;\n align-items: center;\n }\n \n .nameContainer p {\n display: inline-flex;\n }\n \n .feedback-element {\n position: absolute;\n top: 0;\n left: 0;\n opacity: 0;\n width: 100%;\n height: 100%;\n background-color: rgb(0,0,0);\n }\n \n @keyframes tap-feedback {\n 0% {transform: translateX(-100%); opacity: 0;}\n 64% {transform: translateX(0); opacity: 0.1;}\n 100% {transform: translateX(100%); opacity: 0;}\n }\n `;kt.innerHTML=wt,this.content.appendChild(kt),this.styleAdded=!0}}if("separator"===this.config.card_type){const $t=this.config.icon?this.config.icon:"",Ct=this.config.name?this.config.name:"";if(!this.separatorAdded){const Et=document.createElement("div");if(Et.setAttribute("class","separator-container"),Et.innerHTML=`\n
\n \n

${Ct}

\n
\n
\n `,this.content.appendChild(Et),this.separatorAdded=!0,!this.styleAdded){const Lt=document.createElement("style"),St=`\n ${c}\n .separator-container {\n display: inline-flex;\n width: 100%;\n }\n .separator-container div:first-child {\n display: inline-flex;\n max-width: calc(100% - 38px);\n }\n .separator-container div ha-icon{\n display: inline-flex;\n height: 24px;\n width: 24px;\n margin: 0 20px 0 8px;\n transform: translateY(-2px);\n }\n .separator-container div h4{\n display: inline-flex;\n margin: 0 20px 0 0;\n font-size: 17px;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n }\n .separator-container div:last-child{\n display: inline-flex; \n border-radius: 6px; \n opacity: 0.3; \n margin-left: 10px; \n flex-grow: 1; \n height: 6px; \n align-self: center; \n background-color: var(--background-color,var(--secondary-background-color));\n `;Lt.innerHTML=St,this.content.appendChild(Lt),this.styleAdded=!0}}}if("cover"===this.config.card_type){const At=this.config.entity,Tt=this.config.icon_open?this.config.icon_open:"mdi:window-shutter-open",zt=this.config.icon_close?this.config.icon_close:"mdi:window-shutter",Vt="open"===t.states[this.config.entity].state?Tt:zt,It=this.config.name?this.config.name:t.states[entityId].attributes.friendly_name||"",Ht=this.config.open_service?this.config.open_service:"cover.open_cover",qt=this.config.close_service?this.config.close_service:"cover.close_cover",Dt=this.config.stop_service?this.config.stop_service:"cover.stop_cover";if(!this.coverAdded){const Bt=document.createElement("div");Bt.setAttribute("class","cover-container"),Bt.innerHTML=`\n
\n
\n
\n

${It}

\n
\n
\n \n \n \n
\n `,this.content.appendChild(Bt);const Mt=Bt.querySelector(".open"),Yt=Bt.querySelector(".stop"),Ot=Bt.querySelector(".close");Mt.addEventListener("click",(()=>{t.callService(Ht.split(".")[0],Ht.split(".")[1],{entity_id:At})})),Yt.addEventListener("click",(()=>{t.callService(Dt.split(".")[0],Dt.split(".")[1],{entity_id:At})})),Ot.addEventListener("click",(()=>{t.callService(qt.split(".")[0],qt.split(".")[1],{entity_id:At})}));s(this,this.content.querySelector(".icon-container")),this.coverAdded=!0}if(this.content.querySelector(".icon-container").innerHTML=``,!this.styleAdded){const Rt=document.createElement("style"),Xt=`\n ${c}\n ha-card {\n margin-top: 0 !important;\n background: none !important;\n }\n \n .header-container {\n display: flex;\n align-items: center;\n margin-bottom: 10px;\n }\n \n .name {\n display: inline-block; \n margin-left: 10px;\n font-weight: 600;\n }\n \n .cover-container {\n display: grid;\n }\n \n .icon-container {\n display: flex;\n margin: 0 !important;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n z-index: 2;\n width: 48px;\n height: 48px;\n margin: 6px;\n border-radius: 50%;\n background-color: var(--card-background-color,var(--ha-card-background));\n border: 6px solid var(--background-color-2,var(--secondary-background-color));\n box-sizing: border-box;\n }\n \n .buttons-container {\n display: grid;\n align-self: center;\n grid-auto-flow: column;\n grid-gap: 18px; \n }\n \n ha-icon {\n display: flex; \n height: 24px; \n width: 24px; \n color: var(--primary-text-color);\n }\n \n .button {\n display: flex;\n background: var(--background-color-2,var(--secondary-background-color));\n height: 42px;\n border-radius: 32px;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n border: none;\n }\n `;Rt.innerHTML=Xt,this.content.appendChild(Rt),this.styleAdded=!0}}if("empty-column"===this.config.card_type&&!this.emptyCollumnAdded){const jt=document.createElement("div");jt.setAttribute("class","empty-column"),jt.innerHTML='\n
\n
\n ',this.content.appendChild(jt),this.emptyColumnAdded=!0}}setConfig(t){if("pop-up"===t.card_type){if(!t.hash)throw new Error("You need to define an hash");if(!t.icon)throw new Error("You need to define an icon");if(!t.name)throw new Error("You need to define a name")}else if(("button"===t.card_type||"cover"===t.card_type)&&!t.entity)throw new Error("You need to define an entity");this.config=t}getCardSize(){return 1}static getConfigElement(){return document.createElement("bubble-card-editor")}}console.info(`%c Bubble Card %c ${version} `,"background-color: #555;color: #fff;padding: 3px 2px 3px 3px;border-radius: 14px 0 0 14px;font-family: DejaVu Sans,Verdana,Geneva,sans-serif;text-shadow: 0 1px 0 rgba(1, 1, 1, 0.3)","background-color: #506eac;color: #fff;padding: 3px 3px 3px 2px;border-radius: 0 14px 14px 0;font-family: DejaVu Sans,Verdana,Geneva,sans-serif;text-shadow: 0 1px 0 rgba(1, 1, 1, 0.3)"),customElements.define("bubble-card",BubbleCard);const fireEvent=(t,e,n,i)=>{i=i||{},n=null==n?{}:n;const o=new Event(e,{bubbles:void 0===i.bubbles||i.bubbles,cancelable:Boolean(i.cancelable),composed:void 0===i.composed||i.composed});return o.detail=n,t.dispatchEvent(o),o};customElements.get("ha-switch");const LitElement=Object.getPrototypeOf(customElements.get("ha-panel-lovelace")),html=LitElement.prototype.html,css=LitElement.prototype.css;class BubbleCardEditor extends LitElement{setConfig(t){this._config={...t}}static get properties(){return{hass:{},_config:{}}}get _card_type(){return this._config.card_type||""}get _button_type(){return this._config.button_type||"switch"}get _entity(){return this._config.entity||""}get _name(){return this._config.name||""}get _icon(){return this._config.icon||""}get _state(){return this._config.state||""}get _state_unit(){return this._config.state_unit||""}get _hash(){return this._config.hash||"#pop-up-name"}get _margin_top_mobile(){return this._config.margin_top_mobile||"0px"}get _margin_top_desktop(){return this._config.margin_top_desktop||"0px"}get _width_desktop(){return this._config.width_desktop||"600px"}get _is_sidebar_hidden(){return this._config.is_sidebar_hidden||!1}get _icon_open(){return this._config.icon_open||""}get _icon_close(){return this._config.icon_close||""}get _open_service(){return this._config.open_service||"cover.open_cover"}get _close_service(){return this._config.open_service||"cover.close_cover"}get _stop_service(){return this._config.open_service||"cover.stop_cover"}get _auto_order(){return this._config.auto_order||!1}render(){if(!this.hass)return html``;if(!this.listsUpdated){const t=t=>({label:t,value:t});this.allEntitiesList=Object.keys(this.hass.states).map(t),this.lightList=Object.keys(this.hass.states).filter((t=>"light"===t.substr(0,t.indexOf(".")))).map(t),this.sensorList=Object.keys(this.hass.states).filter((t=>"sensor"===t.substr(0,t.indexOf(".")))).map(t),this.binarySensorList=Object.keys(this.hass.states).filter((t=>"binary_sensor"===t.substr(0,t.indexOf(".")))).map(t),this.coverList=Object.keys(this.hass.states).filter((t=>"cover"===t.substr(0,t.indexOf(".")))).map(t),this.cardTypeList=[{label:"Button",value:"button"},{label:"Cover",value:"cover"},{label:"Empty column",value:"empty-column"},{label:"Horizontal buttons stack",value:"horizontal-buttons-stack"},{label:"Pop-up",value:"pop-up"},{label:"Separator",value:"separator"}],this.buttonTypeList=[{label:"Switch",value:"switch"},{label:"Slider",value:"slider"}],this.listsUpdated=!0}const t=this.allEntitiesList,e=(this.lightList,this.sensorList,this.coverList),n=this.cardTypeList,i=this.buttonTypeList;if("pop-up"===this._config.card_type)return html`
${this.makeDropdown("Card type","card_type",n)} This card allows you to convert any vertical-stack into a pop-up. Each pop-up can be opened by targeting its link (e.g. '#pop-up-name'), with navigation_path or with the horizontal buttons stack that is included.

It must be placed within a vertical-stack card at the top most position to function properly.
${this.makeDropdown("Icon","icon")} ${this.makeDropdown("Entity to toggle (e.g. room light group)","entity",t)} ${this.makeDropdown("Entity state to display (e.g. room temperature)","state",t)}
${this.makeVersion()}
`;if("button"===this._config.card_type)return html`
${this.makeDropdown("Card type","card_type",n)} This card can be a slider or a button, allowing you to toggle your entities, control the brightness of your lights and the volume of your media players. To access color / control of an entity, simply tap on the icon. ${this.makeDropdown("slider"!==this._button_type?"Entity (toggle)":"Entity (light or media_player)","entity",t)} ${this.makeDropdown("Button type","button_type",i)} ${this.makeDropdown("Icon","icon")} ${this.makeVersion()}
`;if("separator"===this._config.card_type)return html`
${this.makeDropdown("Card type","card_type",n)} This card is a simple separator for dividing your pop-up into categories / sections. e.g. Lights, Devices, Covers, Settings, Automations... ${this.makeDropdown("Icon","icon")} ${this.makeVersion()}
`;if("horizontal-buttons-stack"===this._config.card_type){if(!this.buttonAdded&&this.shadowRoot.querySelector("#add-button")){const t=this.shadowRoot.querySelector("#add-button");for(this.buttonIndex=0;this._config[this.buttonIndex+1+"_name"];)this.buttonIndex++;t.addEventListener("click",(()=>{this.buttonIndex++,fireEvent(this,"config-changed",{config:this._config})})),this.buttonAdded=!0}return fireEvent(this,"config-changed",{config:this._config}),html`
${this.makeDropdown("Card type","card_type",n)} This card is the companion to the pop-up card, allowing you to open the corresponding pop-ups. It also allows you to open any page of your dashboard. In addition, you can add your motion sensors so that the order of the buttons adapts according to the room you just entered. This card is scrollable, remains visible and acts as a footer.

Please note that this card may take some time to load in edit mode.
${this.makeButton()}
${this.makeVersion()}
`}return"cover"===this._config.card_type?html`
${this.makeDropdown("Card type","card_type",n)} This card allows you to control your covers. ${this.makeDropdown("Entity","entity",e)} ${this.makeDropdown("Open icon","icon_open")} ${this.makeDropdown("Closed icon","icon_close")} ${this.makeVersion()}
`:"empty-column"===this._config.card_type?html`
${this.makeDropdown("Card type","card_type",n)} Just an empty card to fill any empty column. ${this.makeVersion()}
`:this._config.card_type?void 0:html`
${this.makeDropdown("Card type","card_type",n)} You need to add a card type first. ${this.makeVersion()}
`}makeDropdown(t,e,n){this.hass;return"Icon"===t||"Open icon"===t||"Closed icon"===t?html`
`:html`
`}makeButton(){let t=[];for(let e=1;e<=this.buttonIndex;e++)t.push(html`
this.removeButton(e)}> Button ${e}
`);return fireEvent(this,"config-changed",{config:this._config}),t}makeVersion(){return html`

Bubble Card ${version}

`}removeButton(t){delete this._config[t+"_name"],delete this._config[t+"_icon"],delete this._config[t+"_link"],delete this._config[t+"_entity"],delete this._config[t+"_pir_sensor"];for(let e=t;e