diff --git a/README.md b/README.md index bf19d0e..4046ffc 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,8 @@ colorize: true icon: mdi:lamp show_percentage: true bold_text: true +min: 1 +max: 80 hold_time: 600 settle_time: 3000 tap_action: @@ -67,6 +69,8 @@ hold_action: | icon | string | **Optional** | Sets custom icon | entity icon | | show_percentage | boolean | **Optional** | Show percentage under entity name | false | | bold_text | boolean | **Optional** | Make taxt font bold | false | +| min | number | **Optional** | Maximum value for slider | `0` | +| max | number | **Optional** | minimum value for slider | `100` | | hold_time | number | **Optional** | Hold gesture time (ms) | `600` | | settle_time | number | **Optional** | Ignore updates after changig the value (ms) | `3000` | | tap_action | object | **Optional** | Action to take on tap | `action: toggle` | diff --git a/dist/big-slider-card.js b/dist/big-slider-card.js index 2841468..f49415d 100644 --- a/dist/big-slider-card.js +++ b/dist/big-slider-card.js @@ -25,7 +25,7 @@ function t(t,e,i,n){var o,s=arguments.length,r=s<3?e:null===n?n=Object.getOwnPro * subject to an additional IP rights grant found at * http://polymer.github.io/PATENTS.txt */ -const y=new WeakMap,g=t=>"function"==typeof t&&y.has(t),_={},v={}; +const g=new WeakMap,y=t=>"function"==typeof t&&g.has(t),_={},v={}; /** * @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 P=t=>null===t||!("object"==typeof t||"function"==typeof t),k=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(;g(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=U(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 U=t=>t&&(M?{capture:t.capture,passive:t.passive,once:t.once}:t.capture) + */const P=t=>null===t||!("object"==typeof t||"function"==typeof t),k=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=U(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 U=t=>t&&(M?{capture:t.capture,passive:t.passive,once:t.once}:t.capture) /** * @license * Copyright (c) 2017 The Polymer Project Authors. All rights reserved. @@ -170,7 +170,7 @@ 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 ot={};class st 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!==ot&&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 ot}}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 o=n.scopeName,s=D.has(e),r=$&&11===e.nodeType&&!!e.host,a=r&&!F.has(o),c=a?document.createDocumentFragment():e;if(((t,e,n)=>{let o=D.get(e);void 0===o&&(i(e,e.firstChild),D.set(e,o=new N(Object.assign({templateFactory:R},n))),o.appendInto(e)),o.setValue(t),o.commit()})(t,c,Object.assign({templateFactory:q(o)},n)),a){const t=D.get(c);D.delete(c);const n=t.value instanceof w?t.value.template:void 0;H(o,c,n),i(e,e.firstChild),e.appendChild(c),D.set(e,t)}!s&&r&&window.ShadyCSS.styleElement(e.host)},st.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 o=new Event(e,{bubbles:void 0===n.bubbles||n.bubbles,cancelable:Boolean(n.cancelable),composed:void 0===n.composed||n.composed});return o.detail=i,t.dispatchEvent(o),o},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)},yt=function(t,e){return function(t,e,i){void 0===i&&(i=!0);var n,o=dt(e),s="group"===o?"homeassistant":o;switch(o){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(s,n,{entity_id:e})}(t,e,ut.includes(t.states[e].state))},gt=function(t,e,i,n,o){var s;if(o&&i.double_tap_action?s=i.double_tap_action:n&&i.hold_action?s=i.hold_action:!n&&i.tap_action&&(s=i.tap_action),s||(s={action:"more-info"}),!s.confirmation||s.confirmation.exemptions&&s.confirmation.exemptions.some((function(t){return t.user===e.user.id}))||confirm(s.confirmation.text||"Are you sure you want to "+s.action+"?"))switch(s.action){case"more-info":(s.entity||i.entity||i.camera_image)&&(ht(t,"hass-more-info",{entityId:s.entity?s.entity:i.entity?i.entity:i.camera_image}),s.haptic&&ft(s.haptic));break;case"navigate":s.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,s.navigation_path),s.haptic&&ft(s.haptic));break;case"url":s.url_path&&window.open(s.url_path),s.haptic&&ft(s.haptic);break;case"toggle":i.entity&&(yt(e,i.entity),s.haptic&&ft(s.haptic));break;case"call-service":if(!s.service)return;var r=s.service.split(".",2),a=r[0],c=r[1],l=lt({},s.service_data);"entity"===l.entity_id&&(l.entity_id=i.entity),e.callService(a,c,l,s.target),s.haptic&&ft(s.haptic);break;case"fire-dom-event":ht(t,"ll-custom",s),s.haptic&&ft(s.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 o=t.attributes.unit_of_measurement;return"°C"===o||"°F"===o?"mdi:thermometer":mt("sensor")},input_datetime:function(t){return t.attributes.has_date?t.attributes.has_time?mt("input_datetime"):"mdi:calendar":"mdi:clock"}}; +(window.litElementVersions||(window.litElementVersions=[])).push("2.5.1");const ot={};class st 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!==ot&&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 ot}}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 o=n.scopeName,s=D.has(e),r=$&&11===e.nodeType&&!!e.host,a=r&&!F.has(o),c=a?document.createDocumentFragment():e;if(((t,e,n)=>{let o=D.get(e);void 0===o&&(i(e,e.firstChild),D.set(e,o=new N(Object.assign({templateFactory:R},n))),o.appendInto(e)),o.setValue(t),o.commit()})(t,c,Object.assign({templateFactory:q(o)},n)),a){const t=D.get(c);D.delete(c);const n=t.value instanceof w?t.value.template:void 0;H(o,c,n),i(e,e.firstChild),e.appendChild(c),D.set(e,t)}!s&&r&&window.ShadyCSS.styleElement(e.host)},st.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 o=new Event(e,{bubbles:void 0===n.bubbles||n.bubbles,cancelable:Boolean(n.cancelable),composed:void 0===n.composed||n.composed});return o.detail=i,t.dispatchEvent(o),o},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,o=dt(e),s="group"===o?"homeassistant":o;switch(o){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(s,n,{entity_id:e})}(t,e,ut.includes(t.states[e].state))},yt=function(t,e,i,n,o){var s;if(o&&i.double_tap_action?s=i.double_tap_action:n&&i.hold_action?s=i.hold_action:!n&&i.tap_action&&(s=i.tap_action),s||(s={action:"more-info"}),!s.confirmation||s.confirmation.exemptions&&s.confirmation.exemptions.some((function(t){return t.user===e.user.id}))||confirm(s.confirmation.text||"Are you sure you want to "+s.action+"?"))switch(s.action){case"more-info":(s.entity||i.entity||i.camera_image)&&(ht(t,"hass-more-info",{entityId:s.entity?s.entity:i.entity?i.entity:i.camera_image}),s.haptic&&ft(s.haptic));break;case"navigate":s.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,s.navigation_path),s.haptic&&ft(s.haptic));break;case"url":s.url_path&&window.open(s.url_path),s.haptic&&ft(s.haptic);break;case"toggle":i.entity&&(gt(e,i.entity),s.haptic&&ft(s.haptic));break;case"call-service":if(!s.service)return;var r=s.service.split(".",2),a=r[0],c=r[1],l=lt({},s.service_data);"entity"===l.entity_id&&(l.entity_id=i.entity),e.callService(a,c,l,s.target),s.haptic&&ft(s.haptic);break;case"fire-dom-event":ht(t,"ll-custom",s),s.haptic&&ft(s.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 o=t.attributes.unit_of_measurement;return"°C"===o||"°F"===o?"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. @@ -247,7 +247,7 @@ 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 Rt="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],Ft=function(){try{return 1===new MouseEvent("test",{buttons:1}).buttons}catch(t){return!1}}();function Ht(t){return qt.indexOf(t)>-1}let Wt=!1;function Xt(t){if(!Ht(t)&&"touchend"!==t)return Rt&&Wt&&Vt?{passive:!0}:void 0}!function(){try{let t=Object.defineProperty({},"passive",{get(){Wt=!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=se(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 o=n[i];if(o){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;Rt||"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=se(t);for(let t,n=0;no:"pan-y"===i&&(n=o>s)),n?t.preventDefault():me("track")}}(t)}if(e=t[Dt],!e.skip){for(let i,n=0;n-1&&i.reset&&i.reset();for(let n,s=0;s{t.style.touchAction=e}));t[Lt]=e}(t,n.touchAction)}(t,e,i),!0)}function ue(t,e,i){return!!re[e]&&(function(t,e,i){let n=re[e],o=n.deps,s=n.name,r=t[jt];if(r)for(let e,i,n=0;n=Bt||o>=Bt}function ge(t,e,i){if(!e)return;let n,o=t.moves[t.moves.length-2],s=t.moves[t.moves.length-1],r=s.x-t.x,a=s.y-t.y,c=0;o&&(n=s.x-o.x,c=s.y-o.y),pe(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 o=n;if(n=n.shadowRoot.elementFromPoint(t,e),o===n)break;n&&(i=n)}return i}(i.clientX,i.clientY)}})}function _e(t,e,i){let n=Math.abs(e.clientX-t.x),o=Math.abs(e.clientY-t.y),s=ce(i||e);!s||Kt[s.localName]&&s.hasAttribute("disabled")||(isNaN(n)||isNaN(o)||n<=It&&o<=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,o=t.pageY;return!(n>=i.left&&n<=i.right&&o>=i.top&&o<=i.bottom)}return!1}(e))&&(t.prevent||pe(s,"tap",{x:e.clientX,y:e.clientY,sourceEvent:e,preventer:i}))} +*/let Rt="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],Ft=function(){try{return 1===new MouseEvent("test",{buttons:1}).buttons}catch(t){return!1}}();function Ht(t){return qt.indexOf(t)>-1}let Wt=!1;function Xt(t){if(!Ht(t)&&"touchend"!==t)return Rt&&Wt&&Vt?{passive:!0}:void 0}!function(){try{let t=Object.defineProperty({},"passive",{get(){Wt=!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=se(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 o=n[i];if(o){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;Rt||"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=se(t);for(let t,n=0;no:"pan-y"===i&&(n=o>s)),n?t.preventDefault():me("track")}}(t)}if(e=t[Dt],!e.skip){for(let i,n=0;n-1&&i.reset&&i.reset();for(let n,s=0;s{t.style.touchAction=e}));t[Lt]=e}(t,n.touchAction)}(t,e,i),!0)}function ue(t,e,i){return!!re[e]&&(function(t,e,i){let n=re[e],o=n.deps,s=n.name,r=t[jt];if(r)for(let e,i,n=0;n=Bt||o>=Bt}function ye(t,e,i){if(!e)return;let n,o=t.moves[t.moves.length-2],s=t.moves[t.moves.length-1],r=s.x-t.x,a=s.y-t.y,c=0;o&&(n=s.x-o.x,c=s.y-o.y),pe(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 o=n;if(n=n.shadowRoot.elementFromPoint(t,e),o===n)break;n&&(i=n)}return i}(i.clientX,i.clientY)}})}function _e(t,e,i){let n=Math.abs(e.clientX-t.x),o=Math.abs(e.clientY-t.y),s=ce(i||e);!s||Kt[s.localName]&&s.hasAttribute("disabled")||(isNaN(n)||isNaN(o)||n<=It&&o<=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,o=t.pageY;return!(n>=i.left&&n<=i.right&&o>=i.top&&o<=i.bottom)}return!1}(e))&&(t.prevent||pe(s,"tap",{x:e.clientX,y:e.clientY,sourceEvent:e,preventer:i}))} /** @license Copyright (c) 2017 The Polymer Project Authors. All rights reserved. @@ -256,7 +256,7 @@ 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(){oe(this.info)},mousedown:function(t){if(!ee(t))return;let e=ce(t),i=this;ne(this.info,(function(t){ee(t)||(fe("up",e,t),oe(i.info))}),(function(t){ee(t)&&fe("up",e,t),oe(i.info)})),fe("down",e,t)},touchstart:function(t){fe("down",ce(t),t.changedTouches[0],t)},touchend:function(t){fe("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,oe(this.info)},mousedown:function(t){if(!ee(t))return;let e=ce(t),i=this,n=function(t){let n=t.clientX,o=t.clientY;ye(i.info,n,o)&&(i.info.state=i.info.started?"mouseup"===t.type?"end":"track":"start","start"===i.info.state&&me("tap"),i.info.addMove({x:n,y:o}),ee(t)||(i.info.state="end",oe(i.info)),e&&ge(i.info,e,t),i.info.started=!0)};ne(this.info,n,(function(t){i.info.started&&n(t),oe(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,o=i.clientY;ye(this.info,n,o)&&("start"===this.info.state&&me("tap"),this.info.addMove({x:n,y:o}),ge(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}),ge(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)&&_e(this.info,t)},touchstart:function(t){const e=t.changedTouches[0];this.info.x=e.clientX,this.info.y=e.clientY},touchend:function(t){_e(this.info,t.changedTouches[0],t)}});const ve=function(t){let e=t.__mixinApplications;e||(e=new WeakMap,t.__mixinApplications=e);let i=wt++;return function(n){let o=n.__mixinSet;if(o&&o[i])return n;let s=e,r=s.get(n);if(!r){r=t(n),s.set(n,r);let e=Object.create(r.__mixinSet||o||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 we="brightness";var be={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"},Se={common:be},xe={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:xe};const ke={en:Object.freeze({__proto__:null,common:be,default:Se}),ro:Object.freeze({__proto__:null,common:xe,default:Pe})};function Te(t,e="",i=""){const n=(localStorage.getItem("selectedLanguage")||"en").replace(/['"]+/g,"").replace("-","_");let o;try{o=t.split(".").reduce(((t,e)=>t[e]),ke[n])}catch(e){o=t.split(".").reduce(((t,e)=>t[e]),ke.en)}return void 0===o&&(o=t.split(".").reduce(((t,e)=>t[e]),ke.en)),""!==e&&""!==i&&(o=o.replace(e,i)),o}console.info(`%c BIG-SLIDER-CARD \n%c ${Te("common.version")} 1.0.7 `,"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 Ee=class extends(ve(st)){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,gt(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||gt(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._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(),de(this,"down",this._handleDown),de(this,"up",this._handleUp),de(this,"tap",this._handleTap),de(this,"track",this._handleTrack),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.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()}_endTrack(){this._updateValue(),this._unpress(),this._setValue(),this.updateTimeout&&clearTimeout(this.updateTimeout),this.updateTimeout=window.setTimeout(this._startUpdates.bind(this),this.config.settle_time)}_press(){this.setAttribute("pressed","")}_unpress(){this.removeAttribute("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.currentValue<0&&(this.currentValue=0,this._startTrack()),this.currentValue>100&&(this.currentValue=100,this._startTrack())}_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)",o="0%",s="50%",r=!1;const a=this.stateObj;if(a){if("on"==a.state){const i=(null===(t=a.attributes)||void 0===t?void 0:t.rgb_color)||[255,255,255],c=(null===(e=a.attributes)||void 0===e?void 0:e.brightness)||255;console.log("DEBUG: state.attributes: ",a.attributes),r=!0,i&&(n=`rgb(${i.join(",")})`),c&&(o=`${Math.ceil(100*c/255)}%`,s=`${Math.ceil(100*c/510+50)}%`)}"off"==a.state&&(console.log("DEBUG: OFF state.attributes: ",a.attributes),n="var(--bsc-off-color)")}const c=null===(i=null==this?void 0:this.shadowRoot)||void 0===i?void 0:i.getElementById("percentage");r||c&&(c.innerText=Te("common.off")),this.style.setProperty("--bsc-entity-color",n),this.style.setProperty("--bsc-brightness",o),this.style.setProperty("--bsc-brightness-ui",s),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)||we;let i=0;if("off"==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||we,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 o={entity_id:this.stateObj.entity_id};n?(o[i]=e,this.config.transition&&(o.transition=this.config.transition),this.hass.callService("light","turn_on",o)):this.hass.callService("light","turn_off",o)}setConfig(t){if(!t)throw new Error(Te("common.invalid_configuration"));if(!t.entity)throw new Error(Te("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:we,tap_action:{action:"toggle",haptic:"light"},hold_time:600,settle_time:3e3},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(`${Te("common.no_entity")}: ${this.config.entity}`);this.stateObj=this.config.entity&&this.hass.states[this.config.entity];const o=this._getName(),s=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` +*/he({name:"downup",deps:["mousedown","touchstart","touchend"],flow:{start:["mousedown","touchstart"],end:["mouseup","touchend"]},emits:["down","up"],info:{movefn:null,upfn:null},reset:function(){oe(this.info)},mousedown:function(t){if(!ee(t))return;let e=ce(t),i=this;ne(this.info,(function(t){ee(t)||(fe("up",e,t),oe(i.info))}),(function(t){ee(t)&&fe("up",e,t),oe(i.info)})),fe("down",e,t)},touchstart:function(t){fe("down",ce(t),t.changedTouches[0],t)},touchend:function(t){fe("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,oe(this.info)},mousedown:function(t){if(!ee(t))return;let e=ce(t),i=this,n=function(t){let n=t.clientX,o=t.clientY;ge(i.info,n,o)&&(i.info.state=i.info.started?"mouseup"===t.type?"end":"track":"start","start"===i.info.state&&me("tap"),i.info.addMove({x:n,y:o}),ee(t)||(i.info.state="end",oe(i.info)),e&&ye(i.info,e,t),i.info.started=!0)};ne(this.info,n,(function(t){i.info.started&&n(t),oe(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,o=i.clientY;ge(this.info,n,o)&&("start"===this.info.state&&me("tap"),this.info.addMove({x:n,y:o}),ye(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}),ye(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)&&_e(this.info,t)},touchstart:function(t){const e=t.changedTouches[0];this.info.x=e.clientX,this.info.y=e.clientY},touchend:function(t){_e(this.info,t.changedTouches[0],t)}});const ve=function(t){let e=t.__mixinApplications;e||(e=new WeakMap,t.__mixinApplications=e);let i=wt++;return function(n){let o=n.__mixinSet;if(o&&o[i])return n;let s=e,r=s.get(n);if(!r){r=t(n),s.set(n,r);let e=Object.create(r.__mixinSet||o||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 we="brightness";var be={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"},Se={common:be},xe={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:xe};const ke={en:Object.freeze({__proto__:null,common:be,default:Se}),ro:Object.freeze({__proto__:null,common:xe,default:Pe})};function Te(t,e="",i=""){const n=(localStorage.getItem("selectedLanguage")||"en").replace(/['"]+/g,"").replace("-","_");let o;try{o=t.split(".").reduce(((t,e)=>t[e]),ke[n])}catch(e){o=t.split(".").reduce(((t,e)=>t[e]),ke.en)}return void 0===o&&(o=t.split(".").reduce(((t,e)=>t[e]),ke.en)),""!==e&&""!==i&&(o=o.replace(e,i)),o}console.info(`%c BIG-SLIDER-CARD \n%c ${Te("common.version")} 1.0.7 `,"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 Ee=class extends(ve(st)){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._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(),de(this,"down",this._handleDown),de(this,"up",this._handleUp),de(this,"tap",this._handleTap),de(this,"track",this._handleTrack),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.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()}_endTrack(){this._updateValue(),this._unpress(),this._setValue(),this.updateTimeout&&clearTimeout(this.updateTimeout),this.updateTimeout=window.setTimeout(this._startUpdates.bind(this),this.config.settle_time)}_press(){this.setAttribute("pressed","")}_unpress(){this.removeAttribute("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._startTrack())}_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)",o="0%",s="50%",r=!1;const a=this.stateObj;if(a){if("on"==a.state){const i=(null===(t=a.attributes)||void 0===t?void 0:t.rgb_color)||[255,255,255],c=(null===(e=a.attributes)||void 0===e?void 0:e.brightness)||255;console.log("DEBUG: state.attributes: ",a.attributes),r=!0,i&&(n=`rgb(${i.join(",")})`),c&&(o=`${Math.ceil(100*c/255)}%`,s=`${Math.ceil(100*c/510+50)}%`)}"off"==a.state&&(console.log("DEBUG: OFF state.attributes: ",a.attributes),n="var(--bsc-off-color)")}const c=null===(i=null==this?void 0:this.shadowRoot)||void 0===i?void 0:i.getElementById("percentage");r||c&&(c.innerText=Te("common.off")),this.style.setProperty("--bsc-entity-color",n),this.style.setProperty("--bsc-brightness",o),this.style.setProperty("--bsc-brightness-ui",s),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)||we;let i=0;if("off"==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||we,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 o={entity_id:this.stateObj.entity_id};n?(o[i]=e,this.config.transition&&(o.transition=this.config.transition),this.hass.callService("light","turn_on",o)):this.hass.callService("light","turn_off",o)}setConfig(t){if(!t)throw new Error(Te("common.invalid_configuration"));if(!t.entity)throw new Error(Te("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:we,tap_action:{action:"toggle",haptic:"light"},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(`${Te("common.no_entity")}: ${this.config.entity}`);this.stateObj=this.config.entity&&this.hass.states[this.config.entity];const o=this._getName(),s=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` 100){ - this.currentValue = 100; + if (this.currentValue > this.config.max){ + this.currentValue = this.config.max; this._startTrack(); } } @@ -377,6 +377,8 @@ export class BigSliderCard extends GestureEventListeners(LitElement) { }, hold_time: HOLD_TIME, settle_time: SETTLE_TIME, + min: 0, + max: 100, ...config, }; /* eslint-enable @typescript-eslint/camelcase */