diff --git a/dist/big-slider-card.js b/dist/big-slider-card.js index 5100b51..6917d0f 100644 --- a/dist/big-slider-card.js +++ b/dist/big-slider-card.js @@ -1,4 +1,4 @@ -function t(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 +function t(t,e,i,s){var r,n=arguments.length,o=n<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,i,s);else for(var a=t.length-1;a>=0;a--)(r=t[a])&&(o=(n<3?r(o):n>3?r(e,i,o):r(e,i))||o);return n>3&&o&&Object.defineProperty(e,i,o),o /** * @license * Copyright (c) 2017 The Polymer Project Authors. All rights reserved. @@ -11,7 +11,7 @@ function t(t,e,i,n){var s,o=arguments.length,r=o<3?e:null===n?n=Object.getOwnPro * 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="undefined"!=typeof window&&null!=window.customElements&&void 0!==window.customElements.polyfillWrapFlushCallback,i=(t,e,i=null)=>{for(;e!==i;){const i=e.nextSibling;t.removeChild(e),e=i}},n=`{{lit-${String(Math.random()).slice(2)}}}`,s=`\x3c!--${n}--\x3e`,o=new RegExp(`${n}|${s}`),r="$lit$";class a{constructor(t,e){this.parts=[],this.element=e;const i=[],s=[],a=document.createTreeWalker(e.content,133,null,!1);let l=0,h=-1,p=0;const{strings:m,values:{length:f}}=t;for(;p0;){const e=m[p],i=u.exec(e)[2],n=i.toLowerCase()+r,s=t.getAttribute(n);t.removeAttribute(n);const a=s.split(o);this.parts.push({type:"attribute",index:h,name:i,strings:a}),p+=a.length-1}}"TEMPLATE"===t.tagName&&(s.push(t),a.currentNode=t.content)}else if(3===t.nodeType){const e=t.data;if(e.indexOf(n)>=0){const n=t.parentNode,s=e.split(o),a=s.length-1;for(let e=0;e{const i=t.length-e.length;return i>=0&&t.slice(i)===e},l=t=>-1!==t.index,d=()=>document.createComment(""),u=/([ \x09\x0a\x0c\x0d])([^\0-\x1F\x7F-\x9F "'>=/]+)([ \x09\x0a\x0c\x0d]*=[ \x09\x0a\x0c\x0d]*(?:[^ \x09\x0a\x0c\x0d"'`<>=]*|"[^"]*|'[^']*))$/,h=133;function p(t,e){const{element:{content:i},parts:n}=t,s=document.createTreeWalker(i,h,null,!1);let o=f(n),r=n[o],a=-1,c=0;const l=[];let d=null;for(;s.nextNode();){a++;const t=s.currentNode;for(t.previousSibling===d&&(d=null),e.has(t)&&(l.push(t),null===d&&(d=t)),null!==d&&c++;void 0!==r&&r.index===a;)r.index=null!==d?-1:r.index-c,o=f(n,o),r=n[o]}l.forEach((t=>t.parentNode.removeChild(t)))}const m=t=>{let e=11===t.nodeType?0:1;const i=document.createTreeWalker(t,h,null,!1);for(;i.nextNode();)e++;return e},f=(t,e=-1)=>{for(let i=e+1;i{for(;e!==i;){const i=e.nextSibling;t.removeChild(e),e=i}},s=`{{lit-${String(Math.random()).slice(2)}}}`,r=`\x3c!--${s}--\x3e`,n=new RegExp(`${s}|${r}`),o="$lit$";class a{constructor(t,e){this.parts=[],this.element=e;const i=[],r=[],a=document.createTreeWalker(e.content,133,null,!1);let c=0,u=-1,p=0;const{strings:m,values:{length:f}}=t;for(;p0;){const e=m[p],i=h.exec(e)[2],s=i.toLowerCase()+o,r=t.getAttribute(s);t.removeAttribute(s);const a=r.split(n);this.parts.push({type:"attribute",index:u,name:i,strings:a}),p+=a.length-1}}"TEMPLATE"===t.tagName&&(r.push(t),a.currentNode=t.content)}else if(3===t.nodeType){const e=t.data;if(e.indexOf(s)>=0){const s=t.parentNode,r=e.split(n),a=r.length-1;for(let e=0;e{const i=t.length-e.length;return i>=0&&t.slice(i)===e},c=t=>-1!==t.index,d=()=>document.createComment(""),h=/([ \x09\x0a\x0c\x0d])([^\0-\x1F\x7F-\x9F "'>=/]+)([ \x09\x0a\x0c\x0d]*=[ \x09\x0a\x0c\x0d]*(?:[^ \x09\x0a\x0c\x0d"'`<>=]*|"[^"]*|'[^']*))$/,u=133;function p(t,e){const{element:{content:i},parts:s}=t,r=document.createTreeWalker(i,u,null,!1);let n=f(s),o=s[n],a=-1,l=0;const c=[];let d=null;for(;r.nextNode();){a++;const t=r.currentNode;for(t.previousSibling===d&&(d=null),e.has(t)&&(c.push(t),null===d&&(d=t)),null!==d&&l++;void 0!==o&&o.index===a;)o.index=null!==d?-1:o.index-l,n=f(s,n),o=s[n]}c.forEach((t=>t.parentNode.removeChild(t)))}const m=t=>{let e=11===t.nodeType?0:1;const i=document.createTreeWalker(t,u,null,!1);for(;i.nextNode();)e++;return e},f=(t,e=-1)=>{for(let i=e+1;i"function"==typeof t&&g.has(t),_={},v={}; +const g=new WeakMap,_=t=>"function"==typeof t&&g.has(t),v={},y={}; /** * @license * Copyright (c) 2017 The Polymer Project Authors. All rights reserved. @@ -39,7 +39,7 @@ const g=new WeakMap,y=t=>"function"==typeof t&&g.has(t),_={},v={}; * subject to an additional IP rights grant found at * http://polymer.github.io/PATENTS.txt */ -class w{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=e?this.template.element.content.cloneNode(!0):document.importNode(this.template.element.content,!0),i=[],n=this.template.parts,s=document.createTreeWalker(t,133,null,!1);let o,r=0,a=0,c=s.nextNode();for(;rt}),S=` ${n} `;class x{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 o=0;o-1||i)&&-1===t.indexOf("--\x3e",a+1);const c=u.exec(t);e+=null===c?t+(i?S:s):t.substr(0,c.index)+c[1]+c[2]+r+c[3]+n}return e+=this.strings[t],e}getTemplateElement(){const t=document.createElement("template");let e=this.getHTML();return void 0!==b&&(e=b.createHTML(e)),t.innerHTML=e,t}} + */const w=window.trustedTypes&&trustedTypes.createPolicy("lit-html",{createHTML:t=>t}),S=` ${s} `;class x{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 n=0;n-1||i)&&-1===t.indexOf("--\x3e",a+1);const l=h.exec(t);e+=null===l?t+(i?S:r):t.substr(0,l.index)+l[1]+l[2]+o+l[3]+s}return e+=this.strings[t],e}getTemplateElement(){const t=document.createElement("template");let e=this.getHTML();return void 0!==w&&(e=w.createHTML(e)),t.innerHTML=e,t}} /** * @license * Copyright (c) 2017 The Polymer Project Authors. All rights reserved. @@ -65,7 +65,7 @@ class w{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 k=t=>null===t||!("object"==typeof t||"function"==typeof t),P=t=>Array.isArray(t)||!(!t||!t[Symbol.iterator]);class T{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 M=!0,!1}};window.addEventListener("test",t,t),window.removeEventListener("test",t,t)}catch(t){}})();class V{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(;y(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=R(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 R=t=>t&&(M?{capture:t.capture,passive:t.passive,once:t.once}:t.capture) + */const T=t=>null===t||!("object"==typeof t||"function"==typeof t),k=t=>Array.isArray(t)||!(!t||!t[Symbol.iterator]);class P{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 V=!0,!1}};window.addEventListener("test",t,t),window.removeEventListener("test",t,t)}catch(t){}})();class U{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(;_(this.__pendingValue);){const t=this.__pendingValue;this.__pendingValue=v,t(this)}if(this.__pendingValue===v)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=j(t),this.element.addEventListener(this.eventName,this.__boundHandleEvent,this.__options)),this.value=t,this.__pendingValue=v}handleEvent(t){"function"==typeof this.value?this.value.call(this.eventContext||this.element,t):this.value.handleEvent(t)}}const j=t=>t&&(V?{capture:t.capture,passive:t.passive,once:t.once}:t.capture) /** * @license * Copyright (c) 2017 The Polymer Project Authors. All rights reserved. @@ -78,7 +78,7 @@ class w{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 U(t){let e=j.get(t.type);void 0===e&&(e={stringsArray:new WeakMap,keyString:new Map},j.set(t.type,e));let i=e.stringsArray.get(t.strings);if(void 0!==i)return i;const s=t.strings.join(n);return i=e.keyString.get(s),void 0===i&&(i=new a(t,t.getTemplateElement()),e.keyString.set(s,i)),e.stringsArray.set(t.strings,i),i}const j=new Map,D=new WeakMap; + */;function R(t){let e=M.get(t.type);void 0===e&&(e={stringsArray:new WeakMap,keyString:new Map},M.set(t.type,e));let i=e.stringsArray.get(t.strings);if(void 0!==i)return i;const r=t.strings.join(s);return i=e.keyString.get(r),void 0===i&&(i=new a(t,t.getTemplateElement()),e.keyString.set(r,i)),e.stringsArray.set(t.strings,i),i}const M=new Map,L=new WeakMap; /** * @license * Copyright (c) 2017 The Polymer Project Authors. All rights reserved. @@ -91,7 +91,7 @@ class w{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 L=new + */const I=new /** * @license * Copyright (c) 2017 The Polymer Project Authors. All rights reserved. @@ -105,7 +105,7 @@ class w{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,n){const s=e[0];if("."===s){return new O(t,e.slice(1),i).parts}if("@"===s)return[new V(t,e.slice(1),n.eventContext)];if("?"===s)return[new E(t,e.slice(1),i)];return new T(t,e,i).parts}handleTextExpression(t){return new C(t)}}; +class{handleAttributeExpressions(t,e,i,s){const r=e[0];if("."===r){return new O(t,e.slice(1),i).parts}if("@"===r)return[new U(t,e.slice(1),s.eventContext)];if("?"===r)return[new N(t,e.slice(1),i)];return new P(t,e,i).parts}handleTextExpression(t){return new E(t)}}; /** * @license * Copyright (c) 2017 The Polymer Project Authors. All rights reserved. @@ -118,7 +118,7 @@ class{handleAttributeExpressions(t,e,i,n){const s=e[0];if("."===s){return new O( * 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 I=(t,...e)=>new x(t,e,"html",L) + */"undefined"!=typeof window&&(window.litHtmlVersions||(window.litHtmlVersions=[])).push("1.4.1");const $=(t,...e)=>new x(t,e,"html",I) /** * @license * Copyright (c) 2017 The Polymer Project Authors. All rights reserved. @@ -131,7 +131,7 @@ class{handleAttributeExpressions(t,e,i,n){const s=e[0];if("."===s){return new O( * 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 $=!0;void 0===window.ShadyCSS?$=!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."),$=!1);const q=t=>e=>{const i=B(e.type,t);let s=j.get(i);void 0===s&&(s={stringsArray:new WeakMap,keyString:new Map},j.set(i,s));let o=s.stringsArray.get(e.strings);if(void 0!==o)return o;const r=e.strings.join(n);if(o=s.keyString.get(r),void 0===o){const i=e.getTemplateElement();$&&window.ShadyCSS.prepareTemplateDom(i,t),o=new a(e,i),s.keyString.set(r,o)}return s.stringsArray.set(e.strings,o),o},z=["html","svg"],H=new Set,W=(t,e,i)=>{H.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=j.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)})),p(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,h,null,!1);let r=f(s),a=0,c=-1;for(;o.nextNode();)for(c++,o.currentNode===i&&(a=m(e),i.parentNode.insertBefore(e,i));-1!==r&&s[r].index===c;){if(a>0){for(;-1!==r;)s[r].index+=a,r=f(s,r);return}r=f(s,r)}}(i,r,a.firstChild):a.insertBefore(r,a.firstChild),window.ShadyCSS.prepareTemplateStyles(n,t);const c=a.querySelector("style");if(window.ShadyCSS.nativeShadow&&null!==c)e.insertBefore(c.cloneNode(!0),e.firstChild);else if(i){a.insertBefore(r,a.firstChild);const t=new Set;t.add(r),p(i,t)}};window.JSCompiler_renameProperty=(t,e)=>t;const F={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}},X=(t,e)=>e!==t&&(e==e||t==t),Y={attribute:!0,type:String,converter:F,reflect:!1,hasChanged:X},J="finalized";class G 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=Y){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)||Y}static finalize(){const t=Object.getPrototypeOf(this);if(t.hasOwnProperty(J)||t.finalize(),this[J]=!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=X){return i(t,e)}static _propertyValueFromAttribute(t,e){const i=e.type,n=e.converter||F,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||F.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=Y){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){}}G[J]=!0; + */,q=(t,e)=>`${t}--${e}`;let z=!0;void 0===window.ShadyCSS?z=!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."),z=!1);const B=t=>e=>{const i=q(e.type,t);let r=M.get(i);void 0===r&&(r={stringsArray:new WeakMap,keyString:new Map},M.set(i,r));let n=r.stringsArray.get(e.strings);if(void 0!==n)return n;const o=e.strings.join(s);if(n=r.keyString.get(o),void 0===n){const i=e.getTemplateElement();z&&window.ShadyCSS.prepareTemplateDom(i,t),n=new a(e,i),r.keyString.set(o,n)}return r.stringsArray.set(e.strings,n),n},X=["html","svg"],Y=new Set,D=(t,e,i)=>{Y.add(t);const s=i?i.element:document.createElement("template"),r=e.querySelectorAll("style"),{length:n}=r;if(0===n)return void window.ShadyCSS.prepareTemplateStyles(s,t);const o=document.createElement("style");for(let t=0;t{X.forEach((e=>{const i=M.get(q(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)})),p(t,i)}))}))})(t);const a=s.content;i?function(t,e,i=null){const{element:{content:s},parts:r}=t;if(null==i)return void s.appendChild(e);const n=document.createTreeWalker(s,u,null,!1);let o=f(r),a=0,l=-1;for(;n.nextNode();)for(l++,n.currentNode===i&&(a=m(e),i.parentNode.insertBefore(e,i));-1!==o&&r[o].index===l;){if(a>0){for(;-1!==o;)r[o].index+=a,o=f(r,o);return}o=f(r,o)}}(i,o,a.firstChild):a.insertBefore(o,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(o,a.firstChild);const t=new Set;t.add(o),p(i,t)}};window.JSCompiler_renameProperty=(t,e)=>t;const H={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}},W=(t,e)=>e!==t&&(e==e||t==t),F={attribute:!0,type:String,converter:H,reflect:!1,hasChanged:W},J="finalized";class G 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=F){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 r=this[t];this[e]=s,this.requestUpdateInternal(t,r,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this._classProperties&&this._classProperties.get(t)||F}static finalize(){const t=Object.getPrototypeOf(this);if(t.hasOwnProperty(J)||t.finalize(),this[J]=!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=W){return i(t,e)}static _propertyValueFromAttribute(t,e){const i=e.type,s=e.converter||H,r="function"==typeof s?s:s.fromAttribute;return r?r(t,i):t}static _propertyValueToAttribute(t,e){if(void 0===e.reflect)return;const i=e.type,s=e.converter;return(s&&s.toAttribute||H.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=F){const s=this.constructor,r=s._attributeNameForProperty(t,i);if(void 0!==r){const t=s._propertyValueToAttribute(e,i);if(void 0===t)return;this._updateState=8|this._updateState,null==t?this.removeAttribute(r):this.setAttribute(r,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 r=this.constructor;i=i||r.getPropertyOptions(t),r._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){}}G[J]=!0; /** * @license * Copyright (c) 2017 The Polymer Project Authors. All rights reserved. @@ -156,7 +156,7 @@ 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 */ -const tt=window.ShadowRoot&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,et=Symbol();class it{constructor(t,e){if(e!==et)throw new Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t}get styleSheet(){return void 0===this._styleSheet&&(tt?(this._styleSheet=new CSSStyleSheet,this._styleSheet.replaceSync(this.cssText)):this._styleSheet=null),this._styleSheet}toString(){return this.cssText}}const nt=(t,...e)=>{const i=e.reduce(((e,i,n)=>e+(t=>{if(t instanceof it)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 it(i,et)}; +const tt=window.ShadowRoot&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,et=Symbol();class it{constructor(t,e){if(e!==et)throw new Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t}get styleSheet(){return void 0===this._styleSheet&&(tt?(this._styleSheet=new CSSStyleSheet,this._styleSheet.replaceSync(this.cssText)):this._styleSheet=null),this._styleSheet}toString(){return this.cssText}}const st=(t,...e)=>{const i=e.reduce(((e,i,s)=>e+(t=>{if(t instanceof it)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 it(i,et)}; /** * @license * Copyright (c) 2017 The Polymer Project Authors. All rights reserved. @@ -170,111 +170,25 @@ const tt=window.ShadowRoot&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeSha * subject to an additional IP rights grant found at * http://polymer.github.io/PATENTS.txt */ -(window.litElementVersions||(window.litElementVersions=[])).push("2.5.1");const st={};class ot extends G{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&&!tt){const e=Array.prototype.slice.call(t.cssRules).reduce(((t,e)=>t+e.cssText),"");return new it(String(e),et)}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?tt?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!==st&&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 st}}var rt,at,ct;function lt(){return(lt=Object.assign||function(t){for(var e=1;e{if(!n||"object"!=typeof n||!n.scopeName)throw new Error("The `scopeName` option is required.");const s=n.scopeName,o=D.has(e),r=$&&11===e.nodeType&&!!e.host,a=r&&!H.has(s),c=a?document.createDocumentFragment():e;if(((t,e,n)=>{let s=D.get(e);void 0===s&&(i(e,e.firstChild),D.set(e,s=new C(Object.assign({templateFactory:U},n))),s.appendInto(e)),s.setValue(t),s.commit()})(t,c,Object.assign({templateFactory:q(s)},n)),a){const t=D.get(c);D.delete(c);const n=t.value instanceof w?t.value.template:void 0;W(s,c,n),i(e,e.firstChild),e.appendChild(c),D.set(e,t)}!o&&r&&window.ShadyCSS.styleElement(e.host)},ot.shadowRootOptions={mode:"open"},(ct=rt||(rt={})).language="language",ct.system="system",ct.comma_decimal="comma_decimal",ct.decimal_comma="decimal_comma",ct.space_comma="space_comma",ct.none="none",function(t){t.language="language",t.system="system",t.am_pm="12",t.twenty_four="24"}(at||(at={}));var ut=["closed","locked","off"],ht=function(t,e,i,n){n=n||{},i=null==i?{}:i;var 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},pt={alert:"mdi:alert",automation:"mdi:playlist-play",calendar:"mdi:calendar",camera:"mdi:video",climate:"mdi:thermostat",configurator:"mdi:settings",conversation:"mdi:text-to-speech",device_tracker:"mdi:account",fan:"mdi:fan",group:"mdi:google-circles-communities",history_graph:"mdi:chart-line",homeassistant:"mdi:home-assistant",homekit:"mdi:home-automation",image_processing:"mdi:image-filter-frames",input_boolean:"mdi:drawing",input_datetime:"mdi:calendar-clock",input_number:"mdi:ray-vertex",input_select:"mdi:format-list-bulleted",input_text:"mdi:textbox",light:"mdi:lightbulb",mailbox:"mdi:mailbox",notify:"mdi:comment-alert",person:"mdi:account",plant:"mdi:flower",proximity:"mdi:apple-safari",remote:"mdi:remote",scene:"mdi:google-pages",script:"mdi:file-document",sensor:"mdi:eye",simple_alarm:"mdi:bell",sun:"mdi:white-balance-sunny",switch:"mdi:flash",timer:"mdi:timer",updater:"mdi:cloud-upload",vacuum:"mdi:robot-vacuum",water_heater:"mdi:thermometer",weblink:"mdi:open-in-new"};function mt(t,e){if(t in pt)return pt[t];switch(t){case"alarm_control_panel":switch(e){case"armed_home":return"mdi:bell-plus";case"armed_night":return"mdi:bell-sleep";case"disarmed":return"mdi:bell-outline";case"triggered":return"mdi:bell-ring";default:return"mdi:bell"}case"binary_sensor":return e&&"off"===e?"mdi:radiobox-blank":"mdi:checkbox-marked-circle";case"cover":return"closed"===e?"mdi:window-closed":"mdi:window-open";case"lock":return e&&"unlocked"===e?"mdi:lock-open":"mdi:lock";case"media_player":return e&&"off"!==e&&"idle"!==e?"mdi:cast-connected":"mdi:cast";case"zwave":switch(e){case"dead":return"mdi:emoticon-dead";case"sleeping":return"mdi:sleep";case"initializing":return"mdi:timer-sand";default:return"mdi:z-wave"}default:return console.warn("Unable to find icon for domain "+t+" ("+e+")"),"mdi:bookmark"}}var ft=function(t){ht(window,"haptic",t)},gt=function(t,e){return function(t,e,i){void 0===i&&(i=!0);var n,s=dt(e),o="group"===s?"homeassistant":s;switch(s){case"lock":n=i?"unlock":"lock";break;case"cover":n=i?"open_cover":"close_cover";break;default:n=i?"turn_on":"turn_off"}return t.callService(o,n,{entity_id:e})}(t,e,ut.includes(t.states[e].state))},yt=function(t,e,i,n,s){var o;if(s&&i.double_tap_action?o=i.double_tap_action:n&&i.hold_action?o=i.hold_action:!n&&i.tap_action&&(o=i.tap_action),o||(o={action:"more-info"}),!o.confirmation||o.confirmation.exemptions&&o.confirmation.exemptions.some((function(t){return t.user===e.user.id}))||confirm(o.confirmation.text||"Are you sure you want to "+o.action+"?"))switch(o.action){case"more-info":(o.entity||i.entity||i.camera_image)&&(ht(t,"hass-more-info",{entityId:o.entity?o.entity:i.entity?i.entity:i.camera_image}),o.haptic&&ft(o.haptic));break;case"navigate":o.navigation_path&&(function(t,e,i){void 0===i&&(i=!1),i?history.replaceState(null,"",e):history.pushState(null,"",e),ht(window,"location-changed",{replace:i})}(0,o.navigation_path),o.haptic&&ft(o.haptic));break;case"url":o.url_path&&window.open(o.url_path),o.haptic&&ft(o.haptic);break;case"toggle":i.entity&&(gt(e,i.entity),o.haptic&&ft(o.haptic));break;case"call-service":if(!o.service)return;var r=o.service.split(".",2),a=r[0],c=r[1],l=lt({},o.service_data);"entity"===l.entity_id&&(l.entity_id=i.entity),e.callService(a,c,l,o.target),o.haptic&&ft(o.haptic);break;case"fire-dom-event":ht(t,"ll-custom",o),o.haptic&&ft(o.haptic)}};var _t={humidity:"mdi:water-percent",illuminance:"mdi:brightness-5",temperature:"mdi:thermometer",pressure:"mdi:gauge",power:"mdi:flash",signal_strength:"mdi:wifi"},vt={binary_sensor:function(t,e){var i="off"===t;switch(null==e?void 0:e.attributes.device_class){case"battery":return i?"mdi:battery":"mdi:battery-outline";case"battery_charging":return i?"mdi:battery":"mdi:battery-charging";case"cold":return i?"mdi:thermometer":"mdi:snowflake";case"connectivity":return i?"mdi:server-network-off":"mdi:server-network";case"door":return i?"mdi:door-closed":"mdi:door-open";case"garage_door":return i?"mdi:garage":"mdi:garage-open";case"power":case"plug":return i?"mdi:power-plug-off":"mdi:power-plug";case"gas":case"problem":case"safety":case"tamper":return i?"mdi:check-circle":"mdi:alert-circle";case"smoke":return i?"mdi:check-circle":"mdi:smoke";case"heat":return i?"mdi:thermometer":"mdi:fire";case"light":return i?"mdi:brightness-5":"mdi:brightness-7";case"lock":return i?"mdi:lock":"mdi:lock-open";case"moisture":return i?"mdi:water-off":"mdi:water";case"motion":return i?"mdi:walk":"mdi:run";case"occupancy":case"presence":return i?"mdi:home-outline":"mdi:home";case"opening":return i?"mdi:square":"mdi:square-outline";case"running":return i?"mdi:stop":"mdi:play";case"sound":return i?"mdi:music-note-off":"mdi:music-note";case"update":return i?"mdi:package":"mdi:package-up";case"vibration":return i?"mdi:crop-portrait":"mdi:vibrate";case"window":return i?"mdi:window-closed":"mdi:window-open";default:return i?"mdi:radiobox-blank":"mdi:checkbox-marked-circle"}},cover:function(t){var e="closed"!==t.state;switch(t.attributes.device_class){case"garage":return e?"mdi:garage-open":"mdi:garage";case"door":return e?"mdi:door-open":"mdi:door-closed";case"shutter":return e?"mdi:window-shutter-open":"mdi:window-shutter";case"blind":return e?"mdi:blinds-open":"mdi:blinds";case"window":return e?"mdi:window-open":"mdi:window-closed";default:return mt("cover",t.state)}},sensor:function(t){var e=t.attributes.device_class;if(e&&e in _t)return _t[e];if("battery"===e){var i=Number(t.state);if(isNaN(i))return"mdi:battery-unknown";var n=10*Math.round(i/10);return n>=100?"mdi:battery":n<=0?"mdi:battery-alert":"hass:battery-"+n}var s=t.attributes.unit_of_measurement;return"°C"===s||"°F"===s?"mdi:thermometer":mt("sensor")},input_datetime:function(t){return t.attributes.has_date?t.attributes.has_time?mt("input_datetime"):"mdi:calendar":"mdi:clock"}}; -/** -@license -Copyright (c) 2017 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 -*/window.JSCompiler_renameProperty=function(t,e){return t}; -/** -@license -Copyright (c) 2017 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 -*/ -let wt=0; -/** -@license -Copyright (c) 2017 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 -*/ -let bt=0,St=0,xt=[],kt=0,Pt=!1,Tt=document.createTextNode("");new window.MutationObserver((function(){Pt=!1;const t=xt.length;for(let e=0;e{throw t}))}}xt.splice(0,t),St+=t})).observe(Tt,{characterData:!0});const Nt={after:t=>({run:e=>window.setTimeout(e,t),cancel(t){window.clearTimeout(t)}}),run:(t,e)=>window.setTimeout(t,e),cancel(t){window.clearTimeout(t)}},Ct={run:t=>(Pt||(Pt=!0,Tt.textContent=kt++),xt.push(t),bt++),cancel(t){const e=t-St;if(e>=0){if(!xt[e])throw new Error("invalid async handle: "+t);xt[e]=null}}}; -/** -@license -Copyright (c) 2017 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 Et{constructor(){this._asyncModule=null,this._callback=null,this._timer=null}setConfig(t,e){this._asyncModule=t,this._callback=e,this._timer=this._asyncModule.run((()=>{this._timer=null,Ot.delete(this),this._callback()}))}cancel(){this.isActive()&&(this._cancelAsync(),Ot.delete(this))}_cancelAsync(){this.isActive()&&(this._asyncModule.cancel(this._timer),this._timer=null)}flush(){this.isActive()&&(this.cancel(),this._callback())}isActive(){return null!=this._timer}static debounce(t,e,i){return t instanceof Et?t._cancelAsync():t=new Et,t.setConfig(e,i),t}}let Ot=new Set; -/** -@license -Copyright (c) 2017 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 -*/ -/** -@license -Copyright (c) 2017 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 -*/ -const At=!window.ShadyDOM||!window.ShadyDOM.inUse;var Mt;Boolean(!window.ShadyCSS||window.ShadyCSS.nativeCss),At&&"adoptedStyleSheets"in Document.prototype&&"replaceSync"in CSSStyleSheet.prototype&&(()=>{try{const t=new CSSStyleSheet;t.replaceSync("");const e=document.createElement("div");return e.attachShadow({mode:"open"}),e.shadowRoot.adoptedStyleSheets=[t],e.shadowRoot.adoptedStyleSheets[0]===t}catch(t){return!1}})(),window.Polymer&&window.Polymer.rootPath||(Mt=document.baseURI||window.location.href).substring(0,Mt.lastIndexOf("/")+1),window.Polymer&&window.Polymer.sanitizeDOMValue;let Vt=window.Polymer&&window.Polymer.setPassiveTouchGestures||!1;window.Polymer&&window.Polymer.strictTemplatePolicy,window.Polymer&&window.Polymer.allowTemplateFromDomModule,window.Polymer&&window.Polymer.legacyOptimizations,window.Polymer&&window.Polymer.legacyWarnings,window.Polymer&&window.Polymer.syncInitialRender,window.Polymer&&window.Polymer.legacyUndefined,window.Polymer&&window.Polymer.orderedComputed,window.Polymer&&window.Polymer.removeNestedTemplates,window.Polymer&&window.Polymer.fastDomIf,window.Polymer&&window.Polymer.suppressTemplateNotifications,window.Polymer&&window.Polymer.legacyNoObservedAttributes,window.Polymer&&window.Polymer.useAdoptedStyleSheetsWithBuiltCSS; -/** -@license -Copyright (c) 2017 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 -*/ -const Rt=window.ShadyDOM&&window.ShadyDOM.noPatch&&window.ShadyDOM.wrap?window.ShadyDOM.wrap:window.ShadyDOM?t=>ShadyDOM.patch(t):t=>t; -/** -@license -Copyright (c) 2017 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 -*/let Ut="string"==typeof document.head.style.touchAction,jt="__polymerGestures",Dt="__polymerGesturesHandled",Lt="__polymerGesturesTouchAction",It=25,Bt=5,$t=2500,qt=["mousedown","mousemove","mouseup","click"],zt=[0,1,4,2],Ht=function(){try{return 1===new MouseEvent("test",{buttons:1}).buttons}catch(t){return!1}}();function Wt(t){return qt.indexOf(t)>-1}let Ft=!1;function Xt(t){if(!Wt(t)&&"touchend"!==t)return Ut&&Ft&&Vt?{passive:!0}:void 0}!function(){try{let t=Object.defineProperty({},"passive",{get(){Ft=!0}});window.addEventListener("test",null,t),window.removeEventListener("test",null,t)}catch(t){}}();let Yt=navigator.userAgent.match(/iP(?:[oa]d|hone)|Android/);const Jt=[],Gt={button:!0,input:!0,keygen:!0,meter:!0,output:!0,textarea:!0,progress:!0,select:!0},Kt={button:!0,command:!0,fieldset:!0,input:!0,keygen:!0,optgroup:!0,option:!0,select:!0,textarea:!0};function Qt(t){let e=Array.prototype.slice.call(t.labels||[]);if(!e.length){e=[];try{let i=t.getRootNode();if(t.id){let n=i.querySelectorAll(`label[for = '${t.id}']`);for(let t=0;t-1}if(n[t]===ie.mouse.target)return}if(e)return;t.preventDefault(),t.stopPropagation()}};function te(t){let e=Yt?["click"]:qt;for(let i,n=0;nt.composedPath&&t.composedPath()||[],re={},ae=[];function ce(t){const e=oe(t);return e.length>0?e[0]:t.target}function le(t){let e,i=t.type,n=t.currentTarget[jt];if(!n)return;let s=n[i];if(s){if(!t[Dt]&&(t[Dt]={},"touch"===i.slice(0,5))){let e=t.changedTouches[0];if("touchstart"===i&&1===t.touches.length&&(ie.touch.id=e.identifier),ie.touch.id!==e.identifier)return;Ut||"touchstart"!==i&&"touchmove"!==i||function(t){let e=t.changedTouches[0],i=t.type;if("touchstart"===i)ie.touch.x=e.clientX,ie.touch.y=e.clientY,ie.touch.scrollDecided=!1;else if("touchmove"===i){if(ie.touch.scrollDecided)return;ie.touch.scrollDecided=!0;let i=function(t){let e="auto",i=oe(t);for(let t,n=0;ns:"pan-y"===i&&(n=s>o)),n?t.preventDefault():fe("track")}}(t)}if(e=t[Dt],!e.skip){for(let i,n=0;n-1&&i.reset&&i.reset();for(let n,o=0;o{t.style.touchAction=e})),t[Lt]=e}function me(t,e,i){let n=new Event(e,{bubbles:!0,cancelable:!0,composed:!0});if(n.detail=i,Rt(t).dispatchEvent(n),n.defaultPrevented){let t=i.preventer||i.sourceEvent;t&&t.preventDefault&&t.preventDefault()}}function fe(t){let e=function(t){for(let e,i=0;i=Bt||s>=Bt}function _e(t,e,i){if(!e)return;let n,s=t.moves[t.moves.length-2],o=t.moves[t.moves.length-1],r=o.x-t.x,a=o.y-t.y,c=0;s&&(n=o.x-s.x,c=o.y-s.y),me(e,"track",{state:t.state,x:i.clientX,y:i.clientY,dx:r,dy:a,ddx:n,ddy:c,sourceEvent:i,hover:function(){return function(t,e){let i=document.elementFromPoint(t,e),n=i;for(;n&&n.shadowRoot&&!window.ShadyDOM;){let s=n;if(n=n.shadowRoot.elementFromPoint(t,e),s===n)break;n&&(i=n)}return i}(i.clientX,i.clientY)}})}function ve(t,e,i){let n=Math.abs(e.clientX-t.x),s=Math.abs(e.clientY-t.y),o=ce(i||e);!o||Kt[o.localName]&&o.hasAttribute("disabled")||(isNaN(n)||isNaN(s)||n<=It&&s<=It||function(t){if("click"===t.type){if(0===t.detail)return!0;let e=ce(t);if(!e.nodeType||e.nodeType!==Node.ELEMENT_NODE)return!0;let i=e.getBoundingClientRect(),n=t.pageX,s=t.pageY;return!(n>=i.left&&n<=i.right&&s>=i.top&&s<=i.bottom)}return!1}(e))&&(t.prevent||me(o,"tap",{x:e.clientX,y:e.clientY,sourceEvent:e,preventer:i}))} -/** -@license -Copyright (c) 2017 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 -*/he({name:"downup",deps:["mousedown","touchstart","touchend"],flow:{start:["mousedown","touchstart"],end:["mouseup","touchend"]},emits:["down","up"],info:{movefn:null,upfn:null},reset:function(){se(this.info)},mousedown:function(t){if(!ee(t))return;let e=ce(t),i=this;ne(this.info,(function(t){ee(t)||(ge("up",e,t),se(i.info))}),(function(t){ee(t)&&ge("up",e,t),se(i.info)})),ge("down",e,t)},touchstart:function(t){ge("down",ce(t),t.changedTouches[0],t)},touchend:function(t){ge("up",ce(t),t.changedTouches[0],t)}}),he({name:"track",touchAction:"none",deps:["mousedown","touchstart","touchmove","touchend"],flow:{start:["mousedown","touchstart"],end:["mouseup","touchend"]},emits:["track"],info:{x:0,y:0,state:"start",started:!1,moves:[],addMove:function(t){this.moves.length>2&&this.moves.shift(),this.moves.push(t)},movefn:null,upfn:null,prevent:!1},reset:function(){this.info.state="start",this.info.started=!1,this.info.moves=[],this.info.x=0,this.info.y=0,this.info.prevent=!1,se(this.info)},mousedown:function(t){if(!ee(t))return;let e=ce(t),i=this,n=function(t){let n=t.clientX,s=t.clientY;ye(i.info,n,s)&&(i.info.state=i.info.started?"mouseup"===t.type?"end":"track":"start","start"===i.info.state&&fe("tap"),i.info.addMove({x:n,y:s}),ee(t)||(i.info.state="end",se(i.info)),e&&_e(i.info,e,t),i.info.started=!0)};ne(this.info,n,(function(t){i.info.started&&n(t),se(i.info)})),this.info.x=t.clientX,this.info.y=t.clientY},touchstart:function(t){let e=t.changedTouches[0];this.info.x=e.clientX,this.info.y=e.clientY},touchmove:function(t){let e=ce(t),i=t.changedTouches[0],n=i.clientX,s=i.clientY;ye(this.info,n,s)&&("start"===this.info.state&&fe("tap"),this.info.addMove({x:n,y:s}),_e(this.info,e,i),this.info.state="track",this.info.started=!0)},touchend:function(t){let e=ce(t),i=t.changedTouches[0];this.info.started&&(this.info.state="end",this.info.addMove({x:i.clientX,y:i.clientY}),_e(this.info,e,i))}}),he({name:"tap",deps:["mousedown","click","touchstart","touchend"],flow:{start:["mousedown","touchstart"],end:["click","touchend"]},emits:["tap"],info:{x:NaN,y:NaN,prevent:!1},reset:function(){this.info.x=NaN,this.info.y=NaN,this.info.prevent=!1},mousedown:function(t){ee(t)&&(this.info.x=t.clientX,this.info.y=t.clientY)},click:function(t){ee(t)&&ve(this.info,t)},touchstart:function(t){const e=t.changedTouches[0];this.info.x=e.clientX,this.info.y=e.clientY},touchend:function(t){ve(this.info,t.changedTouches[0],t)}});const we=function(t){let e=t.__mixinApplications;e||(e=new WeakMap,t.__mixinApplications=e);let i=wt++;return function(n){let s=n.__mixinSet;if(s&&s[i])return n;let o=e,r=o.get(n);if(!r){r=t(n),o.set(n,r);let e=Object.create(r.__mixinSet||s||null);e[i]=!0,r.__mixinSet=e}return r}}((t=>class extends t{_addEventListenerToNode(t,e,i){de(t,e,i)||super._addEventListenerToNode(t,e,i)}_removeEventListenerFromNode(t,e,i){ue(t,e,i)||super._removeEventListenerFromNode(t,e,i)}}));const be="brightness";var Se={version:"Version",invalid_configuration:"Invalid configuration",show_warning:"Show Warning",no_entity_set:"Entity not set",no_entity:"Entity not available",on:"On",off:"Off"},xe={common:Se},ke={version:"Versiunea",invalid_configuration:"Configurație invalidă",show_warning:"Show Warning",no_entity_set:"Entitatea nu e setată",no_entity:"Entitatea nu e disponibilă",on:"Pornit",off:"Oprit"},Pe={common:ke};const Te={en:Object.freeze({__proto__:null,common:Se,default:xe}),ro:Object.freeze({__proto__:null,common:ke,default:Pe})};function Ne(t,e="",i=""){const n=(localStorage.getItem("selectedLanguage")||"en").replace(/['"]+/g,"").replace("-","_");let s;try{s=t.split(".").reduce(((t,e)=>t[e]),Te[n])}catch(e){s=t.split(".").reduce(((t,e)=>t[e]),Te.en)}return void 0===s&&(s=t.split(".").reduce(((t,e)=>t[e]),Te.en)),""!==e&&""!==i&&(s=s.replace(e,i)),s}console.info(`%c BIG-SLIDER-CARD \n%c ${Ne("common.version")} 1.0.11 `,"color: orange; font-weight: bold; background: black","color: white; font-weight: bold; background: dimgray"),window.customCards=window.customCards||[],window.customCards.push({type:"big-slider-card",name:"Big Slider Card",description:"Big slider card for light entities."});let Ce=class extends(we(ot)){constructor(){super(),this._handleContextMenu=t=>{const e=t||window.event;return e.preventDefault&&e.preventDefault(),e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0,e.returnValue=!1,!1},this._handleDown=()=>{this._press(),this.isHold=!1,this.holdTimer=window.setTimeout(this._setHold,this.config.hold_time)},this._setHold=()=>{this.isHold=!0,yt(this,this.hass,this.config,!0,!1)},this._handleUp=()=>{this._unpress()},this._handleTap=()=>{var t;clearTimeout(this.holdTimer),(null===(t=this.config)||void 0===t?void 0:t.tap_action)&&(this.isHold||yt(this,this.hass,this.config,!1,!1))},this._handleTrack=t=>{switch(this.mousePos={x:t.detail.x,y:t.detail.y},clearTimeout(this.holdTimer),t.detail.state){case"start":this._startTrack();break;case"track":this._track();break;case"end":this._endTrack()}},this.mouseStartPos={x:0,y:0},this.mousePos={x:0,y:0},this.containerWidth=0,this.oldValue=0,this.currentValue=30,this.stateObj=null,this.isHold=!1,this.holdTimer=0,this._shouldUpdate=!0,this.updateTimeout=0,this.pressTimeout=0,this.trackingStartTime=0,this._setValueThrottled=function(t,e){let i=0;return function(){const n=Date.now();n-i>=e&&(t(),i=n)}}(this._setValue.bind(this),200)}static getStubConfig(){return{}}connectedCallback(){super.connectedCallback(),Vt=!0,de(this,"down",this._handleDown),de(this,"up",this._handleUp),de(this,"tap",this._handleTap),de(this,"track",this._handleTrack),pe(this,"pan-y pinch-zoom"),this.addEventListener("contextmenu",this._handleContextMenu)}disconnectedCallback(){ue(this,"down",this._handleDown),ue(this,"up",this._handleUp),ue(this,"tap",this._handleTap),ue(this,"track",this._handleTrack),this.removeEventListener("contextmenu",this._handleContextMenu),super.disconnectedCallback()}_log(t){console.log(`%c BIG-SLIDER-CARD ${this._getName()} %c ${t} `,"color: orange; font-weight: bold; background: black","")}_startTrack(){this.trackingStartTime=Date.now(),this.trackingStartRect=this.getBoundingClientRect(),this._restartTrack()}_restartTrack(){this.mouseStartPos={x:this.mousePos.x,y:this.mousePos.y},this.oldValue=this.currentValue,this._press(),this._stopUpdates(),this.updateTimeout&&clearTimeout(this.updateTimeout)}_track(){this._updateValue(),this._hasScrolled()&&this._endTrack()}_endTrack(){this._updateValue(),this._unpress(),this.updateTimeout&&clearTimeout(this.updateTimeout);Date.now()-this.trackingStartTimethis.setAttribute("pressed","")),this.config.min_slide_time),this.setAttribute("half-pressed","")}_unpress(){this.pressTimeout&&clearTimeout(this.pressTimeout),this.removeAttribute("pressed"),this.removeAttribute("half-pressed")}_updateValue(){const t=this.containerWidth,e=this.mousePos.x-this.mouseStartPos.x,i=Math.round(100*e/t);this.currentValue=this.oldValue+i,this._checklimits(),this._updateSlider()}_checklimits(){this.currentValuethis.config.max&&(this.currentValue=this.config.max,this._restartTrack())}_hasScrolled(){var t;const e=this.getBoundingClientRect().top,i=(null===(t=this.trackingStartRect)||void 0===t?void 0:t.top)||0;return Math.abs(e-i)>5}_updateSlider(){var t;this.style.setProperty("--bsc-percent",this.currentValue+"%");const e=null===(t=null==this?void 0:this.shadowRoot)||void 0===t?void 0:t.getElementById("percentage");e&&(e.innerText=Math.round(this.currentValue)+"%")}_updateColors(){var t,e,i;let n="var(--bsc-color)",s="0%",o="50%",r=!1;if(this.stateObj)if("on"==this.stateObj.state){const i=(null===(t=this.stateObj.attributes)||void 0===t?void 0:t.rgb_color)||[255,255,255],a=(null===(e=this.stateObj.attributes)||void 0===e?void 0:e.brightness)||255;r=!0,i&&(n=`rgb(${i.join(",")})`),a&&(s=`${Math.ceil(100*a/255)}%`,o=`${Math.ceil(100*a/510+50)}%`)}else n="var(--bsc-off-color)";const a=null===(i=null==this?void 0:this.shadowRoot)||void 0===i?void 0:i.getElementById("percentage");r||a&&(a.innerText=Ne("common.off")),this.style.setProperty("--bsc-entity-color",n),this.style.setProperty("--bsc-brightness",s),this.style.setProperty("--bsc-brightness-ui",o),this.config.icon_color&&r&&this.style.setProperty("--bsc-icon-color",this.config.icon_color),this.config.icon_color&&!r&&this.style.removeProperty("--bsc-icon-color"),this.config.color&&this.style.setProperty("--bsc-slider-color",this.config.color)}_getValue(){var t;if(!this._shouldUpdate)return;if(!this.stateObj)return;const e=(null===(t=this.config)||void 0===t?void 0:t.attribute)||be;let i=0;if("on"!=this.stateObj.state)i=0;else switch(e){case"brightness":i=Math.ceil(100*(this.stateObj.attributes.brightness||255)/255);break;case"red":case"green":case"blue":const t=this.stateObj.attributes.rgb_color||[255,255,255];"red"===e&&(i=t[0]),"green"===e&&(i=t[1]),"blue"===e&&(i=t[2]),i=Math.ceil(100*i/255);break;case"hue":case"saturation":const n=this.stateObj.attributes.hs_color||[100,100];"hue"===e&&(i=n[0]),"saturation"===e&&(i=n[1])}this.currentValue=i,this._updateSlider()}_setValue(){let t,e=this.currentValue,i=this.config.attribute||be,n=!0;switch(i){case"brightness":e=Math.ceil(e/100*255),e||(n=!1);break;case"red":case"green":case"blue":t=this.stateObj.attributes.rgb_color||[255,255,255],"red"===i&&(t[0]=e),"green"===i&&(t[1]=e),"blue"===i&&(t[2]=e),e=t,i="rgb_color";break;case"hue":case"saturation":t=this.stateObj.attributes.hs_color||[100,100],"hue"===i&&(t[0]=e),"saturation"===i&&(t[1]=e),e=t,i="hs_color"}const s={entity_id:this.stateObj.entity_id};n?(s[i]=e,this.config.transition&&(s.transition=this.config.transition),this.hass.callService("light","turn_on",s)):this.hass.callService("light","turn_off",s)}setConfig(t){if(!t)throw new Error(Ne("common.invalid_configuration"));if(!t.entity)throw new Error(Ne("common.no_entity_set"));t.test_gui&&function(){var t=document.querySelector("home-assistant");if(t=(t=(t=(t=(t=(t=(t=(t=t&&t.shadowRoot)&&t.querySelector("home-assistant-main"))&&t.shadowRoot)&&t.querySelector("app-drawer-layout partial-panel-resolver"))&&t.shadowRoot||t)&&t.querySelector("ha-panel-lovelace"))&&t.shadowRoot)&&t.querySelector("hui-root")){var e=t.lovelace;return e.current_view=t.___curView,e}return null}().setEditMode(!0),this.config=Object.assign({attribute:be,tap_action:{action:"toggle",haptic:"light"},min_slide_time:0,hold_time:600,settle_time:3e3,min:0,max:100},t)}_stopUpdates(){var t,e,i;this._shouldUpdate=!1,null===(i=null===(e=null===(t=this.shadowRoot)||void 0===t?void 0:t.getElementById("slider"))||void 0===e?void 0:e.classList)||void 0===i||i.remove("animate")}_startUpdates(){var t,e,i;this._shouldUpdate=!0,null===(i=null===(e=null===(t=this.shadowRoot)||void 0===t?void 0:t.getElementById("slider"))||void 0===e?void 0:e.classList)||void 0===i||i.add("animate"),this.requestUpdate()}shouldUpdate(t){return!!this.config&&function(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}(this,t,!1)}updated(){var t,e;this.containerWidth=(null===(e=null===(t=this.shadowRoot)||void 0===t?void 0:t.getElementById("container"))||void 0===e?void 0:e.clientWidth)||0,this._getValue(),this._updateColors()}render(){var t,e,i,n;if(this.config||(this.stateObj=null),this.config.entity||(this.stateObj=null),!this.config.entity||!(this.config.entity in this.hass.states))return this.stateObj=null,this._showError(`${Ne("common.no_entity")}: ${this.config.entity}`);this.stateObj=this.config.entity&&this.hass.states[this.config.entity];const s=this._getName(),o=null!==(t=this.config.icon)&&void 0!==t?t:function(t){if(!t)return"mdi:bookmark";if(t.attributes.icon)return t.attributes.icon;var e=dt(t.entity_id);return e in vt?vt[e](t):mt(e,t.state)}(this.stateObj),r=null!==(e=this.config.colorize&&!0)&&void 0!==e&&e,a=null!==(i=this.config.show_percentage&&!0)&&void 0!==i&&i,c=null!==(n=this.config.bold_text&&!0)&&void 0!==n&&n;return I` +(window.litElementVersions||(window.litElementVersions=[])).push("2.5.1");const rt={};class nt extends G{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&&!tt){const e=Array.prototype.slice.call(t.cssRules).reduce(((t,e)=>t+e.cssText),"");return new it(String(e),et)}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?tt?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!==rt&&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 rt}}var ot,at,lt;function ct(){return(ct=Object.assign||function(t){for(var e=1;e{if(!s||"object"!=typeof s||!s.scopeName)throw new Error("The `scopeName` option is required.");const r=s.scopeName,n=L.has(e),o=z&&11===e.nodeType&&!!e.host,a=o&&!Y.has(r),l=a?document.createDocumentFragment():e;if(((t,e,s)=>{let r=L.get(e);void 0===r&&(i(e,e.firstChild),L.set(e,r=new E(Object.assign({templateFactory:R},s))),r.appendInto(e)),r.setValue(t),r.commit()})(t,l,Object.assign({templateFactory:B(r)},s)),a){const t=L.get(l);L.delete(l);const s=t.value instanceof b?t.value.template:void 0;D(r,l,s),i(e,e.firstChild),e.appendChild(l),L.set(e,t)}!n&&o&&window.ShadyCSS.styleElement(e.host)},nt.shadowRootOptions={mode:"open"},(lt=ot||(ot={})).language="language",lt.system="system",lt.comma_decimal="comma_decimal",lt.decimal_comma="decimal_comma",lt.space_comma="space_comma",lt.none="none",function(t){t.language="language",t.system="system",t.am_pm="12",t.twenty_four="24"}(at||(at={}));var ht=["closed","locked","off"],ut=function(t,e,i,s){s=s||{},i=null==i?{}:i;var r=new Event(e,{bubbles:void 0===s.bubbles||s.bubbles,cancelable:Boolean(s.cancelable),composed:void 0===s.composed||s.composed});return r.detail=i,t.dispatchEvent(r),r},pt={alert:"mdi:alert",automation:"mdi:playlist-play",calendar:"mdi:calendar",camera:"mdi:video",climate:"mdi:thermostat",configurator:"mdi:settings",conversation:"mdi:text-to-speech",device_tracker:"mdi:account",fan:"mdi:fan",group:"mdi:google-circles-communities",history_graph:"mdi:chart-line",homeassistant:"mdi:home-assistant",homekit:"mdi:home-automation",image_processing:"mdi:image-filter-frames",input_boolean:"mdi:drawing",input_datetime:"mdi:calendar-clock",input_number:"mdi:ray-vertex",input_select:"mdi:format-list-bulleted",input_text:"mdi:textbox",light:"mdi:lightbulb",mailbox:"mdi:mailbox",notify:"mdi:comment-alert",person:"mdi:account",plant:"mdi:flower",proximity:"mdi:apple-safari",remote:"mdi:remote",scene:"mdi:google-pages",script:"mdi:file-document",sensor:"mdi:eye",simple_alarm:"mdi:bell",sun:"mdi:white-balance-sunny",switch:"mdi:flash",timer:"mdi:timer",updater:"mdi:cloud-upload",vacuum:"mdi:robot-vacuum",water_heater:"mdi:thermometer",weblink:"mdi:open-in-new"};function mt(t,e){if(t in pt)return pt[t];switch(t){case"alarm_control_panel":switch(e){case"armed_home":return"mdi:bell-plus";case"armed_night":return"mdi:bell-sleep";case"disarmed":return"mdi:bell-outline";case"triggered":return"mdi:bell-ring";default:return"mdi:bell"}case"binary_sensor":return e&&"off"===e?"mdi:radiobox-blank":"mdi:checkbox-marked-circle";case"cover":return"closed"===e?"mdi:window-closed":"mdi:window-open";case"lock":return e&&"unlocked"===e?"mdi:lock-open":"mdi:lock";case"media_player":return e&&"off"!==e&&"idle"!==e?"mdi:cast-connected":"mdi:cast";case"zwave":switch(e){case"dead":return"mdi:emoticon-dead";case"sleeping":return"mdi:sleep";case"initializing":return"mdi:timer-sand";default:return"mdi:z-wave"}default:return console.warn("Unable to find icon for domain "+t+" ("+e+")"),"mdi:bookmark"}}var ft=function(t){ut(window,"haptic",t)},gt=function(t,e){return function(t,e,i){void 0===i&&(i=!0);var s,r=dt(e),n="group"===r?"homeassistant":r;switch(r){case"lock":s=i?"unlock":"lock";break;case"cover":s=i?"open_cover":"close_cover";break;default:s=i?"turn_on":"turn_off"}return t.callService(n,s,{entity_id:e})}(t,e,ht.includes(t.states[e].state))},_t=function(t,e,i,s,r){var n;if(r&&i.double_tap_action?n=i.double_tap_action:s&&i.hold_action?n=i.hold_action:!s&&i.tap_action&&(n=i.tap_action),n||(n={action:"more-info"}),!n.confirmation||n.confirmation.exemptions&&n.confirmation.exemptions.some((function(t){return t.user===e.user.id}))||confirm(n.confirmation.text||"Are you sure you want to "+n.action+"?"))switch(n.action){case"more-info":(n.entity||i.entity||i.camera_image)&&(ut(t,"hass-more-info",{entityId:n.entity?n.entity:i.entity?i.entity:i.camera_image}),n.haptic&&ft(n.haptic));break;case"navigate":n.navigation_path&&(function(t,e,i){void 0===i&&(i=!1),i?history.replaceState(null,"",e):history.pushState(null,"",e),ut(window,"location-changed",{replace:i})}(0,n.navigation_path),n.haptic&&ft(n.haptic));break;case"url":n.url_path&&window.open(n.url_path),n.haptic&&ft(n.haptic);break;case"toggle":i.entity&&(gt(e,i.entity),n.haptic&&ft(n.haptic));break;case"call-service":if(!n.service)return;var o=n.service.split(".",2),a=o[0],l=o[1],c=ct({},n.service_data);"entity"===c.entity_id&&(c.entity_id=i.entity),e.callService(a,l,c,n.target),n.haptic&&ft(n.haptic);break;case"fire-dom-event":ut(t,"ll-custom",n),n.haptic&&ft(n.haptic)}};var vt={humidity:"mdi:water-percent",illuminance:"mdi:brightness-5",temperature:"mdi:thermometer",pressure:"mdi:gauge",power:"mdi:flash",signal_strength:"mdi:wifi"},yt={binary_sensor:function(t,e){var i="off"===t;switch(null==e?void 0:e.attributes.device_class){case"battery":return i?"mdi:battery":"mdi:battery-outline";case"battery_charging":return i?"mdi:battery":"mdi:battery-charging";case"cold":return i?"mdi:thermometer":"mdi:snowflake";case"connectivity":return i?"mdi:server-network-off":"mdi:server-network";case"door":return i?"mdi:door-closed":"mdi:door-open";case"garage_door":return i?"mdi:garage":"mdi:garage-open";case"power":case"plug":return i?"mdi:power-plug-off":"mdi:power-plug";case"gas":case"problem":case"safety":case"tamper":return i?"mdi:check-circle":"mdi:alert-circle";case"smoke":return i?"mdi:check-circle":"mdi:smoke";case"heat":return i?"mdi:thermometer":"mdi:fire";case"light":return i?"mdi:brightness-5":"mdi:brightness-7";case"lock":return i?"mdi:lock":"mdi:lock-open";case"moisture":return i?"mdi:water-off":"mdi:water";case"motion":return i?"mdi:walk":"mdi:run";case"occupancy":case"presence":return i?"mdi:home-outline":"mdi:home";case"opening":return i?"mdi:square":"mdi:square-outline";case"running":return i?"mdi:stop":"mdi:play";case"sound":return i?"mdi:music-note-off":"mdi:music-note";case"update":return i?"mdi:package":"mdi:package-up";case"vibration":return i?"mdi:crop-portrait":"mdi:vibrate";case"window":return i?"mdi:window-closed":"mdi:window-open";default:return i?"mdi:radiobox-blank":"mdi:checkbox-marked-circle"}},cover:function(t){var e="closed"!==t.state;switch(t.attributes.device_class){case"garage":return e?"mdi:garage-open":"mdi:garage";case"door":return e?"mdi:door-open":"mdi:door-closed";case"shutter":return e?"mdi:window-shutter-open":"mdi:window-shutter";case"blind":return e?"mdi:blinds-open":"mdi:blinds";case"window":return e?"mdi:window-open":"mdi:window-closed";default:return mt("cover",t.state)}},sensor:function(t){var e=t.attributes.device_class;if(e&&e in vt)return vt[e];if("battery"===e){var i=Number(t.state);if(isNaN(i))return"mdi:battery-unknown";var s=10*Math.round(i/10);return s>=100?"mdi:battery":s<=0?"mdi:battery-alert":"hass:battery-"+s}var r=t.attributes.unit_of_measurement;return"°C"===r||"°F"===r?"mdi:thermometer":mt("sensor")},input_datetime:function(t){return t.attributes.has_date?t.attributes.has_time?mt("input_datetime"):"mdi:calendar":"mdi:clock"}};class bt{constructor(t,e,{touchActions:i,stopScrollDirection:s}={}){this.el=t,this.touchActions=i,this.startX=0,this.startY=0,this.lastTotalX=0,this.lastTotalY=0,this.callback=e,this.stopScrollDirection=s,this.addListeners()}addListeners(){this.el.addEventListener("pointerdown",this.handleEvt.bind(this)),this.el.addEventListener("pointermove",this.handleEvt.bind(this)),this.el.addEventListener("pointerup",this.handleEvt.bind(this)),this.el.addEventListener("pointercancel",this.handleEvt.bind(this)),window.addEventListener("touchmove",this.handleScroll.bind(this),{passive:!1}),this.touchActions&&(this.el.style.touchAction=this.touchActions)}removeListeners(){this.el.removeEventListener("pointerdown",this.handleEvt.bind(this)),this.el.removeEventListener("pointermove",this.handleEvt.bind(this)),this.el.removeEventListener("pointerup",this.handleEvt.bind(this)),this.el.removeEventListener("pointercancel",this.handleEvt.bind(this)),window.removeEventListener("touchmove",this.handleScroll.bind(this)),this.touchActions&&(this.el.style.touchAction=null)}preventTouchScroll(){this.shouldPreventScroll=!0}allowTouchScroll(){this.shouldPreventScroll=!1}handleScroll(t){this.shouldPreventScroll&&t.preventDefault()}handleEvt(t){if("pointerdown"===t.type&&(this.el.setPointerCapture(t.pointerId),this.startX=t.pageX,this.startY=t.pageY),this.el.hasPointerCapture(t.pointerId)&&"pointercancel"!==t.type&&"function"==typeof this.callback){const e=t.pageX-this.startX,i=t.pageY-this.startY;"horizontal"===this.stopScrollDirection&&Math.abs(e/i)>1&&this.preventTouchScroll(),"vertical"===this.stopScrollDirection&&Math.abs(e/i)<1&&this.preventTouchScroll(),this.callback(t,{startX:this.startX,startY:this.startY,relativeX:e,relativeY:i,totalX:e+this.lastTotalX,totalY:i+this.lastTotalY})}"pointerup"===t.type&&(this.lastTotalX=+this.lastTotalX+t.pageX-this.startX,this.lastTotalY=+this.lastTotalY+t.pageY-this.startY,this.el.releasePointerCapture(t.pointerId),this.allowTouchScroll()),"pointercancel"===t.type&&(this.callback(t,{startX:this.startX,startY:this.startY,relativeX:0,relativeY:0,totalX:this.lastTotalX,totalY:this.lastTotalY}),this.el.releasePointerCapture(t.pointerId),this.allowTouchScroll())}}const wt="brightness";var St={version:"Version",invalid_configuration:"Invalid configuration",show_warning:"Show Warning",no_entity_set:"Entity not set",no_entity:"Entity not available",on:"On",off:"Off"},xt={common:St},Tt={version:"Versiunea",invalid_configuration:"Configurație invalidă",show_warning:"Show Warning",no_entity_set:"Entitatea nu e setată",no_entity:"Entitatea nu e disponibilă",on:"Pornit",off:"Oprit"},kt={common:Tt};const Pt={en:Object.freeze({__proto__:null,common:St,default:xt}),ro:Object.freeze({__proto__:null,common:Tt,default:kt})};function Ct(t,e="",i=""){const s=(localStorage.getItem("selectedLanguage")||"en").replace(/['"]+/g,"").replace("-","_");let r;try{r=t.split(".").reduce(((t,e)=>t[e]),Pt[s])}catch(e){r=t.split(".").reduce(((t,e)=>t[e]),Pt.en)}return void 0===r&&(r=t.split(".").reduce(((t,e)=>t[e]),Pt.en)),""!==e&&""!==i&&(r=r.replace(e,i)),r}console.info(`%c BIG-SLIDER-CARD \n%c ${Ct("common.version")} 1.1.0 `,"color: orange; font-weight: bold; background: black","color: white; font-weight: bold; background: dimgray"),window.customCards=window.customCards||[],window.customCards.push({type:"big-slider-card",name:"Big Slider Card",description:"Big slider card for light entities."});let Et=class extends nt{constructor(){super(),this._handleContextMenu=t=>{const e=t||window.event;return e.preventDefault&&e.preventDefault(),e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0,e.returnValue=!1,!1},this._handlePointer=(t,e)=>{if(this.mousePos={x:t.pageX,y:t.pageY},"pointerdown"===t.type&&(this._press(),this.isTap=!0,this.isHold=!1,this.holdTimer=window.setTimeout(this._setHold,this.config.hold_time),this.trackingStartTime=Date.now(),this._resetTrack()),this._updateValue(),"pointermove"===t.type&&this.isTap&&(Math.abs(e.relativeX)>5||Math.abs(e.relativeY)>5)&&(this._stopUpdates(),this.isTap=!1,clearTimeout(this.holdTimer)),"pointercancel"===t.type&&(clearTimeout(this.holdTimer),this._unpress(),this._startUpdates()),"pointerup"===t.type){if(clearTimeout(this.holdTimer),this._unpress(),this._startUpdates(),this.isTap)return void this._handleTap();Date.now()-this.trackingStartTime>this.config.min_slide_time&&(this._setValue(),this._startUpdates(!0))}},this._setHold=()=>{this.isTap=!1,this.isHold=!0,_t(this,this.hass,this.config,!0,!1)},this._handleTap=()=>{var t;clearTimeout(this.holdTimer),(null===(t=this.config)||void 0===t?void 0:t.tap_action)&&(this.isHold||_t(this,this.hass,this.config,!1,!1))},this.mouseStartPos={x:0,y:0},this.mousePos={x:0,y:0},this.containerWidth=0,this.oldValue=0,this.currentValue=30,this.stateObj=null,this.isTap=!1,this.isHold=!1,this.holdTimer=0,this._shouldUpdate=!0,this.updateTimeout=0,this.pressTimeout=0,this.trackingStartTime=0}static getStubConfig(){return{}}connectedCallback(){super.connectedCallback(),this.addEventListener("contextmenu",this._handleContextMenu),this.slideGesture=new bt(this,this._handlePointer.bind(this),{touchActions:"pan-y",stopScrollDirection:"horizontal"})}disconnectedCallback(){this.removeEventListener("contextmenu",this._handleContextMenu),this.slideGesture.removeListeners(),super.disconnectedCallback()}_log(t){console.log(`%c BIG-SLIDER-CARD ${this._getName()} %c ${t} `,"color: orange; font-weight: bold; background: black","")}_updateValue(){const t=this.containerWidth,e=this.mousePos.x-this.mouseStartPos.x,i=Math.round(100*e/t);this.currentValue=this.oldValue+i,this._checklimits(),this._updateSlider()}_resetTrack(){this.mouseStartPos={x:this.mousePos.x,y:this.mousePos.y},this.oldValue=this.currentValue}_press(){this.pressTimeout&&clearTimeout(this.pressTimeout),this.pressTimeout=window.setTimeout((()=>this.setAttribute("pressed","")),this.config.min_slide_time),this.setAttribute("half-pressed","")}_unpress(){this.pressTimeout&&clearTimeout(this.pressTimeout),this.removeAttribute("pressed"),this.removeAttribute("half-pressed")}_checklimits(){this.currentValuethis.config.max&&(this.currentValue=this.config.max,this._resetTrack())}_updateSlider(){var t;this.style.setProperty("--bsc-percent",this.currentValue+"%");const e=null===(t=null==this?void 0:this.shadowRoot)||void 0===t?void 0:t.getElementById("percentage");e&&(e.innerText=Math.round(this.currentValue)+"%")}_updateColors(){var t,e,i;let s="var(--bsc-color)",r="0%",n="50%",o=!1;if(this.stateObj)if("on"==this.stateObj.state){const i=(null===(t=this.stateObj.attributes)||void 0===t?void 0:t.rgb_color)||[255,255,255],a=(null===(e=this.stateObj.attributes)||void 0===e?void 0:e.brightness)||255;o=!0,i&&(s=`rgb(${i.join(",")})`),a&&(r=`${Math.ceil(100*a/255)}%`,n=`${Math.ceil(100*a/510+50)}%`)}else s="var(--bsc-off-color)";const a=null===(i=null==this?void 0:this.shadowRoot)||void 0===i?void 0:i.getElementById("percentage");o||a&&(a.innerText=Ct("common.off")),this.style.setProperty("--bsc-entity-color",s),this.style.setProperty("--bsc-brightness",r),this.style.setProperty("--bsc-brightness-ui",n),this.config.icon_color&&o&&this.style.setProperty("--bsc-icon-color",this.config.icon_color),this.config.icon_color&&!o&&this.style.removeProperty("--bsc-icon-color"),this.config.color&&this.style.setProperty("--bsc-slider-color",this.config.color)}_getValue(){var t;if(!this._shouldUpdate)return;if(!this.stateObj)return;const e=(null===(t=this.config)||void 0===t?void 0:t.attribute)||wt;let i=0;if("on"!=this.stateObj.state)i=0;else switch(e){case"brightness":i=Math.ceil(100*(this.stateObj.attributes.brightness||255)/255);break;case"red":case"green":case"blue":const t=this.stateObj.attributes.rgb_color||[255,255,255];"red"===e&&(i=t[0]),"green"===e&&(i=t[1]),"blue"===e&&(i=t[2]),i=Math.ceil(100*i/255);break;case"hue":case"saturation":const s=this.stateObj.attributes.hs_color||[100,100];"hue"===e&&(i=s[0]),"saturation"===e&&(i=s[1])}this.currentValue=i,this._updateSlider()}_setValue(){let t,e=this.currentValue,i=this.config.attribute||wt,s=!0;switch(i){case"brightness":e=Math.ceil(e/100*255),e||(s=!1);break;case"red":case"green":case"blue":t=this.stateObj.attributes.rgb_color||[255,255,255],"red"===i&&(t[0]=e),"green"===i&&(t[1]=e),"blue"===i&&(t[2]=e),e=t,i="rgb_color";break;case"hue":case"saturation":t=this.stateObj.attributes.hs_color||[100,100],"hue"===i&&(t[0]=e),"saturation"===i&&(t[1]=e),e=t,i="hs_color"}const r={entity_id:this.stateObj.entity_id};s?(r[i]=e,this.config.transition&&(r.transition=this.config.transition),this.hass.callService("light","turn_on",r)):this.hass.callService("light","turn_off",r)}setConfig(t){if(!t)throw new Error(Ct("common.invalid_configuration"));if(!t.entity)throw new Error(Ct("common.no_entity_set"));t.test_gui&&function(){var t=document.querySelector("home-assistant");if(t=(t=(t=(t=(t=(t=(t=(t=t&&t.shadowRoot)&&t.querySelector("home-assistant-main"))&&t.shadowRoot)&&t.querySelector("app-drawer-layout partial-panel-resolver"))&&t.shadowRoot||t)&&t.querySelector("ha-panel-lovelace"))&&t.shadowRoot)&&t.querySelector("hui-root")){var e=t.lovelace;return e.current_view=t.___curView,e}return null}().setEditMode(!0),this.config=Object.assign({attribute:wt,tap_action:{action:"toggle",haptic:"light"},min_slide_time:0,hold_time:600,settle_time:3e3,min:0,max:100},t)}_stopUpdates(){var t,e,i;this._shouldUpdate&&(this.updateTimeout&&clearTimeout(this.updateTimeout),null===(i=null===(e=null===(t=this.shadowRoot)||void 0===t?void 0:t.getElementById("slider"))||void 0===e?void 0:e.classList)||void 0===i||i.remove("animate"),this._shouldUpdate=!1)}_startUpdates(t=!1){this.updateTimeout&&clearTimeout(this.updateTimeout),this.updateTimeout=window.setTimeout((()=>{var t,e,i;this._shouldUpdate=!0,null===(i=null===(e=null===(t=this.shadowRoot)||void 0===t?void 0:t.getElementById("slider"))||void 0===e?void 0:e.classList)||void 0===i||i.add("animate"),this.requestUpdate()}),t?this.config.settle_time:0)}shouldUpdate(t){return!!this.config&&function(t,e,i){if(e.has("config")||i)return!0;if(t.config.entity){var s=e.get("hass");return!s||s.states[t.config.entity]!==t.hass.states[t.config.entity]}return!1}(this,t,!1)}updated(){var t,e;this.containerWidth=(null===(e=null===(t=this.shadowRoot)||void 0===t?void 0:t.getElementById("container"))||void 0===e?void 0:e.clientWidth)||0,this._getValue(),this._updateColors()}render(){var t,e,i,s;if(this.config||(this.stateObj=null),this.config.entity||(this.stateObj=null),!this.config.entity||!(this.config.entity in this.hass.states))return this.stateObj=null,this._showError(`${Ct("common.no_entity")}: ${this.config.entity}`);this.stateObj=this.config.entity&&this.hass.states[this.config.entity];const r=this._getName(),n=null!==(t=this.config.icon)&&void 0!==t?t:function(t){if(!t)return"mdi:bookmark";if(t.attributes.icon)return t.attributes.icon;var e=dt(t.entity_id);return e in yt?yt[e](t):mt(e,t.state)}(this.stateObj),o=null!==(e=this.config.colorize&&!0)&&void 0!==e&&e,a=null!==(i=this.config.show_percentage&&!0)&&void 0!==i&&i,l=null!==(s=this.config.bold_text&&!0)&&void 0!==s&&s;return $` -
- +
+
-

- ${this.config.name||s} +

+ ${this.config.name||r}

- `}_getName(){var t,e,i;return(null===(e=null===(t=this.stateObj)||void 0===t?void 0:t.attributes)||void 0===e?void 0:e.friendly_name)?this.stateObj.attributes.friendly_name:(null===(i=this.stateObj)||void 0===i?void 0:i.entity_id)?function(t){return t.substr(t.indexOf(".")+1)}(this.stateObj.entity_id):"???"}_showWarning(t){return I` + `}_getName(){var t,e,i;return(null===(e=null===(t=this.stateObj)||void 0===t?void 0:t.attributes)||void 0===e?void 0:e.friendly_name)?this.stateObj.attributes.friendly_name:(null===(i=this.stateObj)||void 0===i?void 0:i.entity_id)?function(t){return t.substr(t.indexOf(".")+1)}(this.stateObj.entity_id):"???"}_showWarning(t){return $` ${t} - `}_showError(t){const e=document.createElement("hui-error-card");return e.setConfig({type:"error",error:t}),I` + `}_showError(t){const e=document.createElement("hui-error-card");return e.setConfig({type:"error",error:t}),$` ${e} - `}static get styles(){return nt` + `}static get styles(){return st` :host { --bsc-background: var(--card-background-color, #aaaaaa); --bsc-slider-color: var(--paper-slider-active-color, #f9d2b0); @@ -378,4 +292,4 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN #percentage { color: var(--bsc-secondary-text-color) } - `}};var Ee,Oe;t([Z({attribute:!1})],Ce.prototype,"hass",void 0),t([Z({attribute:!1,hasChanged:null==Ee?void 0:Ee.hasChanged})],Ce.prototype,"config",void 0),Ce=t([(Oe="big-slider-card",t=>"function"==typeof t?((t,e)=>(window.customElements.define(t,e),e))(Oe,t):((t,e)=>{const{kind:i,elements:n}=e;return{kind:i,elements:n,finisher(e){window.customElements.define(t,e)}}})(Oe,t))],Ce);export{Ce as BigSliderCard}; + `}};var Nt,Ot;t([Z({attribute:!1})],Et.prototype,"hass",void 0),t([Z({attribute:!1,hasChanged:null==Nt?void 0:Nt.hasChanged})],Et.prototype,"config",void 0),Et=t([(Ot="big-slider-card",t=>"function"==typeof t?((t,e)=>(window.customElements.define(t,e),e))(Ot,t):((t,e)=>{const{kind:i,elements:s}=e;return{kind:i,elements:s,finisher(e){window.customElements.define(t,e)}}})(Ot,t))],Et);export{Et as BigSliderCard}; diff --git a/package.json b/package.json index e2908ce..14d8a5c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "big-slider-card", - "version": "1.3.2", + "version": "1.1.0", "description": "Lovelace big-slider-card", "keywords": [ "home-assistant", @@ -15,7 +15,7 @@ "author": "Ian Richardson ", "license": "MIT", "dependencies": { - "@polymer/paper-slider": "^3.0.1", + "@nicufarmache/slide-gesture": "^1.1.1", "custom-card-helpers": "^1.6.6", "home-assistant-js-websocket": "^4.5.0", "lit-element": "^2.4.0", diff --git a/src/big-slider-card.ts b/src/big-slider-card.ts index f4a129b..bfeeebe 100644 --- a/src/big-slider-card.ts +++ b/src/big-slider-card.ts @@ -20,10 +20,8 @@ import { stateIcon, } from 'custom-card-helpers'; // This is a community maintained npm module with common helper functions/types -import {GestureEventListeners} from '@polymer/polymer/lib/mixins/gesture-event-listeners.js'; -import * as Gestures from '@polymer/polymer/lib/utils/gestures.js'; -import {setPassiveTouchGestures} from '@polymer/polymer/lib/utils/settings.js'; -import { throttle } from './helpers'; +import { SlideGesture } from '@nicufarmache/slide-gesture'; + import type { BigSliderCardConfig, MousePos } from './types'; import { CARD_VERSION, @@ -31,7 +29,7 @@ import { SETTLE_TIME, HOLD_TIME, MIN_SLIDE_TIME, - SCROLL_THRESHOLD, + TAP_THRESHOLD, } from './const'; import { localize } from './localize/localize'; @@ -52,7 +50,7 @@ console.info( }); @customElement('big-slider-card') -export class BigSliderCard extends GestureEventListeners(LitElement) { +export class BigSliderCard extends LitElement { mouseStartPos: MousePos; mousePos: MousePos; containerWidth: number; @@ -61,12 +59,12 @@ export class BigSliderCard extends GestureEventListeners(LitElement) { holdTimer: number; isHold: boolean stateObj: any | null; - _setValueThrottled: Function; _shouldUpdate: boolean; updateTimeout: number; pressTimeout: number; trackingStartTime: number; - trackingStartRect: DOMRect | undefined; + slideGesture: any; + isTap: boolean; public static getStubConfig(): object { return {}; @@ -85,32 +83,27 @@ export class BigSliderCard extends GestureEventListeners(LitElement) { this.oldValue = 0; this.currentValue = 30; this.stateObj = null; + this.isTap = false; this.isHold = false; this.holdTimer = 0; this._shouldUpdate = true; this.updateTimeout = 0; this.pressTimeout = 0; this.trackingStartTime = 0; - this._setValueThrottled = throttle(this._setValue.bind(this), 200); } connectedCallback(): void { super.connectedCallback(); - setPassiveTouchGestures(true); - Gestures.addListener(this, 'down', this._handleDown); - Gestures.addListener(this, 'up', this._handleUp); - Gestures.addListener(this, 'tap', this._handleTap); - Gestures.addListener(this, 'track', this._handleTrack); - Gestures.setTouchAction(this, 'pan-y pinch-zoom'); // Let browser handle vertical scrolling and zoom this.addEventListener('contextmenu', this._handleContextMenu); + this.slideGesture = new SlideGesture(this, this._handlePointer.bind(this), { + touchActions: 'pan-y', + stopScrollDirection: 'horizontal' + }); } disconnectedCallback(): void { - Gestures.removeListener(this, 'down', this._handleDown); - Gestures.removeListener(this, 'up', this._handleUp); - Gestures.removeListener(this, 'tap', this._handleTap); - Gestures.removeListener(this, 'track', this._handleTrack); this.removeEventListener('contextmenu', this._handleContextMenu); + this.slideGesture.removeListeners(); super.disconnectedCallback(); } @@ -135,21 +128,68 @@ export class BigSliderCard extends GestureEventListeners(LitElement) { return false; } - _handleDown = (): void => { - this._press(); - this.isHold = false; - this.holdTimer = window.setTimeout(this._setHold, this.config.hold_time); + _handlePointer = (evt, extra): void => { + this.mousePos = { x: evt.pageX, y: evt.pageY }; + + if (evt.type === 'pointerdown') { + this._press(); + this.isTap = true; + this.isHold = false; + this.holdTimer = window.setTimeout(this._setHold, this.config.hold_time); + this.trackingStartTime = Date.now(); + this._resetTrack(); + } + + this._updateValue(); + + if (evt.type === 'pointermove') { + if(this.isTap && (Math.abs(extra.relativeX) > TAP_THRESHOLD || Math.abs(extra.relativeY) > TAP_THRESHOLD)) { + this._stopUpdates(); + this.isTap = false; + clearTimeout(this.holdTimer); + } + } + + if (evt.type === 'pointercancel') { + clearTimeout(this.holdTimer); + this._unpress(); + this._startUpdates(); + } + + if (evt.type === 'pointerup') { + clearTimeout(this.holdTimer); + this._unpress(); + this._startUpdates(); + + if (this.isTap) { + this._handleTap(); + return; + } + + if((Date.now() - this.trackingStartTime) > this.config.min_slide_time) { + this._setValue(); + this._startUpdates(true); + } + } + } + + _updateValue(): void { + const width = this.containerWidth; + const dx = this.mousePos.x - this.mouseStartPos.x; + + const percentage = Math.round( 100 * dx / width ); + + this.currentValue = this.oldValue + percentage; + this._checklimits(); + this._updateSlider(); } _setHold = (): void => { + this.isTap = false; this.isHold = true; handleClick(this, this.hass, this.config, true, false); } - _handleUp = (): void => { - this._unpress(); - } - _handleTap = (): void => { clearTimeout(this.holdTimer); if (this.config?.tap_action) { @@ -159,59 +199,9 @@ export class BigSliderCard extends GestureEventListeners(LitElement) { } } - _handleTrack = (e): void => { - this.mousePos = { x: e.detail.x, y: e.detail.y }; - clearTimeout(this.holdTimer); - - switch(e.detail.state) { - case 'start': - this._startTrack() - break; - case 'track': - this._track() - break; - case 'end': - this._endTrack() - break; - } - } - - _startTrack(): void { - this.trackingStartTime = Date.now(); - this.trackingStartRect = this.getBoundingClientRect(); - this._restartTrack(); - } - - _restartTrack(): void { + _resetTrack(): void { this.mouseStartPos = { x: this.mousePos.x, y: this.mousePos.y }; this.oldValue = this.currentValue; - this._press(); - this._stopUpdates(); - if(this.updateTimeout) clearTimeout(this.updateTimeout); - } - - _track(): void { - this._updateValue(); - //this._setValueThrottled(); - if (this._hasScrolled()) { - this._endTrack(); - } - } - - _endTrack(): void { - this._updateValue(); - this._unpress(); - if(this.updateTimeout) clearTimeout(this.updateTimeout); - - const isTooShort = (Date.now() - this.trackingStartTime) < this.config.min_slide_time; - - if(isTooShort || this._hasScrolled()) { - this.updateTimeout = window.setTimeout(this._startUpdates.bind(this), 0); - return; - } - - this._setValue(); - this.updateTimeout = window.setTimeout(this._startUpdates.bind(this), this.config.settle_time) } _press(): void { @@ -226,35 +216,17 @@ export class BigSliderCard extends GestureEventListeners(LitElement) { this.removeAttribute('half-pressed'); } - _updateValue(): void { - const width = this.containerWidth; - const x = this.mousePos.x - this.mouseStartPos.x; - - const percentage = Math.round( 100 * x / width ); - - this.currentValue = this.oldValue + percentage; - this._checklimits(); - this._updateSlider(); - } - _checklimits(): void { if (this.currentValue < this.config.min){ this.currentValue = this.config.min; - this._restartTrack(); + this._resetTrack(); } if (this.currentValue > this.config.max){ this.currentValue = this.config.max; - this._restartTrack(); + this._resetTrack(); } } - _hasScrolled(): boolean { - // Check for scrolling - const currentTop = this.getBoundingClientRect().top; - const startTop = this.trackingStartRect?.top || 0; - return Math.abs(currentTop - startTop) > SCROLL_THRESHOLD; - } - _updateSlider(): void { this.style.setProperty('--bsc-percent', this.currentValue + '%'); const percentage = this?.shadowRoot?.getElementById('percentage'); @@ -418,14 +390,20 @@ export class BigSliderCard extends GestureEventListeners(LitElement) { } _stopUpdates(): void { - this._shouldUpdate = false; + if(!this._shouldUpdate) return; + if(this.updateTimeout) clearTimeout(this.updateTimeout); this.shadowRoot?.getElementById('slider')?.classList?.remove('animate') + this._shouldUpdate = false; } - _startUpdates(): void { - this._shouldUpdate = true; - this.shadowRoot?.getElementById('slider')?.classList?.add('animate') - this.requestUpdate(); + _startUpdates(settle = false): void { + if(this.updateTimeout) clearTimeout(this.updateTimeout); + this.updateTimeout = window.setTimeout(() => { + this._shouldUpdate = true; + this.shadowRoot?.getElementById('slider')?.classList?.add('animate') + this.requestUpdate(); + }, settle ? this.config.settle_time : 0); + } // https://lit-element.polymer-project.org/guide/lifecycle#shouldupdate diff --git a/src/const.ts b/src/const.ts index dd961cd..9810bdf 100644 --- a/src/const.ts +++ b/src/const.ts @@ -1,6 +1,6 @@ -export const CARD_VERSION = '1.0.11'; +export const CARD_VERSION = '1.1.0'; export const DEFAULT_ATTRIBUTE = 'brightness'; export const SETTLE_TIME = 3000; export const HOLD_TIME = 600; export const MIN_SLIDE_TIME = 0; -export const SCROLL_THRESHOLD = 5; +export const TAP_THRESHOLD = 5; diff --git a/src/helpers.ts b/src/helpers.ts deleted file mode 100644 index bb2fc4f..0000000 --- a/src/helpers.ts +++ /dev/null @@ -1,19 +0,0 @@ -//from https://stackoverflow.com/a/59378445 - -export function throttle(func, timeFrame): Function { - let lastTime = 0; - return function (): void { - const now = Date.now(); - if (now - lastTime >= timeFrame) { - func(); - lastTime = now; - } - }; -} - -export function addBrightness(color: Array, brightness: number): Array { - const limit = (x: number): number => Math.min(Math.max(x, 0), 255); - const transform = (x: number, brightness: number): number => x * (255-brightness)/255 + brightness; - - return color.map((x: number): number => limit(transform(x,brightness))); -} \ No newline at end of file diff --git a/src/types.ts b/src/types.ts index 86c9ac7..f15e59f 100644 --- a/src/types.ts +++ b/src/types.ts @@ -17,8 +17,6 @@ export interface BigSliderCardConfig extends LovelaceCardConfig { entity?: string; attribute?: string; transition?: number; - hold_time?: number; - settle_time?: number; tap_action?: ActionConfig; hold_action?: ActionConfig; double_tap_action?: ActionConfig;