diff --git a/README.md b/README.md index 544cc4c..7ea6a77 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,8 @@ # slider-card +If you find the project useful, please consider starring the repository :) + +[![stars - my-cards](https://img.shields.io/github/stars/AnthonMS/my-cards?style=social)](https://github.com/AnthonMS/my-cards) +[![forks - my-cards](https://img.shields.io/github/forks/AnthonMS/my-cards?style=social)](https://github.com/AnthonMS/my-cards) ## Update Notes diff --git a/dist/dev/my-cards.js b/dist/dev/my-cards.js index f06e3dd..14a2a12 100644 --- a/dist/dev/my-cards.js +++ b/dist/dev/my-cards.js @@ -1,4 +1,4 @@ -var t={version:"Version",invalid_configuration:"Invalid configuration",show_warning:"Show Warning",show_error:"Show Error"},e={common:t},i={version:"Versjon",invalid_configuration:"Ikke gyldig konfiguration",show_warning:"Vis advarsel"},s={common:i};const o={en:Object.freeze({__proto__:null,common:t,default:e}),nb:Object.freeze({__proto__:null,common:i,default:s})};function n(t,e="",i=""){const s=(localStorage.getItem("selectedLanguage")||"en").replace(/['"]+/g,"").replace("-","_");let n;try{n=t.split(".").reduce((t,e)=>t[e],o[s])}catch(e){n=t.split(".").reduce((t,e)=>t[e],o.en)}return void 0===n&&(n=t.split(".").reduce((t,e)=>t[e],o.en)),""!==e&&""!==i&&(n=n.replace(e,i)),n} +const t=(e=["unavailable","unknown"],(t,i)=>e.includes(t,i));var e,i={version:"Version",invalid_configuration:"Invalid configuration",show_warning:"Show Warning",show_error:"Show Error"},n={common:i},s={version:"Versjon",invalid_configuration:"Ikke gyldig konfiguration",show_warning:"Vis advarsel"},o={common:s};const r={en:Object.freeze({__proto__:null,common:i,default:n}),nb:Object.freeze({__proto__:null,common:s,default:o})};function a(t,e="",i=""){const n=(localStorage.getItem("selectedLanguage")||"en").replace(/['"]+/g,"").replace("-","_");let s;try{s=t.split(".").reduce((t,e)=>t[e],r[n])}catch(e){s=t.split(".").reduce((t,e)=>t[e],r.en)}return void 0===s&&(s=t.split(".").reduce((t,e)=>t[e],r.en)),""!==e&&""!==i&&(s=s.replace(e,i)),s} /*! ***************************************************************************** Copyright (c) Microsoft Corporation. @@ -12,7 +12,7 @@ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -***************************************************************************** */function r(t,e,i,s){var o,n=arguments.length,r=n<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,s);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(r=(n<3?o(r):n>3?o(e,i,r):o(e,i))||r);return n>3&&r&&Object.defineProperty(e,i,r),r +***************************************************************************** */function l(t,e,i,n){var s,o=arguments.length,r=o<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var a=t.length-1;a>=0;a--)(s=t[a])&&(r=(o<3?s(r):o>3?s(e,i,r):s(e,i))||r);return o>3&&r&&Object.defineProperty(e,i,r),r /** * @license * Copyright (c) 2017 The Polymer Project Authors. All rights reserved. @@ -25,7 +25,7 @@ PERFORMANCE OF THIS SOFTWARE. * 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 - */}const a="undefined"!=typeof window&&null!=window.customElements&&void 0!==window.customElements.polyfillWrapFlushCallback,l=(t,e,i=null)=>{for(;e!==i;){const i=e.nextSibling;t.removeChild(e),e=i}},c=`{{lit-${String(Math.random()).slice(2)}}}`,h=`\x3c!--${c}--\x3e`,d=new RegExp(`${c}|${h}`);class u{constructor(t,e){this.parts=[],this.element=e;const i=[],s=[],o=document.createTreeWalker(e.content,133,null,!1);let n=0,r=-1,a=0;const{strings:l,values:{length:h}}=t;for(;a0;){const e=l[a],i=f.exec(e)[2],s=i.toLowerCase()+"$lit$",o=t.getAttribute(s);t.removeAttribute(s);const n=o.split(d);this.parts.push({type:"attribute",index:r,name:i,strings:n}),a+=n.length-1}}"TEMPLATE"===t.tagName&&(s.push(t),o.currentNode=t.content)}else if(3===t.nodeType){const e=t.data;if(e.indexOf(c)>=0){const s=t.parentNode,o=e.split(d),n=o.length-1;for(let e=0;e{const i=t.length-e.length;return i>=0&&t.slice(i)===e},m=t=>-1!==t.index,g=()=>document.createComment(""),f=/([ \x09\x0a\x0c\x0d])([^\0-\x1F\x7F-\x9F "'>=/]+)([ \x09\x0a\x0c\x0d]*=[ \x09\x0a\x0c\x0d]*(?:[^ \x09\x0a\x0c\x0d"'`<>=]*|"[^"]*|'[^']*))$/;function v(t,e){const{element:{content:i},parts:s}=t,o=document.createTreeWalker(i,133,null,!1);let n=_(s),r=s[n],a=-1,l=0;const c=[];let h=null;for(;o.nextNode();){a++;const t=o.currentNode;for(t.previousSibling===h&&(h=null),e.has(t)&&(c.push(t),null===h&&(h=t)),null!==h&&l++;void 0!==r&&r.index===a;)r.index=null!==h?-1:r.index-l,n=_(s,n),r=s[n]}c.forEach(t=>t.parentNode.removeChild(t))}const y=t=>{let e=11===t.nodeType?0:1;const i=document.createTreeWalker(t,133,null,!1);for(;i.nextNode();)e++;return e},_=(t,e=-1)=>{for(let i=e+1;i{for(;e!==i;){const i=e.nextSibling;t.removeChild(e),e=i}},h=`{{lit-${String(Math.random()).slice(2)}}}`,u=`\x3c!--${h}--\x3e`,g=new RegExp(`${h}|${u}`);class p{constructor(t,e){this.parts=[],this.element=e;const i=[],n=[],s=document.createTreeWalker(e.content,133,null,!1);let o=0,r=-1,a=0;const{strings:l,values:{length:c}}=t;for(;a0;){const e=l[a],i=v.exec(e)[2],n=i.toLowerCase()+"$lit$",s=t.getAttribute(n);t.removeAttribute(n);const o=s.split(g);this.parts.push({type:"attribute",index:r,name:i,strings:o}),a+=o.length-1}}"TEMPLATE"===t.tagName&&(n.push(t),s.currentNode=t.content)}else if(3===t.nodeType){const e=t.data;if(e.indexOf(h)>=0){const n=t.parentNode,s=e.split(g),o=s.length-1;for(let e=0;e{const i=t.length-e.length;return i>=0&&t.slice(i)===e},f=t=>-1!==t.index,_=()=>document.createComment(""),v=/([ \x09\x0a\x0c\x0d])([^\0-\x1F\x7F-\x9F "'>=/]+)([ \x09\x0a\x0c\x0d]*=[ \x09\x0a\x0c\x0d]*(?:[^ \x09\x0a\x0c\x0d"'`<>=]*|"[^"]*|'[^']*))$/;function y(t,e){const{element:{content:i},parts:n}=t,s=document.createTreeWalker(i,133,null,!1);let o=w(n),r=n[o],a=-1,l=0;const c=[];let d=null;for(;s.nextNode();){a++;const t=s.currentNode;for(t.previousSibling===d&&(d=null),e.has(t)&&(c.push(t),null===d&&(d=t)),null!==d&&l++;void 0!==r&&r.index===a;)r.index=null!==d?-1:r.index-l,o=w(n,o),r=n[o]}c.forEach(t=>t.parentNode.removeChild(t))}const b=t=>{let e=11===t.nodeType?0:1;const i=document.createTreeWalker(t,133,null,!1);for(;i.nextNode();)e++;return e},w=(t,e=-1)=>{for(let i=e+1;i(...e)=>{const i=t(...e);return b.set(i,!0),i},S=t=>"function"==typeof t&&b.has(t),x={},C={}; +const x=new WeakMap,S=t=>(...e)=>{const i=t(...e);return x.set(i,!0),i},k=t=>"function"==typeof t&&x.has(t),$={},T={}; /** * @license * Copyright (c) 2017 The Polymer Project Authors. All rights reserved. @@ -53,7 +53,7 @@ const b=new WeakMap,w=t=>(...e)=>{const i=t(...e);return b.set(i,!0),i},S=t=>"fu * subject to an additional IP rights grant found at * http://polymer.github.io/PATENTS.txt */ -class ${constructor(t,e,i){this.__parts=[],this.template=t,this.processor=e,this.options=i}update(t){let e=0;for(const i of this.__parts)void 0!==i&&i.setValue(t[e]),e++;for(const t of this.__parts)void 0!==t&&t.commit()}_clone(){const t=a?this.template.element.content.cloneNode(!0):document.importNode(this.template.element.content,!0),e=[],i=this.template.parts,s=document.createTreeWalker(t,133,null,!1);let o,n=0,r=0,l=s.nextNode();for(;nt}),k=` ${c} `;class M{constructor(t,e,i,s){this.strings=t,this.values=e,this.type=i,this.processor=s}getHTML(){const t=this.strings.length-1;let e="",i=!1;for(let s=0;s-1||i)&&-1===t.indexOf("--\x3e",o+1);const n=f.exec(t);e+=null===n?t+(i?k:h):t.substr(0,n.index)+n[1]+n[2]+"$lit$"+n[3]+c}return e+=this.strings[t],e}getTemplateElement(){const t=document.createElement("template");let e=this.getHTML();return void 0!==T&&(e=T.createHTML(e)),t.innerHTML=e,t}} + */const C=window.trustedTypes&&trustedTypes.createPolicy("lit-html",{createHTML:t=>t}),E=` ${h} `;class P{constructor(t,e,i,n){this.strings=t,this.values=e,this.type=i,this.processor=n}getHTML(){const t=this.strings.length-1;let e="",i=!1;for(let n=0;n-1||i)&&-1===t.indexOf("--\x3e",s+1);const o=v.exec(t);e+=null===o?t+(i?E:u):t.substr(0,o.index)+o[1]+o[2]+"$lit$"+o[3]+h}return e+=this.strings[t],e}getTemplateElement(){const t=document.createElement("template");let e=this.getHTML();return void 0!==C&&(e=C.createHTML(e)),t.innerHTML=e,t}} /** * @license * Copyright (c) 2017 The Polymer Project Authors. All rights reserved. @@ -79,7 +79,7 @@ class ${constructor(t,e,i){this.__parts=[],this.template=t,this.processor=e,this * 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 - */const E=t=>null===t||!("object"==typeof t||"function"==typeof t),P=t=>Array.isArray(t)||!(!t||!t[Symbol.iterator]);class O{constructor(t,e,i){this.dirty=!0,this.element=t,this.name=e,this.strings=i,this.parts=[];for(let t=0;t{try{const t={get capture(){return D=!0,!1}};window.addEventListener("test",t,t),window.removeEventListener("test",t,t)}catch(t){}})();class H{constructor(t,e,i){this.value=void 0,this.__pendingValue=void 0,this.element=t,this.eventName=e,this.eventContext=i,this.__boundHandleEvent=t=>this.handleEvent(t)}setValue(t){this.__pendingValue=t}commit(){for(;S(this.__pendingValue);){const t=this.__pendingValue;this.__pendingValue=x,t(this)}if(this.__pendingValue===x)return;const t=this.__pendingValue,e=this.value,i=null==t||null!=e&&(t.capture!==e.capture||t.once!==e.once||t.passive!==e.passive),s=null!=t&&(null==e||i);i&&this.element.removeEventListener(this.eventName,this.__boundHandleEvent,this.__options),s&&(this.__options=Y(t),this.element.addEventListener(this.eventName,this.__boundHandleEvent,this.__options)),this.value=t,this.__pendingValue=x}handleEvent(t){"function"==typeof this.value?this.value.call(this.eventContext||this.element,t):this.value.handleEvent(t)}}const Y=t=>t&&(D?{capture:t.capture,passive:t.passive,once:t.once}:t.capture) + */const N=t=>null===t||!("object"==typeof t||"function"==typeof t),O=t=>Array.isArray(t)||!(!t||!t[Symbol.iterator]);class V{constructor(t,e,i){this.dirty=!0,this.element=t,this.name=e,this.strings=i,this.parts=[];for(let t=0;t{try{const t={get capture(){return R=!0,!1}};window.addEventListener("test",t,t),window.removeEventListener("test",t,t)}catch(t){}})();class Y{constructor(t,e,i){this.value=void 0,this.__pendingValue=void 0,this.element=t,this.eventName=e,this.eventContext=i,this.__boundHandleEvent=t=>this.handleEvent(t)}setValue(t){this.__pendingValue=t}commit(){for(;k(this.__pendingValue);){const t=this.__pendingValue;this.__pendingValue=$,t(this)}if(this.__pendingValue===$)return;const t=this.__pendingValue,e=this.value,i=null==t||null!=e&&(t.capture!==e.capture||t.once!==e.once||t.passive!==e.passive),n=null!=t&&(null==e||i);i&&this.element.removeEventListener(this.eventName,this.__boundHandleEvent,this.__options),n&&(this.__options=I(t),this.element.addEventListener(this.eventName,this.__boundHandleEvent,this.__options)),this.value=t,this.__pendingValue=$}handleEvent(t){"function"==typeof this.value?this.value.call(this.eventContext||this.element,t):this.value.handleEvent(t)}}const I=t=>t&&(R?{capture:t.capture,passive:t.passive,once:t.once}:t.capture) /** * @license * Copyright (c) 2017 The Polymer Project Authors. All rights reserved. @@ -92,7 +92,7 @@ class ${constructor(t,e,i){this.__parts=[],this.template=t,this.processor=e,this * 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 - */;function R(t){let e=z.get(t.type);void 0===e&&(e={stringsArray:new WeakMap,keyString:new Map},z.set(t.type,e));let i=e.stringsArray.get(t.strings);if(void 0!==i)return i;const s=t.strings.join(c);return i=e.keyString.get(s),void 0===i&&(i=new u(t,t.getTemplateElement()),e.keyString.set(s,i)),e.stringsArray.set(t.strings,i),i}const z=new Map,F=new WeakMap; + */;function z(t){let e=F.get(t.type);void 0===e&&(e={stringsArray:new WeakMap,keyString:new Map},F.set(t.type,e));let i=e.stringsArray.get(t.strings);if(void 0!==i)return i;const n=t.strings.join(h);return i=e.keyString.get(n),void 0===i&&(i=new p(t,t.getTemplateElement()),e.keyString.set(n,i)),e.stringsArray.set(t.strings,i),i}const F=new Map,U=new WeakMap; /** * @license * Copyright (c) 2017 The Polymer Project Authors. All rights reserved. @@ -105,7 +105,7 @@ class ${constructor(t,e,i){this.__parts=[],this.template=t,this.processor=e,this * 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 - */const I=new + */const B=new /** * @license * Copyright (c) 2017 The Polymer Project Authors. All rights reserved. @@ -119,7 +119,7 @@ class ${constructor(t,e,i){this.__parts=[],this.template=t,this.processor=e,this * subject to an additional IP rights grant found at * http://polymer.github.io/PATENTS.txt */ -class{handleAttributeExpressions(t,e,i,s){const o=e[0];if("."===o){return new j(t,e.slice(1),i).parts}if("@"===o)return[new H(t,e.slice(1),s.eventContext)];if("?"===o)return[new A(t,e.slice(1),i)];return new O(t,e,i).parts}handleTextExpression(t){return new V(t)}}; +class{handleAttributeExpressions(t,e,i,n){const s=e[0];if("."===s){return new D(t,e.slice(1),i).parts}if("@"===s)return[new Y(t,e.slice(1),n.eventContext)];if("?"===s)return[new L(t,e.slice(1),i)];return new V(t,e,i).parts}handleTextExpression(t){return new H(t)}}; /** * @license * Copyright (c) 2017 The Polymer Project Authors. All rights reserved. @@ -132,7 +132,7 @@ class{handleAttributeExpressions(t,e,i,s){const o=e[0];if("."===o){return new j( * 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 - */"undefined"!=typeof window&&(window.litHtmlVersions||(window.litHtmlVersions=[])).push("1.4.1");const U=(t,...e)=>new M(t,e,"html",I) + */"undefined"!=typeof window&&(window.litHtmlVersions||(window.litHtmlVersions=[])).push("1.4.1");const q=(t,...e)=>new P(t,e,"html",B) /** * @license * Copyright (c) 2017 The Polymer Project Authors. All rights reserved. @@ -145,7 +145,7 @@ class{handleAttributeExpressions(t,e,i,s){const o=e[0];if("."===o){return new j( * 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 - */,B=(t,e)=>`${t}--${e}`;let W=!0;void 0===window.ShadyCSS?W=!1:void 0===window.ShadyCSS.prepareTemplateDom&&(console.warn("Incompatible ShadyCSS version detected. Please update to at least @webcomponents/webcomponentsjs@2.0.2 and @webcomponents/shadycss@1.3.1."),W=!1);const q=t=>e=>{const i=B(e.type,t);let s=z.get(i);void 0===s&&(s={stringsArray:new WeakMap,keyString:new Map},z.set(i,s));let o=s.stringsArray.get(e.strings);if(void 0!==o)return o;const n=e.strings.join(c);if(o=s.keyString.get(n),void 0===o){const i=e.getTemplateElement();W&&window.ShadyCSS.prepareTemplateDom(i,t),o=new u(e,i),s.keyString.set(n,o)}return s.stringsArray.set(e.strings,o),o},J=["html","svg"],X=new Set,Z=(t,e,i)=>{X.add(t);const s=i?i.element:document.createElement("template"),o=e.querySelectorAll("style"),{length:n}=o;if(0===n)return void window.ShadyCSS.prepareTemplateStyles(s,t);const r=document.createElement("style");for(let t=0;t{J.forEach(e=>{const i=z.get(B(e,t));void 0!==i&&i.keyString.forEach(t=>{const{element:{content:e}}=t,i=new Set;Array.from(e.querySelectorAll("style")).forEach(t=>{i.add(t)}),v(t,i)})})})(t);const a=s.content;i?function(t,e,i=null){const{element:{content:s},parts:o}=t;if(null==i)return void s.appendChild(e);const n=document.createTreeWalker(s,133,null,!1);let r=_(o),a=0,l=-1;for(;n.nextNode();){l++;for(n.currentNode===i&&(a=y(e),i.parentNode.insertBefore(e,i));-1!==r&&o[r].index===l;){if(a>0){for(;-1!==r;)o[r].index+=a,r=_(o,r);return}r=_(o,r)}}}(i,r,a.firstChild):a.insertBefore(r,a.firstChild),window.ShadyCSS.prepareTemplateStyles(s,t);const l=a.querySelector("style");if(window.ShadyCSS.nativeShadow&&null!==l)e.insertBefore(l.cloneNode(!0),e.firstChild);else if(i){a.insertBefore(r,a.firstChild);const t=new Set;t.add(r),v(i,t)}};window.JSCompiler_renameProperty=(t,e)=>t;const G={toAttribute(t,e){switch(e){case Boolean:return t?"":null;case Object:case Array:return null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){switch(e){case Boolean:return null!==t;case Number:return null===t?null:Number(t);case Object:case Array:return JSON.parse(t)}return t}},K=(t,e)=>e!==t&&(e==e||t==t),Q={attribute:!0,type:String,converter:G,reflect:!1,hasChanged:K};class tt extends HTMLElement{constructor(){super(),this.initialize()}static get observedAttributes(){this.finalize();const t=[];return this._classProperties.forEach((e,i)=>{const s=this._attributeNameForProperty(i,e);void 0!==s&&(this._attributeToPropertyMap.set(s,i),t.push(s))}),t}static _ensureClassProperties(){if(!this.hasOwnProperty(JSCompiler_renameProperty("_classProperties",this))){this._classProperties=new Map;const t=Object.getPrototypeOf(this)._classProperties;void 0!==t&&t.forEach((t,e)=>this._classProperties.set(e,t))}}static createProperty(t,e=Q){if(this._ensureClassProperties(),this._classProperties.set(t,e),e.noAccessor||this.prototype.hasOwnProperty(t))return;const i="symbol"==typeof t?Symbol():"__"+t,s=this.getPropertyDescriptor(t,i,e);void 0!==s&&Object.defineProperty(this.prototype,t,s)}static getPropertyDescriptor(t,e,i){return{get(){return this[e]},set(s){const o=this[t];this[e]=s,this.requestUpdateInternal(t,o,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this._classProperties&&this._classProperties.get(t)||Q}static finalize(){const t=Object.getPrototypeOf(this);if(t.hasOwnProperty("finalized")||t.finalize(),this.finalized=!0,this._ensureClassProperties(),this._attributeToPropertyMap=new Map,this.hasOwnProperty(JSCompiler_renameProperty("properties",this))){const t=this.properties,e=[...Object.getOwnPropertyNames(t),..."function"==typeof Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(t):[]];for(const i of e)this.createProperty(i,t[i])}}static _attributeNameForProperty(t,e){const i=e.attribute;return!1===i?void 0:"string"==typeof i?i:"string"==typeof t?t.toLowerCase():void 0}static _valueHasChanged(t,e,i=K){return i(t,e)}static _propertyValueFromAttribute(t,e){const i=e.type,s=e.converter||G,o="function"==typeof s?s:s.fromAttribute;return o?o(t,i):t}static _propertyValueToAttribute(t,e){if(void 0===e.reflect)return;const i=e.type,s=e.converter;return(s&&s.toAttribute||G.toAttribute)(t,i)}initialize(){this._updateState=0,this._updatePromise=new Promise(t=>this._enableUpdatingResolver=t),this._changedProperties=new Map,this._saveInstanceProperties(),this.requestUpdateInternal()}_saveInstanceProperties(){this.constructor._classProperties.forEach((t,e)=>{if(this.hasOwnProperty(e)){const t=this[e];delete this[e],this._instanceProperties||(this._instanceProperties=new Map),this._instanceProperties.set(e,t)}})}_applyInstanceProperties(){this._instanceProperties.forEach((t,e)=>this[e]=t),this._instanceProperties=void 0}connectedCallback(){this.enableUpdating()}enableUpdating(){void 0!==this._enableUpdatingResolver&&(this._enableUpdatingResolver(),this._enableUpdatingResolver=void 0)}disconnectedCallback(){}attributeChangedCallback(t,e,i){e!==i&&this._attributeToProperty(t,i)}_propertyToAttribute(t,e,i=Q){const s=this.constructor,o=s._attributeNameForProperty(t,i);if(void 0!==o){const t=s._propertyValueToAttribute(e,i);if(void 0===t)return;this._updateState=8|this._updateState,null==t?this.removeAttribute(o):this.setAttribute(o,t),this._updateState=-9&this._updateState}}_attributeToProperty(t,e){if(8&this._updateState)return;const i=this.constructor,s=i._attributeToPropertyMap.get(t);if(void 0!==s){const t=i.getPropertyOptions(s);this._updateState=16|this._updateState,this[s]=i._propertyValueFromAttribute(e,t),this._updateState=-17&this._updateState}}requestUpdateInternal(t,e,i){let s=!0;if(void 0!==t){const o=this.constructor;i=i||o.getPropertyOptions(t),o._valueHasChanged(this[t],e,i.hasChanged)?(this._changedProperties.has(t)||this._changedProperties.set(t,e),!0!==i.reflect||16&this._updateState||(void 0===this._reflectingProperties&&(this._reflectingProperties=new Map),this._reflectingProperties.set(t,i))):s=!1}!this._hasRequestedUpdate&&s&&(this._updatePromise=this._enqueueUpdate())}requestUpdate(t,e){return this.requestUpdateInternal(t,e),this.updateComplete}async _enqueueUpdate(){this._updateState=4|this._updateState;try{await this._updatePromise}catch(t){}const t=this.performUpdate();return null!=t&&await t,!this._hasRequestedUpdate}get _hasRequestedUpdate(){return 4&this._updateState}get hasUpdated(){return 1&this._updateState}performUpdate(){if(!this._hasRequestedUpdate)return;this._instanceProperties&&this._applyInstanceProperties();let t=!1;const e=this._changedProperties;try{t=this.shouldUpdate(e),t?this.update(e):this._markUpdated()}catch(e){throw t=!1,this._markUpdated(),e}t&&(1&this._updateState||(this._updateState=1|this._updateState,this.firstUpdated(e)),this.updated(e))}_markUpdated(){this._changedProperties=new Map,this._updateState=-5&this._updateState}get updateComplete(){return this._getUpdateComplete()}_getUpdateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._updatePromise}shouldUpdate(t){return!0}update(t){void 0!==this._reflectingProperties&&this._reflectingProperties.size>0&&(this._reflectingProperties.forEach((t,e)=>this._propertyToAttribute(e,this[e],t)),this._reflectingProperties=void 0),this._markUpdated()}updated(t){}firstUpdated(t){}}tt.finalized=!0; + */,W=(t,e)=>`${t}--${e}`;let X=!0;void 0===window.ShadyCSS?X=!1:void 0===window.ShadyCSS.prepareTemplateDom&&(console.warn("Incompatible ShadyCSS version detected. Please update to at least @webcomponents/webcomponentsjs@2.0.2 and @webcomponents/shadycss@1.3.1."),X=!1);const J=t=>e=>{const i=W(e.type,t);let n=F.get(i);void 0===n&&(n={stringsArray:new WeakMap,keyString:new Map},F.set(i,n));let s=n.stringsArray.get(e.strings);if(void 0!==s)return s;const o=e.strings.join(h);if(s=n.keyString.get(o),void 0===s){const i=e.getTemplateElement();X&&window.ShadyCSS.prepareTemplateDom(i,t),s=new p(e,i),n.keyString.set(o,s)}return n.stringsArray.set(e.strings,s),s},Z=["html","svg"],G=new Set,K=(t,e,i)=>{G.add(t);const n=i?i.element:document.createElement("template"),s=e.querySelectorAll("style"),{length:o}=s;if(0===o)return void window.ShadyCSS.prepareTemplateStyles(n,t);const r=document.createElement("style");for(let t=0;t{Z.forEach(e=>{const i=F.get(W(e,t));void 0!==i&&i.keyString.forEach(t=>{const{element:{content:e}}=t,i=new Set;Array.from(e.querySelectorAll("style")).forEach(t=>{i.add(t)}),y(t,i)})})})(t);const a=n.content;i?function(t,e,i=null){const{element:{content:n},parts:s}=t;if(null==i)return void n.appendChild(e);const o=document.createTreeWalker(n,133,null,!1);let r=w(s),a=0,l=-1;for(;o.nextNode();){l++;for(o.currentNode===i&&(a=b(e),i.parentNode.insertBefore(e,i));-1!==r&&s[r].index===l;){if(a>0){for(;-1!==r;)s[r].index+=a,r=w(s,r);return}r=w(s,r)}}}(i,r,a.firstChild):a.insertBefore(r,a.firstChild),window.ShadyCSS.prepareTemplateStyles(n,t);const l=a.querySelector("style");if(window.ShadyCSS.nativeShadow&&null!==l)e.insertBefore(l.cloneNode(!0),e.firstChild);else if(i){a.insertBefore(r,a.firstChild);const t=new Set;t.add(r),y(i,t)}};window.JSCompiler_renameProperty=(t,e)=>t;const Q={toAttribute(t,e){switch(e){case Boolean:return t?"":null;case Object:case Array:return null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){switch(e){case Boolean:return null!==t;case Number:return null===t?null:Number(t);case Object:case Array:return JSON.parse(t)}return t}},tt=(t,e)=>e!==t&&(e==e||t==t),et={attribute:!0,type:String,converter:Q,reflect:!1,hasChanged:tt};class it extends HTMLElement{constructor(){super(),this.initialize()}static get observedAttributes(){this.finalize();const t=[];return this._classProperties.forEach((e,i)=>{const n=this._attributeNameForProperty(i,e);void 0!==n&&(this._attributeToPropertyMap.set(n,i),t.push(n))}),t}static _ensureClassProperties(){if(!this.hasOwnProperty(JSCompiler_renameProperty("_classProperties",this))){this._classProperties=new Map;const t=Object.getPrototypeOf(this)._classProperties;void 0!==t&&t.forEach((t,e)=>this._classProperties.set(e,t))}}static createProperty(t,e=et){if(this._ensureClassProperties(),this._classProperties.set(t,e),e.noAccessor||this.prototype.hasOwnProperty(t))return;const i="symbol"==typeof t?Symbol():"__"+t,n=this.getPropertyDescriptor(t,i,e);void 0!==n&&Object.defineProperty(this.prototype,t,n)}static getPropertyDescriptor(t,e,i){return{get(){return this[e]},set(n){const s=this[t];this[e]=n,this.requestUpdateInternal(t,s,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this._classProperties&&this._classProperties.get(t)||et}static finalize(){const t=Object.getPrototypeOf(this);if(t.hasOwnProperty("finalized")||t.finalize(),this.finalized=!0,this._ensureClassProperties(),this._attributeToPropertyMap=new Map,this.hasOwnProperty(JSCompiler_renameProperty("properties",this))){const t=this.properties,e=[...Object.getOwnPropertyNames(t),..."function"==typeof Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(t):[]];for(const i of e)this.createProperty(i,t[i])}}static _attributeNameForProperty(t,e){const i=e.attribute;return!1===i?void 0:"string"==typeof i?i:"string"==typeof t?t.toLowerCase():void 0}static _valueHasChanged(t,e,i=tt){return i(t,e)}static _propertyValueFromAttribute(t,e){const i=e.type,n=e.converter||Q,s="function"==typeof n?n:n.fromAttribute;return s?s(t,i):t}static _propertyValueToAttribute(t,e){if(void 0===e.reflect)return;const i=e.type,n=e.converter;return(n&&n.toAttribute||Q.toAttribute)(t,i)}initialize(){this._updateState=0,this._updatePromise=new Promise(t=>this._enableUpdatingResolver=t),this._changedProperties=new Map,this._saveInstanceProperties(),this.requestUpdateInternal()}_saveInstanceProperties(){this.constructor._classProperties.forEach((t,e)=>{if(this.hasOwnProperty(e)){const t=this[e];delete this[e],this._instanceProperties||(this._instanceProperties=new Map),this._instanceProperties.set(e,t)}})}_applyInstanceProperties(){this._instanceProperties.forEach((t,e)=>this[e]=t),this._instanceProperties=void 0}connectedCallback(){this.enableUpdating()}enableUpdating(){void 0!==this._enableUpdatingResolver&&(this._enableUpdatingResolver(),this._enableUpdatingResolver=void 0)}disconnectedCallback(){}attributeChangedCallback(t,e,i){e!==i&&this._attributeToProperty(t,i)}_propertyToAttribute(t,e,i=et){const n=this.constructor,s=n._attributeNameForProperty(t,i);if(void 0!==s){const t=n._propertyValueToAttribute(e,i);if(void 0===t)return;this._updateState=8|this._updateState,null==t?this.removeAttribute(s):this.setAttribute(s,t),this._updateState=-9&this._updateState}}_attributeToProperty(t,e){if(8&this._updateState)return;const i=this.constructor,n=i._attributeToPropertyMap.get(t);if(void 0!==n){const t=i.getPropertyOptions(n);this._updateState=16|this._updateState,this[n]=i._propertyValueFromAttribute(e,t),this._updateState=-17&this._updateState}}requestUpdateInternal(t,e,i){let n=!0;if(void 0!==t){const s=this.constructor;i=i||s.getPropertyOptions(t),s._valueHasChanged(this[t],e,i.hasChanged)?(this._changedProperties.has(t)||this._changedProperties.set(t,e),!0!==i.reflect||16&this._updateState||(void 0===this._reflectingProperties&&(this._reflectingProperties=new Map),this._reflectingProperties.set(t,i))):n=!1}!this._hasRequestedUpdate&&n&&(this._updatePromise=this._enqueueUpdate())}requestUpdate(t,e){return this.requestUpdateInternal(t,e),this.updateComplete}async _enqueueUpdate(){this._updateState=4|this._updateState;try{await this._updatePromise}catch(t){}const t=this.performUpdate();return null!=t&&await t,!this._hasRequestedUpdate}get _hasRequestedUpdate(){return 4&this._updateState}get hasUpdated(){return 1&this._updateState}performUpdate(){if(!this._hasRequestedUpdate)return;this._instanceProperties&&this._applyInstanceProperties();let t=!1;const e=this._changedProperties;try{t=this.shouldUpdate(e),t?this.update(e):this._markUpdated()}catch(e){throw t=!1,this._markUpdated(),e}t&&(1&this._updateState||(this._updateState=1|this._updateState,this.firstUpdated(e)),this.updated(e))}_markUpdated(){this._changedProperties=new Map,this._updateState=-5&this._updateState}get updateComplete(){return this._getUpdateComplete()}_getUpdateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._updatePromise}shouldUpdate(t){return!0}update(t){void 0!==this._reflectingProperties&&this._reflectingProperties.size>0&&(this._reflectingProperties.forEach((t,e)=>this._propertyToAttribute(e,this[e],t)),this._reflectingProperties=void 0),this._markUpdated()}updated(t){}firstUpdated(t){}}it.finalized=!0; /** * @license * Copyright (c) 2017 The Polymer Project Authors. All rights reserved. @@ -159,7 +159,7 @@ class{handleAttributeExpressions(t,e,i,s){const o=e[0];if("."===o){return new j( * subject to an additional IP rights grant found at * http://polymer.github.io/PATENTS.txt */ -const et=t=>e=>"function"==typeof e?((t,e)=>(window.customElements.define(t,e),e))(t,e):((t,e)=>{const{kind:i,elements:s}=e;return{kind:i,elements:s,finisher(e){window.customElements.define(t,e)}}})(t,e),it=(t,e)=>"method"===e.kind&&e.descriptor&&!("value"in e.descriptor)?Object.assign(Object.assign({},e),{finisher(i){i.createProperty(e.key,t)}}):{kind:"field",key:Symbol(),placement:"own",descriptor:{},initializer(){"function"==typeof e.initializer&&(this[e.key]=e.initializer.call(this))},finisher(i){i.createProperty(e.key,t)}};function st(t){return(e,i)=>void 0!==i?((t,e,i)=>{e.constructor.createProperty(i,t)})(t,e,i):it(t,e)}function ot(t){return st({attribute:!1,hasChanged:null==t?void 0:t.hasChanged})}const nt=t=>ot(t) +const nt=t=>e=>"function"==typeof e?((t,e)=>(window.customElements.define(t,e),e))(t,e):((t,e)=>{const{kind:i,elements:n}=e;return{kind:i,elements:n,finisher(e){window.customElements.define(t,e)}}})(t,e),st=(t,e)=>"method"===e.kind&&e.descriptor&&!("value"in e.descriptor)?Object.assign(Object.assign({},e),{finisher(i){i.createProperty(e.key,t)}}):{kind:"field",key:Symbol(),placement:"own",descriptor:{},initializer(){"function"==typeof e.initializer&&(this[e.key]=e.initializer.call(this))},finisher(i){i.createProperty(e.key,t)}};function ot(t){return(e,i)=>void 0!==i?((t,e,i)=>{e.constructor.createProperty(i,t)})(t,e,i):st(t,e)}function rt(t){return ot({attribute:!1,hasChanged:null==t?void 0:t.hasChanged})}const at=t=>rt(t) /** @license Copyright (c) 2019 The Polymer Project Authors. All rights reserved. @@ -169,7 +169,7 @@ http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt 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 -*/,rt=window.ShadowRoot&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,at=Symbol();class lt{constructor(t,e){if(e!==at)throw new Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t}get styleSheet(){return void 0===this._styleSheet&&(rt?(this._styleSheet=new CSSStyleSheet,this._styleSheet.replaceSync(this.cssText)):this._styleSheet=null),this._styleSheet}toString(){return this.cssText}}const ct=(t,...e)=>{const i=e.reduce((e,i,s)=>e+(t=>{if(t instanceof lt)return t.cssText;if("number"==typeof t)return t;throw new Error(`Value passed to 'css' function must be a 'css' function result: ${t}. Use 'unsafeCSS' to pass non-literal values, but\n take care to ensure page security.`)})(i)+t[s+1],t[0]);return new lt(i,at)}; +*/,lt=window.ShadowRoot&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,ct=Symbol();class dt{constructor(t,e){if(e!==ct)throw new Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t}get styleSheet(){return void 0===this._styleSheet&&(lt?(this._styleSheet=new CSSStyleSheet,this._styleSheet.replaceSync(this.cssText)):this._styleSheet=null),this._styleSheet}toString(){return this.cssText}}const ht=(t,...e)=>{const i=e.reduce((e,i,n)=>e+(t=>{if(t instanceof dt)return t.cssText;if("number"==typeof t)return t;throw new Error(`Value passed to 'css' function must be a 'css' function result: ${t}. Use 'unsafeCSS' to pass non-literal values, but\n take care to ensure page security.`)})(i)+t[n+1],t[0]);return new dt(i,ct)}; /** * @license * Copyright (c) 2017 The Polymer Project Authors. All rights reserved. @@ -183,81 +183,81 @@ found at http://polymer.github.io/PATENTS.txt * subject to an additional IP rights grant found at * http://polymer.github.io/PATENTS.txt */ -(window.litElementVersions||(window.litElementVersions=[])).push("2.5.1");const ht={};class dt extends tt{static getStyles(){return this.styles}static _getUniqueStyles(){if(this.hasOwnProperty(JSCompiler_renameProperty("_styles",this)))return;const t=this.getStyles();if(Array.isArray(t)){const e=(t,i)=>t.reduceRight((t,i)=>Array.isArray(i)?e(i,t):(t.add(i),t),i),i=e(t,new Set),s=[];i.forEach(t=>s.unshift(t)),this._styles=s}else this._styles=void 0===t?[]:[t];this._styles=this._styles.map(t=>{if(t instanceof CSSStyleSheet&&!rt){const e=Array.prototype.slice.call(t.cssRules).reduce((t,e)=>t+e.cssText,"");return new lt(String(e),at)}return t})}initialize(){super.initialize(),this.constructor._getUniqueStyles(),this.renderRoot=this.createRenderRoot(),window.ShadowRoot&&this.renderRoot instanceof window.ShadowRoot&&this.adoptStyles()}createRenderRoot(){return this.attachShadow(this.constructor.shadowRootOptions)}adoptStyles(){const t=this.constructor._styles;0!==t.length&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShadow?rt?this.renderRoot.adoptedStyleSheets=t.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet):this._needsShimAdoptedStyleSheets=!0:window.ShadyCSS.ScopingShim.prepareAdoptedCssText(t.map(t=>t.cssText),this.localName))}connectedCallback(){super.connectedCallback(),this.hasUpdated&&void 0!==window.ShadyCSS&&window.ShadyCSS.styleElement(this)}update(t){const e=this.render();super.update(t),e!==ht&&this.constructor.render(e,this.renderRoot,{scopeName:this.localName,eventContext:this}),this._needsShimAdoptedStyleSheets&&(this._needsShimAdoptedStyleSheets=!1,this.constructor._styles.forEach(t=>{const e=document.createElement("style");e.textContent=t.cssText,this.renderRoot.appendChild(e)}))}render(){return ht}}dt.finalized=!0,dt.render=(t,e,i)=>{if(!i||"object"!=typeof i||!i.scopeName)throw new Error("The `scopeName` option is required.");const s=i.scopeName,o=F.has(e),n=W&&11===e.nodeType&&!!e.host,r=n&&!X.has(s),a=r?document.createDocumentFragment():e;if(((t,e,i)=>{let s=F.get(e);void 0===s&&(l(e,e.firstChild),F.set(e,s=new V(Object.assign({templateFactory:R},i))),s.appendInto(e)),s.setValue(t),s.commit()})(t,a,Object.assign({templateFactory:q(s)},i)),r){const t=F.get(a);F.delete(a);const i=t.value instanceof $?t.value.template:void 0;Z(s,a,i),l(e,e.firstChild),e.appendChild(a),F.set(e,t)}!o&&n&&window.ShadyCSS.styleElement(e.host)},dt.shadowRootOptions={mode:"open"};var ut=/d{1,4}|M{1,4}|YY(?:YY)?|S{1,3}|Do|ZZ|Z|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g,pt="[^\\s]+",mt=/\[([^]*?)\]/gm;function gt(t,e){for(var i=[],s=0,o=t.length;s-1?s:null}};function vt(t){for(var e=[],i=1;i3?0:(t-t%10!=10?1:0)*t%10]}},St=vt({},wt),xt=function(t,e){for(void 0===e&&(e=2),t=String(t);t.length0?"-":"+")+xt(100*Math.floor(Math.abs(e)/60)+Math.abs(e)%60,4)},Z:function(t){var e=t.getTimezoneOffset();return(e>0?"-":"+")+xt(Math.floor(Math.abs(e)/60),2)+":"+xt(Math.abs(e)%60,2)}},$t=function(t){return+t-1},Tt=[null,"[1-9]\\d?"],kt=[null,pt],Mt=["isPm",pt,function(t,e){var i=t.toLowerCase();return i===e.amPm[0]?0:i===e.amPm[1]?1:null}],Et=["timezoneOffset","[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z?",function(t){var e=(t+"").match(/([+-]|\d\d)/gi);if(e){var i=60*+e[1]+parseInt(e[2],10);return"+"===e[0]?i:-i}return 0}],Pt=(ft("monthNamesShort"),ft("monthNames"),{default:"ddd MMM DD YYYY HH:mm:ss",shortDate:"M/D/YY",mediumDate:"MMM D, YYYY",longDate:"MMMM D, YYYY",fullDate:"dddd, MMMM D, YYYY",isoDate:"YYYY-MM-DD",isoDateTime:"YYYY-MM-DDTHH:mm:ssZ",shortTime:"HH:mm",mediumTime:"HH:mm:ss",longTime:"HH:mm:ss.SSS"});var Ot,Nt,Vt=function(t,e,i){if(void 0===e&&(e=Pt.default),void 0===i&&(i={}),"number"==typeof t&&(t=new Date(t)),"[object Date]"!==Object.prototype.toString.call(t)||isNaN(t.getTime()))throw new Error("Invalid Date pass to format");var s=[];e=(e=Pt[e]||e).replace(mt,(function(t,e){return s.push(e),"@@@"}));var o=vt(vt({},St),i);return(e=e.replace(ut,(function(e){return Ct[e](t,o)}))).replace(/@@@/g,(function(){return s.shift()}))};(function(){try{(new Date).toLocaleDateString("i")}catch(t){return"RangeError"===t.name}})(),function(){try{(new Date).toLocaleString("i")}catch(t){return"RangeError"===t.name}}(),function(){try{(new Date).toLocaleTimeString("i")}catch(t){return"RangeError"===t.name}}();function At(){return(At=Object.assign||function(t){for(var e=1;e1),It=[],Ut=!1,Bt=-1,Wt=void 0,qt=void 0,Jt=void 0,Xt=function(t){return It.some((function(e){return!(!e.options.allowTouchMove||!e.options.allowTouchMove(t))}))},Zt=function(t){var e=t||window.event;return!!Xt(e.target)||(e.touches.length>1||(e.preventDefault&&e.preventDefault(),!1))},Gt=function(t,e){if(t){if(!It.some((function(e){return e.targetElement===t}))){var i={targetElement:t,options:e||{}};It=[].concat(function(t){if(Array.isArray(t)){for(var e=0,i=Array(t.length);e=s&&(document.body.style.top=-(e+t))}))}),300)}})):function(t){if(void 0===Jt){var e=!!t&&!0===t.reserveScrollBarGap,i=window.innerWidth-document.documentElement.clientWidth;if(e&&i>0){var s=parseInt(window.getComputedStyle(document.body).getPropertyValue("padding-right"),10);Jt=document.body.style.paddingRight,document.body.style.paddingRight=s+i+"px"}}void 0===Wt&&(Wt=document.body.style.overflow,document.body.style.overflow="hidden")}(e),Ft&&(t.ontouchstart=function(t){1===t.targetTouches.length&&(Bt=t.targetTouches[0].clientY)},t.ontouchmove=function(e){1===e.targetTouches.length&&function(t,e){var i=t.targetTouches[0].clientY-Bt;!Xt(t.target)&&(e&&0===e.scrollTop&&i>0||function(t){return!!t&&t.scrollHeight-t.scrollTop<=t.clientHeight}(e)&&i<0?Zt(t):t.stopPropagation())}(e,t)},Ut||(document.addEventListener("touchmove",Zt,Rt?{passive:!1}:void 0),Ut=!0))}}else console.error("disableBodyScroll unsuccessful - targetElement must be provided when calling disableBodyScroll on IOS devices.")},Kt=function(t){t?(It=It.filter((function(e){return e.targetElement!==t})),Ft&&(t.ontouchstart=null,t.ontouchmove=null,Ut&&0===It.length&&(document.removeEventListener("touchmove",Zt,Rt?{passive:!1}:void 0),Ut=!1)),Ft?function(){if(void 0!==qt){var t=-parseInt(document.body.style.top,10),e=-parseInt(document.body.style.left,10);document.body.style.position=qt.position,document.body.style.top=qt.top,document.body.style.left=qt.left,window.scrollTo(e,t),qt=void 0}}():(void 0!==Jt&&(document.body.style.paddingRight=Jt,Jt=void 0),void 0!==Wt&&(document.body.style.overflow=Wt,Wt=void 0))):console.error("enableBodyScroll unsuccessful - targetElement must be provided when calling enableBodyScroll on IOS devices.")};console.info(`%c ---- MY-SLIDER ---- \n%c ${n("common.version")} 3.0.5 `,"color: orange; font-weight: bold; background: black","color: white; font-weight: bold; background: green"),window.customCards=window.customCards||[],window.customCards.push({type:"my-slider",name:"Slider Card",description:"Custom Slider Card for Lovelace."});let Qt=class extends dt{static getStubConfig(){return{}}static get properties(){return{hass:{},config:{},active:{}}}setConfig(t){const e=["input_number","number","light","media_player","cover","fan","switch","lock"];if(!t.entity)throw new Error("You need to define entity");if(!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:"MySlider",disabled_scroll:!1},t)}shouldUpdate(t){return!!this.config&&Yt(this,t,!1)}render(){var t,e=JSON.parse(JSON.stringify(this.config));const i=this.config.entity?this.config.entity:"ERROR: NO ENTITY ID",s=(null===(t=this.config.entity)||void 0===t||t.split(".")[1],this.hass.states[""+i]);var o=e.step?e.step:"1",n=e.minBar?e.minBar:0,r=e.maxBar?e.maxBar:100,a=e.minSet?e.minSet:0,l=e.maxSet?e.maxSet:100;(i.includes("input_number.")||i.includes("number."))&&(o=e.step?e.step:s.attributes.step,a=e.minSet?e.minSet:s.attributes.min,l=e.maxSet?e.maxSet:s.attributes.max);var c=e.width?e.width:"100%",h=e.height?e.height:"50px",d=e.radius?e.radius:"4px",u=e.top?e.top:"0px",p=e.bottom?e.bottom:"0px",m=e.right?e.right:"0px",g=e.left?e.left:"0px",f=e.rotate?e.rotate:"0",v=e.containerHeight?e.containerHeight:h;"0"!=f&&(f+="deg");var y=e.mainSliderColor?e.mainSliderColor:"var(--accent-color)",_=e.secondarySliderColor?e.secondarySliderColor:"#4d4d4d",b=e.mainSliderColorOff?e.mainSliderColorOff:"#636363",w=e.secondarySliderColorOff?e.secondarySliderColorOff:"#4d4d4d",S=e.border?e.border:"0",x=e.thumbWidth?e.thumbWidth:"25px",C=e.thumbHeight?e.thumbHeight:"80px",$=e.thumbColor?e.thumbColor:"#FFFFFF",T=e.thumbColorOff?e.thumbColorOff:"#969696",k=e.thumbHorizontalPadding?e.thumbHorizontalPadding:"10px",M=e.thumbVerticalPadding?e.thumbVerticalPadding:"20px",E=e.thumpTop?e.thumpTop:"calc((var(--slider-width) - var(--thumb-height)) / 2)",P=e.thumbBorderRight?e.thumbBorderRight:"var(--thumb-horizontal-padding) solid var(--slider-main-color)",O=e.thumbBorderLeft?e.thumbBorderLeft:"var(--thumb-horizontal-padding) solid var(--slider-main-color)",N=e.thumbBorderTop?e.thumbBorderTop:"var(--thumb-vertical-padding) solid var(--slider-main-color)",V=e.thumbBorderBotton?e.thumbBorderBotton:"var(--thumb-vertical-padding) solid var(--slider-main-color)",A=!!e.lockTrack&&e.lockTrack,j=`\n\t\t\t--slider-width: ${c};\n\t\t\t--slider-width-inverse: -${c};\n\t\t\t--slider-height: ${h};\n\t\t\t--slider-main-color: ${"off"===s.state||"locked"===s.state||null==s.state?"var(--slider-main-color-off)":"var(--slider-main-color-on)"};\n\t\t\t--slider-main-color-on: ${y};\n\t\t\t--slider-main-color-off: ${b};\n\t\t\t--slider-secondary-color: ${"off"===s.state||"locked"===s.state||null==s.state?"var(--slider-secondary-color-off)":"var(--slider-secondary-color-on)"};\n\t\t\t--slider-secondary-color-on: ${_};\n\t\t\t--slider-secondary-color-off: ${w};\n\t\t\t--slider-radius: ${d};\n\t\t\t--border: ${S};\n\n\t\t\t--thumb-width: ${x};\n\t\t\t--thumb-height: ${C};\n\t\t\t--thumb-color: ${"off"===s.state||null==s.state?"var(--thumb-color-off)":"var(--thumb-color-on)"};\n\t\t\t--thumb-color-on: ${$};\n\t\t\t--thumb-color-off: ${T};\n\t\t\t--thumb-horizontal-padding: ${k};\n\t\t\t--thumb-vertical-padding: ${M};\n\n\t\t\t--rotate: ${f};\n\t\t\t--top: ${u};\n\t\t\t--bottom: ${p};\n\t\t\t--right: ${m};\n\t\t\t--left: ${g};\n\t\t\t--container-height: ${v};\n\t\t\t--thumb-top: ${E};\n\t\t\t--thumb-border-right: ${P};\n\t\t\t--thumb-border-left: ${O};\n\t\t\t--thumb-border-top: ${N};\n\t\t\t--thumb-border-bottom: ${V};\n\t\t\t\n\t\t\t--lock-track-container: ${A?"none":"auto"};\n\t\t`;const L=t=>{i.includes("light.")?"Warmth"==e.function?this._setWarmth(s,t.target,a,l):this._setBrightness(s,t.target,a,l):i.includes("input_number.")||i.includes("number.")?this._setInputNumber(s,t.target,a,l):i.includes("media_player.")?this._setMediaVolume(s,t.target,a,l):i.includes("cover.")?this._setCover(s,t.target,a,l):i.includes("fan.")?this._setFan(s,t.target,a,l):i.includes("switch.")?this._setSwitch(s,t.target,a,l,n,r):i.includes("lock.")&&this._setLock(s,t.target,a,l,n,r)},D=t=>{e.intermediate&&L(t)},H=t=>{e.intermediate||L(t)},Y=()=>{this.config.disabled_scroll=!this.config.disabled_scroll,this.config.disabled_scroll?Gt(window):Kt(window)};if(i.includes("light."))return"Warmth"==e.function?U` +(window.litElementVersions||(window.litElementVersions=[])).push("2.5.1");const ut={};class gt extends it{static getStyles(){return this.styles}static _getUniqueStyles(){if(this.hasOwnProperty(JSCompiler_renameProperty("_styles",this)))return;const t=this.getStyles();if(Array.isArray(t)){const e=(t,i)=>t.reduceRight((t,i)=>Array.isArray(i)?e(i,t):(t.add(i),t),i),i=e(t,new Set),n=[];i.forEach(t=>n.unshift(t)),this._styles=n}else this._styles=void 0===t?[]:[t];this._styles=this._styles.map(t=>{if(t instanceof CSSStyleSheet&&!lt){const e=Array.prototype.slice.call(t.cssRules).reduce((t,e)=>t+e.cssText,"");return new dt(String(e),ct)}return t})}initialize(){super.initialize(),this.constructor._getUniqueStyles(),this.renderRoot=this.createRenderRoot(),window.ShadowRoot&&this.renderRoot instanceof window.ShadowRoot&&this.adoptStyles()}createRenderRoot(){return this.attachShadow(this.constructor.shadowRootOptions)}adoptStyles(){const t=this.constructor._styles;0!==t.length&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShadow?lt?this.renderRoot.adoptedStyleSheets=t.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet):this._needsShimAdoptedStyleSheets=!0:window.ShadyCSS.ScopingShim.prepareAdoptedCssText(t.map(t=>t.cssText),this.localName))}connectedCallback(){super.connectedCallback(),this.hasUpdated&&void 0!==window.ShadyCSS&&window.ShadyCSS.styleElement(this)}update(t){const e=this.render();super.update(t),e!==ut&&this.constructor.render(e,this.renderRoot,{scopeName:this.localName,eventContext:this}),this._needsShimAdoptedStyleSheets&&(this._needsShimAdoptedStyleSheets=!1,this.constructor._styles.forEach(t=>{const e=document.createElement("style");e.textContent=t.cssText,this.renderRoot.appendChild(e)}))}render(){return ut}}gt.finalized=!0,gt.render=(t,e,i)=>{if(!i||"object"!=typeof i||!i.scopeName)throw new Error("The `scopeName` option is required.");const n=i.scopeName,s=U.has(e),o=X&&11===e.nodeType&&!!e.host,r=o&&!G.has(n),a=r?document.createDocumentFragment():e;if(((t,e,i)=>{let n=U.get(e);void 0===n&&(d(e,e.firstChild),U.set(e,n=new H(Object.assign({templateFactory:z},i))),n.appendInto(e)),n.setValue(t),n.commit()})(t,a,Object.assign({templateFactory:J(n)},i)),r){const t=U.get(a);U.delete(a);const i=t.value instanceof M?t.value.template:void 0;K(n,a,i),d(e,e.firstChild),e.appendChild(a),U.set(e,t)}!s&&o&&window.ShadyCSS.styleElement(e.host)},gt.shadowRootOptions={mode:"open"};var pt=/d{1,4}|M{1,4}|YY(?:YY)?|S{1,3}|Do|ZZ|Z|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g,mt="[^\\s]+",ft=/\[([^]*?)\]/gm;function _t(t,e){for(var i=[],n=0,s=t.length;n-1?n:null}};function yt(t){for(var e=[],i=1;i3?0:(t-t%10!=10?1:0)*t%10]}},kt=yt({},St),$t=function(t,e){for(void 0===e&&(e=2),t=String(t);t.length0?"-":"+")+$t(100*Math.floor(Math.abs(e)/60)+Math.abs(e)%60,4)},Z:function(t){var e=t.getTimezoneOffset();return(e>0?"-":"+")+$t(Math.floor(Math.abs(e)/60),2)+":"+$t(Math.abs(e)%60,2)}},Mt=function(t){return+t-1},Ct=[null,"[1-9]\\d?"],Et=[null,mt],Pt=["isPm",mt,function(t,e){var i=t.toLowerCase();return i===e.amPm[0]?0:i===e.amPm[1]?1:null}],Nt=["timezoneOffset","[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z?",function(t){var e=(t+"").match(/([+-]|\d\d)/gi);if(e){var i=60*+e[1]+parseInt(e[2],10);return"+"===e[0]?i:-i}return 0}],Ot=(vt("monthNamesShort"),vt("monthNames"),{default:"ddd MMM DD YYYY HH:mm:ss",shortDate:"M/D/YY",mediumDate:"MMM D, YYYY",longDate:"MMMM D, YYYY",fullDate:"dddd, MMMM D, YYYY",isoDate:"YYYY-MM-DD",isoDateTime:"YYYY-MM-DDTHH:mm:ssZ",shortTime:"HH:mm",mediumTime:"HH:mm:ss",longTime:"HH:mm:ss.SSS"});var Vt,At,Ht=function(t,e,i){if(void 0===e&&(e=Ot.default),void 0===i&&(i={}),"number"==typeof t&&(t=new Date(t)),"[object Date]"!==Object.prototype.toString.call(t)||isNaN(t.getTime()))throw new Error("Invalid Date pass to format");var n=[];e=(e=Ot[e]||e).replace(ft,(function(t,e){return n.push(e),"@@@"}));var s=yt(yt({},kt),i);return(e=e.replace(pt,(function(e){return Tt[e](t,s)}))).replace(/@@@/g,(function(){return n.shift()}))};(function(){try{(new Date).toLocaleDateString("i")}catch(t){return"RangeError"===t.name}})(),function(){try{(new Date).toLocaleString("i")}catch(t){return"RangeError"===t.name}}(),function(){try{(new Date).toLocaleTimeString("i")}catch(t){return"RangeError"===t.name}}();function Lt(t,e,i){if(e.has("config")||i)return!0;if(t.config.entity){var n=e.get("hass");return!n||n.states[t.config.entity]!==t.hass.states[t.config.entity]}return!1}(At=Vt||(Vt={})).language="language",At.system="system",At.comma_decimal="comma_decimal",At.decimal_comma="decimal_comma",At.space_comma="space_comma",At.none="none";var Dt=!1;if("undefined"!=typeof window){var jt={get passive(){Dt=!0}};window.addEventListener("testPassive",null,jt),window.removeEventListener("testPassive",null,jt)}var Rt="undefined"!=typeof window&&window.navigator&&window.navigator.platform&&(/iP(ad|hone|od)/.test(window.navigator.platform)||"MacIntel"===window.navigator.platform&&window.navigator.maxTouchPoints>1),Yt=[],It=!1,zt=-1,Ft=void 0,Ut=void 0,Bt=void 0,qt=function(t){return Yt.some((function(e){return!(!e.options.allowTouchMove||!e.options.allowTouchMove(t))}))},Wt=function(t){var e=t||window.event;return!!qt(e.target)||(e.touches.length>1||(e.preventDefault&&e.preventDefault(),!1))},Xt=function(t,e){if(t){if(!Yt.some((function(e){return e.targetElement===t}))){var i={targetElement:t,options:e||{}};Yt=[].concat(function(t){if(Array.isArray(t)){for(var e=0,i=Array(t.length);e=n&&(document.body.style.top=-(e+t))}))}),300)}})):function(t){if(void 0===Bt){var e=!!t&&!0===t.reserveScrollBarGap,i=window.innerWidth-document.documentElement.clientWidth;if(e&&i>0){var n=parseInt(window.getComputedStyle(document.body).getPropertyValue("padding-right"),10);Bt=document.body.style.paddingRight,document.body.style.paddingRight=n+i+"px"}}void 0===Ft&&(Ft=document.body.style.overflow,document.body.style.overflow="hidden")}(e),Rt&&(t.ontouchstart=function(t){1===t.targetTouches.length&&(zt=t.targetTouches[0].clientY)},t.ontouchmove=function(e){1===e.targetTouches.length&&function(t,e){var i=t.targetTouches[0].clientY-zt;!qt(t.target)&&(e&&0===e.scrollTop&&i>0||function(t){return!!t&&t.scrollHeight-t.scrollTop<=t.clientHeight}(e)&&i<0?Wt(t):t.stopPropagation())}(e,t)},It||(document.addEventListener("touchmove",Wt,Dt?{passive:!1}:void 0),It=!0))}}else console.error("disableBodyScroll unsuccessful - targetElement must be provided when calling disableBodyScroll on IOS devices.")},Jt=function(t){t?(Yt=Yt.filter((function(e){return e.targetElement!==t})),Rt&&(t.ontouchstart=null,t.ontouchmove=null,It&&0===Yt.length&&(document.removeEventListener("touchmove",Wt,Dt?{passive:!1}:void 0),It=!1)),Rt?function(){if(void 0!==Ut){var t=-parseInt(document.body.style.top,10),e=-parseInt(document.body.style.left,10);document.body.style.position=Ut.position,document.body.style.top=Ut.top,document.body.style.left=Ut.left,window.scrollTo(e,t),Ut=void 0}}():(void 0!==Bt&&(document.body.style.paddingRight=Bt,Bt=void 0),void 0!==Ft&&(document.body.style.overflow=Ft,Ft=void 0))):console.error("enableBodyScroll unsuccessful - targetElement must be provided when calling enableBodyScroll on IOS devices.")};console.info(`%c ---- MY-SLIDER ---- \n%c ${a("common.version")} 3.0.6 `,"color: orange; font-weight: bold; background: black","color: white; font-weight: bold; background: green"),window.customCards=window.customCards||[],window.customCards.push({type:"my-slider",name:"Slider Card",description:"Custom Slider Card for Lovelace."});let Zt=class extends gt{static getStubConfig(){return{}}static get properties(){return{hass:{},config:{},active:{}}}setConfig(t){const e=["input_number","number","light","media_player","cover","fan","switch","lock"];if(!t.entity)throw new Error("You need to define entity");if(!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:"MySlider",disabled_scroll:!1},t)}shouldUpdate(t){return!!this.config&&Lt(this,t,!1)}render(){var t,e=JSON.parse(JSON.stringify(this.config));const i=this.config.entity?this.config.entity:"ERROR: NO ENTITY ID",n=(null===(t=this.config.entity)||void 0===t||t.split(".")[1],this.hass.states[""+i]);var s=e.step?e.step:"1",o=e.minBar?e.minBar:0,r=e.maxBar?e.maxBar:100,a=e.minSet?e.minSet:0,l=e.maxSet?e.maxSet:100;(i.includes("input_number.")||i.includes("number."))&&(s=e.step?e.step:n.attributes.step,a=e.minSet?e.minSet:n.attributes.min,l=e.maxSet?e.maxSet:n.attributes.max);var c=e.width?e.width:"100%",d=e.height?e.height:"50px",h=e.radius?e.radius:"4px",u=e.top?e.top:"0px",g=e.bottom?e.bottom:"0px",p=e.right?e.right:"0px",m=e.left?e.left:"0px",f=e.rotate?e.rotate:"0",_=e.containerHeight?e.containerHeight:d;"0"!=f&&(f+="deg");var v=e.mainSliderColor?e.mainSliderColor:"var(--accent-color)",y=e.secondarySliderColor?e.secondarySliderColor:"#4d4d4d",b=e.mainSliderColorOff?e.mainSliderColorOff:"#636363",w=e.secondarySliderColorOff?e.secondarySliderColorOff:"#4d4d4d",x=e.border?e.border:"0",S=e.thumbWidth?e.thumbWidth:"25px",k=e.thumbHeight?e.thumbHeight:"80px",$=e.thumbColor?e.thumbColor:"#FFFFFF",T=e.thumbColorOff?e.thumbColorOff:"#969696",M=e.thumbHorizontalPadding?e.thumbHorizontalPadding:"10px",C=e.thumbVerticalPadding?e.thumbVerticalPadding:"20px",E=e.thumpTop?e.thumpTop:"calc((var(--slider-width) - var(--thumb-height)) / 2)",P=e.thumbBorderRight?e.thumbBorderRight:"var(--thumb-horizontal-padding) solid var(--slider-main-color)",N=e.thumbBorderLeft?e.thumbBorderLeft:"var(--thumb-horizontal-padding) solid var(--slider-main-color)",O=e.thumbBorderTop?e.thumbBorderTop:"var(--thumb-vertical-padding) solid var(--slider-main-color)",V=e.thumbBorderBotton?e.thumbBorderBotton:"var(--thumb-vertical-padding) solid var(--slider-main-color)",A=!!e.lockTrack&&e.lockTrack,H=`\n\t\t\t--slider-width: ${c};\n\t\t\t--slider-width-inverse: -${c};\n\t\t\t--slider-height: ${d};\n\t\t\t--slider-main-color: ${"off"===n.state||"locked"===n.state||null==n.state?"var(--slider-main-color-off)":"var(--slider-main-color-on)"};\n\t\t\t--slider-main-color-on: ${v};\n\t\t\t--slider-main-color-off: ${b};\n\t\t\t--slider-secondary-color: ${"off"===n.state||"locked"===n.state||null==n.state?"var(--slider-secondary-color-off)":"var(--slider-secondary-color-on)"};\n\t\t\t--slider-secondary-color-on: ${y};\n\t\t\t--slider-secondary-color-off: ${w};\n\t\t\t--slider-radius: ${h};\n\t\t\t--border: ${x};\n\n\t\t\t--thumb-width: ${S};\n\t\t\t--thumb-height: ${k};\n\t\t\t--thumb-color: ${"off"===n.state||null==n.state?"var(--thumb-color-off)":"var(--thumb-color-on)"};\n\t\t\t--thumb-color-on: ${$};\n\t\t\t--thumb-color-off: ${T};\n\t\t\t--thumb-horizontal-padding: ${M};\n\t\t\t--thumb-vertical-padding: ${C};\n\n\t\t\t--rotate: ${f};\n\t\t\t--top: ${u};\n\t\t\t--bottom: ${g};\n\t\t\t--right: ${p};\n\t\t\t--left: ${m};\n\t\t\t--container-height: ${_};\n\t\t\t--thumb-top: ${E};\n\t\t\t--thumb-border-right: ${P};\n\t\t\t--thumb-border-left: ${N};\n\t\t\t--thumb-border-top: ${O};\n\t\t\t--thumb-border-bottom: ${V};\n\t\t\t\n\t\t\t--lock-track-container: ${A?"none":"auto"};\n\t\t`;const L=t=>{i.includes("light.")?"Warmth"==e.function?this._setWarmth(n,t.target,a,l):this._setBrightness(n,t.target,a,l):i.includes("input_number.")||i.includes("number.")?this._setInputNumber(n,t.target,a,l):i.includes("media_player.")?this._setMediaVolume(n,t.target,a,l):i.includes("cover.")?this._setCover(n,t.target,a,l):i.includes("fan.")?this._setFan(n,t.target,a,l):i.includes("switch.")?this._setSwitch(n,t.target,a,l,o,r):i.includes("lock.")&&this._setLock(n,t.target,a,l,o,r)},D=t=>{e.intermediate&&L(t)},j=t=>{e.intermediate||L(t)},R=()=>{this.config.disabled_scroll=!this.config.disabled_scroll,this.config.disabled_scroll?Xt(window):Jt(window)};if(i.includes("light."))return"Warmth"==e.function?q` -
- +
+
- `:U` + `:q` -
- +
+
- `;if(i.includes("input_number.")||i.includes("number."))return U` + `;if(i.includes("input_number.")||i.includes("number."))return q` -
- + + step="${s}" .value="${n.state}" + @input=${D} @change=${j} + @touchstart=${e.toggle_scroll?R:null} + @touchend=${e.toggle_scroll?R:null} >
- `;if(i.includes("media_player.")){var R=0;if(null!=s.attributes.volume_level)R=Number(100*s.attributes.volume_level);return U` + `;if(i.includes("media_player.")){var Y=0;if(null!=n.attributes.volume_level)Y=Number(100*n.attributes.volume_level);return q` -
- +
+
- `}return i.includes("cover.")?U` + `}return i.includes("cover.")?q` -
- +
+
- `:i.includes("fan.")?U` + `:i.includes("fan.")?q` -
- +
+
- `:i.includes("switch.")||i.includes("lock.")?U` + `:i.includes("switch.")||i.includes("lock.")?q` -
- +
+
- `:void 0}_setBrightness(t,e,i,s){var o=e.value;o>s?o=s:os?o=s:os?o=s:os?o=s:os?o=s:os?o=s:on?s=n:sn?s=n:sn?s=n:sn?s=n:sn?s=n:sn?s=n:se=>{if(!(e instanceof N)||e instanceof L||"style"!==e.committer.name||e.committer.parts.length>1)throw new Error("The `styleMap` directive must be used in the style attribute and must be the only part in the attribute.");const{committer:i}=e,{style:s}=i.element;let o=te.get(e);void 0===o&&(s.cssText=i.strings.join(" "),te.set(e,o=new Set)),o.forEach(e=>{e in t||(o.delete(e),-1===e.indexOf("-")?s[e]=null:s.removeProperty(e))});for(const e in t)o.add(e),-1===e.indexOf("-")?s[e]=t[e]:s.setProperty(e,t[e])}),ie=(t,e={})=>{const i=se[t];return i?i(e):void console.log(t+": Not found in styles")},se={card:t=>Object.assign({height:"30px"},t),container:t=>Object.assign({width:"100%",height:"100%",position:"relative",overflow:"hidden","border-radius":"5px"},t),track:t=>Object.assign({width:"100%",height:"100%",position:"relative",background:"var(--card-background-color)"},t),progress:t=>Object.assign({height:"100%",background:"var(--paper-item-icon-active-color)",position:"absolute",width:"0.00%"},t),thumb:t=>Object.assign({height:"100%",background:"black",position:"absolute",right:"-5px",width:"10px"},t)},oe=function(t,e,i){var s,o;for(var n in e=void 0===e?[]:e,i=void 0===i?{}:i,t)t.hasOwnProperty(n)&&(s=n,o=t[n],e.push(s),"object"==typeof o&&null!==o?i=oe(o,e,i):i[e[e.length-1]]=o,e.pop());return i},ne=(t,e=100,i=0)=>t/(e-i)*100,re=t=>Math.round(100*(t+Number.EPSILON))/100;function ae(t,e){const i=Object.assign({},t);return le(t)&&le(e)&&Object.keys(e).forEach(s=>{Array.isArray(e[s])?i[s]=e[s].map((e,i)=>t[s]&&le(t[s][i])&&le(e)?ae(t[s][i],e):e):le(e[s])?s in t?i[s]=ae(t[s],e[s]):Object.assign(i,{[s]:e[s]}):Object.assign(i,{[s]:e[s]})}),i}function le(t){return t&&"object"==typeof t&&!Array.isArray(t)}console.info(`%c ---- MY-SLIDER-V2 ---- \n%c ${n("common.version")} 3.0.5 `,"color: orange; font-weight: bold; background: black","color: white; font-weight: bold; background: green"),window.customCards=window.customCards||[],window.customCards.push({type:"my-slider-v2",name:"Slider Card V2",description:"Custom Slider Card V2 for Lovelace."});let ce=class extends dt{constructor(){super(...arguments),this.colorMode="brightness",this.coverMode="position",this.sliderId="",this.touchInput=!1,this.disableScroll=!0,this.allowTapping=!0,this.allowSliding=!1,this.slideDistance=10,this.marginOfError=10,this.thumbTapped=!1,this.isSliding=!1,this.clientXLast=0,this.clientYLast=0,this.actionTaken=!1,this.vertical=!1,this.flipped=!1,this.inverse=!1,this.showMin=!1,this.zero=0,this.savedMin=1,this.min=0,this.max=100,this.minThreshold=0,this.maxThreshold=100,this.step=1,this.oldVal=0,this.sliderVal=0,this.sliderValPercent=0}setSliderValues(t,e){this.inverse?(this.sliderVal=this.max-t,this.sliderValPercent=100-e):(this.sliderVal=t,this.sliderValPercent=e)}static getStubConfig(){return{}}static get properties(){return{hass:{},config:{},active:{}}}setConfig(t){const e=["light","input_number","number","media_player","cover","fan","switch","lock"];if(!t.entity)throw new Error("You need to define entity");if(!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:"MySliderV2"},t)}shouldUpdate(t){return!!this.config&&Yt(this,t,!1)}render(){var t,e,i,s,o,n,r,a,l,c;const h=this.initializeConfig();if(null!==h)return h;const d=oe(null===(t=this._config.styles)||void 0===t?void 0:t.card)?oe(null===(e=this._config.styles)||void 0===e?void 0:e.card):{},u=oe(null===(i=this._config.styles)||void 0===i?void 0:i.container)?oe(null===(s=this._config.styles)||void 0===s?void 0:s.container):{},p=oe(null===(o=this._config.styles)||void 0===o?void 0:o.track)?oe(null===(n=this._config.styles)||void 0===n?void 0:n.track):{},m=oe(null===(r=this._config.styles)||void 0===r?void 0:r.progress)?oe(null===(a=this._config.styles)||void 0===a?void 0:a.progress):{},g=oe(null===(l=this._config.styles)||void 0===l?void 0:l.thumb)?oe(null===(c=this._config.styles)||void 0===c?void 0:c.thumb):{},f=ie("card",d),v=ie("container",u),y=ie("track",p),_=ie("progress",m),b=ie("thumb",g);this.vertical?(_.height=this.sliderValPercent.toString()+"%",f.height=d.height?d.height:"100%",f.width=d.width?d.width:"30px",_.width=m.width?m.width:"100%",_.right=m.right?m.right:"auto",b.right=g.right?g:"auto",b.width=g.width?g.width:"100%",b.height=g.height?g.height:"10px",this.flipped?(_.top=m.top?m.top:"0",b.bottom=g.bottom?g.bottom:"-5px"):(_.bottom=m.bottom?m.bottom:"0",b.top=g.top?g.top:"-5px")):(_.width=this.sliderValPercent.toString()+"%",this.flipped&&(_.right=m.right?m.right:"0",b.right=g.right?g.right:"auto",b.left=g.left?g.left:"-5px"));const w=t=>{const e=t.composedPath().find(t=>t.classList.contains("my-slider-custom-container"));this.sliderEl=e||t.target},S=t=>{switch(t.type){case"mousedown":if(this.touchInput)return;x(t);break;case"touchstart":this.touchInput=!0,x(t);break;case"mousemove":if(this.touchInput)return;$(t);break;case"touchmove":this.disableScroll&&t.preventDefault(),$(t);break;case"mouseup":case"touchend":case"touchcancel":C(t)}},x=t=>{var e;if(this.actionTaken)return;w(t);const i=t.clientX||t.touches[0].clientX,s=t.clientY||t.touches[0].clientY;if(0===this.clientXLast&&(this.clientXLast=i),0===this.clientYLast&&(this.clientYLast=s),this.allowTapping)return this.actionTaken=!0,void this.calcProgress(t);{const o=t.composedPath()[0],n=null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector(".my-slider-custom-thumb");if(o.classList.contains("my-slider-custom-thumb"))return this.thumbTapped=!0,this.actionTaken=!0,void this.calcProgress(t);if(n){const e=n.getBoundingClientRect();if(i>=e.left-this.marginOfError&&i<=e.right+this.marginOfError&&s>=e.top-this.marginOfError&&s<=e.bottom+this.marginOfError)return this.thumbTapped=!0,this.actionTaken=!0,void this.calcProgress(t)}}this.allowSliding&&(this.actionTaken=!0),this.clientYLast=s,this.clientXLast=i},C=t=>{this.actionTaken&&((this.allowTapping||this.thumbTapped||this.isSliding)&&this.calcProgress(t),this.thumbTapped=!1,this.actionTaken=!1,this.touchInput=!1,this.isSliding=!1)},$=t=>{if(this.actionTaken){const e=t.clientX||t.touches[0].clientX,i=t.clientY||t.touches[0].clientY;this.allowTapping||this.isSliding||!this.allowTapping&&this.thumbTapped?(this.calcProgress(t),this.clientXLast=e,this.clientYLast=i):this.allowSliding&&(this.vertical?Math.abs(i-this.clientYLast)>=this.slideDistance&&(this.isSliding=!0,this.clientXLast=e,this.clientYLast=i):Math.abs(e-this.clientXLast)>=this.slideDistance&&(this.isSliding=!0,this.clientXLast=e,this.clientYLast=i))}};return this.createAndCleanupEventListeners(S),U` - -
e=>{if(!(e instanceof A)||e instanceof j||"style"!==e.committer.name||e.committer.parts.length>1)throw new Error("The `styleMap` directive must be used in the style attribute and must be the only part in the attribute.");const{committer:i}=e,{style:n}=i.element;let s=Gt.get(e);void 0===s&&(n.cssText=i.strings.join(" "),Gt.set(e,s=new Set)),s.forEach(e=>{e in t||(s.delete(e),-1===e.indexOf("-")?n[e]=null:n.removeProperty(e))});for(const e in t)s.add(e),-1===e.indexOf("-")?n[e]=t[e]:n.setProperty(e,t[e])}),Qt=(t,e={})=>{const i=te[t];return i?Object.assign(Object.assign({},i),e):void console.log(t+": Not found in styles")},te={card:{height:"30px"},container:{width:"100%",height:"100%",position:"relative",overflow:"hidden","border-radius":"5px"},track:{width:"100%",height:"100%",position:"relative",background:"var(--card-background-color)"},progress:{height:"100%",background:"var(--paper-item-icon-active-color)",position:"absolute",width:"0.00%"},thumb:{height:"100%",background:"black",position:"absolute",right:"-5px",width:"10px"}},ee=function(t,e,i){var n,s;for(var o in e=void 0===e?[]:e,i=void 0===i?{}:i,t)t.hasOwnProperty(o)&&(n=o,s=t[o],e.push(n),"object"==typeof s&&null!==s?i=ee(s,e,i):i[e[e.length-1]]=s,e.pop());return i},ie=(t,e=100,i=0)=>t/(e-i)*100,ne=t=>Math.round(100*(t+Number.EPSILON))/100;function se(t,e){if(!oe(t))return oe(e)?e:{};if(!oe(e))return oe(t)?t:{};if(oe(t)&&oe(e)){const i=Object.assign({},t);return Object.keys(e).forEach(n=>{Array.isArray(e[n])?i[n]=e[n].map((e,i)=>t[n]&&oe(t[n][i])&&oe(e)?se(t[n][i],e):e):oe(e[n])?n in t?i[n]=se(t[n],e[n]):Object.assign(i,{[n]:e[n]}):Object.assign(i,{[n]:e[n]})}),i}return{}}function oe(t){return t&&"object"==typeof t&&!Array.isArray(t)}function re(e,i){if(void 0===e)return!1;const n=(s=e.entity_id).substring(0,s.indexOf("."));var s;const o=void 0!==i?i:null==e?void 0:e.state;if(["button","event","input_button","scene"].includes(n))return"unavailable"!==o;if(t(o))return!1;if("off"===o&&"alert"!==n)return!1;switch(n){case"alarm_control_panel":return"disarmed"!==o;case"alert":return"idle"!==o;case"cover":return"closed"!==o;case"device_tracker":case"person":return"not_home"!==o;case"lock":return"locked"!==o;case"media_player":return"standby"!==o;case"vacuum":return!["idle","docked","paused"].includes(o);case"plant":return"problem"===o;case"group":return["on","home","open","locked","problem"].includes(o);case"timer":return"active"===o;case"camera":return"streaming"===o}return!0}const ae=(t,e)=>{if(t===e)return!0;if(t&&e&&"object"==typeof t&&"object"==typeof e){if(t.constructor!==e.constructor)return!1;let i,n;if(Array.isArray(t)){if(n=t.length,n!==e.length)return!1;for(i=n;0!=i--;)if(!ae(t[i],e[i]))return!1;return!0}if(t instanceof Map&&e instanceof Map){if(t.size!==e.size)return!1;for(i of t.entries())if(!e.has(i[0]))return!1;for(i of t.entries())if(!ae(i[1],e.get(i[0])))return!1;return!0}if(t instanceof Set&&e instanceof Set){if(t.size!==e.size)return!1;for(i of t.entries())if(!e.has(i[0]))return!1;return!0}if(ArrayBuffer.isView(t)&&ArrayBuffer.isView(e)){if(n=t.length,n!==e.length)return!1;for(i=n;0!=i--;)if(t[i]!==e[i])return!1;return!0}if(t.constructor===RegExp)return t.source===e.source&&t.flags===e.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===e.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===e.toString();const s=Object.keys(t);if(n=s.length,n!==Object.keys(e).length)return!1;for(i=n;0!=i--;)if(!Object.prototype.hasOwnProperty.call(e,s[i]))return!1;for(i=n;0!=i--;){const n=s[i];if(!ae(t[n],e[n]))return!1}return!0}return t!=t&&e!=e},le=(t,e,i)=>{const n=JSON.parse(JSON.stringify(i));return ce(t,e,n)},ce=(t,e,i)=>{if(["number","boolean"].includes(typeof i))return i;if(!i)return i;if("object"==typeof i)return Object.keys(i).forEach(n=>{i[n]=ce(t,e,i[n])}),i;const n=i.trim();if("[[["===n.substring(0,3)&&"]]]"===n.slice(-3)){return de(t,e,n.slice(3,-3))}return i},de=(t,e,i)=>{try{return new Function("states","entity","user","hass","html","'use strict'; "+i).call(t,t.hass.states,e,t.hass.user,t.hass,q)}catch(t){if(t instanceof Error){const e=i.length<=100?i.trim():i.trim().substring(0,98)+"...";throw t.message=`${t.name}: ${t.message} in '${e}'`,t.name="MyCardJSTemplateError",t}console.log("Unexpected error (_evalTemplate)",t)}};console.info(`%c ---- MY-SLIDER-V2 ---- \n%c ${a("common.version")} 3.0.6 `,"color: orange; font-weight: bold; background: black","color: white; font-weight: bold; background: green"),window.customCards=window.customCards||[],window.customCards.push({type:"my-slider-v2",name:"Slider Card V2",description:"Custom Slider Card V2 for Lovelace."});let he=class extends gt{constructor(){super(...arguments),this.touchInput=!1,this.thumbTapped=!1,this.isSliding=!1,this.clientXLast=0,this.clientYLast=0,this.actionTaken=!1,this.zero=0,this.oldVal=0,this.sliderVal=0,this.sliderValPercent=0,this.initialTransition=""}setSliderValues(t,e){this._config.inverse?(this.sliderVal=this._config.max-t,this.sliderValPercent=100-e):(this.sliderVal=t,this.sliderValPercent=e)}static getStubConfig(){return{}}static get properties(){return{hass:{},config:{},active:{}}}setConfig(t){const e=["light","input_number","number","media_player","cover","fan","switch","input_boolean","lock"];if(!t.entity)throw new Error("You need to define entity");if(!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:"MySliderV2"},t)}shouldUpdate(t){return!!this.config&&(void 0!==this._config&&"seekbar"===this._config.mode&&this.entity.state,Lt(this,t,!1))}updated(t){super.updated(t),requestAnimationFrame(()=>{if(void 0===this.sliderEl&&null!==this.shadowRoot){this.sliderEl=this.shadowRoot.querySelector(".my-slider-custom-container");const t=this.sliderEl.querySelector(".my-slider-custom-progress");this.initialTransition=t.style.transition}})}render(){var t,e,i,n,s,o,r,a,l;const c=this.initializeConfig();if(null!==c)return c;const d=[{transition:this._config.vertical?"height 0.2s ease 0s":"width 0.2s ease 0s"}],h=(null===(t=this._config.styles)||void 0===t?void 0:t.progress)?Object.assign(Object.assign({},d),this._config.styles.progress):d,u=ee(null===(e=this._config.styles)||void 0===e?void 0:e.card)?ee(null===(i=this._config.styles)||void 0===i?void 0:i.card):{},g=ee(null===(n=this._config.styles)||void 0===n?void 0:n.container)?ee(null===(s=this._config.styles)||void 0===s?void 0:s.container):{},p=ee(null===(o=this._config.styles)||void 0===o?void 0:o.track)?ee(null===(r=this._config.styles)||void 0===r?void 0:r.track):{},m=ee(h),f=ee(null===(a=this._config.styles)||void 0===a?void 0:a.thumb)?ee(null===(l=this._config.styles)||void 0===l?void 0:l.thumb):{},_=Qt("card",u),v=Qt("container",g),y=Qt("track",p),b=Qt("progress",m),w=Qt("thumb",f);this._config.vertical?(b.height=this.sliderValPercent.toString()+"%",_.height=u.height?u.height:"100%",_.width=u.width?u.width:"30px",b.width=m.width?m.width:"100%",b.right=m.right?m.right:"auto",w.right=f.right?f:"auto",w.width=f.width?f.width:"100%",w.height=f.height?f.height:"10px",this._config.flipped?(b.top=m.top?m.top:"0",w.bottom=f.bottom?f.bottom:"-5px"):(b.bottom=m.bottom?m.bottom:"0",w.top=f.top?f.top:"-5px")):(b.width=this.sliderValPercent.toString()+"%",this._config.flipped&&(b.right=m.right?m.right:"0",w.right=f.right?f.right:"auto",w.left=f.left?f.left:"-5px"));const x=t=>{switch(t.type){case"mousedown":if(this.touchInput)return;S(t);break;case"touchstart":this.touchInput=!0,S(t);break;case"mousemove":if(this.touchInput)return;$(t);break;case"touchmove":this._config.disableScroll&&t.preventDefault(),$(t);break;case"mouseup":case"touchend":case"touchcancel":k(t)}},S=t=>{var e;if(this.actionTaken)return;const i=t.clientX||t.touches[0].clientX,n=t.clientY||t.touches[0].clientY;if(0===this.clientXLast&&(this.clientXLast=i),0===this.clientYLast&&(this.clientYLast=n),this._config.allowTapping)return this.actionTaken=!0,void this.calcProgress(t);{const s=t.composedPath()[0],o=null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector(".my-slider-custom-thumb");if(s.classList.contains("my-slider-custom-thumb"))return this.thumbTapped=!0,this.actionTaken=!0,void this.calcProgress(t);if(o){const e=o.getBoundingClientRect();if(i>=e.left-this._config.marginOfError&&i<=e.right+this._config.marginOfError&&n>=e.top-this._config.marginOfError&&n<=e.bottom+this._config.marginOfError)return this.thumbTapped=!0,this.actionTaken=!0,void this.calcProgress(t)}}this._config.allowSliding&&(this.actionTaken=!0),this.clientYLast=n,this.clientXLast=i},k=t=>{if(!this.actionTaken)return;this.sliderEl.querySelector(".my-slider-custom-progress").style.transition=this.initialTransition,(this._config.allowTapping||this.thumbTapped||this.isSliding)&&this.calcProgress(t),this.thumbTapped=!1,this.touchInput=!1,this.isSliding=!1,setTimeout(()=>{this.actionTaken=!1},50)},$=t=>{if(this.actionTaken){this.sliderEl.querySelector(".my-slider-custom-progress").style.transition="";const e=t.clientX||t.touches[0].clientX,i=t.clientY||t.touches[0].clientY;this._config.allowTapping||this.isSliding||!this._config.allowTapping&&this.thumbTapped?(this.calcProgress(t),this.clientXLast=e,this.clientYLast=i):this._config.allowSliding&&(this._config.vertical?Math.abs(i-this.clientYLast)>=this._config.slideDistance&&(this.isSliding=!0,this.clientXLast=e,this.clientYLast=i):Math.abs(e-this.clientXLast)>=this._config.slideDistance&&(this.isSliding=!0,this.clientXLast=e,this.clientYLast=i))}};return this.createAndCleanupEventListeners(x),q` + +
-
-
-
+
+
+
- `}initializeConfig(){this.entity=this.hass.states[""+this.config.entity];try{this._config=this._objectEvalTemplate(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)}this.sliderId="slider-"+this._config.entity.replace(".","-"),this.colorMode=void 0!==this._config.colorMode?this._config.colorMode:"brightness",this.coverMode=void 0!==this._config.coverMode?this._config.coverMode:"position",this.vertical=void 0!==this._config.vertical&&this._config.vertical,this.flipped=void 0!==this._config.flipped&&this._config.flipped,this.inverse=void 0!==this._config.inverse&&this._config.inverse,this.disableScroll=void 0===this._config.disableScroll||this._config.disableScroll,this.allowTapping=void 0===this._config.allowTapping||this._config.allowTapping,this.allowSliding=void 0!==this._config.allowSliding&&this._config.allowSliding,this.marginOfError=void 0!==this._config.marginOfError?this._config.marginOfError:10,this.slideDistance=void 0!==this._config.slideDistance?this._config.slideDistance:10,this.showMin=void 0!==this._config.showMin&&this._config.showMin,this.min=this._config.min?this._config.min:0,this.max=this._config.max?this._config.max:100,this.minThreshold=this._config.minThreshold?this._config.minThreshold:0,this.maxThreshold=this._config.maxThreshold?this._config.maxThreshold:100,this.step=this._config.step?this._config.step:1;let t=0;switch(this._config.entity.split(".")[0]){case"light":if("brightness"===this.colorMode)this.oldVal=Math.ceil(ne(this.entity.attributes.brightness,256)),"on"===this.entity.state?(t=Math.round(this.entity.attributes.brightness/2.56),this.showMin||(t-=this.min)):t=0;else if("temperature"===this.colorMode){if("on"!==this.entity.state)break;this.min=this._config.min?this._config.min:this.entity.attributes.min_mireds,this.max=this._config.max?this._config.max:this.entity.attributes.max_mireds,t=parseFloat(this.entity.attributes.color_temp),this.oldVal=parseFloat(this.entity.attributes.color_temp),this.showMin||(this.max=this.max-this.min,t-=this.min)}else if("hue"===this.colorMode&&"hs"===this.entity.attributes.color_mode){if("on"!==this.entity.state)break;this.min=this._config.min?this._config.min:0,this.max=this._config.max?this._config.max:360,this.oldVal=parseFloat(this.entity.attributes.hs_color[0]),t=parseFloat(this.entity.attributes.hs_color[0]),this.showMin||(this.max=this.max-this.min,t-=this.min)}else if("saturation"===this.colorMode&&"hs"===this.entity.attributes.color_mode){if("on"!==this.entity.state)break;this.min=this._config.min?this._config.min:0,this.max=this._config.max?this._config.max:100,this.oldVal=parseFloat(this.entity.attributes.hs_color[1]),t=parseFloat(this.entity.attributes.hs_color[1]),this.showMin||(this.max=this.max-this.min,t-=this.min)}this.setSliderValues(t,re(ne(t,this.max)));break;case"input_number":case"number":this.step=this._config.step?this._config.step:this.entity.attributes.step,this.min=this._config.min?this._config.min:this.entity.attributes.min,this.max=this._config.max?this._config.max:this.entity.attributes.max,this.oldVal=parseFloat(this.entity.state),t=parseFloat(this.entity.state),this.showMin||(this.max=this.max-this.min,t-=this.min),this.setSliderValues(t,re(ne(t,this.max)));break;case"media_player":t=0,null!=this.entity.attributes.volume_level&&(t=Number(100*this.entity.attributes.volume_level)),this.oldVal=t,this.showMin||(this.max=this.max-this.min,t-=this.min),this.setSliderValues(t,re(ne(t,this.max)));break;case"cover":t=0,"position"===this.coverMode?null!=this.entity.attributes.current_position&&(t=Number(this.entity.attributes.current_position)):"tilt"===this.coverMode&&null!=this.entity.attributes.current_tilt_position&&(t=Number(this.entity.attributes.current_tilt_position)),this.oldVal=t,this.showMin||(this.max=this.max-this.min,t-=this.min),this.inverse=void 0===this._config.inverse||this._config.inverse,this.vertical=void 0===this._config.vertical||this._config.vertical,this.flipped=void 0===this._config.flipped||this._config.flipped,this.setSliderValues(t,re(ne(t,this.max)));break;case"fan":t=0,null!=this.entity.attributes.percentage&&(t=Number(this.entity.attributes.percentage)),this.oldVal=t,this.showMin||(this.max=this.max-this.min,t-=this.min),this.setSliderValues(t,re(ne(t,this.max)));break;case"switch":this.minThreshold=this._config.minThreshold?this._config.minThreshold:15,this.maxThreshold=this._config.maxThreshold?this._config.maxThreshold:75,t=Number(Math.max(this.zero,this.minThreshold)),this.setSliderValues(t,t);break;case"lock":this.minThreshold=this._config.minThreshold?this._config.minThreshold:15,this.maxThreshold=this._config.maxThreshold?this._config.maxThreshold:75,t=Number(Math.max(this.zero,this.minThreshold)),this.oldVal=t,this.setSliderValues(t,t);break;default:console.log("No Entity type initiated... ("+this._config.entity.split(".")[0]+")")}return null}calcProgress(t){if(null==this.sliderEl||null===this.sliderEl)return;const e=((t,e)=>{let i={x:0,y:0};if("touchstart"==t.type||"touchmove"==t.type||"touchend"==t.type||"touchcancel"==t.type){let e=void 0===t.originalEvent?t:t.originalEvent,s=e.touches[0]||e.changedTouches[0];i.x=s.clientX,i.y=s.clientY}else"mousedown"!=t.type&&"mouseup"!=t.type&&"mousemove"!=t.type&&"mouseover"!=t.type&&"mouseout"!=t.type&&"mouseenter"!=t.type&&"mouseleave"!=t.type||(i.x=t.clientX,i.y=t.clientY);let s=e.getBoundingClientRect(),o=i.x-s.left,n=i.y-s.top;return n=e.offsetHeight-n,{x:o,y:n}})(t,this.sliderEl),i=this.sliderEl.offsetWidth,s=this.sliderEl.offsetHeight,o=(this.vertical?re(e.y/s*100):re(e.x/i*100))/100*(this.max-0),n=this.max-o;let r=this.flipped?Math.round(n):Math.round(o);r=rthis.max?this.max:r{n.style.transition=r},200)}_setLock(t,e){var i=Math.min(this.max,this.maxThreshold);if(Number(i)<=e){var s="locked"===t.state?"unlock":"lock";this.hass.callService("lock",s,{entity_id:t.entity_id})}const o=Number(Math.max(this.zero,this.minThreshold)),n=re(ne(o,this.max));this.setSliderValues(o,n);const r=this.sliderEl.querySelector(".my-slider-custom-progress");r.style.transition="width 0.2s ease 0s",r.style.width=n.toString()+"%",setTimeout(()=>{r.style.transition="initial"},200)}createAndCleanupEventListeners(t){document.removeEventListener("mouseup",t),document.removeEventListener("touchend",t),document.removeEventListener("touchcancel",t),document.addEventListener("mouseup",t),document.addEventListener("touchend",t),document.addEventListener("touchcancel",t),document.addEventListener("mousemove",t)}_objectEvalTemplate(t,e){const i=JSON.parse(JSON.stringify(e));return this._getTemplateOrValue(t,i)}_getTemplateOrValue(t,e){if(["number","boolean"].includes(typeof e))return e;if(!e)return e;if("object"==typeof e)return Object.keys(e).forEach(i=>{e[i]=this._getTemplateOrValue(t,e[i])}),e;const i=e.trim();if("[[["===i.substring(0,3)&&"]]]"===i.slice(-3)){return this._evalTemplate(t,i.slice(3,-3))}return e}_evalTemplate(t,e){try{return new Function("states","entity","user","hass","html","'use strict'; "+e).call(this,this.hass.states,t,this.hass.user,this.hass,U)}catch(t){if(t instanceof Error){const i=e.length<=100?e.trim():e.trim().substring(0,98)+"...";throw t.message=`${t.name}: ${t.message} in '${i}'`,t.name="MyCardJSTemplateError",t}console.log("Unexpected error (_evalTemplate)",t)}}static get styles(){return ct` - `}};r([st()],ce.prototype,"_config",void 0),r([st({attribute:!1})],ce.prototype,"hass",void 0),r([nt()],ce.prototype,"config",void 0),ce=r([et("my-slider-v2")],ce);const he="ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0;class de extends HTMLElement{constructor(){super(),this.holdTime=500,this.held=!1,this.ripple=document.createElement("mwc-ripple")}connectedCallback(){Object.assign(this.style,{position:"absolute",width:he?"100px":"50px",height:he?"100px":"50px",transform:"translate(-50%, -50%)",pointerEvents:"none",zIndex:"999"}),this.appendChild(this.ripple),this.ripple.primary=!0,["touchcancel","mouseout","mouseup","touchmove","mousewheel","wheel","scroll"].forEach(t=>{document.addEventListener(t,()=>{clearTimeout(this.timer),this.stopAnimation(),this.timer=void 0},{passive:!0})})}bind(t,e){if(t.actionHandler)return;t.actionHandler=!0,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});const i=t=>{let e,i;this.held=!1,t.touches?(e=t.touches[0].pageX,i=t.touches[0].pageY):(e=t.pageX,i=t.pageY),this.timer=window.setTimeout(()=>{this.startAnimation(e,i),this.held=!0},this.holdTime)},s=i=>{i.preventDefault(),["touchend","touchcancel"].includes(i.type)&&void 0===this.timer||(clearTimeout(this.timer),this.stopAnimation(),this.timer=void 0,this.held?Lt(t,"action",{action:"hold"}):e.hasDoubleClick?"click"===i.type&&i.detail<2||!this.dblClickTimeout?this.dblClickTimeout=window.setTimeout(()=>{this.dblClickTimeout=void 0,Lt(t,"action",{action:"tap"})},250):(clearTimeout(this.dblClickTimeout),this.dblClickTimeout=void 0,Lt(t,"action",{action:"double_tap"})):Lt(t,"action",{action:"tap"}))};t.addEventListener("touchstart",i,{passive:!0}),t.addEventListener("touchend",s),t.addEventListener("touchcancel",s),t.addEventListener("mousedown",i,{passive:!0}),t.addEventListener("click",s),t.addEventListener("keyup",t=>{13===t.keyCode&&s(t)})}startAnimation(t,e){Object.assign(this.style,{left:t+"px",top:e+"px",display:null}),this.ripple.disabled=!1,this.ripple.active=!0,this.ripple.unbounded=!0}stopAnimation(){this.ripple.active=!1,this.ripple.disabled=!0,this.style.display="none"}}customElements.define("action-handler-my-footer",de);const ue=(t,e)=>{const i=(()=>{const t=document.body;if(t.querySelector("action-handler-my-footer"))return t.querySelector("action-handler-my-footer");const e=document.createElement("action-handler-my-footer");return t.appendChild(e),e})();i&&i.bind(t,e)},pe=w((t={})=>e=>{ue(e.committer.element,t)}),me=(t,e={})=>{const i=ge[t];return i?i(e):void console.log(t+": Not found in styles")},ge={card:t=>Object.assign({height:"125px",width:"100%","min-width":"fit-content",background:"var(--card-background-color)",overflow:"hidden",cursor:"pointer"},t),icon:t=>Object.assign({"--mdc-icon-size":"100%",height:"35px",width:"35px",display:"inline-block",padding:"10px 0 0 10px",color:"var(--paper-item-icon-color)"},t),stats:t=>Object.assign({"margin-left":"auto","margin-right":"5px","margin-top":"5px","margin-bottom":"5px",color:"var(--primary-text-color)",display:"grid","place-items":"center","aspect-ratio":"1 / 1","font-family":'"Arial", sans-serif',"font-size":"11px","text-align":"center","text-shadow":"2px 2px 4px rgba(0, 0, 0, 0.5)"},t),"label-wrapper":t=>Object.assign({width:"100%",height:"100%",display:"flex"},t),label:t=>Object.assign({padding:"0",margin:"0 10px",color:"var(--primary-text-color)","font-weight":"bold",cursor:"pointer"},t),container:t=>Object.assign({padding:"0",margin:"0",display:"flex","flex-flow":"column",height:"100%"},t),row1:t=>Object.assign({flex:"0 1 auto",display:"flex","justify-content":"space-between"},t),row2:t=>Object.assign({flex:"1 1 auto"},t),row3:t=>Object.assign({flex:"0 1 auto"},t),"container-column":t=>Object.assign({padding:"0",margin:"0",display:"flex","flex-flow":"row",height:"100%"},t),column1:t=>Object.assign({flex:"1"},t),column2:t=>Object.assign({flex:"0"},t)};console.info(`%c ---- MY-BUTTON ---- \n%c ${n("common.version")} 1.0.1 `,"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 fe=class extends dt{constructor(){super(...arguments),this.lastAction=0,this.layout="vertical",this.iconConfig={},this.labelConfig={},this.sliderConfig={},this.statsConfig={},this.cardStl={},this.containerStl={},this.containerColumnStl={},this.iconStl={},this.statsStl={},this.labelWrapperStl={},this.labelStl={},this.row1Stl={},this.row2Stl={},this.row3Stl={},this.column1Stl={},this.column2Stl={}}static getStubConfig(){return{}}static get properties(){return{hass:{},config:{},active:{}}}setConfig(t){const e=["light","cover","switch"];if(!t.entity)throw new Error("You need to define entity");if(!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&&Yt(this,t,!1)}render(){const t=this.initializeConfig();return null!==t?t:this.entity&&this._config?"vertical"===this.layout?this.verticalLayoutCard():this.horizontalLayoutCard():U``}verticalLayoutCard(){var t,e,i,s,o,n,r,a;return U` - -
-
this._handleAction(t,this.config)} - .actionHandler=${pe({hasDoubleClick:"none"!==(null===(e=null===(t=this.config)||void 0===t?void 0:t.double_tap_action)||void 0===e?void 0:e.action),hasHold:"none"!==(null===(s=null===(i=this.config)||void 0===i?void 0:i.hold_action)||void 0===s?void 0:s.action)})}> - ${this.iconElement()} + `}initializeConfig(){var t;if(this.actionTaken)return null;this.entity=this.hass.states[""+this.config.entity];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 evaluated _config`;const e=this._config.entity?null===(t=this._config.entity)||void 0===t?void 0:t.split(".")[0]:this._config.entity?this._config.entity.split(".")[0]:"none",i={sliderId:`slider-${this._config.entity.replace(".","-")}-${this._config.mode}`,type:this._config.type,disableScroll:void 0===this._config.disableScroll||this._config.disableScroll,allowTapping:void 0===this._config.allowTapping||this._config.allowTapping,allowSliding:void 0!==this._config.allowSliding&&this._config.allowSliding,marginOfError:void 0!==this._config.marginOfError?this._config.marginOfError:10,slideDistance:void 0!==this._config.slideDistance?this._config.slideDistance:10,showMin:void 0!==this._config.showMin&&this._config.showMin,minThreshold:0,maxThreshold:100,sliderMin:this._config.sliderMin?this._config.sliderMin:0,vertical:void 0!==this._config.vertical&&this._config.vertical,flipped:void 0!==this._config.flipped&&this._config.flipped,inverse:void 0!==this._config.inverse&&this._config.inverse,intermediate:void 0!==this._config.intermediate&&this._config.intermediate,min:this._config.min?this._config.min:0,max:this._config.max?this._config.max:100,step:this._config.step?this._config.step:1,mode:void 0!==this._config.mode?this._config.mode:void 0!==this._config.colorMode?this._config.colorMode:void 0!==this._config.coverMode?this._config.coverMode:"light"===e?"brightness":"cover"===e?"position":"media_player"===e?"volume":"brightness"};let n=0,s=0,o=0;switch(e){case"light":if("brightness"===i.mode)this.oldVal=Math.ceil(ie(this.entity.attributes.brightness,256)),"on"===this.entity.state&&(n=Math.ceil(ie(this.entity.attributes.brightness,256)),!i.showMin&&i.min&&(n-=i.min)),n=n*(100-i.sliderMin)/100+i.sliderMin,n=nthis.updateSeekbar(),500);if("playing"!==this.entity.state)return;let t=0;this._config.max=this.entity.attributes.media_duration;const e=new Date,i=new Date(this.entity.attributes.media_position_updated_at);let n=this.entity.attributes.media_position+(e.getTime()-i.getTime())/1e3;n=Math.min(n,this._config.max),t=n,this.setSliderValues(t,ne(ie(t,this._config.max))),this.setProgress(this.sliderEl,Math.round(t),"updateSeekbar"),setTimeout(()=>this.updateSeekbar(),1e3)}calcProgress(t){if(void 0===this.sliderEl||null===this.sliderEl)return;const e=((t,e)=>{let i={x:0,y:0};if("touchstart"==t.type||"touchmove"==t.type||"touchend"==t.type||"touchcancel"==t.type){let e=void 0===t.originalEvent?t:t.originalEvent,n=e.touches[0]||e.changedTouches[0];i.x=n.clientX,i.y=n.clientY}else"mousedown"!=t.type&&"mouseup"!=t.type&&"mousemove"!=t.type&&"mouseover"!=t.type&&"mouseout"!=t.type&&"mouseenter"!=t.type&&"mouseleave"!=t.type||(i.x=t.clientX,i.y=t.clientY);let n=e.getBoundingClientRect(),s=i.x-n.left,o=i.y-n.top;return o=e.offsetHeight-o,{x:s,y:o}})(t,this.sliderEl),i=this.sliderEl.offsetWidth,n=this.sliderEl.offsetHeight,s=(this._config.vertical?ne(e.y/n*100):ne(e.x/i*100))/100*(this._config.max-0),o=this._config.max-s;let r=this._config.flipped?o:s;r=rthis._config.max?this._config.max:r{o.style.transition=this.initialTransition},200)}_setLock(t,e){var i=Math.min(this._config.max,this._config.maxThreshold);if(Number(i)<=e){var n="locked"===t.state?"unlock":"lock";this.hass.callService("lock",n,{entity_id:t.entity_id})}const s=Number(Math.max(this.zero,this._config.minThreshold)),o=ne(ie(s,this._config.max)),r=this.sliderEl.querySelector(".my-slider-custom-progress");this._config.vertical?r.style.transition="height 0.2s ease 0s":r.style.transition="width 0.2s ease 0s",this.setSliderValues(s,o),this.setProgress(this.sliderEl,s,"setLock"),setTimeout(()=>{r.style.transition=this.initialTransition},200)}createAndCleanupEventListeners(t){document.removeEventListener("mouseup",t),document.removeEventListener("touchend",t),document.removeEventListener("touchcancel",t),document.addEventListener("mouseup",t),document.addEventListener("touchend",t),document.addEventListener("touchcancel",t),document.addEventListener("mousemove",t)}static get styles(){return ht` + `}};l([ot()],he.prototype,"_config",void 0),l([ot({attribute:!1})],he.prototype,"hass",void 0),l([at()],he.prototype,"config",void 0),he=l([nt("my-slider-v2")],he);const ue=(t,e,i,n)=>{n=n||{},i=null==i?{}:i;const s=new Event(e,{bubbles:void 0===n.bubbles||n.bubbles,cancelable:Boolean(n.cancelable),composed:void 0===n.composed||n.composed});return s.detail=i,t.dispatchEvent(s),s},ge=1,pe=2,me=3,fe=4,_e=5; +/** + * @license + * Copyright (c) 2021 The Polymer Project Authors. All rights reserved. + * This code may only be used under the BSD style license found at + * http://polymer.github.io/LICENSE.txt + * The complete set of authors may be found at + * http://polymer.github.io/AUTHORS.txt + * The complete set of contributors may be found at + * http://polymer.github.io/CONTRIBUTORS.txt + * 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?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 +
+
this._handleAction(t,this._config)} + .actionHandler=${$e({hasDoubleClick:"none"!==(null===(e=null===(t=this._config)||void 0===t?void 0:t.double_tap_action)||void 0===e?void 0:e.action),hasHold:"none"!==(null===(n=null===(i=this._config)||void 0===i?void 0:i.hold_action)||void 0===n?void 0:n.action),repeat:null===(o=null===(s=this._config)||void 0===s?void 0:s.hold_action)||void 0===o?void 0:o.repeat,repeatLimit:null===(a=null===(r=this._config)||void 0===r?void 0:r.hold_action)||void 0===a?void 0:a.repeat_limit})}> +
+ ${this.iconElement()} + ${this.statsElement()} +
+
+ ${this.labelElement()} +
- ${this.statsElement()}
-
this._handleAction(t,this.config)} - .actionHandler=${pe({hasDoubleClick:"none"!==(null===(n=null===(o=this.config)||void 0===o?void 0:o.double_tap_action)||void 0===n?void 0:n.action),hasHold:"none"!==(null===(a=null===(r=this.config)||void 0===r?void 0:r.hold_action)||void 0===a?void 0:a.action)})}> - ${this.labelElement()} +
+ ${!1===this._config.buttons.vertical?this.buttonsElement():""}
-
- ${this.sliderElement()} +
+ ${!1===this._config.slider.vertical?this.sliderElement():""} + ${this._config.seekbar.show?this.seekbarElement():""} +
+
+ ${!0===this._config.buttons.vertical?this.buttonsElement():""} +
+
+ ${!0===this._config.slider.vertical?this.sliderElement():""}
- `}horizontalLayoutCard(){var t,e,i,s,o,n,r,a;return U` - -
-
-
-
this._handleAction(t,this.config)} - .actionHandler=${pe({hasDoubleClick:"none"!==(null===(e=null===(t=this.config)||void 0===t?void 0:t.double_tap_action)||void 0===e?void 0:e.action),hasHold:"none"!==(null===(s=null===(i=this.config)||void 0===i?void 0:i.hold_action)||void 0===s?void 0:s.action)})}> - ${this.iconElement()} -
-
this._handleAction(t,this.config)} - .actionHandler=${pe({hasDoubleClick:"none"!==(null===(n=null===(o=this.config)||void 0===o?void 0:o.double_tap_action)||void 0===n?void 0:n.action),hasHold:"none"!==(null===(a=null===(r=this.config)||void 0===r?void 0:r.hold_action)||void 0===a?void 0:a.action)})}> - ${this.labelElement()} -
-
-
+ `}iconElement(){var t,e,i,n;return this._config.icon.show?this._config.icon.tap_action||this._config.icon.double_tap_action||this._config.icon.hold_action?q` + this._handleAction(t,this._config.icon)} + .actionHandler=${$e({hasDoubleClick:"none"!==(null===(t=this._config.icon.double_tap_action)||void 0===t?void 0:t.action),hasHold:"none"!==(null===(e=this._config.icon.hold_action)||void 0===e?void 0:e.action),repeat:null===(i=this._config.icon.hold_action)||void 0===i?void 0:i.repeat,repeatLimit:null===(n=this._config.icon.hold_action)||void 0===n?void 0:n.repeat_limit})} /> + `:q` + + `:q``}statsElement(){var t,e,i,n,s,o,r,a;return this._config.stats.show?this._config.stats.tap_action||this._config.stats.double_tap_action||this._config.stats.hold_action?this._config.camera?q` +
this._handleAction(t,this._config.stats)} + .actionHandler=${$e({hasDoubleClick:"none"!==(null===(t=this._config.stats.double_tap_action)||void 0===t?void 0:t.action),hasHold:"none"!==(null===(e=this._config.stats.hold_action)||void 0===e?void 0:e.action),repeat:null===(i=this._config.stats.hold_action)||void 0===i?void 0:i.repeat,repeatLimit:null===(n=this._config.stats.hold_action)||void 0===n?void 0:n.repeat_limit})}> +
+ + ${this._config.stats.text}
-
- ${this.sliderElement()} + `:q` +
this._handleAction(t,this._config.stats)} + .actionHandler=${$e({hasDoubleClick:"none"!==(null===(s=this._config.stats.double_tap_action)||void 0===s?void 0:s.action),hasHold:"none"!==(null===(o=this._config.stats.hold_action)||void 0===o?void 0:o.action),repeat:null===(r=this._config.stats.hold_action)||void 0===r?void 0:r.repeat,repeatLimit:null===(a=this._config.stats.hold_action)||void 0===a?void 0:a.repeat_limit})}> + +
+ ${this._config.stats.text} +
+
+ `:this._config.camera?q` +
+
+ +
+
+ `:q` +
+
+ ${this._config.stats.text} +
+
+ `:q``}labelElement(){var t,e,i,n;return this._config.label.show?this._config.label.tap_action||this._config.label.double_tap_action||this._config.label.hold_action?q` +
+ + ${this._config.label.extra?q`

${this._config.label.extra}

`:""} +
- - `}iconElement(){var t,e;return this.iconConfig.show?this.iconConfig.tap_action||this.iconConfig.double_tap_action||this.iconConfig.hold_action?U` - this._handleAction(t,this.iconConfig)} - .actionHandler=${pe({hasDoubleClick:"none"!==(null===(t=this.iconConfig.double_tap_action)||void 0===t?void 0:t.action),hasHold:"none"!==(null===(e=this.iconConfig.hold_action)||void 0===e?void 0:e.action)})} /> - `:U` - - `:U``}statsElement(){var t,e;return this.statsConfig.show?this.statsConfig.tap_action||this.statsConfig.double_tap_action||this.statsConfig.hold_action?U` -
this._handleAction(t,this.statsConfig)} - .actionHandler=${pe({hasDoubleClick:"none"!==(null===(t=this.statsConfig.double_tap_action)||void 0===t?void 0:t.action),hasHold:"none"!==(null===(e=this.statsConfig.hold_action)||void 0===e?void 0:e.action)})}> - - ${this.statsConfig.text} - -
- `:U` -
- ${this.statsConfig.text} -
- `:U``}labelElement(){var t,e;return this.labelConfig.show?this.labelConfig.tap_action||this.labelConfig.double_tap_action||this.labelConfig.hold_action?U` -
- -
- `:U` -
- + `:q` +
+ + ${this._config.label.extra?q`

${this._config.label.extra}

`:""}
- `:U``}sliderElement(){return this.sliderConfig.show?("horizontal"===this.layout&&(this.sliderConfig.vertical=void 0===this.sliderConfig.vertical||this.sliderConfig.vertical,this.sliderConfig.styles=this.sliderConfig.styles?this.sliderConfig.styles:{},this.sliderConfig.styles.card=this.sliderConfig.styles.card?this.sliderConfig.styles.card:{},this.sliderConfig.styles.card.width=this.sliderConfig.styles.card.width?this.sliderConfig.styles.card.width:"35px"),U` - - `):U``}initializeConfig(){var t,e,i,s,o,n,r,a,l,c,h,d,u,p,m,g,f,v,y,_,b,w,S;this.entity=this.hass.states[""+this.config.entity],0===this.lastAction&&(this.lastAction=(new Date).getTime());try{this._config=this._objectEvalTemplate(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 U`Error with this._config...`;const x=this._config.entity.split(".")[0],C={show:!0,icon:"mdi:lightbulb-outline"};"cover"===x?C.icon=(null===(t=this.entity.attributes)||void 0===t?void 0:t.current_position)>=50?"mdi:blinds-open":"mdi:blinds":"switch"===x&&(C.icon="on"===this.entity.state?"mdi:power-plug":"mdi:power-plug-off");const $={show:!0,text:this.entity.attributes.friendly_name};this.layout=this._config.layout?this._config.layout:"vertical","cover"===this._config.entity.split(".")[0]&&(this.layout=this._config.layout?this._config.layout:"horizontal"),this.iconConfig="string"==typeof this._config.icon?Object.assign(Object.assign({},C),{icon:this._config.icon}):"object"==typeof this._config.icon?ae(C,this._config.icon):C,this.labelConfig="string"==typeof this._config.label?Object.assign(Object.assign({},$),{text:this._config.label}):"object"==typeof this._config.label?ae($,this._config.label):$;const T={show:!!this.entity.attributes.brightness,text:this.entity.attributes.brightness&&Math.ceil(ne(this.entity.attributes.brightness,256))};this.statsConfig="string"==typeof this._config.stats?Object.assign(Object.assign({},T),{text:this._config.stats}):"object"==typeof this._config.stats?ae(T,this._config.stats):T;const k={show:!0,entity:this.entity.entity_id,styles:{card:[{"border-radius":"0px",background:"transparent","box-shadow":"none",cursor:"default"}],container:[{"border-radius":"0px"}],thumb:"vertical"===this.layout?[{height:"20px",width:"3px",top:"6px",right:"2px","border-radius":"50px"}]:[{width:"20px",height:"3px",bottom:"2px",left:"7px","border-radius":"50px"}],track:[{background:"transparent"}],progress:"vertical"===this.layout?[{background:"linear-gradient(to top, var(--paper-item-icon-active-color), transparent)"}]:[{background:"linear-gradient(to left, var(--paper-item-icon-active-color), transparent)"}]}};"switch"===x&&(k.show=!1),this.sliderConfig=this._config.slider?ae(k,this._config.slider):k;let M=[];if("light"===x)if(this.entity.attributes.brightness){let t=1+this.entity.attributes.brightness/256;M=[{background:`radial-gradient(circle at top left, rgba(230, 230, 230, 0.7), var(--card-background-color) ${Math.ceil(ne(this.entity.attributes.brightness,256))/t+"%"})`}]}else M=[{background:"radial-gradient(circle at top left, rgba(230, 230, 230, 0.5), var(--card-background-color) 40%)"}];else if("switch"===x){M=[{background:"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%)"}]}const E=(null===(e=this._config.styles)||void 0===e?void 0:e.card)?Object.assign(Object.assign({},M),this._config.styles.card):M,P=[{color:"on"===this.entity.state?"var(--paper-item-icon-active-color)":"var(--paper-item-icon-color)"},{filter:"on"===this.entity.state?"drop-shadow(2px 2px 2px rgba(0,0,0,0.6)":"drop-shadow(3px 3px 2px rgba(0,0,0,0.3)"}],O=(null===(i=this._config.styles)||void 0===i?void 0:i.icon)?Object.assign(Object.assign({},P),this._config.styles.icon):P;return this.cardStl=me("card",oe(E)?oe(E):{}),this.containerStl=me("container",oe(null===(s=this._config.styles)||void 0===s?void 0:s.container)?oe(null===(o=this._config.styles)||void 0===o?void 0:o.container):{}),this.containerColumnStl=me("container-column",oe(null===(n=this._config.styles)||void 0===n?void 0:n.containerColumn)?oe(null===(r=this._config.styles)||void 0===r?void 0:r.containerColumn):{}),this.iconStl=me("icon",oe(O)?oe(O):{}),this.statsStl=me("stats",oe(null===(a=this._config.styles)||void 0===a?void 0:a.stats)?oe(null===(l=this._config.styles)||void 0===l?void 0:l.stats):{}),this.labelWrapperStl=me("label-wrapper",oe(null===(c=this._config.styles)||void 0===c?void 0:c.labelWrapper)?oe(null===(h=this._config.styles)||void 0===h?void 0:h.labelWrapper):{}),this.labelStl=me("label",oe(null===(d=this._config.styles)||void 0===d?void 0:d.label)?oe(null===(u=this._config.styles)||void 0===u?void 0:u.label):{}),this.row1Stl=me("row1",oe(null===(p=this._config.styles)||void 0===p?void 0:p.row1)?oe(null===(m=this._config.styles)||void 0===m?void 0:m.row1):{}),this.row2Stl=me("row2",oe(null===(g=this._config.styles)||void 0===g?void 0:g.row2)?oe(null===(f=this._config.styles)||void 0===f?void 0:f.row2):{}),this.row3Stl=me("row3",oe(null===(v=this._config.styles)||void 0===v?void 0:v.row3)?oe(null===(y=this._config.styles)||void 0===y?void 0:y.row3):{}),this.column1Stl=me("column1",oe(null===(_=this._config.styles)||void 0===_?void 0:_.column1)?oe(null===(b=this._config.styles)||void 0===b?void 0:b.column1):{}),this.column2Stl=me("column2",oe(null===(w=this._config.styles)||void 0===w?void 0:w.column2)?oe(null===(S=this._config.styles)||void 0===S?void 0:S.column2):{}),null}_handleAction(t,e){var i;t.stopPropagation(),t.stopImmediatePropagation();if(!((new Date).getTime()-this.lastAction<100)&&(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":e.tap_action&&this._handleTap(e);break;case"hold":e.hold_action&&this._handleHold(e);break;case"double_tap":e.double_tap_action&&this._handleDblTap(e)}}_handleTap(t){Ht(this,this.hass,this._evalActions(this._config,"tap_action"),!1,!1)}_handleHold(t){Ht(this,this.hass,this._evalActions(this._config,"hold_action"),!0,!1)}_handleDblTap(t){Ht(this,this.hass,this._evalActions(this._config,"double_tap_action"),!1,!0)}_evalActions(t,e){const i=JSON.parse(JSON.stringify(t)),s=t=>t?(Object.keys(t).forEach(e=>{"object"==typeof t[e]?t[e]=s(t[e]):t[e]=this._getTemplateOrValue(this.entity,t[e])}),t):t;return i[e]=s(i[e]),!i[e].confirmation&&i.confirmation&&(i[e].confirmation=s(i.confirmation)),i}_objectEvalTemplate(t,e){const i=JSON.parse(JSON.stringify(e));return this._getTemplateOrValue(t,i)}_getTemplateOrValue(t,e){if(["number","boolean"].includes(typeof e))return e;if(!e)return e;if("object"==typeof e)return Object.keys(e).forEach(i=>{e[i]=this._getTemplateOrValue(t,e[i])}),e;const i=e.trim();if("[[["===i.substring(0,3)&&"]]]"===i.slice(-3)){return this._evalTemplate(t,i.slice(3,-3))}return e}_evalTemplate(t,e){try{return new Function("states","entity","user","hass","html","'use strict'; "+e).call(this,this.hass.states,t,this.hass.user,this.hass,U)}catch(t){if(t instanceof Error){const i=e.length<=100?e.trim():e.trim().substring(0,98)+"...";throw t.message=`${t.name}: ${t.message} in '${i}'`,t.name="MyCardJSTemplateError",t}console.log("Unexpected error (_evalTemplate)",t)}}static get styles(){return ct``}};r([st()],fe.prototype,"_config",void 0),r([st({attribute:!1})],fe.prototype,"hass",void 0),r([nt()],fe.prototype,"config",void 0),fe=r([et("my-button")],fe),console.info(`%c ---- MY-CARDS ---- \n%c ${n("common.version")} 2.0.3 `,"color: orange; font-weight: bold; background: black","color: white; font-weight: bold; background: green");export{fe as MyButton,Qt as MySlider,ce as MySliderV2}; + `:q``}sliderElement(){return this._config.slider.show?q` + + `:q``}buttonsElement(){if(!this._config.buttons.show)return q``;let t=Object.keys(this._config.buttons).filter(t=>t.startsWith("button")).map(t=>{var e,i,n,s;return this._config.buttons[t].show?this._config.buttons[t].tap_action||this._config.buttons[t].double_tap_action||this._config.buttons[t].hold_action?q` +
this._handleAction(e,this._config.buttons[t])} + .actionHandler=${$e({hasDoubleClick:"none"!==(null===(e=this._config.buttons[t].double_tap_action)||void 0===e?void 0:e.action),hasHold:"none"!==(null===(i=this._config.buttons[t].hold_action)||void 0===i?void 0:i.action),repeat:null===(n=this._config.buttons[t].hold_action)||void 0===n?void 0:n.repeat,repeatLimit:null===(s=this._config.buttons[t].hold_action)||void 0===s?void 0:s.repeat_limit})}> + ${this._config.buttons[t].text?q`

${this._config.buttons[t].text}

`:""} + ${this._config.buttons[t].icon?q``:""} +
`:q` +
+ ${this._config.buttons[t].text?q`

${this._config.buttons[t].text}

`:""} + ${this._config.buttons[t].icon?q``:""} +
`:q``});return q` +
+ ${t} + +
+ `}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"},"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% } + } + `}};l([ot()],Ce.prototype,"_hass",void 0),l([ot()],Ce.prototype,"_config",void 0),l([ot({attribute:!1})],Ce.prototype,"hass",void 0),l([at()],Ce.prototype,"config",void 0),Ce=l([nt("my-button")],Ce),console.info(`%c ---- MY-CARDS ---- \n%c ${a("common.version")} 2.0.4 `,"color: orange; font-weight: bold; background: black","color: white; font-weight: bold; background: green");export{Ce as MyButton,Zt as MySlider,he as MySliderV2}; diff --git a/docs/cards/button.md b/docs/cards/button.md index eac8e5c..7a4a9c4 100644 --- a/docs/cards/button.md +++ b/docs/cards/button.md @@ -22,15 +22,76 @@ It is completely customizable now and fully templatable. But is still very much | ---- | ---- | ------- | ----------- | | type | string | **Required** | `custom:my-slider-v2` | | entity | string | **Required** | `light.livingroom` | -| layout | string | vertical | Layout of card. Default is horizontal on cover entities. [Beautiful illustration of different layouts](#layouts) | | icon | string/object | "lightbulb-outline" | The icon to use. Can be an object like in the example. | | label | string/object | "entity.friendly_name" | The label text. Can be an object like the icon. Holds text, show and actions | -| slider | object | [Default slider config](/docs/cards/slider-v2.md) | The icon to use. Can be an object like in the example. | -| styles | object | [Default styles](#default-styles) | Style each component used in the card. | +| buttons | object | depends on entity type | This is the list of buttons and their config like tap_action etc. You can create as many or few buttons as you desire and have room for in your setup. Just create a 'button'+N where N is anything unique. The key names for the buttons does not matter. So you can just use 'button0', 'button1' and so on. | +| stats | object | depends on entity type | This is a static container that can be used to display a statistic in the top right corner. Default for light is brightness % otherwise it's entity state. You can give the stats container actions like any other component. | +| camera | string | Nothing | This can be set as a camera entity and then it can display the stream in the stats container. Only used with locks. | +| slider | object | [Slider config](/docs/cards/slider-v2.md) | Config for slider inside card. Look at available config keys in readme. Only extra key here is 'show': true/false | +| seekbar | object | [Slider config](/docs/cards/slider-v2.md) | Just another slider config with extra key 'show', but only used for media_player seekbars | +| styles | object | [Button styles](/src/cards/styles/my-button.styles.ts) | Default harcoded styles. For dynamic styles you can inspect the DOM to find css key to style or reference 'initializeStyles' function in [my-button.ts](/src/cards/my-button.ts) | ## Examples -![Examples](/docs/images/my-button/example-1.png) +![Examples](/docs/images/my-button/lights.png) +![Examples](/docs/images/my-button/lock.png) +
+![Examples](/docs/images/my-button/Light-switch-mediaplayer.png) +![Examples](/docs/images/my-button/media_player.gif) + +```yaml +- type: custom:my-button + entity: light.basement_room_spots + label: Room + icon: mdi:wall-sconce-flat + +- type: custom:my-button + entity: light.basement_entrance_spots + label: Entrance + icon: mdi:wall-sconce-flat + +- type: custom:my-button + entity: light.basement_hall_spots + label: Hall + icon: mdi:wall-sconce-flat + + +- type: custom:my-button + entity: lock.front_door + label: Front Door + camera: camera.front_door_cam + tap_action: + action: none + slider: + show: true + + +- type: custom:my-button + entity: media_player.office_google + label: Google Speaker + + +- type: horizontal-stack + title: Office + cards: + - type: custom:my-button + entity: light.grono_lamp_office + label: Lamp + icon: mdi:desk-lamp + + - type: custom:my-button + entity: switch.anthon_beast + label: PC + slider: + show: true + tap_action: + action: more-info + + - type: custom:my-button + entity: media_player.office_google + label: Google Speaker +``` + ```yaml - type: custom:my-button entity: light.front_door_spots @@ -42,6 +103,39 @@ It is completely customizable now and fully templatable. But is still very much action: toggle hold_action: action: more-info + stats: + show: true + text: 'Your custom text, can be templated' + styles: + container: + - border-radius: '12px' + camera: + - border: '1px solid red' + buttons: + show: true + vertical: false + button0: + show: true + text: 'B1' + icon: 'mdi:power' + styles: + text: + - color: 'black' + icon: + - color: 'orange' + tap_action: + action: toggle + slider: + show: true + vertical: true + styles: + card: + - background: 'orange' + seekbar: + show: true + styles: + card: + - background: 'purple' styles: card: - background: rgba(230, 230, 230, 0.5) @@ -59,66 +153,76 @@ It is completely customizable now and fully templatable. But is still very much action: more-info ``` +## Styling configs +It is possible to nest the styles to give a better overview of the yaml. So with the slider, it is possible to nest all the styles in the slider object like you would when using the slider card by itself. +Likewise, it is possible to style the buttonsContainer, buttons, text and icon for the new buttons directly in the buttons->styles object. +The same with the label and stats. +When doing it nested, the names are a little different since we dont need to specify sliderContainer, now we can just style the 'container' in the slider->styles. -### Default Styles: ```yaml -styles: - card: - - height: '125px' - - width: '100%' - - min-width: 'fit-content' - - background: 'var(--card-background-color)' - icon: - - height: '35px' - - width: '35px' - - display: 'inline-block' - - padding: '10px 10px 10px 10px' - - cursor: 'pointer' - - color: 'var(--paper-item-active-icon-color)' - labelWrapper: - - width: '100%' - - height: '100%' - - display: 'flex' - label: - - padding: '0' - - margin: '0 10px' - - color: 'var(--primary-text-color)' - - font-weight: 'bold' - container: - - padding: '0' - - margin: '0' - - display: 'flex' - - flex-flow: 'column' - - height: '100%' - row1: - - flex: '0 1 auto' - row2: - - flex: '1 1 auto' - row3: - - flex: '0 1 auto' - - margin: '0 2px 2px 2px' - containerColumn: - - padding: '0' - - margin: '0' - - display: 'flex' - - flex-flow: 'row' - - height: '100%' - column1: - - flex: '1' - column2: - - flex: '0' - - padding: '3px 3px 3px 0' -``` +'Styles can be set on the background of the track by setting it from the styles config in the root:' +- type: horizontal-stack + cards: + - type: custom:my-button + entity: lock.front_door + label: + text: Front Door + extra: Smaller label under + camera: camera.front_door_cam + slider: + show: true + styles: + sliderTrack: + - background: rgba(255, 0, 0, 0.5) -## Layouts -Here you see an illustration of where the different elements are so you can better style them. With the default styles above, you should be able to figure out what and where things go. -I will add more layout options as we go, also are more freestyle layout where you will just have the card and then everything in the root of that to put wherever you want. I'm not good with css, so if anyone has good ideas to layouts I should implement. Then please let me know. +'Or by setting it in the track directly on the slider:' +- type: custom:my-button + entity: lock.front_door + label: + text: Front Door + extra: Smaller label under + camera: camera.front_door_cam + slider: + show: true + styles: + track: + - background: rgba(255, 0, 0, 0.5) -![Layout Illustration](/docs/images/my-button/layouts-illustration.png) +'If using the buttons, you can set individual styling for each button. Or set a default for all of them and specify a specific style for one of them:' +- type: custom:my-button + entity: lock.front_door + label: + text: Front Door + extra: Smaller label under + camera: camera.front_door_cam + buttons: + show: true + vertical: true + button0: + show: true + icon: mdi:lock + tap_action: + action: more-info + styles: + container: + - background: rgba(0, 0, 255, 0.5) + button1: + show: true + icon: mdi:lock-open + tap_action: + action: more-info + styles: + button: + - background: rgba(255, 0, 0, 0.5) + slider: + show: true + styles: + track: + - background: rgba(255, 0, 0, 0.5) + styles: + sliderTrack: + - background: rgba(255, 0, 0, 0.5) +``` -- **row1** will fit content inside -- **row2** will fill the remaining space between row1 and 2 -- **row3** will fit content inside (On horizontal layout, this is empty so row2 technically fills all remaining space.) -- label will fit text -- labelWrapper will fill full space -- slider will use all default options from that card. Some styles are set here if it's vertical/cover etc. \ No newline at end of file +## Layouts +The illustration the button card is outdated and might still change further. So I will postpone creating another until I am certain that is the final layout of the card. Though I am pretty sure the one it currently has is going to be the final. \ No newline at end of file diff --git a/docs/cards/slider-v2.md b/docs/cards/slider-v2.md index 366bd24..4e360e1 100644 --- a/docs/cards/slider-v2.md +++ b/docs/cards/slider-v2.md @@ -17,9 +17,8 @@ It is completely customizable now and fully templatable. ### Future features (Maybe) - Text inside slider (Should be easily done with this new slider) -- Radius attribute to set how close to the thumb user has to be when allowTapping is set to false - If user is not actively changing the slider, then it should animate between states. -- **If you would like a new feature, please feel free to create an issue asking for it.** +- **If you would like something made or fixed, please feel free to create an issue asking about it.** ## Options @@ -28,8 +27,9 @@ It is completely customizable now and fully templatable. | type | string | **Required** | `custom:my-slider-v2` | | entity | string | **Required** | `light.livingroom` | | step | string | "1" | Number of steps to take (For input number, if step is not specified, it will use step from attributes.) (For media_player, if step is not specified it will step by 0.01. (It will actually step by 1, but it will convert 27 to 0.27. So if you set a custom step, set it between 0 and 100.)) | -| colorMode | string | brightness | Can be brightness, temperature, hue, saturation | -| coverMode | string | position | Can be position or tilt | +| colorMode (Deprecated: Use 'mode' instead) | string | brightness | Can be brightness, temperature, hue, saturation | +| coverMode (Deprecated: Use 'mode' instead) | string | position | Can be position or tilt | +| mode | string | cover:position, light:brightness | Can be position, tilt, brightness, temperature, hue, saturation, volume & seekbar | | vertical | boolean | false | This will set the slider to be vertical and handled from bottom to top. Default on covers | | flipped | boolean | false | This will just flip the slider to go from right to left or top to bottom. Default on covers | | inverse | boolean | false | Will inverse how far the slider has progressed compared to value. so if brightness is 75%, then it will only be 25% progressed. This is useful for cover, where it is Default. | @@ -44,7 +44,8 @@ It is completely customizable now and fully templatable. | maxThreshold | number | 75 | Only used to determine how far users have to slide to activate toggle commands for switch and lock | | min | number | 0 | Minimum value you can set the entity state | | max | number | 100 | Maximum value you can set the entity state | -| styles | object | [Default styles](#default-styles) | Style each component used in the card. | +| sliderMin | number | 0 | The minimum percentage progress to show always | +| styles | object | [Default styles](/src/cards/styles/my-slider.styles.ts) | Style each component used in the card. | ## Examples @@ -110,34 +111,4 @@ It is completely customizable now and fully templatable. card: - height: 200px - width: 50px -``` - - -### Default Styles: -```yaml -styles: - card: - - height: '30px' - container: - - width: '100%' - - height: '100%' - - position: 'relative' - - overflow: 'hidden' - - border-radius: '5px' - track: - - width: '100%' - - height: '100%' - - position: 'relative' - - background: 'var(--card-background-color)' - progress: - - height: '100%' - - background: 'var(--paper-item-icon-active-color)' - - position: 'absolute' - - width: '0.00%' # This will be where the progress is before it finds the actual state on load. Otherwise it's handled by the slider obviously. - thumb: - - height: '100%' - - background: 'black' - - position: 'absolute' - - right: '-5px' - - width: '10px' ``` \ No newline at end of file diff --git a/docs/images/my-button/Light-switch-mediaplayer.png b/docs/images/my-button/Light-switch-mediaplayer.png new file mode 100644 index 0000000..42f326c Binary files /dev/null and b/docs/images/my-button/Light-switch-mediaplayer.png differ diff --git a/docs/images/my-button/lights.png b/docs/images/my-button/lights.png new file mode 100644 index 0000000..b8fc60b Binary files /dev/null and b/docs/images/my-button/lights.png differ diff --git a/docs/images/my-button/lock.png b/docs/images/my-button/lock.png new file mode 100644 index 0000000..ab77ee3 Binary files /dev/null and b/docs/images/my-button/lock.png differ diff --git a/docs/images/my-button/media_player.gif b/docs/images/my-button/media_player.gif new file mode 100644 index 0000000..20ee889 Binary files /dev/null and b/docs/images/my-button/media_player.gif differ diff --git a/docs/images/my-button/media_player.png b/docs/images/my-button/media_player.png new file mode 100644 index 0000000..372d81a Binary files /dev/null and b/docs/images/my-button/media_player.png differ diff --git a/package.json b/package.json index f55cee3..172be15 100644 --- a/package.json +++ b/package.json @@ -48,13 +48,11 @@ "scripts": { "start": "npm run dev", "dev": "rollup -c ./other/ops/rollup.config.dev.js --watch", - "build": "npm run build:bundle && npm run build:button && npm run build:slider && npm run build:slider-v2", "build:bundle": "rollup -c ./other/ops/rollup.config.js", "build:button": "rollup -c ./other/ops/rollup.config.my-button.js", "build:slider": "rollup -c ./other/ops/rollup.config.my-slider.js", "build:slider-v2": "rollup -c ./other/ops/rollup.config.my-slider-v2.js", - "OLD:build:lint": "npm run lint && npm run OLD:rollup", "OLD:lint": "eslint src/*.ts", "OLD:rollup": "rollup -c" diff --git a/src/cards/extras/const.ts b/src/cards/extras/const.ts index dddf3fc..b2352ab 100644 --- a/src/cards/extras/const.ts +++ b/src/cards/extras/const.ts @@ -1,3 +1,24 @@ -export const CARD_VERSION = '2.0.3' -export const SLIDER_VERSION = '3.0.5' -export const BUTTON_VERSION = '1.0.1' \ No newline at end of file +export const CARD_VERSION = '2.0.4' +export const SLIDER_VERSION = '3.0.6' +export const BUTTON_VERSION = '1.0.2' + + + + +export const UNAVAILABLE = 'unavailable'; +export const BINARY_STATE_ON = 'on'; +export const BINARY_STATE_OFF = 'off'; +const arrayLiteralIncludes = + (array: T) => + (searchElement: unknown, fromIndex?: number): searchElement is T[number] => + array.includes(searchElement as T[number], fromIndex); + +export const UNKNOWN = 'unknown'; +export const ON = 'on'; +export const OFF = 'off'; + +export const UNAVAILABLE_STATES = [UNAVAILABLE, UNKNOWN] as const; +export const OFF_STATES = [UNAVAILABLE, UNKNOWN, OFF] as const; + +export const isUnavailableState = arrayLiteralIncludes(UNAVAILABLE_STATES); +export const isOffState = arrayLiteralIncludes(OFF_STATES); \ No newline at end of file diff --git a/src/cards/extras/types.ts b/src/cards/extras/types.ts deleted file mode 100644 index c4f5022..0000000 --- a/src/cards/extras/types.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { LovelaceCard, LovelaceCardConfig, LovelaceCardEditor } from 'custom-card-helpers'; - -declare global { - interface HTMLElementTagNameMap { - 'my-footer-card-editor': LovelaceCardEditor; - 'hui-error-card': LovelaceCard; - } -} - -export interface MySliderCardConfig extends LovelaceCardConfig { - type: string; - entity: string; -} - -export interface MyButtonCardConfig extends LovelaceCardConfig { - type: string; - entity: string; -} -export interface MyButtonCoverCardConfig extends LovelaceCardConfig { - type: string; - entity: string; -} \ No newline at end of file diff --git a/src/cards/my-button-cover.ts b/src/cards/my-button-cover.ts deleted file mode 100644 index fffd025..0000000 --- a/src/cards/my-button-cover.ts +++ /dev/null @@ -1,431 +0,0 @@ -/* eslint-disable @typescript-eslint/no-explicit-any */ -import { - LitElement, - html, - customElement, - property, - CSSResult, - TemplateResult, - css, - PropertyValues, - internalProperty, -} from 'lit-element'; -// import { HassEntity } from 'home-assistant-js-websocket' -import { - HomeAssistant, - hasConfigOrEntityChanged, - hasAction, - ActionHandlerEvent, - handleAction, - handleClick, -} from 'custom-card-helpers' // This is a community maintained npm module with common helper functions/types -import { actionHandler } from '../scripts/action-handler-directive' -import { disableBodyScroll, enableBodyScroll } from 'body-scroll-lock' - -import type { MyButtonCoverCardConfig } from './extras/types' -import { BUTTON_COVER_VERSION } from './extras/const' -import { localize } from '../localize/localize' -import { objectToStyleString } from '../scripts/helpers' -import { getStyle } from './styles/style-configs' - -/* eslint no-console: 0 */ -console.info( - `%c ---- MY-BUTTON-COVER ---- \n%c ${localize('common.version')} ${BUTTON_COVER_VERSION} `, - 'color: orange; font-weight: bold; background: black', - 'color: white; font-weight: bold; background: green', -); - -// This puts your card into the UI card picker dialog -(window as any).customCards = (window as any).customCards || []; -(window as any).customCards.push({ - type: 'my-button-cover', - name: 'Cover Button Card', - description: 'Custom Cover Button Card for Lovelace.', -}) - -@customElement('my-button-cover') -export class MyButtonCover extends LitElement { - // private _stateObj: HassEntity | undefined; - // private _evaledVariables: any | undefined; - - public static getStubConfig(): object { - return {} - } - - static get properties() { - return { - hass: {}, - config: {}, - active: {} - } - } - - @property({ attribute: false }) public hass!: HomeAssistant; - @internalProperty() private config!: MyButtonCoverCardConfig; - - // https://lit-element.polymer-project.org/guide/properties#accessors-custom - public setConfig(config: MyButtonCoverCardConfig): void { - - if (!config.entity) { - throw new Error("You need to define entity"); - } - - if (!config.entity.includes("cover.")) { - throw new Error("Entity has to be a cover."); - } - - this.config = { - name: 'MyButtonCover', - disabled_scroll: false, - ...config, - } - } - - // https://lit-element.polymer-project.org/guide/lifecycle#shouldupdate - protected shouldUpdate(changedProps: PropertyValues): boolean { - if (!this.config) { - return false - } - - return hasConfigOrEntityChanged(this, changedProps, false) - } - - // https://lit-element.polymer-project.org/guide/templates - protected render(): TemplateResult | void { - // console.log('Config:', this.config) - // var conf = JSON.parse(JSON.stringify(this.config)) - const styles = this.config.styles ? JSON.parse(JSON.stringify(this.config.styles)) : {} - const entityId = this.config.entity ? this.config.entity : "ERROR" - const entity = this.hass.states[`${entityId}`] - - // ---- Icon Config ---- // - const defaultIconAttr = { - show: true, - icon: '', - iconOpen: 'mdi:blinds-open', - iconClose: 'mdi:blinds', - } - // If icon is just a string, then save that under iconConfig. If it's an object, then combine default with custom configs. If nothing then just use default config - const iconConfig = typeof this.config.icon === 'string' ? { ...defaultIconAttr, icon: this.config.icon } : typeof this.config.icon === 'object' ? { ...defaultIconAttr, ...this.config.icon } : defaultIconAttr - - // ---- Label Config ---- // - const defaultLabelAttr = { - show: true, - text: entity.attributes.friendly_name, - vertical: true - } - // If label is just a string, then save that under labelConfig. If it's an object, then combine default with custom configs. If nothing then just use default config - const labelConfig = typeof this.config.label === 'string' ? { ...defaultLabelAttr, text: this.config.label } : typeof this.config.label === 'object' ? { ...defaultLabelAttr, ...this.config.label } : defaultLabelAttr - - // ---- Slider Config ---- // - const defaultSliderConfig = { - min: 0, - max: 100, - step: '1' - } - const sliderConfig = this.config.slider ? { ...defaultSliderConfig, ...this.config.slider } : defaultSliderConfig - - // ---- Styles ---- // - const cardStyle = getStyle('my-button-card', styles.card) - const iconStyle = getStyle('my-button-icon', styles.icon) - const labelStyle = labelConfig.vertical ? getStyle('my-button-label-vertical', styles.label) : getStyle('my-button-label', styles.label) - const labelWrapperStyle = getStyle('my-button-label-wrapper', styles['label-wrapper']) - const { containerStyle, inputStyle } = getStyle('my-button-slider-vertical', styles.slider) - const sliderWrapperStyle = getStyle('my-button-slider-wrapper', styles.slider?.wrapper) - - const toggleScroll = () => { - this.config.disabled_scroll = !this.config.disabled_scroll - if (this.config.disabled_scroll) { - disableBodyScroll(window) - } else { - enableBodyScroll(window) - } - } - - const handleSlider = (e) => { - this._setCover(entity, e.target, sliderConfig.min, sliderConfig.max) - } - - if (entityId === 'ERROR') - return html`Error: No Entity ID` - - - const icon = () => { - if (!iconConfig.show) return html`` - let icon = iconConfig.icon ? iconConfig.icon : '' - let iconOpen = iconConfig.iconOpen ? iconConfig.iconOpen : 'mdi:blinds-open' - let iconClose = iconConfig.iconClose ? iconConfig.iconClose : 'mdi:blinds' - - if (icon === '') { - icon = iconClose - if (entity.attributes.current_position >= 50) { - icon = iconOpen - } - } - - return html` - this._handleAction(e, iconConfig)} - .actionHandler=${actionHandler({ - hasDoubleClick: iconConfig?.double_tap_action?.action !== 'none', - hasHold: iconConfig?.hold_action?.action !== 'none', - })} - /> - ` - } - - const label = () => { - if (!labelConfig.show) return html`` - return html` -
this._handleAction(e, labelConfig)} - .actionHandler=${actionHandler({ - hasDoubleClick: labelConfig?.double_tap_action?.action !== 'none', - hasHold: labelConfig?.hold_action?.action !== 'none', - })} - > - - -
- ` - } - - return html` - -
-
-
this._handleAction(e, this.config)} - .actionHandler=${actionHandler({ - hasDoubleClick: this.config?.double_tap_action?.action !== 'none', - hasHold: this.config?.hold_action?.action !== 'none', - })} - > -
-
- ${icon()} -
-
- ${label()} -
-
-
-
-
-
-
- -
-
-
-
-
-
- `; - } - - private _handleAction(ev: any, actionConfig: any): void { - if (!actionConfig.entity) { - actionConfig.entity = this.config.entity - } - if (ev.detail?.action) { - switch (ev.detail.action) { - case 'tap': - if (actionConfig.tap_action) - this._handleTap(actionConfig); - break; - case 'hold': - if (actionConfig.hold_action) - this._handleHold(actionConfig); - break; - case 'double_tap': - if (actionConfig.double_tap_action) - this._handleDblTap(actionConfig); - break; - default: - break; - } - } - } - - private _handleTap(actionConfig: any): void { - // handleClick(this, this.hass!, this._evalActions(config, 'tap_action'), false, false); - handleAction(this, this.hass, actionConfig, 'tap') - } - - private _handleHold(actionConfig: any): void { - // handleClick(this, this.hass!, this._evalActions(config, 'hold_action'), true, false); - handleAction(this, this.hass, actionConfig, 'hold') - } - - private _handleDblTap(actionConfig: any): void { - // handleClick(this, this.hass!, this._evalActions(config, 'double_tap_action'), false, true); - handleAction(this, this.hass, actionConfig, 'double_tap') - } - - private _setCover(_entity, _target, _minSet, _maxSet): void { - var value = _target.value; - if (value > _maxSet) { - value = _maxSet; - } else if (value < _minSet) { - value = _minSet; - } - - this.hass.callService("cover", "set_cover_position", { - entity_id: _entity.entity_id, - position: value - }); - - _target.value = value; - } - - // https://lit-element.polymer-project.org/guide/styles - static get styles(): CSSResult { - return css` - .my-button-icon { - --mdc-icon-size: 100%; - } - .my-button-wrapper { - height: 100%; - width: 100%; - margin: 0; - padding: 0; - position: relative; - pointer-events: auto; - } - .flex-container-columns { - padding: 0; - margin: 0; - display: flex; - flex-flow: row; - height: 100%; - pointer-events: auto; - } - .flex-container-columns .column-1 { - flex: 1; - } - .flex-container-columns .column-2 { - flex: 0; - } - - .flex-container-rows { - padding: 0; - margin: 0; - display: flex; - flex-flow: column; - height: 100%; - } - - .flex-container-rows .row-1 { - flex: 0 1 auto; - } - .flex-container-rows .row-2 { - flex: 1 1 auto; - padding-bottom: 5px; - } - .flex-container-rows .row-3 { - flex: 0 1 auto; - } - - - .slider-container input[type="range"]::-webkit-slider-runnable-track { - height: 100%; - -webkit-appearance: none; - color: var(--accent-color); - transition: box-shadow 0.2s ease-in-out; - } - - .slider-container input[type="range"]::-webkit-slider-thumb { - width: 8px; - height: 80px; - -webkit-appearance: none; - cursor: ew-resize; - border-radius: 0; - transition: box-shadow 0.2s ease-in-out; - position: relative; - - box-shadow: -3500px 0 0 3500px var(--slider-color), inset 0 0 0 25px rgba(0, 0, 0, 0); - - top: calc((100% - 80px) / 2); - border-right: 2px solid var(--slider-color); - border-left: 4px solid var(--slider-color); - border-top: 28px solid var(--slider-color); - border-bottom: 28px solid var(--slider-color); - pointer-events: auto; - } - - .slider-container input[type=range]::-moz-range-thumb { - width: calc(25px / 4); - height: calc(80px / 2); - box-shadow: -3500px 10px 0 3500px var(--slider-color), inset 0 0 0 25px rgba(0, 0, 0, 0); - top: calc((100% - 80px) / 2); - cursor: ew-resize; - border-radius: 0; - transition: box-shadow 0.2s ease-in-out; - position: relative; - border-radius: 0; - border-right: 10px solid var(--slider-color); - border-left: 10px solid var(--slider-color); - border-top: 20px solid var(--slider-color); - border-bottom: 20px solid var(--slider-color); - pointer-events: auto; - } - - .slider-container input[type="range"]::-webkit-slider-thumb:hover { - cursor: default; - } - - .slider-container input[type="range"]:hover { - cursor: default; - } - `; - } -} - -// Options: - -// entity -// icon -// label -// text -// show -// vertical -// slider -// intermediate -// step -// min -// max -// toggle_scroll -// styles -// card -// color-on: rgba(253, 216, 53, 1) -// color-off: rgba(86, 86, 86, 0.75) -// icon -// color-on: green -// color-off: red -// label -// label-wrapper (only used if label.vertical = true) -// slider: -// container: -// color-on: rgba(253, 216, 53, 1) -// color-off: rgba(86, 86, 86, 0.75) -// input: -// height: 100% -// track: (Not implemented yet) -// height: 100% -// color: red -// thumb: (Not implemented yet) -// height: 80px -// tap_action -// double_tap_action -// hold_action \ No newline at end of file diff --git a/src/cards/my-button.ts b/src/cards/my-button.ts index e1edc95..181544a 100644 --- a/src/cards/my-button.ts +++ b/src/cards/my-button.ts @@ -10,22 +10,23 @@ import { PropertyValues, state, } from 'lit-element' -import { styleMap, StyleInfo } from 'lit-html/directives/style-map' +import { styleMap, StyleInfo } from 'lit-html/directives/style-map' // type StyleInfo import { HassEntity } from 'home-assistant-js-websocket' -import { - HomeAssistant, - hasConfigOrEntityChanged, - handleClick, - LovelaceCard -} from 'custom-card-helpers'; // This is a community maintained npm module with common helper functions/types -import { actionHandler } from '../scripts/action-handler-directive'; - -import type { MyButtonCardConfig } from './extras/types'; -import { BUTTON_VERSION } from './extras/const'; -import { localize } from '../localize/localize'; +import { hasConfigOrEntityChanged, } from 'custom-card-helpers' // This is a community maintained npm module with common helper functions/types + +import { BUTTON_VERSION } from './extras/const' +import type { LovelaceCard } from '../types/lovelace'; +import type { HomeAssistant } from '../types/homeassistant'; +import type { MyButtonConfig } from '../types/types' + +import { actionHandler } from '../scripts/action-handler' +import { handleAction } from '../scripts/handle-action' + +import { localize } from '../localize/localize' import { getStyle } from './styles/my-button.styles' import { deflate } from '../scripts/deflate' -import { deepMerge, percentage } from '../scripts/helpers' +import { deepMerge, percentage, stateActive } from '../scripts/helpers' +import { evalActions, objectEvalTemplate } from '../scripts/templating' /* eslint no-console: 0 */ console.info( @@ -40,32 +41,14 @@ console.info( type: 'my-button', name: 'My Button Card', description: 'Custom Button Card for Lovelace.', -}); +}) @customElement('my-button') export class MyButton extends LitElement { - @property() private _config?: MyButtonCardConfig + @property() private _hass?: HomeAssistant; + @property() private _config?: MyButtonConfig private entity: HassEntity | undefined private lastAction: number = 0 - private layout: string = 'vertical' - private iconConfig: any = {} - private labelConfig: any = {} - private sliderConfig: any = {} - private statsConfig: any = {} - - // STYLES - private cardStl: StyleInfo = {} - private containerStl: StyleInfo = {} - private containerColumnStl: StyleInfo = {} - private iconStl: StyleInfo = {} - private statsStl: StyleInfo = {} - private labelWrapperStl: StyleInfo = {} - private labelStl: StyleInfo = {} - private row1Stl: StyleInfo = {} - private row2Stl: StyleInfo = {} - private row3Stl: StyleInfo = {} - private column1Stl: StyleInfo = {} - private column2Stl: StyleInfo = {} public static getStubConfig(): object { return {} @@ -80,21 +63,26 @@ export class MyButton extends LitElement { } @property({ attribute: false }) public hass!: HomeAssistant; - @state() private config!: MyButtonCardConfig; + @state() private config!: MyButtonConfig; // https://lit-element.polymer-project.org/guide/properties#accessors-custom - public setConfig(config: MyButtonCardConfig): void { + public setConfig(config: MyButtonConfig): void { const allowedEntities = [ + '', 'light', 'cover', - 'switch' + 'switch', + 'input_boolean', + 'button', + 'lock', + 'media_player' ] - if (!config.entity) { - throw new Error("You need to define entity") - } + // if (!config.entity) { + // throw new Error("You need to define entity") + // } - if (!allowedEntities.includes(config.entity.split('.')[0])) { + if (config.entity && !allowedEntities.includes(config.entity.split('.')[0])) { throw new Error(`Entity has to be one of the following: ${allowedEntities.map(e => ' ' + e)}`) } @@ -109,82 +97,80 @@ export class MyButton extends LitElement { if (!this.config) { return false } - return hasConfigOrEntityChanged(this, changedProps, false) } + // After your component has been rendered + updated(changedProperties: PropertyValues) { + super.updated(changedProperties); + requestAnimationFrame(() => { + const labelEl = this.shadowRoot?.querySelector('[data-container="label-row"]') as HTMLElement; + const extraText = labelEl?.querySelector('p') as HTMLElement; + + if (labelEl && extraText) { + const extraTextStyles = window.getComputedStyle(extraText) + const labelElStyles = window.getComputedStyle(labelEl) + + const labelElWidth = labelEl.offsetWidth + const extraTextWidth = extraText.offsetWidth + const extraTextMarginLeft = parseFloat(extraTextStyles.marginLeft) + const extraTextMarginRight = parseFloat(extraTextStyles.marginRight) + const labelElPaddingLeft = parseFloat(labelElStyles.paddingLeft) + const labelElPaddingRight = parseFloat(labelElStyles.paddingRight) + + const totalExtraTextWidth = extraTextWidth + extraTextMarginLeft + extraTextMarginRight; + const availableLabelElWidth = labelElWidth - labelElPaddingLeft - labelElPaddingRight; + if (totalExtraTextWidth < availableLabelElWidth) { + extraText.style.animation = '' + } + else { + extraText.style.animation = 'marquee 10s linear infinite' + } + } + }) + } // https://lit-element.polymer-project.org/guide/templates protected render(): TemplateResult | void { const initFailed = this.initializeConfig() if (initFailed !== null) return initFailed - if (!this.entity || !this._config) return html`` - + if (!this._config) return html`` - if (this.layout === 'vertical') { - return this.verticalLayoutCard() - } - else { - return this.horizontalLayoutCard() - } + return this.dynamicCard() } // ------------------- CUSTOM CARDS ------------------- // - private verticalLayoutCard(): TemplateResult { + private dynamicCard(): TemplateResult { return html` - -
-
this._handleAction(e, this.config)} - .actionHandler=${actionHandler({ - hasDoubleClick: this.config?.double_tap_action?.action !== 'none', - hasHold: this.config?.hold_action?.action !== 'none', + +
+
this._handleAction(e, this._config)} + .actionHandler=${actionHandler({ + hasDoubleClick: this._config?.double_tap_action?.action !== 'none', + hasHold: this._config?.hold_action?.action !== 'none', + repeat: this._config?.hold_action?.repeat, + repeatLimit: this._config?.hold_action?.repeat_limit, })}> - ${this.iconElement()} +
+ ${this.iconElement()} + ${this.statsElement()} +
+
+ ${this.labelElement()} +
- ${this.statsElement()}
-
this._handleAction(e, this.config)} - .actionHandler=${actionHandler({ - hasDoubleClick: this.config?.double_tap_action?.action !== 'none', - hasHold: this.config?.hold_action?.action !== 'none', - })}> - ${this.labelElement()} +
+ ${this._config.buttons.vertical === false ? this.buttonsElement() : ''}
-
- ${this.sliderElement()} +
+ ${this._config.slider.vertical === false ? this.sliderElement() : ''} + ${this._config.seekbar.show ? this.seekbarElement() : ''}
-
- - `; - } - private horizontalLayoutCard(): TemplateResult { - return html` - -
-
-
-
this._handleAction(e, this.config)} - .actionHandler=${actionHandler({ - hasDoubleClick: this.config?.double_tap_action?.action !== 'none', - hasHold: this.config?.hold_action?.action !== 'none', - })}> - ${this.iconElement()} -
-
this._handleAction(e, this.config)} - .actionHandler=${actionHandler({ - hasDoubleClick: this.config?.double_tap_action?.action !== 'none', - hasHold: this.config?.hold_action?.action !== 'none', - })}> - ${this.labelElement()} -
-
-
-
+
+ ${this._config.buttons.vertical === true ? this.buttonsElement() : ''}
-
- ${this.sliderElement()} +
+ ${this._config.slider.vertical === true ? this.sliderElement() : ''}
@@ -192,91 +178,175 @@ export class MyButton extends LitElement { } private iconElement(): TemplateResult { - if (!this.iconConfig.show) return html`` + if (!this._config.icon.show) return html`` - if (this.iconConfig.tap_action || this.iconConfig.double_tap_action || this.iconConfig.hold_action) { + if (this._config.icon.tap_action || this._config.icon.double_tap_action || this._config.icon.hold_action) { return html` - this._handleAction(e, this.iconConfig)} + this._handleAction(e, this._config.icon)} .actionHandler=${actionHandler({ - hasDoubleClick: this.iconConfig.double_tap_action?.action !== 'none', - hasHold: this.iconConfig.hold_action?.action !== 'none', + hasDoubleClick: this._config.icon.double_tap_action?.action !== 'none', + hasHold: this._config.icon.hold_action?.action !== 'none', + repeat: this._config.icon.hold_action?.repeat, + repeatLimit: this._config.icon.hold_action?.repeat_limit, })} /> ` } else { return html` - + ` } } private statsElement(): TemplateResult { - if (!this.statsConfig.show) return html`` + if (!this._config.stats.show) return html`` - if (this.statsConfig.tap_action || this.statsConfig.double_tap_action || this.statsConfig.hold_action) { - return html` -
this._handleAction(e, this.statsConfig)} + if (this._config.stats.tap_action || this._config.stats.double_tap_action || this._config.stats.hold_action) { + if (this._config.camera) { + return html` +
this._handleAction(e, this._config.stats)} .actionHandler=${actionHandler({ - hasDoubleClick: this.statsConfig.double_tap_action?.action !== 'none', - hasHold: this.statsConfig.hold_action?.action !== 'none', - })}> - - ${this.statsConfig.text} - -
- ` + hasDoubleClick: this._config.stats.double_tap_action?.action !== 'none', + hasHold: this._config.stats.hold_action?.action !== 'none', + repeat: this._config.stats.hold_action?.repeat, + repeatLimit: this._config.stats.hold_action?.repeat_limit, + })}> +
+ + ${this._config.stats.text} +
+
+ ` + } + else { + return html` +
this._handleAction(e, this._config.stats)} + .actionHandler=${actionHandler({ + hasDoubleClick: this._config.stats.double_tap_action?.action !== 'none', + hasHold: this._config.stats.hold_action?.action !== 'none', + repeat: this._config.stats.hold_action?.repeat, + repeatLimit: this._config.stats.hold_action?.repeat_limit, + })}> + +
+ ${this._config.stats.text} +
+ +
+ ` + } } else { - return html` -
- ${this.statsConfig.text} -
- ` + if (this._config.camera) { + return html` +
+
+ +
+
+ ` + } + else { + return html` +
+
+ ${this._config.stats.text} +
+
+ ` + } } } private labelElement(): TemplateResult { - if (!this.labelConfig.show) return html`` + if (!this._config.label.show) return html`` - - if (this.labelConfig.tap_action || this.labelConfig.double_tap_action || this.labelConfig.hold_action) { + if (this._config.label.tap_action || this._config.label.double_tap_action || this._config.label.hold_action) { return html` -
-