diff --git a/.gitignore b/.gitignore index 48f3b8c..59e528e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +/dist/ /node_modules/ /.rpt2_cache/ /.idea/ diff --git a/README.md b/README.md index b581654..6f66d2c 100644 --- a/README.md +++ b/README.md @@ -169,7 +169,7 @@ Custom styles can be set by using [Card mod](https://github.com/thomasloven/love - + @@ -200,7 +200,7 @@ action_button: - + @@ -220,7 +220,7 @@ compact: true - + @@ -240,7 +240,7 @@ icon: - + @@ -264,7 +264,7 @@ icon: - + @@ -284,7 +284,7 @@ action_button: - + @@ -306,7 +306,7 @@ action_button: - + @@ -334,7 +334,7 @@ action_button: - + @@ -354,7 +354,7 @@ slider: - + @@ -375,7 +375,7 @@ slider: - + @@ -397,7 +397,7 @@ slider: - + @@ -425,7 +425,7 @@ For fan entities the icon auto rotates based on the speed of the fan. - + @@ -458,7 +458,7 @@ name: Fan - + @@ -492,7 +492,7 @@ For most use cases: set `slider.direction: top-bottom` and `slider.background: s - + @@ -527,7 +527,7 @@ In this example the action button is used to toggle play/pause. - + @@ -565,7 +565,7 @@ Default behavior: slider is used to set target temperature, it doesn't alter sta - + @@ -599,7 +599,7 @@ Default behavior: `slider.toggle_on_click: true` - + @@ -631,7 +631,7 @@ name: Lock - + @@ -709,7 +709,7 @@ Mixed `group` entities are not supported, if you want to control multiple - media players use [Media player group](https://www.home-assistant.io/integrations/media_player.group/) ## Known issues -When you discover any bugs please open an [issue](https://github.com/mattieha/slider-button-card/issues). +When you discover any bugs please open an [issue](https://github.com/custom-cards/slider-button-card/issues). ## Languages @@ -727,20 +727,21 @@ This card supports translations. Please, help to add more translations and impro - [_Your language?_][add-translation] ## Credits -- Inspired by [Slider entity row](https://github.com/thomasloven/lovelace-slider-entity-row) +- Originally inspired by [Slider entity row](https://github.com/thomasloven/lovelace-slider-entity-row) +- Forked from [Slider button card](https://github.com/mattieha/slider-button-card/) by [@mattieha](https://www.github.com/mattieha) --- [![beer](https://www.buymeacoffee.com/assets/img/custom_images/black_img.png)](https://www.buymeacoffee.com/mattijsha) [hacs]: https://hacs.xyz -[add-translation]: https://github.com/mattieha/slider-button-card/blob/main/CONTRIBUTE.md#adding-a-new-translation -[visual-editor]: https://raw.githubusercontent.com/mattieha/slider-button-card/main/assets/card-editor.png -[preview]: https://raw.githubusercontent.com/mattieha/slider-button-card/main/assets/preview.gif -[preview-2]: https://raw.githubusercontent.com/mattieha/slider-button-card/main/assets/preview-2.gif -[grid]: https://raw.githubusercontent.com/mattieha/slider-button-card/main/assets/grid-not-square.png -[full-width]: https://raw.githubusercontent.com/mattieha/slider-button-card/main/assets/grid-full-width.png -[latest-release]: https://github.com/mattieha/slider-button-card/releases/latest -[releases-shield]: https://img.shields.io/github/release/mattieha/slider-button-card.svg?style=for-the-badge -[releases]: https://github.com/mattieha/slider-button-card/releases -[icon-minimal]: https://raw.githubusercontent.com/mattieha/slider-button-card/main/assets/grid-full-width.png +[add-translation]: https://github.com/custom-cards/slider-button-card/blob/main/CONTRIBUTE.md#adding-a-new-translation +[visual-editor]: https://raw.githubusercontent.com/custom-cards/slider-button-card/main/assets/card-editor.png +[preview]: https://raw.githubusercontent.com/custom-cards/slider-button-card/main/assets/preview.gif +[preview-2]: https://raw.githubusercontent.com/custom-cards/slider-button-card/main/assets/preview-2.gif +[grid]: https://raw.githubusercontent.com/custom-cards/slider-button-card/main/assets/grid-not-square.png +[full-width]: https://raw.githubusercontent.com/custom-cards/slider-button-card/main/assets/grid-full-width.png +[latest-release]: https://github.com/custom-cards/slider-button-card/releases/latest +[releases-shield]: https://img.shields.io/github/release/custom-cards/slider-button-card.svg?style=for-the-badge +[releases]: https://github.com/custom-cards/slider-button-card/releases +[icon-minimal]: https://raw.githubusercontent.com/custom-cards/slider-button-card/main/assets/grid-full-width.png diff --git a/dist/slider-button-card.js b/dist/slider-button-card.js deleted file mode 100644 index 62b8ec5..0000000 --- a/dist/slider-button-card.js +++ /dev/null @@ -1,979 +0,0 @@ -/*! ***************************************************************************** -Copyright (c) Microsoft Corporation. - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH -REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, -INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -PERFORMANCE OF THIS SOFTWARE. -***************************************************************************** */ -function t(t,e,i,o){var r,s=arguments.length,n=s<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,i):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(t,e,i,o);else for(var a=t.length-1;a>=0;a--)(r=t[a])&&(n=(s<3?r(n):s>3?r(e,i,n):r(e,i))||n);return s>3&&n&&Object.defineProperty(e,i,n),n}var e=/d{1,4}|M{1,4}|YY(?:YY)?|S{1,3}|Do|ZZ|Z|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g,i="[^\\s]+",o=/\[([^]*?)\]/gm;function r(t,e){for(var i=[],o=0,r=t.length;o-1?o:null}};function n(t){for(var e=[],i=1;i3?0:(t-t%10!=10?1:0)*t%10]}},d=n({},h),u=function(t,e){for(void 0===e&&(e=2),t=String(t);t.length0?"-":"+")+u(100*Math.floor(Math.abs(e)/60)+Math.abs(e)%60,4)},Z:function(t){var e=t.getTimezoneOffset();return(e>0?"-":"+")+u(Math.floor(Math.abs(e)/60),2)+":"+u(Math.abs(e)%60,2)}},g=function(t){return+t-1},f=[null,"[1-9]\\d?"],b=[null,i],m=["isPm",i,function(t,e){var i=t.toLowerCase();return i===e.amPm[0]?0:i===e.amPm[1]?1:null}],_=["timezoneOffset","[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z?",function(t){var e=(t+"").match(/([+-]|\d\d)/gi);if(e){var i=60*+e[1]+parseInt(e[2],10);return"+"===e[0]?i:-i}return 0}],v=(s("monthNamesShort"),s("monthNames"),{default:"ddd MMM DD YYYY HH:mm:ss",shortDate:"M/D/YY",mediumDate:"MMM D, YYYY",longDate:"MMMM D, YYYY",fullDate:"dddd, MMMM D, YYYY",isoDate:"YYYY-MM-DD",isoDateTime:"YYYY-MM-DDTHH:mm:ssZ",shortTime:"HH:mm",mediumTime:"HH:mm:ss",longTime:"HH:mm:ss.SSS"});var y=function(t,i,r){if(void 0===i&&(i=v.default),void 0===r&&(r={}),"number"==typeof t&&(t=new Date(t)),"[object Date]"!==Object.prototype.toString.call(t)||isNaN(t.getTime()))throw new Error("Invalid Date pass to format");var s=[];i=(i=v[i]||i).replace(o,(function(t,e){return s.push(e),"@@@"}));var a=n(n({},d),r);return(i=i.replace(e,(function(e){return p[e](t,a)}))).replace(/@@@/g,(function(){return s.shift()}))};(function(){try{(new Date).toLocaleDateString("i")}catch(t){return"RangeError"===t.name}})(),function(){try{(new Date).toLocaleString("i")}catch(t){return"RangeError"===t.name}}(),function(){try{(new Date).toLocaleTimeString("i")}catch(t){return"RangeError"===t.name}}();function w(t){return t.substr(0,t.indexOf("."))}function S(t){return w(t.entity_id)}var k="hass:bookmark",x=["closed","locked","off"],O=function(t,e,i,o){o=o||{},i=null==i?{}:i;var r=new Event(e,{bubbles:void 0===o.bubbles||o.bubbles,cancelable:Boolean(o.cancelable),composed:void 0===o.composed||o.composed});return r.detail=i,t.dispatchEvent(r),r},T={alert:"hass:alert",automation:"hass:playlist-play",calendar:"hass:calendar",camera:"hass:video",climate:"hass:thermostat",configurator:"hass:settings",conversation:"hass:text-to-speech",device_tracker:"hass:account",fan:"hass:fan",group:"hass:google-circles-communities",history_graph:"hass:chart-line",homeassistant:"hass:home-assistant",homekit:"hass:home-automation",image_processing:"hass:image-filter-frames",input_boolean:"hass:drawing",input_datetime:"hass:calendar-clock",input_number:"hass:ray-vertex",input_select:"hass:format-list-bulleted",input_text:"hass:textbox",light:"hass:lightbulb",mailbox:"hass:mailbox",notify:"hass:comment-alert",person:"hass:account",plant:"hass:flower",proximity:"hass:apple-safari",remote:"hass:remote",scene:"hass:google-pages",script:"hass:file-document",sensor:"hass:eye",simple_alarm:"hass:bell",sun:"hass:white-balance-sunny",switch:"hass:flash",timer:"hass:timer",updater:"hass:cloud-upload",vacuum:"hass:robot-vacuum",water_heater:"hass:thermometer",weblink:"hass:open-in-new"};function C(t,e){if(t in T)return T[t];switch(t){case"alarm_control_panel":switch(e){case"armed_home":return"hass:bell-plus";case"armed_night":return"hass:bell-sleep";case"disarmed":return"hass:bell-outline";case"triggered":return"hass:bell-ring";default:return"hass:bell"}case"binary_sensor":return e&&"off"===e?"hass:radiobox-blank":"hass:checkbox-marked-circle";case"cover":return"closed"===e?"hass:window-closed":"hass:window-open";case"lock":return e&&"unlocked"===e?"hass:lock-open":"hass:lock";case"media_player":return e&&"off"!==e&&"idle"!==e?"hass:cast-connected":"hass:cast";case"zwave":switch(e){case"dead":return"hass:emoticon-dead";case"sleeping":return"hass:sleep";case"initializing":return"hass:timer-sand";default:return"hass:z-wave"}default:return console.warn("Unable to find icon for domain "+t+" ("+e+")"),k}}var P=function(t){O(window,"haptic",t)},A=function(t,e){return function(t,e,i){void 0===i&&(i=!0);var o,r=w(e),s="group"===r?"homeassistant":r;switch(r){case"lock":o=i?"unlock":"lock";break;case"cover":o=i?"open_cover":"close_cover";break;default:o=i?"turn_on":"turn_off"}return t.callService(s,o,{entity_id:e})}(t,e,x.includes(t.states[e].state))},M=function(t,e,i,o){if(o||(o={action:"more-info"}),!o.confirmation||o.confirmation.exemptions&&o.confirmation.exemptions.some((function(t){return t.user===e.user.id}))||(P("warning"),confirm(o.confirmation.text||"Are you sure you want to "+o.action+"?")))switch(o.action){case"more-info":(i.entity||i.camera_image)&&O(t,"hass-more-info",{entityId:i.entity?i.entity:i.camera_image});break;case"navigate":o.navigation_path&&function(t,e,i){void 0===i&&(i=!1),i?history.replaceState(null,"",e):history.pushState(null,"",e),O(window,"location-changed",{replace:i})}(0,o.navigation_path);break;case"url":o.url_path&&window.open(o.url_path);break;case"toggle":i.entity&&(A(e,i.entity),P("success"));break;case"call-service":if(!o.service)return void P("failure");var r=o.service.split(".",2);e.callService(r[0],r[1],o.service_data),P("success");break;case"fire-dom-event":O(t,"ll-custom",o)}},E=function(t,e,i,o){var r;"double_tap"===o&&i.double_tap_action?r=i.double_tap_action:"hold"===o&&i.hold_action?r=i.hold_action:"tap"===o&&i.tap_action&&(r=i.tap_action),M(t,e,i,r)};var $={humidity:"hass:water-percent",illuminance:"hass:brightness-5",temperature:"hass:thermometer",pressure:"hass:gauge",power:"hass:flash",signal_strength:"hass:wifi"},N={binary_sensor:function(t){var e=t.state&&"off"===t.state;switch(t.attributes.device_class){case"battery":return e?"hass:battery":"hass:battery-outline";case"cold":return e?"hass:thermometer":"hass:snowflake";case"connectivity":return e?"hass:server-network-off":"hass:server-network";case"door":return e?"hass:door-closed":"hass:door-open";case"garage_door":return e?"hass:garage":"hass:garage-open";case"gas":case"power":case"problem":case"safety":case"smoke":return e?"hass:shield-check":"hass:alert";case"heat":return e?"hass:thermometer":"hass:fire";case"light":return e?"hass:brightness-5":"hass:brightness-7";case"lock":return e?"hass:lock":"hass:lock-open";case"moisture":return e?"hass:water-off":"hass:water";case"motion":return e?"hass:walk":"hass:run";case"occupancy":return e?"hass:home-outline":"hass:home";case"opening":return e?"hass:square":"hass:square-outline";case"plug":return e?"hass:power-plug-off":"hass:power-plug";case"presence":return e?"hass:home-outline":"hass:home";case"sound":return e?"hass:music-note-off":"hass:music-note";case"vibration":return e?"hass:crop-portrait":"hass:vibrate";case"window":return e?"hass:window-closed":"hass:window-open";default:return e?"hass:radiobox-blank":"hass:checkbox-marked-circle"}},cover:function(t){var e="closed"!==t.state;switch(t.attributes.device_class){case"garage":return e?"hass:garage-open":"hass:garage";case"door":return e?"hass:door-open":"hass:door-closed";case"shutter":return e?"hass:window-shutter-open":"hass:window-shutter";case"blind":return e?"hass:blinds-open":"hass:blinds";case"window":return e?"hass:window-open":"hass:window-closed";default:return C("cover",t.state)}},sensor:function(t){var e=t.attributes.device_class;if(e&&e in $)return $[e];if("battery"===e){var i=Number(t.state);if(isNaN(i))return"hass:battery-unknown";var o=10*Math.round(i/10);return o>=100?"hass:battery":o<=0?"hass:battery-alert":"hass:battery-"+o}var r=t.attributes.unit_of_measurement;return"°C"===r||"°F"===r?"hass:thermometer":C("sensor")},input_datetime:function(t){return t.attributes.has_date?t.attributes.has_time?C("input_datetime"):"hass:calendar":"hass:clock"}},j=function(t){if(!t)return k;if(t.attributes.icon)return t.attributes.icon;var e=w(t.entity_id);return e in N?N[e](t):C(e,t.state)},I=Function.prototype.toString,R=Object.create,V=Object.defineProperty,H=Object.getOwnPropertyDescriptor,z=Object.getOwnPropertyNames,U=Object.getOwnPropertySymbols,L=Object.getPrototypeOf,F=Object.prototype,D=F.hasOwnProperty,B=F.propertyIsEnumerable,q="function"==typeof U,G="function"==typeof WeakMap,Y=function(t,e){if(!t.constructor)return R(null);var i=t.constructor,o=t.__proto__||L(t);if(i===e.Object)return o===e.Object.prototype?{}:R(o);if(~I.call(i).indexOf("[native code]"))try{return new i}catch(t){}return R(o)},W=function(t,e,i,o){var r=Y(t,e);for(var s in o.set(t,r),t)D.call(t,s)&&(r[s]=i(t[s],o));if(q){var n=U(t),a=n.length;if(a)for(var c=0,l=void 0;c{for(;e!==i;){const i=e.nextSibling;t.removeChild(e),e=i}},et=`{{lit-${String(Math.random()).slice(2)}}}`,it=`\x3c!--${et}--\x3e`,ot=new RegExp(`${et}|${it}`);class rt{constructor(t,e){this.parts=[],this.element=e;const i=[],o=[],r=document.createTreeWalker(e.content,133,null,!1);let s=0,n=-1,a=0;const{strings:c,values:{length:l}}=t;for(;a0;){const e=c[a],i=ct.exec(e)[2],o=i.toLowerCase()+"$lit$",r=t.getAttribute(o);t.removeAttribute(o);const s=r.split(ot);this.parts.push({type:"attribute",index:n,name:i,strings:s}),a+=s.length-1}}"TEMPLATE"===t.tagName&&(o.push(t),r.currentNode=t.content)}else if(3===t.nodeType){const e=t.data;if(e.indexOf(et)>=0){const o=t.parentNode,r=e.split(ot),s=r.length-1;for(let e=0;e{const i=t.length-e.length;return i>=0&&t.slice(i)===e},nt=t=>-1!==t.index,at=()=>document.createComment(""),ct=/([ \x09\x0a\x0c\x0d])([^\0-\x1F\x7F-\x9F "'>=/]+)([ \x09\x0a\x0c\x0d]*=[ \x09\x0a\x0c\x0d]*(?:[^ \x09\x0a\x0c\x0d"'`<>=]*|"[^"]*|'[^']*))$/;function lt(t,e){const{element:{content:i},parts:o}=t,r=document.createTreeWalker(i,133,null,!1);let s=dt(o),n=o[s],a=-1,c=0;const l=[];let h=null;for(;r.nextNode();){a++;const t=r.currentNode;for(t.previousSibling===h&&(h=null),e.has(t)&&(l.push(t),null===h&&(h=t)),null!==h&&c++;void 0!==n&&n.index===a;)n.index=null!==h?-1:n.index-c,s=dt(o,s),n=o[s]}l.forEach(t=>t.parentNode.removeChild(t))}const ht=t=>{let e=11===t.nodeType?0:1;const i=document.createTreeWalker(t,133,null,!1);for(;i.nextNode();)e++;return e},dt=(t,e=-1)=>{for(let i=e+1;i(...e)=>{const i=t(...e);return ut.set(i,!0),i},gt=t=>"function"==typeof t&&ut.has(t),ft={},bt={}; -/** - * @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 mt{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=Q?this.template.element.content.cloneNode(!0):document.importNode(this.template.element.content,!0),e=[],i=this.template.parts,o=document.createTreeWalker(t,133,null,!1);let r,s=0,n=0,a=o.nextNode();for(;st}),vt=` ${et} `;class yt{constructor(t,e,i,o){this.strings=t,this.values=e,this.type=i,this.processor=o}getHTML(){const t=this.strings.length-1;let e="",i=!1;for(let o=0;o-1||i)&&-1===t.indexOf("--\x3e",r+1);const s=ct.exec(t);e+=null===s?t+(i?vt:it):t.substr(0,s.index)+s[1]+s[2]+"$lit$"+s[3]+et}return e+=this.strings[t],e}getTemplateElement(){const t=document.createElement("template");let e=this.getHTML();return void 0!==_t&&(e=_t.createHTML(e)),t.innerHTML=e,t}} -/** - * @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 wt=t=>null===t||!("object"==typeof t||"function"==typeof t),St=t=>Array.isArray(t)||!(!t||!t[Symbol.iterator]);class kt{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 At=!0,!1}};window.addEventListener("test",t,t),window.removeEventListener("test",t,t)}catch(t){}})();class Mt{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(;gt(this.__pendingValue);){const t=this.__pendingValue;this.__pendingValue=ft,t(this)}if(this.__pendingValue===ft)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),o=null!=t&&(null==e||i);i&&this.element.removeEventListener(this.eventName,this.__boundHandleEvent,this.__options),o&&(this.__options=Et(t),this.element.addEventListener(this.eventName,this.__boundHandleEvent,this.__options)),this.value=t,this.__pendingValue=ft}handleEvent(t){"function"==typeof this.value?this.value.call(this.eventContext||this.element,t):this.value.handleEvent(t)}}const Et=t=>t&&(At?{capture:t.capture,passive:t.passive,once:t.once}:t.capture) -/** - * @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 - */;function $t(t){let e=Nt.get(t.type);void 0===e&&(e={stringsArray:new WeakMap,keyString:new Map},Nt.set(t.type,e));let i=e.stringsArray.get(t.strings);if(void 0!==i)return i;const o=t.strings.join(et);return i=e.keyString.get(o),void 0===i&&(i=new rt(t,t.getTemplateElement()),e.keyString.set(o,i)),e.stringsArray.set(t.strings,i),i}const Nt=new Map,jt=new WeakMap; -/** - * @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 It=new -/** - * @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{handleAttributeExpressions(t,e,i,o){const r=e[0];if("."===r){return new Ct(t,e.slice(1),i).parts}if("@"===r)return[new Mt(t,e.slice(1),o.eventContext)];if("?"===r)return[new Tt(t,e.slice(1),i)];return new kt(t,e,i).parts}handleTextExpression(t){return new Ot(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 - */"undefined"!=typeof window&&(window.litHtmlVersions||(window.litHtmlVersions=[])).push("1.4.1");const Rt=(t,...e)=>new yt(t,e,"html",It) -/** - * @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 - */,Vt=(t,e)=>`${t}--${e}`;let Ht=!0;void 0===window.ShadyCSS?Ht=!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."),Ht=!1);const zt=t=>e=>{const i=Vt(e.type,t);let o=Nt.get(i);void 0===o&&(o={stringsArray:new WeakMap,keyString:new Map},Nt.set(i,o));let r=o.stringsArray.get(e.strings);if(void 0!==r)return r;const s=e.strings.join(et);if(r=o.keyString.get(s),void 0===r){const i=e.getTemplateElement();Ht&&window.ShadyCSS.prepareTemplateDom(i,t),r=new rt(e,i),o.keyString.set(s,r)}return o.stringsArray.set(e.strings,r),r},Ut=["html","svg"],Lt=new Set,Ft=(t,e,i)=>{Lt.add(t);const o=i?i.element:document.createElement("template"),r=e.querySelectorAll("style"),{length:s}=r;if(0===s)return void window.ShadyCSS.prepareTemplateStyles(o,t);const n=document.createElement("style");for(let t=0;t{Ut.forEach(e=>{const i=Nt.get(Vt(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)}),lt(t,i)})})})(t);const a=o.content;i?function(t,e,i=null){const{element:{content:o},parts:r}=t;if(null==i)return void o.appendChild(e);const s=document.createTreeWalker(o,133,null,!1);let n=dt(r),a=0,c=-1;for(;s.nextNode();){c++;for(s.currentNode===i&&(a=ht(e),i.parentNode.insertBefore(e,i));-1!==n&&r[n].index===c;){if(a>0){for(;-1!==n;)r[n].index+=a,n=dt(r,n);return}n=dt(r,n)}}}(i,n,a.firstChild):a.insertBefore(n,a.firstChild),window.ShadyCSS.prepareTemplateStyles(o,t);const c=a.querySelector("style");if(window.ShadyCSS.nativeShadow&&null!==c)e.insertBefore(c.cloneNode(!0),e.firstChild);else if(i){a.insertBefore(n,a.firstChild);const t=new Set;t.add(n),lt(i,t)}};window.JSCompiler_renameProperty=(t,e)=>t;const Dt={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}},Bt=(t,e)=>e!==t&&(e==e||t==t),qt={attribute:!0,type:String,converter:Dt,reflect:!1,hasChanged:Bt};class Gt extends HTMLElement{constructor(){super(),this.initialize()}static get observedAttributes(){this.finalize();const t=[];return this._classProperties.forEach((e,i)=>{const o=this._attributeNameForProperty(i,e);void 0!==o&&(this._attributeToPropertyMap.set(o,i),t.push(o))}),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=qt){if(this._ensureClassProperties(),this._classProperties.set(t,e),e.noAccessor||this.prototype.hasOwnProperty(t))return;const i="symbol"==typeof t?Symbol():"__"+t,o=this.getPropertyDescriptor(t,i,e);void 0!==o&&Object.defineProperty(this.prototype,t,o)}static getPropertyDescriptor(t,e,i){return{get(){return this[e]},set(o){const r=this[t];this[e]=o,this.requestUpdateInternal(t,r,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this._classProperties&&this._classProperties.get(t)||qt}static finalize(){const t=Object.getPrototypeOf(this);if(t.hasOwnProperty("finalized")||t.finalize(),this.finalized=!0,this._ensureClassProperties(),this._attributeToPropertyMap=new Map,this.hasOwnProperty(JSCompiler_renameProperty("properties",this))){const t=this.properties,e=[...Object.getOwnPropertyNames(t),..."function"==typeof Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(t):[]];for(const i of e)this.createProperty(i,t[i])}}static _attributeNameForProperty(t,e){const i=e.attribute;return!1===i?void 0:"string"==typeof i?i:"string"==typeof t?t.toLowerCase():void 0}static _valueHasChanged(t,e,i=Bt){return i(t,e)}static _propertyValueFromAttribute(t,e){const i=e.type,o=e.converter||Dt,r="function"==typeof o?o:o.fromAttribute;return r?r(t,i):t}static _propertyValueToAttribute(t,e){if(void 0===e.reflect)return;const i=e.type,o=e.converter;return(o&&o.toAttribute||Dt.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=qt){const o=this.constructor,r=o._attributeNameForProperty(t,i);if(void 0!==r){const t=o._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,o=i._attributeToPropertyMap.get(t);if(void 0!==o){const t=i.getPropertyOptions(o);this._updateState=16|this._updateState,this[o]=i._propertyValueFromAttribute(e,t),this._updateState=-17&this._updateState}}requestUpdateInternal(t,e,i){let o=!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))):o=!1}!this._hasRequestedUpdate&&o&&(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){}}Gt.finalized=!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 - */ -const Yt=t=>e=>"function"==typeof e?((t,e)=>(window.customElements.define(t,e),e))(t,e):((t,e)=>{const{kind:i,elements:o}=e;return{kind:i,elements:o,finisher(e){window.customElements.define(t,e)}}})(t,e),Wt=(t,e)=>"method"===e.kind&&e.descriptor&&!("value"in e.descriptor)?Object.assign(Object.assign({},e),{finisher(i){i.createProperty(e.key,t)}}):{kind:"field",key:Symbol(),placement:"own",descriptor:{},initializer(){"function"==typeof e.initializer&&(this[e.key]=e.initializer.call(this))},finisher(i){i.createProperty(e.key,t)}};function Zt(t){return(e,i)=>void 0!==i?((t,e,i)=>{e.constructor.createProperty(i,t)})(t,e,i):Wt(t,e)}const Kt=t=>function(t){return Zt({attribute:!1,hasChanged:null==t?void 0:t.hasChanged})}(t);function Jt(t,e){return(i,o)=>{const r={get(){return this.renderRoot.querySelector(t)},enumerable:!0,configurable:!0};if(e){const e=void 0!==o?o:i.key,s="symbol"==typeof e?Symbol():"__"+e;r.get=function(){return void 0===this[s]&&(this[s]=this.renderRoot.querySelector(t)),this[s]}}return void 0!==o?Xt(r,i,o):Qt(r,i)}}const Xt=(t,e,i)=>{Object.defineProperty(e,i,t)},Qt=(t,e)=>({kind:"method",placement:"prototype",key:e.key,descriptor:t});function te(t){return(e,i)=>void 0!==i?((t,e,i)=>{Object.assign(e[i],t)})(t,e,i):((t,e)=>Object.assign(Object.assign({},e),{finisher(i){Object.assign(i.prototype[e.key],t)}}))(t,e)} -/** -@license -Copyright (c) 2019 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 ee=window.ShadowRoot&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,ie=Symbol();class oe{constructor(t,e){if(e!==ie)throw new Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t}get styleSheet(){return void 0===this._styleSheet&&(ee?(this._styleSheet=new CSSStyleSheet,this._styleSheet.replaceSync(this.cssText)):this._styleSheet=null),this._styleSheet}toString(){return this.cssText}}const re=(t,...e)=>{const i=e.reduce((e,i,o)=>e+(t=>{if(t instanceof oe)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[o+1],t[0]);return new oe(i,ie)}; -/** - * @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.litElementVersions||(window.litElementVersions=[])).push("2.5.1");const se={};class ne extends Gt{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),o=[];i.forEach(t=>o.unshift(t)),this._styles=o}else this._styles=void 0===t?[]:[t];this._styles=this._styles.map(t=>{if(t instanceof CSSStyleSheet&&!ee){const e=Array.prototype.slice.call(t.cssRules).reduce((t,e)=>t+e.cssText,"");return new oe(String(e),ie)}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?ee?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!==se&&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 se}}ne.finalized=!0,ne.render=(t,e,i)=>{if(!i||"object"!=typeof i||!i.scopeName)throw new Error("The `scopeName` option is required.");const o=i.scopeName,r=jt.has(e),s=Ht&&11===e.nodeType&&!!e.host,n=s&&!Lt.has(o),a=n?document.createDocumentFragment():e;if(((t,e,i)=>{let o=jt.get(e);void 0===o&&(tt(e,e.firstChild),jt.set(e,o=new Ot(Object.assign({templateFactory:$t},i))),o.appendInto(e)),o.setValue(t),o.commit()})(t,a,Object.assign({templateFactory:zt(o)},i)),n){const t=jt.get(a);jt.delete(a);const i=t.value instanceof mt?t.value.template:void 0;Ft(o,a,i),tt(e,e.firstChild),e.appendChild(a),jt.set(e,t)}!r&&s&&window.ShadyCSS.styleElement(e.host)},ne.shadowRootOptions={mode:"open"}; -/** - * @license - * Copyright (c) 2018 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 ae{constructor(t){this.classes=new Set,this.changed=!1,this.element=t;const e=(t.getAttribute("class")||"").split(/\s+/);for(const t of e)this.classes.add(t)}add(t){this.classes.add(t),this.changed=!0}remove(t){this.classes.delete(t),this.changed=!0}commit(){if(this.changed){let t="";this.classes.forEach(e=>t+=e+" "),this.element.setAttribute("class",t)}}}const ce=new WeakMap,le=pt(t=>e=>{if(!(e instanceof xt)||e instanceof Pt||"class"!==e.committer.name||e.committer.parts.length>1)throw new Error("The `classMap` directive must be used in the `class` attribute and must be the only part in the attribute.");const{committer:i}=e,{element:o}=i;let r=ce.get(e);void 0===r&&(o.setAttribute("class",i.strings.join(" ")),ce.set(e,r=new Set));const s=o.classList||new ae(o);r.forEach(e=>{e in t||(s.remove(e),r.delete(e))});for(const e in t){const i=t[e];i!=r.has(e)&&(i?(s.add(e),r.add(e)):(s.remove(e),r.delete(e)))}"function"==typeof s.commit&&s.commit()}),he=new WeakMap,de=pt(t=>e=>{const i=he.get(e);if(void 0===t&&e instanceof xt){if(void 0!==i||!he.has(e)){const t=e.committer.name;e.committer.element.removeAttribute(t)}}else t!==i&&e.setValue(t);he.set(e,t)}),ue=new WeakMap,pe=pt(t=>e=>{if(!(e instanceof xt)||e instanceof Pt||"style"!==e.committer.name||e.committer.parts.length>1)throw new Error("The `styleMap` directive must be used in the style attribute and must be the only part in the attribute.");const{committer:i}=e,{style:o}=i.element;let r=ue.get(e);void 0===r&&(o.cssText=i.strings.join(" "),ue.set(e,r=new Set)),r.forEach(e=>{e in t||(r.delete(e),-1===e.indexOf("-")?o[e]=null:o.removeProperty(e))});for(const e in t)r.add(e),-1===e.indexOf("-")?o[e]=t[e]:o.setProperty(e,t[e])}),ge="ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0;class fe extends HTMLElement{constructor(){super(),this.holdTime=500,this.held=!1,this.ripple=document.createElement("mwc-ripple")}connectedCallback(){Object.assign(this.style,{position:"absolute",width:ge?"100px":"50px",height:ge?"100px":"50px",transform:"translate(-50%, -50%)",pointerEvents:"none",zIndex:"999"}),this.appendChild(this.ripple),this.ripple.primary=!0,["touchcancel","mouseout","mouseup","touchmove","mousewheel","wheel","scroll"].forEach(t=>{document.addEventListener(t,()=>{clearTimeout(this.timer),this.stopAnimation(),this.timer=void 0},{passive:!0})})}bind(t,e){if(t.actionHandler)return;t.actionHandler=!0,t.addEventListener("contextmenu",t=>{const e=t||window.event;return e.preventDefault&&e.preventDefault(),e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0,e.returnValue=!1,!1});const i=t=>{let e,i;this.held=!1,t.touches?(e=t.touches[0].pageX,i=t.touches[0].pageY):(e=t.pageX,i=t.pageY),this.timer=window.setTimeout(()=>{this.startAnimation(e,i),this.held=!0},this.holdTime)},o=i=>{i.preventDefault(),["touchend","touchcancel"].includes(i.type)&&void 0===this.timer||(clearTimeout(this.timer),this.stopAnimation(),this.timer=void 0,this.held?O(t,"action",{action:"hold"}):e.hasDoubleClick?"click"===i.type&&i.detail<2||!this.dblClickTimeout?this.dblClickTimeout=window.setTimeout(()=>{this.dblClickTimeout=void 0,O(t,"action",{action:"tap"})},250):(clearTimeout(this.dblClickTimeout),this.dblClickTimeout=void 0,O(t,"action",{action:"double_tap"})):O(t,"action",{action:"tap"}))};t.addEventListener("touchstart",i,{passive:!0}),t.addEventListener("touchend",o),t.addEventListener("touchcancel",o),t.addEventListener("mousedown",i,{passive:!0}),t.addEventListener("click",o),t.addEventListener("keyup",t=>{13===t.keyCode&&o(t)})}startAnimation(t,e){Object.assign(this.style,{left:t+"px",top:e+"px",display:null}),this.ripple.disabled=!1,this.ripple.active=!0,this.ripple.unbounded=!0}stopAnimation(){this.ripple.active=!1,this.ripple.disabled=!0,this.style.display="none"}}customElements.define("action-handler-slider-button",fe);const be=(t,e)=>{const i=(()=>{const t=document.body;if(t.querySelector("action-handler-slider-button"))return t.querySelector("action-handler-slider-button");const e=document.createElement("action-handler-slider-button");return t.appendChild(e),e})();i&&i.bind(t,e)},me=pt((t={})=>e=>{be(e.committer.element,t)});var _e,ve,ye,we;!function(t){t.TOGGLE="toggle",t.CUSTOM="custom"}(_e||(_e={})),function(t){t.LEFT_RIGHT="left-right",t.TOP_BOTTOM="top-bottom",t.BOTTOM_TOP="bottom-top"}(ve||(ve={})),function(t){t.SOLID="solid",t.GRADIENT="gradient",t.TRIANGLE="triangle",t.STRIPED="striped",t.CUSTOM="custom"}(ye||(ye={})),function(t){t.LIGHT="light",t.SWITCH="switch",t.FAN="fan",t.COVER="cover",t.INPUT_BOOLEAN="input_boolean",t.MEDIA_PLAYER="media_player",t.CLIMATE="climate",t.LOCK="lock"}(we||(we={}));const Se={mode:_e.TOGGLE,icon:"mdi:power",show:!0,show_spinner:!0,tap_action:{action:"toggle"}},ke={show:!0,use_state_color:!0,tap_action:{action:"more-info"}},xe={direction:ve.LEFT_RIGHT,background:ye.SOLID,use_percentage_bg_opacity:!1,use_state_color:!1,show_track:!1,toggle_on_click:!1,force_square:!1},Oe=new Map([[we.LIGHT,{direction:ve.LEFT_RIGHT,background:ye.GRADIENT,use_state_color:!0,use_percentage_bg_opacity:!1,show_track:!1,toggle_on_click:!1,force_square:!1}],[we.FAN,{direction:ve.LEFT_RIGHT,background:ye.SOLID,use_state_color:!1,use_percentage_bg_opacity:!1,show_track:!1,toggle_on_click:!1,force_square:!1}],[we.SWITCH,{direction:ve.LEFT_RIGHT,background:ye.SOLID,use_state_color:!1,use_percentage_bg_opacity:!1,show_track:!1,toggle_on_click:!0,force_square:!1}],[we.COVER,{direction:ve.TOP_BOTTOM,background:ye.STRIPED,use_state_color:!1,use_percentage_bg_opacity:!1,toggle_on_click:!1,show_track:!1,force_square:!1,invert:!0}],[we.INPUT_BOOLEAN,{direction:ve.LEFT_RIGHT,background:ye.SOLID,use_state_color:!1,use_percentage_bg_opacity:!1,show_track:!1,toggle_on_click:!0,force_square:!1}],[we.MEDIA_PLAYER,{direction:ve.LEFT_RIGHT,background:ye.TRIANGLE,use_state_color:!1,use_percentage_bg_opacity:!1,show_track:!0,toggle_on_click:!1,force_square:!1}],[we.LOCK,{direction:ve.LEFT_RIGHT,background:ye.SOLID,use_state_color:!1,use_percentage_bg_opacity:!1,show_track:!1,toggle_on_click:!0,force_square:!1}],[we.CLIMATE,{direction:ve.LEFT_RIGHT,background:ye.TRIANGLE,use_state_color:!1,use_percentage_bg_opacity:!1,show_track:!0,toggle_on_click:!1,force_square:!1}]]);var Te,Ce,Pe;function Ae(t,e){(function(t){return"string"==typeof t&&-1!==t.indexOf(".")&&1===parseFloat(t)})(t)&&(t="100%");var i=function(t){return"string"==typeof t&&-1!==t.indexOf("%")}(t);return t=360===e?t:Math.min(e,Math.max(0,parseFloat(t))),i&&(t=parseInt(String(t*e),10)/100),Math.abs(t-e)<1e-6?1:t=360===e?(t<0?t%e+e:t%e)/parseFloat(String(e)):t%e/parseFloat(String(e))}function Me(t){return Math.min(1,Math.max(0,t))}function Ee(t){return t=parseFloat(t),(isNaN(t)||t<0||t>1)&&(t=1),t}function $e(t){return t<=1?100*Number(t)+"%":t}function Ne(t){return 1===t.length?"0"+t:String(t)}function je(t,e,i){t=Ae(t,255),e=Ae(e,255),i=Ae(i,255);var o=Math.max(t,e,i),r=Math.min(t,e,i),s=0,n=0,a=(o+r)/2;if(o===r)n=0,s=0;else{var c=o-r;switch(n=a>.5?c/(2-o-r):c/(o+r),o){case t:s=(e-i)/c+(e1&&(i-=1),i<1/6?t+6*i*(e-t):i<.5?e:i<2/3?t+(e-t)*(2/3-i)*6:t}function Re(t,e,i){t=Ae(t,255),e=Ae(e,255),i=Ae(i,255);var o=Math.max(t,e,i),r=Math.min(t,e,i),s=0,n=o,a=o-r,c=0===o?0:a/o;if(o===r)s=0;else{switch(o){case t:s=(e-i)/a+(e>16,g:(65280&t)>>8,b:255&t}}(e)),this.originalInput=e;var r=Le(e);this.originalInput=e,this.r=r.r,this.g=r.g,this.b=r.b,this.a=r.a,this.roundA=Math.round(100*this.a)/100,this.format=null!==(o=i.format)&&void 0!==o?o:r.format,this.gradientType=i.gradientType,this.r<1&&(this.r=Math.round(this.r)),this.g<1&&(this.g=Math.round(this.g)),this.b<1&&(this.b=Math.round(this.b)),this.isValid=r.ok}return t.prototype.isDark=function(){return this.getBrightness()<128},t.prototype.isLight=function(){return!this.isDark()},t.prototype.getBrightness=function(){var t=this.toRgb();return(299*t.r+587*t.g+114*t.b)/1e3},t.prototype.getLuminance=function(){var t=this.toRgb(),e=t.r/255,i=t.g/255,o=t.b/255;return.2126*(e<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4))+.7152*(i<=.03928?i/12.92:Math.pow((i+.055)/1.055,2.4))+.0722*(o<=.03928?o/12.92:Math.pow((o+.055)/1.055,2.4))},t.prototype.getAlpha=function(){return this.a},t.prototype.setAlpha=function(t){return this.a=Ee(t),this.roundA=Math.round(100*this.a)/100,this},t.prototype.toHsv=function(){var t=Re(this.r,this.g,this.b);return{h:360*t.h,s:t.s,v:t.v,a:this.a}},t.prototype.toHsvString=function(){var t=Re(this.r,this.g,this.b),e=Math.round(360*t.h),i=Math.round(100*t.s),o=Math.round(100*t.v);return 1===this.a?"hsv("+e+", "+i+"%, "+o+"%)":"hsva("+e+", "+i+"%, "+o+"%, "+this.roundA+")"},t.prototype.toHsl=function(){var t=je(this.r,this.g,this.b);return{h:360*t.h,s:t.s,l:t.l,a:this.a}},t.prototype.toHslString=function(){var t=je(this.r,this.g,this.b),e=Math.round(360*t.h),i=Math.round(100*t.s),o=Math.round(100*t.l);return 1===this.a?"hsl("+e+", "+i+"%, "+o+"%)":"hsla("+e+", "+i+"%, "+o+"%, "+this.roundA+")"},t.prototype.toHex=function(t){return void 0===t&&(t=!1),Ve(this.r,this.g,this.b,t)},t.prototype.toHexString=function(t){return void 0===t&&(t=!1),"#"+this.toHex(t)},t.prototype.toHex8=function(t){return void 0===t&&(t=!1),function(t,e,i,o,r){var s,n=[Ne(Math.round(t).toString(16)),Ne(Math.round(e).toString(16)),Ne(Math.round(i).toString(16)),Ne((s=o,Math.round(255*parseFloat(s)).toString(16)))];return r&&n[0].startsWith(n[0].charAt(1))&&n[1].startsWith(n[1].charAt(1))&&n[2].startsWith(n[2].charAt(1))&&n[3].startsWith(n[3].charAt(1))?n[0].charAt(0)+n[1].charAt(0)+n[2].charAt(0)+n[3].charAt(0):n.join("")}(this.r,this.g,this.b,this.a,t)},t.prototype.toHex8String=function(t){return void 0===t&&(t=!1),"#"+this.toHex8(t)},t.prototype.toRgb=function(){return{r:Math.round(this.r),g:Math.round(this.g),b:Math.round(this.b),a:this.a}},t.prototype.toRgbString=function(){var t=Math.round(this.r),e=Math.round(this.g),i=Math.round(this.b);return 1===this.a?"rgb("+t+", "+e+", "+i+")":"rgba("+t+", "+e+", "+i+", "+this.roundA+")"},t.prototype.toPercentageRgb=function(){var t=function(t){return Math.round(100*Ae(t,255))+"%"};return{r:t(this.r),g:t(this.g),b:t(this.b),a:this.a}},t.prototype.toPercentageRgbString=function(){var t=function(t){return Math.round(100*Ae(t,255))};return 1===this.a?"rgb("+t(this.r)+"%, "+t(this.g)+"%, "+t(this.b)+"%)":"rgba("+t(this.r)+"%, "+t(this.g)+"%, "+t(this.b)+"%, "+this.roundA+")"},t.prototype.toName=function(){if(0===this.a)return"transparent";if(this.a<1)return!1;for(var t="#"+Ve(this.r,this.g,this.b,!1),e=0,i=Object.entries(Ue);e=0;return e||!o||!t.startsWith("hex")&&"name"!==t?("rgb"===t&&(i=this.toRgbString()),"prgb"===t&&(i=this.toPercentageRgbString()),"hex"!==t&&"hex6"!==t||(i=this.toHexString()),"hex3"===t&&(i=this.toHexString(!0)),"hex4"===t&&(i=this.toHex8String(!0)),"hex8"===t&&(i=this.toHex8String()),"name"===t&&(i=this.toName()),"hsl"===t&&(i=this.toHslString()),"hsv"===t&&(i=this.toHsvString()),i||this.toHexString()):"name"===t&&0===this.a?this.toName():this.toRgbString()},t.prototype.toNumber=function(){return(Math.round(this.r)<<16)+(Math.round(this.g)<<8)+Math.round(this.b)},t.prototype.clone=function(){return new t(this.toString())},t.prototype.lighten=function(e){void 0===e&&(e=10);var i=this.toHsl();return i.l+=e/100,i.l=Me(i.l),new t(i)},t.prototype.brighten=function(e){void 0===e&&(e=10);var i=this.toRgb();return i.r=Math.max(0,Math.min(255,i.r-Math.round(-e/100*255))),i.g=Math.max(0,Math.min(255,i.g-Math.round(-e/100*255))),i.b=Math.max(0,Math.min(255,i.b-Math.round(-e/100*255))),new t(i)},t.prototype.darken=function(e){void 0===e&&(e=10);var i=this.toHsl();return i.l-=e/100,i.l=Me(i.l),new t(i)},t.prototype.tint=function(t){return void 0===t&&(t=10),this.mix("white",t)},t.prototype.shade=function(t){return void 0===t&&(t=10),this.mix("black",t)},t.prototype.desaturate=function(e){void 0===e&&(e=10);var i=this.toHsl();return i.s-=e/100,i.s=Me(i.s),new t(i)},t.prototype.saturate=function(e){void 0===e&&(e=10);var i=this.toHsl();return i.s+=e/100,i.s=Me(i.s),new t(i)},t.prototype.greyscale=function(){return this.desaturate(100)},t.prototype.spin=function(e){var i=this.toHsl(),o=(i.h+e)%360;return i.h=o<0?360+o:o,new t(i)},t.prototype.mix=function(e,i){void 0===i&&(i=50);var o=this.toRgb(),r=new t(e).toRgb(),s=i/100;return new t({r:(r.r-o.r)*s+o.r,g:(r.g-o.g)*s+o.g,b:(r.b-o.b)*s+o.b,a:(r.a-o.a)*s+o.a})},t.prototype.analogous=function(e,i){void 0===e&&(e=6),void 0===i&&(i=30);var o=this.toHsl(),r=360/i,s=[this];for(o.h=(o.h-(r*e>>1)+720)%360;--e;)o.h=(o.h+r)%360,s.push(new t(o));return s},t.prototype.complement=function(){var e=this.toHsl();return e.h=(e.h+180)%360,new t(e)},t.prototype.monochromatic=function(e){void 0===e&&(e=6);for(var i=this.toHsv(),o=i.h,r=i.s,s=i.v,n=[],a=1/e;e--;)n.push(new t({h:o,s:r,v:s})),s=(s+a)%1;return n},t.prototype.splitcomplement=function(){var e=this.toHsl(),i=e.h;return[this,new t({h:(i+72)%360,s:e.s,l:e.l}),new t({h:(i+216)%360,s:e.s,l:e.l})]},t.prototype.onBackground=function(e){var i=this.toRgb(),o=new t(e).toRgb();return new t({r:o.r+(i.r-o.r)*i.a,g:o.g+(i.g-o.g)*i.a,b:o.b+(i.b-o.b)*i.a})},t.prototype.triad=function(){return this.polyad(3)},t.prototype.tetrad=function(){return this.polyad(4)},t.prototype.polyad=function(e){for(var i=this.toHsl(),o=i.h,r=[this],s=360/e,n=1;nt[e]).filter(t=>"string"==typeof t)}const Ke=(t,e,i)=>{if(1!==e.length)return t[e[0]]||(t[e[0]]={}),Ke(t[e[0]],e.slice(1),i);t[e[0]]=i};function Je(t){const e=w(t)||we.LIGHT;return X(Oe.get(e)||xe)}function Xe(t,e,i){const o=new Ye("rgb(255, 160, 0)"),r=new Ye("rgb(166, 209, 255)"),s=new Ye("white"),n=(t-e)/(i-e)*100;return n<50?We(r).mix(s,2*n).toRgbString():We(s).mix(o,2*(n-50)).toRgbString()}function Qe(t,e,i){return(t-e)/i*100}function ti(t,e,i){return Math.floor(t*(i-e)/100+e)}class ei{constructor(t){this._sliderPrevColor="",this._config=t}set hass(t){this._hass=t}get stateObj(){return this._hass.states[this._config.entity]}get domain(){return S(this.stateObj)}get name(){var t,e;return this._config.name?this._config.name:(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:""}get icon(){var t,e,i;return"string"==typeof(null===(t=this._config.icon)||void 0===t?void 0:t.icon)&&(null===(e=this._config.icon)||void 0===e?void 0:e.icon.length)?this._config.icon.icon:(null===(i=this.stateObj.attributes)||void 0===i?void 0:i.icon)?this.stateObj.attributes.icon:C(this.domain,this.stateObj.state)}get value(){return this._value?Math.round(this._value/this.step)*this.step:this.min}set value(t){t!==this.value&&(this._value=t)}get targetValue(){return 0===this._targetValue?0:this._targetValue?Math.round(this._targetValue/this.step)*this.step:this.value?this.value:0}set targetValue(t){t!==this.targetValue&&(this._targetValue=t)}get label(){return""+this.targetValue}get hidden(){return!1}get hasSlider(){return!0}get hasToggle(){var t,e;return null!==(e=null===(t=this._config.slider)||void 0===t?void 0:t.toggle_on_click)&&void 0!==e&&e}get toggleValue(){return this.value===this.min?this.max:this.min}get state(){var t;return null===(t=this.stateObj)||void 0===t?void 0:t.state}get isOff(){return 0===this.percentage}get isUnavailable(){return!this.state||"unavailable"===this.state}get isSliderDisabled(){return this.isUnavailable?this.isUnavailable:this.hasToggle}get min(){var t,e,i;return null!==(i=null!==(e=null===(t=this._config.slider)||void 0===t?void 0:t.min)&&void 0!==e?e:this._min)&&void 0!==i?i:0}get max(){var t,e,i;return null!==(i=null!==(e=null===(t=this._config.slider)||void 0===t?void 0:t.max)&&void 0!==e?e:this._max)&&void 0!==i?i:100}get step(){var t,e,i;return null!==(i=null!==(e=null===(t=this._config.slider)||void 0===t?void 0:t.step)&&void 0!==e?e:this._step)&&void 0!==i?i:5}get invert(){var t,e,i;return null!==(i=null!==(e=null===(t=this._config.slider)||void 0===t?void 0:t.invert)&&void 0!==e?e:this._invert)&&void 0!==i&&i}get isValuePercentage(){return!0}get percentage(){return Math.round(100*(this.targetValue-(this.invert?this.max:this.min))/(this.max-this.min)*(this.invert?-1:1))}get valueFromPercentage(){return ti(this.percentage,this.min,this.max)}get allowedAttributes(){return[]}get style(){return{icon:{filter:this.iconFilter,color:this.iconColor,rotateSpeed:this.iconRotateSpeed},slider:{filter:this.sliderFilter,color:this.sliderColor}}}get iconFilter(){var t;return(null===(t=this._config.icon)||void 0===t?void 0:t.use_state_color)&&0!==this.percentage?`brightness(${(this.percentage+100)/2}%)`:"brightness(100%)"}get iconColor(){var t;if(null===(t=this._config.icon)||void 0===t?void 0:t.use_state_color){if(!this.stateObj.attributes.hs_color)return this.percentage>0?"var(--paper-item-icon-active-color, #fdd835)":"var(--paper-item-icon-color, #44739e)";{const[t,e]=this.stateObj.attributes.hs_color;if(e>10)return`hsl(${t}, 100%, ${100-e/2}%)`}}return""}get iconRotateSpeed(){return"0s"}get sliderFilter(){var t;return(null===(t=this._config.slider)||void 0===t?void 0:t.use_percentage_bg_opacity)&&0!==this.percentage&&this._config.slider.background!==ye.GRADIENT?`brightness(${(this.percentage+100)/2}%)`:"brightness(100%)"}get sliderColor(){var t;if(null===(t=this._config.slider)||void 0===t?void 0:t.use_state_color)if(this.stateObj.attributes.hs_color){const[t,e]=this.stateObj.attributes.hs_color;if(e>10){const i=`hsl(${t}, 100%, ${100-e/2}%)`;return this._sliderPrevColor=i,i}}else{if(this.stateObj.attributes.color_temp&&this.stateObj.attributes.min_mireds&&this.stateObj.attributes.max_mireds){const t=Xe(this.stateObj.attributes.color_temp,this.stateObj.attributes.min_mireds,this.stateObj.attributes.max_mireds);return this._sliderPrevColor=t,t}if(this._sliderPrevColor.startsWith("hsl")||this._sliderPrevColor.startsWith("rgb"))return this._sliderPrevColor}return"inherit"}moveSlider(t,{left:e,top:i,width:o,height:r}){let s=this.calcMovementPercentage(t,{left:e,top:i,width:o,height:r});var n,a,c;return s=this.applyStep(s),n=s,a=0,c=100,s=isNaN(n)||isNaN(a)||isNaN(c)?0:n>c?c:n0?"open_cover":"close_cover";this._hass.callService("cover",e,{entity_id:this.stateObj.entity_id})}}get _step(){return 1}get label(){const t=this._hass.localize("component.cover.state._."+this.state),e=this._hass.localize("component.cover.state._.closed"),i=this._hass.localize("component.cover.state._.open");if(!this.hasSlider)return t;switch(this.attribute){case Pe.POSITION:return 0===this.percentage?this.invert?i:e:100===this.percentage?this.invert?e:i:this.percentage+"%";case Pe.TILT:return""+this.percentage}return t}get hasSlider(){switch(this.attribute){case Pe.POSITION:if("current_position"in this.stateObj.attributes)return!0;if("supported_features"in this.stateObj.attributes&&4&this.stateObj.attributes.supported_features)return!0;break;case Pe.TILT:if("current_tilt_position"in this.stateObj.attributes)return!0;if("supported_features"in this.stateObj.attributes&&128&this.stateObj.attributes.supported_features)return!0;break;default:return!1}return!1}get _max(){return this.hasSlider?100:1}}class ri extends ei{constructor(){super(...arguments),this._min=0,this._invert=!1}get _value(){return this.isUnavailable||x.includes(this.state)?0:this.hasSlider?this.stateObj.attributes.percentage:1}set _value(t){const e=t>0?"turn_on":"turn_off";t>0&&this.hasSlider?this._hass.callService("fan","set_percentage",{entity_id:this.stateObj.entity_id,percentage:t}):this._hass.callService("fan",e,{entity_id:this.stateObj.entity_id})}get _step(){return this.stateObj.attributes.percentage_step}get label(){return this.percentage>0?this.hasSlider?this.percentage+"%":this._hass.localize("component.fan.state._.on"):this._hass.localize("component.fan.state._.off")}get hasSlider(){return"speed"in this.stateObj.attributes}get _max(){return this.hasSlider?100:1}get iconRotateSpeed(){let t=0;return this.percentage>0&&(t=3-this.percentage/100*2),t+"s"}}class si extends ei{constructor(){super(...arguments),this._min=0,this._max=1,this._invert=!1}get _value(){return x.includes(this.stateObj.state)?0:1}set _value(t){const e=t>0?"turn_on":"turn_off";this._hass.callService("input_boolean",e,{entity_id:this.stateObj.entity_id})}get _step(){return 1}get label(){return this.percentage>0?this._hass.localize("component.input_boolean.state._.on"):this._hass.localize("component.input_boolean.state._.off")}}const ni={hue:0,saturation:1};class ai extends ei{constructor(){super(...arguments),this._step=1,this._invert=!1}get attribute(){var t,e,i,o,r;const s=null===(t=this._config.slider)||void 0===t?void 0:t.attribute;let n=Te.BRIGHTNESS_PCT,a=[];if(Array.isArray(null===(i=null===(e=this.stateObj)||void 0===e?void 0:e.attributes)||void 0===i?void 0:i.supported_color_modes)&&(a=null===(r=null===(o=this.stateObj)||void 0===o?void 0:o.attributes)||void 0===r?void 0:r.supported_color_modes),1===a.length&&a[0]===Te.ON_OFF&&(n=Te.ON_OFF),(null==s?void 0:s.length)&&this.allowedAttributes.includes(s))switch(n=s,s){case Te.COLOR_TEMP:a.includes("color_temp")||(n=Te.BRIGHTNESS_PCT);break;case Te.HUE:case Te.SATURATION:a.includes("hs")||(n=Te.BRIGHTNESS_PCT)}return n}get allowedAttributes(){return Ze(Te)}get colorMode(){var t,e;return null===(e=null===(t=this.stateObj)||void 0===t?void 0:t.attributes)||void 0===e?void 0:e.color_mode}get _value(){if(!this.stateObj||x.includes(this.state))return this.isValuePercentage?0:this.min;const t=this.stateObj.attributes;switch(this.attribute){case Te.COLOR_TEMP:return t.color_temp?Math.round(t.color_temp):this.min;case Te.BRIGHTNESS:return Math.round(t.brightness);case Te.BRIGHTNESS_PCT:return Math.round(100*t.brightness/255);case Te.ON_OFF:return 1;case Te.HUE:case Te.SATURATION:return t.hs_color?Math.round(t.hs_color[ni[this.attribute]]):0;default:return 0}}set _value(t){if(!this.stateObj)return;let e,i=this.attribute,o=t>0?"turn_on":"turn_off",r={entity_id:this.stateObj.entity_id};switch(i){case Te.BRIGHTNESS:case Te.BRIGHTNESS_PCT:(t=i===Te.BRIGHTNESS?Math.round(t):Math.round(t/100*255))?(i="brightness",r=Object.assign(Object.assign({},r),{[i]:t})):o="turn_off";break;case Te.HUE:case Te.SATURATION:e=this.stateObj.attributes.hs_color||[0,0],e[ni[i]]=t,t=e,i="hs_color",o="turn_on",r=Object.assign(Object.assign({},r),{[i]:t});break;case Te.COLOR_TEMP:i="color_temp",o="turn_on",r=Object.assign(Object.assign({},r),{[i]:t})}this._hass.callService("light",o,Object.assign({},r))}get _min(){var t;switch(this.attribute){case Te.COLOR_TEMP:return this.stateObj&&(null===(t=this.stateObj.attributes)||void 0===t?void 0:t.min_mireds)?this.stateObj.attributes.min_mireds:153;default:return 0}}get _max(){var t;switch(this.attribute){case Te.COLOR_TEMP:return this.stateObj&&(null===(t=this.stateObj.attributes)||void 0===t?void 0:t.max_mireds)?this.stateObj.attributes.max_mireds:500;case Te.BRIGHTNESS:return 255;case Te.HUE:return 360;case Te.ON_OFF:return 1;default:return 100}}get isValuePercentage(){switch(this.attribute){case Te.COLOR_TEMP:case Te.HUE:case Te.BRIGHTNESS:return!1;default:return!0}}get isOff(){switch(this.attribute){case Te.COLOR_TEMP:case Te.HUE:case Te.SATURATION:case Te.BRIGHTNESS:case Te.ON_OFF:return x.includes(this.state);default:return this.colorMode===Ce.ON_OFF?x.includes(this.state):0===this.percentage}}get label(){if(this.isOff)return this._hass.localize("component.light.state._.off");if(this.colorMode===Ce.ON_OFF)return this._hass.localize("component.light.state._.on");switch(this.attribute){case Te.ON_OFF:return this._hass.localize("component.light.state._.on");case Te.COLOR_TEMP:case Te.BRIGHTNESS:return""+this.targetValue;case Te.BRIGHTNESS_PCT:case Te.SATURATION:return this.targetValue+"%";case Te.HUE:return this.targetValue+"°";default:return""+this.targetValue}}get hasToggle(){var t,e,i,o,r,s;let n=[];return Array.isArray(null===(e=null===(t=this.stateObj)||void 0===t?void 0:t.attributes)||void 0===e?void 0:e.supported_color_modes)&&(n=null===(o=null===(i=this.stateObj)||void 0===i?void 0:i.attributes)||void 0===o?void 0:o.supported_color_modes),1===n.length&&n[0]===Te.ON_OFF||null!==(s=null===(r=this._config.slider)||void 0===r?void 0:r.toggle_on_click)&&void 0!==s&&s}get hasSlider(){var t,e;if(!this.stateObj)return!1;switch(this.attribute){case Te.ON_OFF:return!1;case Te.BRIGHTNESS:case Te.BRIGHTNESS_PCT:return"brightness"in this.stateObj.attributes||!!("supported_features"in this.stateObj.attributes&&1&(null===(e=null===(t=this.stateObj)||void 0===t?void 0:t.attributes)||void 0===e?void 0:e.supported_features));case Te.COLOR_TEMP:return"color_temp"in this.stateObj.attributes||!!("supported_features"in this.stateObj.attributes&&2&this.stateObj.attributes.supported_features);case Te.HUE:case Te.SATURATION:return"hs_color"in this.stateObj.attributes||!!("supported_features"in this.stateObj.attributes&&16&this.stateObj.attributes.supported_features);default:return!1}}get sliderColor(){var t;let e="inherit";if(null===(t=this._config.slider)||void 0===t?void 0:t.use_state_color)if(this.stateObj.attributes.hs_color&&this.attribute!==Te.COLOR_TEMP){const[t,i]=this.stateObj.attributes.hs_color;let o=t,r=i;switch(this.attribute){case Te.HUE:o=this.valueFromPercentage;break;case Te.SATURATION:r=this.percentage}r>10&&(e=`hsl(${o}, 100%, ${100-r/2}%)`,this._sliderPrevColor=e)}else if(this.attribute===Te.HUE||this.attribute===Te.SATURATION){let t=0,i=20;switch(this.attribute){case Te.HUE:t=this.valueFromPercentage;break;case Te.SATURATION:i=this.percentage}i>10&&(e=`hsl(${t}, 100%, ${100-i/2}%)`,this._sliderPrevColor=e)}else this.stateObj.attributes.color_temp&&this.stateObj.attributes.min_mireds&&this.stateObj.attributes.max_mireds?(e=Xe(this.attribute===Te.COLOR_TEMP?this.valueFromPercentage:this.stateObj.attributes.color_temp,this.stateObj.attributes.min_mireds,this.stateObj.attributes.max_mireds),this._sliderPrevColor=e):this.attribute===Te.COLOR_TEMP?(e=Xe(this.valueFromPercentage,153,500),this._sliderPrevColor=e):(this._sliderPrevColor.startsWith("hsl")||this._sliderPrevColor.startsWith("rgb"))&&(e=this._sliderPrevColor);return e}}class ci extends ei{constructor(){super(...arguments),this._min=0,this._max=1,this._invert=!1}get _value(){return x.includes(this.stateObj.state)?0:1}set _value(t){const e=t>0?"lock":"unlock";this._hass.callService("lock",e,{entity_id:this.stateObj.entity_id})}get _step(){return 1}get label(){return this.percentage>0?this._hass.localize("component.lock.state._.unlocked"):this._hass.localize("component.lock.state._.locked")}}class li extends ei{constructor(){super(...arguments),this._min=0,this._max=100,this._step=1,this._invert=!1}get _value(){var t,e;return this.isUnavailable||(null===(e=null===(t=this.stateObj)||void 0===t?void 0:t.attributes)||void 0===e?void 0:e.is_volume_muted)?0:Math.floor(100*parseFloat(Number.parseFloat(this.stateObj.attributes.volume_level).toPrecision(2)))}set _value(t){t/=100,this._hass.callService("media_player","volume_set",{entity_id:this.stateObj.entity_id,volume_level:t}),t&&this._hass.callService("media_player","volume_mute",{entity_id:this.stateObj.entity_id,is_volume_muted:!1})}get isOff(){return"off"===this.stateObj.state}get label(){return this.stateObj.attributes.is_volume_muted?"-":this.stateObj.attributes.volume_level?this.percentage+"%":this._hass.localize("component.media_player.state._."+this.state)}}class hi extends ei{constructor(){super(...arguments),this._min=0,this._max=1,this._invert=!1}get _value(){return x.includes(this.stateObj.state)?0:1}set _value(t){const e=t>0?"turn_on":"turn_off";this._hass.callService("switch",e,{entity_id:this.stateObj.entity_id})}get _step(){return 1}get label(){return this.percentage>0?this._hass.localize("component.switch.state._.on"):this._hass.localize("component.switch.state._.off")}}var di={version:"v",invalid_configuration:"Invalid configuration",show_warning:"Show Warning",show_error:"Show Error"},ui={general:{title:"General",entity:"Entity (Required)",name:"Name (Optional)",show_name:"Show name?",show_state:"Show state?",compact:"Compact?"},icon:{title:"Icon",icon:"Icon (Optional)",show_icon:"Show icon?",use_state_color:"Use state color?",tap_action:"Tap action"},slider:{title:"Slider",direction:"Direction",background:"Background",use_brightness:"Use brightness?",show_track:"Show track?",toggle_on_click:"Act as a toggle (disable sliding)",force_square:"Force square?"},action_button:{title:"Action button",mode:"Mode",icon:"Icon",show_button:"Show button?",show_spinner:"Show spinner?",tap_action:"Tap action"}},pi={off:"Off",on:"On"},gi={"left-right":"Left to right","top-bottom":"Top to bottom","bottom-top":"Bottom to top"},fi={striped:"Striped",gradient:"Gradient",solid:"Solid",triangle:"Triangle",custom:"Custom"},bi={toggle:"Toggle",custom:"Custom"},mi={common:di,tabs:ui,state:pi,direction:gi,background:fi,mode:bi},_i={version:"v",invalid_configuration:"Ungültige Konfiguration",show_warning:"Zeige Warnung",show_error:"Zeige Fehler"},vi={general:{title:"Allgemein",entity:"Entiät (vorgeschrieben)",name:"Name (optional)",show_name:"Namen zeigen?",show_state:"Zustand zeigen?",compact:"Kompakt?"},icon:{title:"Icon",icon:"Icon (optional)",show_icon:"Icon zeigen?",use_state_color:"Zustandsfarbe verwenden?",tap_action:"Tap action"},slider:{title:"Schieberegler",direction:"Richtung",background:"Hintergrund",use_brightness:"Helligkeit benutzen?",show_track:"Spur anzeigen?",toggle_on_click:"Als Schalter benutzen (schieben deaktivieren)",force_square:"Quadrat erzwingen?"},action_button:{title:"Action-Knopf",mode:"Modus",icon:"Icon",show_button:"Knopf zeigen?",show_spinner:"Spinner anzeigen?",tap_action:"Tap action"}},yi={off:"Aus",on:"An"},wi={"left-right":"Links nach Rechts","top-bottom":"Oben nach Unten","bottom-top":"Unten nach Oben"},Si={striped:"gestreift",gradient:"Farbverlauf",solid:"Einfarbig",triangle:"Dreieck",custom:"benuzerdefiniert"},ki={toggle:"Umschalter",custom:"benuzerdefiniert"},xi={common:_i,tabs:vi,state:yi,direction:wi,background:Si,mode:ki},Oi={version:"v",invalid_configuration:"Configuration incorrecte",show_warning:"Afficher les avertissement",show_error:"Afficher les erreurs"},Ti={general:{title:"Général",entity:"Entité (Obligatoire)",name:"Nom (Optionnel)",show_name:"Afficher le nom ?",show_state:"Afficher l'état ?",compact:"Compact ?"},icon:{title:"Icône",icon:"Icône (Optionnel)",show_icon:"Afficher l'icône ?",use_state_color:"Afficher la couleur d'état?",tap_action:"Action"},slider:{title:"Curseur",direction:"Direction",background:"Fond",use_brightness:"Utiliser la luminosité ?",show_track:"Afficher le chemin ?",toggle_on_click:"Agir comme un bouton (désactive le curseur)",force_square:"Forcer carré ?"},action_button:{title:"Bouton d'action",mode:"Mode",icon:"Icône",show_button:"Afficher le bouton ?",show_spinner:"Afficher spinner ?",tap_action:"Action"}},Ci={off:"Inactif",on:"Actif"},Pi={"left-right":"gauche à droite","top-bottom":"haut à bas","bottom-top":"Bas à haut"},Ai={striped:"Rayures",gradient:"Dégradé",solid:"Uni",triangle:"Triangle",custom:"Personnalisé"},Mi={toggle:"Bascule",custom:"Personnalisé"},Ei={common:Oi,tabs:Ti,state:Ci,direction:Pi,background:Ai,mode:Mi},$i={version:"v",invalid_configuration:"תצורה לא חוקית",show_warning:"הצג אזהרה",show_error:"הצג שגיאה"},Ni={general:{title:"כללי",entity:"ישיות (נדרש)",name:"שם (אופציונלי)",show_name:"להציג שם?",show_state:"להציג מצב?",compact:"קוֹמפָּקטִי?"},icon:{title:"סמליל",icon:"סמליל (אופציונלי)",show_icon:"להציג סמליל?",use_state_color:"להשתמש בצבע מצב?",tap_action:"פעולה בהקשה"},slider:{title:"גלילה",direction:"כיוון",background:"רקע",use_brightness:"להשתמש בבהירות?",show_track:"להציג מסלול?",toggle_on_click:"פעל כמתג (השבת החלקה)",force_square:"כוח מרובע?"},action_button:{title:"כפתור פעולה",mode:"מצב",icon:"סמליל",show_button:"להציג כפתור?",show_spinner:"להציג ספינר?",tap_action:"פעולה בהקשה"}},ji={off:"כבוי",on:"פועל"},Ii={"left-right":"שמאל לימין","top-bottom":"מלמעלה למטה","bottom-top":"מלמטה למעלה"},Ri={striped:"מפוספס",gradient:"שיפוע",solid:"מוצק",triangle:"משולש",custom:"מותאם אישית"},Vi={toggle:"החלפה",custom:"מותאם אישית"},Hi={common:$i,tabs:Ni,state:ji,direction:Ii,background:Ri,mode:Vi},zi={version:"v",invalid_configuration:"Ongeldige configuratie",show_warning:"Toon waarschuwing",show_error:"Toon fout"},Ui={general:{title:"Algemeen",entity:"Entiteit (Verplicht)",name:"Naam (Optioneel)",show_name:"Toon naam?",show_state:"Toon status?",compact:"Compact?"},icon:{title:"Icoon",icon:"Icoon (Optioneel)",show_icon:"Toon icoon?",use_state_color:"Gebruik status kleur?",tap_action:"Tap actie"},slider:{title:"Schuifregelaar",direction:"Richting",background:"Actergrond",use_brightness:"Gebruik helderheid?",show_track:"Toon spoor?",toggle_on_click:"Fungeren als een schakelaar (schuiven uitschakelen)",force_square:"Forceer vierkant?"},action_button:{title:"Actie button",mode:"Modus",icon:"Icoon",show_button:"Toon button?",show_spinner:"Toon spinner?",tap_action:"Tap actie"}},Li={off:"Uit",on:"Aan"},Fi={"left-right":"Links naar rechts","top-bottom":"Boven naar onder","bottom-top":"Onder naar boven"},Di={striped:"Gestreept",gradient:"Verloop",solid:"Vast",triangle:"Driehoek",custom:"Aangepast"},Bi={toggle:"Schakelaar",custom:"Aangepast"},qi={common:zi,tabs:Ui,state:Li,direction:Fi,background:Di,mode:Bi},Gi={version:"v",invalid_configuration:"Nieprawidłowa konfiguracja",show_warning:"Pokaż ostrzeżenia",show_error:"Pokaż błędy"},Yi={general:{title:"Ogólne",entity:"Encja (Wymagana)",name:"Nazwa (Opcjonalna)",show_name:"Pokazać nazwę?",show_state:"Pokazać stan?",compact:"Kompaktowy?"},icon:{title:"Ikona",icon:"Ikona (Opcjonalna)",show_icon:"Pokazać ikonę?",use_state_color:"Uzyć kolor stanu?",tap_action:"Akcja kliknięcia"},slider:{title:"Suwak",direction:"Kierunek",background:"Tło",use_brightness:"Użyć jasności?",show_track:"Pokazać ślad?",toggle_on_click:"Działaj jako przełącznik (wyłącz przesuwanie)",force_square:"Wymusić kwadrat?"},action_button:{title:"Przycisk akcji",mode:"Tryb",icon:"Ikona",show_button:"Pokazać przycisk?",show_spinner:"Pokazać spinner?",tap_action:"Akcja kliknięcia"}},Wi={off:"Wyłączony",on:"Włączony"},Zi={"left-right":"Z lewej do prawej","top-bottom":"Z góry na dół","bottom-top":"Z dołu do góry"},Ki={striped:"W paski",gradient:"Gradient",solid:"Pełne tło",triangle:"Trójkąt",custom:"Ustawienia własne"},Ji={toggle:"Przełącznik",custom:"Ustawienia własne"},Xi={common:Gi,tabs:Yi,state:Wi,direction:Zi,background:Ki,mode:Ji},Qi={version:"v",invalid_configuration:"Configuração Inválida",show_warning:"Mostrar Aviso",show_error:"Mostrar Erro"},to={general:{title:"Geral",entity:"Entidade (Obrigatório)",name:"Nome (Opcional)",show_name:"Mostrar Nome?",show_state:"Mostrar Estado?",compact:"Compactar?"},icon:{title:"Ícone",icon:"Ícone (Opcional)",show_icon:"Mostrar Ícone?",use_state_color:"Usar Cor de Estado?",tap_action:"Ação de Toque"},slider:{title:"Slider",direction:"Direção",background:"Fundo",use_brightness:"Usar Brilho?",show_track:"Mostrar Acompanhamento?",toggle_on_click:"Atua como um alternador (desative o deslizamento)",force_square:"Forçar Quadrado?"},action_button:{title:"Botão de Ação",mode:"Modo",icon:"Ícone",show_button:"Mostrar Botão?",show_spinner:"Mostrar Spinner?",tap_action:"Ação de Toque"}},eo={off:"Desligar",on:"Ligar"},io={"left-right":"Esquerda para a Direita","top-bottom":"De Cima para Baixo","bottom-top":"De Baixo para Cima"},oo={striped:"Listrado",gradient:"Gradiente",solid:"Sólido",triangle:"Triângulo",custom:"Personalizado"},ro={toggle:"Alternancia",custom:"Personalizado"},so={common:Qi,tabs:to,state:eo,direction:io,background:oo,mode:ro},no={version:"v",invalid_configuration:"Неверная конфигурация",show_warning:"Показать предупреждения",show_error:"Показать ошибки"},ao={general:{title:"Общие",entity:"Объект (обязательно)",name:"Имя (Опционально)",show_name:"Отображать имя?",show_state:"Отображать статус?",compact:"Компактный?"},icon:{title:"Иконка",icon:"Иконка (Опционально)",show_icon:"Показать иконку?",use_state_color:"Использовать цвет статуса?",tap_action:"Действие по нажатию"},slider:{title:"Слайдер",direction:"Направление",background:"Фон",use_brightness:"Использовать яркость?",show_track:"Показать трек?",toggle_on_click:"Действовать как переключатель (отключить скольжение)",force_square:"Отображать квадратным?"},action_button:{title:"Кнопка действия",mode:"Режим",icon:"Иконка",show_button:"Отобразить кнопку?",show_spinner:"Отобразить спиннер?",tap_action:"Действие по нажатию"}},co={off:"Выкл",on:"Вкл"},lo={"left-right":"Слева направо","top-bottom":"Сверху вниз","bottom-top":"Снизу вверх"},ho={striped:"Полосатый",gradient:"Градиент",solid:"Сплошной цвет",triangle:"Треугольник",custom:"Свои настройки"},uo={toggle:"Переключатель",custom:"Свои настройки"},po={common:no,tabs:ao,state:co,direction:lo,background:ho,mode:uo},go={version:"v",invalid_configuration:"유효하지 않은 설정입니다",show_warning:"경고 표시",show_error:"에러 표시"},fo={general:{title:"일반",entity:"구성 요소 (필수)",name:"이름 (옵션)",show_name:"이름 표시",show_state:"상태 표시",compact:"슬림 모드"},icon:{title:"아이콘",icon:"아이콘 (옵션)",show_icon:"아이콘 표시",use_state_color:"상태 색상 사용",tap_action:"탭 액션"},slider:{title:"슬라이더",direction:"방향 지정",background:"배경",use_brightness:"밝기 사용",show_track:"범위 표시",toggle_on_click:"토글 버튼으로 동작(슬라이더 비활성화)",force_square:"정사각형 모양으로 고정"},action_button:{title:"액션 버튼",mode:"모드",icon:"아이콘",show_button:"버튼 표시",show_spinner:"로딩 스피너 표시",tap_action:"탭 액셥"}},bo={off:"꺼짐",on:"켜짐"},mo={"left-right":"왼쪽에서 오른쪽","top-bottom":"위에서 아래","bottom-top":"아래에서 위"},_o={striped:"줄무늬",gradient:"그레디언트",solid:"단색",triangle:"삼각형",custom:"커스텀"},vo={toggle:"토글 모드",custom:"커스텀 모드"},yo={common:go,tabs:fo,state:bo,direction:mo,background:_o,mode:vo};const wo={en:Object.freeze({__proto__:null,common:di,tabs:ui,state:pi,direction:gi,background:fi,mode:bi,default:mi}),de:Object.freeze({__proto__:null,common:_i,tabs:vi,state:yi,direction:wi,background:Si,mode:ki,default:xi}),fr:Object.freeze({__proto__:null,common:Oi,tabs:Ti,state:Ci,direction:Pi,background:Ai,mode:Mi,default:Ei}),he:Object.freeze({__proto__:null,common:$i,tabs:Ni,state:ji,direction:Ii,background:Ri,mode:Vi,default:Hi}),nl:Object.freeze({__proto__:null,common:zi,tabs:Ui,state:Li,direction:Fi,background:Di,mode:Bi,default:qi}),pl:Object.freeze({__proto__:null,common:Gi,tabs:Yi,state:Wi,direction:Zi,background:Ki,mode:Ji,default:Xi}),pt:Object.freeze({__proto__:null,common:Qi,tabs:to,state:eo,direction:io,background:oo,mode:ro,default:so}),ru:Object.freeze({__proto__:null,common:no,tabs:ao,state:co,direction:lo,background:ho,mode:uo,default:po}),ko:Object.freeze({__proto__:null,common:go,tabs:fo,state:bo,direction:mo,background:_o,mode:vo,default:yo})};function So(t,e="",i=""){const o=(localStorage.getItem("selectedLanguage")||"en").replace(/['"]+/g,"").replace("-","_");let r;try{r=t.split(".").reduce((t,e)=>t[e],wo[o])}catch(e){r=t.split(".").reduce((t,e)=>t[e],wo.en)}return void 0===r&&(r=t.split(".").reduce((t,e)=>t[e],wo.en)),""!==e&&""!==i&&(r=r.replace(e,i)),r}let ko=class extends ne{constructor(){super(...arguments),this._initialized=!1,this.directions=Ze(ve),this.backgrounds=Ze(ye),this.actionModes=Ze(_e),this.actions=["more-info","toggle","navigate","url","call-service","none"]}async setConfig(t){this._config=t,void 0===this._helpers&&await this.loadCardHelpers()}shouldUpdate(){return this._initialized||this._initialize(),!0}get _name(){var t;return(null===(t=this._config)||void 0===t?void 0:t.name)||""}get _show_name(){var t,e;return void 0===(null===(t=this._config)||void 0===t?void 0:t.show_name)||(null===(e=this._config)||void 0===e?void 0:e.show_name)}get _show_state(){var t,e;return void 0===(null===(t=this._config)||void 0===t?void 0:t.show_state)||(null===(e=this._config)||void 0===e?void 0:e.show_state)}get _compact(){var t,e;return"boolean"==typeof(null===(t=this._config)||void 0===t?void 0:t.compact)&&(null===(e=this._config)||void 0===e?void 0:e.compact)}get _entity(){var t;return(null===(t=this._config)||void 0===t?void 0:t.entity)||""}get _icon(){var t;return(null===(t=this._config)||void 0===t?void 0:t.icon)||ke}get _slider(){var t;return(null===(t=this._config)||void 0===t?void 0:t.slider)||xe}get _action_button(){var t;return(null===(t=this._config)||void 0===t?void 0:t.action_button)||Se}render(){var t,e;return this.hass&&this._helpers?(this._helpers.importMoreInfoControl("climate"),Rt` -
-
-
- - -
- - -
- - - - - - - - - -
-
-
- -
- - -
- - -
- - - - ${this.renderStateColor("icon")} -
- -
-
- -
- - -
-
- - - ${this.directions.map(t=>Rt` - ${So("direction."+t)} - `)} - - - - - ${this.backgrounds.map(t=>Rt` - ${So("background."+t)} - `)} - - - -
-
- ${this.renderBrightness("slider")} - ${this.renderStateColor("slider")} - - - - - - - - - -
-
-
- -
- - -
- - - ${this.actionModes.map(t=>Rt` - ${So("mode."+t)} - `)} - - - ${this._action_button.mode===_e.CUSTOM?Rt` - - - `:""} -
- - - - ${this._action_button.mode===_e.CUSTOM?Rt` - - - - `:""} -
- ${this._action_button.mode===_e.CUSTOM?Rt` - - `:""} -
-
-
-
- `):Rt``}renderBrightness(t){const e=this["_"+t];return Rt` - - - - `}renderStateColor(t){const e=this["_"+t];return Rt` - - - - `}_initialize(){void 0!==this.hass&&void 0!==this._config&&void 0!==this._helpers&&(this._initialized=!0)}async loadCardHelpers(){this._helpers=await window.loadCardHelpers()}_valueChangedSelect(t){var e;const i=t.detail.value;i&&this._changeValue(null===(e=i.parentElement)||void 0===e?void 0:e.configValue,i.itemValue)}_valueChangedEntity(t){var e,i;const o=t.target,r=null===(e=t.detail)||void 0===e?void 0:e.value,s=w(r)!==w((null===(i=this._config)||void 0===i?void 0:i.entity)||"light.dummy");if(this._changeValue("name",""),this._changeValue("icon.icon",""),this._changeValue(o.configValue,r),s){const t=X(this._config);Ke(t,["slider"],Je(r)),this._config=t,O(this,"config-changed",{config:this._config})}}_valueChanged(t){var e;const i=t.target,o=null===(e=t.detail)||void 0===e?void 0:e.value;this._changeValue(i.configValue,void 0!==i.checked?i.checked:o)}_changeValue(t,e){if(this._config&&this.hass&&(void 0===this["_"+t]||this["_"+t]!==e)){if(t){const i=X(this._config);Ke(i,[...t.split(".")],e),this._config=i,""===e&&delete this._config[t]}O(this,"config-changed",{config:this._config})}}static get styles(){return re` - ha-switch { - padding: 16px 6px; - } - .side-by-side { - display: flex; - flex-flow: row wrap; - } - .side-by-side > * { - padding-right: 8px; - width: 50%; - flex-flow: column wrap; - box-sizing: border-box; - } - .side-by-side > *:last-child { - flex: 1; - padding-right: 0; - } - .suffix { - margin: 0 8px; - } - .group { - padding: 15px; - border: 1px solid var(--primary-text-color) - } - .tabs { - overflow: hidden; - } - .tab { - width: 100%; - color: var(--primary-text-color); - overflow: hidden; - } - .tab-label { - display: flex; - justify-content: space-between; - padding: 1em 1em 1em 0em; - border-bottom: 1px solid var(--secondary-text-color); - font-weight: bold; - cursor: pointer; - } - .tab-label:hover { - /*background: #1a252f;*/ - } - .tab-label::after { - content: "❯"; - width: 1em; - height: 1em; - text-align: center; - transition: all 0.35s; - } - .tab-content { - max-height: 0; - padding: 0 1em; - background: var(--secondary-background-color); - transition: all 0.35s; - } - input.tab-checkbox { - position: absolute; - opacity: 0; - z-index: -1; - } - input.tab-checkbox:checked + .tab-label { - border-color: var(--accent-color); - } - input.tab-checkbox:checked + .tab-label::after { - transform: rotate(90deg); - } - input.tab-checkbox:checked ~ .tab-content { - max-height: 100vh; - padding: 1em; - } - `}};t([Zt({attribute:!1})],ko.prototype,"hass",void 0),t([Kt()],ko.prototype,"_config",void 0),t([Kt()],ko.prototype,"_helpers",void 0),ko=t([Yt("slider-button-card-editor")],ko),console.info(`%c SLIDER-BUTTON-CARD %c ${So("common.version")}1.10.3 %c`,"background-color: #555;color: #fff;padding: 3px 2px 3px 3px;border: 1px solid #555;border-radius: 3px 0 0 3px;font-family: Roboto,Verdana,Geneva,sans-serif;text-shadow: 0 1px 0 rgba(1, 1, 1, 0.3)","background-color: transparent;color: #555;padding: 3px 3px 3px 2px;border: 1px solid #555; border-radius: 0 3px 3px 0;font-family: Roboto,Verdana,Geneva,sans-serif","background-color: transparent"),window.customCards=window.customCards||[],window.customCards.push({type:"slider-button-card",name:"Slider button Card",description:"A button card with slider",preview:!0});let xo=class extends ne{constructor(){super(...arguments),this.changing=!1,this.changed=!1}static async getConfigElement(){return document.createElement("slider-button-card-editor")}static getStubConfig(t,e){const i=e.find(t=>t.startsWith("light"))||"";return{entity:i,slider:Je(i),show_name:!0,show_state:!0,compact:!1,icon:X(ke),action_button:X(Se)}}getCardSize(){return 0}setConfig(t){if(!t)throw new Error(So("common.invalid_configuration"));if(!t.entity)throw new Error(So("common.invalid_configuration"));this.config=Object.assign({slider:Je(t.entity),icon:X(ke),show_name:!0,show_state:!0,compact:!1,action_button:X(Se),debug:!1},t),this.ctrl=class{static getInstance(t){const e=w(t.entity),i={[we.LIGHT]:ai,[we.FAN]:ri,[we.SWITCH]:hi,[we.COVER]:oi,[we.INPUT_BOOLEAN]:si,[we.MEDIA_PLAYER]:li,[we.CLIMATE]:ii,[we.LOCK]:ci};if(void 0===i[e])throw new Error("Unsupported entity type: "+e);return new i[e](t)}}.getInstance(this.config)}shouldUpdate(t){if(!this.config)return!1;const e=t.get("hass");return e&&e.themes===this.hass.themes&&e.language===this.hass.language?function(t,e,i){if(e.has("config")||i)return!0;if(t.config.entity){var o=e.get("hass");return!o||o.states[t.config.entity]!==t.hass.states[t.config.entity]}return!1}(this,t,!1):(this.ctrl.log("shouldUpdate","forced true"),!0)}updated(t){this.updateValue(this.ctrl.value,!1),this.animateActionEnd();const e=t.get("hass"),i=t.get("config");(null==e?void 0:e.themes)===this.hass.themes&&(null==i?void 0:i.theme)===this.config.theme||(this.ctrl.log("Theme","updated"),function(t,e,i,o){void 0===o&&(o=!1),t._themes||(t._themes={});var r=e.default_theme;("default"===i||i&&e.themes[i])&&(r=i);var s=Object.assign({},t._themes);if("default"!==r){var n=e.themes[r];Object.keys(n).forEach((function(e){var i="--"+e;t._themes[i]="",s[i]=n[e]}))}if(t.updateStyles?t.updateStyles(s):window.ShadyCSS&&window.ShadyCSS.styleSubtree(t,s),o){var a=document.querySelector("meta[name=theme-color]");if(a){a.hasAttribute("default-content")||a.setAttribute("default-content",a.getAttribute("content"));var c=s["--primary-color"]||a.getAttribute("default-content");a.setAttribute("content",c)}}}(this,this.hass.themes,this.config.theme)),this.ctrl.log("Updated",this.ctrl.value)}firstUpdated(t){super.firstUpdated(t)}render(){var t,e,i,o,r;return this.ctrl.hass=this.hass,this.ctrl.stateObj?Rt` - -
-
- ${this.ctrl.hasToggle?Rt` -
- `:""} -
-
-
- ${this.renderText()} - ${this.renderAction()} - ${this.renderIcon()} -
-
- `:this._showError(So("common.show_error"))}renderText(){return this.config.show_name||this.config.show_state?Rt` -
- ${this.config.show_name?Rt` -
${this.ctrl.name}
- `:""} - ${this.config.show_state?Rt` -
- ${this.ctrl.isUnavailable?Rt` - ${this.hass.localize("state.default.unavailable")} - `:Rt` - ${this.ctrl.label} - `} -
- `:""} -
- `:Rt``}renderIcon(){var t;if(!1===(null===(t=this.config.icon)||void 0===t?void 0:t.show))return Rt``;let e=!1,i="";return this.ctrl.stateObj.attributes.entity_picture&&(i=`url(${this.ctrl.stateObj.attributes.entity_picture})`,e=!0),Rt` -
this._handleAction(t,this.config.icon)} - .actionHandler=${me({hasHold:!1,hasDoubleClick:!1})} - style=${pe({"background-image":""+i})} - > - -
- `}renderAction(){var t,e,i,o,r;return!1===(null===(t=this.config.action_button)||void 0===t?void 0:t.show)?Rt``:(null===(e=this.config.action_button)||void 0===e?void 0:e.mode)===_e.TOGGLE?Rt` -
- -
- `:Rt` -
this._handleAction(t,this.config.action_button)} - .actionHandler=${me({hasHold:!1,hasDoubleClick:!1})} - > - - ${void 0===(null===(o=this.config.action_button)||void 0===o?void 0:o.show_spinner)||(null===(r=this.config.action_button)||void 0===r?void 0:r.show_spinner)?Rt` - - - - `:""} -
- `}_handleAction(t,e){var i;this.hass&&this.config&&t.detail.action&&("toggle"!==(null===(i=e.tap_action)||void 0===i?void 0:i.action)||this.ctrl.isUnavailable||this.animateActionStart(),E(this,this.hass,Object.assign(Object.assign({},e),{entity:this.config.entity}),t.detail.action))}async handleClick(t){this.ctrl.hasToggle&&!this.ctrl.isUnavailable&&(t.preventDefault(),this.animateActionStart(),this.ctrl.log("Toggle"),await A(this.hass,this.config.entity))}_toggle(){this.hass&&this.config&&E(this,this.hass,{tap_action:{action:"toggle"},entity:this.config.entity},"tap")}setStateValue(t){this.ctrl.log("setStateValue",t),this.updateValue(t,!1),this.ctrl.value=t,this.animateActionStart()}animateActionStart(){this.animateActionEnd(),this.action&&this.action.classList.add("loading")}animateActionEnd(){this.action&&(clearTimeout(this.actionTimeout),this.actionTimeout=setTimeout(()=>{this.action.classList.remove("loading")},750))}updateValue(t,e=!0){this.changing=e,this.changed=!e,this.ctrl.log("updateValue",t),this.ctrl.targetValue=t,this.button&&(this.button.classList.remove("off"),e?this.button.classList.add("changing"):(this.button.classList.remove("changing"),this.ctrl.isOff&&this.button.classList.add("off")),this.stateText&&(this.stateText.innerHTML=this.ctrl.isUnavailable?""+this.hass.localize("state.default.unavailable"):this.ctrl.label),this.button.style.setProperty("--slider-value",this.ctrl.percentage+"%"),this.button.style.setProperty("--slider-bg-filter",this.ctrl.style.slider.filter),this.button.style.setProperty("--slider-color",this.ctrl.style.slider.color),this.button.style.setProperty("--icon-filter",this.ctrl.style.icon.filter),this.button.style.setProperty("--icon-color",this.ctrl.style.icon.color),this.button.style.setProperty("--icon-rotate-speed",this.ctrl.style.icon.rotateSpeed||"0s"))}_showError(t){const e=document.createElement("hui-error-card");return e.setConfig({type:"error",error:t,origConfig:this.config}),Rt` - ${e} - `}getColorFromVariable(t){if(void 0!==t&&"var"===t.substring(0,3)){let e=window.getComputedStyle(this).getPropertyValue(t.substring(4).slice(0,-1)).trim();return e.length||(e=window.getComputedStyle(document.documentElement).getPropertyValue(t.substring(4).slice(0,-1)).trim()),e}return t}onPointerDown(t){t.stopPropagation(),this.ctrl.isSliderDisabled||this.slider.setPointerCapture(t.pointerId)}onPointerUp(t){this.ctrl.isSliderDisabled||this.slider.hasPointerCapture(t.pointerId)&&(this.setStateValue(this.ctrl.targetValue),this.slider.releasePointerCapture(t.pointerId))}onPointerCancel(t){this.updateValue(this.ctrl.value,!1),this.slider.releasePointerCapture(t.pointerId)}onPointerMove(t){if(this.ctrl.isSliderDisabled)return;if(!this.slider.hasPointerCapture(t.pointerId))return;const{left:e,top:i,width:o,height:r}=this.slider.getBoundingClientRect(),s=this.ctrl.moveSlider(t,{left:e,top:i,width:o,height:r});this.ctrl.log("onPointerMove",s),this.updateValue(s)}connectedCallback(){super.connectedCallback()}disconnectedCallback(){super.disconnectedCallback()}static get styles(){return re` - ha-card { - box-sizing: border-box; - height: 100%; - width: 100%; - min-height: 7rem; - display: flex; - flex-direction: column; - justify-content: space-between; - touch-action: pan-y; - overflow: hidden; - --mdc-icon-size: 2.2em; - } - ha-card.square { - aspect-ratio: 1 / 1; - } - ha-card.compact { - min-height: 3rem !important; - } - :host { - --slider-bg-default-color: var(--primary-color, rgb(95, 124, 171)); - --slider-bg: var(--slider-color); - --slider-bg-filter: brightness(100%); - --slider-bg-direction: to right; - --slider-track-color: #2b374e; - --slider-tracker-color: transparent; - --slider-value: 0%; - --slider-transition-duration: 0.2s; - /*--label-text-shadow: rgb(255 255 255 / 10%) -1px -1px 1px, rgb(0 0 0 / 50%) 1px 1px 1px;*/ - /*--label-color-on: var(--primary-text-color, white);*/ - /*--label-color-off: var(--primary-text-color, white);*/ - --icon-filter: brightness(100%); - --icon-color: var(--paper-item-icon-color); - --icon-rotate-speed: 0s; - /*--state-color-on: #BAC0C6; */ - /*--state-color-off: var(--disabled-text-color);*/ - /*--state-text-shadow: rgb(255 255 255 / 10%) -1px -1px 1px, rgb(0 0 0 / 50%) 1px 1px 1px;*/ - --btn-bg-color-off: rgba(43,55,78,1); - --btn-bg-color-on: #20293c; - /*--action-icon-color-on: var(--paper-item-icon-color, black);*/ - /*--action-icon-color-off: var(--paper-item-icon-color, black);*/ - /*--action-spinner-color: var(--label-badge-text-color, white);*/ - } - /* --- BUTTON --- */ - - .button { - position: relative; - padding: 0.8rem; - box-sizing: border-box; - height: 100%; - min-height: 7rem; - width: 100%; - display: block; - overflow: hidden; - transition: all 0.2s ease-in-out; - touch-action: pan-y; - } - ha-card.compact .button { - min-height: 3rem !important; - } - .button.off { - background-color: var(--btn-bg-color-off); - } - - /* --- ICON --- */ - - .icon { - position: relative; - cursor: pointer; - width: var(--mdc-icon-size, 24px); - height: var(--mdc-icon-size, 24px); - box-sizing: border-box; - padding: 0; - outline: none; - animation: var(--icon-rotate-speed, 0s) linear 0s infinite normal both running rotate; - -webkit-tap-highlight-color: transparent; - } - .icon ha-icon { - filter: var(--icon-filter, brightness(100%)); - color: var(--icon-color); - transition: color 0.4s ease-in-out 0s, filter 0.2s linear 0s; - } - .icon.has-picture { - background-size: cover; - border-radius: 50%; - } - .icon.has-picture ha-icon{ - display: none; - } - .unavailable .icon ha-icon { - color: var(--disabled-text-color); - } - .compact .icon { - float: left; - } - - /* --- TEXT --- */ - - .text { - position: absolute; - bottom: 0; - left: 0; - padding: 0.8rem; - pointer-events: none; - user-select: none; - font-size: 1.1rem; - line-height: 1.3rem; - max-width: calc(100% - 2em); - /*text-shadow: rgb(255 255 255 / 10%) -1px -1px 1px, rgb(0 0 0 / 50%) 1px 1px 1px;*/ - } - .compact .text { - position: relative; - top: 0.5rem; - left: 0.5rem; - display: inline-block; - padding: 0; - height: 1.3rem; - width: 100%; - overflow: hidden; - max-width: calc(100% - 4em); - } - .compact.hide-action .text { - max-width: calc(100% - 2em); - } - - /* --- LABEL --- */ - - .name { - color: var(--label-color-on, var(--primary-text-color, white)); - text-overflow: ellipsis; - overflow: hidden; - white-space: nowrap; - text-shadow: var(--label-text-shadow, none); - } - .off .name { - color: var(--label-color-off, var(--primary-text-color, white)); - } - .unavailable.off .name, - .unavailable .name { - color: var(--disabled-text-color); - } - .compact .name { - display: inline-block; - max-width: calc(100% - 3.5em); - } - - /* --- STATE --- */ - - .state { - color: var(--state-color-on, var(--label-badge-text-color, white)); - text-overflow: ellipsis; - white-space: nowrap; - text-shadow: var(--state-text-shadow); - transition: font-size 0.1s ease-in-out; - } - .changing .state { - font-size: 150%; - } - .off .state { - color: var(--state-color-off, var(--disabled-text-color)); - } - .unavailable .state { - color: var(--disabled-text-color); - } - .compact .state { - display: inline-block; - max-width: calc(100% - 0em); - overflow: hidden; - } - - - /* --- SLIDER --- */ - - .slider { - position: absolute; - top: 0px; - left: 0px; - height: 100%; - width: 100%; - background-color: var( --ha-card-background, var(--card-background-color, var(--btn-bg-color-on, black)) ); - cursor: ew-resize; - z-index: 0; - } - .slider[data-mode="bottom-top"] { - cursor: ns-resize; - } - .slider[data-mode="top-bottom"] { - cursor: ns-resize; - } - .slider:active { - cursor: grabbing; - } - - /* --- SLIDER OVERLAY --- */ - - .slider .toggle-overlay { - position: absolute; - top: 0px; - left: 0px; - height: 100%; - width: 100%; - cursor: pointer; - opacity: 0; - z-index: 999; - } - - /* --- SLIDER BACKGROUND --- */ - - .slider-bg { - position: absolute; - top: 0; - left: 0px; - height: 100%; - width: 100%; - background: var(--slider-bg); - background-size: var(--slider-bg-size, 100% 100%); - background-color: var(--slider-bg-color, transparent); - background-position: var(--slider-bg-position, 0 0); - filter: var(--slider-bg-filter, brightness(100%)); - } - .off .slider .slider-bg { - background-color: var( --ha-card-background, var(--card-background-color, var(--btn-bg-color-off, black)) ); - } - .slider[data-background="solid"] .slider-bg { - --slider-bg-color: var(--slider-color); - } - .slider[data-background="triangle"] .slider-bg { - --slider-bg-direction: to bottom right; - --slider-bg: linear-gradient(var(--slider-bg-direction), transparent 0%, transparent 50%, var(--slider-color) 50%, var(--slider-color) 100%); - border-right: 0px solid; - } - .slider[data-background="triangle"][data-mode="bottom-top"] .slider-bg { - --slider-bg-direction: to top left; - } - .slider[data-background="triangle"][data-mode="top-bottom"] .slider-bg { - --slider-bg-direction: to bottom left; - } - .slider[data-background="custom"] .slider-bg { - --slider-bg: repeating-linear-gradient(-45deg, var(--slider-color) 0, var(--slider-color) 1px, var(--slider-color) 0, transparent 10%); - --slider-bg-size: 30px 30px; - } - .slider[data-background="gradient"] .slider-bg { - --slider-bg: linear-gradient(var(--slider-bg-direction), rgba(0, 0, 0, 0) -10%, var(--slider-color) 100%); - } - .slider[data-background="striped"] .slider-bg { - --slider-bg: linear-gradient(var(--slider-bg-direction), var(--slider-color), var(--slider-color) 50%, transparent 50%, transparent); - --slider-bg-size: 4px 100%; - } - .slider[data-background="striped"][data-mode="bottom-top"] .slider-bg, - .slider[data-background="striped"][data-mode="top-bottom"] .slider-bg { - --slider-bg-size: 100% 4px; - } - .slider[data-mode="bottom-top"] .slider-bg { - --slider-bg-direction: to top; - } - .slider[data-mode="top-bottom"] .slider-bg { - --slider-bg-direction: to bottom; - } - - /* --- SLIDER THUMB --- */ - - .slider-thumb { - position: relative; - width: 100%; - height: 100%; - transform: translateX(var(--slider-value)); - background: transparent; - transition: transform var(--slider-transition-duration) ease-in; - } - .changing .slider .slider-thumb { - transition: none; - } - .slider[data-mode="top-bottom"] .slider-thumb { - transform: translateY(var(--slider-value)) !important; - } - .slider[data-mode="bottom-top"] .slider-thumb { - transform: translateY(calc(var(--slider-value) * -1)) !important; - } - - .slider-thumb:before { - content: ''; - position: absolute; - top: 0; - left: -2px; - height: 100%; - width: 2px; - background: var(--slider-color); - opacity: 0; - transition: opacity 0.2s ease-in-out 0s; - box-shadow: var(--slider-color) 0px 1px 5px 1px; - z-index: 999; - } - .slider[data-mode="top-bottom"] .slider-thumb:before { - top: -2px; - left: 0px; - height: 2px; - width: 100%; - } - .changing .slider-thumb:before { - opacity: 0.5; - } - .off.changing .slider-thumb:before { - opacity: 0; - } - - .slider-thumb:after { - content: ''; - position: absolute; - top: 0; - left: 0px; - height: 100%; - width: 100%; - background: var( --ha-card-background, var(--card-background-color, var(--btn-bg-color-on, black)) ); - opacity: 1; - } - .slider[data-show-track="true"] .slider-thumb:after { - opacity: 0.9; - } - .off .slider[data-show-track="true"] .slider-thumb:after { - opacity: 1; - } - - /* --- ACTION BUTTON --- */ - - .action { - position: relative; - float: right; - width: var(--mdc-icon-size, 24px); - height: var(--mdc-icon-size, 24px); - color: var(--action-icon-color-on, var(--paper-item-icon-color, black)); - cursor: pointer; - outline: none; - -webkit-tap-highlight-color: transparent; - } - .action ha-switch { - position: absolute; - right: 0; - top: 5px; - } - .off .action { - color: var(--action-icon-color-off, var(--paper-item-icon-color, black)); - } - .unavailable .action { - color: var(--disabled-text-color); - } - - - .circular-loader { - position: absolute; - left: -8px; - top: -8px; - width: calc(var(--mdc-icon-size, 24px) + 16px); - height: calc(var(--mdc-icon-size, 24px) + 16px); - opacity: 0; - transition: opacity 0.2s ease-in-out; - animation: rotate 2s linear infinite; - } - .action.loading .circular-loader { - opacity: 1; - } - - .loader-path { - fill: none; - stroke-width: 2px; - stroke: var(--action-spinner-color, var(--label-badge-text-color, white)); - animation: animate-stroke 1.5s ease-in-out infinite both; - stroke-linecap: round; - } - - /* --- MISC --- */ - - .unavailable .slider .toggle-overlay, - .unavailable .action, - .unavailable .action ha-switch, - .unavailable .slider { - cursor: not-allowed !important; - } - - - @keyframes rotate { - 100% { - transform: rotate(360deg); - } - } - - @keyframes animate-stroke { - 0% { - stroke-dasharray: 1, 200; - stroke-dashoffset: 0; - } - 50% { - stroke-dasharray: 89, 200; - stroke-dashoffset: -35; - } - 100% { - stroke-dasharray: 89, 200; - stroke-dashoffset: -124; - } - } - `}};t([Zt({attribute:!1})],xo.prototype,"hass",void 0),t([Kt()],xo.prototype,"config",void 0),t([Jt(".state")],xo.prototype,"stateText",void 0),t([Jt(".button")],xo.prototype,"button",void 0),t([Jt(".action")],xo.prototype,"action",void 0),t([Jt(".slider")],xo.prototype,"slider",void 0),t([te({passive:!0})],xo.prototype,"onPointerDown",null),t([te({passive:!0})],xo.prototype,"onPointerUp",null),t([te({passive:!0})],xo.prototype,"onPointerCancel",null),t([te({passive:!0})],xo.prototype,"onPointerMove",null),xo=t([Yt("slider-button-card")],xo);export{xo as SliderButtonCard}; diff --git a/hacs.json b/hacs.json index afe12cd..3f8fd45 100644 --- a/hacs.json +++ b/hacs.json @@ -1,6 +1,5 @@ { "name": "Slider Button Card", "render_readme": true, - "filename": "slider-button-card.js", - "domains": ["light", "fan", "cover", "switch", "input_boolean", "media_player"] + "filename": "slider-button-card.js" } diff --git a/package-lock.json b/package-lock.json index 3619e25..87c2053 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "slider-button-card", - "version": "1.10.3", + "version": "1.10.9", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "slider-button-card", - "version": "1.10.3", + "version": "1.10.9", "license": "MIT", "dependencies": { "@ctrl/tinycolor": "^3.4.0", @@ -36,7 +36,6 @@ "rollup-plugin-serve": "^1.1.0", "rollup-plugin-terser": "^5.3.1", "rollup-plugin-typescript2": "^0.24.3", - "rollup-plugin-uglify": "^6.0.4", "typescript": "^3.9.7" } }, @@ -3094,27 +3093,6 @@ "integrity": "sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ==", "dev": true }, - "node_modules/rollup-plugin-uglify": { - "version": "6.0.4", - "resolved": "https://registry.npmjs.org/rollup-plugin-uglify/-/rollup-plugin-uglify-6.0.4.tgz", - "integrity": "sha512-ddgqkH02klveu34TF0JqygPwZnsbhHVI6t8+hGTcYHngPkQb5MIHI0XiztXIN/d6V9j+efwHAqEL7LspSxQXGw==", - "dev": true, - "dependencies": { - "@babel/code-frame": "^7.0.0", - "jest-worker": "^24.0.0", - "serialize-javascript": "^2.1.2", - "uglify-js": "^3.4.9" - }, - "peerDependencies": { - "rollup": ">=0.66.0 <2" - } - }, - "node_modules/rollup-plugin-uglify/node_modules/serialize-javascript": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-2.1.2.tgz", - "integrity": "sha512-rs9OggEUF0V4jUSecXazOYsLfu7OGK2qIn3c7IPBiffz32XniEp/TX9Xmc9LQfK2nQ2QKHvZ2oygKUGU0lG4jQ==", - "dev": true - }, "node_modules/rollup-pluginutils": { "version": "2.8.2", "resolved": "https://registry.npmjs.org/rollup-pluginutils/-/rollup-pluginutils-2.8.2.tgz", @@ -3615,18 +3593,6 @@ "node": ">=4.2.0" } }, - "node_modules/uglify-js": { - "version": "3.13.6", - "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.13.6.tgz", - "integrity": "sha512-rRprLwl8RVaS+Qvx3Wh5hPfPBn9++G6xkGlUupya0s5aDmNjI7z3lnRLB3u7sN4OmbB0pWgzhM9BEJyiWAwtAA==", - "dev": true, - "bin": { - "uglifyjs": "bin/uglifyjs" - }, - "engines": { - "node": ">=0.8.0" - } - }, "node_modules/unbox-primitive": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.1.tgz", @@ -6101,26 +6067,6 @@ } } }, - "rollup-plugin-uglify": { - "version": "6.0.4", - "resolved": "https://registry.npmjs.org/rollup-plugin-uglify/-/rollup-plugin-uglify-6.0.4.tgz", - "integrity": "sha512-ddgqkH02klveu34TF0JqygPwZnsbhHVI6t8+hGTcYHngPkQb5MIHI0XiztXIN/d6V9j+efwHAqEL7LspSxQXGw==", - "dev": true, - "requires": { - "@babel/code-frame": "^7.0.0", - "jest-worker": "^24.0.0", - "serialize-javascript": "^2.1.2", - "uglify-js": "^3.4.9" - }, - "dependencies": { - "serialize-javascript": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-2.1.2.tgz", - "integrity": "sha512-rs9OggEUF0V4jUSecXazOYsLfu7OGK2qIn3c7IPBiffz32XniEp/TX9Xmc9LQfK2nQ2QKHvZ2oygKUGU0lG4jQ==", - "dev": true - } - } - }, "rollup-pluginutils": { "version": "2.8.2", "resolved": "https://registry.npmjs.org/rollup-pluginutils/-/rollup-pluginutils-2.8.2.tgz", @@ -6538,12 +6484,6 @@ "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.9.tgz", "integrity": "sha512-kdMjTiekY+z/ubJCATUPlRDl39vXYiMV9iyeMuEuXZh2we6zz80uovNN2WlAxmmdE/Z/YQe+EbOEXB5RHEED3w==" }, - "uglify-js": { - "version": "3.13.6", - "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.13.6.tgz", - "integrity": "sha512-rRprLwl8RVaS+Qvx3Wh5hPfPBn9++G6xkGlUupya0s5aDmNjI7z3lnRLB3u7sN4OmbB0pWgzhM9BEJyiWAwtAA==", - "dev": true - }, "unbox-primitive": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.1.tgz", diff --git a/package.json b/package.json index 6fc27f5..337040b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "slider-button-card", - "version": "1.10.3", + "version": "1.10.9", "description": "Lovelace slider-button-card", "keywords": [ "home-assistant", @@ -12,7 +12,7 @@ ], "module": "slider-button-card.js", "repository": { - "url": "https://github.com/mattieha/slider-button-card" + "url": "https://github.com/custom-cards/slider-button-card" }, "author": "M Hoog Antink", "license": "MIT", @@ -44,7 +44,6 @@ "rollup-plugin-serve": "^1.1.0", "rollup-plugin-terser": "^5.3.1", "rollup-plugin-typescript2": "^0.24.3", - "rollup-plugin-uglify": "^6.0.4", "typescript": "^3.9.7" }, "scripts": { diff --git a/src/controllers/fan-controller.ts b/src/controllers/fan-controller.ts index 71a4189..15d43e3 100644 --- a/src/controllers/fan-controller.ts +++ b/src/controllers/fan-controller.ts @@ -29,7 +29,7 @@ export class FanController extends Controller { } get _step(): number { - return this.stateObj.attributes.percentage_step; + return this.hasSlider ? this.stateObj.attributes.percentage_step : 1; } get label(): string { @@ -44,7 +44,7 @@ export class FanController extends Controller { } get hasSlider(): boolean { - return 'speed' in this.stateObj.attributes; + return 'percentage' in this.stateObj.attributes; } get _max(): number { @@ -53,9 +53,14 @@ export class FanController extends Controller { get iconRotateSpeed(): string { let speed = 0; - if (this.percentage > 0) { - speed = 3 - ((this.percentage / 100) * 2); + if (this.hasSlider) { + if (this.percentage > 0) { + speed = 3 - ((this.percentage / 100) * 2); + } + } else { + speed = this._value } + return `${speed}s` }