diff --git a/www/community/compact-custom-header/compact-custom-header.js b/www/community/compact-custom-header/compact-custom-header.js
index 892e07c..3734973 100644
--- a/www/community/compact-custom-header/compact-custom-header.js
+++ b/www/community/compact-custom-header/compact-custom-header.js
@@ -1,998 +1,1477 @@
-const LitElement = Object.getPrototypeOf(
- customElements.get("ha-panel-lovelace")
+console.info(
+ `%c COMPACT-CUSTOM-HEADER \n%c Version 1.4.9 `,
+ "color: orange; font-weight: bold; background: black",
+ "color: white; font-weight: bold; background: dimgray"
);
-const html = LitElement.prototype.html;
-const hass = document.querySelector("home-assistant").hass;
-const fireEvent = (node, type, detail, options) => {
- options = options || {};
- detail = detail === null || detail === undefined ? {} : detail;
- const event = new Event(type, {
- bubbles: options.bubbles === undefined ? true : options.bubbles,
- cancelable: Boolean(options.cancelable),
- composed: options.composed === undefined ? true : options.composed
- });
- event.detail = detail;
- node.dispatchEvent(event);
- return event;
-};
+class CompactCustomHeader {
+ constructor() {
+ this.LitElement = Object.getPrototypeOf(
+ customElements.get("ha-panel-lovelace")
+ );
+ this.hass = document.querySelector("home-assistant").hass;
+ this.fireEvent = (node, type, detail, options = {}) => {
+ detail = detail === null || detail === undefined ? {} : detail;
+ const event = new Event(type, {
+ bubbles: options.bubbles === undefined ? true : options.bubbles,
+ cancelable: Boolean(options.cancelable),
+ composed: options.composed === undefined ? true : options.composed
+ });
+ event.detail = detail;
+ node.dispatchEvent(event);
+ return event;
+ };
-const defaultConfig = {
- header: true,
- disable: false,
- menu: "show",
- voice: "show",
- notifications: "show",
- options: "show",
- clock_format: 12,
- clock_am_pm: true,
- clock_date: false,
- date_locale: hass.language,
- chevrons: false,
- redirect: true,
- background: "",
- hide_tabs: [],
- show_tabs: [],
- default_tab: [],
- kiosk_mode: false,
- sidebar_swipe: true,
- sidebar_closed: false,
- disable_sidebar: false,
- hide_help: false,
- hide_config: false,
- hide_unused: false,
- tab_color: {},
- button_color: {},
- swipe: false,
- swipe_amount: "15",
- swipe_animate: "none",
- swipe_skip: "",
- swipe_wrap: true,
- swipe_prevent_default: false,
- warning: true,
- compact_header: true
-};
+ let ll = document.querySelector("home-assistant");
+ ll = ll && ll.shadowRoot;
+ ll = ll && ll.querySelector("home-assistant-main");
+ this.main = ll;
+ ll = ll && ll.shadowRoot;
+ ll = ll && ll.querySelector("app-drawer-layout partial-panel-resolver");
+ this.panelResolver = ll;
+ ll = (ll && ll.shadowRoot) || ll;
+ ll = ll && ll.querySelector("ha-panel-lovelace");
+ ll = ll && ll.shadowRoot;
+ ll = ll && ll.querySelector("hui-root");
+ this.lovelace = ll.lovelace;
+ this.root = ll.shadowRoot;
-let root = document.querySelector("home-assistant");
-root = root && root.shadowRoot;
-root = root && root.querySelector("home-assistant-main");
-const main = root;
-root = root && root.shadowRoot;
-root = root && root.querySelector("app-drawer-layout partial-panel-resolver");
-root = (root && root.shadowRoot) || root;
-root = root && root.querySelector("ha-panel-lovelace");
-root = root && root.shadowRoot;
-root = root && root.querySelector("hui-root");
-const lovelace = root.lovelace;
-root = root.shadowRoot;
+ this.frontendVersion = Number(window.frontendVersion);
+ this.newSidebar = this.frontendVersion >= 20190710;
+ this.header = this.root.querySelector("app-header");
+ this.editMode = this.header.className == "edit-mode";
+ this.view = this.root.querySelector("ha-app-layout #view");
-const newSidebar = !root.querySelector("hui-notification-drawer");
+ this.sidebarClosed = false;
+ this.firstRun = true;
+ this.buttons = {};
+ this.prevColor = {};
-let notifications = notificationCount();
-const header = root.querySelector("app-header");
-let cchConfig = buildConfig(lovelace.config.cch || {});
-const view = root.querySelector("ha-app-layout").querySelector('[id="view"]');
+ this.defaultConfig = {
+ header: true,
+ disable: false,
+ yaml_editor: false,
+ menu: "show",
+ voice: "show",
+ notifications: "show",
+ options: "show",
+ clock_format: 12,
+ clock_am_pm: true,
+ clock_date: false,
+ date_locale: this.hass.language,
+ chevrons: false,
+ redirect: true,
+ background: "",
+ hide_tabs: "",
+ show_tabs: "",
+ edit_mode_show_tabs: false,
+ default_tab: "",
+ default_tab_template: "",
+ kiosk_mode: false,
+ sidebar_swipe: true,
+ sidebar_closed: false,
+ disable_sidebar: false,
+ hide_help: false,
+ hide_config: false,
+ hide_unused: false,
+ tab_color: {},
+ button_color: {},
+ statusbar_color: "",
+ swipe: false,
+ swipe_amount: "15",
+ swipe_animate: "none",
+ swipe_skip: "",
+ swipe_wrap: true,
+ swipe_prevent_default: false,
+ swipe_skip_hidden: true,
+ warning: true,
+ compact_header: true,
+ view_css: "",
+ time_css: "",
+ date_css: "",
+ header_css: "",
+ tab_css: {},
+ button_css: {}
+ };
-let defaultTabRedirect = false;
-let sidebarClosed = false;
-let editMode = header.className == "edit-mode";
-let firstRun = true;
-let condState = [];
-let prevColor = {};
-let prevState = [];
-let buttons = {};
-
-run();
-breakingChangeNotification();
-
-function run() {
- const disable = cchConfig.disable;
- const urlDisable = window.location.href.includes("disable_cch");
- const tabContainer = root.querySelector("paper-tabs");
- const tabs = tabContainer
- ? Array.from(tabContainer.querySelectorAll("paper-tab"))
- : [];
-
- if (firstRun || buttons == undefined) {
- buttons = getButtonElements(tabContainer);
- }
- if (!buttons.menu || !buttons.options || header.className == "edit-mode") {
- return;
+ this.cchConfig = this.buildConfig(
+ this.lovelace.config.cch || {},
+ this.hass.user.name
+ );
}
- if (!disable && !urlDisable) {
- insertEditMenu(tabs);
- hideMenuItems();
- styleHeader(tabContainer, tabs, header);
- styleButtons(tabs);
- defaultTab(tabs, tabContainer);
- hideTabs(tabContainer, tabs);
- for (let button in buttons) {
- if (cchConfig[button] == "clock") insertClock(button);
+ run() {
+ const tabContainer = this.root.querySelector("paper-tabs");
+ const tabs = tabContainer
+ ? Array.from(tabContainer.querySelectorAll("paper-tab"))
+ : [];
+ let disabled =
+ window.location.href.includes("disable_cch") || this.cchConfig.disable;
+
+ if (this.firstRun || this.buttons == undefined) {
+ this.buttons = this.getButtonElements(tabContainer);
}
- if (firstRun) {
- sidebarMod();
- conditionalStyling(tabs, header);
- }
- if (!editMode) tabContainerMargin(tabContainer);
- if (cchConfig.swipe) swipeNavigation(tabs, tabContainer);
- }
-
- if (!disable && firstRun) observers(tabContainer, tabs, urlDisable, header);
- fireEvent(header, "iron-resize");
- firstRun = false;
-}
-
-function buildConfig(config) {
- let exceptionConfig = {};
- let highestMatch = 0;
- if (config.exceptions) {
- config.exceptions.forEach(exception => {
- const matches = countMatches(exception.conditions);
- if (matches > highestMatch) {
- highestMatch = matches;
- exceptionConfig = exception.config;
- }
- });
- }
-
- if (
- exceptionConfig.hide_tabs &&
- config.show_tabs &&
- exceptionConfig.hide_tabs.length &&
- config.show_tabs.length
- ) {
- delete config.show_tabs;
- } else if (
- exceptionConfig.show_tabs &&
- config.hide_tabs &&
- exceptionConfig.show_tabs.length &&
- config.hide_tabs.length
- ) {
- delete config.hide_tabs;
- }
- return { ...defaultConfig, ...config, ...exceptionConfig };
-
- function countMatches(conditions) {
- const userVars = { user: hass.user.name, user_agent: navigator.userAgent };
- let count = 0;
- for (const cond in conditions) {
- if (cond == "user" && conditions[cond].includes(",")) {
- let userList = conditions[cond].split(/[ ,]+/);
- for (let user in userList) {
- if (userVars[cond] == userList[user]) {
- count++;
- }
- }
- } else {
- if (
- userVars[cond] == conditions[cond] ||
- (cond == "query_string" &&
- window.location.search.includes(conditions[cond])) ||
- (cond == "user_agent" && userVars[cond].includes(conditions[cond])) ||
- (cond == "media_query" && window.matchMedia(conditions[cond]).matches)
- ) {
- count++;
- } else {
- return 0;
- }
+ if (!this.buttons.menu || !this.buttons.options || this.editMode) return;
+ if (!disabled) {
+ this.insertEditMenu(tabs);
+ this.hideMenuItems();
+ this.styleHeader(tabContainer, tabs);
+ this.styleButtons(tabs, tabContainer);
+ if (this.firstRun) this.sidebarMod();
+ this.hideTabs(tabContainer, tabs);
+ for (let button in this.buttons) {
+ if (this.cchConfig[button] == "clock") this.insertClock(button);
}
+ if (!this.editMode) this.tabContainerMargin(tabContainer);
+ if (this.cchConfig.swipe) this.swipeNavigation(tabs, tabContainer);
+ if (this.firstRun) this.defaultTab(tabs, tabContainer);
}
- return count;
- }
-}
-
-function observers(tabContainer, tabs, urlDisable, header) {
- const callback = function(mutations) {
- mutations.forEach(mutation => {
- if (mutation.target.className == "edit-mode") {
- editMode = true;
- if (!cchConfig.disable) removeStyles(tabContainer, tabs, header);
- buttons.options = root.querySelector("paper-menu-button");
- insertEditMenu(tabs);
- } else if (mutation.target.nodeName == "APP-HEADER") {
- for (let node of mutation.addedNodes) {
- if (node.nodeName == "APP-TOOLBAR") {
- editMode = false;
- buttons = getButtonElements(tabContainer);
- run();
- return;
- }
- }
- } else if (mutation.addedNodes.length) {
- if (mutation.addedNodes[0].nodeName == "HUI-UNUSED-ENTITIES") return;
- let editor = root
- .querySelector("ha-app-layout")
- .querySelector("editor");
- if (editor) root.querySelector("ha-app-layout").removeChild(editor);
- if (!editMode && !urlDisable && cchConfig.conditional_styles) {
- conditionalStyling(tabs, header);
- }
- }
- });
- };
- new MutationObserver(callback).observe(view, { childList: true });
- new MutationObserver(callback).observe(root.querySelector("app-header"), {
- childList: true
- });
-
- if (!urlDisable) {
- window.hassConnection.then(({ conn }) => {
- conn.socket.onmessage = () => {
- notifications = notificationCount();
- if (cchConfig.conditional_styles && !editMode) {
- conditionalStyling(tabs, header);
- }
- };
- });
- }
-}
-
-function notificationCount() {
- if (newSidebar) {
- let badge = main.shadowRoot
- .querySelector("ha-sidebar")
- .shadowRoot.querySelector("span.notification-badge");
- if (!badge) {
- return 0;
- } else {
- return parseInt(badge.innerHTML);
+ if (this.firstRun) {
+ this.observers(tabContainer, tabs, disabled);
+ this.breakingChangeNotification();
}
+ this.firstRun = false;
+ this.fireEvent(this.header, "iron-resize");
}
- let i = 0;
- let drawer = root
- .querySelector("hui-notification-drawer")
- .shadowRoot.querySelector(".notifications");
- for (let notification of drawer.querySelectorAll(".notification")) {
- if (notification.style.display !== "none") i++;
- }
- return i;
-}
-function getButtonElements(tabContainer) {
- let buttons = {};
- buttons.options = root.querySelector("paper-menu-button");
- if (!editMode) {
- buttons.menu = root.querySelector("ha-menu-button");
- buttons.voice = root.querySelector("ha-start-voice-button");
- if (!newSidebar) {
- buttons.notifications = root.querySelector("hui-notifications-button");
- }
- }
- if (buttons.menu && newSidebar) {
- new MutationObserver(() => {
- if (buttons.menu.style.visibility == "hidden") {
- buttons.menu.style.display = "none";
- } else {
- buttons.menu.style.display = "";
- }
- tabContainerMargin(tabContainer);
- }).observe(buttons.menu, { attributeFilter: ["style"] });
- }
- return buttons;
-}
-
-function tabContainerMargin(tabContainer) {
- let marginRight = 0;
- let marginLeft = 15;
- for (const button in buttons) {
- let visible = buttons[button].style.display !== "none";
- if (cchConfig[button] == "show" && visible) {
- if (button == "menu") marginLeft += 45;
- else marginRight += 45;
- } else if (cchConfig[button] == "clock" && visible) {
- const clockWidth =
- (cchConfig.clock_format == 12 && cchConfig.clock_am_pm) ||
- cchConfig.clock_date
- ? 110
- : 80;
- if (button == "menu") marginLeft += clockWidth + 15;
- else marginRight += clockWidth;
- }
- }
- if (tabContainer) {
- tabContainer.style.marginRight = marginRight + "px";
- tabContainer.style.marginLeft = marginLeft + "px";
- }
-}
-
-function hideMenuItems() {
- if (cchConfig.hide_help || cchConfig.hide_config || cchConfig.hide_unused) {
- let menuItems = buttons.options
- .querySelector("paper-listbox")
- .querySelectorAll("paper-item");
- for (let item of menuItems) {
- if (
- (item.innerHTML.includes("Help") ||
- item.getAttribute("aria-label") == "Help") &&
- cchConfig.hide_help
- ) {
- item.parentNode.removeChild(item);
- } else if (
- (item.innerHTML.includes("Unused entities") ||
- item.getAttribute("aria-label") == "Unused entities") &&
- cchConfig.hide_unused
- ) {
- item.parentNode.removeChild(item);
- } else if (
- (item.innerHTML.includes("Configure UI") ||
- item.getAttribute("aria-label") == "Configure UI") &&
- cchConfig.hide_config
- ) {
- item.parentNode.removeChild(item);
- }
- }
- }
-}
-
-function insertEditMenu(tabs) {
- if (buttons.options && editMode) {
- if (cchConfig.hide_tabs) {
- let show_tabs = document.createElement("paper-item");
- show_tabs.setAttribute("id", "show_tabs");
- show_tabs.addEventListener("click", () => {
- for (let i = 0; i < tabs.length; i++) {
- tabs[i].style.removeProperty("display");
+ buildConfig(config, user_name) {
+ let exceptionConfig = {};
+ let highestMatch = 0;
+ // Count number of matching conditions and choose config with most matches.
+ if (config.exceptions) {
+ config.exceptions.forEach(exception => {
+ const matches = countMatches(exception.conditions, user_name);
+ if (matches > highestMatch) {
+ highestMatch = matches;
+ exceptionConfig = exception.config;
}
});
- show_tabs.innerHTML = "Show all tabs";
- insertMenuItem(buttons.options.querySelector("paper-listbox"), show_tabs);
+ }
+ // If exception config uses hide_tabs and main config uses show_tabs,
+ // delete show_tabs and vice versa.
+ if (
+ exceptionConfig.hide_tabs &&
+ config.show_tabs &&
+ exceptionConfig.hide_tabs.length &&
+ config.show_tabs.length
+ ) {
+ delete config.show_tabs;
+ } else if (
+ exceptionConfig.show_tabs &&
+ config.hide_tabs &&
+ exceptionConfig.show_tabs.length &&
+ config.hide_tabs.length
+ ) {
+ delete config.hide_tabs;
}
- let cchSettings = document.createElement("paper-item");
- cchSettings.setAttribute("id", "cch_settings");
- cchSettings.addEventListener("click", () => {
- showEditor();
- });
- cchSettings.innerHTML = "CCH Settings";
- insertMenuItem(buttons.options.querySelector("paper-listbox"), cchSettings);
- }
-}
+ return { ...this.defaultConfig, ...config, ...exceptionConfig };
-function removeStyles(tabContainer, tabs, header) {
- let header_colors = root.querySelector('[id="cch_header_colors"]');
- if (tabContainer) {
- tabContainer.style.marginLeft = "";
- tabContainer.style.marginRight = "";
- }
- header.style.background = null;
- view.style.minHeight = "";
- view.style.marginTop = "";
- view.style.paddingTop = "";
- view.style.boxSizing = "";
- if (root.querySelector('[id="cch_iron_selected"]')) {
- root.querySelector('[id="cch_iron_selected"]').outerHTML = "";
- }
- if (header_colors) header_colors.parentNode.removeChild(header_colors);
- for (let i = 0; i < tabs.length; i++) {
- tabs[i].style.color = "";
- }
-}
-
-function styleHeader(tabContainer, tabs, header) {
- if (!cchConfig.header || cchConfig.kiosk_mode) {
- header.style.display = "none";
- view.style.minHeight = "100vh";
- } else {
- view.style.minHeight = "100vh";
- view.style.marginTop = "-48.5px";
- view.style.paddingTop = "48.5px";
- view.style.boxSizing = "border-box";
- header.style.background =
- cchConfig.background ||
- getComputedStyle(document.body).getPropertyValue("--cch-background") ||
- "var(--primary-color)";
- header.querySelector("app-toolbar").style.background = "transparent";
+ function countMatches(conditions, user_name) {
+ const userVars = {
+ user: user_name,
+ user_agent: navigator.userAgent
+ };
+ let count = 0;
+ for (const cond in conditions) {
+ if (cond == "user" && conditions[cond].includes(",")) {
+ conditions[cond].split(/[ ,]+/).forEach(user => {
+ if (userVars[cond] == user) count++;
+ });
+ } else {
+ if (
+ userVars[cond] == conditions[cond] ||
+ (cond == "query_string" &&
+ window.location.search.includes(conditions[cond])) ||
+ (cond == "user_agent" &&
+ userVars[cond].includes(conditions[cond])) ||
+ (cond == "media_query" &&
+ window.matchMedia(conditions[cond]).matches)
+ ) {
+ count++;
+ } else {
+ return 0;
+ }
+ }
+ }
+ return count;
+ }
}
- if (newSidebar && cchConfig.compact_header) {
- let sidebar = main.shadowRoot.querySelector("ha-sidebar").shadowRoot;
- sidebar.querySelector(".menu").style = "height:49px;";
- sidebar.querySelector("paper-listbox").style = "height:calc(100% - 180px);";
- }
- let indicator = cchConfig.tab_indicator_color;
- if (
- indicator &&
- !root.querySelector('[id="cch_header_colors"]') &&
- !editMode
- ) {
- let style = document.createElement("style");
- style.setAttribute("id", "cch_header_colors");
- style.innerHTML = `
- paper-tabs {
- ${
- indicator
- ? `--paper-tabs-selection-bar-color: ${indicator} !important`
- : "var(--cch-tab-indicator-color) !important"
+ observers(tabContainer, tabs, disabled) {
+ // Watch for changes in Lovelace.
+ const callback = mutations => {
+ // Theme changed.
+ if (mutations[0].target.nodeName == "HTML") {
+ mutations = [mutations[0]];
+ this.styleHeader(tabContainer, tabs);
+ this.conditionalStyling(tabs);
+ return;
+ }
+ mutations.forEach(({ addedNodes, target }) => {
+ if (addedNodes.length && target.nodeName == "PARTIAL-PANEL-RESOLVER") {
+ // Navigated back to lovelace from elsewhere in HA.
+ this.buttons = this.getButtonElements();
+ this.run();
+ } else if (target.className == "edit-mode" && addedNodes.length) {
+ // Entered edit mode.
+ this.editMode = true;
+ if (!disabled) this.removeStyles(tabContainer, tabs, this.header);
+ this.buttons.options = this.root.querySelector("paper-menu-button");
+ this.insertEditMenu(tabs);
+ this.fireEvent(this.header, "iron-resize");
+ } else if (target.nodeName == "APP-HEADER" && addedNodes.length) {
+ // Exited edit mode.
+ let editor = this.root
+ .querySelector("ha-app-layout")
+ .querySelector("editor");
+ if (editor) {
+ this.root.querySelector("ha-app-layout").removeChild(editor);
+ }
+ for (let node of addedNodes) {
+ if (node.nodeName == "APP-TOOLBAR") {
+ this.editMode = false;
+ this.buttons = this.getButtonElements();
+ this.root.querySelectorAll("[id^='cch']").forEach(style => {
+ style.remove();
+ });
+ setTimeout(() => {
+ this.run();
+ if (!disabled) this.conditionalStyling(tabs, this.header);
+ }, 100);
}
}
- `;
- root.appendChild(style);
+ } else if (
+ // Viewing unused entities
+ this.frontendVersion < 20190911 &&
+ addedNodes.length &&
+ !addedNodes[0].nodeName == "HUI-UNUSED-ENTITIES"
+ ) {
+ let editor = this.root
+ .querySelector("ha-app-layout")
+ .querySelector("editor");
+ if (editor) {
+ this.root.querySelector("ha-app-layout").removeChild(editor);
+ }
+ if (this.cchConfig.conditional_styles) {
+ this.buttons = this.getButtonElements(tabContainer);
+ this.conditionalStyling(tabs, this.header);
+ }
+ } else if (target.id == "view" && addedNodes.length) {
+ // Navigating to new tab/view.
+ this.run();
+ if (tabContainer) this.scrollTabIconIntoView();
+ }
+ });
+ };
+ let observer = new MutationObserver(callback);
+ observer.observe(this.panelResolver, { childList: true });
+ observer.observe(document.querySelector("html"), { attributes: true });
+ observer.observe(this.view, { childList: true });
+ observer.observe(this.root.querySelector("app-header"), {
+ childList: true
+ });
+
+ if (!disabled) {
+ // Watch for changes in entities.
+ window.hassConnection.then(({ conn }) => {
+ conn.socket.onmessage = () => {
+ if (this.cchConfig.conditional_styles && !this.editMode) {
+ this.conditionalStyling(tabs, this.header);
+ }
+ };
+ });
+ }
}
- let conditionalTabs = cchConfig.conditional_styles
- ? JSON.stringify(cchConfig.conditional_styles).includes("tab")
- : false;
- if (
- !root.querySelector('[id="cch_iron_selected"]') &&
- !editMode &&
- !conditionalTabs &&
- tabContainer
- ) {
- let style = document.createElement("style");
- style.setAttribute("id", "cch_iron_selected");
- style.innerHTML = `
- .iron-selected {
+ getButtonElements(disabled) {
+ let buttons = {};
+ buttons.options = this.root.querySelector("paper-menu-button");
+ if (!this.editMode) {
+ buttons.menu = this.root.querySelector("ha-menu-button");
+ buttons.voice =
+ this.root.querySelector("ha-start-voice-button") ||
+ this.root.querySelector('[icon="hass:microphone"]');
+ if (!this.newSidebar) {
+ buttons.notifications = this.root.querySelector(
+ "hui-notifications-button"
+ );
+ }
+ }
+ // Remove space taken up by "hidden" menu button anytime we get buttons.
+ if (
+ buttons.menu &&
+ buttons.menu.style.visibility == "hidden" &&
+ !disabled
+ ) {
+ buttons.menu.style.display = "none";
+ } else if (buttons.menu) {
+ buttons.menu.style.display = "";
+ }
+ return buttons;
+ }
+
+ tabContainerMargin(tabContainer) {
+ let marginRight = 0;
+ let marginLeft = 15;
+ for (const button in this.buttons) {
+ if (!this.buttons[button]) continue;
+ let paperIconButton =
+ this.buttons[button].querySelector("paper-icon-button") ||
+ this.buttons[button].shadowRoot.querySelector("paper-icon-button");
+ let visible = paperIconButton
+ ? this.buttons[button].style.display !== "none" &&
+ !paperIconButton.hasAttribute("hidden")
+ : this.buttons[button].style.display !== "none";
+ if (this.cchConfig[button] == "show" && visible) {
+ if (button == "menu") marginLeft += 45;
+ else marginRight += 45;
+ } else if (this.cchConfig[button] == "clock" && visible) {
+ const clockWidth =
+ (this.cchConfig.clock_format == 12 && this.cchConfig.clock_am_pm) ||
+ this.cchConfig.clock_date
+ ? 110
+ : 80;
+ if (button == "menu") marginLeft += clockWidth + 15;
+ else marginRight += clockWidth;
+ }
+ }
+ if (tabContainer) {
+ tabContainer.style.marginRight = `${marginRight}px`;
+ tabContainer.style.marginLeft = `${marginLeft}px`;
+ }
+ }
+
+ scrollTabIconIntoView() {
+ let paperTabs = this.root.querySelector("paper-tabs");
+ let currentTab = paperTabs.querySelector(".iron-selected");
+ if (!paperTabs || !currentTab) return;
+ let tab = currentTab.getBoundingClientRect();
+ let container = paperTabs.shadowRoot
+ .querySelector("#tabsContainer")
+ .getBoundingClientRect();
+ // If tab's icon isn't in view scroll it in.
+ if (container.right < tab.right || container.left > tab.left) {
+ if ("scrollMarginInline" in document.documentElement.style) {
+ currentTab.scrollIntoView({ inline: "center" });
+ } else if (Element.prototype.scrollIntoViewIfNeeded) {
+ currentTab.scrollIntoViewIfNeeded(true);
+ } else {
+ currentTab.scrollIntoView();
+ }
+ }
+ }
+
+ hideMenuItems() {
+ // Hide items in options menu.
+ if (
+ this.cchConfig.hide_help ||
+ this.cchConfig.hide_config ||
+ this.cchConfig.hide_unused
+ ) {
+ const localized = (item, string) => {
+ let localString = this.hass.localize(
+ `ui.panel.lovelace.menu.${string}`
+ );
+ return (
+ item.innerHTML.includes(localString) ||
+ item.getAttribute("aria-label") == localString
+ );
+ };
+ this.buttons.options
+ .querySelector("paper-listbox")
+ .querySelectorAll("paper-item")
+ .forEach(item => {
+ if (
+ (this.cchConfig.hide_help && localized(item, "help")) ||
+ (this.cchConfig.hide_unused &&
+ localized(item, "unused_entities")) ||
+ (this.cchConfig.hide_config && localized(item, "configure_ui"))
+ ) {
+ item.parentNode.removeChild(item);
+ }
+ });
+ }
+ }
+
+ insertEditMenu(tabs, disabled) {
+ if (
+ this.buttons.options &&
+ (this.editMode ||
+ (this.lovelace.mode == "yaml" && this.cchConfig.yaml_editor))
+ ) {
+ // If any tabs are hidden, add "show all tabs" option.
+ if (this.cchConfig.hide_tabs && !this.cchConfig.edit_mode_show_tabs) {
+ let show_tabs = document.createElement("paper-item");
+ show_tabs.setAttribute("id", "show_tabs");
+ show_tabs.addEventListener("click", () => {
+ for (let i = 0; i < tabs.length; i++) {
+ tabs[i].style.removeProperty("display");
+ }
+ });
+ show_tabs.innerHTML = "Show all tabs";
+ this.insertMenuItem(
+ this.buttons.options.querySelector("paper-listbox"),
+ show_tabs
+ );
+ }
+
+ // Add menu item to open CCH settings.
+ let cchSettings = document.createElement("paper-item");
+ cchSettings.setAttribute("id", "cch_settings");
+ cchSettings.addEventListener("click", () => this.showEditor());
+ cchSettings.innerHTML = "CCH Settings";
+ this.insertMenuItem(
+ this.buttons.options.querySelector("paper-listbox"),
+ cchSettings
+ );
+ if (!disabled) this.hideMenuItems();
+ }
+ }
+
+ removeStyles(tabContainer, tabs, { style }) {
+ this.root.querySelector("app-header").style.backgroundColor = "#455a64";
+ this.root.querySelectorAll("[id^='cch']").forEach(style => {
+ style.remove();
+ });
+ if (this.cchConfig.tab_css) {
+ for (let [key, value] of Object.entries(this.cchConfig.tab_css)) {
+ key = this.getViewIndex(key);
+ value = value.replace(/: /g, ":").replace(/; /g, ";");
+ let css = tabs[key].style.cssText
+ .replace(/: /g, ":")
+ .replace(/; /g, ";");
+ tabs[key].style.cssText = css.replace(value, "");
+ }
+ }
+ if (this.cchConfig.header_css) {
+ let value = this.cchConfig.header_css
+ .replace(/: /g, ":")
+ .replace(/; /g, ";");
+ let css = style.cssText.replace(/: /g, ":").replace(/; /g, ";");
+ style.cssText = css.replace(value, "");
+ }
+ if (tabContainer) {
+ tabContainer.style.marginLeft = "";
+ tabContainer.style.marginRight = "";
+ }
+ this.view.style = "";
+ for (let i = 0; i < tabs.length; i++) {
+ tabs[i].style.color = "";
+ }
+ if (this.cchConfig.edit_mode_show_tabs) {
+ for (let i = 0; i < tabs.length; i++) {
+ tabs[i].style.removeProperty("display");
+ }
+ }
+ let viewStyle = document.createElement("style");
+ viewStyle.setAttribute("id", "cch_view_styling");
+ viewStyle.innerHTML = `
+ hui-view {
+ min-height: 100vh;
+ }
+ hui-panel-view {
+ min-height: calc(100vh - 52px);
+ }
+ `;
+ this.root.appendChild(viewStyle);
+ }
+
+ styleHeader(tabContainer, tabs) {
+ // Fix for old background config option.
+ if (typeof this.cchConfig.background == "boolean") {
+ this.cchConfig.background = "";
+ }
+ this.prevColor.background =
+ this.cchConfig.background ||
+ getComputedStyle(document.body).getPropertyValue("--cch-background") ||
+ getComputedStyle(document.body).getPropertyValue("--primary-color");
+ let statusBarColor =
+ this.cchConfig.statusbar_color || this.prevColor.background;
+ // Match mobile status bar color to header color.
+ let themeColor = document.querySelector('[name="theme-color"]');
+ let themeColorApple =
+ document.querySelector(
+ '[name="apple-mobile-web-app-status-bar-style"]'
+ ) || document.createElement("meta");
+ colorStatusBar(statusBarColor);
+ // If browser is idle or in background sometimes theme-color needs reset.
+ let observeStatus = new MutationObserver(() => {
+ if (themeColor.content != statusBarColor) colorStatusBar(statusBarColor);
+ });
+ if (this.firstRun) {
+ observeStatus.observe(themeColor, {
+ attributes: true,
+ attributeFilter: ["content"]
+ });
+ }
+
+ // Adjust view size & padding for new header size.
+ if (!this.cchConfig.header || this.cchConfig.kiosk_mode) {
+ this.header.style.display = "none";
+ this.view.style.minHeight = "100vh";
+ if (
+ this.frontendVersion >= 20190911 &&
+ !this.root.querySelector("#cch_view_styling")
+ ) {
+ let viewStyle = document.createElement("style");
+ viewStyle.setAttribute("id", "cch_view_styling");
+ viewStyle.innerHTML = `
+ hui-view {
+ ${this.cchConfig.view_css ? this.cchConfig.view_css : ""}
+ }
+ hui-panel-view {
+ ${this.cchConfig.view_css ? this.cchConfig.view_css : ""}
+ }
+ `;
+ this.root.appendChild(viewStyle);
+ }
+ } else {
+ this.view.style.minHeight = "100vh";
+ this.view.style.marginTop = "-48.5px";
+ this.view.style.paddingTop = "48.5px";
+ this.view.style.boxSizing = "border-box";
+ this.header.style.background = this.prevColor.background;
+ this.conditionalStyling(tabs, this.header);
+ this.header.querySelector("app-toolbar").style.background = "transparent";
+ if (
+ this.frontendVersion >= 20190911 &&
+ !this.root.querySelector("#cch_view_styling")
+ ) {
+ let viewStyle = document.createElement("style");
+ viewStyle.setAttribute("id", "cch_view_styling");
+ viewStyle.innerHTML = `
+ hui-view {
+ margin-top: -48.5px;
+ padding-top: 52px;
+ min-height: 100vh;
+ ${this.cchConfig.view_css ? this.cchConfig.view_css : ""}
+ }
+ hui-panel-view {
+ margin-top: -52px;
+ padding-top: 52px;
+ min-height: calc(100vh - 52px);
+ ${this.cchConfig.view_css ? this.cchConfig.view_css : ""}
+ }
+ `;
+ this.root.appendChild(viewStyle);
+ }
+ }
+
+ // Match sidebar elements to header's size.
+ if (this.newSidebar && this.cchConfig.compact_header) {
+ let sidebar = this.main.shadowRoot.querySelector("ha-sidebar").shadowRoot;
+ sidebar.querySelector(".menu").style = "height:49px;";
+ sidebar.querySelector("paper-listbox").style =
+ "height:calc(100% - 180px);";
+ }
+
+ // Current tab icon color.
+ let conditionalTabs = this.cchConfig.conditional_styles
+ ? JSON.stringify(this.cchConfig.conditional_styles).includes("tab")
+ : false;
+ if (
+ !this.root.querySelector("#cch_iron_selected") &&
+ !this.editMode &&
+ !conditionalTabs &&
+ tabContainer
+ ) {
+ let style = document.createElement("style");
+ style.setAttribute("id", "cch_iron_selected");
+ style.innerHTML = `
+ .iron-selected {
+ ${
+ this.cchConfig.active_tab_color
+ ? `color: ${`${
+ this.cchConfig.active_tab_color
+ } !important`}`
+ : "var(--cch-active-tab-color)"
+ }
+ }
+ `;
+ tabContainer.appendChild(style);
+ }
+
+ // Style current tab indicator.
+ let indicator = this.cchConfig.tab_indicator_color;
+ if (
+ indicator &&
+ !this.root.querySelector("#cch_header_colors") &&
+ !this.editMode
+ ) {
+ let style = document.createElement("style");
+ style.setAttribute("id", "cch_header_colors");
+ style.innerHTML = `
+ paper-tabs {
${
- cchConfig.active_tab_color
- ? `color: ${cchConfig.active_tab_color + " !important"}`
- : "var(--cch-active-tab-color)"
+ indicator
+ ? `--paper-tabs-selection-bar-color: ${indicator} !important`
+ : "var(--cch-tab-indicator-color) !important"
}
}
`;
- tabContainer.appendChild(style);
- }
- let all_tabs_color = cchConfig.all_tabs_color || "var(--cch-all-tabs-color)";
- if (
- (cchConfig.tab_color && Object.keys(cchConfig.tab_color).length) ||
- all_tabs_color
- ) {
- for (let i = 0; i < tabs.length; i++) {
- tabs[i].style.color = cchConfig.tab_color[i] || all_tabs_color;
+ this.root.appendChild(style);
+ }
+
+ // Tab's icon color.
+ let all_tabs_color =
+ this.cchConfig.all_tabs_color || "var(--cch-all-tabs-color)";
+ if (
+ (this.cchConfig.tab_color &&
+ Object.keys(this.cchConfig.tab_color).length) ||
+ all_tabs_color
+ ) {
+ for (let i = 0; i < tabs.length; i++) {
+ tabs[i].style.color = this.cchConfig.tab_color[i] || all_tabs_color;
+ }
+ }
+
+ // Add custom css.
+ if (this.cchConfig.tab_css) {
+ for (let [key, value] of Object.entries(this.cchConfig.tab_css)) {
+ key = this.getViewIndex(key);
+ if (tabs[key]) tabs[key].style.cssText += value;
+ }
+ }
+ if (this.cchConfig.header_css)
+ this.header.style.cssText += this.cchConfig.header_css;
+ if (this.cchConfig.view_css && this.frontendVersion < 20190911) {
+ this.view.style.cssText += this.cchConfig.view_css;
+ }
+
+ if (tabContainer) {
+ // Shift the header up to hide unused portion.
+ this.root.querySelector("app-toolbar").style.marginTop = this.cchConfig
+ .compact_header
+ ? "-64px"
+ : "";
+
+ tabs.forEach(({ style }) => {
+ style.marginTop = "-1px";
+ });
+
+ // Show/hide tab navigation chevrons.
+ if (!this.cchConfig.chevrons) {
+ let chevron = tabContainer.shadowRoot.querySelectorAll(
+ '[icon^="paper-tabs:chevron"]'
+ );
+ chevron[0].style.display = "none";
+ chevron[1].style.display = "none";
+ } else {
+ // Remove space taken up by "not-visible" chevron.
+ let style = document.createElement("style");
+ style.setAttribute("id", "cch_chevron");
+ style.innerHTML = `
+ .not-visible {
+ display:none;
+ }
+ `;
+ tabContainer.shadowRoot.appendChild(style);
+ }
+ }
+ function colorStatusBar(statusBarColor) {
+ themeColor = document.querySelector("meta[name=theme-color]");
+ themeColor.setAttribute("content", statusBarColor);
+ themeColor.setAttribute("default-content", statusBarColor);
+ if (
+ !document.querySelector(
+ '[name="apple-mobile-web-app-status-bar-style"]'
+ )
+ ) {
+ themeColorApple.name = "apple-mobile-web-app-status-bar-style";
+ themeColorApple.content = statusBarColor;
+ document.getElementsByTagName("head")[0].appendChild(themeColorApple);
+ } else {
+ themeColorApple.setAttribute("content", statusBarColor);
+ }
}
}
- if (tabContainer) {
- // Shift the header up to hide unused portion.
- root.querySelector("app-toolbar").style.marginTop = cchConfig.compact_header
- ? "-64px"
- : "";
+ styleButtons({ length }, tabContainer) {
+ let topMargin =
+ length > 0 && this.cchConfig.compact_header ? "margin-top:111px;" : "";
+ let topMarginMenu =
+ length > 0 && this.cchConfig.compact_header ? "margin-top:115px;" : "";
+ // Reverse buttons object so "menu" is first in the overflow menu.
+ this.buttons = this.reverseObject(this.buttons);
+ for (const button in this.buttons) {
+ if (!this.buttons[button]) continue;
+ if (button == "options" && this.cchConfig[button] == "overflow") {
+ this.cchConfig[button] = "show";
+ }
+ let buttonStyle = `
+ z-index:1;
+ ${
+ button == "menu"
+ ? `padding: 8px 0; margin-bottom:5px; ${topMarginMenu}`
+ : "padding: 8px;"
+ }
+ ${
+ button == "voice" && this.cchConfig["voice"] == "clock"
+ ? "width: 100px; padding:4px;"
+ : ""
+ }
+ ${button == "menu" ? "" : topMargin}
+ ${button == "options" ? "margin-right:-5px;" : ""}
+ `;
+ if (
+ this.cchConfig[button] == "show" ||
+ this.cchConfig[button] == "clock"
+ ) {
+ if (button == "menu") {
+ let paperIconButton = this.buttons[button].querySelector(
+ "paper-icon-button"
+ )
+ ? this.buttons[button].querySelector("paper-icon-button")
+ : this.buttons[button].shadowRoot.querySelector(
+ "paper-icon-button"
+ );
+ if (!paperIconButton) continue;
+ paperIconButton.style.cssText = buttonStyle;
+ } else {
+ this.buttons[button].style.cssText = buttonStyle;
+ }
+ } else if (this.cchConfig[button] == "overflow") {
+ const menu_items = this.buttons.options.querySelector("paper-listbox");
+ let paperIconButton = this.buttons[button].querySelector(
+ "paper-icon-button"
+ )
+ ? this.buttons[button].querySelector("paper-icon-button")
+ : this.buttons[button].shadowRoot.querySelector("paper-icon-button");
+ if (paperIconButton && paperIconButton.hasAttribute("hidden")) {
+ continue;
+ }
+ const id = `menu_item_${button}`;
+ if (!menu_items.querySelector(`#${id}`)) {
+ const wrapper = document.createElement("paper-item");
+ wrapper.setAttribute("id", id);
+ wrapper.innerText = this.getTranslation(button);
+ wrapper.appendChild(this.buttons[button]);
+ wrapper.addEventListener("click", () => {
+ paperIconButton.click();
+ });
+ paperIconButton.style.pointerEvents = "none";
+ this.insertMenuItem(menu_items, wrapper);
+ if (button == "notifications" && !this.newSidebar) {
+ let style = document.createElement("style");
+ style.innerHTML = `
+ .indicator {
+ top: 5px;
+ right: 0px;
+ width: 10px;
+ height: 10px;
+ ${
+ this.cchConfig.notify_indicator_color
+ ? `background-color:${
+ this.cchConfig.notify_indicator_color
+ }`
+ : ""
+ }
+ }
+ .indicator > div{
+ display:none;
+ }
+ `;
+ paperIconButton.parentNode.appendChild(style);
+ }
+ }
+ } else if (this.cchConfig[button] == "hide") {
+ this.buttons[button].style.display = "none";
+ }
+ // Hide menu button if hiding the sidebar.
+ if (
+ this.newSidebar &&
+ (this.cchConfig.kiosk_mode || this.cchConfig.disable_sidebar)
+ ) {
+ this.buttons.menu.style.display = "none";
+ }
+ }
- if (!cchConfig.chevrons) {
- // Hide chevrons.
- let chevron = tabContainer.shadowRoot.querySelectorAll(
- '[icon^="paper-tabs:chevron"]'
- );
- chevron[0].style.display = "none";
- chevron[1].style.display = "none";
- } else {
- // Remove space taken up by "not-visible" chevron.
+ // Remove empty space taken up by hidden menu button.
+ if (this.buttons.menu && this.newSidebar && this.firstRun) {
+ new MutationObserver(() => {
+ if (this.buttons.menu.style.visibility == "hidden") {
+ this.buttons.menu.style.display = "none";
+ } else {
+ this.buttons.menu.style.display = "";
+ }
+ this.tabContainerMargin(tabContainer);
+ }).observe(this.buttons.menu, {
+ attributes: true,
+ attributeFilter: ["style"]
+ });
+ }
+
+ // Use color vars set in HA theme.
+ this.buttons.menu.style.color = "var(--cch-button-color-menu)";
+ if (!this.newSidebar) {
+ this.buttons.notifications.style.color =
+ "var(--cch-button-color-notifications)";
+ }
+ if (this.buttons.voice) this.buttons.voice.style.color = "var(--cch-button-color-voice)";
+ this.buttons.options.style.color = "var(--cch-button-color-options)";
+ if (this.cchConfig.all_buttons_color) {
+ this.root.querySelector("app-toolbar").style.color =
+ this.cchConfig.all_buttons_color || "var(--cch-all-buttons-color)";
+ }
+
+ // Use colors set in CCH config.
+ for (const button in this.buttons) {
+ if (this.cchConfig.button_color[button]) {
+ this.buttons[button].style.color = this.cchConfig.button_color[button];
+ }
+ }
+
+ // Notification indicator's color for HA 0.96 and above.
+ if (
+ this.newSidebar &&
+ this.cchConfig.menu != "hide" &&
+ !this.buttons.menu.shadowRoot.querySelector("#cch_dot")
+ ) {
let style = document.createElement("style");
- style.setAttribute("id", "cch_chevron");
+ style.setAttribute("id", "cch_dot");
+ let indicator =
+ this.cchConfig.notify_indicator_color ||
+ getComputedStyle(this.header).getPropertyValue(
+ "--cch-tab-indicator-color"
+ ) ||
+ "";
+ let border = getComputedStyle(this.header)
+ .getPropertyValue("background")
+ .includes("url")
+ ? "border-color: transparent !important"
+ : `border-color: ${getComputedStyle(this.header).getPropertyValue(
+ "background-color"
+ )} !important;`;
style.innerHTML = `
- .not-visible {
+ .dot {
+ ${topMargin}
+ z-index: 2;
+ ${indicator ? `background: ${indicator} !important` : ""}
+ ${border}
+ }
+ `;
+ this.buttons.menu.shadowRoot.appendChild(style);
+ } else if (
+ // Notification indicator's color for HA 0.95 and below.
+ this.cchConfig.notify_indicator_color &&
+ this.cchConfig.notifications == "show" &&
+ !this.newSidebar
+ ) {
+ let style = document.createElement("style");
+ style.innerHTML = `
+ .indicator {
+ background-color:${this.cchConfig.notify_indicator_color ||
+ "var(--cch-notify-indicator-color)"} !important;
+ color: ${this.cchConfig.notify_text_color ||
+ "var(--cch-notify-text-color), var(--primary-text-color)"};
+ }
+ `;
+ this.buttons.notifications.shadowRoot.appendChild(style);
+ }
+
+ // Add buttons's custom css.
+ let buttonCss = this.cchConfig.button_css;
+ if (buttonCss) {
+ for (const [key, value] of Object.entries(buttonCss)) {
+ if (!this.buttons[key]) {
+ continue;
+ } else {
+ this.buttons[key].style.cssText += value;
+ }
+ }
+ }
+ }
+
+ getTranslation(button) {
+ switch (button) {
+ case "notifications":
+ return this.hass.localize("ui.notification_drawer.title");
+ default:
+ return button.charAt(0).toUpperCase() + button.slice(1);
+ }
+ }
+
+ defaultTab(tabs, tabContainer) {
+ let firstTab = tabs.indexOf(tabs.filter(tab => tab.style.display == "")[0]);
+ let default_tab = this.cchConfig.default_tab;
+ if (typeof default_tab == "object" && !default_tab.length) return;
+ let template = this.cchConfig.default_tab_template;
+ if ((default_tab || template) && tabContainer) {
+ if (template) default_tab = this.templateEval(template, this.hass.states);
+ default_tab = this.getViewIndex(default_tab);
+ let activeTab = tabs.indexOf(
+ tabContainer.querySelector(".iron-selected")
+ );
+ if (
+ activeTab != default_tab &&
+ activeTab == firstTab &&
+ (!this.cchConfig.redirect ||
+ (this.cchConfig.redirect &&
+ tabs[default_tab].style.display != "none"))
+ ) {
+ tabs[default_tab].click();
+ }
+ }
+ }
+
+ sidebarMod() {
+ let menu = this.buttons.menu.querySelector("paper-icon-button");
+ let sidebar = this.main.shadowRoot.querySelector("app-drawer");
+
+ // HA 0.95 and below
+ if (!this.newSidebar) {
+ if (!this.cchConfig.sidebar_swipe || this.cchConfig.kiosk_mode) {
+ sidebar.removeAttribute("swipe-open");
+ }
+ if (
+ (this.cchConfig.sidebar_closed || this.cchConfig.kiosk_mode) &&
+ !this.sidebarClosed
+ ) {
+ if (sidebar.hasAttribute("opened")) menu.click();
+ this.sidebarClosed = true;
+ }
+ // HA 0.96 and above
+ } else if (this.cchConfig.disable_sidebar || this.cchConfig.kiosk_mode) {
+ sidebar.style.display = "none";
+ sidebar.addEventListener(
+ "mouseenter",
+ event => {
+ event.stopPropagation();
+ },
+ true
+ );
+ let style = document.createElement("style");
+ style.type = "text/css";
+ style.appendChild(
+ document.createTextNode(
+ ":host(:not([expanded])) {width: 0px !important;}"
+ )
+ );
+ this.main.shadowRoot
+ .querySelector("ha-sidebar")
+ .shadowRoot.appendChild(style);
+
+ style = document.createElement("style");
+ style.type = "text/css";
+ style.appendChild(
+ document.createTextNode(":host {--app-drawer-width: 0px !important;}")
+ );
+ this.main.shadowRoot.appendChild(style);
+ }
+ }
+
+ hideTabs(tabContainer, tabs) {
+ let hidden_tabs = String(this.cchConfig.hide_tabs).length
+ ? String(this.cchConfig.hide_tabs)
+ .replace(/\s+/g, "")
+ .split(",")
+ : null;
+ let shown_tabs = String(this.cchConfig.show_tabs).length
+ ? String(this.cchConfig.show_tabs)
+ .replace(/\s+/g, "")
+ .split(",")
+ : null;
+
+ // Set the tab config source.
+ if (!hidden_tabs && shown_tabs) {
+ let all_tabs = [];
+ shown_tabs = this.buildRanges(shown_tabs);
+ for (let i = 0; i < tabs.length; i++) all_tabs.push(i);
+ // Invert shown_tabs to hidden_tabs.
+ hidden_tabs = all_tabs.filter(el => !shown_tabs.includes(el));
+ } else {
+ hidden_tabs = this.buildRanges(hidden_tabs);
+ }
+
+ // Hide tabs.
+ for (const tab of hidden_tabs) {
+ if (!tabs[tab]) continue;
+ tabs[tab].style.display = "none";
+ }
+
+ if (this.cchConfig.redirect && tabContainer) {
+ const activeTab = tabContainer.querySelector("paper-tab.iron-selected");
+ const activeTabIndex = tabs.indexOf(activeTab);
+ // Is the current tab hidden and is there at least one tab is visible.
+ if (
+ hidden_tabs.includes(activeTabIndex) &&
+ hidden_tabs.length != tabs.length
+ ) {
+ let i = 0;
+ // Find the first visible tab and navigate.
+ while (hidden_tabs.includes(i)) {
+ i++;
+ }
+ tabs[i].click();
+ }
+ }
+ return hidden_tabs;
+ }
+
+ insertMenuItem(menu_items, element) {
+ let first_item = menu_items.querySelector("paper-item");
+ if (!menu_items.querySelector(`#${element.id}`)) {
+ first_item.parentNode.insertBefore(element, first_item);
+ }
+ }
+
+ insertClock(button) {
+ if (!this.buttons[button]) return;
+ const clock_button = this.buttons[button].querySelector("paper-icon-button")
+ ? this.buttons[button]
+ : this.buttons[button].shadowRoot;
+ const clockIcon =
+ clock_button.querySelector("paper-icon-button") || this.buttons[button];
+ const clockIronIcon =
+ clockIcon.querySelector("iron-icon") ||
+ clockIcon.shadowRoot.querySelector("iron-icon");
+ const clockWidth =
+ (this.cchConfig.clock_format == 12 && this.cchConfig.clock_am_pm) ||
+ this.cchConfig.clock_date
+ ? 105
+ : 80;
+
+ if (
+ !this.newSidebar &&
+ this.cchConfig.notifications == "clock" &&
+ this.cchConfig.clock_date &&
+ !this.buttons.notifications.shadowRoot.querySelector("#cch_indicator")
+ ) {
+ let style = document.createElement("style");
+ style.setAttribute("id", "cch_indicator");
+ style.innerHTML = `
+ .indicator {
+ top: unset;
+ bottom: -3px;
+ right: 0px;
+ width: 90%;
+ height: 3px;
+ border-radius: 0;
+ ${
+ this.cchConfig.notify_indicator_color
+ ? `background-color:${this.cchConfig.notify_indicator_color}`
+ : ""
+ }
+ }
+ .indicator > div{
display:none;
}
`;
- tabContainer.shadowRoot.appendChild(style);
+ this.buttons.notifications.shadowRoot.appendChild(style);
}
- }
-}
-function styleButtons(tabs) {
- let topMargin =
- tabs.length > 0 && cchConfig.compact_header ? "margin-top:111px;" : "";
- buttons = reverseObject(buttons);
- if (
- newSidebar &&
- cchConfig.menu != "hide" &&
- !buttons.menu.shadowRoot.querySelector('[id="cch_dot"]')
- ) {
- let style = document.createElement("style");
- style.setAttribute("id", "cch_dot");
- let indicator =
- cchConfig.notify_indicator_color ||
- getComputedStyle(header).getPropertyValue("--cch-tab-indicator-color") ||
- "";
- let border = getComputedStyle(header)
- .getPropertyValue("background")
- .includes("url")
- ? "border-color: transparent !important"
- : `border-color: ${getComputedStyle(header).getPropertyValue(
- "background-color"
- )} !important;`;
- style.innerHTML = `
- .dot {
- ${topMargin}
- z-index: 2;
- ${indicator ? `background: ${indicator} !important` : ""}
- ${border}
- }
- `;
- buttons.menu.shadowRoot.appendChild(style);
- }
- for (const button in buttons) {
- if (!buttons[button]) continue;
- if (button == "options" && cchConfig[button] == "overflow") {
- cchConfig[button] = "show";
+ let clockElement = clockIronIcon.parentNode.getElementById("cch_clock");
+ if (this.cchConfig.menu == "clock") {
+ this.buttons.menu.style.marginTop = this.cchConfig.compact_header
+ ? "111px"
+ : "";
+ this.buttons.menu.style.zIndex = "1";
}
- if (cchConfig[button] == "show" || cchConfig[button] == "clock") {
- if (button == "menu") {
- let paperIconButton = buttons[button].querySelector("paper-icon-button")
- ? buttons[button].querySelector("paper-icon-button")
- : buttons[button].shadowRoot.querySelector("paper-icon-button");
- if (!paperIconButton) continue;
- paperIconButton.style.cssText = `
- z-index:1;
- ${topMargin}
- ${button == "options" ? "margin-right:-5px; padding:0;" : ""}
- `;
- } else {
- buttons[button].style.cssText = `
- z-index:1;
- ${topMargin}
- ${button == "options" ? "margin-right:-5px; padding:0;" : ""}
- `;
- }
- } else if (cchConfig[button] == "overflow") {
- const menu_items = buttons.options.querySelector("paper-listbox");
- let paperIconButton = buttons[button].querySelector("paper-icon-button")
- ? buttons[button].querySelector("paper-icon-button")
- : buttons[button].shadowRoot.querySelector("paper-icon-button");
- if (paperIconButton.hasAttribute("hidden")) {
- continue;
- }
- const id = `menu_item_${button}`;
- if (!menu_items.querySelector(`[id="${id}"]`)) {
- const wrapper = document.createElement("paper-item");
- wrapper.setAttribute("id", id);
- wrapper.innerText = getTranslation(button);
- wrapper.appendChild(buttons[button]);
- wrapper.addEventListener("click", () => {
- paperIconButton.click();
- });
- paperIconButton.style.pointerEvents = "none";
- insertMenuItem(menu_items, wrapper);
- if (button == "notifications" && !newSidebar) {
- let style = document.createElement("style");
- style.innerHTML = `
- .indicator {
- top: 5px;
- right: 0px;
- width: 10px;
- height: 10px;
- ${
- cchConfig.notify_indicator_color
- ? `background-color:${cchConfig.notify_indicator_color}`
- : ""
- }
- }
- .indicator > div{
- display:none;
- }
+ if (!clockElement) {
+ clockIcon.style.cssText = `
+ margin-right:-5px;
+ width:${clockWidth}px;
+ text-align: center;
`;
- paperIconButton.parentNode.appendChild(style);
+ clockElement = document.createElement("p");
+ clockElement.setAttribute("id", "cch_clock");
+ let clockAlign = "center";
+ let padding = "";
+ let fontSize = "";
+ if (this.cchConfig.clock_date && this.cchConfig.menu == "clock") {
+ clockAlign = "left";
+ padding = "margin-right:-20px";
+ fontSize = "font-size:12pt";
+ } else if (this.cchConfig.clock_date) {
+ clockAlign = "right";
+ padding = "margin-left:-20px";
+ fontSize = "font-size:12pt";
+ }
+ clockElement.style.cssText = `
+ margin-top: ${this.cchConfig.clock_date ? "-4px" : "2px"};
+ text-align: ${clockAlign};
+ ${padding};
+ ${fontSize};
+ `;
+ clockIronIcon.parentNode.insertBefore(clockElement, clockIronIcon);
+ clockIronIcon.style.display = "none";
+ let style = document.createElement("style");
+ style.setAttribute("id", "cch_clock");
+ style.innerHTML = `
+ time {
+ ${this.cchConfig.time_css}
+ }
+ date {
+ ${this.cchConfig.date_css}
+ }
+ `;
+ clockIronIcon.parentNode.insertBefore(style, clockIronIcon);
+ }
+
+ const clockFormat = {
+ hour12: this.cchConfig.clock_format != 24,
+ hour: "2-digit",
+ minute: "2-digit"
+ };
+ this.updateClock(clockElement, clockFormat);
+ }
+
+ updateClock(clock, clockFormat) {
+ let date = new Date();
+ let seconds = date.getSeconds();
+ let locale = this.cchConfig.date_locale || this.hass.language;
+ let time = date.toLocaleTimeString([], clockFormat);
+ let options = {
+ weekday: "short",
+ month: "2-digit",
+ day: "2-digit"
+ };
+ date = this.cchConfig.clock_date
+ ? `${date.toLocaleDateString(locale, options)}`
+ : "";
+ if (!this.cchConfig.clock_am_pm && this.cchConfig.clock_format == 12) {
+ clock.innerHTML = `${date}`;
+ } else {
+ clock.innerHTML = `${date}`;
+ }
+ window.setTimeout(() => {
+ this.updateClock(clock, clockFormat);
+ }, (60 - seconds) * 1000);
+ }
+
+ // Abandon all hope, ye who enter here.
+ conditionalStyling(tabs) {
+ let _hass = document.querySelector("home-assistant").hass;
+ const conditional_styles = this.cchConfig.conditional_styles;
+ let tabContainer = tabs[0] ? tabs[0].parentNode : "";
+ let styling = [];
+
+ if (Array.isArray(conditional_styles)) {
+ for (let i = 0; i < conditional_styles.length; i++) {
+ styling.push(Object.assign({}, conditional_styles[i]));
+ }
+ } else {
+ styling.push(Object.assign({}, conditional_styles));
+ }
+
+ function exists(configItem) {
+ return configItem !== undefined && configItem !== null;
+ }
+
+ function notificationCount() {
+ if (this.newSidebar) {
+ let badge = this.main.shadowRoot
+ .querySelector("ha-sidebar")
+ .shadowRoot.querySelector("span.notification-badge");
+ if (!badge) return 0;
+ else return parseInt(badge.innerHTML);
+ }
+ let i = 0;
+ let drawer = this.root
+ .querySelector("hui-notification-drawer")
+ .shadowRoot.querySelector(".notifications");
+ for (let notification of drawer.querySelectorAll(".notification")) {
+ if (notification.style.display !== "none") i++;
+ }
+ return i;
+ }
+
+ for (let i = 0; i < styling.length; i++) {
+ let template = styling[i].template;
+ let condition = styling[i].condition;
+
+ if (template) {
+ if (!template.length) template = [template];
+ template.forEach(template => {
+ this.templates(template, tabs, _hass, this.header);
+ });
+ } else if (condition) {
+ let entity = styling[i].entity;
+ if (_hass.states[entity] == undefined && entity !== "notifications") {
+ console.log(`CCH conditional styling: ${entity} does not exist.`);
+ continue;
+ }
+ let entState =
+ entity == "notifications"
+ ? notificationCount()
+ : _hass.states[entity].state;
+ let condState = condition.state;
+ let above = condition.above;
+ let below = condition.below;
+
+ let toStyle =
+ (exists(condState) && entState == condState) ||
+ (exists(above) &&
+ exists(below) &&
+ entState > above &&
+ entState < below) ||
+ (exists(above) && entState > above) ||
+ (exists(below) && entState < below);
+
+ let tabIndex = styling[i].tab ? Object.keys(styling[i].tab)[0] : null;
+ let tabCondition = styling[i].tab ? styling[i].tab[tabIndex] : null;
+ let tabElem = tabs[this.getViewIndex(tabIndex)];
+ let tabkey = `tab_${this.getViewIndex(tabIndex)}`;
+ let button = styling[i].button
+ ? Object.keys(styling[i].button)[0]
+ : null;
+ let background = styling[i].background;
+
+ // Conditionally style tabs.
+ if (toStyle && exists(tabIndex) && tabElem) {
+ if (tabCondition.hide) tabElem.style.display = "none";
+ if (tabCondition.color) {
+ if (this.prevColor[tabkey] == undefined) {
+ Object.assign(this.prevColor, {
+ [tabkey]: window
+ .getComputedStyle(tabElem, null)
+ .getPropertyValue("color")
+ });
+ }
+ tabElem.style.color = tabCondition.color;
+ }
+ if (tabCondition.on_icon) {
+ tabElem
+ .querySelector("ha-icon")
+ .setAttribute("icon", tabCondition.on_icon);
+ }
+ } else if (!toStyle && exists(tabIndex) && tabElem) {
+ if (tabCondition.hide) {
+ tabElem.style.display = "";
+ }
+ if (tabCondition.color && this.prevColor[tabkey]) {
+ tabElem.style.color = this.prevColor[tabkey];
+ }
+ if (tabCondition.off_icon) {
+ tabElem
+ .querySelector("ha-icon")
+ .setAttribute("icon", tabCondition.off_icon);
+ }
+ }
+
+ if (toStyle && button) {
+ if (!this.buttons[button]) continue;
+ let buttonCondition = styling[i].button[button];
+ let buttonElem = this.buttons[button].querySelector(
+ "paper-icon-button"
+ )
+ ? this.buttons[button].querySelector("paper-icon-button")
+ : this.buttons[button].shadowRoot.querySelector(
+ "paper-icon-button"
+ );
+ if (buttonCondition.hide) {
+ buttonElem.style.display = "none";
+ }
+ if (buttonCondition.color) {
+ if (this.prevColor.button == undefined) this.prevColor.button = {};
+ if (this.prevColor.button[button] == undefined) {
+ this.prevColor.button[button] = window
+ .getComputedStyle(buttonElem, null)
+ .getPropertyValue("color");
+ }
+ buttonElem.style.color = buttonCondition.color;
+ }
+ if (buttonCondition.on_icon) {
+ let icon =
+ buttonElem.querySelector("iron-icon") ||
+ buttonElem.shadowRoot.querySelector("iron-icon");
+ icon.setAttribute("icon", buttonCondition.on_icon);
+ }
+ } else if (!toStyle && button) {
+ let buttonCondition = styling[i].button[button];
+ let buttonElem = this.buttons[button].querySelector(
+ "paper-icon-button"
+ )
+ ? this.buttons[button].querySelector("paper-icon-button")
+ : this.buttons[button].shadowRoot.querySelector(
+ "paper-icon-button"
+ );
+ if (buttonCondition.hide) {
+ buttonElem.style.display = "";
+ }
+ if (
+ buttonCondition.color &&
+ this.prevColor.button &&
+ this.prevColor.button[button]
+ ) {
+ buttonElem.style.color = this.prevColor.button[button];
+ }
+ if (buttonCondition.off_icon) {
+ let icon =
+ buttonElem.querySelector("iron-icon") ||
+ buttonElem.shadowRoot.querySelector("iron-icon");
+ icon.setAttribute("icon", buttonCondition.off_icon);
+ }
+ }
+
+ // Conditionally style background.
+ if (toStyle && background) {
+ if (this.prevColor.background == undefined) {
+ this.prevColor.background = window
+ .getComputedStyle(this.header, null)
+ .getPropertyValue("background");
+ }
+ this.header.style.background = styling[i].background;
+ } else if (!toStyle && background) {
+ this.header.style.background = this.prevColor.background;
}
}
- } else if (cchConfig[button] == "hide") {
- buttons[button].style.display = "none";
}
- if (newSidebar && (cchConfig.kiosk_mode || cchConfig.disable_sidebar)) {
- buttons.menu.style.display = "none";
+ this.tabContainerMargin(tabContainer);
+ }
+
+ templates(template, tabs, _hass, { style }) {
+ let states = _hass.states;
+ for (const condition in template) {
+ if (condition == "tab") {
+ for (const tab in template[condition]) {
+ let tempCond = template[condition][tab];
+ if (!tempCond.length) tempCond = [tempCond];
+ tempCond.forEach(templateObj => {
+ let tabIndex = this.getViewIndex(Object.keys(template[condition]));
+ let styleTarget = Object.keys(templateObj);
+ let tabTemplate = templateObj[styleTarget];
+ let tabElement = tabs[tabIndex];
+ if (styleTarget == "icon") {
+ tabElement
+ .querySelector("ha-icon")
+ .setAttribute("icon", this.templateEval(tabTemplate, states));
+ } else if (styleTarget == "color") {
+ tabElement.style.color = this.templateEval(tabTemplate, states);
+ } else if (styleTarget == "display") {
+ this.templateEval(tabTemplate, states) == "show"
+ ? (tabElement.style.display = "")
+ : (tabElement.style.display = "none");
+ }
+ });
+ }
+ } else if (condition == "button") {
+ for (const button in template[condition]) {
+ let tempCond = template[condition][button];
+ if (!tempCond.length) tempCond = [tempCond];
+ tempCond.forEach(templateObj => {
+ let buttonName = Object.keys(template[condition]);
+ if (this.newSidebar && buttonName == "notifications") return;
+ let styleTarget = Object.keys(templateObj);
+ let buttonElem = this.buttons[buttonName];
+ let tempCond = templateObj[styleTarget];
+ let iconTarget = buttonElem.querySelector("paper-icon-button")
+ ? buttonElem.querySelector("paper-icon-button")
+ : buttonElem.shadowRoot.querySelector("paper-icon-button");
+ if (styleTarget == "icon") {
+ iconTarget.setAttribute(
+ "icon",
+ this.templateEval(tempCond, states)
+ );
+ } else if (styleTarget == "color") {
+ let tar =
+ iconTarget.querySelector("iron-icon") ||
+ iconTarget.shadowRoot.querySelector("iron-icon");
+ tar.style.color = this.templateEval(tempCond, states);
+ } else if (styleTarget == "display") {
+ this.templateEval(tempCond, states) == "show"
+ ? (buttonElem.style.display = "")
+ : (buttonElem.style.display = "none");
+ }
+ });
+ }
+ } else if (condition == "background") {
+ style.background = this.templateEval(template[condition], states);
+ }
}
}
- // Use color vars set in HA theme.
- buttons.menu.style.color = "var(--cch-button-color-menu)";
- if (!newSidebar) {
- buttons.notifications.style.color = "var(--cch-button-color-notifications)";
- }
- buttons.voice.style.color = "var(--cch-button-color-voice)";
- buttons.options.style.color = "var(--cch-button-color-options)";
- if (cchConfig.all_buttons_color) {
- root.querySelector("app-toolbar").style.color =
- cchConfig.all_buttons_color || "var(--cch-all-buttons-color)";
- }
-
- // Use colors set in CCH config.
- for (const button in buttons) {
- if (cchConfig.button_color[button]) {
- buttons[button].style.color = cchConfig.button_color[button];
- }
- }
-
- if (cchConfig.notify_indicator_color && cchConfig.notifications == "show") {
- let style = document.createElement("style");
- style.innerHTML = `
- .indicator {
- background-color:${cchConfig.notify_indicator_color ||
- "var(--cch-notify-indicator-color)"} !important;
- color: ${cchConfig.notify_text_color ||
- "var(--cch-notify-text-color), var(--primary-text-color)"};
+ // Get range (e.g., "5 to 9") and build (5,6,7,8,9).
+ buildRanges(array) {
+ let ranges = [];
+ if (!array) return [];
+ const sortNumber = (a, b) => a - b;
+ const range = (start, end) =>
+ new Array(end - start + 1).fill(undefined).map((_, i) => i + start);
+ for (let i in array) {
+ if (typeof array[i] == "string" && array[i].includes("to")) {
+ let split = array[i].split("to");
+ if (parseInt(split[1]) > parseInt(split[0])) {
+ ranges.push(range(parseInt(split[0]), parseInt(split[1])));
+ } else {
+ ranges.push(range(parseInt(split[1]), parseInt(split[0])));
+ }
+ } else if (isNaN(array[i])) {
+ let views = this.lovelace.config.views;
+ for (let view in views) {
+ if (
+ views[view]["title"] == array[i] ||
+ views[view]["path"] == array[i]
+ ) {
+ ranges.push(parseInt(view));
}
- `;
- if (!newSidebar) buttons.notifications.shadowRoot.appendChild(style);
+ }
+ } else {
+ ranges.push(parseInt(array[i]));
+ }
+ }
+ return ranges.flat().sort(sortNumber);
}
-}
-function getTranslation(button) {
- switch (button) {
- case "notifications":
- return hass.localize("ui.notification_drawer.title");
- default:
- return button.charAt(0).toUpperCase() + button.slice(1);
+ showEditor() {
+ window.scrollTo(0, 0);
+ if (!this.root.querySelector("ha-app-layout editor")) {
+ const container = document.createElement("editor");
+ const nest = document.createElement("div");
+ nest.style.cssText = `
+ padding: 20px;
+ max-width: 600px;
+ margin: 15px auto;
+ background: var(--paper-card-background-color);
+ border: 6px solid var(--paper-card-background-color);
+ `;
+ container.style.cssText = `
+ width: 100%;
+ min-height: 100%;
+ box-sizing: border-box;
+ position: absolute;
+ background: var(--background-color, grey);
+ z-index: 2;
+ padding: 5px;
+ `;
+ this.root
+ .querySelector("ha-app-layout")
+ .insertBefore(container, this.view);
+ container.appendChild(nest);
+ nest.appendChild(document.createElement("compact-custom-header-editor"));
+ }
}
-}
-function defaultTab(tabs, tabContainer) {
- if (cchConfig.default_tab && !defaultTabRedirect && tabContainer) {
- let default_tab = cchConfig.default_tab;
- let activeTab = tabs.indexOf(tabContainer.querySelector(".iron-selected"));
- if (isNaN(default_tab)) {
- let views = lovelace.config.views;
+ getViewIndex(viewString) {
+ let views = this.lovelace.config.views;
+ if (isNaN(viewString)) {
for (let view in views) {
if (
- views[view]["title"] == default_tab ||
- views[view]["path"] == default_tab
+ views[view]["title"] == viewString ||
+ views[view]["path"] == viewString
) {
- default_tab = view;
+ return view;
}
}
- }
- if (
- activeTab != default_tab &&
- activeTab == 0 &&
- !cchConfig.hide_tabs.includes(default_tab)
- ) {
- tabs[default_tab].click();
- }
- defaultTabRedirect = true;
- }
-}
-
-function sidebarMod() {
- let menu = buttons.menu.querySelector("paper-icon-button");
- let sidebar = main.shadowRoot.querySelector("app-drawer");
-
- if (!newSidebar) {
- if (!cchConfig.sidebar_swipe || cchConfig.kiosk_mode) {
- sidebar.removeAttribute("swipe-open");
- }
- if ((cchConfig.sidebar_closed || cchConfig.kiosk_mode) && !sidebarClosed) {
- if (sidebar.hasAttribute("opened")) menu.click();
- sidebarClosed = true;
- }
- } else if (
- newSidebar &&
- (cchConfig.disable_sidebar || cchConfig.kiosk_mode)
- ) {
- sidebar.style.display = "none";
- sidebar.addEventListener(
- "mouseenter",
- function(event) {
- event.stopPropagation();
- },
- true
- );
- let style = document.createElement("style");
- style.type = "text/css";
- style.appendChild(
- document.createTextNode(
- ":host(:not([expanded])) {width: 0px !important;}"
- )
- );
- main.shadowRoot.querySelector("ha-sidebar").shadowRoot.appendChild(style);
-
- style = document.createElement("style");
- style.type = "text/css";
- style.appendChild(
- document.createTextNode(":host {--app-drawer-width: 0px !important;}")
- );
- main.shadowRoot.appendChild(style);
- }
-}
-
-function hideTabs(tabContainer, tabs) {
- let hidden_tabs = String(cchConfig.hide_tabs).length
- ? String(cchConfig.hide_tabs)
- .replace(/\s+/g, "")
- .split(",")
- : null;
- let shown_tabs = String(cchConfig.show_tabs).length
- ? String(cchConfig.show_tabs)
- .replace(/\s+/g, "")
- .split(",")
- : null;
-
- // Set the tab config source.
- if (!hidden_tabs && shown_tabs) {
- let all_tabs = [];
- shown_tabs = buildRanges(shown_tabs);
- for (let i = 0; i < tabs.length; i++) all_tabs.push(i);
- // Invert shown_tabs to hidden_tabs.
- hidden_tabs = all_tabs.filter(el => !shown_tabs.includes(el));
- } else {
- hidden_tabs = buildRanges(hidden_tabs);
- }
-
- // Hide tabs.
- for (const tab of hidden_tabs) {
- if (!tabs[tab]) continue;
- tabs[tab].style.display = "none";
- }
-
- if (cchConfig.redirect && tabContainer) {
- const activeTab = tabContainer.querySelector("paper-tab.iron-selected");
- const activeTabIndex = tabs.indexOf(activeTab);
- // Is the current tab hidden and is there at least one tab is visible.
- if (
- hidden_tabs.includes(activeTabIndex) &&
- hidden_tabs.length != tabs.length
- ) {
- let i = 0;
- // Find the first visible tab and navigate.
- while (hidden_tabs.includes(i)) {
- i++;
- }
- tabs[i].click();
+ } else {
+ return parseInt(viewString);
}
}
- return hidden_tabs;
-}
-function insertMenuItem(menu_items, element) {
- let first_item = menu_items.querySelector("paper-item");
- if (!menu_items.querySelector(`[id="${element.id}"]`)) {
- first_item.parentNode.insertBefore(element, first_item);
- }
-}
-
-function insertClock(button) {
- const clock_button = buttons[button].querySelector("paper-icon-button")
- ? buttons[button]
- : buttons[button].shadowRoot;
- const clockIcon = clock_button.querySelector("paper-icon-button");
- const clockIronIcon = clockIcon.shadowRoot.querySelector("iron-icon");
- const clockWidth =
- (cchConfig.clock_format == 12 && cchConfig.clock_am_pm) ||
- cchConfig.clock_date
- ? 110
- : 80;
-
- if (
- !newSidebar &&
- cchConfig.notifications == "clock" &&
- cchConfig.clock_date &&
- !buttons.notifications.shadowRoot.querySelector('[id="cch_indicator"]')
- ) {
- let style = document.createElement("style");
- style.setAttribute("id", "cch_indicator");
- style.innerHTML = `
- .indicator {
- top: unset;
- bottom: -3px;
- right: 0px;
- width: 90%;
- height: 3px;
- border-radius: 0;
- ${
- cchConfig.notify_indicator_color
- ? `background-color:${cchConfig.notify_indicator_color}`
- : ""
- }
- }
- .indicator > div{
- display:none;
- }
- `;
- buttons.notifications.shadowRoot.appendChild(style);
- }
-
- let clockElement = clockIronIcon.parentNode.getElementById("cch_clock");
- if (cchConfig.menu == "clock") {
- buttons.menu.style.marginTop = cchConfig.compact_header ? "111px" : "";
- buttons.menu.style.zIndex = "1";
- }
- if (!clockElement) {
- clockIcon.style.cssText = `
- margin-right:-5px;
- width:${clockWidth}px;
- text-align: center;
- `;
- clockElement = document.createElement("p");
- clockElement.setAttribute("id", "cch_clock");
- let clockAlign = "center";
- let padding = "";
- let fontSize = "";
- if (cchConfig.clock_date && cchConfig.menu == "clock") {
- clockAlign = "left";
- padding = "margin-right:-20px";
- fontSize = "font-size:12pt";
- } else if (cchConfig.clock_date) {
- clockAlign = "right";
- padding = "margin-left:-20px";
- fontSize = "font-size:12pt";
+ reverseObject(object) {
+ let newObject = {};
+ let keys = [];
+ for (let key in object) keys.push(key);
+ for (let i = keys.length - 1; i >= 0; i--) {
+ let value = object[keys[i]];
+ newObject[keys[i]] = value;
}
- clockElement.style.cssText = `
- margin-top: ${cchConfig.clock_date ? "-4px" : "2px"};
- text-align: ${clockAlign};
- ${padding};
- ${fontSize};
- `;
- clockIronIcon.parentNode.insertBefore(clockElement, clockIronIcon);
- clockIronIcon.style.display = "none";
+ return newObject;
}
- const clockFormat = {
- hour12: cchConfig.clock_format != 24,
- hour: "2-digit",
- minute: "2-digit"
- };
- updateClock(clockElement, clockFormat);
-}
-
-function updateClock(clock, clockFormat) {
- let date = new Date();
- let locale = cchConfig.date_locale || hass.language;
- let time = date.toLocaleTimeString([], clockFormat);
- let options = {
- weekday: "short",
- month: "2-digit",
- day: "2-digit"
- };
- date = cchConfig.clock_date
- ? `${date.toLocaleDateString(locale, options)}`
- : "";
- if (!cchConfig.clock_am_pm && cchConfig.clock_format == 12) {
- clock.innerHTML = time.slice(0, -3) + date;
- } else {
- clock.innerHTML = time + date;
- }
- window.setTimeout(() => updateClock(clock, clockFormat), 60000);
-}
-
-// Abandon all hope, ye who enter here.
-function conditionalStyling(tabs, header) {
- let _hass = document.querySelector("home-assistant").hass;
- const conditional_styles = cchConfig.conditional_styles;
- let tabContainer = tabs[0] ? tabs[0].parentNode : "";
- let elem, color, bg, hide, onIcon, offIcon, iconElem;
-
- const styleElements = () => {
- if (bg && elem == "background") header.style.background = bg;
- else if (color) elem.style.color = color;
- if (onIcon && iconElem) iconElem.setAttribute("icon", onIcon);
- if (hide && elem !== "background" && !editMode) {
- elem.style.display = "none";
- }
- };
-
- const getElements = (key, elemArray, i, obj, styling) => {
- elem = elemArray[key];
- color = styling[i][obj][key].color;
- onIcon = styling[i][obj][key].on_icon;
- offIcon = styling[i][obj][key].off_icon;
- hide = styling[i][obj][key].hide;
- if (!prevColor[key]) {
- prevColor[key] = window
- .getComputedStyle(elem, null)
- .getPropertyValue("color");
- }
- };
-
- let styling = [];
- if (Array.isArray(conditional_styles)) {
- for (let i = 0; i < conditional_styles.length; i++) {
- styling.push(Object.assign({}, conditional_styles[i]));
- }
- } else {
- styling.push(Object.assign({}, conditional_styles));
- }
-
- for (let i = 0; i < styling.length; i++) {
- let template = styling[i].template;
- if (template) {
- if (!template.length) template = [template];
- template.forEach(template => {
- templates(template, tabs, _hass, header);
- });
- } else if (conditional_styles) {
- let entity = styling[i].entity;
- if (_hass.states[entity] == undefined && entity !== "notifications") {
- console.log(`CCH conditional styling: ${entity} does not exist.`);
- continue;
- }
- if (entity == "notifications") condState[i] = notifications;
- else condState[i] = _hass.states[entity].state;
-
- if (condState[i] !== prevState[i] || !condState.length) {
- prevState[i] = condState[i];
- let above = styling[i].condition.above;
- let below = styling[i].condition.below;
-
- for (const obj in styling[i]) {
- let key;
- if (styling[i][obj]) {
- key = Object.keys(styling[i][obj])[0];
- }
- if (obj == "background") {
- elem = "background";
- color = styling[i][obj].color;
- bg = styling[i][obj];
- iconElem = false;
- if (!prevColor[obj]) {
- prevColor[obj] = window
- .getComputedStyle(header, null)
- .getPropertyValue("background");
- }
- } else if (obj == "button") {
- if (newSidebar && key == "notifications") continue;
- getElements(key, buttons, i, obj, styling);
- if (key == "menu") {
- iconElem = elem
- .querySelector("paper-icon-button")
- .shadowRoot.querySelector("iron-icon");
- } else {
- iconElem = elem.shadowRoot
- .querySelector("paper-icon-button")
- .shadowRoot.querySelector("iron-icon");
- }
- } else if (obj == "tab") {
- if (isNaN(key)) {
- let views = lovelace.config.views;
- for (let view in views) {
- if (views[view]["title"] == key || views[view]["path"] == key) {
- styling[i][obj][view] = styling[i][obj][key];
- delete styling[i][obj][key];
- key = view;
- }
- }
- }
- getElements(key, tabs, i, obj, styling);
- iconElem = elem.querySelector("ha-icon");
- }
-
- if (condState[i] == styling[i].condition.state) {
- styleElements();
- } else if (
- above !== undefined &&
- below !== undefined &&
- condState[i] > above &&
- condState[i] < below
- ) {
- styleElements();
- } else if (
- above !== undefined &&
- below == undefined &&
- condState[i] > above
- ) {
- styleElements();
- } else if (
- above == undefined &&
- below !== undefined &&
- condState[i] < below
- ) {
- styleElements();
- } else {
- if (elem !== "background" && hide && elem.style.display == "none") {
- elem.style.display = "";
- }
- if (bg && elem == "background") {
- header.style.background = prevColor[obj];
- } else if (
- obj !== "background" &&
- obj !== "entity" &&
- obj !== "condition"
- ) {
- elem.style.color = prevColor[key];
- }
- if (onIcon && offIcon) {
- iconElem.setAttribute("icon", offIcon);
- }
- }
- }
- }
- }
- }
- tabContainerMargin(tabContainer);
-}
-
-function templates(template, tabs, _hass, header) {
- // Variables for templates.
- let states = _hass.states;
- let entity = states;
-
- const templateEval = template => {
+ templateEval(template, states) {
+ let entity = states;
try {
if (template.includes("return")) {
return eval(`(function() {${template}}())`);
@@ -1000,326 +1479,384 @@ function templates(template, tabs, _hass, header) {
return eval(template);
}
} catch (e) {
- console.log("CCH styling template failed.");
- console.log(e);
- }
- };
-
- for (const condition in template) {
- if (condition == "tab") {
- for (const tab in template[condition]) {
- let tempCond = template[condition][tab];
- if (!tempCond.length) tempCond = [tempCond];
- tempCond.forEach(templateObj => {
- let tabIndex = Object.keys(template[condition]);
- let views = lovelace.config.views;
- if (isNaN(tabIndex)) {
- for (let view in views) {
- if (
- views[view]["title"] == tabIndex ||
- views[view]["path"] == tabIndex
- ) {
- tabIndex = view;
- }
- }
- } else {
- tabIndex = parseInt(tabIndex);
- }
- let styleTarget = Object.keys(templateObj);
- let tabTemplate = templateObj[styleTarget];
- let tabElement = tabs[tabIndex];
- if (styleTarget == "icon") {
- tabElement
- .querySelector("ha-icon")
- .setAttribute("icon", templateEval(tabTemplate, entity));
- } else if (styleTarget == "color") {
- tabElement.style.color = templateEval(tabTemplate, entity);
- } else if (styleTarget == "display") {
- templateEval(tabTemplate, entity) == "show"
- ? (tabElement.style.display = "")
- : (tabElement.style.display = "none");
- }
- });
- }
- } else if (condition == "button") {
- for (const button in template[condition]) {
- let tempCond = template[condition][button];
- if (!tempCond.length) tempCond = [tempCond];
- tempCond.forEach(templateObj => {
- let buttonName = Object.keys(template[condition]);
- if (newSidebar && buttonName == "notifications") return;
- let styleTarget = Object.keys(templateObj);
- let buttonElem = buttons[buttonName];
- let tempCond = templateObj[styleTarget];
- let iconTarget = buttonElem.querySelector("paper-icon-button")
- ? buttonElem.querySelector("paper-icon-button")
- : buttonElem.shadowRoot.querySelector("paper-icon-button");
- if (styleTarget == "icon") {
- iconTarget.setAttribute("icon", templateEval(tempCond, entity));
- } else if (styleTarget == "color") {
- iconTarget.shadowRoot.querySelector(
- "iron-icon"
- ).style.color = templateEval(tempCond, entity);
- } else if (styleTarget == "display") {
- templateEval(tempCond, entity) == "show"
- ? (buttonElem.style.display = "")
- : (buttonElem.style.display = "none");
- }
- });
- }
- } else if (condition == "background") {
- header.style.background = templateEval(template[condition], entity);
+ console.log(
+ `%cCCH Template Failed:%c\n${template}\n%c${e}`,
+ "text-decoration: underline;",
+ "",
+ "color: red;"
+ );
}
}
-}
-// Get range (e.g., "5 to 9") and build (5,6,7,8,9).
-function buildRanges(array) {
- let ranges = [];
- if (!array) return [];
- const sortNumber = (a, b) => a - b;
- const range = (start, end) =>
- new Array(end - start + 1).fill(undefined).map((_, i) => i + start);
- for (let i in array) {
- if (typeof array[i] == "string" && array[i].includes("to")) {
- let split = array[i].split("to");
- if (parseInt(split[1]) > parseInt(split[0])) {
- ranges.push(range(parseInt(split[0]), parseInt(split[1])));
- } else {
- ranges.push(range(parseInt(split[1]), parseInt(split[0])));
- }
- } else if (isNaN(array[i])) {
- let views = lovelace.config.views;
- for (let view in views) {
- if (
- views[view]["title"] == array[i] ||
- views[view]["path"] == array[i]
- ) {
- ranges.push(parseInt(view));
+ swipeNavigation(tabs, tabContainer) {
+ // To make it easier to update lovelace-swipe-navigation
+ // keep this as close to the standalone lovelace addon as possible.
+ if (!tabContainer) return;
+ let swipe_amount = this.cchConfig.swipe_amount || 15;
+ let swipe_groups = this.cchConfig.swipe_groups;
+ let animate = this.cchConfig.swipe_animate || "none";
+ let skip_tabs = this.cchConfig.swipe_skip
+ ? this.buildRanges(this.cchConfig.swipe_skip.split(","))
+ : [];
+ let wrap =
+ this.cchConfig.swipe_wrap != undefined ? this.cchConfig.swipe_wrap : true;
+ let prevent_default =
+ this.cchConfig.swipe_prevent_default != undefined
+ ? this.cchConfig.swipe_prevent_default
+ : false;
+
+ swipe_amount /= 10 ** 2;
+ const appLayout = this.root.querySelector("ha-app-layout");
+ let inGroup = true;
+ let xDown;
+ let yDown;
+ let xDiff;
+ let yDiff;
+ let activeTab;
+ let firstTab;
+ let lastTab;
+ let left;
+ let fTabs;
+
+ appLayout.addEventListener("touchstart", handleTouchStart.bind(this), {
+ passive: true
+ });
+ appLayout.addEventListener("touchmove", handleTouchMove, {
+ passive: false
+ });
+ appLayout.addEventListener("touchend", handleTouchEnd, { passive: true });
+
+ click = click.bind(this);
+ clearClassNames = clearClassNames.bind(this);
+ animation = animation.bind(this);
+
+ if (!this.root.querySelector("#cch_swipe_animation")) {
+ let swipeAnimations = document.createElement("style");
+ swipeAnimations.setAttribute("id", "cch_swipe_animation");
+ swipeAnimations.innerHTML = `
+ @keyframes swipeOutRight, swipeOutLeft {
+ 0% { transform: translateX(0px); opacity: 1; }
+ }
+ @keyframes swipeOutRight {
+ 100% { transform: translateX(${screen.width / 1.5}px); opacity: 0; }
+ }
+ @keyframes swipeOutLeft {
+ 100% { transform: translateX(-${screen.width / 1.5}px); opacity: 0; }
+ }
+ @keyframes swipeInRight, swipeInLeft {
+ 100% { transform: translateX(0px); opacity: 1; }
+ }
+ @keyframes swipeInRight {
+ 0% { transform: translateX(${screen.width / 1.5}px); opacity: 0; }
+ }
+ @keyframes swipeInLeft {
+ 0% { transform: translateX(-${screen.width / 1.5}px); opacity: 0; }
+ }
+ @keyframes fadeOut {
+ 0% { opacity: 1; }
+ 100% { opacity: 0; }
+ }
+ @keyframes fadeIn {
+ 0% { opacity: 0; }
+ 100% { opacity: 1; }
+ }
+ @keyframes flipOut {
+ 0% { transform: rotatey(0deg); opacity: 1; }
+ 100% { transform: rotatey(90deg); opacity: 0; }
+ }
+ @keyframes flipIn{
+ 0% { transform: rotatey(90deg); opacity: 0; }
+ 100% { transform: rotatey(0deg); opacity: 1; }
+ }
+ .swipeOutRight { animation: swipeOutRight .20s 1; }
+ .swipeOutLeft { animation: swipeOutLeft .20s 1; }
+ .swipeInRight { animation: swipeInRight .20s 1; }
+ .swipeInLeft { animation: swipeInLeft .20s 1; }
+ .fadeIn { animation: fadeIn .20s 1; }
+ .fadeOut { animation: fadeOut .20s 1; }
+ .flipIn { animation: flipIn .20s 1; }
+ .flipOut { animation: flipOut .20s 1; }
+ .swipeOutRight,
+ .swipeOutLeft,
+ .swipeInRight,
+ .swipeInLeft,
+ .fadeIn,
+ .fadeOut,
+ .flipIn,
+ .flipOut {
+ animation-fill-mode: forwards;
+ }
+ `;
+ this.view.parentNode.appendChild(swipeAnimations);
+ }
+
+ function handleTouchStart(event) {
+ filterTabs(this.cchConfig);
+ if (swipe_groups && !inGroup) return;
+ let ignored = [
+ "APP-HEADER",
+ "HA-SLIDER",
+ "SWIPE-CARD",
+ "HUI-MAP-CARD",
+ "ROUND-SLIDER",
+ "HUI-THERMOSTAT-CARD"
+ ];
+ let path = (event.composedPath && event.composedPath()) || event.path;
+ if (path) {
+ for (let element of path) {
+ if (element.nodeName == "HUI-VIEW") break;
+ else if (ignored.includes(element.nodeName)) return;
}
}
- } else {
- ranges.push(parseInt(array[i]));
+ xDown = event.touches[0].clientX;
+ yDown = event.touches[0].clientY;
}
- }
- return ranges.flat().sort(sortNumber);
-}
-function showEditor() {
- window.scrollTo(0, 0);
- if (!root.querySelector("ha-app-layout").querySelector("editor")) {
- const container = document.createElement("editor");
- const nest = document.createElement("div");
- nest.style.cssText = `
- padding: 20px;
- max-width: 600px;
- margin: 15px auto;
- background: var(--paper-card-background-color);
- border: 6px solid var(--paper-card-background-color);
- `;
- container.style.cssText = `
- width: 100%;
- min-height: 100%;
- box-sizing: border-box;
- position: absolute;
- background: var(--background-color, grey);
- z-index: 2;
- padding: 5px;
- `;
- root.querySelector("ha-app-layout").insertBefore(container, view);
- container.appendChild(nest);
- nest.appendChild(document.createElement("compact-custom-header-editor"));
- }
-}
-
-function reverseObject(object) {
- let newObject = {};
- let keys = [];
- for (let key in object) keys.push(key);
- for (let i = keys.length - 1; i >= 0; i--) {
- let value = object[keys[i]];
- newObject[keys[i]] = value;
- }
- return newObject;
-}
-
-function swipeNavigation(tabs, tabContainer) {
- // To make it easier to update lovelace-swipe-navigation
- // keep this as close to the standalone lovelace addon as possible.
- let swipe_amount = cchConfig.swipe_amount || 15;
- let animate = cchConfig.swipe_animate || "none";
- let skip_tabs = cchConfig.swipe_skip
- ? buildRanges(cchConfig.swipe_skip.split(","))
- : [];
- let wrap = cchConfig.swipe_wrap != undefined ? cchConfig.swipe_wrap : true;
- let prevent_default =
- cchConfig.swipe_prevent_default != undefined
- ? cchConfig.swipe_prevent_default
- : false;
-
- swipe_amount /= Math.pow(10, 2);
- const appLayout = root.querySelector("ha-app-layout");
- let xDown, yDown, xDiff, yDiff, activeTab, firstTab, lastTab, left;
-
- appLayout.addEventListener("touchstart", handleTouchStart, { passive: true });
- appLayout.addEventListener("touchmove", handleTouchMove, { passive: false });
- appLayout.addEventListener("touchend", handleTouchEnd, { passive: true });
-
- function handleTouchStart(event) {
- let ignored = ["APP-HEADER", "HA-SLIDER", "SWIPE-CARD", "HUI-MAP-CARD"];
- let path = (event.composedPath && event.composedPath()) || event.path;
- if (path) {
- for (let element of path) {
- if (element.nodeName == "HUI-VIEW") break;
- else if (ignored.indexOf(element.nodeName) > -1) return;
+ function handleTouchMove(event) {
+ if (xDown && yDown) {
+ xDiff = xDown - event.touches[0].clientX;
+ yDiff = yDown - event.touches[0].clientY;
+ if (Math.abs(xDiff) > Math.abs(yDiff) && prevent_default) {
+ event.preventDefault();
+ }
}
}
- xDown = event.touches[0].clientX;
- yDown = event.touches[0].clientY;
- if (!lastTab) filterTabs();
- activeTab = tabs.indexOf(tabContainer.querySelector(".iron-selected"));
- }
- function handleTouchMove(event) {
- if (xDown && yDown) {
- xDiff = xDown - event.touches[0].clientX;
- yDiff = yDown - event.touches[0].clientY;
- if (Math.abs(xDiff) > Math.abs(yDiff) && prevent_default) {
- event.preventDefault();
+ function handleTouchEnd() {
+ if (activeTab < 0 || Math.abs(xDiff) < Math.abs(yDiff)) {
+ xDown = yDown = xDiff = yDiff = null;
+ return;
+ }
+ if (xDiff > Math.abs(screen.width * swipe_amount)) {
+ left = false;
+ if (!wrap && fTabs[activeTab] == lastTab) return;
+ else if (fTabs[activeTab] == lastTab && wrap) click(firstTab);
+ else click(fTabs[activeTab + 1]);
+ } else if (xDiff < -Math.abs(screen.width * swipe_amount)) {
+ left = true;
+ if (!wrap && fTabs[activeTab] == firstTab) return;
+ else if (fTabs[activeTab] == firstTab && wrap) click(lastTab);
+ else click(fTabs[activeTab - 1]);
}
- }
- }
-
- function handleTouchEnd() {
- if (activeTab < 0 || Math.abs(xDiff) < Math.abs(yDiff)) {
xDown = yDown = xDiff = yDiff = null;
- return;
}
- if (xDiff > Math.abs(screen.width * swipe_amount)) {
- left = false;
- activeTab == tabs.length - 1 ? click(firstTab) : click(activeTab + 1);
- } else if (xDiff < -Math.abs(screen.width * swipe_amount)) {
- left = true;
- activeTab == 0 ? click(lastTab) : click(activeTab - 1);
- }
- xDown = yDown = xDiff = yDiff = null;
- }
- function filterTabs() {
- tabs = tabs.filter(element => {
- return (
- !skip_tabs.includes(tabs.indexOf(element)) &&
- getComputedStyle(element, null).display != "none"
+ function filterTabs(config) {
+ let currentTab = tabs.indexOf(
+ tabContainer.querySelector(".iron-selected")
);
- });
- firstTab = wrap ? 0 : null;
- lastTab = wrap ? tabs.length - 1 : null;
+ if (swipe_groups) {
+ let groups = swipe_groups.replace(/, /g, ",").split(",");
+ for (let group in groups) {
+ let firstLast = groups[group].replace(/ /g, "").split("to");
+ if (
+ wrap &&
+ currentTab >= firstLast[0] &&
+ currentTab <= firstLast[1]
+ ) {
+ inGroup = true;
+ firstTab = tabs[parseInt(firstLast[0])];
+ lastTab = tabs[parseInt(firstLast[1])];
+ fTabs = tabs.filter(
+ element =>
+ tabs.indexOf(element) >= firstLast[0] &&
+ tabs.indexOf(element) <= firstLast[1]
+ );
+ break;
+ } else {
+ inGroup = false;
+ }
+ }
+ }
+ if (config.swipe_skip_hidden) {
+ fTabs = tabs.filter(
+ element =>
+ !skip_tabs.includes(tabs.indexOf(element)) &&
+ getComputedStyle(element, null).display != "none"
+ );
+ } else {
+ fTabs = tabs.filter(
+ element => !skip_tabs.includes(tabs.indexOf(element))
+ );
+ }
+ if (!swipe_groups) {
+ firstTab = fTabs[0];
+ lastTab = fTabs[fTabs.length - 1];
+ }
+ activeTab = fTabs.indexOf(tabContainer.querySelector(".iron-selected"));
+ }
+
+ function animation(secs, transform, opacity, timeout) {
+ setTimeout(() => {
+ this.view.style.transition = `transform ${secs}s, opacity ${secs}s`;
+ this.view.style.transform = transform ? transform : "";
+ this.view.style.opacity = opacity;
+ }, timeout);
+ }
+
+ function clearClassNames(huiView) {
+ [
+ "swipeOutRight",
+ "swipeOutLeft",
+ "swipeInRight",
+ "swipeInLeft",
+ "fadeIn",
+ "fadeOut",
+ "flipIn",
+ "flipOut"
+ ].forEach(name => {
+ if (huiView.classList.contains(name)) {
+ huiView.classList.remove(name);
+ }
+ if (this.view.classList.contains(name)) {
+ this.view.classList.remove(name);
+ }
+ });
+ huiView.style.overflowX = "";
+ this.view.style.overflowX = "";
+ }
+
+ function navigate(tab, timeout) {
+ setTimeout(() => {
+ tab.dispatchEvent(
+ new MouseEvent("click", { bubbles: false, cancelable: true })
+ );
+ }, timeout);
+ }
+
+ function click(tab) {
+ if (
+ !tab ||
+ this.animation_running ||
+ (tab.style.display == "none" && this.cchConfig.swipe_skip_hidden)
+ ) {
+ return;
+ }
+ if (animate)
+ if (
+ !wrap &&
+ ((activeTab == firstTab && left) || (activeTab == lastTab && !left))
+ ) {
+ return;
+ } else if (animate == "swipe") {
+ const getHuiView = () => {
+ return (
+ this.view.querySelector("hui-view") ||
+ this.view.querySelector("hui-panel-view")
+ );
+ };
+ this.animation_running = true;
+ let huiView = getHuiView();
+ clearClassNames(huiView);
+ huiView.style.overflowX = "hidden";
+ this.view.style.overflowX = "hidden";
+ // Swipe view off screen and fade out.
+ huiView.classList.add(left ? "swipeOutRight" : "swipeOutLeft");
+ this.view.classList.add("fadeOut");
+ setTimeout(() => {
+ this.view.style.opacity = "0";
+ clearClassNames(huiView);
+ }, 210);
+ // Watch for destination view to load.
+ const observer = new MutationObserver(mutations => {
+ mutations.forEach(({ addedNodes }) => {
+ addedNodes.forEach(({ nodeName }) => {
+ if (nodeName) {
+ // Swipe view on screen and fade in.
+ huiView = getHuiView();
+ huiView.style.overflowX = "hidden";
+ this.view.style.overflowX = "hidden";
+ this.view.classList.add("fadeIn");
+ huiView.classList.add(left ? "swipeInLeft" : "swipeInRight");
+ setTimeout(() => {
+ this.view.style.opacity = "1";
+ clearClassNames(huiView);
+ }, 210);
+ observer.disconnect();
+ return;
+ }
+ });
+ });
+ });
+ observer.observe(this.view, { childList: true });
+ // Navigate to next view and trigger the observer.
+ navigate(tab, 220);
+ } else if (animate == "fade") {
+ animation(0.16, "", 0, 0);
+ const observer = new MutationObserver(mutations => {
+ mutations.forEach(({ addedNodes }) => {
+ addedNodes.forEach(({ nodeName }) => {
+ if (nodeName == "HUI-VIEW" || nodeName == "HUI-PANEL-VIEW") {
+ animation(0.16, "", 1, 0);
+ observer.disconnect();
+ }
+ });
+ });
+ });
+ observer.observe(this.view, { childList: true });
+ navigate(tab, 170);
+ } else if (animate == "flip") {
+ animation(0.25, "rotatey(90deg)", 0.25, 0);
+ const observer = new MutationObserver(mutations => {
+ mutations.forEach(({ addedNodes }) => {
+ addedNodes.forEach(({ nodeName }) => {
+ if (nodeName == "HUI-VIEW" || nodeName == "HUI-PANEL-VIEW") {
+ animation(0.25, "rotatey(0deg)", 1, 50);
+ observer.disconnect();
+ }
+ });
+ });
+ });
+ observer.observe(this.view, { childList: true });
+ navigate(tab, 270);
+ } else {
+ navigate(tab, 0);
+ }
+ this.animation_running = false;
+ }
}
- function click(index) {
+ breakingChangeNotification() {
if (
- (activeTab == 0 && !wrap && left) ||
- (activeTab == tabs.length - 1 && !wrap && !left)
+ this.lovelace.config.cch == undefined &&
+ JSON.stringify(this.lovelace.config.views).includes(
+ "custom:compact-custom-header"
+ )
) {
- return;
- }
- if (animate == "swipe") {
- let _in = left ? `${screen.width / 1.5}px` : `-${screen.width / 1.5}px`;
- let _out = left ? `-${screen.width / 1.5}px` : `${screen.width / 1.5}px`;
- view.style.transitionDuration = "200ms";
- view.style.opacity = 0;
- view.style.transform = `translateX(${_in})`;
- view.style.transition = "transform 0.20s, opacity 0.20s";
- setTimeout(function() {
- tabs[index].dispatchEvent(
- new MouseEvent("click", { bubbles: false, cancelable: true })
- );
- view.style.transitionDuration = "0ms";
- view.style.transform = `translateX(${_out})`;
- view.style.transition = "transform 0s";
- }, 210);
- setTimeout(function() {
- view.style.transitionDuration = "200ms";
- view.style.opacity = 1;
- view.style.transform = `translateX(0px)`;
- view.style.transition = "transform 0.20s, opacity 0.20s";
- }, 215);
- } else if (animate == "fade") {
- view.style.transitionDuration = "200ms";
- view.style.transition = "opacity 0.20s";
- view.style.opacity = 0;
- setTimeout(function() {
- tabs[index].dispatchEvent(
- new MouseEvent("click", { bubbles: false, cancelable: true })
- );
- view.style.transitionDuration = "0ms";
- view.style.opacity = 0;
- view.style.transition = "opacity 0s";
- }, 210);
- setTimeout(function() {
- view.style.transitionDuration = "200ms";
- view.style.transition = "opacity 0.20s";
- view.style.opacity = 1;
- }, 250);
- } else if (animate == "flip") {
- view.style.transitionDuration = "200ms";
- view.style.transform = "rotatey(90deg)";
- view.style.transition = "transform 0.20s, opacity 0.20s";
- view.style.opacity = 0.25;
- setTimeout(function() {
- tabs[index].dispatchEvent(
- new MouseEvent("click", { bubbles: false, cancelable: true })
- );
- }, 210);
- setTimeout(function() {
- view.style.transitionDuration = "200ms";
- view.style.transform = "rotatey(0deg)";
- view.style.transition = "transform 0.20s, opacity 0.20s";
- view.style.opacity = 1;
- }, 250);
- } else {
- tabs[index].dispatchEvent(
- new MouseEvent("click", { bubbles: false, cancelable: true })
- );
+ this.hass.callService("persistent_notification", "create", {
+ title: "CCH Breaking Change",
+ notification_id: "CCH_Breaking_Change",
+ message:
+ "Compact-Custom-Header's configuration method has changed. You are " +
+ "receiving this notification because you have updated CCH, but are " +
+ "using the old config method. Please, visit the [upgrade guide]" +
+ "(https://maykar.github.io/compact-custom-header/1_1_0_upgrade/) " +
+ "for more info."
+ });
}
}
}
-function breakingChangeNotification() {
- if (
- lovelace.config.cch == undefined &&
- JSON.stringify(lovelace.config.views).includes(
- "custom:compact-custom-header"
- )
- ) {
- hass.callService("persistent_notification", "create", {
- title: "CCH Breaking Change",
- notification_id: "CCH_Breaking_Change",
- message:
- "Compact-Custom-Header's configuration method has changed. You are " +
- "receiving this notification because you have updated CCH, but are " +
- "using the old config method. Please, visit the [upgrade guide]" +
- "(https://maykar.github.io/compact-custom-header/1_1_0_upgrade/) " +
- "for more info."
- });
- }
-}
+const cch = new CompactCustomHeader();
+cch.run();
-// EDITOR //////////////////////////////////////////////////////////////////
-
-const buttonOptions = ["show", "hide", "clock", "overflow"];
-const overflowOptions = ["show", "hide", "clock"];
-const swipeAnimation = ["none", "swipe", "fade", "flip"];
-let _lovelace;
-
-class CompactCustomHeaderEditor extends LitElement {
+class CompactCustomHeaderEditor extends cch.LitElement {
static get properties() {
- return {
- _config: {}
- };
+ return { _config: {} };
}
firstUpdated() {
+ this.html = cch.LitElement.prototype.html;
+ if (
+ !customElements.get("paper-toggle-button") &&
+ customElements.get("ha-switch")
+ ) {
+ customElements.define(
+ "paper-toggle-button",
+ class extends customElements.get("ha-switch") {}
+ );
+ }
+
let ll = document.querySelector("home-assistant");
ll = ll && ll.shadowRoot;
ll = ll && ll.querySelector("home-assistant-main");
@@ -1328,29 +1865,33 @@ class CompactCustomHeaderEditor extends LitElement {
ll = (ll && ll.shadowRoot) || ll;
ll = ll && ll.querySelector("ha-panel-lovelace");
ll = ll && ll.shadowRoot;
- _lovelace = ll && ll.querySelector("hui-root").lovelace;
+ this._lovelace = ll && ll.querySelector("hui-root").lovelace;
- this._config = _lovelace.config.cch ? deepcopy(_lovelace.config.cch) : {};
+ this.deepcopy = this.deepcopy.bind(this);
+ this._config = this._lovelace.config.cch
+ ? this.deepcopy(this._lovelace.config.cch)
+ : {};
}
render() {
- if (!this._config || !_lovelace) return html``;
- return html`
+ if (!this._config || !this._lovelace) return this.html``;
+ return this.html`
X
${this.renderStyle()}
Exceptions
- ${this._config.exceptions
- ? this._config.exceptions.map((exception, index) => {
- return html`
+ ${
+ this._config.exceptions
+ ? this._config.exceptions.map(
+ (exception, index) => this.html`
- `;
- })
- : ""}
+ `
+ )
+ : ""
+ }
- ${this._mwc_button
- ? html`
+ ${
+ this._mwc_button
+ ? this.html`
Add Exception
`
- : html`
+ : this.html`
Add Exception
- `}
+ `
+ }
Current User
- ${hass.user.name}
+ ${cch.hass.user.name}
Current User Agent
${navigator.userAgent}
- ${!this.exception
- ? html`
+ ${
+ !this.exception
+ ? this.html`
${this._save_button}
`
- : ""}
- ${!this.exception
- ? html`
+ : ""
+ }
+ ${
+ !this.exception
+ ? this.html`
${this._cancel_button}
`
- : ""}
+ : ""
+ }
`;
}
@@ -1410,41 +1958,49 @@ class CompactCustomHeaderEditor extends LitElement {
}
_save() {
- for (var key in this._config) {
- if (this._config[key] == defaultConfig[key]) {
- delete this._config[key];
+ for (const key in this._config) {
+ if (this._config[key] == cch.defaultConfig[key]) delete this._config[key];
+ // Remove old config option.
+ if (typeof this._config.background == "boolean") {
+ this._config.background = "";
}
}
- let newConfig = {
- ..._lovelace.config,
- ...{ cch: this._config }
- };
- try {
- _lovelace.saveConfig(newConfig).then(() => {
- location.reload(true);
- });
- } catch (e) {
- alert("Save failed: " + e);
+ let newConfig = { ...this._lovelace.config, ...{ cch: this._config } };
+ if (cch.lovelace.mode == "storage") {
+ try {
+ this._lovelace.saveConfig(newConfig).then(() => {
+ window.location.href = window.location.href;
+ });
+ } catch (e) {
+ alert(`Save failed: ${e}`);
+ }
+ } else {
+ window.prompt(
+ "Copy to clipboard: Ctrl+C, Enter\n" +
+ "This option is experimental, check the copied config and backup.",
+ this.obj2yaml({ cch: newConfig.cch })
+ );
}
}
get _save_button() {
+ let text = cch.lovelace.mode == "storage" ? "Save and Reload" : "Copy YAML";
return this._mwc_button
- ? html`
- Save and Reload
+ ? this.html`
+ ${text}
`
- : html`
+ : this.html`
Save and Reload${text}
`;
}
get _cancel_button() {
return this._mwc_button
- ? html`
+ ? this.html`
Cancel
`
- : html`
+ : this.html`
Cancel
`;
}
@@ -1453,78 +2009,156 @@ class CompactCustomHeaderEditor extends LitElement {
let newExceptions;
if (this._config.exceptions) {
newExceptions = this._config.exceptions.slice(0);
- newExceptions.push({
- conditions: {},
- config: {}
- });
+ newExceptions.push({ conditions: {}, config: {} });
} else {
- newExceptions = [
- {
- conditions: {},
- config: {}
- }
- ];
+ newExceptions = [{ conditions: {}, config: {} }];
}
- this._config = {
- ...this._config,
- exceptions: newExceptions
- };
+ this._config = { ...this._config, exceptions: newExceptions };
- fireEvent(this, "config-changed", {
- config: this._config
- });
+ cch.fireEvent(this, "config-changed", { config: this._config });
}
- _configChanged(ev) {
- if (!this._config) {
- return;
- }
- this._config = {
- ...this._config,
- ...ev.detail.config
- };
- fireEvent(this, "config-changed", {
- config: this._config
- });
+ _configChanged({ detail }) {
+ if (!this._config) return;
+ this._config = { ...this._config, ...detail.config };
+ cch.fireEvent(this, "config-changed", { config: this._config });
}
_exceptionChanged(ev) {
- if (!this._config) {
- return;
- }
+ if (!this._config) return;
const target = ev.target.index;
const newExceptions = this._config.exceptions.slice(0);
newExceptions[target] = ev.detail.exception;
- this._config = {
- ...this._config,
- exceptions: newExceptions
- };
+ this._config = { ...this._config, exceptions: newExceptions };
- fireEvent(this, "config-changed", {
- config: this._config
- });
+ cch.fireEvent(this, "config-changed", { config: this._config });
}
_exceptionDelete(ev) {
- if (!this._config) {
- return;
- }
+ if (!this._config) return;
const target = ev.target;
const newExceptions = this._config.exceptions.slice(0);
newExceptions.splice(target.index, 1);
- this._config = {
- ...this._config,
- exceptions: newExceptions
- };
+ this._config = { ...this._config, exceptions: newExceptions };
- fireEvent(this, "config-changed", {
- config: this._config
- });
+ cch.fireEvent(this, "config-changed", { config: this._config });
this.requestUpdate();
}
+ deepcopy(value) {
+ if (!(!!value && typeof value == "object")) return value;
+ if (Object.prototype.toString.call(value) == "[object Date]") {
+ return new Date(value.getTime());
+ }
+ if (Array.isArray(value)) return value.map(this.deepcopy);
+ const result = {};
+ Object.keys(value).forEach(key => {
+ result[key] = this.deepcopy(value[key]);
+ });
+ return result;
+ }
+
+ obj2yaml(obj) {
+ if (typeof obj == "string") obj = JSON.parse(obj);
+ const ret = [];
+ convert(obj, ret);
+ return ret.join("\n");
+ function getType(obj) {
+ if (obj instanceof Array) {
+ return "array";
+ } else if (typeof obj == "string") {
+ return "string";
+ } else if (typeof obj == "boolean") {
+ return "boolean";
+ } else if (typeof obj == "number") {
+ return "number";
+ } else if (typeof obj == "undefined" || obj === null) {
+ return "null";
+ } else {
+ return "hash";
+ }
+ }
+ function convert(obj, ret) {
+ const type = getType(obj);
+ switch (getType(obj)) {
+ case "array":
+ convertArray(obj, ret);
+ break;
+ case "hash":
+ convertHash(obj, ret);
+ break;
+ case "string":
+ convertString(obj, ret);
+ break;
+ case "null":
+ ret.push("null");
+ break;
+ case "number":
+ ret.push(obj.toString());
+ break;
+ case "boolean":
+ ret.push(obj ? "true" : "false");
+ break;
+ }
+ }
+ function convertArray(obj, ret) {
+ if (obj.length === 0) ret.push("[]");
+ for (let i = 0; i < obj.length; i++) {
+ const ele = obj[i];
+ const recurse = [];
+ convert(ele, recurse);
+ for (let j = 0; j < recurse.length; j++) {
+ ret.push((j == 0 ? "- " : " ") + recurse[j]);
+ }
+ }
+ }
+ function convertHash(obj, ret) {
+ for (const k in obj) {
+ const recurse = [];
+ if (obj.hasOwnProperty(k)) {
+ const ele = obj[k];
+ convert(ele, recurse);
+ const type = getType(ele);
+ if (
+ type == "string" ||
+ type == "null" ||
+ type == "number" ||
+ type == "boolean"
+ ) {
+ ret.push(`${k}: ${recurse[0]}`);
+ } else {
+ ret.push(`${k}: `);
+ for (let i = 0; i < recurse.length; i++) {
+ ret.push(` ${recurse[i]}`);
+ }
+ }
+ }
+ }
+ }
+ function convertString(obj, ret) {
+ if ((obj.includes("'") && obj.includes('"')) || obj.length > 45) {
+ if (obj.includes(";")) {
+ obj = obj.includes("; ") ? obj.split("; ") : obj.split(";");
+ obj[0] = `>\n ${obj[0]}`;
+ if (obj[obj.length - 1].trim() == "") obj.pop();
+ obj = obj.join(";\n ");
+ obj = obj.replace(/\n$/, "");
+ ret.push(obj);
+ } else {
+ ret.push(`>\n ${obj}`);
+ }
+ } else if (obj.includes('"')) {
+ obj = obj.replace(/\n$/, "");
+ ret.push(`'${obj}'`);
+ } else {
+ obj = obj.replace(/\n$/, "");
+ ret.push(`"${obj}"`);
+ }
+ }
+ }
+
renderStyle() {
- return html`
+ return this.html`
- ${!this.exception
- ? html`
+ ${
+ !this.exception
+ ? this.html`
- Compact Custom Header
+ Compact Custom Header ₁.₄.₉
- ${this.getConfig("warning")
- ? html`
+ ${
+ this.getConfig("warning")
+ ? this.html`
Modifying options marked with a
@@ -1671,15 +2314,19 @@ class CchConfigEditor extends LitElement {
`
- : ""}
+ : ""
+ }
`
- : ""}
+ : ""
+ }
${this.renderStyle()}
`;
}
_toggleCard() {
this._closed = !this._closed;
- fireEvent(this, "iron-resize");
+ cch.fireEvent(this, "iron-resize");
}
_tabVisibility() {
- let show = this.shadowRoot.querySelector('[id="show"]');
- let hide = this.shadowRoot.querySelector('[id="hide"]');
- if (this.shadowRoot.querySelector('[id="tabs"]').value == "Hide Tabs") {
+ let show = this.shadowRoot.querySelector("#show");
+ let hide = this.shadowRoot.querySelector("#hide");
+ if (this.shadowRoot.querySelector("#tabs").value == "Hide Tabs") {
show.style.display = "none";
hide.style.display = "initial";
} else {
@@ -2186,31 +2886,25 @@ class CchConfigEditor extends LitElement {
}
_valueChanged(ev) {
- if (!this.config) {
- return;
- }
- const target = ev.target;
- if (this[`_${target.configValue}`] === target.value) {
- return;
- }
- if (target.configValue) {
- if (target.value === "") {
- delete this.config[target.configValue];
+ if (!this.config) return;
+ if (ev.target.configValue) {
+ if (ev.target.value === "") {
+ delete this.config[ev.target.configValue];
} else {
this.config = {
...this.config,
- [target.configValue]:
- target.checked !== undefined ? target.checked : target.value
+ [ev.target.configValue]:
+ ev.target.checked !== undefined
+ ? ev.target.checked
+ : ev.target.value
};
}
}
- fireEvent(this, "cch-config-changed", {
- config: this.config
- });
+ cch.fireEvent(this, "cch-config-changed", { config: this.config });
}
renderStyle() {
- return html`
+ return this.html`
-
-
-
- ${title}
-
-
- `;
- popup.appendChild(message);
- this.moreInfo(Object.keys(this.hass.states)[0]);
- let moreInfo = document.querySelector("home-assistant")._moreInfoEl;
- moreInfo._page = "none";
- moreInfo.shadowRoot.appendChild(popup);
- moreInfo.large = large;
- document.querySelector("home-assistant").provideHass(message);
-
- setTimeout(() => {
- let interval = setInterval(() => {
- if (moreInfo.getAttribute('aria-hidden')) {
- popup.parentNode.removeChild(popup);
- clearInterval(interval);
- }
- }, 100)
- }, 1000);
- return moreInfo;
- }
- static closePopUp() {
- let moreInfo = document.querySelector("home-assistant")._moreInfoEl;
- if (moreInfo) moreInfo.close()
- }
-
- static logger(message, script=null) {
- if(!('debug' in this.args(script))) return;
-
- if(typeof message !== "string")
- message = JSON.stringify(message);
- console.log(`%cDEBUG:%c ${message}`,
- "color: blue; font-weight: bold", "");
- }
-
-});
-
-// Global definition of cardTools
-var cardTools = customElements.get('card-tools');
-
-console.info(`%cCARD-TOOLS IS INSTALLED
-%cDeviceID: ${customElements.get('card-tools').deviceID}`,
-"color: green; font-weight: bold",
-"");
+!function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=3)}([function(e,t,r){"use strict";function n(){return document.querySelector("home-assistant").hass}function o(e){return document.querySelector("home-assistant").provideHass(e)}function s(){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}function a(){var e=document.querySelector("home-assistant");return e=(e=(e=(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"))&&e.shadowRoot)&&e.querySelector("ha-app-layout #view"))&&e.firstElementChild}r.d(t,"a",(function(){return n})),r.d(t,"d",(function(){return o})),r.d(t,"b",(function(){return s})),r.d(t,"c",(function(){return a}))},function(e,t,r){"use strict";r.d(t,"a",(function(){return n}));let n=function(){if(window.fully&&"function"==typeof fully.getDeviceId)return fully.getDeviceId();if(!localStorage["lovelace-player-device-id"]){const e=()=>Math.floor(1e5*(1+Math.random())).toString(16).substring(1);localStorage["lovelace-player-device-id"]=`${e()}${e()}-${e()}${e()}`}return localStorage["lovelace-player-device-id"]}()},function(module,__webpack_exports__,__webpack_require__){"use strict";__webpack_require__.d(__webpack_exports__,"a",(function(){return hasOldTemplate})),__webpack_require__.d(__webpack_exports__,"b",(function(){return parseOldTemplate}));var _hass_js__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(0),_deviceID_js__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(1);function hasOldTemplate(e){return/\[\[\s+.*\s+\]\]/.test(e)}function parseTemplateString(str,specialData={}){if("string"!=typeof str)return text;const FUNCTION=/^[a-zA-Z0-9_]+\(.*\)$/,EXPR=/([^=<>!]+)\s*(==|!=|<|>|<=|>=)\s*([^=<>!]+)/,SPECIAL=/^\{.+\}$/,STRING=/^"[^"]*"|'[^']*'$/;"string"==typeof specialData&&(specialData={}),specialData=Object.assign({user:Object(_hass_js__WEBPACK_IMPORTED_MODULE_0__.a)().user.name,browser:_deviceID_js__WEBPACK_IMPORTED_MODULE_1__.a,hash:location.hash.substr(1)||" "},specialData);const _parse_function=e=>{let t=[e.substr(0,e.indexOf("(")).trim()];for(e=e.substr(e.indexOf("(")+1);e;){let r=0,n=0,o=!1;for(;e[r];){let t=e[r++];if(t===o&&r>1&&"\\"!==e[r-2]?o=!1:"\"'".includes(t)&&(o=t),!o){if("("===t)n+=1;else if(")"===t){n-=1;continue}if(!(n>0)&&",)".includes(t))break}}t.push(e.substr(0,r-1).trim()),e=e.substr(r)}return t},_parse_special=e=>(e=e.substr(1,e.length-2),specialData[e]||`{${e}}`),_parse_entity=e=>{let t;if((e=e.split("."))[0].match(SPECIAL))t=_parse_special(e.shift()),t=Object(_hass_js__WEBPACK_IMPORTED_MODULE_0__.a)().states[t]||t;else if(t=Object(_hass_js__WEBPACK_IMPORTED_MODULE_0__.a)().states[`${e.shift()}.${e.shift()}`],!e.length)return t.state;return e.forEach(e=>t=t[e]),t},_eval_expr=str=>{if(str=EXPR.exec(str),null===str)return!1;const lhs=parseTemplateString(str[1]),rhs=parseTemplateString(str[3]);var expr="";return expr=parseFloat(lhs)!=lhs?`"${lhs}" ${str[2]} "${rhs}"`:`${parseFloat(lhs)} ${str[2]} ${parseFloat(rhs)}`,eval(expr)},_eval_function=e=>{if("if"===e[0])return _eval_expr(e[1])?parseTemplateString(e[2]):parseTemplateString(e[3])};try{return str=str.trim(),str.match(STRING)?str.substr(1,str.length-2):str.match(SPECIAL)?_parse_special(str):str.match(FUNCTION)?_eval_function(_parse_function(str)):str.includes(".")?_parse_entity(str):str}catch(e){return`[[ Template matching failed: ${str} ]]`}}function parseOldTemplate(e,t={}){if("string"!=typeof e)return e;return e=e.replace(/\[\[\s(.*?)\s\]\]/g,(e,r,n,o)=>parseTemplateString(r,t))}},function(e,t,r){"use strict";r.r(t);const n=customElements.get("home-assistant-main")?Object.getPrototypeOf(customElements.get("home-assistant-main")):Object.getPrototypeOf(customElements.get("hui-view")),o=n.prototype.html,s=n.prototype.css;function a(e,t,r=null){if((e=new Event(e,{bubbles:!0,cancelable:!1,composed:!0})).detail=t||{},r)r.dispatchEvent(e);else{var n=document.querySelector("home-assistant");(n=(n=(n=(n=(n=(n=(n=(n=(n=(n=(n=n&&n.shadowRoot)&&n.querySelector("home-assistant-main"))&&n.shadowRoot)&&n.querySelector("app-drawer-layout partial-panel-resolver"))&&n.shadowRoot||n)&&n.querySelector("ha-panel-lovelace"))&&n.shadowRoot)&&n.querySelector("hui-root"))&&n.shadowRoot)&&n.querySelector("ha-app-layout #view"))&&n.firstElementChild)&&n.dispatchEvent(e)}}const i="custom:";function c(e,t){const r=document.createElement("hui-error-card");return r.setConfig({type:"error",error:e,origConfig:t}),r}function l(e,t){if(!t||"object"!=typeof t||!t.type)return c(`No ${e} type configured`,t);let r=t.type;if(r=r.startsWith(i)?r.substr(i.length):`hui-${r}-${e}`,customElements.get(r))return function(e,t){const r=document.createElement(e);try{r.setConfig(t)}catch(e){return c(e,t)}return r}(r,t);const n=c(`Custom element doesn't exist: ${r}.`,t);n.style.display="None";const o=setTimeout(()=>{n.style.display=""},2e3);return customElements.whenDefined(r).then(()=>{clearTimeout(o),a("ll-rebuild",{},n)}),n}function u(e){return l("card",e)}function p(e){return l("element",e)}function d(e){const t=new Set(["call-service","divider","section","weblink"]);if(!e)return c("Invalid configuration given.",e);if("string"==typeof e&&(e={entity:e}),"object"!=typeof e||!e.entity&&!e.type)return c("Invalid configuration given.",e);const r=e.type||"default";if(t.has(r)||r.startsWith(i))return l("row",e);const n=e.entity.split(".",1)[0];return Object.assign(e,{type:{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"}[n]||"text"}),l("entity-row",e)}var f=r(0);const m=2;class h extends n{static get version(){return m}static get properties(){return{noHass:{type:Boolean}}}setConfig(e){this._config=e,this.el?this.el.setConfig(e):(this.el=this.create(e),this._hass&&(this.el.hass=this._hass),this.noHass&&Object(f.d)(this))}set config(e){this.setConfig(e)}set hass(e){this._hass=e,this.el&&(this.el.hass=e)}createRenderRoot(){return this}render(){return o`${this.el}`}}const _=function(e,t){const r=Object.getOwnPropertyDescriptors(t.prototype);for(const[t,n]of Object.entries(r))"constructor"!==t&&Object.defineProperty(e.prototype,t,n);const n=Object.getOwnPropertyDescriptors(t);for(const[t,r]of Object.entries(n))"prototype"!==t&&Object.defineProperty(e,t,r);const o=Object.getPrototypeOf(t),s=Object.getOwnPropertyDescriptors(o.prototype);for(const[t,r]of Object.entries(s))"constructor"!==t&&Object.defineProperty(Object.getPrototypeOf(e).prototype,t,r);const a=Object.getOwnPropertyDescriptors(o);for(const[t,r]of Object.entries(a))"prototype"!==t&&Object.defineProperty(Object.getPrototypeOf(e),t,r)},g=customElements.get("card-maker");if(!g||!g.version||g.version{document.body.querySelector("long-press").bind(e)}),customElements.whenDefined("action-handler").then(()=>{document.body.querySelector("action-handler").bind(e,t)}),e}function O(e,t=!1){a("hass-more-info",{entityId:e},document.querySelector("home-assistant"));const r=document.querySelector("home-assistant")._moreInfoEl;return r.large=t,r}function E(){const e=document.querySelector("home-assistant")&&document.querySelector("home-assistant")._moreInfoEl;e&&e.close()}function S(e,t,r=!1,n=null,o=!1){a("hass-more-info",{entityId:null});const s=document.querySelector("home-assistant")._moreInfoEl;s.close(),s.open();const i=document.createElement("div");i.innerHTML=`\n \n ${o?"":`\n \n \n \n ${e}\n
\n \n `}\n \n \n \n
\n `;const c=i.querySelector(".scrollable");c.querySelector("card-maker").config=t,s.sizingTarget=c,s.large=r,s._page="none",s.shadowRoot.appendChild(i);let l={};if(n)for(var u in s.resetFit(),n)l[u]=s.style[u],s.style.setProperty(u,n[u]);return s._dialogOpenChanged=function(e){if(!e&&(this.stateObj&&this.fire("hass-more-info",{entityId:null}),this.shadowRoot==i.parentNode&&(this._page=null,this.shadowRoot.removeChild(i),n)))for(var t in s.resetFit(),l)l[t]?s.style.setProperty(t,l[t]):s.style.removeProperty(t)},s}function j(e,t,r){e||(e=Object(f.a)().connection);let n={user:Object(f.a)().user.name,browser:v.a,hash:location.hash.substr(1)||" ",...r.variables},o=r.template,s=r.entity_ids;return e.subscribeMessage(e=>t(e.result),{type:"render_template",template:o,variables:n,entity_ids:s})}var D=r(2);const T=Object(f.a)().callWS({type:"config/area_registry/list"}),P=Object(f.a)().callWS({type:"config/device_registry/list"}),C=Object(f.a)().callWS({type:"config/entity_registry/list"});async function q(){return window.cardToolsData=window.cardToolsData||{areas:await T,devices:await P,entities:await C},window.cardToolsData}function R(e){const t=window.cardToolsData;for(const r of t.areas)if(r.name.toLowerCase()===e.toLowerCase())return r;return null}function I(e){const t=window.cardToolsData;let r=[];if(!e)return r;for(const n of t.devices)n.area_id===e.area_id&&r.push(n);return r}function x(e){const t=window.cardToolsData;for(const r of t.devices)if(r.name.toLowerCase()===e.toLowerCase())return r;return null}function $(e){const t=window.cardToolsData;let r=[];if(!e)return r;for(const n of t.entities)n.device_id===e.id&&r.push(n.entity_id);return r}q();class k{static checkVersion(e){}static args(){}static logger(){}static get localize(){return Object(f.a)().localize}static get deviceID(){return v.a}static get fireEvent(){return a}static get hass(){return Object(f.a)()}static get lovelace(){return Object(f.b)()}static get lovelace_view(){return f.c}static get provideHass(){return f.d}static get LitElement(){return n}static get LitHtml(){return o}static get LitCSS(){return s}static get longpress(){return w}static get createCard(){return u}static get createElement(){return p}static get createEntityRow(){return d}static get moreInfo(){return O}static get popUp(){return S}static get closePopUp(){return E}static get hasTemplate(){return D.a}static parseTemplate(e,t,r={}){return"string"==typeof e?Object(D.b)(e,t):async function(e,t,r={}){for(var n in e||(e=e()),r={},r=Object.assign({user:e.user.name,browser:v.a,hash:location.hash.substr(1)||" "},r)){var o=new RegExp(`\\{${n}\\}`,"g");t=t.replace(o,r[n])}return e.callApi("POST","template",{template:t})}(e,t,r)}static get subscribeRenderTemplate(){return j}static get getData(){return q}static get areaByName(){return R}static get areaDevices(){return I}static get deviceByName(){return x}static get deviceEntities(){return $}}customElements.get("card-tools")||(customElements.define("card-tools",k),window.cardTools=customElements.get("card-tools"),console.info(`%cCARD-TOOLS 2 IS INSTALLED\n %cDeviceID: ${customElements.get("card-tools").deviceID}`,"color: green; font-weight: bold",""))}]);
\ No newline at end of file
diff --git a/www/community/lovelace-card-tools/card-tools.js.gz b/www/community/lovelace-card-tools/card-tools.js.gz
index 7cbadc1..315ed2d 100644
Binary files a/www/community/lovelace-card-tools/card-tools.js.gz and b/www/community/lovelace-card-tools/card-tools.js.gz differ
diff --git a/www/community/lovelace-card-tools/webpack.config.js b/www/community/lovelace-card-tools/webpack.config.js
new file mode 100644
index 0000000..ee97d11
--- /dev/null
+++ b/www/community/lovelace-card-tools/webpack.config.js
@@ -0,0 +1,10 @@
+const path = require('path');
+
+module.exports = {
+ entry: './src/main.js',
+ mode: 'production',
+ output: {
+ filename: 'card-tools.js',
+ path: path.resolve(__dirname)
+ }
+};
diff --git a/www/community/lovelace-card-tools/webpack.config.js.gz b/www/community/lovelace-card-tools/webpack.config.js.gz
new file mode 100644
index 0000000..5e35119
Binary files /dev/null and b/www/community/lovelace-card-tools/webpack.config.js.gz differ
diff --git a/www/community/lovelace-fold-entity-row/fold-entity-row.js b/www/community/lovelace-fold-entity-row/fold-entity-row.js
index 447a16a..040a64d 100644
--- a/www/community/lovelace-fold-entity-row/fold-entity-row.js
+++ b/www/community/lovelace-fold-entity-row/fold-entity-row.js
@@ -1,8 +1,8 @@
-!function(e){var t={};function n(i){if(t[i])return t[i].exports;var o=t[i]={i:i,l:!1,exports:{}};return e[i].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,i){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},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 i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(i,o,function(t){return e[t]}.bind(null,o));return i},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=0)}([function(e,t,n){"use strict";n.r(t);const i=Object.getPrototypeOf(customElements.get("home-assistant-main")),o=i.prototype.html,s=i.prototype.css;function r(e,t,n=null){if((e=new Event(e,{bubbles:!0,cancelable:!1,composed:!0})).detail=t||{},n)n.dispatchEvent(e);else{var i=document.querySelector("home-assistant");(i=(i=(i=(i=(i=(i=(i=(i=(i=(i=(i=i&&i.shadowRoot)&&i.querySelector("home-assistant-main"))&&i.shadowRoot)&&i.querySelector("app-drawer-layout partial-panel-resolver"))&&i.shadowRoot||i)&&i.querySelector("ha-panel-lovelace"))&&i.shadowRoot)&&i.querySelector("hui-root"))&&i.shadowRoot)&&i.querySelector("ha-app-layout #view"))&&i.firstElementChild)&&i.dispatchEvent(e)}}const a="custom:",c=["input_number","input_select","input_text","input_datetime","scene","weblink"];function l(e,t){const n=document.createElement("hui-error-card");return n.setConfig({type:"error",error:e,config:t}),n}function u(e,t){if(!t||"object"!=typeof t||!t.type)return l(`No ${e} type configured`,t);let n=t.type;if(n=n.startsWith(a)?n.substr(a.length):`hui-${n}-${e}`,customElements.get(n))return function(e,t){const n=document.createElement(e);try{n.setConfig(t)}catch(e){return l(e,t)}return n}(n,t);const i=l(`Custom element doesn't exist: ${n}.`,t);i.style.display="None";const o=setTimeout(()=>{i.style.display=""},2e3);return customElements.whenDefined(n).then(()=>{clearTimeout(o),r("ll-rebuild",{},i)}),i}class h extends i{static get properties(){return{hass:{},config:{}}}setConfig(e){var t;this._config=e,this.el?this.el.setConfig(e):this.el=this.create(e),this._hass&&(this.el.hass=this._hass),this.noHass&&(t=this,document.querySelector("home-assistant").provideHass(t))}set config(e){this.setConfig(e)}set hass(e){this._hass=e,this.el&&(this.el.hass=e)}createRenderRoot(){return this}render(){return o`${this.el}`}}if(!customElements.get("card-maker")){class e extends h{create(e){return function(e){return u("card",e)}(e)}}customElements.define("card-maker",e)}if(!customElements.get("element-maker")){class e extends h{create(e){return function(e){return u("element",e)}(e)}}customElements.define("element-maker",e)}if(!customElements.get("entity-row-maker")){class e extends h{create(e){return function(e){const t=new Set(["call-service","divider","section","weblink"]);if(!e)return l("Invalid configuration given.",e);if("string"==typeof e&&(e={entity:e}),"object"!=typeof e||!e.entity&&!e.type)return l("Invalid configuration given.",e);const n=e.type||"default";if(t.has(n)||n.startsWith(a))return u("row",e);const i=e.entity.split(".",1)[0];return Object.assign(e,{type:{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"}[i]||"text"}),u("entity-row",e)}(e)}}customElements.define("entity-row-maker",e)}customElements.define("fold-entity-row",class extends i{static get properties(){return{hass:{},open:Boolean,items:{}}}setConfig(e){this._config=Object.assign({},{open:!1,padding:20,group_config:{}},e),this.open=this.open||this._config.open,this.items=this._config.items,this._config.entities&&(this.items=this._config.entities),"string"==typeof this._config.head&&this._config.head.startsWith("group.")&&(this.items=document.querySelector("home-assistant").hass.states[this._config.head].attributes.entity_id)}clickRow(e){const t=e.target.parentElement._config,n=t.entity||("string"==typeof t?t:null);e.stopPropagation(),this.hasMoreInfo(t)?function(e,t=!1){r("hass-more-info",{entityId:e},document.querySelector("home-assistant"));const n=document.querySelector("home-assistant")._moreInfoEl;n.large=t}(n):e.target.parentElement.hasAttribute("head")&&this.toggle(e)}toggle(e){e&&e.stopPropagation(),this.open=!this.open}hasMoreInfo(e){const t=e.entity||("string"==typeof e?e:null);return!(!t||c.includes(t.split(".",1)[0]))}firstUpdated(){const e=this.shadowRoot.querySelector("#head > entity-row-maker");e.updateComplete.then(()=>{const t=e.querySelector("hui-section-row");t&&t.updateComplete.then(()=>{t.shadowRoot.querySelector(".divider").style.marginRight="-56px"})})}render(){this._entities&&this._entities.forEach(e=>e.hass=this.hass);const e=e=>("string"==typeof e&&(e={entity:e}),Object.assign({},this._config.group_config,e));return o`
+!function(t){var e={};function i(n){if(e[n])return e[n].exports;var s=e[n]={i:n,l:!1,exports:{}};return t[n].call(s.exports,s,s.exports,i),s.l=!0,s.exports}i.m=t,i.c=e,i.d=function(t,e,n){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var s in t)i.d(n,s,function(e){return t[e]}.bind(null,s));return n},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=0)}([function(t,e,i){"use strict";i.r(e);const n=customElements.get("home-assistant-main")?Object.getPrototypeOf(customElements.get("home-assistant-main")):Object.getPrototypeOf(customElements.get("hui-view")),s=n.prototype.html,o=n.prototype.css;function r(){return document.querySelector("home-assistant").hass}const a="custom:",c=["input_number","input_select","input_text","scene","weblink"];function l(t,e){const i=document.createElement("hui-error-card");return i.setConfig({type:"error",error:t,config:e}),i}function h(t,e){if(!e||"object"!=typeof e||!e.type)return l(`No ${t} type configured`,e);let i=e.type;if(i=i.startsWith(a)?i.substr(a.length):`hui-${i}-${t}`,customElements.get(i))return function(t,e){const i=document.createElement(t);try{i.setConfig(e)}catch(t){return l(t,e)}return i}(i,e);const n=l(`Custom element doesn't exist: ${i}.`,e);n.style.display="None";const s=setTimeout(()=>{n.style.display=""},2e3);return customElements.whenDefined(i).then(()=>{clearTimeout(s),function(t,e,i=null){if((t=new Event(t,{bubbles:!0,cancelable:!1,composed:!0})).detail=e||{},i)i.dispatchEvent(t);else{var n=document.querySelector("home-assistant");(n=(n=(n=(n=(n=(n=(n=(n=(n=(n=(n=n&&n.shadowRoot)&&n.querySelector("home-assistant-main"))&&n.shadowRoot)&&n.querySelector("app-drawer-layout partial-panel-resolver"))&&n.shadowRoot||n)&&n.querySelector("ha-panel-lovelace"))&&n.shadowRoot)&&n.querySelector("hui-root"))&&n.shadowRoot)&&n.querySelector("ha-app-layout #view"))&&n.firstElementChild)&&n.dispatchEvent(t)}}("ll-rebuild",{},n)}),n}class u extends n{static get properties(){return{hass:{},config:{},noHass:{type:Boolean}}}setConfig(t){var e;this._config=t,this.el?this.el.setConfig(t):this.el=this.create(t),this._hass&&(this.el.hass=this._hass),this.noHass&&(e=this,document.querySelector("home-assistant").provideHass(e))}set config(t){this.setConfig(t)}set hass(t){this._hass=t,this.el&&(this.el.hass=t)}createRenderRoot(){return this}render(){return s`${this.el}`}}if(!customElements.get("card-maker")){class t extends u{create(t){return function(t){return h("card",t)}(t)}getCardSize(){return this.firstElementChild&&this.firstElementChild.getCardSize?this.firstElementChild.getCardSize():1}}customElements.define("card-maker",t)}if(!customElements.get("element-maker")){class t extends u{create(t){return function(t){return h("element",t)}(t)}}customElements.define("element-maker",t)}if(!customElements.get("entity-row-maker")){class t extends u{create(t){return function(t){const e=new Set(["call-service","divider","section","weblink"]);if(!t)return l("Invalid configuration given.",t);if("string"==typeof t&&(t={entity:t}),"object"!=typeof t||!t.entity&&!t.type)return l("Invalid configuration given.",t);const i=t.type||"default";if(e.has(i)||i.startsWith(a))return h("row",t);const n=t.entity.split(".",1)[0];return Object.assign(t,{type:{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"}[n]||"text"}),h("entity-row",t)}(t)}}customElements.define("entity-row-maker",t)}customElements.define("fold-entity-row",class extends n{static get properties(){return{_hass:{},open:Boolean,items:{}}}setConfig(t){this._config=Object.assign({},{open:!1,padding:20,group_config:{}},t),this.open=this.open||this._config.open,this.head=this._config.head,this._config.entity&&(this.head=this._config.entity),"string"==typeof this.head&&(this.head={entity:this.head}),this.items=this._config.items,this._config.entities&&(this.items=this._config.entities),this.head.entity&&this.head.entity.startsWith("group.")&&!this.items&&(this.items=r().states[this.head.entity].attributes.entity_id)}clickRow(t){t.stopPropagation();const e=t.target.parentElement._config;this.hasMoreInfo(e)||e.tap_action?customElements.get("hui-entities-card").prototype._handleClick.bind(this)(e):t.target.parentElement.hasAttribute("head")&&this.toggle(t)}toggle(t){t&&t.stopPropagation(),this.open=!this.open}hasMoreInfo(t){const e=t.entity||("string"==typeof t?t:null);return!(!e||c.includes(e.split(".",1)[0]))}firstUpdated(){const t=this.shadowRoot.querySelector("#head > entity-row-maker");t.updateComplete.then(()=>{const e=t.querySelector("hui-section-row");e&&e.updateComplete.then(()=>{e.shadowRoot.querySelector(".divider").style.marginRight="-56px"})})}set hass(t){this._hass=t}render(){this._entities&&this._entities.forEach(t=>t.hass=this._hass);const t=t=>("string"==typeof t&&(t={entity:t}),Object.assign({},this._config.group_config,t));return s`
@@ -17,26 +17,28 @@
style=
${this._config.padding?`padding-left: ${this._config.padding}px;`:""}
>
- ${this.items.map(t=>o`
+ ${this.items.map(e=>s`
`)}
- `}static get styles(){return s`
+ `}static get styles(){return o`
#head {
+ --toggle-icon-width: 40px;
display: flex;
cursor: pointer;
align-items: center;
}
#head entity-row-maker {
flex-grow: 1;
+ max-width: calc(100% - var(--toggle-icon-width));
}
#head ha-icon {
- width: 40px;
+ width: var(--toggle-icon-width);
cursor: pointer
}
diff --git a/www/community/lovelace-fold-entity-row/fold-entity-row.js.gz b/www/community/lovelace-fold-entity-row/fold-entity-row.js.gz
index ff0b80c..3caac21 100644
Binary files a/www/community/lovelace-fold-entity-row/fold-entity-row.js.gz and b/www/community/lovelace-fold-entity-row/fold-entity-row.js.gz differ
diff --git a/www/community/lovelace-fold-entity-row/webpack.config.js b/www/community/lovelace-fold-entity-row/webpack.config.js
new file mode 100644
index 0000000..9572dd9
--- /dev/null
+++ b/www/community/lovelace-fold-entity-row/webpack.config.js
@@ -0,0 +1,10 @@
+const path = require('path');
+
+module.exports = {
+ entry: './src/main.js',
+ mode: 'production',
+ output: {
+ filename: 'fold-entity-row.js',
+ path: path.resolve(__dirname)
+ }
+};
diff --git a/www/community/lovelace-fold-entity-row/webpack.config.js.gz b/www/community/lovelace-fold-entity-row/webpack.config.js.gz
new file mode 100644
index 0000000..5e2aa73
Binary files /dev/null and b/www/community/lovelace-fold-entity-row/webpack.config.js.gz differ
diff --git a/www/community/lovelace-layout-card/layout-card.js b/www/community/lovelace-layout-card/layout-card.js
index dbfe21c..ea64eb0 100644
--- a/www/community/lovelace-layout-card/layout-card.js
+++ b/www/community/lovelace-layout-card/layout-card.js
@@ -1,62 +1,31 @@
-customElements.whenDefined('card-tools').then(() => {
-let cardTools = customElements.get('card-tools');
-class LayoutCard extends cardTools.LitElement {
-
- async setConfig(config) {
- this.config = config;
- this.layout = config.layout || 'auto';
- this.minCols = config.column_num || 1;
- this.maxCols = config.max_columns || 100;
- this.colWidth = config.column_width || 400;
- this.maxWidth = config.max_width || 500;
- this.minHeight = config.min_height || 5;
- this.rtl = config.rtl || false;
- this.cardSize = 1;
-
- this.make_cards();
-
- window.addEventListener('resize', () => this.build());
- window.addEventListener('hass-open-menu', () => setTimeout(() => this.build(), 100));
- window.addEventListener('hass-close-menu', () => setTimeout(() => this.build(), 100));
- window.addEventListener('location-changed', () => {
- if(location.hash === "") setTimeout(() =>
- this.build(), 100)
- });
- if(config.rebuild)
- window.setTimeout(() => this.build(), config.rebuild);
- }
-
- render() {
- return cardTools.LitHtml`
-
- `;
- }
-
- firstUpdated() {
- if(this.parentElement && this.parentElement.id !== "view")
- {
- this.style.padding = "0";
- }
- if(this.rtl)
- this.shadowRoot.querySelector("#columns").style.flexDirection = 'row-reverse';
- this.build();
- this._cardModder = {
- target: this,
- styles: this.shadowRoot.querySelector("style")
- };
- }
-
- static get styles() {
- return cardTools.LitCSS`
+!function(t){var e={};function n(s){if(e[s])return e[s].exports;var o=e[s]={i:s,l:!1,exports:{}};return t[s].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=t,n.c=e,n.d=function(t,e,s){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:s})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var s=Object.create(null);if(n.r(s),Object.defineProperty(s,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(s,o,function(e){return t[e]}.bind(null,o));return s},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=0)}([function(t,e,n){"use strict";n.r(e);const s=customElements.get("home-assistant-main")?Object.getPrototypeOf(customElements.get("home-assistant-main")):Object.getPrototypeOf(customElements.get("hui-view")),o=s.prototype.html,i=s.prototype.css;const r="custom:";function c(t,e){const n=document.createElement("hui-error-card");return n.setConfig({type:"error",error:t,origConfig:e}),n}function a(t,e){if(!e||"object"!=typeof e||!e.type)return c(`No ${t} type configured`,e);let n=e.type;if(n=n.startsWith(r)?n.substr(r.length):`hui-${n}-${t}`,customElements.get(n))return function(t,e){const n=document.createElement(t);try{n.setConfig(e)}catch(t){return c(t,e)}return n}(n,e);const s=c(`Custom element doesn't exist: ${n}.`,e);s.style.display="None";const o=setTimeout(()=>{s.style.display=""},2e3);return customElements.whenDefined(n).then(()=>{clearTimeout(o),function(t,e,n=null){if((t=new Event(t,{bubbles:!0,cancelable:!1,composed:!0})).detail=e||{},n)n.dispatchEvent(t);else{var s=document.querySelector("home-assistant");(s=(s=(s=(s=(s=(s=(s=(s=(s=(s=(s=s&&s.shadowRoot)&&s.querySelector("home-assistant-main"))&&s.shadowRoot)&&s.querySelector("app-drawer-layout partial-panel-resolver"))&&s.shadowRoot||s)&&s.querySelector("ha-panel-lovelace"))&&s.shadowRoot)&&s.querySelector("hui-root"))&&s.shadowRoot)&&s.querySelector("ha-app-layout #view"))&&s.firstElementChild)&&s.dispatchEvent(t)}}("ll-rebuild",{},s)}),s}function l(){return document.querySelector("home-assistant").hass}const u=2;class d extends s{static get version(){return u}static get properties(){return{noHass:{type:Boolean}}}setConfig(t){var e;this._config=t,this.el?this.el.setConfig(t):(this.el=this.create(t),this._hass&&(this.el.hass=this._hass),this.noHass&&(e=this,document.querySelector("home-assistant").provideHass(e)))}set config(t){this.setConfig(t)}set hass(t){this._hass=t,this.el&&(this.el.hass=t)}createRenderRoot(){return this}render(){return o`${this.el}`}}const h=function(t,e){const n=Object.getOwnPropertyDescriptors(e.prototype);for(const[e,s]of Object.entries(n))"constructor"!==e&&Object.defineProperty(t.prototype,e,s);const s=Object.getOwnPropertyDescriptors(e);for(const[e,n]of Object.entries(s))"prototype"!==e&&Object.defineProperty(t,e,n);const o=Object.getPrototypeOf(e),i=Object.getOwnPropertyDescriptors(o.prototype);for(const[e,n]of Object.entries(i))"constructor"!==e&&Object.defineProperty(Object.getPrototypeOf(t).prototype,e,n);const r=Object.getOwnPropertyDescriptors(o);for(const[e,n]of Object.entries(r))"prototype"!==e&&Object.defineProperty(Object.getPrototypeOf(t),e,n)},m=customElements.get("card-maker");if(!m||!m.version||m.version{if(!t)return;const s=e[function(){let t=0;for(let s=0;sthis.place_cards()),window.addEventListener("hass-open-menu",()=>setTimeout(()=>this.place_cards(),100)),window.addEventListener("hass-close-menu",()=>setTimeout(()=>this.place_cards(),100)),window.addEventListener("location-changed",()=>{""===location.hash&&setTimeout(()=>this.place_cards(),100)})}async updated(t){!this.cards.length&&(this._config.entities&&this._config.entities.length||this._config.cards&&this._config.cards.length)&&(this.cards=await this.build_cards(),this.place_cards()),t.has("hass")&&this.hass&&this.cards&&this.cards.forEach(t=>{t&&(t.hass=this.hass)})}async build_card(t){if("break"===t)return null;const e=document.createElement("card-maker");return e.config={...t,...this._config.card_options},e.hass=l(),this.shadowRoot.querySelector("#staging").appendChild(e),new Promise((t,n)=>e.updateComplete.then(()=>t(e)))}async build_cards(){const t=this.shadowRoot.querySelector("#staging");for(;t.lastChild;)t.removeChild(t.lastChild);return Promise.all((this._config.entities||this._config.cards).map(t=>this.build_card(t)))}place_cards(){const t=this.shadowRoot.querySelector("#columns").clientWidth;this.columns=function(t,e,n){const s=t=>"string"==typeof t&&t.endsWith("%")?Math.floor(e*parseInt(t)/100):parseInt(t);let o=0;if("object"==typeof n.column_width){let t=e;for(;t>0;){let e=n.column_width[o];void 0===e&&(e=n.column_width.slice(-1)[0]),t-=s(e),o+=1}o=Math.max(o-1,1)}else o=Math.floor(e/s(n.column_width));o=Math.max(o,n.min_columns),o=Math.min(o,n.max_columns);let i=[];for(let t=0;t{if(s+=1,!t)return;const n=e[(s-1)%e.length];n.appendChild(t),n.length+=t.getCardSize?t.getCardSize():1})}(t,i);break;case"vertical":!function(t,e,n){let s=0;t.forEach(t=>{if(!t)return void(s+=1);const n=e[s%e.length];n.appendChild(t),n.length+=t.getCardSize?t.getCardSize():1})}(t,i);break;case"auto":default:g(t,i,n)}return i=i.filter(t=>t.childElementCount>0)}(this.cards,t,this._config),this._config.rtl&&this.columns.reverse(),this.format_columns(),this.requestUpdate()}format_columns(){const t=(t,e,n,s="px")=>{if(void 0===this._config[e])return"";let o=`${t}: `;const i=this._config[e];return"object"==typeof i?i.length>n?o+=`${i[n]}`:o+=`${i.slice(-1)}`:o+=`${i}`,o.endsWith("px")||o.endsWith("%")||(o+=s),o+";"};for(const[e,n]of this.columns.entries()){const s=[t("max-width","max_width",e),t("min-width","min_width",e),t("width","column_width",e),t("flex-grow","flex_grow",e,"")];n.style.cssText="".concat(...s)}}getCardSize(){if(this.columns)return Math.max.apply(Math,this.columns.map(t=>t.length))}_isPanel(){if(this.isPanel)return!0;let t=this.parentElement,e=10;for(;e--;){if("hui-panel-view"===t.localName)return!0;if("div"===t.localName)return!1;t=t.parentElement}return!1}render(){return o`
+
+ ${this.columns.map(t=>o`
+ ${t}
+ `)}
+
+
+ `}static get styles(){return i`
:host {
- padding: 8px 4px 0;
+ padding: 0 4px;
display: block;
+ margin-bottom: 0!important;
}
#columns {
display: flex;
flex-direction: row;
justify-content: center;
+ margin-top: -8px;
+ }
+ #columns.panel {
+ margin-top: 0;
}
.column {
@@ -65,130 +34,19 @@ class LayoutCard extends cardTools.LitElement {
overflow-x: hidden;
}
- .column > * {
+ card-maker>* {
display: block;
margin: 4px 4px 8px;
}
-
- .column > *:first-child {
- margin-top: 0;
+ card-maker:first-child>* {
+ margin-top: 8px;
}
- `;
- }
-
- make_cards() {
- this._cards = this.config.cards.map((c) => {
- if (typeof c === 'string') return c;
- const card = cardTools.createCard(c);
- if(this._hass) card.hass = this._hass;
- this.appendChild(card); // Place card in DOM to get size
- return card;
- });
- }
-
- update_columns() {
- const width = (this.shadowRoot && this.shadowRoot.querySelector("#columns").clientWidth) || (this.parentElement && this.parentElement.clientWidth);
- this.colNum = Math.floor(width / this.colWidth) || 1;
- this.colNum = Math.max(this.colNum, this.minCols);
- this.colNum = Math.min(this.colNum, this.maxCols);
- }
-
- build() {
- if (this.offsetParent === null) return;
- const root = this.shadowRoot.querySelector("#columns");
- while(root.lastChild) {
- root.removeChild(root.lastChild);
- }
-
- this.update_columns();
-
- if(!this._cards) this.make_cards();
-
- let cols = [];
- let colSize = [];
- for(let i = 0; i < this.colNum; i++) {
- cols.push([]);
- colSize.push(0);
- }
-
- const shortestCol = () => {
- let i = 0;
- for(let j = 0; j < this.colNum; j++) {
- if(colSize[j] < this.min_height)
- return j;
- if(colSize[j] < colSize[i])
- i = j;
+ card-maker:last-child>* {
+ margin-bottom: 4px;
}
- return i;
- }
- let i = 0;
- this._cards.forEach((c) => {
- const isBreak = (typeof(c) === 'string');
- const sz = c.getCardSize ? c.getCardSize() : 1;
-
- switch(this.layout) {
- case 'horizontal':
- if(i >= this.colNum) i = 0;
- i += 1;
- if(isBreak) break;
- cols[i-1].push(c);
- colSize[i-1] += sz;
- break;
- case 'vertical':
- if(isBreak){
- i += 1;
- if(i >= this.colNum)
- i = 0;
- break;
- }
- cols[i].push(c);
- colSize[i] += sz;
- break;
- case 'auto':
- default:
- if(isBreak) break;
- cols[shortestCol()].push(c);
- colSize[shortestCol()] += sz;
- break;
+ #staging {
+ visibility: hidden;
+ height: 0;
}
- });
-
- cols = cols.filter((c) => c.length > 0);
- cols.forEach((c, i) => {
- const div = document.createElement('div');
- div.classList.add('column');
- c.forEach((e) => div.appendChild(e));
- root.appendChild(div);
- if(cols.length > 1 && typeof(this.maxWidth) === 'object') {
- div.style.setProperty('max-width', this.maxWidth[i]);
- } else {
- div.style.setProperty('max-width', this.maxWidth+'px');
- }
- });
-
- this.cardSize = Math.max.apply(null, colSize);
- }
-
- set hass(hass) {
- this._hass = hass;
- if(this._cards)
- this._cards
- .filter((c) => typeof(c) !== 'string')
- .forEach((c) => c.hass = hass);
- }
-
- getCardSize() {
- return this.cardSize;
- }
-
-}
-
-customElements.define('layout-card', LayoutCard);
-});
-window.setTimeout(() => {
- if(customElements.get('card-tools')) return;
- customElements.define('layout-card', class extends HTMLElement{
- setConfig() { throw new Error("Can't find card-tools. See https://github.com/thomasloven/lovelace-card-tools");}
- });
-}, 2000);
+ `}get _cardModder(){return{target:this}}})}]);
\ No newline at end of file
diff --git a/www/community/lovelace-layout-card/layout-card.js.gz b/www/community/lovelace-layout-card/layout-card.js.gz
index 95f2073..b528d4b 100644
Binary files a/www/community/lovelace-layout-card/layout-card.js.gz and b/www/community/lovelace-layout-card/layout-card.js.gz differ
diff --git a/www/community/lovelace-layout-card/webpack.config.js b/www/community/lovelace-layout-card/webpack.config.js
new file mode 100644
index 0000000..e24daea
--- /dev/null
+++ b/www/community/lovelace-layout-card/webpack.config.js
@@ -0,0 +1,10 @@
+const path = require('path');
+
+module.exports = {
+ entry: './src/main.js',
+ mode: 'production',
+ output: {
+ filename: 'layout-card.js',
+ path: path.resolve(__dirname)
+ }
+};
\ No newline at end of file
diff --git a/www/community/lovelace-layout-card/webpack.config.js.gz b/www/community/lovelace-layout-card/webpack.config.js.gz
new file mode 100644
index 0000000..d279897
Binary files /dev/null and b/www/community/lovelace-layout-card/webpack.config.js.gz differ
diff --git a/www/community/lovelace-multiple-entity-row/multiple-entity-row.js b/www/community/lovelace-multiple-entity-row/multiple-entity-row.js
index 435f838..cf5c375 100644
--- a/www/community/lovelace-multiple-entity-row/multiple-entity-row.js
+++ b/www/community/lovelace-multiple-entity-row/multiple-entity-row.js
@@ -17,6 +17,7 @@ class MultipleEntityRow extends Polymer.Element {
}
.info {
flex: 1 0 60px;
+ cursor: pointer;
}
.info, .info > * {
white-space: nowrap;
@@ -36,10 +37,12 @@ class MultipleEntityRow extends Polymer.Element {
}
state-badge {
flex: 0 0 40px;
+ cursor: pointer;
}
.entity {
margin-right: 16px;
text-align: center;
+ cursor: pointer;
}
.entity span {
font-size: 10px;
@@ -50,58 +53,93 @@ class MultipleEntityRow extends Polymer.Element {
}
.state {
min-width: 45px;
- text-align: end;
}
.toggle {
margin-left: 8px;
}
-
-
+
+
- [[entityName(_config)]]
+ [[entityName(main)]]
-
+
[[entityName(info)]] [[entityState(info)]]
-
-
+
+
-
-
-
[[entityName(primary)]]
-
[[entityState(primary)]]
+
+
+
[[entityName(primary)]]
+
+
+
+
+ [[entityState(primary)]]
-
-
-
-
[[entityName(secondary)]]
-
[[entityState(secondary)]]
-
-
-
-
- [[entityState(_config)]]
-
-
-
+
+
+
[[entityName(secondary)]]
+
+
+
+
+ [[entityState(secondary)]]
+
+
+
+
+
+
[[entityName(tertiary)]]
+
+
+
+
+ [[entityState(tertiary)]]
+
+
+
+
+
+
+ [[_config.name_state]]
+
+
+
+
+
+
+
+ [[entityState(main)]]
+
`;
}
+ defaultMoreInfo(e) {
+ e.stopPropagation();
+ this.fireEvent(this.main.entity);
+ }
+
primaryMoreInfo(e) {
e.stopPropagation();
- this.fireEvent(this._config.primary.entity)
+ this.fireEvent(this.primary.entity);
}
secondaryMoreInfo(e) {
e.stopPropagation();
- this.fireEvent(this._config.secondary.entity)
+ this.fireEvent(this.secondary.entity);
+ }
+
+ tertiaryMoreInfo(e) {
+ e.stopPropagation();
+ this.fireEvent(this.tertiary.entity);
}
entityName(data) {
@@ -111,7 +149,7 @@ class MultipleEntityRow extends Polymer.Element {
entityState(data) {
if (!data || !data.stateObj) return this._hass.localize('state.default.unavailable');
return data.attribute
- ? data.stateObj.attributes[data.attribute]
+ ? (data.attribute in data.stateObj.attributes)
? `${data.stateObj.attributes[data.attribute]} ${data.unit ? data.unit : ''}`
: this._hass.localize('state.default.unavailable')
: this.computeStateValue(data.stateObj, data.unit);
@@ -134,8 +172,8 @@ class MultipleEntityRow extends Polymer.Element {
if (!display) {
display = this._hass.localize(`state.${domain}.default.${stateObj.state}`);
}
- } else if ((unit || stateObj.attributes.unit_of_measurement) && !["unknown", "unavailable"].includes(stateObj.state)) {
- display = `${stateObj.state} ${stateObj.attributes.unit_of_measurement}`;
+ } else if (unit !== false && (unit || stateObj.attributes.unit_of_measurement) && !["unknown", "unavailable"].includes(stateObj.state)) {
+ display = `${stateObj.state} ${unit || stateObj.attributes.unit_of_measurement}`;
} else if (domain === "zwave") {
display = ["initializing", "dead"].includes(stateObj.state)
? this._hass.localize(`state.zwave.query_stage.${stateObj.state}`, 'query_stage', stateObj.attributes.query_stage)
@@ -154,14 +192,13 @@ class MultipleEntityRow extends Polymer.Element {
if (!config.entity) throw new Error('Please define an entity.');
if (config.primary && !config.primary.entity) throw new Error('Please define a primary entity.');
if (config.secondary && !config.secondary.entity) throw new Error('Please define a secondary entity.');
+ if (config.tertiary && !config.tertiary.entity) throw new Error('Please define a tertiary entity.');
+ if (config.info && !config.info.entity) throw new Error('Please define an info entity.');
+
+ this.showMainHeader = config.name_state;
+ this.showLastChanged = config.secondary_info === 'last-changed' && !config.info;
this._config = config;
- this.displayToggle = config.toggle === true;
- this.displayValue = !this.displayToggle && !config.hide_state;
- this.displayPrimary = config.primary && config.primary.entity;
- this.displaySecondary = config.secondary && config.secondary.entity;
- this.displayInfo = config.info && config.info.entity;
- this.displayLastChanged = !this.displayInfo && config.secondary_info === 'last-changed';
}
set hass(hass) {
@@ -170,24 +207,27 @@ class MultipleEntityRow extends Polymer.Element {
if (hass && this._config) {
const stateObj = this._config.entity in hass.states ? hass.states[this._config.entity] : null;
if (stateObj) {
- this._config.stateObj = stateObj;
-
- this.primary = Object.assign({}, this._config.primary, {
- stateObj: this.displayPrimary && this._config.primary.entity in hass.states ?
- hass.states[this._config.primary.entity] : null
- });
- this.secondary = Object.assign({}, this._config.secondary, {
- stateObj: this.displaySecondary && this._config.secondary.entity in hass.states ?
- hass.states[this._config.secondary.entity] : null
- });
- this.info = Object.assign({}, this._config.info, {
- stateObj: this.displayInfo && this._config.info.entity in hass.states ?
- hass.states[this._config.info.entity] : null
- });
+ this.main = this.initEntity(this._config);
+ this.primary = this.initEntity(this._config.primary);
+ this.secondary = this.initEntity(this._config.secondary);
+ this.tertiary = this.initEntity(this._config.tertiary);
+ this.info = this.initEntity(this._config.info);
}
}
}
+ initEntity(config) {
+ const stateObj = config && config.entity && this._hass.states[config.entity];
+ return stateObj ? Object.assign({}, config, {
+ stateObj: stateObj,
+ showToggle: this.validateToggle(config, stateObj),
+ }) : null;
+ }
+
+ validateToggle(config, stateObj) {
+ return config && config.toggle === true && stateObj && (stateObj.state === "on" || stateObj.state === "off");
+ }
+
fireEvent(entity, options = {}) {
const event = new Event('hass-more-info', {
bubbles: options.bubbles || true,
diff --git a/www/community/lovelace-multiple-entity-row/multiple-entity-row.js.gz b/www/community/lovelace-multiple-entity-row/multiple-entity-row.js.gz
index 2ec8419..70242b5 100644
Binary files a/www/community/lovelace-multiple-entity-row/multiple-entity-row.js.gz and b/www/community/lovelace-multiple-entity-row/multiple-entity-row.js.gz differ
diff --git a/www/community/lovelace-slider-entity-row/slider-entity-row.js b/www/community/lovelace-slider-entity-row/slider-entity-row.js
index 417548f..41b2961 100644
--- a/www/community/lovelace-slider-entity-row/slider-entity-row.js
+++ b/www/community/lovelace-slider-entity-row/slider-entity-row.js
@@ -1,39 +1,41 @@
-!function(t){var e={};function s(i){if(e[i])return e[i].exports;var a=e[i]={i:i,l:!1,exports:{}};return t[i].call(a.exports,a,a.exports,s),a.l=!0,a.exports}s.m=t,s.c=e,s.d=function(t,e,i){s.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},s.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},s.t=function(t,e){if(1&e&&(t=s(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(s.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var a in t)s.d(i,a,function(e){return t[e]}.bind(null,a));return i},s.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return s.d(e,"a",e),e},s.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},s.p="",s(s.s=0)}([function(t,e,s){"use strict";s.r(e);const i=Object.getPrototypeOf(customElements.get("home-assistant-main")),a=i.prototype.html,r=i.prototype.css;class n{constructor(t){this._config=t}set hass(t){this._hass=t,this.stateObj=this._config.entity in t.states?t.states[this._config.entity]:null}get value(){return this._value?Math.round(this._value/this.step)*this.step:0}set value(t){t!==this.value&&(this._value=t)}get string(){return`${this.value}`}get hidden(){return!1}get hasSlider(){return!0}get hasToggle(){return!0}get isOff(){return 0===this.value}get min(){return void 0!==this._config.min?this._config.min:void 0!==this._min?this._min:0}get max(){return void 0!==this._config.max?this._config.max:void 0!==this._max?this._max:100}get step(){return void 0!==this._config.step?this._config.step:void 0!==this._step?this._step:5}}const u={light:class extends n{get _value(){return"on"===this.stateObj.state?Math.ceil(100*this.stateObj.attributes.brightness/255):0}set _value(t){(t=Math.ceil(t/100*255))?this._hass.callService("light","turn_on",{entity_id:this.stateObj.entity_id,brightness:t}):this._hass.callService("light","turn_off",{entity_id:this.stateObj.entity_id})}get string(){return"off"===this.stateObj.state?this._hass.localize("state.default.off"):`${this.value} %`}get hasSlider(){return"brightness"in this.stateObj.attributes||!!("supported_features"in this.stateObj.attributes&&1&this.stateObj.attributes.supported_features)}},media_player:class extends n{get _value(){return"on"===this.stateObj.is_volume_muted?0:Math.ceil(100*this.stateObj.attributes.volume_level)}set _value(t){t/=100,this._hass.callService("media_player","volume_set",{entity_id:this.stateObj.entity_id,volume_level:t})}get isOff(){return"off"===this.stateObj.state}get string(){return this.stateObj.attributes.is_volume_muted?"-":this.stateObj.attributes.volume_level?`${this.value} %`:this._hass.localize("state.media_player.off")}get hasToggle(){return!1}},climate:class extends n{get _value(){return this.stateObj.attributes.temperature}set _value(t){this._hass.callService("climate","set_temperature",{entity_id:this.stateObj.entity_id,temperature:t})}get string(){return"off"===this.stateObj.attributes.operation_mode?this._hass.localize("state.climate.off"):`${this.value} ${this._hass.config.unit_system.temperature}`}get isOff(){return"off"===this.stateObj.attributes.operation_mode}get _min(){return this.stateObj.attributes.min_temp}get _max(){return this.stateObj.attributes.max_temp}get _step(){return 1}},cover:class extends n{get _value(){return"open"===this.stateObj.state?this.stateObj.attributes.current_position:0}set _value(t){this._hass.callService("cover","set_cover_position",{entity_id:this.stateObj.entity_id,position:t})}get string(){return this.hasSlider?"closed"===this.stateObj.state?this._hass.localize("state.cover.closed"):`${this.value} %`:""}get hasToggle(){return!1}get hasSlider(){return"current_position"in this.stateObj.attributes||!!("supported_features"in this.stateObj.attributes&&4&this.stateObj.attributes.supported_features)}get _step(){return 10}},fan:class extends n{get _value(){return"off"!==this.stateObj.state?this.stateObj.attributes.speed_list.indexOf(this.stateObj.attributes.speed):0}set _value(t){t in this.stateObj.attributes.speed_list?this._hass.callService("fan","turn_on",{entity_id:this.stateObj.entity_id,speed:this.stateObj.attributes.speed_list[t]}):this._hass.callService("fan","turn_off",{entity_id:this.stateObj.entity_id})}get string(){return"off"===this.stateObj.state?this._hass.localize("state.default.off"):this.stateObj.attributes.speed}get hasSlider(){return"speed"in this.stateObj.attributes}get _max(){return this.stateObj.attributes.speed_list.length-1}get _step(){return 1}},input_number:class extends n{get _value(){return this.stateObj.state}set _value(t){this._hass.callService("input_number","set_value",{entity_id:this.stateObj.entity_id,value:t})}get string(){return`${parseFloat(this.stateObj.state)}`}get isOff(){return!1}get hasToggle(){return!1}get hasSlider(){return"slider"===this.stateObj.attributes.mode}get _min(){return this.stateObj.attributes.min}get _max(){return this.stateObj.attributes.max}get _step(){return this.stateObj.attributes.step}},input_select:class extends n{get _value(){return this.stateObj.attributes.options.indexOf(this.stateObj.state)}set _value(t){t in this.stateObj.attributes.options&&this._hass.callService("input_select","select_option",{entity_id:this.stateObj.entity_id,option:this.stateObj.attributes.options[t]})}get string(){return this.stateObj.state}get isOff(){return!1}get hasToggle(){return!1}get hasSlider(){return this.stateObj.attributes.options&&this.stateObj.attributes.options.length>0}get _max(){return this.stateObj.attributes.options.length-1}get _step(){return 1}}};customElements.define("slider-entity-row",class extends i{static get properties(){return{hass:{}}}setConfig(t){this._config=t;const e=t.entity.split(".")[0],s=u[e];if(!s)throw new Error(`Unsupported entity type: ${e}`);this.ctrl=new s(t)}render(){const t=this.ctrl;t.hass=this.hass;const e=a`
+!function(t){var e={};function s(i){if(e[i])return e[i].exports;var a=e[i]={i:i,l:!1,exports:{}};return t[i].call(a.exports,a,a.exports,s),a.l=!0,a.exports}s.m=t,s.c=e,s.d=function(t,e,i){s.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},s.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},s.t=function(t,e){if(1&e&&(t=s(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(s.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var a in t)s.d(i,a,function(e){return t[e]}.bind(null,a));return i},s.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return s.d(e,"a",e),e},s.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},s.p="",s(s.s=0)}([function(t,e,s){"use strict";s.r(e);const i=customElements.get("home-assistant-main")?Object.getPrototypeOf(customElements.get("home-assistant-main")):Object.getPrototypeOf(customElements.get("hui-view")),a=i.prototype.html,r=i.prototype.css;class u{constructor(t){this._config=t}set hass(t){this._hass=t,this.stateObj=this._config.entity in t.states?t.states[this._config.entity]:null}get value(){return this._value?Math.round(this._value/this.step)*this.step:0}set value(t){t!==this.value&&(this._value=t)}get string(){return`${this.value}`}get hidden(){return!1}get hasSlider(){return!0}get hasToggle(){return!0}get isOff(){return 0===this.value}get min(){return void 0!==this._config.min?this._config.min:void 0!==this._min?this._min:0}get max(){return void 0!==this._config.max?this._config.max:void 0!==this._max?this._max:100}get step(){return void 0!==this._config.step?this._config.step:void 0!==this._step?this._step:5}}const n={light:class extends u{get attribute(){return this._config.attribute||"brightness"}get _value(){if(!this.stateObj||"on"!==this.stateObj.state)return 0;switch(this.attribute){case"color_temp":return Math.ceil(this.stateObj.attributes.color_temp);case"white_value":return Math.ceil(this.stateObj.attributes.white_value);case"brightness":return Math.ceil(100*this.stateObj.attributes.brightness/255);case"red":return this.stateObj.attributes.rgb_color?Math.ceil(this.stateObj.attributes.rgb_color[0]):0;case"green":return this.stateObj.attributes.rgb_color?Math.ceil(this.stateObj.attributes.rgb_color[1]):0;case"blue":return this.stateObj.attributes.rgb_color?Math.ceil(this.stateObj.attributes.rgb_color[2]):0;case"hue":return this.stateObj.attributes.hs_color?Math.ceil(this.stateObj.attributes.hs_color[0]):0;case"saturation":return this.stateObj.attributes.hs_color?Math.ceil(this.stateObj.attributes.hs_color[1]):0;case"effect":return this.stateObj.attributes.effect_list?this.stateObj.attributes.effect_list.indexOf(this.stateObj.attributes.effect):0;default:return 0}}get _step(){switch(this.attribute){case"effect":return 1;default:return 5}}get _min(){switch(this.attribute){case"color_temp":return this.stateObj?this.stateObj.attributes.min_mireds:0;default:return 0}}get _max(){switch(this.attribute){case"color_temp":return this.stateObj?this.stateObj.attributes.max_mireds:0;case"red":case"green":case"blue":case"white_value":return 255;case"hue":return 360;case"effect":return this.stateObj&&this.stateObj.attributes.effect_list?this.stateObj.attributes.effect_list.length-1:0;default:return 100}}set _value(t){if(!this.stateObj)return;let e,s=this.attribute,i=!0;switch(s){case"brightness":(t=Math.ceil(t/100*255))||(i=!1);break;case"red":case"green":case"blue":e=this.stateObj.attributes.rgb_color||[0,0,0],"red"===s&&(e[0]=t),"green"===s&&(e[1]=t),"blue"===s&&(e[2]=t),t=e,s="rgb_color";break;case"hue":case"saturation":e=this.stateObj.attributes.hs_color||[0,0],"hue"===s&&(e[0]=t),"saturation"===s&&(e[1]=t),t=e,s="hs_color";break;case"effect":t=this.stateObj.attributes.effect_list[t],s="effect"}i?this._hass.callService("light","turn_on",{entity_id:this.stateObj.entity_id,[s]:t}):this._hass.callService("light","turn_off",{entity_id:this.stateObj.entity_id})}get string(){if(this.stateObj&&"off"===this.stateObj.state)return this._hass.localize("state.default.off");switch(this.attribute){case"color_temp":return`${this.value} K`;case"brightness":case"saturation":return`${this.value} %`;case"hue":return`${this.value} °`;case"effect":return this.stateObj?this.stateObj.attributes.effect:"";default:return this.value}}get hasSlider(){if(!this.stateObj)return!1;switch(this.attribute){case"brightness":return"brightness"in this.stateObj.attributes||!!("supported_features"in this.stateObj.attributes&&1&this.stateObj.attributes.supported_features);case"color_temp":return"color_temp"in this.stateObj.attributes||!!("supported_features"in this.stateObj.attributes&&2&this.stateObj.attributes.supported_features);case"white_value":return"white_value"in this.stateObj.attributes||!!("supported_features"in this.stateObj.attributes&&128&this.stateObj.attributes.supported_features);case"red":case"green":case"blue":return"rgb_color"in this.stateObj.attributes||!!("supported_features"in this.stateObj.attributes&&16&this.stateObj.attributes.supported_features);case"hue":case"saturation":return"hs_color"in this.stateObj.attributes||!!("supported_features"in this.stateObj.attributes&&16&this.stateObj.attributes.supported_features);case"effect":return"effect"in this.stateObj.attributes;default:return!1}}},media_player:class extends u{get _value(){return"on"===this.stateObj.is_volume_muted?0:Math.ceil(100*this.stateObj.attributes.volume_level)}set _value(t){t/=100,this._hass.callService("media_player","volume_set",{entity_id:this.stateObj.entity_id,volume_level:t})}get isOff(){return"off"===this.stateObj.state}get string(){return this.stateObj.attributes.is_volume_muted?"-":this.stateObj.attributes.volume_level?`${this.value} %`:this._hass.localize("state.media_player.off")}get hasToggle(){return!1}},climate:class extends u{get _value(){return this.stateObj.attributes.temperature}set _value(t){this._hass.callService("climate","set_temperature",{entity_id:this.stateObj.entity_id,temperature:t})}get string(){return"off"===this.stateObj.attributes.hvac_mode?this._hass.localize("state.climate.off"):`${this.value} ${this._hass.config.unit_system.temperature}`}get isOff(){return"off"===this.stateObj.attributes.hvac_mode}get _min(){return this.stateObj.attributes.min_temp}get _max(){return this.stateObj.attributes.max_temp}get _step(){return 1}},cover:class extends u{get attribute(){return this._config.attribute||"position"}get _value(){switch(this.attribute){case"position":return"closed"===this.stateObj.state?0:this.stateObj.attributes.current_position;case"tilt":return this.stateObj.attributes.current_tilt_position;default:return 0}}set _value(t){switch(this.attribute){case"position":this._hass.callService("cover","set_cover_position",{entity_id:this.stateObj.entity_id,position:t});break;case"tilt":this._hass.callService("cover","set_cover_tilt_position",{entity_id:this.stateObj.entity_id,tilt_position:t})}}get string(){if(!this.hasSlider)return"";switch(this.attribute){case"position":return"closed"===this.stateObj.state?this._hass.localize("state.cover.closed"):`${this.value} %`;case"tilt":return this.value}}get hasToggle(){return!1}get hasSlider(){switch(this.attribute){case"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;case"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;default:return!1}}get _step(){return 10}},fan:class extends u{get _value(){return"off"!==this.stateObj.state?this.stateObj.attributes.speed_list.indexOf(this.stateObj.attributes.speed):0}set _value(t){t in this.stateObj.attributes.speed_list?this._hass.callService("fan","turn_on",{entity_id:this.stateObj.entity_id,speed:this.stateObj.attributes.speed_list[t]}):this._hass.callService("fan","turn_off",{entity_id:this.stateObj.entity_id})}get string(){return"off"===this.stateObj.state?this._hass.localize("state.default.off"):this.stateObj.attributes.speed}get hasSlider(){return"speed"in this.stateObj.attributes}get _max(){return this.stateObj.attributes.speed_list.length-1}get _step(){return 1}},input_number:class extends u{get _value(){return this.stateObj.state}set _value(t){this._hass.callService("input_number","set_value",{entity_id:this.stateObj.entity_id,value:t})}get string(){return`${parseFloat(this.stateObj.state)} ${this.stateObj.attributes.unit_of_measurement||""}`.trim()}get isOff(){return!1}get hasToggle(){return!1}get hasSlider(){return"slider"===this.stateObj.attributes.mode}get _min(){return this.stateObj.attributes.min}get _max(){return this.stateObj.attributes.max}get _step(){return this.stateObj.attributes.step}},input_select:class extends u{get _value(){return this.stateObj.attributes.options.indexOf(this.stateObj.state)}set _value(t){t in this.stateObj.attributes.options&&this._hass.callService("input_select","select_option",{entity_id:this.stateObj.entity_id,option:this.stateObj.attributes.options[t]})}get string(){return this.stateObj.state}get isOff(){return!1}get hasToggle(){return!1}get hasSlider(){return this.stateObj.attributes.options&&this.stateObj.attributes.options.length>0}get _max(){return this.stateObj.attributes.options.length-1}get _step(){return 1}}};customElements.define("slider-entity-row",class extends i{static get properties(){return{hass:{}}}setConfig(t){this._config=t;const e=t.entity.split(".")[0],s=n[e];if(!s)throw new Error(`Unsupported entity type: ${e}`);this.ctrl=new s(t)}render(){const t=this.ctrl;t.hass=this.hass;const e=this.hass.translationMetadata.translations[this.hass.language||"en"].isRTL?"rtl":"ltr",s=a`
t.value=this.shadowRoot.querySelector("ha-slider").value}
class=${this._config.full_row?"full":""}
+ ignore-bar-touch
>
- `,s=a`
+ `,i=a`
- `,i=a`
+ `,r=a`
t.stopPropagation()}>
${"unavailable"===t.stateObj.state?a`
unavailable
`:a`
- ${this._config.hide_when_off&&t.isOff||!t.hasSlider?"":e}
+ ${this._config.hide_when_off&&t.isOff||!t.hasSlider?"":s}
${this._config.hide_state||this._config.toggle?"":a`
${t.string}
`}
- ${this._config.toggle&&t.hasToggle?s:""}
+ ${this._config.toggle&&t.hasToggle?i:""}
`}
- `;return this._config.full_row?i:a`
+ `;return this._config.full_row?r:a`
${i}
+ > ${r}
`}static get styles(){return r`
.wrapper {
display: flex;
diff --git a/www/community/lovelace-slider-entity-row/slider-entity-row.js.gz b/www/community/lovelace-slider-entity-row/slider-entity-row.js.gz
index 216a6eb..175922a 100644
Binary files a/www/community/lovelace-slider-entity-row/slider-entity-row.js.gz and b/www/community/lovelace-slider-entity-row/slider-entity-row.js.gz differ
diff --git a/www/community/lovelace-slider-entity-row/webpack.config.js b/www/community/lovelace-slider-entity-row/webpack.config.js
new file mode 100644
index 0000000..46d9e0c
--- /dev/null
+++ b/www/community/lovelace-slider-entity-row/webpack.config.js
@@ -0,0 +1,10 @@
+const path = require('path');
+
+module.exports = {
+ entry: './src/main.js',
+ mode: 'production',
+ output: {
+ filename: 'slider-entity-row.js',
+ path: path.resolve(__dirname)
+ }
+};
diff --git a/www/community/lovelace-slider-entity-row/webpack.config.js.gz b/www/community/lovelace-slider-entity-row/webpack.config.js.gz
new file mode 100644
index 0000000..aac74bd
Binary files /dev/null and b/www/community/lovelace-slider-entity-row/webpack.config.js.gz differ
diff --git a/www/community/lovelace-xiaomi-vacuum-card/xiaomi-vacuum-card.js b/www/community/lovelace-xiaomi-vacuum-card/xiaomi-vacuum-card.js
index 61afd85..496b9c8 100644
--- a/www/community/lovelace-xiaomi-vacuum-card/xiaomi-vacuum-card.js
+++ b/www/community/lovelace-xiaomi-vacuum-card/xiaomi-vacuum-card.js
@@ -55,16 +55,16 @@ class XiaomiVacuumCard extends Polymer.Element {
-
[[_config.labels.status]]: [[stateObj.attributes.status]]
-
[[_config.labels.battery]]: [[stateObj.attributes.battery_level]] %
-
[[_config.labels.mode]]: [[stateObj.attributes.fan_speed]]
+
[[getValue('status')]]
+
[[getValue('battery', ' %')]]
+
[[getValue('mode')]]
-
[[_config.labels.main_brush]]: [[stateObj.attributes.main_brush_left]] [[_config.labels.hours]]
-
[[_config.labels.side_brush]]: [[stateObj.attributes.side_brush_left]] [[_config.labels.hours]]
-
[[_config.labels.filter]]: [[stateObj.attributes.filter_left]] [[_config.labels.hours]]
-
[[_config.labels.sensor]]: [[stateObj.attributes.sensor_dirty_left]] [[_config.labels.hours]]
+
[[computeValue('main_brush')]]
+
[[computeValue('side_brush')]]
+
[[computeValue('filter')]]
+
[[computeValue('sensor')]]
@@ -165,11 +165,32 @@ class XiaomiVacuumCard extends Polymer.Element {
return: true,
};
+ const attributes = {
+ status: 'status',
+ battery: 'battery_level',
+ mode: 'fan_speed',
+ main_brush: 'main_brush_left',
+ side_brush: 'side_brush_left',
+ filter: 'filter_left',
+ sensor: 'sensor_dirty_left',
+ };
+
const vendors = {
xiaomi: {
image: '/local/img/vacuum.png',
details: true,
},
+ valetudo: {
+ image: '/local/img/vacuum.png',
+ details: true,
+ attributes: {
+ status: 'state',
+ main_brush: 'mainBrush',
+ side_brush: 'sideBrush',
+ filter: 'filter',
+ sensor: 'sensor',
+ },
+ },
ecovacs: {
image: '/local/img/vacuum_ecovacs.png',
details: false,
@@ -182,6 +203,21 @@ class XiaomiVacuumCard extends Polymer.Element {
pause: 'stop',
stop: 'turn_off',
},
+ },
+ deebot: {
+ image: '/local/img/vacuum_ecovacs.png',
+ details: true,
+ service: {
+ start: 'turn_on',
+ pause: 'stop',
+ stop: 'turn_off',
+ },
+ attributes: {
+ main_brush: 'component_main_brush',
+ side_brush: 'component_side_brush',
+ filter: 'component_filter',
+ },
+ computeValue: v => Math.round(Number(v) / 100),
}
};
@@ -196,8 +232,25 @@ class XiaomiVacuumCard extends Polymer.Element {
config.service = Object.assign({}, services, vendor.service);
config.buttons = Object.assign({}, buttons, vendor.buttons, config.buttons);
+ config.attributes = Object.assign({}, attributes, vendor.attributes, config.attributes);
config.labels = Object.assign({}, labels, config.labels);
+ this.getValue = (field, unit = '') => {
+ const value = (this.stateObj && config.attributes[field] in this.stateObj.attributes)
+ ? this.stateObj.attributes[config.attributes[field]] + unit
+ : (this._hass ? this._hass.localize('state.default.unavailable') : 'Unavailable');
+ return `${config.labels[field]}: ${value}`;
+ };
+
+ this.computeValue = field => {
+ if (this.stateObj && config.attributes[field] in this.stateObj.attributes) {
+ const value = this.stateObj.attributes[config.attributes[field]];
+ return `${config.labels[field]}: ${vendor.computeValue ? vendor.computeValue(value) : value} ${config.labels.hours}`;
+ } else {
+ return `${config.labels[field]}: - `;
+ }
+ };
+
this.contentText = `color: ${config.image !== false ? 'white; text-shadow: 0 0 10px black;' : 'var(--primary-text-color)'}`;
this.contentStyle = `padding: ${this.showButtons ? '16px 16px 4px' : '16px'}; ${this.contentText}`;
this.backgroundImage = config.image !== false ? `background-image: url('${config.image || vendor.image}')` : '';
diff --git a/www/community/lovelace-xiaomi-vacuum-card/xiaomi-vacuum-card.js.gz b/www/community/lovelace-xiaomi-vacuum-card/xiaomi-vacuum-card.js.gz
index ef5f3ae..65128ae 100644
Binary files a/www/community/lovelace-xiaomi-vacuum-card/xiaomi-vacuum-card.js.gz and b/www/community/lovelace-xiaomi-vacuum-card/xiaomi-vacuum-card.js.gz differ
diff --git a/www/community/mini-media-player/mini-media-player-bundle.js b/www/community/mini-media-player/mini-media-player-bundle.js
new file mode 100644
index 0000000..2f9e232
--- /dev/null
+++ b/www/community/mini-media-player/mini-media-player-bundle.js
@@ -0,0 +1 @@
+(function(){"use strict";function a(){const b=ya(["
",""]);return a=function(){return b},b}function b(){const a=ya(["
",""]);return b=function(){return a},a}function c(){const a=ya(["\n
"]);return c=function(){return a},a}function d(){const a=ya(["\n
\n ","\n ","\n
"]);return d=function(){return a},a}function e(){const a=ya(["\n
\n "," ","\n
"]);return e=function(){return a},a}function f(){const a=ya(["\n
\n \n
"]);return f=function(){return a},a}function g(){const a=ya(["\n
\n
"]);return g=function(){return a},a}function h(){const a=ya(["
"]);return h=function(){return a},a}function i(){const a=ya(["\n
\n \n "]);return i=function(){return a},a}function j(){const a=ya(["\n
\n \n "]);return j=function(){return a},a}function k(){const a=ya(["\n
\n \n "]);return k=function(){return a},a}function l(){const a=ya(["\n
\n \n ","\n
\n \n
\n ","\n
\n ","\n ","\n
\n
\n \n
\n
\n ","\n \n \n ","\n \n \n
\n
\n \n ","\n
\n \n "]);return l=function(){return a},a}function m(){const a=ya(["\n :host {\n display: flex;\n line-height: 40px;\n max-height: 40px;\n }\n :host([flow]) mmp-media-controls {\n max-width: unset;\n }\n mmp-media-controls {\n max-width: 200px;\n line-height: initial;\n }\n .group-button {\n height: 34px;\n width: 34px;\n min-width: 34px;\n margin: 3px;\n }\n paper-icon-button {\n min-width: 40px;\n }\n "]);return m=function(){return a},a}function n(){const a=ya(["\n
\n ","\n \n "]);return n=function(){return a},a}function o(){const a=ya(["\n
\n "]);return o=function(){return a},a}function p(){const a=ya(["\n
\n "]);return p=function(){return a},a}function q(){const a=ya(["\n
\n "]);return q=function(){return a},a}function r(){const a=ya(["\n
\n "]);return r=function(){return a},a}function s(){const a=ya(["\n
\n "]);return s=function(){return a},a}function t(){const a=ya(["\n
\n \n "]);return t=function(){return a},a}function u(){const a=ya(["\n ","\n ","\n ","\n ","\n ","\n ","\n "]);return u=function(){return a},a}function v(){const a=ya(["\n
\n ","\n \n "]);return v=function(){return a},a}function w(){const a=ya(["\n :host {\n display: flex;\n width: 100%;\n }\n .flex {\n display: flex;\n flex: 1;\n justify-content: space-between;\n }\n ha-slider {\n max-width: none;\n min-width: 100px;\n width: 100%;\n }\n paper-icon-button {\n min-width: 40px;\n }\n .mmp-media-controls__volume {\n flex: 100;\n max-height: 40px;\n }\n .mmp-media-controls__volume.--buttons {\n justify-content: left;\n }\n .mmp-media-controls__media {\n justify-content: flex-end;\n max-width: calc(40px * 4);\n margin-right: 0;\n margin-left: auto;\n }\n .mmp-media-controls__media[flow] {\n max-width: none;\n justify-content: space-between;\n }\n .mmp-media-controls__shuffle {\n flex: 3;\n flex-shrink: 200;\n justify-content: center;\n }\n .mmp-media-controls__shuffle paper-icon-button {\n height: 36px;\n width: 36px;\n min-width: 36px;\n margin: 2px;\n }\n "]);return w=function(){return a},a}function x(){const a=ya([""]);return x=function(){return a},a}function y(){const a=ya(["\n
\n \n "]);return y=function(){return a},a}function z(){const a=ya([""]);return z=function(){return a},a}function A(){const a=ya(["\n
\n \n "]);return A=function(){return a},a}function B(){const a=ya(["\n ","\n ","\n "]);return B=function(){return a},a}function C(){const a=ya(["\n
\n \n "]);return C=function(){return a},a}function D(){const a=ya(["\n
\n \n "]);return D=function(){return a},a}function E(){const a=ya(["\n
\n \n "]);return E=function(){return a},a}function F(){const a=ya(["\n
\n \n "]);return F=function(){return a},a}function G(){const a=ya(["\n
\n \n "]);return G=function(){return a},a}function H(){const a=ya(["\n
"]);return H=function(){return a},a}function I(){const a=ya(["\n
\n ","\n \n \n
"]);return I=function(){return a},a}function J(){const a=ya([""]);return J=function(){return a},a}function K(){const a=ya(["\n
\n "]);return K=function(){return a},a}function L(){const a=ya([""]);return L=function(){return a},a}function M(){const a=ya(["\n
\n "]);return M=function(){return a},a}function N(){const a=ya([""]);return N=function(){return a},a}function O(){const a=ya(["\n ","\n ","\n ","\n "]);return O=function(){return a},a}function P(){const a=ya(["\n :host {\n max-width: 120px;\n min-width: 40px;\n }\n :host([full]) {\n max-width: none;\n }\n "]);return P=function(){return a},a}function Q(){const a=ya(["\n
\n "]);return Q=function(){return a},a}function R(){const a=ya(["\n :host {\n max-width: 120px;\n min-width: 40px;\n }\n :host([full]) {\n max-width: none;\n }\n "]);return R=function(){return a},a}function S(){const a=ya(["\n
\n "]);return S=function(){return a},a}function T(){const a=ya(["\n .mmp-progress {\n cursor: pointer;\n left: 0; right: 0; bottom: 0;\n position: absolute;\n pointer-events: auto;\n min-height: calc(var(--mmp-progress-height) + 10px);\n }\n .mmp-progress__duration {\n left: calc(var(--ha-card-border-radius, 4px) / 2);\n right: calc(var(--ha-card-border-radius, 4px) / 2);\n bottom: calc(var(--mmp-progress-height) + 6px);\n position: absolute;\n display: flex;\n justify-content: space-between;\n font-size: .8em;\n padding: 0 6px;\n z-index: 2\n }\n paper-progress {\n height: var(--mmp-progress-height);\n --paper-progress-height: var(--mmp-progress-height);\n bottom: 0;\n position: absolute;\n width: 100%;\n transition: height 0;\n z-index: 1;\n --paper-progress-active-color: var(--mmp-accent-color);\n --paper-progress-container-color: rgba(100,100,100,.15);\n --paper-progress-transition-duration: 1s;\n --paper-progress-transition-timing-function: linear;\n --paper-progress-transition-delay: 0s;\n }\n paper-progress.seeking {\n transition: height .15s ease-out;\n height: calc(var(--mmp-progress-height) + 4px);\n --paper-progress-height: calc(var(--mmp-progress-height) + 4px);\n }\n .mmp-progress[paused] paper-progress {\n --paper-progress-active-color: var(--disabled-text-color, rgba(150,150,150,.5));\n }\n "]);return T=function(){return a},a}function U(){const a=ya(["\n
\n ","\n ","\n
\n "]);return U=function(){return a},a}function V(){const a=ya(["\n
\n "]);return V=function(){return a},a}function W(){const a=ya(["\n :host {\n align-items: center;\n margin-left: 8px;\n display: flex;\n }\n .mmp-tts__input {\n cursor: text;\n flex: 1;\n margin-right: 8px;\n --paper-input-container-input: {\n font-size: 1em;\n };\n }\n ha-card[rtl] .mmp-tts__input {\n margin-right: auto;\n margin-left: 8px;\n }\n .mmp-tts__button {\n margin: 0;\n height: 30px;\n padding: 0 .4em;\n }\n paper-input {\n opacity: .75;\n --paper-input-container-color: var(--mmp-text-color);\n --paper-input-container-focus-color: var(--mmp-text-color);\n --paper-input-container: {\n padding: 0;\n };\n }\n paper-input[focused] {\n opacity: 1;\n }\n\n ha-card[artwork*='cover'][has-artwork] paper-input {\n --paper-input-container-focus-color: #FFFFFF;\n }\n ha-card[artwork*='cover'][has-artwork] paper-input {\n --paper-input-container-color: #FFFFFF;\n --paper-input-container-input-color: #FFFFFF;\n }\n "]);return W=function(){return a},a}function X(){const a=ya(["\n
\n \n
\n SEND\n \n "]);return X=function(){return a},a}function Y(){const a=ya(["\n .mmp-shortcuts__buttons {\n box-sizing: border-box;\n display: flex;\n flex-wrap: wrap;\n margin-top: 8px;\n }\n .mmp-shortcuts__button {\n min-width: calc(50% - 8px);\n flex: 1;\n }\n .mmp-shortcuts__button > div {\n display: flex;\n justify-content: center;\n align-items: center;\n width: 100%;\n }\n .mmp-shortcuts__button > div[align='left'] {\n justify-content: flex-start;\n }\n .mmp-shortcuts__button > div[align='right'] {\n justify-content: flex-end;\n }\n .mmp-shortcuts__button[columns='1'] {\n min-width: calc(100% - 8px);\n }\n .mmp-shortcuts__button[columns='3'] {\n min-width: calc(33.33% - 8px);\n }\n .mmp-shortcuts__button[columns='4'] {\n min-width: calc(25% - 8px);\n }\n .mmp-shortcuts__button[columns='5'] {\n min-width: calc(20% - 8px);\n }\n .mmp-shortcuts__button[columns='6'] {\n min-width: calc(16.66% - 8px);\n }\n .mmp-shortcuts__button > div > span {\n line-height: 24px;\n text-transform: initial;\n }\n .mmp-shortcuts__button > div > *:nth-child(2) {\n margin-left: 4px;\n }\n "]);return Y=function(){return a},a}function Z(){const a=ya(["\n ","\n ","\n "]);return Z=function(){return a},a}function $(){const a=ya(["
",""]);return $=function(){return a},a}function _(){const a=ya(["
"]);return _=function(){return a},a}function aa(){const a=ya(["\n
\n \n ","\n ","\n
\n "]);return aa=function(){return a},a}function ba(){const a=ya(["\n
\n ","\n
\n "]);return ba=function(){return a},a}function ca(){const a=ya(["\n
\n \n "]);return ca=function(){return a},a}function da(){const a=ya([""]);return da=function(){return a},a}function ea(){const a=ya(["\n :host {\n display: block;\n }\n :host([faded]) {\n opacity: .75;\n }\n :host[small] .mmp-dropdown__label {\n max-width: 60px;\n display: block;\n position: relative;\n width: auto;\n text-transform: initial;\n }\n :host[full] .mmp-dropdown__label {\n max-width: none;\n }\n .mmp-dropdown {\n padding: 0;\n display: block;\n }\n .mmp-dropdown__button {\n display: flex;\n font-size: 1em;\n justify-content: space-between;\n align-items: center;\n height: 36px;\n margin: 2px 0;\n }\n .mmp-dropdown__button.icon {\n height: 40px;\n margin: 0;\n }\n .mmp-dropdown__button > div {\n display: flex;\n flex: 1;\n justify-content: space-between;\n align-items: center;\n height: 36px;\n max-width: 100%;\n }\n .mmp-dropdown__label {\n text-align: left;\n text-transform: none;\n }\n .mmp-dropdown__icon {\n height: 24px;\n width: 24px;\n min-width: 24px;\n }\n paper-item > *:nth-child(2) {\n margin-left: 4px;\n }\n paper-menu-button[focused] mmp-button iron-icon {\n color: var(--mmp-accent-color);\n transform: rotate(180deg);\n }\n paper-menu-button[focused] paper-icon-button {\n color: var(--mmp-accent-color);\n transform: rotate(180deg);\n }\n paper-menu-button[focused] paper-icon-button[focused] {\n color: var(--mmp-text-color);\n transform: rotate(0deg);\n }\n "]);return ea=function(){return a},a}function fa(){const a=ya(["
",""]);return fa=function(){return a},a}function ga(){const a=ya(["
"]);return ga=function(){return a},a}function ha(){const a=ya(["\n
\n ","\n ","\n "]);return ha=function(){return a},a}function ia(){const a=ya(["\n
\n \n \n ","\n \n \n
\n \n "]);return ia=function(){return a},a}function ja(){const a=ya(["\n
\n \n "]);return ja=function(){return a},a}function ka(){const a=ya(["\n
\n ","\n \n ","\n \n \n "]);return ka=function(){return a},a}function la(){const a=ya(["\n .ellipsis {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n .label {\n margin: 0 8px;\n }\n paper-icon-button {\n color: var(--mmp-text-color);\n transition: color .25s;\n }\n paper-icon-button[color] {\n color: var(--mmp-accent-color) !important;\n opacity: 1 !important;\n }\n paper-icon-button[inactive] {\n opacity: .5;\n }\n"]);return la=function(){return a},a}function ma(){const a=ya(["\n .mmp-group-list {\n display: flex;\n flex-direction: column;\n margin-left: 8px;\n margin-bottom: 8px;\n }\n .mmp-group-list__title {\n font-weight: 500;\n letter-spacing: .1em;\n margin: 8px 0 4px;\n text-transform: uppercase;\n }\n .mmp-group-list__buttons {\n display: flex;\n }\n .mmp-group-list__button {\n margin: 8px 8px 0 0;\n min-width: 0;\n text-transform: uppercase;\n text-align: center;\n width: 50%;\n --mdc-theme-primary: transparent;\n background: rgba(255,255,255,0.25);\n }\n "]);return ma=function(){return a},a}function na(){const a=ya([""]);return na=function(){return a},a}function oa(){const a=ya(["Leave"]);return oa=function(){return a},a}function pa(){const a=ya(["Ungroup"]);return pa=function(){return a},a}function qa(){const a=ya(["\n
"]);return qa=function(){return a},a}function ra(){const a=ya(["\n
\n
Group speakers\n ","\n
\n \n ","\n \n \n Group all\n \n
\n
\n "]);return ra=function(){return a},a}function sa(){const a=ya(["\n :host {\n position: relative;\n box-sizing: border-box;\n margin: 4px;\n min-width: 0;\n overflow: hidden;\n transition: background .5s;\n }\n :host([raised]) {\n background: rgba(255,255,255,0.25);\n min-height: 36px;\n box-shadow:\n 0px 3px 1px -2px rgba(0, 0, 0, 0.2),\n 0px 2px 2px 0px rgba(0, 0, 0, 0.14),\n 0px 1px 5px 0px rgba(0,0,0,.12);\n }\n :host([color]) {\n background: var(--mmp-active-color);\n transition: background .25s;\n opacity: 1;\n }\n :host([faded]) {\n opacity: .75;\n }\n .container {\n height: 100%;\n width: 100%;\n }\n .slot-container {\n height: 100%;\n display: flex;\n align-items: center;\n justify-content: center;\n margin: 0 8px;\n width: auto;\n }\n paper-ripple {\n position: absolute;\n left: 0;\n right: 0;\n top: 0;\n bottom: 0;\n }\n "]);return sa=function(){return a},a}function ta(){const a=ya(["\n
\n "]);return ta=function(){return a},a}function ua(){const a=ya(["\n paper-checkbox {\n padding: 8px 0;\n }\n paper-checkbox > span {\n font-weight: 600;\n }\n\n ha-card[artwork*='cover'][has-artwork] paper-checkbox[disabled] {\n --paper-checkbox-checkmark-color: rgba(0,0,0,.5);\n }\n ha-card[artwork*='cover'][has-artwork] paper-checkbox {\n --paper-checkbox-unchecked-color: #FFFFFF;\n --paper-checkbox-label-color: #FFFFFF;\n }\n "]);return ua=function(){return a},a}function va(){const a=ya(["
(master)"]);return va=function(){return a},a}function wa(){const a=ya(["\n
\n ","\n ","\n \n "]);return wa=function(){return a},a}function xa(){const a=ya(["\n :host {\n overflow: visible !important;\n display: block;\n --mmp-accent-color: var(--mini-media-player-accent-color, var(--accent-color, #f39c12));\n --mmp-base-color: var(--mini-media-player-base-color, var(--primary-text-color, #000));\n --mmp-overlay-color: var(--mini-media-player-overlay-color, rgba(0,0,0,0.5));\n --mmp-overlay-color-stop: var(--mini-media-player-overlay-color-stop, 25%);\n --mmp-overlay-base-color: var(--mini-media-player-overlay-base-color, #fff);\n --mmp-overlay-accent-color: var(--mini-media-player-overlay-accent-color, --mmp-accent-color);\n --mmp-text-color: var(--mini-media-player-base-color, var(--primary-text-color, #000));\n --mmp-media-cover-info-color: var(--mini-media-player-media-cover-info-color, --mmp-text-color);\n --mmp-text-color-inverted: var(--disabled-text-color);\n --mmp-active-color: var(--mmp-accent-color);\n --mmp-icon-color:\n var(--mini-media-player-icon-color,\n var(--mini-media-player-base-color,\n var(--paper-item-icon-colo, #44739e)));\n --mmp-info-opacity: 1;\n --mmp-artwork-opacity: var(--mini-media-player-artwork-opacity, 1);\n --mmp-progress-height: var(--mini-media-player-progress-height, 6px);\n --mdc-theme-primary: var(--mmp-text-color);\n --mdc-theme-on-primary: var(--mmp-text-color);\n --paper-checkbox-unchecked-color: var(--mmp-text-color);\n --paper-checkbox-label-color: var(--mmp-text-color);\n color: var(--mmp-text-color);\n }\n ha-card.--bg {\n --mmp-info-opacity: .75;\n }\n ha-card.--has-artwork[artwork*='cover'] {\n --mmp-accent-color: var(--mini-media-player-overlay-accent-color, var(--mini-media-player-accent-color, var(--accent-color, #f39c12)));\n --mmp-text-color: var(--mmp-overlay-base-color);\n --mmp-text-color-inverted: #000;\n --mmp-active-color: rgba(255,255,255,.5);\n --mmp-icon-color: var(--mmp-text-color);\n --mmp-info-opacity: .75;\n --paper-slider-container-color: var(--mini-media-player-overlay-color, rgba(255,255,255,.75));\n --mdc-theme-primary: var(--mmp-text-color);\n --mdc-theme-on-primary: var(--mmp-text-color);\n --paper-checkbox-unchecked-color: var(--mmp-text-color);\n --paper-checkbox-label-color: var(--mmp-text-color);\n color: var(--mmp-text-color);\n }\n ha-card {\n cursor: default;\n display: flex;\n background: transparent;\n overflow: hidden;\n padding: 0;\n position: relative;\n color: inherit;\n }\n ha-card.--group {\n box-shadow: none;\n --mmp-progress-height: var(--mini-media-player-progress-height, 4px);\n }\n ha-card.--more-info {\n cursor: pointer;\n }\n .mmp__bg, .mmp__player, .mmp__container {\n border-radius: var(--ha-card-border-radius, 0);\n -webkit-transform: translateZ(0);\n transform: translateZ(0);\n }\n .mmp__container {\n overflow: hidden;\n height: 100%;\n width: 100%;\n position: absolute;\n pointer-events: none;\n }\n ha-card:before {\n content: '';\n padding-top: 0px;\n transition: padding-top .5s cubic-bezier(.21,.61,.35,1);\n will-change: padding-top;\n }\n ha-card.--initial .entity__artwork,\n ha-card.--initial .entity__icon {\n animation-duration: .001s;\n }\n ha-card.--initial:before,\n ha-card.--initial .mmp-player {\n transition: none;\n }\n header {\n display: none;\n }\n ha-card[artwork='full-cover'].--has-artwork:before {\n padding-top: 56%;\n }\n ha-card[artwork='full-cover'].--has-artwork[content='music']:before,\n ha-card[artwork='full-cover-fit'].--has-artwork:before {\n padding-top: 100%;\n }\n .mmp__bg {\n background: var(--ha-card-background, var(--paper-card-background-color, white));\n position: absolute;\n top: 0; right: 0; bottom: 0; left: 0;\n overflow: hidden;\n -webkit-transform: translateZ(0);\n transform: translateZ(0);\n }\n ha-card[artwork*='cover'].--has-artwork .mmp__bg {\n opacity: var(--mmp-artwork-opacity);\n background: transparent;\n }\n ha-card.--group .mmp__bg {\n background: transparent;\n }\n .cover,\n .cover:before {\n display: block;\n opacity: 0;\n position: absolute;\n top: 0; right: 0; bottom: 0; left: 0;\n transition: opacity .75s cubic-bezier(.21,.61,.35,1);\n will-change: opacity;\n }\n .cover {\n animation: fade-in .5s cubic-bezier(.21,.61,.35,1);\n background-size: cover;\n background-repeat: no-repeat;\n background-position: center center;\n }\n .cover:before {\n background: var(--mmp-overlay-color);\n content: '';\n }\n ha-card[artwork*='full-cover'].--has-artwork .mmp-player {\n background: linear-gradient(to top, var(--mmp-overlay-color) var(--mmp-overlay-color-stop), transparent 100%);\n border-bottom-left-radius: var(--ha-card-border-radius, 0);\n border-bottom-right-radius: var(--ha-card-border-radius, 0);\n }\n ha-card.--has-artwork .cover,\n ha-card.--has-artwork[artwork='cover'] .cover:before,\n ha-card.--bg .cover {\n opacity: .999;\n }\n ha-card[artwork='default'] .cover {\n display: none;\n }\n ha-card.--bg .cover {\n display: block;\n }\n ha-card[artwork='full-cover-fit'].--has-artwork .cover {\n background-color: black;\n background-size: contain;\n }\n .mmp-player {\n align-self: flex-end;\n box-sizing: border-box;\n position: relative;\n padding: 16px;\n transition: padding .25s ease-out;\n width: 100%;\n will-change: padding;\n }\n ha-card.--group .mmp-player {\n padding: 10px 0;\n }\n .flex {\n display: flex;\n display: -ms-flexbox;\n display: -webkit-flex;\n flex-direction: row;\n }\n .mmp-player__core {\n position: relative;\n }\n .entity__info {\n justify-content: center;\n display: flex;\n flex-direction: column;\n margin-left: 8px;\n position: relative;\n overflow: hidden;\n user-select: none;\n }\n ha-card.--rtl .entity__info {\n margin-left: auto;\n margin-right: 8px;\n }\n ha-card[content='movie'] .attr__media_season,\n ha-card[content='movie'] .attr__media_episode {\n display: none;\n }\n .entity__icon {\n color: var(--mmp-icon-color);\n }\n .entity__artwork, .entity__icon {\n animation: fade-in .25s ease-out;\n background-position: center center;\n background-repeat: no-repeat;\n background-size: cover;\n border-radius: 100%;\n height: 40px;\n width: 40px;\n min-width: 40px;\n line-height: 40px;\n margin-right: 8px;\n position: relative;\n text-align: center;\n will-change: border-color;\n transition: border-color .25s ease-out;\n }\n ha-card.--rtl .entity__artwork,\n ha-card.--rtl .entity__icon {\n margin-right: auto;\n }\n .entity__artwork[border] {\n border: 2px solid var(--primary-text-color);\n box-sizing: border-box;\n -moz-box-sizing: border-box;\n -webkit-box-sizing: border-box;\n }\n .entity__artwork[border][state='playing'] {\n border-color: var(--mmp-accent-color);\n }\n .entity__info__name,\n .entity__info__media[short] {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n .entity__info__name {\n line-height: 20px;\n color: var(--mmp-text-color);\n }\n .entity__info__media {\n color: var(--secondary-text-color);\n max-height: 6em;\n word-break: break-word;\n opacity: var(--mmp-info-opacity);\n transition: color .5s;\n }\n .entity__info__media[short] {\n max-height: 20px;\n overflow: hidden;\n }\n .attr__app_name {\n display: none;\n }\n .attr__app_name:first-child,\n .attr__app_name:first-of-type {\n display: inline;\n }\n .mmp-player__core[inactive] .entity__info__media {\n color: var(--mmp-text-color);\n max-width: 200px;\n opacity: .5;\n }\n .entity__info__media[short-scroll] {\n max-height: 20px;\n white-space: nowrap;\n }\n .entity__info__media[scroll] > span {\n visibility: hidden;\n }\n .entity__info__media[scroll] > div {\n animation: move linear infinite;\n }\n .entity__info__media[scroll] .marquee {\n animation: slide linear infinite;\n }\n .entity__info__media[scroll] .marquee,\n .entity__info__media[scroll] > div {\n animation-duration: inherit;\n visibility: visible;\n }\n .entity__info__media[scroll] {\n animation-duration: 10s;\n mask-image: linear-gradient(to right, transparent 0%, black 5%, black 95%, transparent 100%);\n -webkit-mask-image: linear-gradient(to right, transparent 0%, black 5%, black 95%, transparent 100%);\n }\n .marquee {\n visibility: hidden;\n position: absolute;\n white-space: nowrap;\n }\n ha-card[artwork*='cover'].--has-artwork .entity__info__media,\n ha-card.--bg .entity__info__media {\n color: var(--mmp-media-cover-info-color);\n }\n .entity__info__media span:before {\n content: ' - ';\n }\n .entity__info__media span:first-of-type:before {\n content: '';\n }\n .entity__info__media span:empty {\n display: none;\n }\n .mmp-player__adds {\n margin-left: 48px;\n position: relative;\n }\n ha-card.--rtl .mmp-player__adds {\n margin-left: auto;\n margin-right: 48px;\n }\n .mmp-player__adds > *:nth-child(2) {\n margin-top: 0px;\n }\n mmp-powerstrip {\n flex: 1;\n justify-content: flex-end;\n margin-right: 0;\n margin-left: auto;\n width: auto;\n max-width: 100%;\n }\n mmp-media-controls {\n flex-wrap: wrap;\n justify-content: center;\n }\n ha-card.--flow mmp-powerstrip {\n justify-content: space-between;\n margin-left: auto;\n }\n ha-card.--flow.--rtl mmp-powerstrip {\n margin-right: auto;\n }\n ha-card.--flow .entity__info {\n display: none;\n }\n ha-card.--responsive .mmp-player__adds {\n margin-left: 0;\n }\n ha-card.--responsive.--rtl .mmp-player__adds {\n margin-right: 0;\n }\n ha-card.--responsive .mmp-player__adds > mmp-media-controls {\n padding: 0;\n }\n ha-card.--progress .mmp-player {\n padding-bottom: calc(16px + calc(var(--mini-media-player-progress-height, 6px) - 6px));\n }\n ha-card.--progress.--group .mmp-player {\n padding-bottom: calc(10px + calc(var(--mini-media-player-progress-height, 6px) - 6px));\n }\n ha-card.--runtime .mmp-player {\n padding-bottom: calc(16px + 16px + var(--mini-media-player-progress-height, 0px));\n }\n ha-card.--runtime.--group .mmp-player {\n padding-bottom: calc(16px + 12px + var(--mini-media-player-progress-height, 0px));\n }\n ha-card.--inactive .mmp-player {\n padding: 16px;\n }\n ha-card.--inactive.--group .mmp-player {\n padding: 10px 0;\n }\n .mmp-player div:empty {\n display: none;\n }\n @keyframes slide {\n 100% { transform: translateX(-100%); }\n }\n @keyframes move {\n from { transform: translateX(100%); }\n to { transform: translateX(0); }\n }\n @keyframes fade-in {\n from { opacity: 0; }\n to { opacity: 1; }\n }\n"]);return xa=function(){return a},a}function ya(a,b){return b||(b=a.slice(0)),Object.freeze(Object.defineProperties(a,{raw:{value:Object.freeze(b)}}))}function za(a,b){return Ca(a)||Ba(a,b)||Aa()}function Aa(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}function Ba(a,b){var c=[],d=!0,e=!1,f=void 0;try{for(var g,h=a[Symbol.iterator]();!(d=(g=h.next()).done)&&(c.push(g.value),!(b&&c.length===b));d=!0);}catch(a){e=!0,f=a}finally{try{d||null==h["return"]||h["return"]()}finally{if(e)throw f}}return c}function Ca(a){if(Array.isArray(a))return a}function Da(a){for(var b=1;b
a.parentNode.removeChild(a))}function Ba(a,b){let c=2"function"==typeof a&&Pa.has(a),Ra=window.customElements!==void 0&&window.customElements.polyfillWrapFlushCallback!==void 0,Sa=function(a,b){for(let c=2"),Xa=new RegExp("".concat(Va,"|").concat(Wa)),Ya="$lit$";class Za{constructor(a,b){this.parts=[],this.element=b;const c=[],d=[],e=document.createTreeWalker(b.content,133,null,!1);let f=0,g=-1,h=0;for(const i=a.strings,j=a.values.length;h{const c=a.length-b.length;return 0<=c&&a.slice(c)===b},_a=a=>-1!==a.index,ab=()=>document.createComment(""),bb=/([ \x09\x0a\x0c\x0d])([^\0-\x1F\x7F-\x9F "'>=/]+)([ \x09\x0a\x0c\x0d]*=[ \x09\x0a\x0c\x0d]*(?:[^ \x09\x0a\x0c\x0d"'`<>=]*|"[^"]*|'[^']*))$/;class cb{constructor(a,b,c){this.__parts=[],this.template=a,this.processor=b,this.options=c}update(a){let b=0;for(const c of this.__parts)void 0!==c&&c.setValue(a[b]),b++;for(const b of this.__parts)void 0!==b&&b.commit()}_clone(){const a=Ra?this.template.element.content.cloneNode(!0):document.importNode(this.template.element.content,!0),b=[],c=this.template.parts,d=document.createTreeWalker(a,133,null,!1);let e,f=0,g=0,h=d.nextNode();for(;f",e+1);const f=bb.exec(a);b+=null===f?a+(c?Va:Wa):a.substr(0,f.index)+f[1]+f[2]+Ya+f[3]+Va}return b+=this.strings[a],b}getTemplateElement(){const a=document.createElement("template");return a.innerHTML=this.getHTML(),a}}const eb=a=>null===a||"object"!=typeof a&&"function"!=typeof a,fb=a=>Array.isArray(a)||!!(a&&a[Symbol.iterator]);class gb{constructor(a,b,c){this.dirty=!0,this.element=a,this.name=b,this.strings=c,this.parts=[];for(let d=0;dthis.handleEvent(a)}setValue(a){this.__pendingValue=a}commit(){for(;Qa(this.__pendingValue);){const a=this.__pendingValue;this.__pendingValue=Ta,a(this)}if(this.__pendingValue===Ta)return;const a=this.__pendingValue,b=this.value,c=null==a||null!=b&&(a.capture!==b.capture||a.once!==b.once||a.passive!==b.passive);c&&this.element.removeEventListener(this.eventName,this.__boundHandleEvent,this.__options),null!=a&&(null==b||c)&&(this.__options=ob(a),this.element.addEventListener(this.eventName,this.__boundHandleEvent,this.__options)),this.value=a,this.__pendingValue=Ta}handleEvent(a){"function"==typeof this.value?this.value.call(this.eventContext||this.element,a):this.value.handleEvent(a)}}const ob=a=>a&&(mb?{capture:a.capture,passive:a.passive,once:a.once}:a.capture);const pb=new class{handleAttributeExpressions(a,b,c,d){const e=b[0];if("."===e){const d=new kb(a,b.slice(1),c);return d.parts}if("@"===e)return[new nb(a,b.slice(1),d.eventContext)];if("?"===e)return[new jb(a,b.slice(1),c)];const f=new gb(a,b,c);return f.parts}handleTextExpression(a){return new ib(a)}},qb=new Map,rb=new WeakMap,sb=(a,b,c)=>{let d=rb.get(b);d===void 0&&(Sa(b,b.firstChild),rb.set(b,d=new ib(Object.assign({templateFactory:ya},c))),d.appendInto(b)),d.setValue(a),d.commit()};(window.litHtmlVersions||(window.litHtmlVersions=[])).push("1.0.0");const tb=function(a){for(var b=arguments.length,c=Array(1{let b=11===a.nodeType?0:1;for(const c=document.createTreeWalker(a,ub,null,!1);c.nextNode();)b++;return b},wb=function(a){let b=1"".concat(a,"--").concat(b);let yb=!0;"undefined"==typeof window.ShadyCSS?yb=!1:"undefined"==typeof 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."),yb=!1);const zb=a=>b=>{const c=xb(b.type,a);let d=qb.get(c);void 0===d&&(d={stringsArray:new WeakMap,keyString:new Map},qb.set(c,d));let e=d.stringsArray.get(b.strings);if(void 0!==e)return e;const f=b.strings.join(Va);if(e=d.keyString.get(f),void 0===e){const c=b.getTemplateElement();yb&&window.ShadyCSS.prepareTemplateDom(c,a),e=new Za(b,c),d.keyString.set(f,e)}return d.stringsArray.set(b.strings,e),e},Ab=["html","svg"],Bb=a=>{Ab.forEach(b=>{const c=qb.get(xb(b,a));c!==void 0&&c.keyString.forEach(a=>{const b=a.element.content,c=new Set;Array.from(b.querySelectorAll("style")).forEach(a=>{c.add(a)}),Aa(a,c)})})},Cb=new Set,Db=(a,b,c)=>{Cb.add(c);const d=a.querySelectorAll("style"),e=d.length;if(0===e)return void window.ShadyCSS.prepareTemplateStyles(b.element,c);const f=document.createElement("style");for(let g=0;g{const d=c.scopeName,e=rb.has(b),f=yb&&11===b.nodeType&&!!b.host&&a instanceof db,g=f&&!Cb.has(d),h=g?document.createDocumentFragment():b;if(sb(a,h,Object.assign({templateFactory:zb(d)},c)),g){const a=rb.get(h);rb.delete(h),a.value instanceof cb&&Db(h,a.value.template,d),Sa(b,b.firstChild),b.appendChild(h),rb.set(b,a)}!e&&f&&window.ShadyCSS.styleElement(b.host)};window.JSCompiler_renameProperty=a=>a;const Fb={toAttribute(a,b){return b===Boolean?a?"":null:b===Object||b===Array?null==a?a:JSON.stringify(a):a},fromAttribute(a,b){return b===Boolean?null!==a:b===Number?null===a?null:+a:b===Object||b===Array?JSON.parse(a):a}},Gb=(a,b)=>b!==a&&(b===b||a===a),Hb={attribute:!0,type:String,converter:Fb,reflect:!1,hasChanged:Gb},Ib=Promise.resolve(!0),Jb=1,Kb=4,Lb=8,Mb=16,Nb=32;class Ob extends HTMLElement{constructor(){super(),this._updateState=0,this._instanceProperties=void 0,this._updatePromise=Ib,this._hasConnectedResolver=void 0,this._changedProperties=new Map,this._reflectingProperties=void 0,this.initialize()}static get observedAttributes(){this.finalize();const a=[];return this._classProperties.forEach((b,c)=>{const d=this._attributeNameForProperty(c,b);void 0!==d&&(this._attributeToPropertyMap.set(d,c),a.push(d))}),a}static _ensureClassProperties(){if(!this.hasOwnProperty(JSCompiler_renameProperty("_classProperties",this))){this._classProperties=new Map;const a=Object.getPrototypeOf(this)._classProperties;a!==void 0&&a.forEach((a,b)=>this._classProperties.set(b,a))}}static createProperty(a){let b=1{if(this.hasOwnProperty(b)){const a=this[b];delete this[b],this._instanceProperties||(this._instanceProperties=new Map),this._instanceProperties.set(b,a)}})}_applyInstanceProperties(){this._instanceProperties.forEach((a,b)=>this[b]=a),this._instanceProperties=void 0}connectedCallback(){this._updateState|=Nb,this._hasConnectedResolver&&(this._hasConnectedResolver(),this._hasConnectedResolver=void 0)}disconnectedCallback(){}attributeChangedCallback(a,b,c){b!==c&&this._attributeToProperty(a,c)}_propertyToAttribute(a,b){let c=2{b=a,c=d});try{yield d}catch(a){}a._hasConnected||(yield new Promise(b=>a._hasConnectedResolver=b));try{const b=a.performUpdate();null!=b&&(yield b)}catch(a){c(a)}b(!a._hasRequestedUpdate)})()}get _hasConnected(){return this._updateState&Nb}get _hasRequestedUpdate(){return this._updateState&Kb}get hasUpdated(){return this._updateState&Jb}performUpdate(){this._instanceProperties&&this._applyInstanceProperties();let a=!1;const b=this._changedProperties;try{a=this.shouldUpdate(b),a&&this.update(b)}catch(b){throw a=!1,b}finally{this._markUpdated()}a&&(!(this._updateState&Jb)&&(this._updateState|=Jb,this.firstUpdated(b)),this.updated(b))}_markUpdated(){this._changedProperties=new Map,this._updateState&=~Kb}get updateComplete(){return this._updatePromise}shouldUpdate(a){return!0}update(a){this._reflectingProperties!==void 0&&0this._propertyToAttribute(b,this[b],a)),this._reflectingProperties=void 0)}updated(a){}firstUpdated(a){}}Ob.finalized=!0;const Pb="adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Qb=Symbol();class Rb{constructor(a,b){if(b!==Qb)throw new Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=a}get styleSheet(){return void 0===this._styleSheet&&(Pb?(this._styleSheet=new CSSStyleSheet,this._styleSheet.replaceSync(this.cssText)):this._styleSheet=null),this._styleSheet}toString(){return this.cssText}}const Sb=a=>{if(a instanceof Rb)return a.cssText;if("number"==typeof a)return a;throw new Error("Value passed to 'css' function must be a 'css' function result: ".concat(a,". Use 'unsafeCSS' to pass non-literal values, but\n take care to ensure page security."))},Tb=function(a){for(var b=arguments.length,c=Array(1b+Sb(c)+a[d+1],a[0]);return new Rb(e,Qb)};(window.litElementVersions||(window.litElementVersions=[])).push("2.2.0");const Ub=a=>a.flat?a.flat(1/0):Ca(a);class Vb extends Ob{static finalize(){super.finalize(),this._styles=this.hasOwnProperty(JSCompiler_renameProperty("styles",this))?this._getUniqueStyles():this._styles||[]}static _getUniqueStyles(){const a=this.styles,b=[];if(Array.isArray(a)){const c=Ub(a),d=c.reduceRight((a,b)=>(a.add(b),a),new Set);d.forEach(a=>b.unshift(a))}else a&&b.push(a);return b}initialize(){super.initialize(),this.renderRoot=this.createRenderRoot(),window.ShadowRoot&&this.renderRoot instanceof window.ShadowRoot&&this.adoptStyles()}createRenderRoot(){return this.attachShadow({mode:"open"})}adoptStyles(){const a=this.constructor._styles;0===a.length||(window.ShadyCSS===void 0||window.ShadyCSS.nativeShadow?Pb?this.renderRoot.adoptedStyleSheets=a.map(a=>a.styleSheet):this._needsShimAdoptedStyleSheets=!0:window.ShadyCSS.ScopingShim.prepareAdoptedCssText(a.map(a=>a.cssText),this.localName))}connectedCallback(){super.connectedCallback(),this.hasUpdated&&window.ShadyCSS!==void 0&&window.ShadyCSS.styleElement(this)}update(a){super.update(a);const b=this.render();b instanceof db&&this.constructor.render(b,this.renderRoot,{scopeName:this.localName,eventContext:this}),this._needsShimAdoptedStyleSheets&&(this._needsShimAdoptedStyleSheets=!1,this.constructor._styles.forEach(a=>{const b=document.createElement("style");b.textContent=a.cssText,this.renderRoot.appendChild(b)}))}render(){}}Vb.finalized=!0,Vb.render=Eb;const Wb=new WeakMap,Xb=(a=>function(){const b=a(...arguments);return Pa.set(b,!0),b})(a=>b=>{if(!(b instanceof hb)||b instanceof lb||"class"!==b.committer.name||1Da({text:this.attr[a.attr],prefix:""},a)).filter(a=>a.text)}get hasProgress(){return!this.config.hide.progress&&!this.idle&&qc.every(a=>a in this.attr)}get progress(){return this.position+(Date.now()-new Date(this.updatedAt).getTime())/1e3}get idleView(){const a=this.config.idle_view;return!!(a.when_idle&&this.isIdle||a.when_standby&&this.isStandby||a.when_paused&&this.isPaused)||!!(this.updatedAt&&a.after&&!this.isPlaying)&&this.checkIdleAfter(a.after)}get trackIdle(){return this.active&&!this.isPlaying&&this.updatedAt&&this.config.idle_view&&this.config.idle_view.after}checkIdleAfter(a){const b=(Date.now()-new Date(this.updatedAt).getTime())/1e3;return this.idle=b>60*a,this.active=this.isActive,this.idle}get supportsShuffle(){return"undefined"!=typeof this.attr.shuffle}get supportsMute(){return"undefined"!=typeof this.attr.is_volume_muted}getAttribute(a){return this.attr[a]||""}fetchThumbnail(){var a=this;return Ga(function*(){try{const b=yield a.hass.callWS({type:"media_player_thumbnail",entity_id:a.config.entity}),c=b.content_type,d=b.content;return"url(data:".concat(c,";base64,").concat(d,")")}catch(a){return console.error("mini-media-player: Failed fetching thumbnail"),!1}})()}toggle(a){return this.config.toggle_power?this.callService(a,"toggle"):this.isOff?this.callService(a,"turn_on"):void this.callService(a,"turn_off")}toggleMute(a){this.callService(a,"volume_mute",{is_volume_muted:!this.muted})}toggleShuffle(a){this.callService(a,"shuffle_set",{shuffle:!this.shuffle})}setSource(a,b){this.callService(a,"select_source",{source:b})}setMedia(a,b){this.callService(a,"play_media",Da({},b))}playPause(a){this.callService(a,"media_play_pause")}playStop(a){this.isPlaying?this.callService(a,"media_stop"):this.callService(a,"media_play")}setSoundMode(a,b){this.callService(a,"select_sound_mode",{sound_mode:b})}next(a){this.callService(a,"media_next_track")}prev(a){this.callService(a,"media_previous_track")}stop(a){this.callService(a,"media_stop")}volumeUp(a){this.callService(a,"volume_up")}volumeDown(a){this.callService(a,"volume_down")}seek(a,b){this.callService(a,"media_seek",{seek_position:b})}setVolume(a,b){this.config.speaker_group.sync_volume?this.group.forEach(c=>{const d=this.config.speaker_group.entities.find(a=>a.entity_id===c)||{};let e=b;d.volume_offset&&(e+=d.volume_offset/100,1e&&(e=0)),this.callService(a,"volume_set",{entity_id:c,volume_level:e})}):this.callService(a,"volume_set",{entity_id:this.config.entity,volume_level:b})}handleGroupChange(a,b,c){const d=this.config.speaker_group.platform,e={entity_id:b};if(c){if(e.master=this.config.entity,"bluesound"===d)return this.callService(a,"".concat(d,"_JOIN"),e);this.callService(a,"join",e,d)}else{if("bluesound"===d)return this.callService(a,"".concat(d,"_UNJOIN"),e);this.callService(a,"unjoin",e,d)}}toggleScript(a,b){let c=2a.stopPropagation(),this.handleClick,this.item.name,this.master?tb(va()):"")}handleClick(a){a.stopPropagation(),this.dispatchEvent(new CustomEvent("change",{detail:{entity:this.item.entity_id,checked:!this.checked}}))}static get styles(){return Tb(ua())}}customElements.define("mmp-group-item",uc);class vc extends Vb{render(){return tb(ta())}static get styles(){return Tb(sa())}}customElements.define("mmp-button",vc);class wc extends Vb{static get properties(){return{entities:{},player:{},visible:Boolean}}get group(){return this.player.group}get master(){return this.player.master}get isMaster(){return this.player.isMaster}handleGroupChange(a){const b=a.detail,c=b.entity,d=b.checked;this.player.handleGroupChange(a,c,d)}render(){let a=0tb(qa(),this.handleGroupChange,a,a.entity_id===this.player.id||b.includes(a.entity_id),a.entity_id===this.player.id||c!==this.player.id,a.entity_id===c)),2>b.length,a=>this.player.handleGroupChange(a,d?b:this.player.entity_id,!1),d?tb(pa()):tb(oa()),!d,a=>this.player.handleGroupChange(a,this.entities.map(a=>a.entity_id),!0)):tb(na())}static get styles(){return Tb(ma())}}customElements.define("mmp-group-list",wc);const xc=Tb(la());class yc extends Vb{static get properties(){return{items:[],label:String,selected:String}}get selectedId(){return this.items.map(a=>a.id).indexOf(this.selected)}onChange(a){this.dispatchEvent(new CustomEvent("change",{detail:a}))}render(){return tb(ka(),"right","top",44,a=>a.stopPropagation(),this.icon?tb(ja(),oc.DROPDOWN):tb(ia(),this.selected||this.label,oc.DROPDOWN),this.selectedId,this.items.map(a=>tb(ha(),a.id||a.name,()=>this.onChange(a),a.icon?tb(ga(),a.icon):"",a.name?tb(fa(),a.name):"")))}static get styles(){return[xc,Tb(ea())]}}customElements.define("mmp-dropdown",yc);class zc extends Vb{static get properties(){return{player:{},shortcuts:{}}}get buttons(){return this.shortcuts.buttons}get list(){return this.shortcuts.list}get show(){return!this.shortcuts.hide_when_off||this.player.active}get active(){return this.player.getAttribute(this.shortcuts.attribute)}get height(){return this.shortcuts.column_height||36}render(){if(!this.show)return tb(da());const a=this.active,b=this.list?tb(ca(),this.handleShortcut,this.list,this.shortcuts.label,a):"",c=this.buttons?tb(ba(),this.buttons.map(b=>tb(aa(),"min-height: ".concat(this.height,"px;"),this.shortcuts.columns,b.id===a,a=>this.handleShortcut(a,b),this.shortcuts.align_text,b.icon?tb(_(),b.icon):"",b.name?tb($(),b.name):""))):"";return tb(Z(),c,b)}handleShortcut(a,b){const c=b||a.detail,d=c.type,e=c.id,f=c.data;if("source"===d)return this.player.setSource(a,e);if("service"===d)return this.player.toggleService(a,e,f);if("script"===d)return this.player.toggleScript(a,e,f);if("sound_mode"===d)return this.player.setSoundMode(a,e);this.player.setMedia(a,{media_content_type:d,media_content_id:e})}static get styles(){return[xc,Tb(Y())]}}customElements.define("mmp-shortcuts",zc);const Ac=function(a,b){let c=2a.stopPropagation(),this.handleTts)}handleTts(a){const b=this.config,c=this.message,d={message:c,entity_id:b.entity_id||this.entity};b.language&&(d.language=b.language),"alexa"===b.platform?this.hass.callService("notify","alexa_media",{message:c,data:{type:b.type||"tts"},target:d.entity_id}):"sonos"===b.platform?this.hass.callService("script","sonos_say",{sonos_entity:d.entity_id,volume:b.volume||.5,message:c}):"webos"===b.platform?this.hass.callService("notify",d.entity_id.split(".").slice(-1)[0],{message:c}):"ga"===b.platform?this.hass.callService("notify","ga_broadcast",{message:c}):this.hass.callService("tts","".concat(b.platform,"_say"),d),a.stopPropagation(),this.reset()}reset(){this.input.value=""}static get styles(){return Tb(W())}}customElements.define("mmp-tts",Bc);var Cc=a=>{let b=parseInt(a%60,10),c=parseInt(a/60%60,10),d=parseInt(a/3600%24,10);return d=10>d?"0".concat(d):d,c=10>c?"0".concat(c):c,b=10>b?"0".concat(b):b,"".concat("00"===d?"":"".concat(d,":")).concat(c,":").concat(b)};class Dc extends Vb{static get properties(){return{_player:{},showTime:Boolean,progress:Number,duration:Number,tracker:{},seekProgress:Number,seekWidth:Number,track:Boolean}}set player(a){this._player=a,this.hasProgress&&this.trackProgress()}get duration(){return this.player.mediaDuration}get player(){return this._player}get hasProgress(){return this.player.hasProgress}get width(){return this.shadowRoot.querySelector(".mmp-progress").offsetWidth}get offset(){return this.getBoundingClientRect().left}get classes(){return Xb({transiting:!this.seekProgress,seeking:this.seekProgress})}render(){return tb(V(),this.initSeek,this.handleSeek,this.initSeek,this.handleSeek,this.resetSeek,a=>a.stopPropagation(),!this.player.isPlaying,this.showTime?tb(U(),Cc(this.seekProgress||this.progress),Cc(this.duration)):"",this.classes,this.seekProgress||this.progress,this.duration)}trackProgress(){this.progress=this.player.progress,this.tracker||(this.tracker=setInterval(()=>this.trackProgress(),1e3)),this.player.isPlaying||(clearInterval(this.tracker),this.tracker=null)}initSeek(a){const b=a.offsetX||a.touches[0].pageX-this.offset;this.seekWidth=this.width,this.seekProgress=this.calcProgress(b),this.addEventListener("touchmove",this.moveSeek),this.addEventListener("mousemove",this.moveSeek)}resetSeek(){this.seekProgress=null,this.removeEventListener("touchmove",this.moveSeek),this.removeEventListener("mousemove",this.moveSeek)}moveSeek(a){a.preventDefault();const b=a.offsetX||a.touches[0].pageX-this.offset;this.seekProgress=this.calcProgress(b)}handleSeek(a){this.resetSeek();const b=a.offsetX||a.changedTouches[0].pageX-this.offset,c=this.calcProgress(b);this.player.seek(a,c)}disconnectedCallback(){this.resetSeek(),clearInterval(this.tracker)}calcProgress(a){const b=a/this.seekWidth*this.duration;return Math.min(Math.max(b,.1),this.duration)}static get styles(){return Tb(T())}}customElements.define("mmp-progress",Dc);class Ec extends Vb{static get properties(){return{player:{},selected:String,icon:Boolean}}get source(){return this.player.source}get sources(){return this.player.sources.map(a=>({name:a,id:a,type:"source"}))}render(){return tb(S(),this.handleSource,this.sources,this.source,this.selected||this.source,this.icon)}handleSource(a){const b=a.detail.id;this.player.setSource(a,b),this.selected=b}static get styles(){return Tb(R())}}customElements.define("mmp-source-menu",Ec);class Fc extends Vb{static get properties(){return{player:{},selected:String,icon:Boolean}}get mode(){return this.player.soundMode}get modes(){return this.player.soundModes.map(a=>({name:a,id:a,type:"soundMode"}))}render(){return tb(Q(),this.handleChange,this.modes,this.mode,this.selected||this.mode,this.icon)}handleChange(a){const b=a.detail.id;this.player.setSoundMode(a,b),this.selected=b}static get styles(){return Tb(P())}}customElements.define("mmp-sound-menu",Fc);class Gc extends Vb{static get properties(){return{player:{},config:{},break:Boolean}}get showShuffle(){return!this.config.hide.shuffle&&this.player.supportsShuffle}get maxVol(){return this.config.max_volume||100}get minVol(){return this.config.min_volume||0}render(){const a=this.config.hide;return tb(O(),a.volume?tb(N()):this.renderVolControls(this.player.muted),this.showShuffle?tb(M(),a=>this.player.toggleShuffle(a),oc.SHUFFLE,this.player.shuffle):tb(L()),a.controls?tb(J()):tb(K(),this.config.flow||this.break,a=>this.player.prev(a),oc.PREV,this.renderPlayButtons(),a=>this.player.next(a),oc.NEXT))}renderVolControls(a){return this.config.volume_stateless?this.renderVolButtons(a):this.renderVolSlider(a)}renderVolSlider(a){return tb(I(),this.renderMuteButton(a),this.handleVolumeChange,a=>a.stopPropagation(),a,this.minVol,this.maxVol,100*this.player.vol,"ltr")}renderVolButtons(a){return tb(H(),this.renderMuteButton(a),a=>this.player.volumeDown(a),oc.VOL_DOWN,a=>this.player.volumeUp(a),oc.VOL_UP)}renderMuteButton(a){if(!this.config.hide.mute)switch(this.config.replace_mute){case"play":case"play_pause":return tb(G(),a=>this.player.playPause(a),oc.PLAY[this.player.isPlaying]);case"stop":return tb(F(),a=>this.player.stop(a),oc.STOP.true);case"play_stop":return tb(E(),a=>this.player.playStop(a),oc.STOP[this.player.isPlaying]);case"next":return tb(D(),a=>this.player.next(a),oc.NEXT);default:return this.player.supportsMute?tb(C(),a=>this.player.toggleMute(a),oc.MUTE[a]):void 0;}}renderPlayButtons(){const a=this.config.hide;return tb(B(),a.play_pause?tb(z()):tb(A(),a=>this.player.playPause(a),oc.PLAY[this.player.isPlaying]),a.play_stop?tb(x()):tb(y(),a=>this.handleStop(a),a.play_pause?oc.STOP[this.player.isPlaying]:oc.STOP.true))}handleStop(a){return this.config.hide.play_pause?this.player.playStop(a):this.player.stop(a)}handleVolumeChange(a){const b=parseFloat(a.target.value)/100;this.player.setVolume(a,b)}static get styles(){return[xc,Tb(w())]}}customElements.define("mmp-media-controls",Gc);class Hc extends Vb{static get properties(){return{hass:{},player:{},config:{},groupVisible:Boolean,idle:Boolean}}get icon(){return this.config.speaker_group.icon||oc.GROUP}get showGroupButton(){return this.config.speaker_group.entities}get showPowerButton(){return!this.config.hide.power}get powerColor(){return this.player.active&&!this.config.hide.power_state}get sourceSize(){return"icon"===this.config.source||this.hasControls||this.idle}get soundSize(){return"icon"===this.config.sound_mode||this.hasControls||this.idle}get hasControls(){return this.player.active&&this.config.hide.controls!==this.config.hide.volume}get hasSource(){return 0this.player.toggle(a),this.powerColor):"")}handleGroupClick(a){a.stopPropagation(),this.dispatchEvent(new CustomEvent("toggleGroupList"))}get renderIdleView(){return this.player.isPaused?tb(o(),oc.PLAY[this.player.isPlaying],a=>this.player.playPause(a)):tb(n(),Ac(this.hass,"state.media_player.idle","Idle"))}static get styles(){return[xc,Tb(m())]}}customElements.define("mmp-powerstrip",Hc),customElements.get("ha-slider")||customElements.define("ha-slider",class extends customElements.get("paper-slider"){});class Ic extends Vb{constructor(){super(),this._overflow=!1,this.initial=!0,this.picture=!1,this.thumbnail=!1,this.edit=!1,this.rtl=!1}static get properties(){return{_hass:{},config:{},entity:{},player:{},_overflow:Boolean,break:Boolean,initial:Boolean,picture:String,thumbnail:String,edit:Boolean,rtl:Boolean,idle:Boolean}}static get styles(){return tc}set hass(a){if(a){const b=a.states[this.config.entity];this._hass=a,b&&this.entity!==b&&(this.entity=b,this.player=new sc(a,this.config,b),this.rtl=this.computeRTL(a),this.idle=this.player.idle,this.player.trackIdle&&this.updateIdleStatus())}}get hass(){return this._hass}set overflow(a){this._overflow!==a&&(this._overflow=a)}get overflow(){return this._overflow}get name(){return this.config.name||this.player.name}setConfig(a){if(!a.entity||"media_player"!==a.entity.split(".")[0])throw new Error("Specify an entity from within the media_player domain.");const b=Da({artwork:"default",info:"default",more_info:!0,source:"default",sound_mode:"default",toggle_power:!0},a,{hide:Da({},nc,a.hide),speaker_group:Da({show_group_count:!0,platform:"sonos"},a.sonos,a.speaker_group),shortcuts:Da({label:"Shortcuts..."},a.shortcuts)});b.max_volume=+b.max_volume||100,b.min_volume=+b.min_volume||0,b.collapse=b.hide.controls||b.hide.volume,b.info=b.collapse&&"scroll"!==b.info?"short":b.info,b.flow=b.hide.icon&&b.hide.name&&b.hide.info,this.config=b}shouldUpdate(a){return void 0===this.break&&this.computeRect(this),pc.some(b=>a.has(b))&&this.player}firstUpdated(){const a=new mc(a=>{a.forEach(a=>{window.requestAnimationFrame(()=>{"scroll"===this.config.info&&this.computeOverflow(),this._resizeTimer||(this.computeRect(a),this._resizeTimer=setTimeout(()=>{this._resizeTimer=null,this.computeRect(this._resizeEntry)},250)),this._resizeEntry=a})})});a.observe(this),setTimeout(()=>this.initial=!1,250),this.edit=this.config.speaker_group.expanded||!1}updated(){"scroll"===this.config.info&&setTimeout(()=>{this.computeOverflow()},10)}render(){let a=0tb(b(),"attr__".concat(a.attr),a.prefix+a.text))):"",e.map(b=>tb(a(),"attr__".concat(b.attr),b.prefix+b.text)))}}speakerCount(){if(this.config.speaker_group.show_group_count){const a=this.player.groupCount;return 1{this.thumbnail=a}),this.picture=b),!!(c&&this.thumbnail)}computeIcon(){return this.config.icon?this.config.icon:this.player.icon||oc.DEFAULT}computeOverflow(){const a=this.shadowRoot.querySelector(".marquee");if(a){const b=a.clientWidth>a.parentNode.clientWidth;this.overflow=!!(b&&this.player.active)&&7.5+a.clientWidth/50}}computeRect(a){const b=a.contentRect||a.getBoundingClientRect(),c=b.left,d=b.width;this.break=d+2*c<390}computeRTL(a){const b=a.language||"en";return!!a.translationMetadata.translations[b]&&(a.translationMetadata.translations[b].isRTL||!1)}toggleGroupList(){this.edit=!this.edit}handleMoreInfo(a){a.stopPropagation(),this.config.more_info&&this.fire("hass-more-info",{entityId:this.config.entity})}fire(a,b,c){const d=c||{},f=null===b||void 0===b?{}:b,g=new Event(a,{bubbles:void 0===d.bubbles||d.bubbles,cancelable:!!d.cancelable,composed:void 0===d.composed||d.composed});return g.detail=f,this.dispatchEvent(g),g}updateIdleStatus(){this._idleTracker&&clearTimeout(this._idleTracker);const a=(Date.now()-new Date(this.player.updatedAt).getTime())/1e3;this._idleTracker=setTimeout(()=>{this.idle=this.player.checkIdleAfter(this.config.idle_view.after),this.player.idle=this.idle,this._idleTracker=null},1e3*(60*this.config.idle_view.after-a))}getCardSize(){return this.config.collapse?1:2}}customElements.define("mini-media-player",Ic)})})();
diff --git a/www/community/mini-media-player/mini-media-player-bundle.js.gz b/www/community/mini-media-player/mini-media-player-bundle.js.gz
new file mode 100644
index 0000000..2a3d5f3
Binary files /dev/null and b/www/community/mini-media-player/mini-media-player-bundle.js.gz differ
diff --git a/www/community/mini-media-player/mini-media-player.js b/www/community/mini-media-player/mini-media-player.js
index 80c424e..5f82e1c 100644
--- a/www/community/mini-media-player/mini-media-player.js
+++ b/www/community/mini-media-player/mini-media-player.js
@@ -1 +1 @@
-(function(){"use strict";function a(){const b=sa(["",""]);return a=function(){return b},b}function b(){const a=sa(["",""]);return b=function(){return a},a}function c(){const a=sa(["\n "]);return c=function(){return a},a}function d(){const a=sa(["\n \n ","\n ","\n
"]);return d=function(){return a},a}function e(){const a=sa(["\n \n "," ","\n
"]);return e=function(){return a},a}function f(){const a=sa(["\n \n \n
"]);return f=function(){return a},a}function g(){const a=sa(["\n \n
"]);return g=function(){return a},a}function h(){const a=sa([""]);return h=function(){return a},a}function i(){const a=sa(["\n \n \n "]);return i=function(){return a},a}function j(){const a=sa(["\n \n \n "]);return j=function(){return a},a}function k(){const a=sa(["\n \n \n ","\n
\n \n
\n ","\n
\n ","\n ","\n
\n
\n \n
\n
\n ","\n \n \n ","\n \n \n
\n
\n \n \n \n
\n \n "]);return k=function(){return a},a}function l(){const a=sa(["\n :host {\n display: flex;\n line-height: 40px;\n max-height: 40px;\n }\n :host([flow]) mmp-media-controls {\n max-width: unset;\n }\n mmp-media-controls {\n max-width: 200px;\n }\n .group-button {\n height: 34px;\n width: 34px;\n min-width: 34px;\n margin: 3px;\n }\n paper-icon-button {\n min-width: 40px;\n }\n "]);return l=function(){return a},a}function m(){const a=sa(["\n \n ","\n \n "]);return m=function(){return a},a}function n(){const a=sa(["\n \n "]);return n=function(){return a},a}function o(){const a=sa(["\n \n "]);return o=function(){return a},a}function p(){const a=sa(["\n \n "]);return p=function(){return a},a}function q(){const a=sa(["\n \n "]);return q=function(){return a},a}function r(){const a=sa(["\n \n "]);return r=function(){return a},a}function s(){const a=sa(["\n \n \n "]);return s=function(){return a},a}function t(){const a=sa(["\n ","\n ","\n ","\n ","\n ","\n ","\n "]);return t=function(){return a},a}function u(){const a=sa(["\n \n ","\n \n "]);return u=function(){return a},a}function v(){const a=sa(["\n :host {\n display: flex;\n width: 100%;\n }\n .flex {\n display: flex;\n flex: 1;\n justify-content: space-between;\n }\n ha-slider {\n max-width: none;\n min-width: 100px;\n width: 100%;\n }\n paper-icon-button {\n min-width: 40px;\n }\n .mmp-media-controls__volume {\n flex: 100;\n max-height: 40px;\n }\n .mmp-media-controls__volume.--buttons {\n justify-content: left;\n }\n .mmp-media-controls__media {\n direction: ltr;\n max-width: calc(40px * 3);\n margin-right: 0;\n margin-left: auto;\n }\n .mmp-media-controls__media[flow] {\n max-width: none;\n }\n .mmp-media-controls__shuffle {\n flex: 3;\n flex-shrink: 200;\n justify-content: center;\n }\n .mmp-media-controls__shuffle paper-icon-button {\n height: 36px;\n width: 36px;\n min-width: 36px;\n margin: 2px;\n }\n "]);return v=function(){return a},a}function w(){const a=sa(["\n \n \n "]);return w=function(){return a},a}function x(){const a=sa(["\n \n \n "]);return x=function(){return a},a}function y(){const a=sa(["\n \n \n "]);return y=function(){return a},a}function z(){const a=sa(["\n \n \n "]);return z=function(){return a},a}function A(){const a=sa(["\n "]);return A=function(){return a},a}function B(){const a=sa(["\n \n ","\n \n \n
"]);return B=function(){return a},a}function C(){const a=sa([""]);return C=function(){return a},a}function D(){const a=sa(["\n \n "]);return D=function(){return a},a}function E(){const a=sa([""]);return E=function(){return a},a}function F(){const a=sa(["\n \n "]);return F=function(){return a},a}function G(){const a=sa([""]);return G=function(){return a},a}function H(){const a=sa(["\n ","\n ","\n ","\n "]);return H=function(){return a},a}function I(){const a=sa(["\n :host {\n max-width: 120px;\n min-width: 40px;\n }\n :host([full]) {\n max-width: none;\n }\n "]);return I=function(){return a},a}function J(){const a=sa(["\n \n "]);return J=function(){return a},a}function K(){const a=sa(["\n :host {\n max-width: 120px;\n min-width: 40px;\n }\n :host([full]) {\n max-width: none;\n }\n "]);return K=function(){return a},a}function L(){const a=sa(["\n \n "]);return L=function(){return a},a}function M(){const a=sa(["\n .mmp-progress {\n cursor: pointer;\n left: 0; right: 0; bottom: 0;\n position: absolute;\n pointer-events: auto;\n min-height: 10px;\n }\n .mmp-progress__duration {\n display: flex;\n justify-content: space-between;\n font-size: .8em;\n margin: 8px calc(var(--ha-card-border-radius, 4px) / 2);\n margin-top: 0;\n padding: 0 6px;\n }\n paper-progress {\n height: var(--paper-progress-height, 4px);\n bottom: 0;\n position: absolute;\n width: 100%;\n --paper-progress-active-color: var(--mmp-accent-color);\n --paper-progress-container-color: rgba(100,100,100,.15);\n --paper-progress-transition-duration: 1s;\n --paper-progress-transition-timing-function: linear;\n --paper-progress-transition-delay: 0s;\n }\n .mmp-progress[paused] paper-progress {\n --paper-progress-active-color: var(--disabled-text-color, rgba(150,150,150,.5));\n }\n "]);return M=function(){return a},a}function N(){const a=sa([""]);return N=function(){return a},a}function O(){const a=sa(["\n \n ","\n ","\n
\n "]);return O=function(){return a},a}function P(){const a=sa(["\n \n "]);return P=function(){return a},a}function Q(){const a=sa(["\n :host {\n align-items: center;\n margin-left: 8px;\n display: flex;\n }\n .mmp-tts__input {\n cursor: text;\n flex: 1;\n margin-right: 8px;\n --paper-input-container-input: {\n font-size: 1em;\n };\n }\n ha-card[rtl] .mmp-tts__input {\n margin-right: auto;\n margin-left: 8px;\n }\n .mmp-tts__button {\n margin: 0;\n height: 30px;\n padding: 0 .4em;\n }\n paper-input {\n opacity: .75;\n --paper-input-container-color: var(--mmp-text-color);\n --paper-input-container-focus-color: var(--mmp-text-color);\n --paper-input-container: {\n padding: 0;\n };\n }\n paper-input[focused] {\n opacity: 1;\n }\n\n ha-card[artwork*='cover'][has-artwork] paper-input {\n --paper-input-container-focus-color: #FFFFFF;\n }\n ha-card[artwork*='cover'][has-artwork] paper-input {\n --paper-input-container-color: #FFFFFF;\n --paper-input-container-input-color: #FFFFFF;\n }\n "]);return Q=function(){return a},a}function R(){const a=sa(["\n \n \n \n SEND\n \n "]);return R=function(){return a},a}function S(){const a=sa(["\n .mmp-shortcuts__buttons {\n box-sizing: border-box;\n display: flex;\n flex-wrap: wrap;\n margin-top: 8px;\n }\n .mmp-shortcuts__button {\n min-width: calc(50% - 8px);\n flex: 1;\n }\n .mmp-shortcuts__button > div {\n display: flex;\n justify-content: center;\n align-items: center;\n width: 100%;\n }\n .mmp-shortcuts__button > div[align='left'] {\n justify-content: flex-start;\n }\n .mmp-shortcuts__button > div[align='right'] {\n justify-content: flex-end;\n }\n .mmp-shortcuts__button[columns='1'] {\n min-width: calc(100% - 8px);\n }\n .mmp-shortcuts__button[columns='3'] {\n min-width: calc(33.33% - 8px);\n }\n .mmp-shortcuts__button[columns='4'] {\n min-width: calc(25% - 8px);\n }\n .mmp-shortcuts__button[columns='5'] {\n min-width: calc(20% - 8px);\n }\n .mmp-shortcuts__button > div > span {\n line-height: 24px;\n text-transform: initial;\n }\n .mmp-shortcuts__button > div > *:nth-child(2) {\n margin-left: 4px;\n }\n "]);return S=function(){return a},a}function T(){const a=sa(["\n ","\n ","\n "]);return T=function(){return a},a}function U(){const a=sa(["",""]);return U=function(){return a},a}function V(){const a=sa([""]);return V=function(){return a},a}function W(){const a=sa(["\n \n \n ","\n ","\n
\n "]);return W=function(){return a},a}function X(){const a=sa(["\n \n ","\n
\n "]);return X=function(){return a},a}function Y(){const a=sa(["\n \n \n "]);return Y=function(){return a},a}function Z(){const a=sa([""]);return Z=function(){return a},a}function $(){const a=sa(["\n :host {\n display: block;\n }\n :host([faded]) {\n opacity: .75;\n }\n :host[small] .mmp-dropdown__label {\n max-width: 60px;\n display: block;\n position: relative;\n width: auto;\n text-transform: initial;\n }\n :host[full] .mmp-dropdown__label {\n max-width: none;\n }\n .mmp-dropdown {\n padding: 0;\n display: block;\n }\n .mmp-dropdown__button {\n display: flex;\n font-size: 1em;\n justify-content: space-between;\n align-items: center;\n height: 36px;\n margin: 2px 0;\n }\n .mmp-dropdown__button.icon {\n height: 40px;\n margin: 0;\n }\n .mmp-dropdown__button > div {\n display: flex;\n flex: 1;\n justify-content: space-between;\n align-items: center;\n height: 36px;\n max-width: 100%;\n }\n .mmp-dropdown__label {\n text-align: left;\n text-transform: none;\n }\n .mmp-dropdown__icon {\n height: 24px;\n width: 24px;\n min-width: 24px;\n }\n paper-item > *:nth-child(2) {\n margin-left: 4px;\n }\n paper-menu-button[focused] mmp-button iron-icon {\n color: var(--mmp-accent-color);\n transform: rotate(180deg);\n }\n paper-menu-button[focused] paper-icon-button {\n color: var(--mmp-accent-color);\n transform: rotate(180deg);\n }\n paper-menu-button[focused] paper-icon-button[focused] {\n color: var(--mmp-text-color);\n transform: rotate(0deg);\n }\n "]);return $=function(){return a},a}function _(){const a=sa(["",""]);return _=function(){return a},a}function aa(){const a=sa([""]);return aa=function(){return a},a}function ba(){const a=sa(["\n \n ","\n ","\n "]);return ba=function(){return a},a}function ca(){const a=sa(["\n \n \n \n ","\n \n \n
\n \n "]);return ca=function(){return a},a}function da(){const a=sa(["\n \n \n "]);return da=function(){return a},a}function ea(){const a=sa(["\n \n ","\n \n ","\n \n \n "]);return ea=function(){return a},a}function fa(){const a=sa(["\n .ellipsis {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n .label {\n margin: 0 8px;\n }\n paper-icon-button {\n transition: color .25s;\n }\n paper-icon-button[color] {\n color: var(--mmp-accent-color) !important;\n opacity: 1 !important;\n }\n paper-icon-button[inactive] {\n opacity: .5;\n }\n"]);return fa=function(){return a},a}function ga(){const a=sa(["\n .mmp-group-list {\n display: flex;\n flex-direction: column;\n margin-left: 8px;\n }\n .mmp-group-list__title {\n font-weight: 500;\n letter-spacing: .1em;\n margin: 8px 0 4px;\n text-transform: uppercase;\n }\n .mmp-group-list__buttons {\n display: flex;\n }\n .mmp-group-list__button {\n margin: 8px 8px 0 0;\n min-width: 0;\n text-transform: uppercase;\n text-align: center;\n width: 50%;\n --mdc-theme-primary: transparent;\n background: rgba(255,255,255,0.25);\n }\n "]);return ga=function(){return a},a}function ha(){const a=sa([""]);return ha=function(){return a},a}function ia(){const a=sa(["Leave"]);return ia=function(){return a},a}function ja(){const a=sa(["Ungroup"]);return ja=function(){return a},a}function ka(){const a=sa(["\n "]);return ka=function(){return a},a}function la(){const a=sa(["\n \n
Group speakers\n ","\n
\n \n ","\n \n \n Group all\n \n
\n
\n "]);return la=function(){return a},a}function ma(){const a=sa(["\n :host {\n position: relative;\n box-sizing: border-box;\n margin: 4px;\n min-width: 0;\n overflow: hidden;\n transition: background .5s;\n }\n :host([raised]) {\n background: rgba(255,255,255,0.25);\n min-height: 36px;\n box-shadow:\n 0px 3px 1px -2px rgba(0, 0, 0, 0.2),\n 0px 2px 2px 0px rgba(0, 0, 0, 0.14),\n 0px 1px 5px 0px rgba(0,0,0,.12);\n }\n :host([color]) {\n background: var(--mmp-active-color);\n transition: background .25s;\n opacity: 1;\n }\n :host([faded]) {\n opacity: .75;\n }\n .container {\n height: 100%;\n width: 100%;\n }\n .slot-container {\n height: 100%;\n display: flex;\n align-items: center;\n justify-content: center;\n margin: 0 8px;\n width: auto;\n }\n paper-ripple {\n position: absolute;\n left: 0;\n right: 0;\n top: 0;\n bottom: 0;\n }\n "]);return ma=function(){return a},a}function na(){const a=sa(["\n \n "]);return na=function(){return a},a}function oa(){const a=sa(["\n paper-checkbox {\n padding: 8px 0;\n }\n paper-checkbox > span {\n font-weight: 600;\n }\n\n ha-card[artwork*='cover'][has-artwork] paper-checkbox[disabled] {\n --paper-checkbox-checkmark-color: rgba(0,0,0,.5);\n }\n ha-card[artwork*='cover'][has-artwork] paper-checkbox {\n --paper-checkbox-unchecked-color: #FFFFFF;\n --paper-checkbox-label-color: #FFFFFF;\n }\n "]);return oa=function(){return a},a}function pa(){const a=sa(["(master)"]);return pa=function(){return a},a}function qa(){const a=sa(["\n \n ","\n ","\n \n "]);return qa=function(){return a},a}function ra(){const a=sa(["\n :host {\n overflow: visible !important;\n display: block;\n --mmp-accent-color: var(--mini-media-player-accent-color, var(--accent-color, #f39c12));\n --mmp-base-color: var(--mini-media-player-base-color, var(--primary-text-color, #000));\n --mmp-overlay-color: var(--mini-media-player-overlay-color, rgba(0,0,0,0.5));\n --mmp-overlay-base-color: var(--mini-media-player-overlay-base-color, #fff);\n --mmp-overlay-accent-color: var(--mini-media-player-overlay-accent-color, --mmp-accent-color);\n --mmp-text-color: var(--mini-media-player-base-color, --primary-text-color);\n --mmp-media-cover-info-color: var(--mini-media-player-media-cover-info-color, --mmp-text-color);\n --mmp-text-color-inverted: var(--disabled-text-color);\n --mmp-active-color: var(--mmp-accent-color);\n --mmp-icon-color: var(--mini-media-player-base-color, var(--paper-item-icon-color, #44739e));\n --mmp-info-opacity: 1;\n --mdc-theme-primary: var(--mmp-text-color);\n --mdc-theme-on-primary: var(--mmp-text-color);\n --paper-checkbox-unchecked-color: var(--mmp-text-color);\n --paper-checkbox-label-color: var(--mmp-text-color);\n color: var(--mmp-text-color);\n }\n ha-card.--bg {\n --mmp-info-opacity: .75;\n }\n ha-card.--has-artwork[artwork*='cover'] {\n --mmp-accent-color: var(--mini-media-player-overlay-accent-color, var(--mini-media-player-accent-color, var(--accent-color, #f39c12)));\n --mmp-text-color: var(--mmp-overlay-base-color);\n --mmp-text-color-inverted: #000;\n --mmp-active-color: rgba(255,255,255,.5);\n --mmp-icon-color: var(--mmp-text-color);\n --mmp-info-opacity: .75;\n --paper-slider-container-color: var(--mini-media-player-overlay-color, rgba(255,255,255,.75));\n --mdc-theme-primary: var(--mmp-text-color);\n --mdc-theme-on-primary: var(--mmp-text-color);\n --paper-checkbox-unchecked-color: var(--mmp-text-color);\n --paper-checkbox-label-color: var(--mmp-text-color);\n color: var(--mmp-text-color);\n }\n ha-card {\n cursor: default;\n display: flex;\n background: transparent;\n overflow: hidden;\n padding: 0;\n position: relative;\n color: inherit;\n }\n ha-card.--group {\n box-shadow: none;\n }\n ha-card.--more-info {\n cursor: pointer;\n }\n ha-card.--collapse {\n overflow: visible;\n }\n .mmp__bg, .mmp__player, .mmp__container {\n border-radius: var(--ha-card-border-radius, 0);\n -webkit-transform: translateZ(0);\n transform: translateZ(0);\n }\n .mmp__container {\n overflow: hidden;\n height: 100%;\n width: 100%;\n position: absolute;\n pointer-events: none;\n }\n ha-card:before {\n content: '';\n padding-top: 0px;\n transition: padding-top .5s cubic-bezier(.21,.61,.35,1);\n will-change: padding-top;\n }\n ha-card.--initial .entity__artwork,\n ha-card.--initial .entity__icon {\n animation-duration: .001s;\n }\n ha-card.--initial:before,\n ha-card.--initial .mmp-player {\n transition: none;\n }\n header {\n display: none;\n }\n ha-card[artwork='full-cover'].--has-artwork:before {\n padding-top: 56%;\n }\n ha-card[artwork='full-cover'].--has-artwork[content='music']:before,\n ha-card[artwork='full-cover-fit'].--has-artwork:before {\n padding-top: 100%;\n }\n .mmp__bg {\n background: var(--ha-card-background, var(--paper-card-background-color, white));\n position: absolute;\n top: 0; right: 0; bottom: 0; left: 0;\n overflow: hidden;\n -webkit-transform: translateZ(0);\n transform: translateZ(0);\n }\n ha-card.--group .mmp__bg {\n background: transparent;\n }\n .cover,\n .cover:before {\n display: block;\n opacity: 0;\n position: absolute;\n top: 0; right: 0; bottom: 0; left: 0;\n transition: opacity .75s cubic-bezier(.21,.61,.35,1);\n will-change: opacity;\n }\n .cover {\n animation: fade-in .5s cubic-bezier(.21,.61,.35,1);\n background-size: cover;\n background-repeat: no-repeat;\n background-position: center center;\n }\n .cover:before {\n background: var(--mmp-overlay-color);\n content: '';\n }\n ha-card[artwork*='full-cover'].--has-artwork .mmp-player {\n background: linear-gradient(to top, var(--mmp-overlay-color) 25%, transparent 100%);\n border-bottom-left-radius: var(--ha-card-border-radius, 0);\n border-bottom-right-radius: var(--ha-card-border-radius, 0);\n }\n ha-card.--has-artwork .cover,\n ha-card.--has-artwork[artwork='cover'] .cover:before,\n ha-card.--bg .cover {\n opacity: .999;\n }\n ha-card[artwork='default'] .cover {\n display: none;\n }\n ha-card.--bg .cover {\n display: block;\n }\n ha-card[artwork='full-cover-fit'].--has-artwork .cover {\n background-color: black;\n background-size: contain;\n }\n .mmp-player {\n align-self: flex-end;\n box-sizing: border-box;\n position: relative;\n padding: 16px;\n transition: padding .25s ease-out;\n width: 100%;\n will-change: padding;\n }\n ha-card.--group .mmp-player {\n padding: 2px 0;\n }\n .flex {\n display: flex;\n display: -ms-flexbox;\n display: -webkit-flex;\n flex-direction: row;\n }\n .mmp-player__core {\n position: relative;\n }\n .entity__info {\n justify-content: center;\n display: flex;\n flex-direction: column;\n margin-left: 8px;\n position: relative;\n overflow: hidden;\n user-select: none;\n }\n ha-card.--rtl .entity__info {\n margin-left: auto;\n margin-right: 8px;\n }\n ha-card[content='movie'] .attr__media_season,\n ha-card[content='movie'] .attr__media_episode {\n display: none;\n }\n .entity__icon {\n color: var(--mmp-icon-color);\n }\n .entity__artwork, .entity__icon {\n animation: fade-in .25s ease-out;\n background-position: center center;\n background-repeat: no-repeat;\n background-size: cover;\n border-radius: 100%;\n height: 40px;\n width: 40px;\n min-width: 40px;\n line-height: 40px;\n margin-right: 8px;\n position: relative;\n text-align: center;\n will-change: border-color;\n transition: border-color .25s ease-out;\n }\n ha-card.--rtl .entity__artwork,\n ha-card.--rtl .entity__icon {\n margin-right: auto;\n }\n .entity__artwork[border] {\n border: 2px solid var(--primary-text-color);\n box-sizing: border-box;\n -moz-box-sizing: border-box;\n -webkit-box-sizing: border-box;\n }\n .entity__artwork[border][state='playing'] {\n border-color: var(--mmp-accent-color);\n }\n .entity__info__name,\n .entity__info__media[short] {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n .entity__info__name {\n line-height: 20px;\n color: var(--mmp-text-color);\n }\n .entity__info__media {\n color: var(--secondary-text-color);\n max-height: 6em;\n word-break: break-word;\n opacity: var(--mmp-info-opacity);\n transition: color .5s;\n }\n .entity__info__media[short] {\n max-height: 20px;\n overflow: hidden;\n }\n .attr__app_name {\n display: none;\n }\n .attr__app_name:first-child,\n .attr__app_name:first-of-type {\n display: inline;\n }\n .mmp-player__core[inactive] .entity__info__media {\n color: var(--mmp-text-color);\n max-width: 200px;\n opacity: .5;\n }\n .entity__info__media[short-scroll] {\n max-height: 20px;\n white-space: nowrap;\n }\n .entity__info__media[scroll] > span {\n visibility: hidden;\n }\n .entity__info__media[scroll] > div {\n animation: move linear infinite;\n }\n .entity__info__media[scroll] .marquee {\n animation: slide linear infinite;\n }\n .entity__info__media[scroll] .marquee,\n .entity__info__media[scroll] > div {\n animation-duration: inherit;\n visibility: visible;\n }\n .entity__info__media[scroll] {\n animation-duration: 10s;\n mask-image: linear-gradient(to right, transparent 0%, black 5%, black 95%, transparent 100%);\n -webkit-mask-image: linear-gradient(to right, transparent 0%, black 5%, black 95%, transparent 100%);\n }\n .marquee {\n visibility: hidden;\n position: absolute;\n white-space: nowrap;\n }\n ha-card[artwork*='cover'].--has-artwork .entity__info__media,\n ha-card.--bg .entity__info__media {\n color: var(--mmp-media-cover-info-color);\n }\n .entity__info__media span:before {\n content: ' - ';\n }\n .entity__info__media span:first-of-type:before {\n content: '';\n }\n .entity__info__media span:empty {\n display: none;\n }\n .mmp-player__adds {\n margin-left: 48px;\n position: relative;\n }\n ha-card.--rtl .mmp-player__adds {\n margin-left: auto;\n margin-right: 48px;\n }\n .mmp-player__adds > *:nth-child(2) {\n margin-top: 0px;\n }\n mmp-powerstrip {\n flex: 1;\n justify-content: flex-end;\n margin-right: 0;\n margin-left: auto;\n width: auto;\n max-width: 100%;\n }\n mmp-media-controls {\n flex-wrap: wrap;\n justify-content: center;\n }\n ha-card.--flow mmp-powerstrip {\n justify-content: space-between;\n margin-left: auto;\n }\n ha-card.--flow.--rtl mmp-powerstrip {\n margin-right: auto;\n }\n ha-card.--flow .entity__info {\n display: none;\n }\n ha-card.--responsive .mmp-player__adds {\n margin-left: 0;\n }\n ha-card.--responsive.--rtl .mmp-player__adds {\n margin-right: 0;\n }\n ha-card.--responsive .mmp-player__adds > mmp-media-controls {\n padding: 0;\n }\n ha-card.--runtime .mmp-player {\n padding-bottom: calc(16px + 8px);\n }\n ha-card.--runtime.--group .mmp-player {\n padding-bottom: calc(16px + 8px);\n }\n .mmp-player div:empty {\n display: none;\n }\n @keyframes slide {\n 100% { transform: translateX(-100%); }\n }\n @keyframes move {\n from { transform: translateX(100%); }\n to { transform: translateX(0); }\n }\n @keyframes fade-in {\n from { opacity: 0; }\n to { opacity: 1; }\n }\n"]);return ra=function(){return a},a}function sa(a,b){return b||(b=a.slice(0)),Object.freeze(Object.defineProperties(a,{raw:{value:Object.freeze(b)}}))}function ta(a){for(var b=1;ba.parentNode.removeChild(a))}function va(a,b){let c=2"function"==typeof a&&Ia.has(a),Ka=window.customElements!==void 0&&window.customElements.polyfillWrapFlushCallback!==void 0,La=function(a,b){for(let c=2"),Qa=new RegExp("".concat(Oa,"|").concat(Pa)),Ra="$lit$";class Sa{constructor(a,b){this.parts=[],this.element=b;const c=[],d=[],e=document.createTreeWalker(b.content,133,null,!1);let f=0,g=-1,h=0;for(const i=a.strings,j=a.values.length;h{const c=a.length-b.length;return 0<=c&&a.slice(c)===b},Ua=a=>-1!==a.index,Va=()=>document.createComment(""),Wa=/([ \x09\x0a\x0c\x0d])([^\0-\x1F\x7F-\x9F "'>=/]+)([ \x09\x0a\x0c\x0d]*=[ \x09\x0a\x0c\x0d]*(?:[^ \x09\x0a\x0c\x0d"'`<>=]*|"[^"]*|'[^']*))$/;class Xa{constructor(a,b,c){this.__parts=[],this.template=a,this.processor=b,this.options=c}update(a){let b=0;for(const c of this.__parts)void 0!==c&&c.setValue(a[b]),b++;for(const b of this.__parts)void 0!==b&&b.commit()}_clone(){const a=Ka?this.template.element.content.cloneNode(!0):document.importNode(this.template.element.content,!0),b=[],c=this.template.parts,d=document.createTreeWalker(a,133,null,!1);let e,f=0,g=0,h=d.nextNode();for(;f",e+1);const f=Wa.exec(a);b+=null===f?a+(c?Oa:Pa):a.substr(0,f.index)+f[1]+f[2]+Ra+f[3]+Oa}return b+=this.strings[a],b}getTemplateElement(){const a=document.createElement("template");return a.innerHTML=this.getHTML(),a}}const Za=a=>null===a||"object"!=typeof a&&"function"!=typeof a,$a=a=>Array.isArray(a)||!!(a&&a[Symbol.iterator]);class _a{constructor(a,b,c){this.dirty=!0,this.element=a,this.name=b,this.strings=c,this.parts=[];for(let d=0;dthis.handleEvent(a)}setValue(a){this.__pendingValue=a}commit(){for(;Ja(this.__pendingValue);){const a=this.__pendingValue;this.__pendingValue=Ma,a(this)}if(this.__pendingValue===Ma)return;const a=this.__pendingValue,b=this.value,c=null==a||null!=b&&(a.capture!==b.capture||a.once!==b.once||a.passive!==b.passive);c&&this.element.removeEventListener(this.eventName,this.__boundHandleEvent,this.__options),null!=a&&(null==b||c)&&(this.__options=hb(a),this.element.addEventListener(this.eventName,this.__boundHandleEvent,this.__options)),this.value=a,this.__pendingValue=Ma}handleEvent(a){"function"==typeof this.value?this.value.call(this.eventContext||this.element,a):this.value.handleEvent(a)}}const hb=a=>a&&(fb?{capture:a.capture,passive:a.passive,once:a.once}:a.capture);const ib=new class{handleAttributeExpressions(a,b,c,d){const e=b[0];if("."===e){const d=new db(a,b.slice(1),c);return d.parts}if("@"===e)return[new gb(a,b.slice(1),d.eventContext)];if("?"===e)return[new cb(a,b.slice(1),c)];const f=new _a(a,b,c);return f.parts}handleTextExpression(a){return new bb(a)}},jb=new Map,kb=new WeakMap,lb=(a,b,c)=>{let d=kb.get(b);d===void 0&&(La(b,b.firstChild),kb.set(b,d=new bb(Object.assign({templateFactory:sa},c))),d.appendInto(b)),d.setValue(a),d.commit()};(window.litHtmlVersions||(window.litHtmlVersions=[])).push("1.0.0");const mb=function(a){for(var b=arguments.length,c=Array(1{let b=11===a.nodeType?0:1;for(const c=document.createTreeWalker(a,nb,null,!1);c.nextNode();)b++;return b},pb=function(a){let b=1"".concat(a,"--").concat(b);let rb=!0;"undefined"==typeof window.ShadyCSS?rb=!1:"undefined"==typeof 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."),rb=!1);const sb=a=>b=>{const c=qb(b.type,a);let d=jb.get(c);void 0===d&&(d={stringsArray:new WeakMap,keyString:new Map},jb.set(c,d));let e=d.stringsArray.get(b.strings);if(void 0!==e)return e;const f=b.strings.join(Oa);if(e=d.keyString.get(f),void 0===e){const c=b.getTemplateElement();rb&&window.ShadyCSS.prepareTemplateDom(c,a),e=new Sa(b,c),d.keyString.set(f,e)}return d.stringsArray.set(b.strings,e),e},tb=["html","svg"],ub=a=>{tb.forEach(b=>{const c=jb.get(qb(b,a));c!==void 0&&c.keyString.forEach(a=>{const b=a.element.content,c=new Set;Array.from(b.querySelectorAll("style")).forEach(a=>{c.add(a)}),ua(a,c)})})},vb=new Set,wb=(a,b,c)=>{vb.add(c);const d=a.querySelectorAll("style"),e=d.length;if(0===e)return void window.ShadyCSS.prepareTemplateStyles(b.element,c);const f=document.createElement("style");for(let g=0;g{const d=c.scopeName,e=kb.has(b),f=rb&&11===b.nodeType&&!!b.host&&a instanceof Ya,g=f&&!vb.has(d),h=g?document.createDocumentFragment():b;if(lb(a,h,Object.assign({templateFactory:sb(d)},c)),g){const a=kb.get(h);kb.delete(h),a.value instanceof Xa&&wb(h,a.value.template,d),La(b,b.firstChild),b.appendChild(h),kb.set(b,a)}!e&&f&&window.ShadyCSS.styleElement(b.host)};window.JSCompiler_renameProperty=a=>a;const yb={toAttribute(a,b){return b===Boolean?a?"":null:b===Object||b===Array?null==a?a:JSON.stringify(a):a},fromAttribute(a,b){return b===Boolean?null!==a:b===Number?null===a?null:+a:b===Object||b===Array?JSON.parse(a):a}},zb=(a,b)=>b!==a&&(b===b||a===a),Ab={attribute:!0,type:String,converter:yb,reflect:!1,hasChanged:zb},Bb=Promise.resolve(!0),Cb=1,Db=4,Eb=8,Fb=16,Gb=32;class Hb extends HTMLElement{constructor(){super(),this._updateState=0,this._instanceProperties=void 0,this._updatePromise=Bb,this._hasConnectedResolver=void 0,this._changedProperties=new Map,this._reflectingProperties=void 0,this.initialize()}static get observedAttributes(){this.finalize();const a=[];return this._classProperties.forEach((b,c)=>{const d=this._attributeNameForProperty(c,b);void 0!==d&&(this._attributeToPropertyMap.set(d,c),a.push(d))}),a}static _ensureClassProperties(){if(!this.hasOwnProperty(JSCompiler_renameProperty("_classProperties",this))){this._classProperties=new Map;const a=Object.getPrototypeOf(this)._classProperties;a!==void 0&&a.forEach((a,b)=>this._classProperties.set(b,a))}}static createProperty(a){let b=1{if(this.hasOwnProperty(b)){const a=this[b];delete this[b],this._instanceProperties||(this._instanceProperties=new Map),this._instanceProperties.set(b,a)}})}_applyInstanceProperties(){this._instanceProperties.forEach((a,b)=>this[b]=a),this._instanceProperties=void 0}connectedCallback(){this._updateState|=Gb,this._hasConnectedResolver&&(this._hasConnectedResolver(),this._hasConnectedResolver=void 0)}disconnectedCallback(){}attributeChangedCallback(a,b,c){b!==c&&this._attributeToProperty(a,c)}_propertyToAttribute(a,b){let c=2{b=a,c=d});try{yield d}catch(a){}a._hasConnected||(yield new Promise(b=>a._hasConnectedResolver=b));try{const b=a.performUpdate();null!=b&&(yield b)}catch(a){c(a)}b(!a._hasRequestedUpdate)})()}get _hasConnected(){return this._updateState&Gb}get _hasRequestedUpdate(){return this._updateState&Db}get hasUpdated(){return this._updateState&Cb}performUpdate(){this._instanceProperties&&this._applyInstanceProperties();let a=!1;const b=this._changedProperties;try{a=this.shouldUpdate(b),a&&this.update(b)}catch(b){throw a=!1,b}finally{this._markUpdated()}a&&(!(this._updateState&Cb)&&(this._updateState|=Cb,this.firstUpdated(b)),this.updated(b))}_markUpdated(){this._changedProperties=new Map,this._updateState&=~Db}get updateComplete(){return this._updatePromise}shouldUpdate(a){return!0}update(a){this._reflectingProperties!==void 0&&0this._propertyToAttribute(b,this[b],a)),this._reflectingProperties=void 0)}updated(a){}firstUpdated(a){}}Hb.finalized=!0;const Ib="adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Jb=Symbol();class Kb{constructor(a,b){if(b!==Jb)throw new Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=a}get styleSheet(){return void 0===this._styleSheet&&(Ib?(this._styleSheet=new CSSStyleSheet,this._styleSheet.replaceSync(this.cssText)):this._styleSheet=null),this._styleSheet}toString(){return this.cssText}}const Lb=a=>{if(a instanceof Kb)return a.cssText;if("number"==typeof a)return a;throw new Error("Value passed to 'css' function must be a 'css' function result: ".concat(a,". Use 'unsafeCSS' to pass non-literal values, but\n take care to ensure page security."))},Mb=function(a){for(var b=arguments.length,c=Array(1b+Lb(c)+a[d+1],a[0]);return new Kb(e,Jb)};(window.litElementVersions||(window.litElementVersions=[])).push("2.2.0");const Nb=a=>a.flat?a.flat(1/0):xa(a);class Ob extends Hb{static finalize(){super.finalize(),this._styles=this.hasOwnProperty(JSCompiler_renameProperty("styles",this))?this._getUniqueStyles():this._styles||[]}static _getUniqueStyles(){const a=this.styles,b=[];if(Array.isArray(a)){const c=Nb(a),d=c.reduceRight((a,b)=>(a.add(b),a),new Set);d.forEach(a=>b.unshift(a))}else a&&b.push(a);return b}initialize(){super.initialize(),this.renderRoot=this.createRenderRoot(),window.ShadowRoot&&this.renderRoot instanceof window.ShadowRoot&&this.adoptStyles()}createRenderRoot(){return this.attachShadow({mode:"open"})}adoptStyles(){const a=this.constructor._styles;0===a.length||(window.ShadyCSS===void 0||window.ShadyCSS.nativeShadow?Ib?this.renderRoot.adoptedStyleSheets=a.map(a=>a.styleSheet):this._needsShimAdoptedStyleSheets=!0:window.ShadyCSS.ScopingShim.prepareAdoptedCssText(a.map(a=>a.cssText),this.localName))}connectedCallback(){super.connectedCallback(),this.hasUpdated&&window.ShadyCSS!==void 0&&window.ShadyCSS.styleElement(this)}update(a){super.update(a);const b=this.render();b instanceof Ya&&this.constructor.render(b,this.renderRoot,{scopeName:this.localName,eventContext:this}),this._needsShimAdoptedStyleSheets&&(this._needsShimAdoptedStyleSheets=!1,this.constructor._styles.forEach(a=>{const b=document.createElement("style");b.textContent=a.cssText,this.renderRoot.appendChild(b)}))}render(){}}Ob.finalized=!0,Ob.render=xb;const Pb=new WeakMap,Qb=(a=>function(){const b=a(...arguments);return Ia.set(b,!0),b})(a=>b=>{if(!(b instanceof ab)||b instanceof eb||"class"!==b.committer.name||1ta({text:this.attr[a.attr],prefix:""},a)).filter(a=>a.text)}get hasProgress(){return!this.config.hide.progress&&!this.idle&&jc.every(a=>a in this.attr)}get progress(){return this.position+(Date.now()-new Date(this.updatedAt).getTime())/1e3}get idleView(){const a=this.config.idle_view;return!!(a.when_idle&&this.isIdle||a.when_standby&&this.isStandby||a.when_paused&&this.isPaused)||!!(this.updatedAt&&a.after&&!this.isPlaying)&&this.checkIdleAfter(a.after)}get trackIdle(){return this.active&&!this.isPlaying&&this.updatedAt&&this.config.idle_view&&this.config.idle_view.after}checkIdleAfter(a){const b=(Date.now()-new Date(this.updatedAt).getTime())/1e3;return this.idle=b>60*a,this.active=this.isActive,this.idle}get supportsShuffle(){return"undefined"!=typeof this.attr.shuffle}get supportsMute(){return"undefined"!=typeof this.attr.is_volume_muted}getAttribute(a){return this.attr[a]||""}fetchThumbnail(){var a=this;return wa(function*(){try{const b=yield a.hass.callWS({type:"media_player_thumbnail",entity_id:a.config.entity}),c=b.content_type,d=b.content;return"url(data:".concat(c,";base64,").concat(d,")")}catch(a){return console.error("mini-media-player: Failed fetching thumbnail"),!1}})()}toggle(a){return this.config.toggle_power?this.callService(a,"toggle"):this.isOff?this.callService(a,"turn_on"):void this.callService(a,"turn_off")}toggleMute(a){this.callService(a,"volume_mute",{is_volume_muted:!this.muted})}toggleShuffle(a){this.callService(a,"shuffle_set",{shuffle:!this.shuffle})}setSource(a,b){this.callService(a,"select_source",{source:b})}setMedia(a,b){this.callService(a,"play_media",ta({},b))}playPause(a){this.callService(a,"media_play_pause")}setSoundMode(a,b){this.callService(a,"select_sound_mode",{sound_mode:b})}next(a){this.callService(a,"media_next_track")}prev(a){this.callService(a,"media_previous_track")}stop(a){this.callService(a,"media_stop")}volumeUp(a){this.callService(a,"volume_up")}volumeDown(a){this.callService(a,"volume_down")}seek(a,b){this.callService(a,"media_seek",{seek_position:b})}setVolume(a,b){this.config.speaker_group.sync_volume?this.group.forEach(c=>{const d=this.config.speaker_group.entities.find(a=>a.entity_id===c)||{};let e=b;d.volume_offset&&(e+=d.volume_offset/100,1e&&(e=0)),this.callService(a,"volume_set",{entity_id:c,volume_level:e})}):this.callService(a,"volume_set",{entity_id:this.config.entity,volume_level:b})}handleGroupChange(a,b,c){const d=this.config.speaker_group.platform,e={entity_id:b};if(c){if(e.master=this.config.entity,"sonos"===d)return this.callService(a,"join",e,d);this.callService(a,"".concat(d,"_JOIN"),e)}else{if("sonos"===d)return this.callService(a,"unjoin",e,d);this.callService(a,"".concat(d,"_UNJOIN"),e)}}toggleScript(a,b){let c=2a.stopPropagation(),this.handleClick,this.item.name,this.master?mb(pa()):"")}handleClick(a){a.stopPropagation(),this.dispatchEvent(new CustomEvent("change",{detail:{entity:this.item.entity_id,checked:!this.checked}}))}static get styles(){return Mb(oa())}}customElements.define("mmp-group-item",nc);class oc extends Ob{render(){return mb(na())}static get styles(){return Mb(ma())}}customElements.define("mmp-button",oc);class pc extends Ob{static get properties(){return{entities:{},player:{},visible:Boolean}}get group(){return this.player.group}get master(){return this.player.master}get isMaster(){return this.player.isMaster}handleGroupChange(a){const b=a.detail,c=b.entity,d=b.checked;this.player.handleGroupChange(a,c,d)}render(){let a=0mb(ka(),this.handleGroupChange,a,a.entity_id===this.player.id||b.includes(a.entity_id),a.entity_id===this.player.id||c!==this.player.id,a.entity_id===c)),2>b.length,a=>this.player.handleGroupChange(a,d?b:this.player.entity_id,!1),d?mb(ja()):mb(ia()),!d,a=>this.player.handleGroupChange(a,this.entities.map(a=>a.entity_id),!0)):mb(ha())}static get styles(){return Mb(ga())}}customElements.define("mmp-group-list",pc);const qc=Mb(fa());class rc extends Ob{static get properties(){return{items:[],label:String,selected:String}}get selectedId(){return this.items.map(a=>a.id).indexOf(this.selected)}onChange(a){this.dispatchEvent(new CustomEvent("change",{detail:a}))}render(){return mb(ea(),"right","top",44,a=>a.stopPropagation(),this.icon?mb(da(),hc.DROPDOWN):mb(ca(),this.selected||this.label,hc.DROPDOWN),this.selectedId,this.items.map(a=>mb(ba(),a.id||a.name,()=>this.onChange(a),a.icon?mb(aa(),a.icon):"",a.name?mb(_(),a.name):"")))}static get styles(){return[qc,Mb($())]}}customElements.define("mmp-dropdown",rc);class sc extends Ob{static get properties(){return{player:{},shortcuts:{}}}get buttons(){return this.shortcuts.buttons}get list(){return this.shortcuts.list}get show(){return!this.shortcuts.hide_when_off||this.player.active}get active(){return this.player.getAttribute(this.shortcuts.attribute)}get height(){return this.shortcuts.column_height||36}render(){if(!this.show)return mb(Z());const a=this.active,b=this.list?mb(Y(),this.handleShortcut,this.list,this.shortcuts.label,a):"",c=this.buttons?mb(X(),this.buttons.map(b=>mb(W(),"min-height: ".concat(this.height,"px;"),this.shortcuts.columns,b.id===a,a=>this.handleShortcut(a,b),this.shortcuts.align_text,b.icon?mb(V(),b.icon):"",b.name?mb(U(),b.name):""))):"";return mb(T(),c,b)}handleShortcut(a,b){const c=b||a.detail,d=c.type,e=c.id,f=c.data;if("source"===d)return this.player.setSource(a,e);if("service"===d)return this.player.toggleService(a,e,f);if("script"===d)return this.player.toggleScript(a,e,f);if("sound_mode"===d)return this.player.setSoundMode(a,e);this.player.setMedia(a,{media_content_type:d,media_content_id:e})}static get styles(){return[qc,Mb(S())]}}customElements.define("mmp-shortcuts",sc);const tc=function(a,b){let c=2a.stopPropagation(),this.handleTts)}handleTts(a){const b=this.config,c=this.message,d={message:c,entity_id:b.entity_id||this.entity};b.language&&(d.language=b.language),"alexa"===b.platform?this.hass.callService("notify","alexa_media",{message:c,data:{type:b.type||"tts"},target:d.entity_id}):"sonos"===b.platform?this.hass.callService("script","sonos_say",{sonos_entity:d.entity_id,volume:b.volume||.5,message:c}):"webos"===b.platform?this.hass.callService("notify",d.entity_id.split(".").slice(-1)[0],{message:c}):"ga"===b.platform?this.hass.callService("notify","ga_broadcast",{message:c}):this.hass.callService("tts","".concat(b.platform,"_say"),d),a.stopPropagation(),this.reset()}reset(){this.input.value=""}static get styles(){return Mb(Q())}}customElements.define("mmp-tts",uc);var vc=a=>{let b=parseInt(a%60,10),c=parseInt(a/60%60,10),d=parseInt(a/3600%24,10);return d=10>d?"0".concat(d):d,c=10>c?"0".concat(c):c,b=10>b?"0".concat(b):b,"".concat("00"===d?"":"".concat(d,":")).concat(c,":").concat(b)};class wc extends Ob{static get properties(){return{_player:{},showTime:Boolean,progress:Number,duration:Number,tracker:{},track:Boolean}}set player(a){this._player=a,this.hasProgress&&this.trackProgress()}get duration(){return this.player.mediaDuration}get player(){return this._player}get hasProgress(){return this.player.hasProgress}render(){return this.player.active&&this.hasProgress?mb(P(),this.handleSeek,!this.player.isPlaying,this.showTime?mb(O(),vc(this.progress),vc(this.duration)):"",this.progress,this.duration):mb(N())}trackProgress(){this.progress=this.player.progress,this.tracker||(this.tracker=setInterval(()=>this.trackProgress(),1e3)),this.player.isPlaying||(clearInterval(this.tracker),this.tracker=null)}handleSeek(a){const b=this.duration,c=a.offsetX/a.target.offsetWidth*b;this.player.seek(a,c)}disconnectedCallback(){clearInterval(this.tracker)}static get styles(){return Mb(M())}}customElements.define("mmp-progress",wc);class xc extends Ob{static get properties(){return{player:{},selected:String,icon:Boolean}}get source(){return this.player.source}get sources(){return this.player.sources.map(a=>({name:a,id:a,type:"source"}))}render(){return mb(L(),this.handleSource,this.sources,this.source,this.selected||this.source,this.icon)}handleSource(a){const b=a.detail.id;this.player.setSource(a,b),this.selected=b}static get styles(){return Mb(K())}}customElements.define("mmp-source-menu",xc);class yc extends Ob{static get properties(){return{player:{},selected:String,icon:Boolean}}get mode(){return this.player.soundMode}get modes(){return this.player.soundModes.map(a=>({name:a,id:a,type:"soundMode"}))}render(){return mb(J(),this.handleChange,this.modes,this.mode,this.selected||this.mode,this.icon)}handleChange(a){const b=a.detail.id;this.player.setSoundMode(a,b),this.selected=b}static get styles(){return Mb(I())}}customElements.define("mmp-sound-menu",yc);class zc extends Ob{static get properties(){return{player:{},config:{},break:Boolean}}get showShuffle(){return!this.config.hide.shuffle&&this.player.supportsShuffle}get maxVol(){return this.config.max_volume||100}get minVol(){return this.config.min_volume||0}render(){const a=this.config.hide;return mb(H(),a.volume?mb(G()):this.renderVolControls(this.player.muted),this.showShuffle?mb(F(),a=>this.player.toggleShuffle(a),hc.SHUFFLE,this.player.shuffle):mb(E()),a.controls?mb(C()):mb(D(),this.config.flow||this.break,a=>this.player.prev(a),hc.PREV,a=>this.player.playPause(a),hc.PLAY[this.player.isPlaying],a=>this.player.next(a),hc.NEXT))}renderVolControls(a){return this.config.volume_stateless?this.renderVolButtons(a):this.renderVolSlider(a)}renderVolSlider(a){return mb(B(),this.renderMuteButton(a),this.handleVolumeChange,a=>a.stopPropagation(),a,this.minVol,this.maxVol,100*this.player.vol,"ltr")}renderVolButtons(a){return mb(A(),this.renderMuteButton(a),a=>this.player.volumeDown(a),hc.VOL_DOWN,a=>this.player.volumeUp(a),hc.VOL_UP)}renderMuteButton(a){if(!this.config.hide.mute)switch(this.config.replace_mute){case"play":return mb(z(),a=>this.player.playPause(a),hc.PLAY[this.player.isPlaying]);case"stop":return mb(y(),a=>this.player.stop(a),hc.STOP);case"next":return mb(x(),a=>this.player.next(a),hc.NEXT);default:return this.player.supportsMute?mb(w(),a=>this.player.toggleMute(a),hc.MUTE[a]):void 0;}}handleVolumeChange(a){const b=parseFloat(a.target.value)/100;this.player.setVolume(a,b)}static get styles(){return[qc,Mb(v())]}}customElements.define("mmp-media-controls",zc);class Ac extends Ob{static get properties(){return{hass:{},player:{},config:{},groupVisible:Boolean,idle:Boolean}}get showGroupButton(){return this.config.speaker_group.entities}get showPowerButton(){return!this.config.hide.power}get powerColor(){return this.player.active&&!this.config.hide.power_state}get sourceSize(){return"icon"===this.config.source||this.config.collapse||this.idle}get soundSize(){return"icon"===this.config.sound_mode||this.config.collapse||this.idle}get hasSource(){return 0this.player.toggle(a),this.powerColor):"")}handleGroupClick(a){a.stopPropagation(),this.dispatchEvent(new CustomEvent("toggleGroupList"))}get renderIdleView(){return this.player.isPaused?mb(n(),hc.PLAY[this.player.isPlaying],a=>this.player.playPause(a)):mb(m(),tc(this.hass,"state.media_player.idle","Idle"))}static get styles(){return[qc,Mb(l())]}}customElements.define("mmp-powerstrip",Ac),customElements.get("ha-slider")||customElements.define("ha-slider",class extends customElements.get("paper-slider"){});class Bc extends Ob{constructor(){super(),this._overflow=!1,this.initial=!0,this.picture=!1,this.thumbnail=!1,this.edit=!1,this.rtl=!1}static get properties(){return{_hass:{},config:{},entity:{},player:{},_overflow:Boolean,break:Boolean,initial:Boolean,picture:String,thumbnail:String,edit:Boolean,rtl:Boolean,idle:Boolean}}static get styles(){return mc}set hass(a){if(a){const b=a.states[this.config.entity];this._hass=a,b&&this.entity!==b&&(this.entity=b,this.player=new lc(a,this.config,b),this.rtl=this.computeRTL(a),this.idle=this.player.idle,this.player.trackIdle&&this.updateIdleStatus())}}get hass(){return this._hass}set overflow(a){this._overflow!==a&&(this._overflow=a)}get overflow(){return this._overflow}get name(){return this.config.name||this.player.name}setConfig(a){if(!a.entity||"media_player"!==a.entity.split(".")[0])throw new Error("Specify an entity from within the media_player domain.");const b=ta({artwork:"default",info:"default",more_info:!0,source:"default",sound_mode:"default",toggle_power:!0},a,{hide:ta({},gc,a.hide),speaker_group:ta({show_group_count:!0,platform:"sonos"},a.sonos,a.speaker_group),shortcuts:ta({label:"Shortcuts..."},a.shortcuts)});b.max_volume=+b.max_volume||100,b.min_volume=+b.min_volume||0,b.collapse=b.hide.controls||b.hide.volume,b.info=b.collapse&&"scroll"!==b.info?"short":b.info,b.flow=b.hide.icon&&b.hide.name&&b.hide.info,this.config=b}shouldUpdate(a){return void 0===this.break&&this.computeRect(this),ic.some(b=>a.has(b))&&this.player}firstUpdated(){const a=new fc(a=>{a.forEach(a=>{window.requestAnimationFrame(()=>{"scroll"===this.config.info&&this.computeOverflow(),this._resizeTimer||(this.computeRect(a),this._resizeTimer=setTimeout(()=>{this._resizeTimer=null,this.computeRect(this._resizeEntry)},250)),this._resizeEntry=a})})});a.observe(this),setTimeout(()=>this.initial=!1,250),this.edit=this.config.speaker_group.expanded||!1}updated(){"scroll"===this.config.info&&setTimeout(()=>{this.computeOverflow()},10)}render(){let a=0mb(b(),"attr__".concat(a.attr),a.prefix+a.text))):"",e.map(b=>mb(a(),"attr__".concat(b.attr),b.prefix+b.text)))}}speakerCount(){if(this.config.speaker_group.show_group_count){const a=this.player.groupCount;return 1{this.thumbnail=a}),this.picture=b),!!(c&&this.thumbnail)}computeIcon(){return this.config.icon?this.config.icon:this.player.icon||hc.DEFAULT}computeOverflow(){const a=this.shadowRoot.querySelector(".marquee");if(a){const b=a.clientWidth>a.parentNode.clientWidth;this.overflow=!!(b&&this.player.active)&&7.5+a.clientWidth/50}}computeRect(a){const b=a.contentRect||a.getBoundingClientRect(),c=b.left,d=b.width;this.break=d+2*c<390}computeRTL(a){const b=a.language||"en";return!!a.translationMetadata.translations[b]&&(a.translationMetadata.translations[b].isRTL||!1)}toggleGroupList(){this.edit=!this.edit}handleMoreInfo(a){a.stopPropagation(),this.config.more_info&&this.fire("hass-more-info",{entityId:this.config.entity})}fire(a,b,c){const d=c||{},f=null===b||void 0===b?{}:b,g=new Event(a,{bubbles:void 0===d.bubbles||d.bubbles,cancelable:!!d.cancelable,composed:void 0===d.composed||d.composed});return g.detail=f,this.dispatchEvent(g),g}updateIdleStatus(){this._idleTracker&&clearTimeout(this._idleTracker);const a=(Date.now()-new Date(this.player.updatedAt).getTime())/1e3;this._idleTracker=setTimeout(()=>{this.idle=this.player.checkIdleAfter(this.config.idle_view.after),this.player.idle=this.idle,this._idleTracker=null},1e3*(60*this.config.idle_view.after-a))}getCardSize(){return this.config.collapse?1:2}}customElements.define("mini-media-player",Bc)})})();
+(function(){"use strict";function a(){const b=sa(["",""]);return a=function(){return b},b}function b(){const a=sa(["",""]);return b=function(){return a},a}function c(){const a=sa(["\n "]);return c=function(){return a},a}function d(){const a=sa(["\n \n ","\n ","\n
"]);return d=function(){return a},a}function e(){const a=sa(["\n \n "," ","\n
"]);return e=function(){return a},a}function f(){const a=sa(["\n \n \n
"]);return f=function(){return a},a}function g(){const a=sa(["\n \n
"]);return g=function(){return a},a}function h(){const a=sa([""]);return h=function(){return a},a}function i(){const a=sa(["\n \n \n "]);return i=function(){return a},a}function j(){const a=sa(["\n \n \n "]);return j=function(){return a},a}function k(){const a=sa(["\n \n \n ","\n
\n \n
\n ","\n
\n ","\n ","\n
\n
\n \n
\n
\n ","\n \n \n ","\n \n \n
\n
\n \n \n \n
\n \n "]);return k=function(){return a},a}function l(){const a=sa(["\n :host {\n display: flex;\n line-height: 40px;\n max-height: 40px;\n }\n :host([flow]) mmp-media-controls {\n max-width: unset;\n }\n mmp-media-controls {\n max-width: 200px;\n }\n .group-button {\n height: 34px;\n width: 34px;\n min-width: 34px;\n margin: 3px;\n }\n paper-icon-button {\n min-width: 40px;\n }\n "]);return l=function(){return a},a}function m(){const a=sa(["\n \n ","\n \n "]);return m=function(){return a},a}function n(){const a=sa(["\n \n "]);return n=function(){return a},a}function o(){const a=sa(["\n \n "]);return o=function(){return a},a}function p(){const a=sa(["\n \n "]);return p=function(){return a},a}function q(){const a=sa(["\n \n "]);return q=function(){return a},a}function r(){const a=sa(["\n \n "]);return r=function(){return a},a}function s(){const a=sa(["\n \n \n "]);return s=function(){return a},a}function t(){const a=sa(["\n ","\n ","\n ","\n ","\n ","\n ","\n "]);return t=function(){return a},a}function u(){const a=sa(["\n \n ","\n \n "]);return u=function(){return a},a}function v(){const a=sa(["\n :host {\n display: flex;\n width: 100%;\n }\n .flex {\n display: flex;\n flex: 1;\n justify-content: space-between;\n }\n ha-slider {\n max-width: none;\n min-width: 100px;\n width: 100%;\n }\n paper-icon-button {\n min-width: 40px;\n }\n .mmp-media-controls__volume {\n flex: 100;\n max-height: 40px;\n }\n .mmp-media-controls__volume.--buttons {\n justify-content: left;\n }\n .mmp-media-controls__media {\n direction: ltr;\n max-width: calc(40px * 3);\n margin-right: 0;\n margin-left: auto;\n }\n .mmp-media-controls__media[flow] {\n max-width: none;\n }\n .mmp-media-controls__shuffle {\n flex: 3;\n flex-shrink: 200;\n justify-content: center;\n }\n .mmp-media-controls__shuffle paper-icon-button {\n height: 36px;\n width: 36px;\n min-width: 36px;\n margin: 2px;\n }\n "]);return v=function(){return a},a}function w(){const a=sa(["\n \n \n "]);return w=function(){return a},a}function x(){const a=sa(["\n \n \n "]);return x=function(){return a},a}function y(){const a=sa(["\n \n \n "]);return y=function(){return a},a}function z(){const a=sa(["\n \n \n "]);return z=function(){return a},a}function A(){const a=sa(["\n "]);return A=function(){return a},a}function B(){const a=sa(["\n \n ","\n \n \n
"]);return B=function(){return a},a}function C(){const a=sa([""]);return C=function(){return a},a}function D(){const a=sa(["\n \n "]);return D=function(){return a},a}function E(){const a=sa([""]);return E=function(){return a},a}function F(){const a=sa(["\n \n "]);return F=function(){return a},a}function G(){const a=sa([""]);return G=function(){return a},a}function H(){const a=sa(["\n ","\n ","\n ","\n "]);return H=function(){return a},a}function I(){const a=sa(["\n :host {\n max-width: 120px;\n min-width: 40px;\n }\n :host([full]) {\n max-width: none;\n }\n "]);return I=function(){return a},a}function J(){const a=sa(["\n \n "]);return J=function(){return a},a}function K(){const a=sa(["\n :host {\n max-width: 120px;\n min-width: 40px;\n }\n :host([full]) {\n max-width: none;\n }\n "]);return K=function(){return a},a}function L(){const a=sa(["\n \n "]);return L=function(){return a},a}function M(){const a=sa(["\n .mmp-progress {\n cursor: pointer;\n left: 0; right: 0; bottom: 0;\n position: absolute;\n pointer-events: auto;\n min-height: 10px;\n }\n .mmp-progress__duration {\n display: flex;\n justify-content: space-between;\n font-size: .8em;\n margin: 8px calc(var(--ha-card-border-radius, 4px) / 2);\n margin-top: 0;\n padding: 0 6px;\n }\n paper-progress {\n height: var(--paper-progress-height, 4px);\n bottom: 0;\n position: absolute;\n width: 100%;\n --paper-progress-active-color: var(--mmp-accent-color);\n --paper-progress-container-color: rgba(100,100,100,.15);\n --paper-progress-transition-duration: 1s;\n --paper-progress-transition-timing-function: linear;\n --paper-progress-transition-delay: 0s;\n }\n .mmp-progress[paused] paper-progress {\n --paper-progress-active-color: var(--disabled-text-color, rgba(150,150,150,.5));\n }\n "]);return M=function(){return a},a}function N(){const a=sa([""]);return N=function(){return a},a}function O(){const a=sa(["\n \n ","\n ","\n
\n "]);return O=function(){return a},a}function P(){const a=sa(["\n \n "]);return P=function(){return a},a}function Q(){const a=sa(["\n :host {\n align-items: center;\n margin-left: 8px;\n display: flex;\n }\n .mmp-tts__input {\n cursor: text;\n flex: 1;\n margin-right: 8px;\n --paper-input-container-input: {\n font-size: 1em;\n };\n }\n ha-card[rtl] .mmp-tts__input {\n margin-right: auto;\n margin-left: 8px;\n }\n .mmp-tts__button {\n margin: 0;\n height: 30px;\n padding: 0 .4em;\n }\n paper-input {\n opacity: .75;\n --paper-input-container-color: var(--mmp-text-color);\n --paper-input-container-focus-color: var(--mmp-text-color);\n --paper-input-container: {\n padding: 0;\n };\n }\n paper-input[focused] {\n opacity: 1;\n }\n\n ha-card[artwork*='cover'][has-artwork] paper-input {\n --paper-input-container-focus-color: #FFFFFF;\n }\n ha-card[artwork*='cover'][has-artwork] paper-input {\n --paper-input-container-color: #FFFFFF;\n --paper-input-container-input-color: #FFFFFF;\n }\n "]);return Q=function(){return a},a}function R(){const a=sa(["\n \n \n \n SEND\n \n "]);return R=function(){return a},a}function S(){const a=sa(["\n .mmp-shortcuts__buttons {\n box-sizing: border-box;\n display: flex;\n flex-wrap: wrap;\n margin-top: 8px;\n }\n .mmp-shortcuts__button {\n min-width: calc(50% - 8px);\n flex: 1;\n }\n .mmp-shortcuts__button > div {\n display: flex;\n justify-content: center;\n align-items: center;\n width: 100%;\n }\n .mmp-shortcuts__button > div[align='left'] {\n justify-content: flex-start;\n }\n .mmp-shortcuts__button > div[align='right'] {\n justify-content: flex-end;\n }\n .mmp-shortcuts__button[columns='1'] {\n min-width: calc(100% - 8px);\n }\n .mmp-shortcuts__button[columns='3'] {\n min-width: calc(33.33% - 8px);\n }\n .mmp-shortcuts__button[columns='4'] {\n min-width: calc(25% - 8px);\n }\n .mmp-shortcuts__button[columns='5'] {\n min-width: calc(20% - 8px);\n }\n .mmp-shortcuts__button > div > span {\n line-height: 24px;\n text-transform: initial;\n }\n .mmp-shortcuts__button > div > *:nth-child(2) {\n margin-left: 4px;\n }\n "]);return S=function(){return a},a}function T(){const a=sa(["\n ","\n ","\n "]);return T=function(){return a},a}function U(){const a=sa(["",""]);return U=function(){return a},a}function V(){const a=sa([""]);return V=function(){return a},a}function W(){const a=sa(["\n \n \n ","\n ","\n
\n "]);return W=function(){return a},a}function X(){const a=sa(["\n \n ","\n
\n "]);return X=function(){return a},a}function Y(){const a=sa(["\n \n \n "]);return Y=function(){return a},a}function Z(){const a=sa([""]);return Z=function(){return a},a}function $(){const a=sa(["\n :host {\n display: block;\n }\n :host([faded]) {\n opacity: .75;\n }\n :host[small] .mmp-dropdown__label {\n max-width: 60px;\n display: block;\n position: relative;\n width: auto;\n text-transform: initial;\n }\n :host[full] .mmp-dropdown__label {\n max-width: none;\n }\n .mmp-dropdown {\n padding: 0;\n display: block;\n }\n .mmp-dropdown__button {\n display: flex;\n font-size: 1em;\n justify-content: space-between;\n align-items: center;\n height: 36px;\n margin: 2px 0;\n }\n .mmp-dropdown__button.icon {\n height: 40px;\n margin: 0;\n }\n .mmp-dropdown__button > div {\n display: flex;\n flex: 1;\n justify-content: space-between;\n align-items: center;\n height: 36px;\n max-width: 100%;\n }\n .mmp-dropdown__label {\n text-align: left;\n text-transform: none;\n }\n .mmp-dropdown__icon {\n height: 24px;\n width: 24px;\n min-width: 24px;\n }\n paper-item > *:nth-child(2) {\n margin-left: 4px;\n }\n paper-menu-button[focused] mmp-button iron-icon {\n color: var(--mmp-accent-color);\n transform: rotate(180deg);\n }\n paper-menu-button[focused] paper-icon-button {\n color: var(--mmp-accent-color);\n transform: rotate(180deg);\n }\n paper-menu-button[focused] paper-icon-button[focused] {\n color: var(--mmp-text-color);\n transform: rotate(0deg);\n }\n "]);return $=function(){return a},a}function _(){const a=sa(["",""]);return _=function(){return a},a}function aa(){const a=sa([""]);return aa=function(){return a},a}function ba(){const a=sa(["\n \n ","\n ","\n "]);return ba=function(){return a},a}function ca(){const a=sa(["\n \n \n \n ","\n \n \n
\n \n "]);return ca=function(){return a},a}function da(){const a=sa(["\n \n \n "]);return da=function(){return a},a}function ea(){const a=sa(["\n \n ","\n \n ","\n \n \n "]);return ea=function(){return a},a}function fa(){const a=sa(["\n .ellipsis {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n .label {\n margin: 0 8px;\n }\n paper-icon-button {\n transition: color .25s;\n }\n paper-icon-button[color] {\n color: var(--mmp-accent-color) !important;\n opacity: 1 !important;\n }\n paper-icon-button[inactive] {\n opacity: .5;\n }\n"]);return fa=function(){return a},a}function ga(){const a=sa(["\n .mmp-group-list {\n display: flex;\n flex-direction: column;\n margin-left: 8px;\n margin-bottom: 8px;\n }\n .mmp-group-list__title {\n font-weight: 500;\n letter-spacing: .1em;\n margin: 8px 0 4px;\n text-transform: uppercase;\n }\n .mmp-group-list__buttons {\n display: flex;\n }\n .mmp-group-list__button {\n margin: 8px 8px 0 0;\n min-width: 0;\n text-transform: uppercase;\n text-align: center;\n width: 50%;\n --mdc-theme-primary: transparent;\n background: rgba(255,255,255,0.25);\n }\n "]);return ga=function(){return a},a}function ha(){const a=sa([""]);return ha=function(){return a},a}function ia(){const a=sa(["Leave"]);return ia=function(){return a},a}function ja(){const a=sa(["Ungroup"]);return ja=function(){return a},a}function ka(){const a=sa(["\n "]);return ka=function(){return a},a}function la(){const a=sa(["\n \n
Group speakers\n ","\n
\n \n ","\n \n \n Group all\n \n
\n
\n "]);return la=function(){return a},a}function ma(){const a=sa(["\n :host {\n position: relative;\n box-sizing: border-box;\n margin: 4px;\n min-width: 0;\n overflow: hidden;\n transition: background .5s;\n }\n :host([raised]) {\n background: rgba(255,255,255,0.25);\n min-height: 36px;\n box-shadow:\n 0px 3px 1px -2px rgba(0, 0, 0, 0.2),\n 0px 2px 2px 0px rgba(0, 0, 0, 0.14),\n 0px 1px 5px 0px rgba(0,0,0,.12);\n }\n :host([color]) {\n background: var(--mmp-active-color);\n transition: background .25s;\n opacity: 1;\n }\n :host([faded]) {\n opacity: .75;\n }\n .container {\n height: 100%;\n width: 100%;\n }\n .slot-container {\n height: 100%;\n display: flex;\n align-items: center;\n justify-content: center;\n margin: 0 8px;\n width: auto;\n }\n paper-ripple {\n position: absolute;\n left: 0;\n right: 0;\n top: 0;\n bottom: 0;\n }\n "]);return ma=function(){return a},a}function na(){const a=sa(["\n \n "]);return na=function(){return a},a}function oa(){const a=sa(["\n paper-checkbox {\n padding: 8px 0;\n }\n paper-checkbox > span {\n font-weight: 600;\n }\n\n ha-card[artwork*='cover'][has-artwork] paper-checkbox[disabled] {\n --paper-checkbox-checkmark-color: rgba(0,0,0,.5);\n }\n ha-card[artwork*='cover'][has-artwork] paper-checkbox {\n --paper-checkbox-unchecked-color: #FFFFFF;\n --paper-checkbox-label-color: #FFFFFF;\n }\n "]);return oa=function(){return a},a}function pa(){const a=sa(["(master)"]);return pa=function(){return a},a}function qa(){const a=sa(["\n \n ","\n ","\n \n "]);return qa=function(){return a},a}function ra(){const a=sa(["\n :host {\n overflow: visible !important;\n display: block;\n --mmp-accent-color: var(--mini-media-player-accent-color, var(--accent-color, #f39c12));\n --mmp-base-color: var(--mini-media-player-base-color, var(--primary-text-color, #000));\n --mmp-overlay-color: var(--mini-media-player-overlay-color, rgba(0,0,0,0.5));\n --mmp-overlay-base-color: var(--mini-media-player-overlay-base-color, #fff);\n --mmp-overlay-accent-color: var(--mini-media-player-overlay-accent-color, --mmp-accent-color);\n --mmp-text-color: var(--mini-media-player-base-color, --primary-text-color);\n --mmp-media-cover-info-color: var(--mini-media-player-media-cover-info-color, --mmp-text-color);\n --mmp-text-color-inverted: var(--disabled-text-color);\n --mmp-active-color: var(--mmp-accent-color);\n --mmp-icon-color: var(--mini-media-player-icon-color, var(--mini-media-player-base-color, var(--paper-item-icon-color, #44739e)));\n --mmp-info-opacity: 1;\n --mmp-artwork-opacity: var(--mini-media-player-artwork-opacity, 1);\n --mdc-theme-primary: var(--mmp-text-color);\n --mdc-theme-on-primary: var(--mmp-text-color);\n --paper-checkbox-unchecked-color: var(--mmp-text-color);\n --paper-checkbox-label-color: var(--mmp-text-color);\n color: var(--mmp-text-color);\n }\n ha-card.--bg {\n --mmp-info-opacity: .75;\n }\n ha-card.--has-artwork[artwork*='cover'] {\n --mmp-accent-color: var(--mini-media-player-overlay-accent-color, var(--mini-media-player-accent-color, var(--accent-color, #f39c12)));\n --mmp-text-color: var(--mmp-overlay-base-color);\n --mmp-text-color-inverted: #000;\n --mmp-active-color: rgba(255,255,255,.5);\n --mmp-icon-color: var(--mmp-text-color);\n --mmp-info-opacity: .75;\n --paper-slider-container-color: var(--mini-media-player-overlay-color, rgba(255,255,255,.75));\n --mdc-theme-primary: var(--mmp-text-color);\n --mdc-theme-on-primary: var(--mmp-text-color);\n --paper-checkbox-unchecked-color: var(--mmp-text-color);\n --paper-checkbox-label-color: var(--mmp-text-color);\n color: var(--mmp-text-color);\n }\n ha-card {\n cursor: default;\n display: flex;\n background: transparent;\n overflow: hidden;\n padding: 0;\n position: relative;\n color: inherit;\n }\n ha-card.--group {\n box-shadow: none;\n }\n ha-card.--more-info {\n cursor: pointer;\n }\n ha-card.--collapse {\n overflow: visible;\n }\n .mmp__bg, .mmp__player, .mmp__container {\n border-radius: var(--ha-card-border-radius, 0);\n -webkit-transform: translateZ(0);\n transform: translateZ(0);\n }\n .mmp__container {\n overflow: hidden;\n height: 100%;\n width: 100%;\n position: absolute;\n pointer-events: none;\n }\n ha-card:before {\n content: '';\n padding-top: 0px;\n transition: padding-top .5s cubic-bezier(.21,.61,.35,1);\n will-change: padding-top;\n }\n ha-card.--initial .entity__artwork,\n ha-card.--initial .entity__icon {\n animation-duration: .001s;\n }\n ha-card.--initial:before,\n ha-card.--initial .mmp-player {\n transition: none;\n }\n header {\n display: none;\n }\n ha-card[artwork='full-cover'].--has-artwork:before {\n padding-top: 56%;\n }\n ha-card[artwork='full-cover'].--has-artwork[content='music']:before,\n ha-card[artwork='full-cover-fit'].--has-artwork:before {\n padding-top: 100%;\n }\n .mmp__bg {\n background: var(--ha-card-background, var(--paper-card-background-color, white));\n position: absolute;\n top: 0; right: 0; bottom: 0; left: 0;\n overflow: hidden;\n -webkit-transform: translateZ(0);\n transform: translateZ(0);\n }\n ha-card[artwork*='cover'].--has-artwork .mmp__bg {\n opacity: var(--mmp-artwork-opacity);\n background: transparent;\n }\n ha-card.--group .mmp__bg {\n background: transparent;\n }\n .cover,\n .cover:before {\n display: block;\n opacity: 0;\n position: absolute;\n top: 0; right: 0; bottom: 0; left: 0;\n transition: opacity .75s cubic-bezier(.21,.61,.35,1);\n will-change: opacity;\n }\n .cover {\n animation: fade-in .5s cubic-bezier(.21,.61,.35,1);\n background-size: cover;\n background-repeat: no-repeat;\n background-position: center center;\n }\n .cover:before {\n background: var(--mmp-overlay-color);\n content: '';\n }\n ha-card[artwork*='full-cover'].--has-artwork .mmp-player {\n background: linear-gradient(to top, var(--mmp-overlay-color) 25%, transparent 100%);\n border-bottom-left-radius: var(--ha-card-border-radius, 0);\n border-bottom-right-radius: var(--ha-card-border-radius, 0);\n }\n ha-card.--has-artwork .cover,\n ha-card.--has-artwork[artwork='cover'] .cover:before,\n ha-card.--bg .cover {\n opacity: .999;\n }\n ha-card[artwork='default'] .cover {\n display: none;\n }\n ha-card.--bg .cover {\n display: block;\n }\n ha-card[artwork='full-cover-fit'].--has-artwork .cover {\n background-color: black;\n background-size: contain;\n }\n .mmp-player {\n align-self: flex-end;\n box-sizing: border-box;\n position: relative;\n padding: 16px;\n transition: padding .25s ease-out;\n width: 100%;\n will-change: padding;\n }\n ha-card.--group .mmp-player {\n padding: 2px 0;\n }\n .flex {\n display: flex;\n display: -ms-flexbox;\n display: -webkit-flex;\n flex-direction: row;\n }\n .mmp-player__core {\n position: relative;\n }\n .entity__info {\n justify-content: center;\n display: flex;\n flex-direction: column;\n margin-left: 8px;\n position: relative;\n overflow: hidden;\n user-select: none;\n }\n ha-card.--rtl .entity__info {\n margin-left: auto;\n margin-right: 8px;\n }\n ha-card[content='movie'] .attr__media_season,\n ha-card[content='movie'] .attr__media_episode {\n display: none;\n }\n .entity__icon {\n color: var(--mmp-icon-color);\n }\n .entity__artwork, .entity__icon {\n animation: fade-in .25s ease-out;\n background-position: center center;\n background-repeat: no-repeat;\n background-size: cover;\n border-radius: 100%;\n height: 40px;\n width: 40px;\n min-width: 40px;\n line-height: 40px;\n margin-right: 8px;\n position: relative;\n text-align: center;\n will-change: border-color;\n transition: border-color .25s ease-out;\n }\n ha-card.--rtl .entity__artwork,\n ha-card.--rtl .entity__icon {\n margin-right: auto;\n }\n .entity__artwork[border] {\n border: 2px solid var(--primary-text-color);\n box-sizing: border-box;\n -moz-box-sizing: border-box;\n -webkit-box-sizing: border-box;\n }\n .entity__artwork[border][state='playing'] {\n border-color: var(--mmp-accent-color);\n }\n .entity__info__name,\n .entity__info__media[short] {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n .entity__info__name {\n line-height: 20px;\n color: var(--mmp-text-color);\n }\n .entity__info__media {\n color: var(--secondary-text-color);\n max-height: 6em;\n word-break: break-word;\n opacity: var(--mmp-info-opacity);\n transition: color .5s;\n }\n .entity__info__media[short] {\n max-height: 20px;\n overflow: hidden;\n }\n .attr__app_name {\n display: none;\n }\n .attr__app_name:first-child,\n .attr__app_name:first-of-type {\n display: inline;\n }\n .mmp-player__core[inactive] .entity__info__media {\n color: var(--mmp-text-color);\n max-width: 200px;\n opacity: .5;\n }\n .entity__info__media[short-scroll] {\n max-height: 20px;\n white-space: nowrap;\n }\n .entity__info__media[scroll] > span {\n visibility: hidden;\n }\n .entity__info__media[scroll] > div {\n animation: move linear infinite;\n }\n .entity__info__media[scroll] .marquee {\n animation: slide linear infinite;\n }\n .entity__info__media[scroll] .marquee,\n .entity__info__media[scroll] > div {\n animation-duration: inherit;\n visibility: visible;\n }\n .entity__info__media[scroll] {\n animation-duration: 10s;\n mask-image: linear-gradient(to right, transparent 0%, black 5%, black 95%, transparent 100%);\n -webkit-mask-image: linear-gradient(to right, transparent 0%, black 5%, black 95%, transparent 100%);\n }\n .marquee {\n visibility: hidden;\n position: absolute;\n white-space: nowrap;\n }\n ha-card[artwork*='cover'].--has-artwork .entity__info__media,\n ha-card.--bg .entity__info__media {\n color: var(--mmp-media-cover-info-color);\n }\n .entity__info__media span:before {\n content: ' - ';\n }\n .entity__info__media span:first-of-type:before {\n content: '';\n }\n .entity__info__media span:empty {\n display: none;\n }\n .mmp-player__adds {\n margin-left: 48px;\n position: relative;\n }\n ha-card.--rtl .mmp-player__adds {\n margin-left: auto;\n margin-right: 48px;\n }\n .mmp-player__adds > *:nth-child(2) {\n margin-top: 0px;\n }\n mmp-powerstrip {\n flex: 1;\n justify-content: flex-end;\n margin-right: 0;\n margin-left: auto;\n width: auto;\n max-width: 100%;\n }\n mmp-media-controls {\n flex-wrap: wrap;\n justify-content: center;\n }\n ha-card.--flow mmp-powerstrip {\n justify-content: space-between;\n margin-left: auto;\n }\n ha-card.--flow.--rtl mmp-powerstrip {\n margin-right: auto;\n }\n ha-card.--flow .entity__info {\n display: none;\n }\n ha-card.--responsive .mmp-player__adds {\n margin-left: 0;\n }\n ha-card.--responsive.--rtl .mmp-player__adds {\n margin-right: 0;\n }\n ha-card.--responsive .mmp-player__adds > mmp-media-controls {\n padding: 0;\n }\n ha-card.--runtime .mmp-player {\n padding-bottom: calc(16px + 8px);\n }\n ha-card.--runtime.--group .mmp-player {\n padding-bottom: calc(16px + 8px);\n }\n .mmp-player div:empty {\n display: none;\n }\n @keyframes slide {\n 100% { transform: translateX(-100%); }\n }\n @keyframes move {\n from { transform: translateX(100%); }\n to { transform: translateX(0); }\n }\n @keyframes fade-in {\n from { opacity: 0; }\n to { opacity: 1; }\n }\n"]);return ra=function(){return a},a}function sa(a,b){return b||(b=a.slice(0)),Object.freeze(Object.defineProperties(a,{raw:{value:Object.freeze(b)}}))}function ta(a,b){return wa(a)||va(a,b)||ua()}function ua(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}function va(a,b){var c=[],d=!0,e=!1,f=void 0;try{for(var g,h=a[Symbol.iterator]();!(d=(g=h.next()).done)&&(c.push(g.value),!(b&&c.length===b));d=!0);}catch(a){e=!0,f=a}finally{try{d||null==h["return"]||h["return"]()}finally{if(e)throw f}}return c}function wa(a){if(Array.isArray(a))return a}function xa(a){for(var b=1;ba.parentNode.removeChild(a))}function va(a,b){let c=2"function"==typeof a&&Ja.has(a),La=window.customElements!==void 0&&window.customElements.polyfillWrapFlushCallback!==void 0,Ma=function(a,b){for(let c=2"),Ra=new RegExp("".concat(Pa,"|").concat(Qa)),Sa="$lit$";class Ta{constructor(a,b){this.parts=[],this.element=b;const c=[],d=[],e=document.createTreeWalker(b.content,133,null,!1);let f=0,g=-1,h=0;for(const i=a.strings,j=a.values.length;h{const c=a.length-b.length;return 0<=c&&a.slice(c)===b},Va=a=>-1!==a.index,Wa=()=>document.createComment(""),Xa=/([ \x09\x0a\x0c\x0d])([^\0-\x1F\x7F-\x9F "'>=/]+)([ \x09\x0a\x0c\x0d]*=[ \x09\x0a\x0c\x0d]*(?:[^ \x09\x0a\x0c\x0d"'`<>=]*|"[^"]*|'[^']*))$/;class Ya{constructor(a,b,c){this.__parts=[],this.template=a,this.processor=b,this.options=c}update(a){let b=0;for(const c of this.__parts)void 0!==c&&c.setValue(a[b]),b++;for(const b of this.__parts)void 0!==b&&b.commit()}_clone(){const a=La?this.template.element.content.cloneNode(!0):document.importNode(this.template.element.content,!0),b=[],c=this.template.parts,d=document.createTreeWalker(a,133,null,!1);let e,f=0,g=0,h=d.nextNode();for(;f",e+1);const f=Xa.exec(a);b+=null===f?a+(c?Pa:Qa):a.substr(0,f.index)+f[1]+f[2]+Sa+f[3]+Pa}return b+=this.strings[a],b}getTemplateElement(){const a=document.createElement("template");return a.innerHTML=this.getHTML(),a}}const $a=a=>null===a||"object"!=typeof a&&"function"!=typeof a,_a=a=>Array.isArray(a)||!!(a&&a[Symbol.iterator]);class ab{constructor(a,b,c){this.dirty=!0,this.element=a,this.name=b,this.strings=c,this.parts=[];for(let d=0;dthis.handleEvent(a)}setValue(a){this.__pendingValue=a}commit(){for(;Ka(this.__pendingValue);){const a=this.__pendingValue;this.__pendingValue=Na,a(this)}if(this.__pendingValue===Na)return;const a=this.__pendingValue,b=this.value,c=null==a||null!=b&&(a.capture!==b.capture||a.once!==b.once||a.passive!==b.passive);c&&this.element.removeEventListener(this.eventName,this.__boundHandleEvent,this.__options),null!=a&&(null==b||c)&&(this.__options=ib(a),this.element.addEventListener(this.eventName,this.__boundHandleEvent,this.__options)),this.value=a,this.__pendingValue=Na}handleEvent(a){"function"==typeof this.value?this.value.call(this.eventContext||this.element,a):this.value.handleEvent(a)}}const ib=a=>a&&(gb?{capture:a.capture,passive:a.passive,once:a.once}:a.capture);const jb=new class{handleAttributeExpressions(a,b,c,d){const e=b[0];if("."===e){const d=new eb(a,b.slice(1),c);return d.parts}if("@"===e)return[new hb(a,b.slice(1),d.eventContext)];if("?"===e)return[new db(a,b.slice(1),c)];const f=new ab(a,b,c);return f.parts}handleTextExpression(a){return new cb(a)}},kb=new Map,lb=new WeakMap,mb=(a,b,c)=>{let d=lb.get(b);d===void 0&&(Ma(b,b.firstChild),lb.set(b,d=new cb(Object.assign({templateFactory:sa},c))),d.appendInto(b)),d.setValue(a),d.commit()};(window.litHtmlVersions||(window.litHtmlVersions=[])).push("1.0.0");const nb=function(a){for(var b=arguments.length,c=Array(1{let b=11===a.nodeType?0:1;for(const c=document.createTreeWalker(a,ob,null,!1);c.nextNode();)b++;return b},qb=function(a){let b=1"".concat(a,"--").concat(b);let sb=!0;"undefined"==typeof window.ShadyCSS?sb=!1:"undefined"==typeof 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."),sb=!1);const tb=a=>b=>{const c=rb(b.type,a);let d=kb.get(c);void 0===d&&(d={stringsArray:new WeakMap,keyString:new Map},kb.set(c,d));let e=d.stringsArray.get(b.strings);if(void 0!==e)return e;const f=b.strings.join(Pa);if(e=d.keyString.get(f),void 0===e){const c=b.getTemplateElement();sb&&window.ShadyCSS.prepareTemplateDom(c,a),e=new Ta(b,c),d.keyString.set(f,e)}return d.stringsArray.set(b.strings,e),e},ub=["html","svg"],vb=a=>{ub.forEach(b=>{const c=kb.get(rb(b,a));c!==void 0&&c.keyString.forEach(a=>{const b=a.element.content,c=new Set;Array.from(b.querySelectorAll("style")).forEach(a=>{c.add(a)}),ua(a,c)})})},wb=new Set,xb=(a,b,c)=>{wb.add(c);const d=a.querySelectorAll("style"),e=d.length;if(0===e)return void window.ShadyCSS.prepareTemplateStyles(b.element,c);const f=document.createElement("style");for(let g=0;g{const d=c.scopeName,e=lb.has(b),f=sb&&11===b.nodeType&&!!b.host&&a instanceof Za,g=f&&!wb.has(d),h=g?document.createDocumentFragment():b;if(mb(a,h,Object.assign({templateFactory:tb(d)},c)),g){const a=lb.get(h);lb.delete(h),a.value instanceof Ya&&xb(h,a.value.template,d),Ma(b,b.firstChild),b.appendChild(h),lb.set(b,a)}!e&&f&&window.ShadyCSS.styleElement(b.host)};window.JSCompiler_renameProperty=a=>a;const zb={toAttribute(a,b){return b===Boolean?a?"":null:b===Object||b===Array?null==a?a:JSON.stringify(a):a},fromAttribute(a,b){return b===Boolean?null!==a:b===Number?null===a?null:+a:b===Object||b===Array?JSON.parse(a):a}},Ab=(a,b)=>b!==a&&(b===b||a===a),Bb={attribute:!0,type:String,converter:zb,reflect:!1,hasChanged:Ab},Cb=Promise.resolve(!0),Db=1,Eb=4,Fb=8,Gb=16,Hb=32;class Ib extends HTMLElement{constructor(){super(),this._updateState=0,this._instanceProperties=void 0,this._updatePromise=Cb,this._hasConnectedResolver=void 0,this._changedProperties=new Map,this._reflectingProperties=void 0,this.initialize()}static get observedAttributes(){this.finalize();const a=[];return this._classProperties.forEach((b,c)=>{const d=this._attributeNameForProperty(c,b);void 0!==d&&(this._attributeToPropertyMap.set(d,c),a.push(d))}),a}static _ensureClassProperties(){if(!this.hasOwnProperty(JSCompiler_renameProperty("_classProperties",this))){this._classProperties=new Map;const a=Object.getPrototypeOf(this)._classProperties;a!==void 0&&a.forEach((a,b)=>this._classProperties.set(b,a))}}static createProperty(a){let b=1{if(this.hasOwnProperty(b)){const a=this[b];delete this[b],this._instanceProperties||(this._instanceProperties=new Map),this._instanceProperties.set(b,a)}})}_applyInstanceProperties(){this._instanceProperties.forEach((a,b)=>this[b]=a),this._instanceProperties=void 0}connectedCallback(){this._updateState|=Hb,this._hasConnectedResolver&&(this._hasConnectedResolver(),this._hasConnectedResolver=void 0)}disconnectedCallback(){}attributeChangedCallback(a,b,c){b!==c&&this._attributeToProperty(a,c)}_propertyToAttribute(a,b){let c=2{b=a,c=d});try{yield d}catch(a){}a._hasConnected||(yield new Promise(b=>a._hasConnectedResolver=b));try{const b=a.performUpdate();null!=b&&(yield b)}catch(a){c(a)}b(!a._hasRequestedUpdate)})()}get _hasConnected(){return this._updateState&Hb}get _hasRequestedUpdate(){return this._updateState&Eb}get hasUpdated(){return this._updateState&Db}performUpdate(){this._instanceProperties&&this._applyInstanceProperties();let a=!1;const b=this._changedProperties;try{a=this.shouldUpdate(b),a&&this.update(b)}catch(b){throw a=!1,b}finally{this._markUpdated()}a&&(!(this._updateState&Db)&&(this._updateState|=Db,this.firstUpdated(b)),this.updated(b))}_markUpdated(){this._changedProperties=new Map,this._updateState&=~Eb}get updateComplete(){return this._updatePromise}shouldUpdate(a){return!0}update(a){this._reflectingProperties!==void 0&&0this._propertyToAttribute(b,this[b],a)),this._reflectingProperties=void 0)}updated(a){}firstUpdated(a){}}Ib.finalized=!0;const Jb="adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Kb=Symbol();class Lb{constructor(a,b){if(b!==Kb)throw new Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=a}get styleSheet(){return void 0===this._styleSheet&&(Jb?(this._styleSheet=new CSSStyleSheet,this._styleSheet.replaceSync(this.cssText)):this._styleSheet=null),this._styleSheet}toString(){return this.cssText}}const Mb=a=>{if(a instanceof Lb)return a.cssText;if("number"==typeof a)return a;throw new Error("Value passed to 'css' function must be a 'css' function result: ".concat(a,". Use 'unsafeCSS' to pass non-literal values, but\n take care to ensure page security."))},Nb=function(a){for(var b=arguments.length,c=Array(1b+Mb(c)+a[d+1],a[0]);return new Lb(e,Kb)};(window.litElementVersions||(window.litElementVersions=[])).push("2.2.0");const Ob=a=>a.flat?a.flat(1/0):wa(a);class Pb extends Ib{static finalize(){super.finalize(),this._styles=this.hasOwnProperty(JSCompiler_renameProperty("styles",this))?this._getUniqueStyles():this._styles||[]}static _getUniqueStyles(){const a=this.styles,b=[];if(Array.isArray(a)){const c=Ob(a),d=c.reduceRight((a,b)=>(a.add(b),a),new Set);d.forEach(a=>b.unshift(a))}else a&&b.push(a);return b}initialize(){super.initialize(),this.renderRoot=this.createRenderRoot(),window.ShadowRoot&&this.renderRoot instanceof window.ShadowRoot&&this.adoptStyles()}createRenderRoot(){return this.attachShadow({mode:"open"})}adoptStyles(){const a=this.constructor._styles;0===a.length||(window.ShadyCSS===void 0||window.ShadyCSS.nativeShadow?Jb?this.renderRoot.adoptedStyleSheets=a.map(a=>a.styleSheet):this._needsShimAdoptedStyleSheets=!0:window.ShadyCSS.ScopingShim.prepareAdoptedCssText(a.map(a=>a.cssText),this.localName))}connectedCallback(){super.connectedCallback(),this.hasUpdated&&window.ShadyCSS!==void 0&&window.ShadyCSS.styleElement(this)}update(a){super.update(a);const b=this.render();b instanceof Za&&this.constructor.render(b,this.renderRoot,{scopeName:this.localName,eventContext:this}),this._needsShimAdoptedStyleSheets&&(this._needsShimAdoptedStyleSheets=!1,this.constructor._styles.forEach(a=>{const b=document.createElement("style");b.textContent=a.cssText,this.renderRoot.appendChild(b)}))}render(){}}Pb.finalized=!0,Pb.render=yb;const Qb=new WeakMap,Rb=(a=>function(){const b=a(...arguments);return Ja.set(b,!0),b})(a=>b=>{if(!(b instanceof bb)||b instanceof fb||"class"!==b.committer.name||1xa({text:this.attr[a.attr],prefix:""},a)).filter(a=>a.text)}get hasProgress(){return!this.config.hide.progress&&!this.idle&&kc.every(a=>a in this.attr)}get progress(){return this.position+(Date.now()-new Date(this.updatedAt).getTime())/1e3}get idleView(){const a=this.config.idle_view;return!!(a.when_idle&&this.isIdle||a.when_standby&&this.isStandby||a.when_paused&&this.isPaused)||!!(this.updatedAt&&a.after&&!this.isPlaying)&&this.checkIdleAfter(a.after)}get trackIdle(){return this.active&&!this.isPlaying&&this.updatedAt&&this.config.idle_view&&this.config.idle_view.after}checkIdleAfter(a){const b=(Date.now()-new Date(this.updatedAt).getTime())/1e3;return this.idle=b>60*a,this.active=this.isActive,this.idle}get supportsShuffle(){return"undefined"!=typeof this.attr.shuffle}get supportsMute(){return"undefined"!=typeof this.attr.is_volume_muted}getAttribute(a){return this.attr[a]||""}fetchThumbnail(){var a=this;return Aa(function*(){try{const b=yield a.hass.callWS({type:"media_player_thumbnail",entity_id:a.config.entity}),c=b.content_type,d=b.content;return"url(data:".concat(c,";base64,").concat(d,")")}catch(a){return console.error("mini-media-player: Failed fetching thumbnail"),!1}})()}toggle(a){return this.config.toggle_power?this.callService(a,"toggle"):this.isOff?this.callService(a,"turn_on"):void this.callService(a,"turn_off")}toggleMute(a){this.callService(a,"volume_mute",{is_volume_muted:!this.muted})}toggleShuffle(a){this.callService(a,"shuffle_set",{shuffle:!this.shuffle})}setSource(a,b){this.callService(a,"select_source",{source:b})}setMedia(a,b){this.callService(a,"play_media",xa({},b))}playPause(a){this.callService(a,"media_play_pause")}setSoundMode(a,b){this.callService(a,"select_sound_mode",{sound_mode:b})}next(a){this.callService(a,"media_next_track")}prev(a){this.callService(a,"media_previous_track")}stop(a){this.callService(a,"media_stop")}volumeUp(a){this.callService(a,"volume_up")}volumeDown(a){this.callService(a,"volume_down")}seek(a,b){this.callService(a,"media_seek",{seek_position:b})}setVolume(a,b){this.config.speaker_group.sync_volume?this.group.forEach(c=>{const d=this.config.speaker_group.entities.find(a=>a.entity_id===c)||{};let e=b;d.volume_offset&&(e+=d.volume_offset/100,1e&&(e=0)),this.callService(a,"volume_set",{entity_id:c,volume_level:e})}):this.callService(a,"volume_set",{entity_id:this.config.entity,volume_level:b})}handleGroupChange(a,b,c){const d=this.config.speaker_group.platform,e={entity_id:b};if(c){if(e.master=this.config.entity,"bluesound"===d)return this.callService(a,"".concat(d,"_JOIN"),e);this.callService(a,"join",e,d)}else{if("bluesound"===d)return this.callService(a,"".concat(d,"_UNJOIN"),e);this.callService(a,"unjoin",e,d)}}toggleScript(a,b){let c=2a.stopPropagation(),this.handleClick,this.item.name,this.master?nb(pa()):"")}handleClick(a){a.stopPropagation(),this.dispatchEvent(new CustomEvent("change",{detail:{entity:this.item.entity_id,checked:!this.checked}}))}static get styles(){return Nb(oa())}}customElements.define("mmp-group-item",oc);class pc extends Pb{render(){return nb(na())}static get styles(){return Nb(ma())}}customElements.define("mmp-button",pc);class qc extends Pb{static get properties(){return{entities:{},player:{},visible:Boolean}}get group(){return this.player.group}get master(){return this.player.master}get isMaster(){return this.player.isMaster}handleGroupChange(a){const b=a.detail,c=b.entity,d=b.checked;this.player.handleGroupChange(a,c,d)}render(){let a=0nb(ka(),this.handleGroupChange,a,a.entity_id===this.player.id||b.includes(a.entity_id),a.entity_id===this.player.id||c!==this.player.id,a.entity_id===c)),2>b.length,a=>this.player.handleGroupChange(a,d?b:this.player.entity_id,!1),d?nb(ja()):nb(ia()),!d,a=>this.player.handleGroupChange(a,this.entities.map(a=>a.entity_id),!0)):nb(ha())}static get styles(){return Nb(ga())}}customElements.define("mmp-group-list",qc);const rc=Nb(fa());class sc extends Pb{static get properties(){return{items:[],label:String,selected:String}}get selectedId(){return this.items.map(a=>a.id).indexOf(this.selected)}onChange(a){this.dispatchEvent(new CustomEvent("change",{detail:a}))}render(){return nb(ea(),"right","top",44,a=>a.stopPropagation(),this.icon?nb(da(),ic.DROPDOWN):nb(ca(),this.selected||this.label,ic.DROPDOWN),this.selectedId,this.items.map(a=>nb(ba(),a.id||a.name,()=>this.onChange(a),a.icon?nb(aa(),a.icon):"",a.name?nb(_(),a.name):"")))}static get styles(){return[rc,Nb($())]}}customElements.define("mmp-dropdown",sc);class tc extends Pb{static get properties(){return{player:{},shortcuts:{}}}get buttons(){return this.shortcuts.buttons}get list(){return this.shortcuts.list}get show(){return!this.shortcuts.hide_when_off||this.player.active}get active(){return this.player.getAttribute(this.shortcuts.attribute)}get height(){return this.shortcuts.column_height||36}render(){if(!this.show)return nb(Z());const a=this.active,b=this.list?nb(Y(),this.handleShortcut,this.list,this.shortcuts.label,a):"",c=this.buttons?nb(X(),this.buttons.map(b=>nb(W(),"min-height: ".concat(this.height,"px;"),this.shortcuts.columns,b.id===a,a=>this.handleShortcut(a,b),this.shortcuts.align_text,b.icon?nb(V(),b.icon):"",b.name?nb(U(),b.name):""))):"";return nb(T(),c,b)}handleShortcut(a,b){const c=b||a.detail,d=c.type,e=c.id,f=c.data;if("source"===d)return this.player.setSource(a,e);if("service"===d)return this.player.toggleService(a,e,f);if("script"===d)return this.player.toggleScript(a,e,f);if("sound_mode"===d)return this.player.setSoundMode(a,e);this.player.setMedia(a,{media_content_type:d,media_content_id:e})}static get styles(){return[rc,Nb(S())]}}customElements.define("mmp-shortcuts",tc);const uc=function(a,b){let c=2a.stopPropagation(),this.handleTts)}handleTts(a){const b=this.config,c=this.message,d={message:c,entity_id:b.entity_id||this.entity};b.language&&(d.language=b.language),"alexa"===b.platform?this.hass.callService("notify","alexa_media",{message:c,data:{type:b.type||"tts"},target:d.entity_id}):"sonos"===b.platform?this.hass.callService("script","sonos_say",{sonos_entity:d.entity_id,volume:b.volume||.5,message:c}):"webos"===b.platform?this.hass.callService("notify",d.entity_id.split(".").slice(-1)[0],{message:c}):"ga"===b.platform?this.hass.callService("notify","ga_broadcast",{message:c}):this.hass.callService("tts","".concat(b.platform,"_say"),d),a.stopPropagation(),this.reset()}reset(){this.input.value=""}static get styles(){return Nb(Q())}}customElements.define("mmp-tts",vc);var wc=a=>{let b=parseInt(a%60,10),c=parseInt(a/60%60,10),d=parseInt(a/3600%24,10);return d=10>d?"0".concat(d):d,c=10>c?"0".concat(c):c,b=10>b?"0".concat(b):b,"".concat("00"===d?"":"".concat(d,":")).concat(c,":").concat(b)};class xc extends Pb{static get properties(){return{_player:{},showTime:Boolean,progress:Number,duration:Number,tracker:{},track:Boolean}}set player(a){this._player=a,this.hasProgress&&this.trackProgress()}get duration(){return this.player.mediaDuration}get player(){return this._player}get hasProgress(){return this.player.hasProgress}render(){return this.player.active&&this.hasProgress?nb(P(),this.handleSeek,!this.player.isPlaying,this.showTime?nb(O(),wc(this.progress),wc(this.duration)):"",this.progress,this.duration):nb(N())}trackProgress(){this.progress=this.player.progress,this.tracker||(this.tracker=setInterval(()=>this.trackProgress(),1e3)),this.player.isPlaying||(clearInterval(this.tracker),this.tracker=null)}handleSeek(a){const b=this.duration,c=a.offsetX/a.target.offsetWidth*b;this.player.seek(a,c)}disconnectedCallback(){clearInterval(this.tracker)}static get styles(){return Nb(M())}}customElements.define("mmp-progress",xc);class yc extends Pb{static get properties(){return{player:{},selected:String,icon:Boolean}}get source(){return this.player.source}get sources(){return this.player.sources.map(a=>({name:a,id:a,type:"source"}))}render(){return nb(L(),this.handleSource,this.sources,this.source,this.selected||this.source,this.icon)}handleSource(a){const b=a.detail.id;this.player.setSource(a,b),this.selected=b}static get styles(){return Nb(K())}}customElements.define("mmp-source-menu",yc);class zc extends Pb{static get properties(){return{player:{},selected:String,icon:Boolean}}get mode(){return this.player.soundMode}get modes(){return this.player.soundModes.map(a=>({name:a,id:a,type:"soundMode"}))}render(){return nb(J(),this.handleChange,this.modes,this.mode,this.selected||this.mode,this.icon)}handleChange(a){const b=a.detail.id;this.player.setSoundMode(a,b),this.selected=b}static get styles(){return Nb(I())}}customElements.define("mmp-sound-menu",zc);class Ac extends Pb{static get properties(){return{player:{},config:{},break:Boolean}}get showShuffle(){return!this.config.hide.shuffle&&this.player.supportsShuffle}get maxVol(){return this.config.max_volume||100}get minVol(){return this.config.min_volume||0}render(){const a=this.config.hide;return nb(H(),a.volume?nb(G()):this.renderVolControls(this.player.muted),this.showShuffle?nb(F(),a=>this.player.toggleShuffle(a),ic.SHUFFLE,this.player.shuffle):nb(E()),a.controls?nb(C()):nb(D(),this.config.flow||this.break,a=>this.player.prev(a),ic.PREV,a=>this.player.playPause(a),ic.PLAY[this.player.isPlaying],a=>this.player.next(a),ic.NEXT))}renderVolControls(a){return this.config.volume_stateless?this.renderVolButtons(a):this.renderVolSlider(a)}renderVolSlider(a){return nb(B(),this.renderMuteButton(a),this.handleVolumeChange,a=>a.stopPropagation(),a,this.minVol,this.maxVol,100*this.player.vol,"ltr")}renderVolButtons(a){return nb(A(),this.renderMuteButton(a),a=>this.player.volumeDown(a),ic.VOL_DOWN,a=>this.player.volumeUp(a),ic.VOL_UP)}renderMuteButton(a){if(!this.config.hide.mute)switch(this.config.replace_mute){case"play":return nb(z(),a=>this.player.playPause(a),ic.PLAY[this.player.isPlaying]);case"stop":return nb(y(),a=>this.player.stop(a),ic.STOP);case"next":return nb(x(),a=>this.player.next(a),ic.NEXT);default:return this.player.supportsMute?nb(w(),a=>this.player.toggleMute(a),ic.MUTE[a]):void 0;}}handleVolumeChange(a){const b=parseFloat(a.target.value)/100;this.player.setVolume(a,b)}static get styles(){return[rc,Nb(v())]}}customElements.define("mmp-media-controls",Ac);class Bc extends Pb{static get properties(){return{hass:{},player:{},config:{},groupVisible:Boolean,idle:Boolean}}get icon(){return this.config.speaker_group.icon||ic.GROUP}get showGroupButton(){return this.config.speaker_group.entities}get showPowerButton(){return!this.config.hide.power}get powerColor(){return this.player.active&&!this.config.hide.power_state}get sourceSize(){return"icon"===this.config.source||this.hasControls||this.idle}get soundSize(){return"icon"===this.config.sound_mode||this.hasControls||this.idle}get hasControls(){return this.player.active&&this.config.hide.controls!==this.config.hide.volume}get hasSource(){return 0this.player.toggle(a),this.powerColor):"")}handleGroupClick(a){a.stopPropagation(),this.dispatchEvent(new CustomEvent("toggleGroupList"))}get renderIdleView(){return this.player.isPaused?nb(n(),ic.PLAY[this.player.isPlaying],a=>this.player.playPause(a)):nb(m(),uc(this.hass,"state.media_player.idle","Idle"))}static get styles(){return[rc,Nb(l())]}}customElements.define("mmp-powerstrip",Bc),customElements.get("ha-slider")||customElements.define("ha-slider",class extends customElements.get("paper-slider"){});class Cc extends Pb{constructor(){super(),this._overflow=!1,this.initial=!0,this.picture=!1,this.thumbnail=!1,this.edit=!1,this.rtl=!1}static get properties(){return{_hass:{},config:{},entity:{},player:{},_overflow:Boolean,break:Boolean,initial:Boolean,picture:String,thumbnail:String,edit:Boolean,rtl:Boolean,idle:Boolean}}static get styles(){return nc}set hass(a){if(a){const b=a.states[this.config.entity];this._hass=a,b&&this.entity!==b&&(this.entity=b,this.player=new mc(a,this.config,b),this.rtl=this.computeRTL(a),this.idle=this.player.idle,this.player.trackIdle&&this.updateIdleStatus())}}get hass(){return this._hass}set overflow(a){this._overflow!==a&&(this._overflow=a)}get overflow(){return this._overflow}get name(){return this.config.name||this.player.name}setConfig(a){if(!a.entity||"media_player"!==a.entity.split(".")[0])throw new Error("Specify an entity from within the media_player domain.");const b=xa({artwork:"default",info:"default",more_info:!0,source:"default",sound_mode:"default",toggle_power:!0},a,{hide:xa({},hc,a.hide),speaker_group:xa({show_group_count:!0,platform:"sonos"},a.sonos,a.speaker_group),shortcuts:xa({label:"Shortcuts..."},a.shortcuts)});b.max_volume=+b.max_volume||100,b.min_volume=+b.min_volume||0,b.collapse=b.hide.controls||b.hide.volume,b.info=b.collapse&&"scroll"!==b.info?"short":b.info,b.flow=b.hide.icon&&b.hide.name&&b.hide.info,this.config=b}shouldUpdate(a){return void 0===this.break&&this.computeRect(this),jc.some(b=>a.has(b))&&this.player}firstUpdated(){const a=new gc(a=>{a.forEach(a=>{window.requestAnimationFrame(()=>{"scroll"===this.config.info&&this.computeOverflow(),this._resizeTimer||(this.computeRect(a),this._resizeTimer=setTimeout(()=>{this._resizeTimer=null,this.computeRect(this._resizeEntry)},250)),this._resizeEntry=a})})});a.observe(this),setTimeout(()=>this.initial=!1,250),this.edit=this.config.speaker_group.expanded||!1}updated(){"scroll"===this.config.info&&setTimeout(()=>{this.computeOverflow()},10)}render(){let a=0nb(b(),"attr__".concat(a.attr),a.prefix+a.text))):"",e.map(b=>nb(a(),"attr__".concat(b.attr),b.prefix+b.text)))}}speakerCount(){if(this.config.speaker_group.show_group_count){const a=this.player.groupCount;return 1{this.thumbnail=a}),this.picture=b),!!(c&&this.thumbnail)}computeIcon(){return this.config.icon?this.config.icon:this.player.icon||ic.DEFAULT}computeOverflow(){const a=this.shadowRoot.querySelector(".marquee");if(a){const b=a.clientWidth>a.parentNode.clientWidth;this.overflow=!!(b&&this.player.active)&&7.5+a.clientWidth/50}}computeRect(a){const b=a.contentRect||a.getBoundingClientRect(),c=b.left,d=b.width;this.break=d+2*c<390}computeRTL(a){const b=a.language||"en";return!!a.translationMetadata.translations[b]&&(a.translationMetadata.translations[b].isRTL||!1)}toggleGroupList(){this.edit=!this.edit}handleMoreInfo(a){a.stopPropagation(),this.config.more_info&&this.fire("hass-more-info",{entityId:this.config.entity})}fire(a,b,c){const d=c||{},f=null===b||void 0===b?{}:b,g=new Event(a,{bubbles:void 0===d.bubbles||d.bubbles,cancelable:!!d.cancelable,composed:void 0===d.composed||d.composed});return g.detail=f,this.dispatchEvent(g),g}updateIdleStatus(){this._idleTracker&&clearTimeout(this._idleTracker);const a=(Date.now()-new Date(this.player.updatedAt).getTime())/1e3;this._idleTracker=setTimeout(()=>{this.idle=this.player.checkIdleAfter(this.config.idle_view.after),this.player.idle=this.idle,this._idleTracker=null},1e3*(60*this.config.idle_view.after-a))}getCardSize(){return this.config.collapse?1:2}}customElements.define("mini-media-player",Cc)})})();
diff --git a/www/community/mini-media-player/mini-media-player.js.gz b/www/community/mini-media-player/mini-media-player.js.gz
index 4994012..45ecf2f 100644
Binary files a/www/community/mini-media-player/mini-media-player.js.gz and b/www/community/mini-media-player/mini-media-player.js.gz differ
diff --git a/www/community/monster-card/monster-card.js b/www/community/monster-card/monster-card.js
deleted file mode 100644
index 3964b09..0000000
--- a/www/community/monster-card/monster-card.js
+++ /dev/null
@@ -1,122 +0,0 @@
-class MonsterCard extends HTMLElement {
-
- _getEntities(hass, filters) {
- function _filterEntityId(stateObj, pattern) {
- if (pattern.indexOf('*') === -1) {
- return stateObj.entity_id === pattern;
- }
- const regEx = new RegExp(`^${pattern.replace(/\*/g, '.*')}$`, 'i');
- return stateObj.entity_id.search(regEx) === 0;
- }
- function _filterName(stateObj, pattern) {
- let compareEntity = stateObj.attributes.title ? stateObj.attributes.title : stateObj.attributes.friendly_name;
- if (!compareEntity) compareEntity = stateObj.entity_id;
- if (pattern.indexOf('*') === -1) {
- return compareEntity === pattern;
- }
- const regEx = new RegExp(`^${pattern.replace(/\*/g, '.*')}$`, 'i');
- return compareEntity.search(regEx) === 0;
- }
- // Allows '< 300' in b
- function _complexCompare(a, b) {
- const _compare = {
- '>': (x, y) => x > y,
- '<': (x, y) => x < y,
- '<=': (x, y) => x <= y,
- '>=': (x, y) => x >= y,
- '=': (x, y) => x === y,
- };
- let operator = '=';
- let y = b;
- let x = a;
- if (!isNaN(a) && typeof (b) == 'string'
- && b.split(" ").length > 1) {
- [operator, y] = b.split(' ', 2);
- x = parseFloat(a);
- }
- return _compare[operator](x, y);
- }
- const entities = new Map();
- filters.forEach((filter) => {
- const filters = [];
- if (filter.domain) {
- filters.push(stateObj => stateObj.entity_id.split('.', 1)[0] === filter.domain);
- }
- if (filter.attributes) {
- Object.keys(filter.attributes).forEach(key => {
- filters.push(stateObj => _complexCompare(stateObj.attributes[key], filter.attributes[key]));
- });
- }
- if (filter.entity_id) {
- filters.push(stateObj => _filterEntityId(stateObj, filter.entity_id));
- }
- if (filter.name) {
- filters.push(stateObj => _filterName(stateObj, filter.name));
- }
- if (filter.state) {
- filters.push(stateObj => _complexCompare(stateObj.state, filter.state));
- }
-
- const options = filter.options ? filter.options : {}
-
- Object.keys(hass.states).sort().forEach(key => {
- if (filters.every(filterFunc => filterFunc(hass.states[key]))) {
- entities.set(hass.states[key].entity_id, Object.assign({ "entity": hass.states[key].entity_id }, options));
- }
- });
- });
- return Array.from(entities.values());
- }
-
- setConfig(config) {
- if (!config.filter.include || !Array.isArray(config.filter.include)) {
- throw new Error('Please define filters');
- }
-
- if (this.lastChild) this.removeChild(this.lastChild);
-
- const cardConfig = Object.assign({}, config);
- if (!cardConfig.card) cardConfig.card = {};
- if (config.card.entities) delete config.card.entities;
- if (!cardConfig.card.type) cardConfig.card.type = 'entities';
-
- const element = document.createElement(`hui-${cardConfig.card.type}-card`);
- this.appendChild(element);
-
- this._config = cardConfig;
- }
-
- set hass(hass) {
- const config = this._config;
- let entities = this._getEntities(hass, config.filter.include);
- if (config.filter.exclude) {
- const excludeEntities = this._getEntities(hass, config.filter.exclude).map(entity => entity.entity);
- entities = entities.filter(entity => !excludeEntities.includes(entity.entity));
- }
-
-
-
- if (entities.length === 0 && config.show_empty === false) {
- this.style.display = 'none';
- } else {
- if (config.when && (hass.states[config.when.entity].state == config.when.state) || !config.when) {
- this.style.display = 'block';
- } else {
- this.style.display = 'none';
- }
- }
-
- if (!config.card.entities || config.card.entities.length !== entities.length ||
- !config.card.entities.every((value, index) => value.entity === entities[index].entity)) {
- config.card.entities = entities;
- this.lastChild.setConfig(config.card);
- }
- this.lastChild.hass = hass;
- }
-
- getCardSize() {
- return 'getCardSize' in this.lastChild ? this.lastChild.getCardSize() : 1;
- }
-}
-
-customElements.define('monster-card', MonsterCard);
diff --git a/www/community/monster-card/monster-card.js.gz b/www/community/monster-card/monster-card.js.gz
deleted file mode 100644
index 7e3d017..0000000
Binary files a/www/community/monster-card/monster-card.js.gz and /dev/null differ
diff --git a/www/community/secondaryinfo-entity-row/secondaryinfo-entity-row.js.gz b/www/community/secondaryinfo-entity-row/secondaryinfo-entity-row.js.gz
index 8e3ea05..f6ed3c2 100644
Binary files a/www/community/secondaryinfo-entity-row/secondaryinfo-entity-row.js.gz and b/www/community/secondaryinfo-entity-row/secondaryinfo-entity-row.js.gz differ
diff --git a/www/community/vertical-stack-in-card/vertical-stack-in-card.js b/www/community/vertical-stack-in-card/vertical-stack-in-card.js
index 3c133c7..b0be01c 100644
--- a/www/community/vertical-stack-in-card/vertical-stack-in-card.js
+++ b/www/community/vertical-stack-in-card/vertical-stack-in-card.js
@@ -9,26 +9,18 @@ class VerticalStackInCard extends HTMLElement {
if (!config || !config.cards || !Array.isArray(config.cards)) {
throw new Error('Card config incorrect');
}
-
- this.style.boxShadow = "var(--ha-card-box-shadow, 0 2px 2px 0 rgba(0, 0, 0, 0.14), 0 1px 5px 0 rgba(0, 0, 0, 0.12), 0 3px 1px -2px rgba(0, 0, 0, 0.2))";
- this.style.borderRadius = "var(--ha-card-border-radius, 2px)";
- this.style.background = "var(--paper-card-background-color)";
- this.style.display = "block";
-
- const root = this.shadowRoot;
- while (root.hasChildNodes()) {
- root.removeChild(root.lastChild);
+
+ const shadow = this.shadowRoot;
+ while (shadow.hasChildNodes()) {
+ shadow.removeChild(shadow.lastChild);
}
-
+
+ const card = document.createElement("ha-card");
+ const cardContent = document.createElement("div");
+
+ card.header = config.title;
this._refCards = [];
- if (config.title) {
- const title = document.createElement("div");
- title.className = "header";
- title.style = "font-family: var(--paper-font-headline_-_font-family); -webkit-font-smoothing: var(--paper-font-headline_-_-webkit-font-smoothing); font-size: var(--paper-font-headline_-_font-size); font-weight: var(--paper-font-headline_-_font-weight); letter-spacing: var(--paper-font-headline_-_letter-spacing); line-height: var(--paper-font-headline_-_line-height);text-rendering: var(--paper-font-common-expensive-kerning_-_text-rendering);opacity: var(--dark-primary-opacity);padding: 24px 16px 0px 16px";
- title.innerHTML = '' + config.title + '
';
- root.appendChild(title);
- }
-
+
const _createThing = (tag, config) => {
const element = document.createElement(tag);
try {
@@ -84,7 +76,7 @@ class VerticalStackInCard extends HTMLElement {
if (customElements.get(tag)) {
const element = _createThing(tag, item);
- root.appendChild(element);
+ cardContent.appendChild(element);
this._refCards.push(element);
} else {
// If element doesn't exist (yet) create an error
@@ -104,10 +96,12 @@ class VerticalStackInCard extends HTMLElement {
_fireEvent("ll-rebuild", {}, element);
});
- root.appendChild(element);
+ cardContent.appendChild(element);
this._refCards.push(element);
}
});
+ card.appendChild(cardContent);
+ shadow.appendChild(card);
}
set hass(hass) {
@@ -148,11 +142,17 @@ class VerticalStackInCard extends HTMLElement {
this._card(searchEles[i]);
}
} else {
- element.shadowRoot.querySelector('ha-card').style.boxShadow = 'none';
+ let ele = element.shadowRoot.querySelector('ha-card')
+ ele.style.boxShadow = 'none';
+ ele.style.background = 'transparent';
+ ele.style.borderRadius = '0';
}
} else {
if (typeof element.querySelector === 'function' && element.querySelector('ha-card')) {
- element.querySelector('ha-card').style.boxShadow = 'none';
+ let ele = element.querySelector('ha-card')
+ ele.style.boxShadow = 'none';
+ ele.style.background = 'transparent';
+ ele.style.borderRadius = '0';
}
let searchEles = element.childNodes;
for (let i = 0; i < searchEles.length; i++) {
diff --git a/www/community/vertical-stack-in-card/vertical-stack-in-card.js.gz b/www/community/vertical-stack-in-card/vertical-stack-in-card.js.gz
index 1466f1b..72590ca 100644
Binary files a/www/community/vertical-stack-in-card/vertical-stack-in-card.js.gz and b/www/community/vertical-stack-in-card/vertical-stack-in-card.js.gz differ