├── .gitignore ├── LICENSE ├── webpack.config.js ├── package.json ├── src ├── helpers.js ├── main.js └── deep-press.js ├── README.md └── dist └── deep-press.js /.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules/ 2 | /v8-compile-cache-0/ 3 | package-lock.json 4 | webpack.config.js 5 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Jesper Nilsson 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /webpack.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | entry: './src/main.js', 3 | output: { 4 | filename: 'deep-press.js', 5 | // path: '/workspace/hass/www/community/deep-press/' 6 | }, 7 | // devtool: '#inline-source-map', 8 | module: { 9 | rules: [ 10 | { 11 | test: /\.m?js$/, 12 | exclude: /(node_modules)/, 13 | use: { 14 | loader: 'babel-loader', 15 | options: { 16 | presets: [ 17 | [ 18 | "@babel/preset-env", 19 | { 20 | "modules": 'commonjs', 21 | "targets": "> 5%, not dead", 22 | } 23 | ], 24 | ], 25 | plugins: [ 26 | "@babel/plugin-transform-template-literals", 27 | "@babel/plugin-proposal-class-properties" 28 | ], 29 | }, 30 | }, 31 | }, 32 | { 33 | test: /\.(png|svg)$/i, 34 | use: [ 35 | { 36 | loader: 'url-loader', 37 | options: { 38 | limit: 8192 39 | }, 40 | }, 41 | ], 42 | }, 43 | ], 44 | }, 45 | }; 46 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "deep-press", 3 | "version": "2.1.3", 4 | "description": "Adds deep press (3D touch) to Lovelace cards", 5 | "main": "src/deep-press.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1", 8 | "build": "webpack --mode=production", 9 | "watch": "webpack --mode=development --watch " 10 | }, 11 | "keywords": [ 12 | "home-assistant", 13 | "homeassistant", 14 | "hass", 15 | "automation", 16 | "lovelace", 17 | "3D-touch", 18 | "force-touch", 19 | "deep-press", 20 | "custom-cards" 21 | ], 22 | "author": "Jesper Nilsson ", 23 | "repository": "", 24 | "license": "ISC", 25 | "devDependencies": { 26 | "@babel/core": "^7.3.4", 27 | "@babel/plugin-transform-template-literals": "^7.2.0", 28 | "@babel/plugin-proposal-class-properties": "^7.1.0", 29 | "@babel/preset-env": "^7.3.4", 30 | "babel-loader": "^8.0.5", 31 | "url-loader": "^1.1.2", 32 | "webpack": "^4.36.1", 33 | "webpack-cli": "^3.3.6" 34 | }, 35 | "dependencies": { 36 | "custom-card-helpers": "^1.7.0", 37 | "pressure": "^2.1.2", 38 | "forceify": "latest", 39 | "card-tools": "github:thomasloven/lovelace-card-tools" 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/helpers.js: -------------------------------------------------------------------------------- 1 | export const setModalBehaviour = function (enable_clicks, retry) { 2 | var modal = document.querySelector("body > home-assistant").shadowRoot.querySelector("ha-more-info-dialog"); 3 | if (modal) { 4 | if (enable_clicks) { 5 | modal.noCancelOnOutsideClick = false; 6 | modal.style.pointerEvents = "all"; 7 | } else { 8 | modal.noCancelOnOutsideClick = true; 9 | modal.style.pointerEvents = "none"; 10 | } 11 | } else { 12 | if (retry) { //retry once, needed for popup cards that load slowly 13 | setTimeout(function () { 14 | setModalBehaviour(enable_clicks, false); 15 | }, 100); 16 | } 17 | } 18 | }; 19 | 20 | export const getView = function () { 21 | return document 22 | .querySelector("body > home-assistant") 23 | .shadowRoot.querySelector("home-assistant-main") 24 | .shadowRoot.querySelector("app-drawer-layout > partial-panel-resolver > ha-panel-lovelace") 25 | .shadowRoot.querySelector("hui-root") 26 | .shadowRoot.querySelector("#view > hui-view") ? 27 | document 28 | .querySelector("body > home-assistant") 29 | .shadowRoot.querySelector("home-assistant-main") 30 | .shadowRoot.querySelector("app-drawer-layout > partial-panel-resolver > ha-panel-lovelace") 31 | .shadowRoot.querySelector("hui-root") 32 | .shadowRoot.querySelector("#view > hui-view") : 33 | document 34 | .querySelector("body > home-assistant") 35 | .shadowRoot.querySelector("home-assistant-main") 36 | .shadowRoot.querySelector("app-drawer-layout > partial-panel-resolver > ha-panel-lovelace") 37 | .shadowRoot.querySelector("hui-root") 38 | .shadowRoot.querySelector("#view > hui-panel-view"); 39 | } 40 | 41 | export const removeBlur = function () { 42 | try { 43 | getView().style.webkitFilter = 'blur(0px)'; 44 | } catch (err) { 45 | if (!(err instanceof TypeError)) { 46 | throw err 47 | } 48 | } 49 | }; 50 | 51 | export const setIntervalNTimes = (fn, delay, times) => { 52 | if (!times) return; 53 | 54 | setTimeout(() => { 55 | fn(); 56 | setIntervalNTimes(fn, delay, times - 1) 57 | }, delay); 58 | }; 59 | 60 | 61 | export const scaleElement = function (config, element, scale) { 62 | if (config.animations) { 63 | element.style.transform = "scale(" + scale + ")"; 64 | }; 65 | }; 66 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Deep Press Mod for Lovelace 2 | This is not really a card, it adds deep press functionality to already existing cards in [Home Assistant](https://github.com/home-assistant/home-assistant) Lovelace UI. 3 | It can be used to mimic an iOS interface. 4 | 5 | ![deep-press](https://user-images.githubusercontent.com/26493864/61529951-f951ac00-aa22-11e9-8203-230ec5364a7c.GIF) 6 | 7 | ## Install 8 | First of all, [card-tools](https://github.com/thomasloven/lovelace-card-tools) is required. 9 | ### HACS 10 | 11 | 1. Add `https://github.com/roflcoopter/deep-press` as a custom repository. 12 | 13 | 2. Add a reference to `deep-press.js` inside your `ui-lovelace.yaml` or through the raw config editor interface. 14 | 15 | ```yaml 16 | resources: 17 | - url: /community_plugin/deep-press/deep-press.js 18 | type: module 19 | ``` 20 | 21 | ### Manual install 22 | 23 | 1. Download and copy `deep-press.js` from the [latest release](https://github.com/roflcoopter/deep-press/releases/latest) into your `config/www` directory. 24 | 25 | 2. Add a reference to `deep-press.js` inside your `ui-lovelace.yaml` or through the raw config editor interface. 26 | 27 | ```yaml 28 | resources: 29 | - url: /local/deep-press.js 30 | type: module 31 | ``` 32 | 33 | ## Usage 34 | This is not actually a new card. It works by changing how other cards work.
35 | It looks for any card which has `deep_press: true` in it's config. If `hold_action` is in the target cards config, those options are used for the deep press(3D touch).
36 | When you start to press on a 3D touch enabled device it will start to blur out the view.
37 | Once you pressed deep enough the cards `hold_action` will trigger. 38 | 39 | ### Example usage 40 | The config used for the demonstration above: 41 | ```yaml 42 | - type: entity-button 43 | entity: light.kokslampa 44 | name: Entity Button 45 | deep_press: true 46 | - type: custom:button-card 47 | entity: light.vitrinskap 48 | name: Custom button card 49 | deep_press: true 50 | hold_action: 51 | action: more-info 52 | ``` 53 | 54 | ### Configuration options 55 | You can add global options to ```deep_press``` at the root of your lovelace config. 56 | 57 | | Name | Type | Requirement | Description | Default 58 | | ---- | ---- | ------- | ----------- | ------- 59 | | enable_unsupported | boolean | **Optional** | Enable on unsupported devices | false 60 | | animations | boolean | **Optional** | The harder you press, the smaller the div gets | true 61 | 62 | ### Example Configuration 63 | ```yaml 64 | resources: 65 | - url: /local/deep-press.js 66 | type: module 67 | 68 | deep_press: 69 | enable_unsupported: true 70 | 71 | views: 72 | ... 73 | ``` 74 | ## Unsupported devices 75 | ```deep_press``` will fall back to use hold time just as a regular tap-action on devices
76 | that does not support force-touch.
77 | *Note: Some devices dont work well with the fall-back method. This is a problem with the underlying library unfortunately.* 78 | 79 | 80 | ## Notes 81 | This is based a lot on [card-mod](https://github.com/thomasloven/lovelace-card-mod) and it uses the same technique to alter existing cards.
82 | The library used to enable deep pressing is [Pressure.js](https://github.com/stuyam/pressure).
83 | [custom-card-helpers](https://github.com/custom-cards/custom-card-helpers) is used to handle clicks.
84 | README is based on the layout from [simple-weather-card](https://github.com/kalkih/simple-weather-card). 85 | 86 | ## License 87 | This project is under the MIT license. 88 | -------------------------------------------------------------------------------- /src/main.js: -------------------------------------------------------------------------------- 1 | import { 2 | setModalBehaviour, 3 | removeBlur, 4 | } from './helpers' 5 | 6 | import { lovelace } from "card-tools/src/hass"; 7 | import { fireEvent } from "card-tools/src/event"; 8 | 9 | import DeepPress from './deep-press' 10 | 11 | // Wait for lovelace to be defined before initializing 12 | const waitForLovelace = () => { 13 | if (lovelace()) { 14 | initialize() 15 | } else { 16 | setTimeout(waitForLovelace, 250); 17 | } 18 | }; 19 | 20 | const initialize = () => { 21 | // We dont require card-tools, but we have to wait for it since we use the same 22 | // method of patching the firstUpdated function 23 | customElements.whenDefined('card-tools').then(() => { 24 | customElements.whenDefined('ha-card').then(() => { 25 | const HaCard = customElements.get('ha-card'); 26 | 27 | // Set global config 28 | const defaults = { 29 | enable_unsupported: false, 30 | animations: true, 31 | }; 32 | var deep_press_config = Object.assign({}, defaults, lovelace().config.deep_press); 33 | 34 | if ('ontouchforcechange' in document === false && deep_press_config.enable_unsupported == false) { 35 | return; // disable if device doesnt support force-touch 36 | } 37 | 38 | [ 39 | 'touchend', 40 | 'mouseup', 41 | ].forEach((ev) => { 42 | document.addEventListener(ev, 43 | () => { 44 | removeBlur(); 45 | setTimeout(function () { 46 | setModalBehaviour(true, false); 47 | }, 100); 48 | } 49 | ); 50 | }); 51 | 52 | const findConfig = function (node) { 53 | if (node.config) 54 | return node.config; 55 | if (node._config) 56 | return node._config; 57 | if (node.host) 58 | return findConfig(node.host); 59 | if (node.parentElement) 60 | return findConfig(node.parentElement); 61 | if (node.parentNode) 62 | return findConfig(node.parentNode); 63 | return null; 64 | }; 65 | 66 | function addCover(deep_press_config, card_config) { 67 | // Check if cover is already applied 68 | if (this.querySelector(":scope >#deep-press-cover")) 69 | return; 70 | 71 | // Create a cover which captures the deep press 72 | var cover = document.createElement("div"); 73 | cover.setAttribute("id", "deep-press-cover"); 74 | cover.setAttribute( 75 | "style", 76 | "position: absolute; top:0; left:0; width:100%; height: 100%; overflow: visible;" 77 | ); 78 | this.appendChild(cover); 79 | 80 | var deepPress = new DeepPress(cover, this, deep_press_config, card_config); 81 | deepPress.init(); 82 | }; 83 | 84 | var cached_update = HaCard.prototype.firstUpdated; 85 | HaCard.prototype.firstUpdated = function (e) { 86 | // Call the original firstUpdated method, then create cover element 87 | cached_update.apply(this, e); 88 | const card_config = findConfig(this); 89 | if (card_config && card_config.deep_press && card_config.hold_action) { 90 | addCover.call(this, deep_press_config, card_config); 91 | }; 92 | }; 93 | 94 | fireEvent('ll-rebuild', {}); 95 | }); 96 | }); 97 | }; 98 | 99 | waitForLovelace() 100 | 101 | console.info( 102 | `%cdeep-press\n%cVersion: 2.1.3`, 103 | "color: green; font-weight: bold;", 104 | "" 105 | ); 106 | -------------------------------------------------------------------------------- /src/deep-press.js: -------------------------------------------------------------------------------- 1 | import { 2 | setModalBehaviour, 3 | removeBlur, 4 | getView, 5 | scaleElement 6 | } from './helpers' 7 | 8 | import { 9 | handleClick 10 | } from 'custom-card-helpers'; 11 | 12 | import Pressure from 'pressure'; 13 | 14 | export default class DeepPress { 15 | constructor(cover, root, deep_press_config, config) { 16 | this.cover = cover; 17 | this.root = root; 18 | this.deep_press_config = deep_press_config; 19 | this.config = config; 20 | this.cover.deep_press_config = deep_press_config; 21 | this.cover.config = config; 22 | 23 | this._upEvent = this.upEvent.bind(this); 24 | } 25 | 26 | downEvent(event) { 27 | // Listen for release events 28 | [ 29 | // 'touchend', 30 | // 'mouseup', 31 | 'click' 32 | ].forEach(function (eventName) { 33 | this.cover.addEventListener(eventName, this._upEvent, { passive: true, capture: true }); 34 | }, this); 35 | 36 | this.down_event = Object.assign({}, event); // Store event. Used later to simulate a click 37 | /* We have to stop propagation to prevent the underlying cards actions to trigger. 38 | HOWEVER, if we stop propagation, things like swiper-card doesnt work. 39 | To solve this i redispatch the same even on the cards parent. Superhacky. 40 | */ 41 | event.stopPropagation(); 42 | getView().dispatchEvent(new event.constructor(event.type, event)); 43 | } 44 | 45 | upEvent(event) { 46 | scaleElement(this.deep_press_config, this.root, 1); 47 | this.cover.removeEventListener(event.type, this._upEvent, { passive: true, capture: true }); 48 | 49 | if (this.cover.cancel || this.cover.hold) { 50 | event.stopPropagation(); 51 | getView().dispatchEvent(new event.constructor(event.type, event)); 52 | return; 53 | } 54 | if (event.type != 'click') { 55 | this.root.dispatchEvent(new event.constructor(this.down_event.type, this.down_event)); 56 | }; 57 | this.root.dispatchEvent(new event.constructor(event.type, event)); 58 | removeBlur(); 59 | } 60 | 61 | cancelEvent(event) { 62 | this.cover.cancel = true; 63 | scaleElement(this.deep_press_config, this.root, 1); 64 | removeBlur(); 65 | } 66 | 67 | init() { 68 | // Down events 69 | [ 70 | 'touchstart', 71 | 'mousedown' 72 | ].forEach(function (eventName) { 73 | this.cover.addEventListener(eventName, this.downEvent.bind(this), { passive: true, capture: true }); 74 | }, this); 75 | 76 | // Canceling events 77 | [ 78 | 'touchcancel', 79 | 'mouseout', 80 | 'touchmove', 81 | 'mousewheel', 82 | 'wheel', 83 | 'scroll' 84 | ].forEach(function (eventName) { 85 | this.cover.addEventListener(eventName, this.cancelEvent.bind(this), { passive: true, capture: true }); 86 | }, this); 87 | 88 | Pressure.set(this.cover, { 89 | start: function (event) { 90 | this.cancel = false; 91 | this.event_over = false; 92 | this.hold = false; 93 | this.deep_press = false; 94 | this.view = getView(); 95 | }, 96 | 97 | change: function (force, event) { 98 | if (this.cancel || this.deep_press) { 99 | return 100 | } 101 | if (force > 0.2) { 102 | this.view.style.webkitFilter = 'blur(' + Pressure.map(force, 0.2, 0.5, 0, 10) + 'px)'; 103 | scaleElement(this.deep_press_config, this.parentElement, Pressure.map(force, 0.2, 0.5, 1, 0.5)); 104 | this.hold = true; 105 | }; 106 | }, 107 | 108 | startDeepPress: function (event) { 109 | if (this.cancel) { 110 | return 111 | } 112 | if (!this.deep_press) { 113 | this.deep_press = true; 114 | scaleElement(this.deep_press_config, this.parentElement, 1); 115 | handleClick(this.parentElement, cardTools.hass, this.config, true, false); 116 | setModalBehaviour(false, true); 117 | removeBlur(); 118 | }; 119 | }, 120 | 121 | end: function () { 122 | scaleElement(this.deep_press_config, this.parentElement, 1); 123 | removeBlur(); 124 | }, 125 | }); 126 | } 127 | }; 128 | -------------------------------------------------------------------------------- /dist/deep-press.js: -------------------------------------------------------------------------------- 1 | !function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=2)}([function(e,t,n){"use strict";function r(){return document.querySelector("hc-main")?document.querySelector("hc-main").hass:document.querySelector("home-assistant")?document.querySelector("home-assistant").hass:void 0}function o(e){return document.querySelector("hc-main")?document.querySelector("hc-main").provideHass(e):document.querySelector("home-assistant")?document.querySelector("home-assistant").provideHass(e):void 0}function s(){var e,t=document.querySelector("hc-main");return t?((e=t._lovelaceConfig).current_view=t._lovelacePath,e):(t=(t=(t=(t=(t=(t=(t=(t=(t=document.querySelector("home-assistant"))&&t.shadowRoot)&&t.querySelector("home-assistant-main"))&&t.shadowRoot)&&t.querySelector("app-drawer-layout partial-panel-resolver"))&&t.shadowRoot||t)&&t.querySelector("ha-panel-lovelace"))&&t.shadowRoot)&&t.querySelector("hui-root"))?((e=t.lovelace).current_view=t.___curView,e):null}async function i(e){e&&(await customElements.whenDefined(e.localName),e.updateComplete&&await e.updateComplete)}async function a(){var e=document.querySelector("hc-main");return e?(i(e=(e=e&&e.shadowRoot)&&e.querySelector("hc-lovelace")),i(e=(e=e&&e.shadowRoot)&&e.querySelector("hui-view")||e.querySelector("hui-panel-view")),e):(i(e=document.querySelector("home-assistant")),i(e=(e=e&&e.shadowRoot)&&e.querySelector("home-assistant-main")),i(e=(e=e&&e.shadowRoot)&&e.querySelector("app-drawer-layout partial-panel-resolver")),i(e=(e=e&&e.shadowRoot||e)&&e.querySelector("ha-panel-lovelace")),i(e=(e=e&&e.shadowRoot)&&e.querySelector("hui-root")),i(e=(e=e&&e.shadowRoot)&&e.querySelector("ha-app-layout")),i(e=(e=e&&e.querySelector("#view"))&&e.firstElementChild),e)}function u(){var e=document.querySelector("hc-main");return e=e?(e=(e=(e=e&&e.shadowRoot)&&e.querySelector("hc-lovelace"))&&e.shadowRoot)&&e.querySelector("hui-view")||e.querySelector("hui-panel-view"):(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=document.querySelector("home-assistant"))&&e.shadowRoot)&&e.querySelector("home-assistant-main"))&&e.shadowRoot)&&e.querySelector("app-drawer-layout partial-panel-resolver"))&&e.shadowRoot||e)&&e.querySelector("ha-panel-lovelace"))&&e.shadowRoot)&&e.querySelector("hui-root"))&&e.shadowRoot)&&e.querySelector("ha-app-layout"))&&e.querySelector("#view"))&&e.firstElementChild}async function c(){if(customElements.get("hui-view"))return!0;await customElements.whenDefined("partial-panel-resolver");const e=document.createElement("partial-panel-resolver");if(e.hass={panels:[{url_path:"tmp",component_name:"lovelace"}]},e._updateRoutes(),await e.routerOptions.routes.tmp.load(),!customElements.get("ha-panel-lovelace"))return!1;const t=document.createElement("ha-panel-lovelace");return t.hass=r(),void 0===t.hass&&(await new Promise(e=>{window.addEventListener("connection-status",t=>{console.log(t),e()},{once:!0})}),t.hass=r()),t.panel={config:{mode:null}},t._fetchConfig(),!0}n.r(t),n.d(t,"hass",function(){return r}),n.d(t,"provideHass",function(){return o}),n.d(t,"lovelace",function(){return s}),n.d(t,"async_lovelace_view",function(){return a}),n.d(t,"lovelace_view",function(){return u}),n.d(t,"load_lovelace",function(){return c})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.scaleElement=t.setIntervalNTimes=t.removeBlur=t.getView=t.setModalBehaviour=void 0;const r=function(e,t){var n=document.querySelector("body > home-assistant").shadowRoot.querySelector("ha-more-info-dialog");n?e?(n.noCancelOnOutsideClick=!1,n.style.pointerEvents="all"):(n.noCancelOnOutsideClick=!0,n.style.pointerEvents="none"):t&&setTimeout(function(){r(e,!1)},100)};t.setModalBehaviour=r;const o=function(){return document.querySelector("body > home-assistant").shadowRoot.querySelector("home-assistant-main").shadowRoot.querySelector("app-drawer-layout > partial-panel-resolver > ha-panel-lovelace").shadowRoot.querySelector("hui-root").shadowRoot.querySelector("#view > hui-view")?document.querySelector("body > home-assistant").shadowRoot.querySelector("home-assistant-main").shadowRoot.querySelector("app-drawer-layout > partial-panel-resolver > ha-panel-lovelace").shadowRoot.querySelector("hui-root").shadowRoot.querySelector("#view > hui-view"):document.querySelector("body > home-assistant").shadowRoot.querySelector("home-assistant-main").shadowRoot.querySelector("app-drawer-layout > partial-panel-resolver > ha-panel-lovelace").shadowRoot.querySelector("hui-root").shadowRoot.querySelector("#view > hui-panel-view")};t.getView=o;t.removeBlur=function(){try{o().style.webkitFilter="blur(0px)"}catch(e){if(!(e instanceof TypeError))throw e}};const s=(e,t,n)=>{n&&setTimeout(()=>{e(),s(e,t,n-1)},t)};t.setIntervalNTimes=s;t.scaleElement=function(e,t,n){e.animations&&(t.style.transform="scale("+n+")")}},function(e,t,n){"use strict";var r,o=n(1),s=n(0),i=n(3),a=(r=n(4))&&r.__esModule?r:{default:r};const u=()=>{(0,s.lovelace)()?c():setTimeout(u,250)},c=()=>{customElements.whenDefined("card-tools").then(()=>{customElements.whenDefined("ha-card").then(()=>{const e=customElements.get("ha-card");var t=Object.assign({},{enable_unsupported:!1,animations:!0},(0,s.lovelace)().config.deep_press);if("ontouchforcechange"in document==!1&&0==t.enable_unsupported)return;["touchend","mouseup"].forEach(e=>{document.addEventListener(e,()=>{(0,o.removeBlur)(),setTimeout(function(){(0,o.setModalBehaviour)(!0,!1)},100)})});const n=function(e){return e.config?e.config:e._config?e._config:e.host?n(e.host):e.parentElement?n(e.parentElement):e.parentNode?n(e.parentNode):null};var r=e.prototype.firstUpdated;e.prototype.firstUpdated=function(e){r.apply(this,e);const o=n(this);o&&o.deep_press&&o.hold_action&&function(e,t){if(!this.querySelector(":scope >#deep-press-cover")){var n=document.createElement("div");n.setAttribute("id","deep-press-cover"),n.setAttribute("style","position: absolute; top:0; left:0; width:100%; height: 100%; overflow: visible;"),this.appendChild(n),new a.default(n,this,e,t).init()}}.call(this,t,o)},(0,i.fireEvent)("ll-rebuild",{})})})};u(),console.info("%cdeep-press\n%cVersion: 2.1.3","color: green; font-weight: bold;","")},function(e,t,n){"use strict";n.r(t),n.d(t,"fireEvent",function(){return o});var r=n(0);function o(e,t,n=null){if((e=new Event(e,{bubbles:!0,cancelable:!1,composed:!0})).detail=t||{},n)n.dispatchEvent(e);else{var o=Object(r.lovelace_view)();o&&o.dispatchEvent(e)}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r,o=n(1),s=n(6),i=(r=n(5))&&r.__esModule?r:{default:r};t.default=class{constructor(e,t,n,r){this.cover=e,this.root=t,this.deep_press_config=n,this.config=r,this.cover.deep_press_config=n,this.cover.config=r,this._upEvent=this.upEvent.bind(this)}downEvent(e){["click"].forEach(function(e){this.cover.addEventListener(e,this._upEvent,{passive:!0,capture:!0})},this),this.down_event=Object.assign({},e),e.stopPropagation(),(0,o.getView)().dispatchEvent(new e.constructor(e.type,e))}upEvent(e){if((0,o.scaleElement)(this.deep_press_config,this.root,1),this.cover.removeEventListener(e.type,this._upEvent,{passive:!0,capture:!0}),this.cover.cancel||this.cover.hold)return e.stopPropagation(),void(0,o.getView)().dispatchEvent(new e.constructor(e.type,e));"click"!=e.type&&this.root.dispatchEvent(new e.constructor(this.down_event.type,this.down_event)),this.root.dispatchEvent(new e.constructor(e.type,e)),(0,o.removeBlur)()}cancelEvent(e){this.cover.cancel=!0,(0,o.scaleElement)(this.deep_press_config,this.root,1),(0,o.removeBlur)()}init(){["touchstart","mousedown"].forEach(function(e){this.cover.addEventListener(e,this.downEvent.bind(this),{passive:!0,capture:!0})},this),["touchcancel","mouseout","touchmove","mousewheel","wheel","scroll"].forEach(function(e){this.cover.addEventListener(e,this.cancelEvent.bind(this),{passive:!0,capture:!0})},this),i.default.set(this.cover,{start:function(e){this.cancel=!1,this.event_over=!1,this.hold=!1,this.deep_press=!1,this.view=(0,o.getView)()},change:function(e,t){this.cancel||this.deep_press||e>.2&&(this.view.style.webkitFilter="blur("+i.default.map(e,.2,.5,0,10)+"px)",(0,o.scaleElement)(this.deep_press_config,this.parentElement,i.default.map(e,.2,.5,1,.5)),this.hold=!0)},startDeepPress:function(e){this.cancel||this.deep_press||(this.deep_press=!0,(0,o.scaleElement)(this.deep_press_config,this.parentElement,1),(0,s.handleClick)(this.parentElement,cardTools.hass,this.config,!0,!1),(0,o.setModalBehaviour)(!1,!0),(0,o.removeBlur)())},end:function(){(0,o.scaleElement)(this.deep_press_config,this.parentElement,1),(0,o.removeBlur)()}})}}},function(e,t,n){var r,o,s;o=[],void 0===(s="function"==typeof(r=function(){"use strict";function e(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function t(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o=function(){function e(e,t){for(var n=0;n=.5?this._startDeepPress(t):this._endDeepPress()}},{key:"runPolyfill",value:function(e){this.increment=0===h.get("polyfillSpeedUp",this.options)?1:10/h.get("polyfillSpeedUp",this.options),this.decrement=0===h.get("polyfillSpeedDown",this.options)?1:10/h.get("polyfillSpeedDown",this.options),this.setPressed(!0),this.runClosure("start",e),!1===this.runningPolyfill&&this.loopPolyfillForce(0,e)}},{key:"loopPolyfillForce",value:function(e,t){!1===this.nativeSupport&&(this.isPressed()?(this.runningPolyfill=!0,e=e+this.increment>1?1:e+this.increment,this.runClosure("change",e,t),this.deepPress(e,t),setTimeout(this.loopPolyfillForce.bind(this,e,t),10)):((e=e-this.decrement<0?0:e-this.decrement)<.5&&this.isDeepPressed()&&(this.setDeepPressed(!1),this.runClosure("endDeepPress")),0===e?(this.runningPolyfill=!1,this.setPressed(!0),this._endPress()):(this.runClosure("change",e,t),this.deepPress(e,t),setTimeout(this.loopPolyfillForce.bind(this,e,t),10))))}}]),e}(),u=function(r){function s(t,r,o){return n(this,s),e(this,(s.__proto__||Object.getPrototypeOf(s)).call(this,t,r,o))}return t(s,r),o(s,[{key:"bindEvents",value:function(){this.add("webkitmouseforcewillbegin",this._startPress.bind(this)),this.add("mousedown",this.support.bind(this)),this.add("webkitmouseforcechanged",this.change.bind(this)),this.add("webkitmouseforcedown",this._startDeepPress.bind(this)),this.add("webkitmouseforceup",this._endDeepPress.bind(this)),this.add("mouseleave",this._endPress.bind(this)),this.add("mouseup",this._endPress.bind(this))}},{key:"support",value:function(e){!1===this.isPressed()&&this.fail(e,this.runKey)}},{key:"change",value:function(e){this.isPressed()&&e.webkitForce>0&&this._changePress(this.normalizeForce(e.webkitForce),e)}},{key:"normalizeForce",value:function(e){return this.reachOne(p(e,1,3,0,1))}},{key:"reachOne",value:function(e){return e>.995?1:e}}]),s}(a),c=function(r){function s(t,r,o){return n(this,s),e(this,(s.__proto__||Object.getPrototypeOf(s)).call(this,t,r,o))}return t(s,r),o(s,[{key:"bindEvents",value:function(){b?(this.add("touchforcechange",this.start.bind(this)),this.add("touchstart",this.support.bind(this,0)),this.add("touchend",this._endPress.bind(this))):(this.add("touchstart",this.startLegacy.bind(this)),this.add("touchend",this._endPress.bind(this)))}},{key:"start",value:function(e){e.touches.length>0&&(this._startPress(e),this.touch=this.selectTouch(e),this.touch&&this._changePress(this.touch.force,e))}},{key:"support",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.runKey;!1===this.isPressed()&&(e<=6?(e++,setTimeout(this.support.bind(this,e,t,n),10)):this.fail(t,n))}},{key:"startLegacy",value:function(e){this.initialForce=e.touches[0].force,this.supportLegacy(0,e,this.runKey,this.initialForce)}},{key:"supportLegacy",value:function(e,t,n,r){r!==this.initialForce?(this._startPress(t),this.loopForce(t)):e<=6?(e++,setTimeout(this.supportLegacy.bind(this,e,t,n,r),10)):this.fail(t,n)}},{key:"loopForce",value:function(e){this.isPressed()&&(this.touch=this.selectTouch(e),setTimeout(this.loopForce.bind(this,e),10),this._changePress(this.touch.force,e))}},{key:"selectTouch",value:function(e){if(1===e.touches.length)return this.returnTouch(e.touches[0],e);for(var t=0;t1?this.fail(e,this.runKey):(this._startPress(e),this._changePress(e.pressure,e)))}},{key:"change",value:function(e){this.isPressed()&&e.pressure>0&&.5!==e.pressure&&(this._changePress(e.pressure,e),this.deepPress(e.pressure,e))}}]),s}(a),h={polyfill:!0,polyfillSpeedUp:1e3,polyfillSpeedDown:0,preventSelect:!0,only:null,get:function(e,t){return t.hasOwnProperty(e)?t[e]:this[e]},set:function(e){for(var t in e)e.hasOwnProperty(t)&&this.hasOwnProperty(t)&&"get"!=t&&"set"!=t&&(this[t]=e[t])}},d=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if("string"==typeof e||e instanceof String)for(var r=document.querySelectorAll(e),o=0;o-1?r:null}};function u(e){for(var t=[],n=1;n3?0:(e-e%10!=10?1:0)*e%10]}},f=u({},d),p=function(e){return e.replace(/[|\\{()[^$+*?.-]/g,"\\$&")},m=function(e,t){for(void 0===t&&(t=2),e=String(e);e.length0?"-":"+")+m(100*Math.floor(Math.abs(t)/60)+Math.abs(t)%60,4)},Z:function(e){var t=e.getTimezoneOffset();return(t>0?"-":"+")+m(Math.floor(Math.abs(t)/60),2)+":"+m(Math.abs(t)%60,2)}},y=function(e){return+e-1},g=[null,"[1-9]\\d?"],b=[null,o],w=["isPm",o,function(e,t){var n=e.toLowerCase();return n===t.amPm[0]?0:n===t.amPm[1]?1:null}],_=["timezoneOffset","[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z?",function(e){var t=(e+"").match(/([+-]|\d\d)/gi);if(t){var n=60*+t[1]+parseInt(t[2],10);return"+"===t[0]?n:-n}return 0}],S={D:["day","[1-9]\\d?"],DD:["day","\\d\\d"],Do:["day","[1-9]\\d?"+o,function(e){return parseInt(e,10)}],M:["month","[1-9]\\d?",y],MM:["month","\\d\\d",y],YY:["year","\\d\\d",function(e){var t=+(""+(new Date).getFullYear()).substr(0,2);return+(""+(+e>68?t-1:t)+e)}],h:["hour","[1-9]\\d?",void 0,"isPm"],hh:["hour","\\d\\d",void 0,"isPm"],H:["hour","[1-9]\\d?"],HH:["hour","\\d\\d"],m:["minute","[1-9]\\d?"],mm:["minute","\\d\\d"],s:["second","[1-9]\\d?"],ss:["second","\\d\\d"],YYYY:["year","\\d{4}"],S:["millisecond","\\d",function(e){return 100*+e}],SS:["millisecond","\\d\\d",function(e){return 10*+e}],SSS:["millisecond","\\d{3}"],d:g,dd:g,ddd:b,dddd:b,MMM:["month",o,a("monthNamesShort")],MMMM:["month",o,a("monthNames")],a:w,A:w,ZZ:_,Z:_},k={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 D={format:function(e,t,n){if(void 0===t&&(t=k.default),void 0===n&&(n={}),"number"==typeof e&&(e=new Date(e)),"[object Date]"!==Object.prototype.toString.call(e)||isNaN(e.getTime()))throw new Error("Invalid Date pass to format");t=k[t]||t;var o=[];t=t.replace(s,function(e,t){return o.push(t),"@@@"});var i=u(u({},f),n);return(t=t.replace(r,function(t){return v[t](e,i)})).replace(/@@@/g,function(){return o.shift()})},parse:function(e,t,n){if(void 0===n&&(n={}),"string"!=typeof t)throw new Error("Invalid format in fecha parse");if(t=k[t]||t,e.length>1e3)return null;var o={year:(new Date).getFullYear(),month:0,day:1,hour:0,minute:0,second:0,millisecond:0,isPm:null,timezoneOffset:null},i=[],a=[],c=t.replace(s,function(e,t){return a.push(p(t)),"@@@"}),l={},h={};c=p(c).replace(r,function(e){var t=S[e],n=t[0],r=t[1],o=t[3];if(l[n])throw new Error("Invalid format. "+n+" specified twice in format");return l[n]=!0,o&&(h[o]=!0),i.push(t),"("+r+")"}),Object.keys(h).forEach(function(e){if(!l[e])throw new Error("Invalid format. "+e+" is required in specified format")}),c=c.replace(/@@@/g,function(){return a.shift()});var d=e.match(new RegExp(c,"i"));if(!d)return null;for(var m=u(u({},f),n),v=1;v=0?"past":"future";o=Math.abs(o);for(var i=0;i0?t+":"+R(n)+":"+R(r):n>0?n+":"+R(r):r>0?""+r:null}function Y(e){var t=P(e.attributes.remaining);if("active"===e.state){var n=(new Date).getTime(),r=new Date(e.last_changed).getTime();t=Math.max(t-(n-r)/1e3,0)}return t}var x=function(e,t,n,r){void 0===r&&(r=!1),e._themes||(e._themes={});var o=t.default_theme;("default"===n||n&&t.themes[n])&&(o=n);var s=Object.assign({},e._themes);if("default"!==o){var i=t.themes[o];Object.keys(i).forEach(function(t){var n="--"+t;e._themes[n]="",s[n]=i[t]})}if(e.updateStyles?e.updateStyles(s):window.ShadyCSS&&window.ShadyCSS.styleSubtree(e,s),r){var a=document.querySelector("meta[name=theme-color]");if(a){a.hasAttribute("default-content")||a.setAttribute("default-content",a.getAttribute("content"));var u=s["--primary-color"]||a.getAttribute("default-content");a.setAttribute("content",u)}}},F=function(e){return"function"==typeof e.getCardSize?e.getCardSize():4};function I(e){return e.substr(0,e.indexOf("."))}function H(e){return e.substr(e.indexOf(".")+1)}function L(e){var t=e.language||"en";return e.translationMetadata.translations[t]&&e.translationMetadata.translations[t].isRTL||!1}function A(e){return L(e)?"rtl":"ltr"}function j(e){return I(e.entity_id)}function U(e,t,n){if("unknown"===t.state||"unavailable"===t.state)return e("state.default."+t.state);if(t.attributes.unit_of_measurement)return t.state+" "+t.attributes.unit_of_measurement;var r=j(t);if("input_datetime"===r){var o;if(!t.attributes.has_time)return o=new Date(t.attributes.year,t.attributes.month-1,t.attributes.day),E(o,n);if(!t.attributes.has_date){var s=new Date;return o=new Date(s.getFullYear(),s.getMonth(),s.getDay(),t.attributes.hour,t.attributes.minute),T(o,n)}return o=new Date(t.attributes.year,t.attributes.month-1,t.attributes.day,t.attributes.hour,t.attributes.minute),M(o,n)}return t.attributes.device_class&&e("component."+r+".state."+t.attributes.device_class+"."+t.state)||e("component."+r+".state._."+t.state)||t.state}var z="hass:bookmark",B="lovelace",Z=["climate","cover","configurator","input_select","input_number","input_text","lock","media_player","scene","script","timer","vacuum","water_heater","weblink"],V=["alarm_control_panel","automation","camera","climate","configurator","cover","fan","group","history_graph","input_datetime","light","lock","media_player","script","sun","updater","vacuum","water_heater","weather"],K=["input_number","input_select","input_text","scene","weblink"],W=["camera","configurator","history_graph","scene"],G=["closed","locked","off"],J=new Set(["fan","input_boolean","light","switch","group","automation"]),$="°C",Q="°F",X="group.default_view",ee=function(e,t,n,r){r=r||{},n=null==n?{}:n;var o=new Event(t,{bubbles:void 0===r.bubbles||r.bubbles,cancelable:Boolean(r.cancelable),composed:void 0===r.composed||r.composed});return o.detail=n,e.dispatchEvent(o),o},te=new Set(["call-service","divider","section","weblink","cast","select"]),ne={alert:"toggle",automation:"toggle",climate:"climate",cover:"cover",fan:"toggle",group:"group",input_boolean:"toggle",input_number:"input-number",input_select:"input-select",input_text:"input-text",light:"toggle",lock:"lock",media_player:"media-player",remote:"toggle",scene:"scene",script:"script",sensor:"sensor",timer:"timer",switch:"toggle",vacuum:"toggle",water_heater:"climate",input_datetime:"input-datetime"},re=function(e,t){void 0===t&&(t=!1);var n=function(e,t){return r("hui-error-card",{type:"error",error:e,config:t})},r=function(e,t){var r=window.document.createElement(e);try{r.setConfig(t)}catch(r){return console.error(e,r),n(r.message,t)}return r};if(!e||"object"!=typeof e||!t&&!e.type)return n("No type defined",e);var o=e.type;if(o&&o.startsWith("custom:"))o=o.substr("custom:".length);else if(t)if(te.has(o))o="hui-"+o+"-row";else{if(!e.entity)return n("Invalid config given.",e);var s=e.entity.split(".",1)[0];o="hui-"+(ne[s]||"text")+"-entity-row"}else o="hui-"+o+"-card";if(customElements.get(o))return r(o,e);var i=n("Custom element doesn't exist: "+e.type+".",e);i.style.display="None";var a=setTimeout(function(){i.style.display=""},2e3);return customElements.whenDefined(e.type).then(function(){clearTimeout(a),ee(i,"ll-rebuild",{},i)}),i},oe=function(e,t,n){var r;return void 0===n&&(n=!1),function(){for(var o=[],s=arguments.length;s--;)o[s]=arguments[s];var i=this,a=n&&!r;clearTimeout(r),r=setTimeout(function(){r=null,n||e.apply(i,o)},t),a&&e.apply(i,o)}},se={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 ie(e,t){if(e in se)return se[e];switch(e){case"alarm_control_panel":switch(t){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 t&&"off"===t?"hass:radiobox-blank":"hass:checkbox-marked-circle";case"cover":return"closed"===t?"hass:window-closed":"hass:window-open";case"lock":return t&&"unlocked"===t?"hass:lock-open":"hass:lock";case"media_player":return t&&"off"!==t&&"idle"!==t?"hass:cast-connected":"hass:cast";case"zwave":switch(t){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 "+e+" ("+t+")"),z}}var ae=function(e,t){var n=t.value||t,r=t.attribute?e.attributes[t.attribute]:e.state;switch(t.operator||"=="){case"==":return r===n;case"<=":return r<=n;case"<":return r=":return r>=n;case">":return r>n;case"!=":return r!==n;case"regex":return r.match(n);default:return!1}},ue=function(e,t,n){return Number.isNaN=Number.isNaN||function e(t){return"number"==typeof t&&e(t)},!Number.isNaN(Number(e))&&Intl?new Intl.NumberFormat(t,ce(e,n)).format(Number(e)):e.toString()},ce=function(e,t){var n=t||{};if("string"!=typeof e)return n;if(!t||!t.minimumFractionDigits&&!t.maximumFractionDigits){var r=e.indexOf(".")>-1?e.split(".")[1].length:0;n.minimumFractionDigits=r,n.maximumFractionDigits=r}return n},le=function(e){ee(window,"haptic",e)},he=function(e,t,n){void 0===n&&(n=!1),n?history.replaceState(null,"",t):history.pushState(null,"",t),ee(window,"location-changed",{replace:n})},de=function(e,t,n){void 0===n&&(n=!0);var r,o=I(t),s="group"===o?"homeassistant":o;switch(o){case"lock":r=n?"unlock":"lock";break;case"cover":r=n?"open_cover":"close_cover";break;default:r=n?"turn_on":"turn_off"}return e.callService(s,r,{entity_id:t})},fe=function(e,t){var n=G.includes(e.states[t].state);return de(e,t,n)},pe=function(e,t,n,r){if(r||(r={action:"more-info"}),!r.confirmation||r.confirmation.exemptions&&r.confirmation.exemptions.some(function(e){return e.user===t.user.id})||(le("warning"),confirm(r.confirmation.text||"Are you sure you want to "+r.action+"?")))switch(r.action){case"more-info":(n.entity||n.camera_image)&&ee(e,"hass-more-info",{entityId:n.entity?n.entity:n.camera_image});break;case"navigate":r.navigation_path&&he(0,r.navigation_path);break;case"url":r.url_path&&window.open(r.url_path);break;case"toggle":n.entity&&(fe(t,n.entity),le("success"));break;case"call-service":if(!r.service)return void le("failure");var o=r.service.split(".",2);t.callService(o[0],o[1],r.service_data),le("success");break;case"fire-dom-event":ee(e,"ll-custom",r)}},me=function(e,t,n,r){var o;"double_tap"===r&&n.double_tap_action?o=n.double_tap_action:"hold"===r&&n.hold_action?o=n.hold_action:"tap"===r&&n.tap_action&&(o=n.tap_action),pe(e,t,n,o)},ve=function(e,t,n,r,o){var s;if(o&&n.double_tap_action?s=n.double_tap_action:r&&n.hold_action?s=n.hold_action:!r&&n.tap_action&&(s=n.tap_action),s||(s={action:"more-info"}),!s.confirmation||s.confirmation.exemptions&&s.confirmation.exemptions.some(function(e){return e.user===t.user.id})||confirm(s.confirmation.text||"Are you sure you want to "+s.action+"?"))switch(s.action){case"more-info":(s.entity||n.entity||n.camera_image)&&(ee(e,"hass-more-info",{entityId:s.entity?s.entity:n.entity?n.entity:n.camera_image}),s.haptic&&le(s.haptic));break;case"navigate":s.navigation_path&&(he(0,s.navigation_path),s.haptic&&le(s.haptic));break;case"url":s.url_path&&window.open(s.url_path),s.haptic&&le(s.haptic);break;case"toggle":n.entity&&(fe(t,n.entity),s.haptic&&le(s.haptic));break;case"call-service":if(!s.service)return;var i=s.service.split(".",2),a=i[0],u=i[1],c=Object.assign({},s.service_data);"entity"===c.entity_id&&(c.entity_id=n.entity),t.callService(a,u,c),s.haptic&&le(s.haptic);break;case"fire-dom-event":ee(e,"ll-custom",s),s.haptic&&le(s.haptic)}};function ye(e){return void 0!==e&&"none"!==e.action}function ge(e,t,n){if(t.has("config")||n)return!0;if(e.config.entity){var r=t.get("hass");return!r||r.states[e.config.entity]!==e.hass.states[e.config.entity]}return!1}function be(e){return void 0!==e&&"none"!==e.action}var we=function(e,t,n){void 0===n&&(n=!0);var r={};t.forEach(function(t){if(G.includes(e.states[t].state)===n){var o=I(t),s=["cover","lock"].includes(o)?o:"homeassistant";s in r||(r[s]=[]),r[s].push(t)}}),Object.keys(r).forEach(function(t){var o;switch(t){case"lock":o=n?"unlock":"lock";break;case"cover":o=n?"open_cover":"close_cover";break;default:o=n?"turn_on":"turn_off"}e.callService(t,o,{entity_id:r[t]})})},_e=function(){var e=document.querySelector("home-assistant");if(e=(e=(e=(e=(e=(e=(e=(e=e&&e.shadowRoot)&&e.querySelector("home-assistant-main"))&&e.shadowRoot)&&e.querySelector("app-drawer-layout partial-panel-resolver"))&&e.shadowRoot||e)&&e.querySelector("ha-panel-lovelace"))&&e.shadowRoot)&&e.querySelector("hui-root")){var t=e.lovelace;return t.current_view=e.___curView,t}return null},Se={humidity:"hass:water-percent",illuminance:"hass:brightness-5",temperature:"hass:thermometer",pressure:"hass:gauge",power:"hass:flash",signal_strength:"hass:wifi"},ke={binary_sensor:function(e){var t=e.state&&"off"===e.state;switch(e.attributes.device_class){case"battery":return t?"hass:battery":"hass:battery-outline";case"cold":return t?"hass:thermometer":"hass:snowflake";case"connectivity":return t?"hass:server-network-off":"hass:server-network";case"door":return t?"hass:door-closed":"hass:door-open";case"garage_door":return t?"hass:garage":"hass:garage-open";case"gas":case"power":case"problem":case"safety":case"smoke":return t?"hass:shield-check":"hass:alert";case"heat":return t?"hass:thermometer":"hass:fire";case"light":return t?"hass:brightness-5":"hass:brightness-7";case"lock":return t?"hass:lock":"hass:lock-open";case"moisture":return t?"hass:water-off":"hass:water";case"motion":return t?"hass:walk":"hass:run";case"occupancy":return t?"hass:home-outline":"hass:home";case"opening":return t?"hass:square":"hass:square-outline";case"plug":return t?"hass:power-plug-off":"hass:power-plug";case"presence":return t?"hass:home-outline":"hass:home";case"sound":return t?"hass:music-note-off":"hass:music-note";case"vibration":return t?"hass:crop-portrait":"hass:vibrate";case"window":return t?"hass:window-closed":"hass:window-open";default:return t?"hass:radiobox-blank":"hass:checkbox-marked-circle"}},cover:function(e){var t="closed"!==e.state;switch(e.attributes.device_class){case"garage":return t?"hass:garage-open":"hass:garage";case"door":return t?"hass:door-open":"hass:door-closed";case"shutter":return t?"hass:window-shutter-open":"hass:window-shutter";case"blind":return t?"hass:blinds-open":"hass:blinds";case"window":return t?"hass:window-open":"hass:window-closed";default:return ie("cover",e.state)}},sensor:function(e){var t=e.attributes.device_class;if(t&&t in Se)return Se[t];if("battery"===t){var n=Number(e.state);if(isNaN(n))return"hass:battery-unknown";var r=10*Math.round(n/10);return r>=100?"hass:battery":r<=0?"hass:battery-alert":"hass:battery-"+r}var o=e.attributes.unit_of_measurement;return"°C"===o||"°F"===o?"hass:thermometer":ie("sensor")},input_datetime:function(e){return e.attributes.has_date?e.attributes.has_time?ie("input_datetime"):"hass:calendar":"hass:clock"}},De=function(e){if(!e)return z;if(e.attributes.icon)return e.attributes.icon;var t=I(e.entity_id);return t in ke?ke[t](e):ie(t,e.state)}}]); --------------------------------------------------------------------------------