!function(){"use strict";function t(t,e,o,i){return new(o||(o=Promise))((function(_,s){function n(t){try{O(i.next(t))}catch(t){s(t)}}function E(t){try{O(i.throw(t))}catch(t){s(t)}}function O(t){var e;t.done?_(t.value):(e=t.value,e instanceof o?e:new o((function(t){t(e)}))).then(n,E)}O((i=i.apply(t,e||[])).next())}))}function e(t,e,o,i){return new(o||(o=Promise))((function(_,s){function n(t){try{O(i.next(t))}catch(t){s(t)}}function E(t){try{O(i.throw(t))}catch(t){s(t)}}function O(t){var e;t.done?_(t.value):(e=t.value,e instanceof o?e:new o((function(t){t(e)}))).then(n,E)}O((i=i.apply(t,e||[])).next())}))}function o(t,e,o,i){if("a"===o&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===o?i:"a"===o?i.call(t):i?i.value:e.get(t)}function i(t,e,o,i,_){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!_)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!_:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?_.call(t,o):_?_.value=o:e.set(t,o),o}"function"==typeof SuppressedError&&SuppressedError,"function"==typeof SuppressedError&&SuppressedError;const _="$",s=":host",n="invalid selector",E=10,O=10,I=t=>{const[e,o]=t;return(i=e)&&(i instanceof Document||i instanceof Element)&&"string"==typeof o;var i};function A(t,e,o,i,_=!1){return new Promise((s=>{let E=0;const O=()=>{const I=_?t.querySelectorAll(e):t.querySelector(e);_&&I.length||!_&&null!==I?s(I):(E++,E{let _=0;const s=()=>{const n=t.shadowRoot;n?i(n):(_++,_t.trim()))}(t).map((t=>{const o=function(t){return t.split(_).map((t=>t.trim()))}(t);return e(o)}))}(t,(t=>{if(!t[t.length-1].length)throw new SyntaxError(function(t,e){return`${t} cannot be used with a selector ending in a shadowRoot (${_}).${e?` If you want to select a shadowRoot, use ${e} instead.`:""}`}("asyncQuerySelector","asyncShadowRootQuerySelector"));return t})),n=e.length;for(let t=0;tt instanceof NodeList?t[0]||null:t))}get[(D=new WeakMap,l=new WeakMap,_)](){const e=a(o(this,D,"f")).then((t=>t instanceof Document||t instanceof ShadowRoot||null===t||t instanceof NodeList&&0===t.length?null:t instanceof NodeList?r(t[0],o(this,l,"f").retries,o(this,l,"f").delay):r(t,o(this,l,"f").retries,o(this,l,"f").delay)));return new t(e,o(this,l,"f"))}get all(){return a(o(this,D,"f")).then((t=>t instanceof NodeList?t:document.querySelectorAll(n)))}get asyncParams(){return o(this,l,"f")}eq(t){return e(this,void 0,void 0,(function*(){return a(o(this,D,"f")).then((e=>e instanceof NodeList&&e[t]||null))}))}query(e){const i=a(o(this,D,"f")).then((t=>null===t||t instanceof NodeList&&0===t.length?null:t instanceof NodeList?A(t[0],e,o(this,l,"f").retries,o(this,l,"f").delay,!0):A(t,e,o(this,l,"f").retries,o(this,l,"f").delay,!0)));return new t(i,o(this,l,"f"))}};function d(t,e,o,i){if("a"===o&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===o?i:"a"===o?i.call(t):i?i.value:e.get(t)}function R(t,e,o,i,_){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!_)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!_:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?_.call(t,o):_?_.value=o:e.set(t,o),o}"function"==typeof SuppressedError&&SuppressedError;const H="$",S={retries:100,delay:50};var N,u,C,G,M;!function(t){t.HOME_ASSISTANT="HOME_ASSISTANT",t.HOME_ASSISTANT_MAIN="HOME_ASSISTANT_MAIN",t.HA_DRAWER="HA_DRAWER",t.HA_SIDEBAR="HA_SIDEBAR"}(N||(N={})),function(t){t.PARTIAL_PANEL_RESOLVER="PARTIAL_PANEL_RESOLVER",t.HA_PANEL_LOVELACE="HA_PANEL_LOVELACE",t.HUI_ROOT="HUI_ROOT",t.HEADER="HEADER",t.HUI_VIEW="HUI_VIEW"}(u||(u={})),function(t){t.HA_MORE_INFO_DIALOG="HA_MORE_INFO_DIALOG",t.HA_DIALOG="HA_DIALOG",t.HA_DIALOG_CONTENT="HA_DIALOG_CONTENT",t.HA_MORE_INFO_DIALOG_INFO="HA_MORE_INFO_DIALOG_INFO",t.HA_DIALOG_MORE_INFO_HISTORY_AND_LOGBOOK="HA_DIALOG_MORE_INFO_HISTORY_AND_LOGBOOK",t.HA_DIALOG_MORE_INFO_SETTINGS="HA_DIALOG_MORE_INFO_SETTINGS"}(C||(C={})),function(t){t.ON_LOVELACE_PANEL_LOAD="onLovelacePanelLoad",t.ON_LOVELACE_MORE_INFO_DIALOG_OPEN="onLovelaceMoreInfoDialogOpen",t.ON_LOVELACE_HISTORY_AND_LOGBOOK_DIALOG_OPEN="onLovelaceHistoryAndLogBookDialogOpen",t.ON_LOVELACE_SETTINGS_DIALOG_OPEN="onLovelaceSettingsDialogOpen"}(G||(G={})),function(t){t.HOME_ASSISTANT="home-assistant",t.HOME_ASSISTANT_MAIN="home-assistant-main",t.HA_DRAWER="ha-drawer",t.HA_SIDEBAR="ha-sidebar",t.PARTIAL_PANEL_RESOLVER="partial-panel-resolver",t.HA_PANEL_LOVELACE="ha-panel-lovelace",t.HUI_ROOT="hui-root",t.HEADER=".header",t.HUI_VIEW="hui-view",t.HA_MORE_INFO_DIALOG="ha-more-info-dialog",t.HA_DIALOG="ha-dialog",t.HA_DIALOG_CONTENT=".content",t.HA_MORE_INFO_DIALOG_INFO="ha-more-info-info",t.HA_DIALOG_MORE_INFO_HISTORY_AND_LOGBOOK="ha-more-info-history-and-logbook",t.HA_DIALOG_MORE_INFO_SETTINGS="ha-more-info-settings"}(M||(M={}));const p={[N.HOME_ASSISTANT]:{selector:M.HOME_ASSISTANT,children:{shadowRoot:{selector:H,children:{[N.HOME_ASSISTANT_MAIN]:{selector:M.HOME_ASSISTANT_MAIN,children:{shadowRoot:{selector:H,children:{[N.HA_DRAWER]:{selector:M.HA_DRAWER,children:{[N.HA_SIDEBAR]:{selector:M.HA_SIDEBAR,children:{shadowRoot:{selector:H}}}}}}}}}}}}}},f={[u.PARTIAL_PANEL_RESOLVER]:{selector:M.PARTIAL_PANEL_RESOLVER,children:{[u.HA_PANEL_LOVELACE]:{selector:M.HA_PANEL_LOVELACE,children:{shadowRoot:{selector:H,children:{[u.HUI_ROOT]:{selector:M.HUI_ROOT,children:{shadowRoot:{selector:H,children:{[u.HEADER]:{selector:M.HEADER},[u.HUI_VIEW]:{selector:M.HUI_VIEW}}}}}}}}}}}},m={shadowRoot:{selector:H,children:{[C.HA_MORE_INFO_DIALOG]:{selector:M.HA_MORE_INFO_DIALOG,children:{shadowRoot:{selector:H,children:{[C.HA_DIALOG]:{selector:M.HA_DIALOG,children:{[C.HA_DIALOG_CONTENT]:{selector:M.HA_DIALOG_CONTENT,children:{[C.HA_MORE_INFO_DIALOG_INFO]:{selector:M.HA_MORE_INFO_DIALOG_INFO},[C.HA_DIALOG_MORE_INFO_HISTORY_AND_LOGBOOK]:{selector:M.HA_DIALOG_MORE_INFO_HISTORY_AND_LOGBOOK},[C.HA_DIALOG_MORE_INFO_SETTINGS]:{selector:M.HA_DIALOG_MORE_INFO_SETTINGS}}}}}}}}}}}},w=(t,e,o=null,i=!1)=>Object.entries(e||{}).reduce(((e,_)=>{const[s,n]=_;if(n.selector===H&&o)return n.children?Object.assign(Object.assign({},e),w(t,n.children,o,!0)):e;const E=o?o.then((e=>{return L(e,(o=n.selector,i?"$ "+o:o),t);var o})):L(n.selector,t);return e[s]={element:E,children:w(t,n.children,E),selector:new c(E,t)},e}),{}),v=(t,e)=>{const o=Object.entries(e);for(const e of o){if(e[0]===t)return e[1];{const o=v(t,e[1].children);if(o)return o}}},U=(t,e)=>Object.keys(t).reduce(((t,o)=>{const i=function(t,e){var o={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(o[i]=t[i]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var _=0;for(i=Object.getOwnPropertySymbols(t);_{d(this,V,"f").disconnect(),d(this,V,"f").observe(t,{childList:!0})})),R(this,F,((t,e)=>[C.HA_MORE_INFO_DIALOG,C.HA_DIALOG,C.HA_DIALOG_CONTENT,e].reduce(((e,o)=>(e[o]=t[o],e)),{}))(e,t),"f");const o={[C.HA_MORE_INFO_DIALOG_INFO]:G.ON_LOVELACE_MORE_INFO_DIALOG_OPEN,[C.HA_DIALOG_MORE_INFO_HISTORY_AND_LOGBOOK]:G.ON_LOVELACE_HISTORY_AND_LOGBOOK_DIALOG_OPEN,[C.HA_DIALOG_MORE_INFO_SETTINGS]:G.ON_LOVELACE_SETTINGS_DIALOG_OPEN};d(this,y,"m",Q).call(this,o[t],d(this,F,"f"))},Z=function(){R(this,B,w(d(this,g,"f"),p),"f"),R(this,P,U(N,d(this,B,"f")),"f"),d(this,P,"f")[N.HOME_ASSISTANT].selector.$.element.then((t=>{d(this,k,"f").disconnect(),d(this,k,"f").observe(t,{childList:!0})}))},tt=function(){const t=Date.now();t-d(this,X,"f")<500||(R(this,X,t,"f"),R(this,b,w(d(this,g,"f"),f,d(this,P,"f")[N.HA_DRAWER].element),"f"),R(this,W,U(u,d(this,b,"f")),"f"),d(this,W,"f")[u.PARTIAL_PANEL_RESOLVER].element.then((t=>{d(this,K,"f").disconnect(),d(this,K,"f").observe(t,{childList:!0})})),d(this,W,"f")[u.HA_PANEL_LOVELACE].selector.$.element.then((t=>{d(this,Y,"f").disconnect(),d(this,Y,"f").observe(t,{childList:!0})})),d(this,y,"m",Q).call(this,G.ON_LOVELACE_PANEL_LOAD,Object.assign(Object.assign({},d(this,P,"f")),d(this,W,"f"))))},et=function(t){t.forEach((({addedNodes:t})=>{t.forEach((t=>{t.localName===M.HA_MORE_INFO_DIALOG&&d(this,y,"m",J).call(this)}))}))},ot=function(t){t.forEach((({addedNodes:t})=>{t.forEach((t=>{const e={[M.HA_MORE_INFO_DIALOG_INFO]:C.HA_MORE_INFO_DIALOG_INFO,[M.HA_DIALOG_MORE_INFO_HISTORY_AND_LOGBOOK]:C.HA_DIALOG_MORE_INFO_HISTORY_AND_LOGBOOK,[M.HA_DIALOG_MORE_INFO_SETTINGS]:C.HA_DIALOG_MORE_INFO_SETTINGS};if(t.localName&&t.localName in e){const o=t.localName;d(this,y,"m",J).call(this,e[o])}}))}))},it=function(t){t.forEach((({addedNodes:t})=>{t.forEach((t=>{t.localName===M.HA_PANEL_LOVELACE&&d(this,y,"m",tt).call(this)}))}))},_t=function(t){t.forEach((({addedNodes:t})=>{t.forEach((t=>{t.localName===M.HUI_ROOT&&d(this,y,"m",tt).call(this)}))}))};const nt="kiosk-mode",Et="kiosk_mode";var Ot,It,At;!function(t){t.KIOSK="kiosk",t.HIDE_SIDEBAR="hide_sidebar",t.HIDE_HEADER="hide_header",t.HIDE_OVERFLOW="hide_overflow",t.HIDE_MENU_BUTTON="hide_menubutton",t.HIDE_ACCOUNT="hide_account",t.HIDE_NOTIFICATIONS="hide_notifications",t.HIDE_SEARCH="hide_search",t.HIDE_ASSISTANT="hide_assistant",t.HIDE_REFRESH="hide_refresh",t.HIDE_UNUSED_ENTITIES="hide_unused_entities",t.HIDE_RELOAD_RESOURCES="hide_reload_resources",t.HIDE_EDIT_DASHBOARD="hide_edit_dashboard",t.HIDE_DIALOG_HEADER_ACTION_ITEMS="hide_dialog_header_action_items",t.HIDE_DIALOG_HEADER_HISTORY="hide_dialog_header_history",t.HIDE_DIALOG_HEADER_SETTINGS="hide_dialog_header_settings",t.HIDE_DIALOG_HEADER_OVERFLOW="hide_dialog_header_overflow",t.HIDE_DIALOG_HISTORY="hide_dialog_history",t.HIDE_DIALOG_LOGBOOK="hide_dialog_logbook",t.HIDE_DIALOG_ATTRIBUTES="hide_dialog_attributes",t.HIDE_DIALOG_MEDIA_ACTIONS="hide_dialog_media_actions",t.HIDE_DIALOG_UPDATE_ACTIONS="hide_dialog_update_actions",t.HIDE_DIALOG_CLIMATE_ACTIONS="hide_dialog_climate_actions",t.HIDE_DIALOG_CLIMATE_TEMPERATURE_ACTIONS="hide_dialog_climate_temperature_actions",t.HIDE_DIALOG_CLIMATE_SETTINGS_ACTIONS="hide_dialog_climate_settings_actions",t.HIDE_DIALOG_TIMER_ACTIONS="hide_dialog_timer_actions",t.HIDE_DIALOG_HISTORY_SHOW_MORE="hide_dialog_history_show_more",t.HIDE_DIALOG_LOGBOOK_SHOW_MORE="hide_dialog_logbook_show_more",t.BLOCK_OVERFLOW="block_overflow",t.BLOCK_MOUSE="block_mouse",t.BLOCK_CONTEXT_MENU="block_context_menu"}(Ot||(Ot={})),function(t){t.IGNORE_ENTITY_SETTINGS="ignore_entity_settings",t.IGNORE_MOBILE_SETTINGS="ignore_mobile_settings",t.IGNORE_DISABLE_KM="ignore_disable_km"}(It||(It={})),function(t){t.CACHE="cache",t.CLEAR_CACHE="clear_km_cache",t.DISABLE_KIOSK_MODE="disable_km"}(At||(At={}));const rt="ui",at=`${rt}.common`,Tt=`${`${rt}.panel`}.lovelace`,ht=`${Tt}.menu`,Dt=`${rt}.dialogs.more_info_control`;var lt;!function(t){t.SEARCH="SEARCH",t.ASSIST="ASSIST",t.REFRESH="REFRESH",t.UNUSED_ENTITIES="UNUSED_ENTITIES",t.RELOAD_RESOURCES="RELOAD_RESOURCES",t.EDIT_DASHBOARD="EDIT_DASHBOARD",t.DIALOG_DISMISS="DIALOG_DISMISS",t.DIALOG_HISTORY="DIALOG_HISTORY",t.DIALOG_SETTINGS="DIALOG_SETTINGS"}(lt||(lt={}));const Lt=Object.freeze({[lt.SEARCH]:`${ht}.search`,[lt.ASSIST]:`${ht}.assist`,[lt.REFRESH]:`${at}.refresh`,[lt.UNUSED_ENTITIES]:`${Tt}.unused_entities.title`,[lt.RELOAD_RESOURCES]:`${ht}.reload_resources`,[lt.EDIT_DASHBOARD]:`${ht}.configure_ui`,[lt.DIALOG_HISTORY]:`${Dt}.history`,[lt.DIALOG_SETTINGS]:`${Dt}.settings`,[lt.DIALOG_DISMISS]:`${Dt}.dismiss`});var ct;!function(t){t.HOME_ASSISTANT="home-assistant",t.HA_PANEL_LOVELACE="ha-panel-lovelace",t.HUI_VIEW="hui-view",t.MENU_ITEM="ha-icon-button",t.MENU_ITEM_ICON="mwc-icon-button",t.BUTTON_MENU="ha-button-menu",t.OVERLAY_MENU_ITEM="mwc-list-item",t.TOOLBAR=".toolbar",t.ACTION_ITEMS=".action-items",t.HA_MORE_INFO_DIALOG="ha-more-info-dialog",t.HA_DIALOG="ha-dialog",t.HA_DIALOG_HEADER="ha-dialog-header",t.HA_DIALOG_MORE_INFO="ha-more-info-info",t.HA_DIALOG_HISTORY="ha-more-info-history",t.HA_DIALOG_LOGBOOK="ha-more-info-logbook",t.HA_DIALOG_MORE_INFO_CONTENT="more-info-content",t.HA_DIALOG_MORE_INFO_HISTORY_AND_LOGBOOK="ha-more-info-history-and-logbook",t.HA_DIALOG_DEFAULT="more-info-default",t.HA_DIALOG_TIMER="more-info-timer",t.HA_DIALOG_VACUUM="more-info-vacuum",t.HA_DIALOG_MEDIA_PLAYER="more-info-media_player",t.HA_DIALOG_LIGHT="more-info-light",t.HA_DIALOG_UPDATE="more-info-update",t.HA_DIALOG_CLIMATE="more-info-climate",t.HA_DIALOG_CLIMATE_CONTROL_SELECT="ha-more-info-control-select-container",t.HA_DIALOG_CLIMATE_TEMPERATURE="ha-more-info-climate-temperature",t.HA_STATE_CONTROL_CLIMATE_TEMPERATURE="ha-state-control-climate-temperature",t.HA_DIALOG_CLIMATE_TEMPERATURE_BUTTONS=".buttons",t.HA_DIALOG_CLIMATE_CIRCULAR_SLIDER="ha-control-circular-slider",t.HA_DIALOG_CLIMATE_CIRCULAR_SLIDER_INTERACTION="#interaction",t.HA_DIALOG_CLIMATE_CIRCULAR_SLIDER_INTERACTION_SLIDER='path[role="slider"]',t.HA_DIALOG_CLIMATE_CIRCULAR_SLIDER_INTERACTION_TARGET=".target",t.HA_DIALOG_CLIMATE_CIRCULAR_SLIDER_INTERACTION_TARGET_BORDER=".target-border",t.HA_DIALOG_ATTRIBUTES="ha-attributes"}(ct||(ct={}));const dt="true",Rt="state_changed",Ht="hass-toggle-menu",St=t=>Array.isArray(t)?t:[t],Nt=t=>t instanceof ShadowRoot?t.host.localName:t.localName,ut=t=>{const e=Nt(t);return t.querySelector(`#${Et}_${e}`)},Ct=(t,e)=>{if(!e)return;const o=Nt(e);let i=ut(e);i||(i=document.createElement("style"),i.setAttribute("id",`${Et}_${o}`),e.appendChild(i)),i.innerHTML=t},Gt=t=>{t&&St(t).forEach((t=>{const e=Nt(t);ut(t)&&t.querySelector(`#${Et}_${e}`).remove()}))},Mt=t=>`km${t.replace(/(?:^|_)([a-z])/g,((t,e)=>e.toUpperCase()))}`,pt=t=>{const e=new URLSearchParams(window.location.search);return St(t).some((t=>e.has(t)))},ft=(t,e)=>{St(t).forEach((t=>window.localStorage.setItem(Mt(t),e)))},mt=t=>St(t).some((t=>window.localStorage.getItem(Mt(t))===dt)),wt=t=>Object.entries(t).map((t=>{const[e,o]=t;return`${e}:${o}`})).join(";")+";",vt=t=>Object.entries(t).map((t=>{const[e,o]=t;return`${e}{${wt(o)}}`})).join(""),Ut=(...t)=>t.map((t=>`${t}{display: none !important;}`)).join(""),yt=e=>t(void 0,void 0,void 0,(function*(){const t=yield(t=>{let e=0;const o=Object.values(Lt);return new Promise(((i,_)=>{const s=()=>{var n;const E=null===(n=null==t?void 0:t.hass)||void 0===n?void 0:n.resources;let O=!1;if(E){const e=t.hass.language;o.find((t=>!E[e][t]))||(O=!0)}O?i(E):(e++,e<500?setTimeout(s,50):_())};s()}))})(e),o=t[e.hass.language],i=Object.entries(Lt).map((t=>{const[e,i]=t;return[o[i],e]}));return Object.fromEntries(i)})),gt=(t,e,o)=>new Promise(((i,_)=>{let s=0;const n=()=>{const E=t();E&&e(E)?i(E):(s++,s<500?setTimeout(n,50):_(new Error(`${nt}: Cannot select ${o} after 500 attempts. Giving up!`)))};n()})),$t=(t,e)=>{t.forEach((t=>{if(t&&t.dataset&&!t.dataset.selector){const o=t.shadowRoot.querySelector(ct.MENU_ITEM_ICON);t.dataset.selector=e[o.title]}}))},Bt={HEADER:vt({"#view":{"min-height":"100vh !important","--header-height":"0px"},".header":{display:"none"}}),ACCOUNT:Ut(".profile"),NOTIFICATIONS:Ut(".notifications-container"),DIVIDER:Ut(".divider"),PEPER_LISTBOX:(t,e)=>{let o=132;return t&&e?o=0:t?o-=50:e&&(o-=48),vt({"paper-listbox":{height:`calc(100% - var(--header-height) - ${o}px - env(safe-area-inset-bottom)) !important`}})},MENU_BUTTON:Ut(".menu ha-icon-button"),MENU_BUTTON_BURGER:Ut("ha-menu-button"),MOUSE:vt({"body::after":{bottom:"0",content:'""',cursor:"none",display:"block",left:"0",position:"fixed",right:"0",top:"0","z-index":"999999"}}),SIDEBAR:vt({":host":{"--mdc-drawer-width":"0 !important"},"partial-panel-resolver":{"--mdc-top-app-bar-width":"100% !important"},"ha-drawer > ha-sidebar":{display:"none"},".header":{width:"100% !important"}}),ASIDE:Ut(".mdc-drawer"),OVERFLOW_MENU:Ut(`${ct.TOOLBAR} > ${ct.ACTION_ITEMS} > ${ct.BUTTON_MENU}`),BLOCK_OVERFLOW:vt({[`${ct.TOOLBAR} > ${ct.ACTION_ITEMS} > ${ct.BUTTON_MENU}`]:{"pointer-events":"none !important"}}),SEARCH:Ut(`${ct.TOOLBAR} > ${ct.ACTION_ITEMS} > ha-icon-button[data-selector="${lt.SEARCH}"]`,`${ct.TOOLBAR} > ${ct.ACTION_ITEMS} > ${ct.BUTTON_MENU} > ${ct.OVERLAY_MENU_ITEM}[data-selector="${lt.SEARCH}"]`),ASSISTANT:Ut(`${ct.TOOLBAR} > ${ct.ACTION_ITEMS} > ha-icon-button[data-selector="${lt.ASSIST}"]`,`${ct.TOOLBAR} > ${ct.ACTION_ITEMS} > ${ct.BUTTON_MENU} > ${ct.OVERLAY_MENU_ITEM}[data-selector="${lt.ASSIST}"]`),REFRESH:Ut(`${ct.TOOLBAR} > ${ct.ACTION_ITEMS} > ${ct.BUTTON_MENU} > ${ct.OVERLAY_MENU_ITEM}[data-selector="${lt.REFRESH}"]`),UNUSED_ENTITIES:Ut(`${ct.TOOLBAR} > ${ct.ACTION_ITEMS} > ${ct.BUTTON_MENU} > ${ct.OVERLAY_MENU_ITEM}[data-selector="${lt.UNUSED_ENTITIES}"]`),RELOAD_RESOURCES:Ut(`${ct.TOOLBAR} > ${ct.ACTION_ITEMS} > ${ct.BUTTON_MENU} > ${ct.OVERLAY_MENU_ITEM}[data-selector="${lt.RELOAD_RESOURCES}"]`),EDIT_DASHBOARD:Ut(`${ct.TOOLBAR} > ${ct.ACTION_ITEMS} > ${ct.BUTTON_MENU} > ${ct.OVERLAY_MENU_ITEM}[data-selector="${lt.EDIT_DASHBOARD}"]`),DIALOG_HEADER_HISTORY:Ut(`${ct.HA_DIALOG_HEADER} > ${ct.MENU_ITEM}[data-selector="${lt.DIALOG_HISTORY}"]`),DIALOG_HEADER_SETTINGS:Ut(`${ct.HA_DIALOG_HEADER} > ${ct.MENU_ITEM}[data-selector="${lt.DIALOG_SETTINGS}"]`),DIALOG_HEADER_OVERFLOW:Ut(`${ct.HA_DIALOG_HEADER} > ${ct.BUTTON_MENU}`),DIALOG_HISTORY:Ut(ct.HA_DIALOG_HISTORY),DIALOG_LOGBOOK:Ut(ct.HA_DIALOG_LOGBOOK),DIALOG_ATTRIBUTES:Ut(ct.HA_DIALOG_ATTRIBUTES),DIALOG_MEDIA_ACTIONS:Ut(".controls"),DIALOG_TIMER_ACTIONS:Ut(".actions"),DIALOG_UPDATE_ACTIONS:Ut(".actions","hr:has(+ .actions)"),DIALOG_CLIMATE_CONTROL_SELECT:Ut(ct.HA_DIALOG_CLIMATE_CONTROL_SELECT),DIALOG_CLIMATE_TEMPERATURE_BUTTONS:Ut(ct.HA_DIALOG_CLIMATE_TEMPERATURE_BUTTONS),DIALOG_CLIMATE_CIRCULAR_SLIDER_INTERACTION:Ut(ct.HA_DIALOG_CLIMATE_CIRCULAR_SLIDER_INTERACTION,ct.HA_DIALOG_CLIMATE_CIRCULAR_SLIDER_INTERACTION_SLIDER,ct.HA_DIALOG_CLIMATE_CIRCULAR_SLIDER_INTERACTION_TARGET_BORDER,ct.HA_DIALOG_CLIMATE_CIRCULAR_SLIDER_INTERACTION_TARGET),DIALOG_SHOW_MORE:Ut(".header a")};class bt{constructor(){pt(At.CLEAR_CACHE)&&Object.values(Ot).forEach((t=>{window.localStorage.removeItem(Mt(t))})),window.kioskModeEntities={},this.options={};const e=new st;e.addEventListener(G.ON_LOVELACE_PANEL_LOAD,(e=>t(this,void 0,void 0,(function*(){var t,o;this.HAElements=e.detail;const{HOME_ASSISTANT:i,HOME_ASSISTANT_MAIN:_,HUI_ROOT:s,HA_DRAWER:n,HEADER:E,HA_SIDEBAR:O}=this.HAElements;this.ha=yield i.element,this.main=yield _.selector.$.element,this.huiRoot=yield s.selector.$.element,this.drawerLayout=yield n.element,this.appToolbar=yield E.selector.query(ct.TOOLBAR).element,this.sideBarRoot=yield O.selector.$.element,this.user=yield gt((()=>{var t,e;return null===(e=null===(t=this.ha)||void 0===t?void 0:t.hass)||void 0===e?void 0:e.user}),(t=>!!t),`${ct.HOME_ASSISTANT} > hass > user`),this.version=(t=>{const e=t?t.match(/^(\d+)\.(\d+)\.(\w+)(?:\.(\w+))?$/):null;return e?[+e[1],+e[2],e[3]]:null})(null===(o=null===(t=this.ha.hass)||void 0===t?void 0:t.config)||void 0===o?void 0:o.version),this.run()})))),e.addEventListener(G.ON_LOVELACE_MORE_INFO_DIALOG_OPEN,(t=>{this.HAMoreInfoDialogElements=t.detail,this.insertMoreInfoDialogStyles()})),e.addEventListener(G.ON_LOVELACE_HISTORY_AND_LOGBOOK_DIALOG_OPEN,(t=>{this.HAMoreInfoDialogElements=t.detail,this.insertMoreInfoDialogStyles()})),e.listen(),this.entityWatch(),this.resizeWindowBinded=this.resizeWindow.bind(this)}run(){return t(this,void 0,void 0,(function*(){const t=this.main.querySelector(ct.HA_PANEL_LOVELACE);if(t)return gt((()=>{var e;return null===(e=null==t?void 0:t.lovelace)||void 0===e?void 0:e.config}),(t=>!!t),"Lovelace config").then((t=>this.processConfig(t.kiosk_mode||{})))}))}runDialogs(t){var e,o;void 0===t&&(t=null===(o=null===(e=this.ha)||void 0===e?void 0:e.shadowRoot)||void 0===o?void 0:o.querySelector(ct.HA_MORE_INFO_DIALOG)),t&&this.insertMoreInfoDialogStyles()}processConfig(e){return t(this,void 0,void 0,(function*(){const t=this.ha.hass.panelUrl;window.kioskModeEntities[t]||(window.kioskModeEntities[t]=[]),Object.values(Ot).forEach((t=>{this.options[t]=!1})),Object.values(It).forEach((t=>{this.options[t]=!1})),yt(this.ha).then((t=>{this.menuTranslations=t,this.updateMenuItemsLabels()})).catch((()=>{console.warn(`${nt}: [ Non critial warning ] Cannot get resources translations`)})),mt(Object.values(Ot))||pt(Object.values(Ot))?Object.values(Ot).forEach((t=>{this.options[t]=mt(t)||pt(t)})):this.setOptions(e,!1);const o=this.user.is_admin?e.admin_settings:e.non_admin_settings;o&&this.setOptions(o,!0),e.user_settings&&St(e.user_settings).forEach((t=>{St(t.users).some((t=>t.toLowerCase()===this.user.name.toLowerCase()))&&this.setOptions(t,!0)}));const i=this.options[It.IGNORE_MOBILE_SETTINGS]?null:e.mobile_settings;if(i){const t=i.custom_width?i.custom_width:812;window.innerWidth<=t&&this.setOptions(i,!0)}const _=this.options[It.IGNORE_ENTITY_SETTINGS]?null:e.entity_settings;_&&_.forEach((e=>{const o=Object.keys(e.entity)[0];window.kioskModeEntities[t].includes(o)||window.kioskModeEntities[t].push(o),this.ha.hass.states[o].state==e.entity[o]&&this.setOptions(e,!1)})),pt(At.DISABLE_KIOSK_MODE)&&!this.options[It.IGNORE_DISABLE_KM]||this.insertStyles()}))}insertStyles(){var t,e,o,i;if(this.options[Ot.KIOSK]||this.options[Ot.HIDE_HEADER]?(Ct(Bt.HEADER,this.huiRoot),pt(At.CACHE)&&ft(Ot.HIDE_HEADER,dt)):Gt(this.huiRoot),null===(e=null===(t=this.main)||void 0===t?void 0:t.host)||void 0===e||e.removeEventListener(Ht,this.blockEventHandler,!0),this.options[Ot.KIOSK]||this.options[Ot.HIDE_SIDEBAR]?(null===(i=null===(o=this.main)||void 0===o?void 0:o.host)||void 0===i||i.addEventListener(Ht,this.blockEventHandler,!0),Ct(Bt.SIDEBAR,this.drawerLayout),Ct(Bt.ASIDE,this.drawerLayout.shadowRoot),pt(At.CACHE)&&ft(Ot.HIDE_SIDEBAR,dt)):(Gt(this.drawerLayout),Gt(this.drawerLayout.shadowRoot)),this.options[Ot.HIDE_ACCOUNT]||this.options[Ot.HIDE_NOTIFICATIONS]||this.options[Ot.HIDE_MENU_BUTTON]){const t=[this.options[Ot.HIDE_ACCOUNT]?Bt.ACCOUNT:"",this.options[Ot.HIDE_NOTIFICATIONS]?Bt.NOTIFICATIONS:"",this.options[Ot.HIDE_ACCOUNT]&&this.options[Ot.HIDE_NOTIFICATIONS]?Bt.DIVIDER:"",this.options[Ot.HIDE_ACCOUNT]||this.options[Ot.HIDE_NOTIFICATIONS]?Bt.PEPER_LISTBOX(this.options[Ot.HIDE_ACCOUNT],this.options[Ot.HIDE_NOTIFICATIONS]):"",this.options[Ot.HIDE_MENU_BUTTON]?Bt.MENU_BUTTON:""];Ct(t.join(""),this.sideBarRoot),pt(At.CACHE)&&(this.options[Ot.HIDE_ACCOUNT]&&ft(Ot.HIDE_ACCOUNT,dt),this.options[Ot.HIDE_NOTIFICATIONS]&&ft(Ot.HIDE_NOTIFICATIONS,dt))}else Gt(this.sideBarRoot);if(this.options[Ot.HIDE_SEARCH]||this.options[Ot.HIDE_ASSISTANT]||this.options[Ot.HIDE_REFRESH]||this.options[Ot.HIDE_UNUSED_ENTITIES]||this.options[Ot.HIDE_RELOAD_RESOURCES]||this.options[Ot.HIDE_EDIT_DASHBOARD]||this.options[Ot.HIDE_OVERFLOW]||this.options[Ot.BLOCK_OVERFLOW]||this.options[Ot.HIDE_SIDEBAR]||this.options[Ot.HIDE_MENU_BUTTON]){const t=[this.options[Ot.HIDE_SEARCH]?Bt.SEARCH:"",this.options[Ot.HIDE_ASSISTANT]?Bt.ASSISTANT:"",this.options[Ot.HIDE_REFRESH]?Bt.REFRESH:"",this.options[Ot.HIDE_UNUSED_ENTITIES]?Bt.UNUSED_ENTITIES:"",this.options[Ot.HIDE_RELOAD_RESOURCES]?Bt.RELOAD_RESOURCES:"",this.options[Ot.HIDE_EDIT_DASHBOARD]?Bt.EDIT_DASHBOARD:"",this.options[Ot.HIDE_OVERFLOW]?Bt.OVERFLOW_MENU:"",this.options[Ot.BLOCK_OVERFLOW]?Bt.BLOCK_OVERFLOW:"",this.options[Ot.HIDE_MENU_BUTTON]||this.options[Ot.HIDE_SIDEBAR]?Bt.MENU_BUTTON_BURGER:""];Ct(t.join(""),this.appToolbar),pt(At.CACHE)&&(this.options[Ot.HIDE_SEARCH]&&ft(Ot.HIDE_SEARCH,dt),this.options[Ot.HIDE_ASSISTANT]&&ft(Ot.HIDE_ASSISTANT,dt),this.options[Ot.HIDE_REFRESH]&&ft(Ot.HIDE_REFRESH,dt),this.options[Ot.HIDE_UNUSED_ENTITIES]&&ft(Ot.HIDE_UNUSED_ENTITIES,dt),this.options[Ot.HIDE_RELOAD_RESOURCES]&&ft(Ot.HIDE_RELOAD_RESOURCES,dt),this.options[Ot.HIDE_EDIT_DASHBOARD]&&ft(Ot.HIDE_EDIT_DASHBOARD,dt),this.options[Ot.HIDE_OVERFLOW]&&ft(Ot.HIDE_OVERFLOW,dt),this.options[Ot.BLOCK_OVERFLOW]&&ft(Ot.BLOCK_OVERFLOW,dt),this.options[Ot.HIDE_MENU_BUTTON]&&ft(Ot.HIDE_MENU_BUTTON,dt))}else Gt(this.appToolbar);this.options[Ot.BLOCK_MOUSE]?(Ct(Bt.MOUSE,document.body),pt(At.CACHE)&&ft(Ot.BLOCK_MOUSE,dt)):Gt(document.body),window.removeEventListener("contextmenu",this.blockEventHandler,!0),this.options[Ot.BLOCK_CONTEXT_MENU]&&(window.addEventListener("contextmenu",this.blockEventHandler,!0),pt(At.CACHE)&&ft(Ot.BLOCK_CONTEXT_MENU,dt)),window.removeEventListener("resize",this.resizeWindowBinded),window.addEventListener("resize",this.resizeWindowBinded),window.dispatchEvent(new Event("resize"))}insertMoreInfoDialogStyles(){return t(this,void 0,void 0,(function*(){const t=Boolean(this.version&&(this.version[0]<2023||2023===this.version[0]&&this.version[1]<12));this.HAMoreInfoDialogElements.HA_DIALOG.selector.query(`${ct.HA_DIALOG_HEADER} > ${ct.MENU_ITEM}`).all.then((t=>{$t(t,this.menuTranslations)}));const e=yield this.HAMoreInfoDialogElements.HA_DIALOG.element,o=this.HAMoreInfoDialogElements.HA_DIALOG_CONTENT.selector.query(`${ct.HA_DIALOG_MORE_INFO}, ${ct.HA_DIALOG_MORE_INFO_HISTORY_AND_LOGBOOK}`).$,i=yield o.element;if(this.options[Ot.HIDE_DIALOG_HEADER_ACTION_ITEMS]||this.options[Ot.HIDE_DIALOG_HEADER_HISTORY]||this.options[Ot.HIDE_DIALOG_HEADER_SETTINGS]||this.options[Ot.HIDE_DIALOG_HEADER_OVERFLOW]){const t=[this.options[Ot.HIDE_DIALOG_HEADER_ACTION_ITEMS]||this.options[Ot.HIDE_DIALOG_HEADER_HISTORY]?Bt.DIALOG_HEADER_HISTORY:"",this.options[Ot.HIDE_DIALOG_HEADER_ACTION_ITEMS]||this.options[Ot.HIDE_DIALOG_HEADER_SETTINGS]?Bt.DIALOG_HEADER_SETTINGS:"",this.options[Ot.HIDE_DIALOG_HEADER_ACTION_ITEMS]||this.options[Ot.HIDE_DIALOG_HEADER_OVERFLOW]?Bt.DIALOG_HEADER_OVERFLOW:""];Ct(t.join(""),e),pt(At.CACHE)&&(this.options[Ot.HIDE_DIALOG_HEADER_ACTION_ITEMS]&&ft(Ot.HIDE_DIALOG_HEADER_ACTION_ITEMS,dt),this.options[Ot.HIDE_DIALOG_HEADER_HISTORY]&&ft(Ot.HIDE_DIALOG_HEADER_HISTORY,dt),this.options[Ot.HIDE_DIALOG_HEADER_SETTINGS]&&ft(Ot.HIDE_DIALOG_HEADER_SETTINGS,dt),this.options[Ot.HIDE_DIALOG_HEADER_OVERFLOW]&&ft(Ot.HIDE_DIALOG_HEADER_OVERFLOW,dt))}else Gt(e);if(this.options[Ot.HIDE_DIALOG_HISTORY]||this.options[Ot.HIDE_DIALOG_LOGBOOK]){const t=[this.options[Ot.HIDE_DIALOG_HISTORY]?Bt.DIALOG_HISTORY:"",this.options[Ot.HIDE_DIALOG_LOGBOOK]?Bt.DIALOG_LOGBOOK:""];Ct(t.join(""),i),pt(At.CACHE)&&(this.options[Ot.HIDE_DIALOG_HISTORY]&&ft(Ot.HIDE_DIALOG_HISTORY,dt),this.options[Ot.HIDE_DIALOG_LOGBOOK]&&ft(Ot.HIDE_DIALOG_LOGBOOK,dt))}else Gt(i);const _=t?o.query(ct.HA_DIALOG_CLIMATE).$:o.query(ct.HA_DIALOG_MORE_INFO_CONTENT).$.query(ct.HA_DIALOG_CLIMATE).$,s=_.query(t?ct.HA_DIALOG_CLIMATE_TEMPERATURE:ct.HA_STATE_CONTROL_CLIMATE_TEMPERATURE).$,n=s.query(ct.HA_DIALOG_CLIMATE_CIRCULAR_SLIDER).$;_.element.then((t=>{this.options[Ot.HIDE_DIALOG_CLIMATE_ACTIONS]||this.options[Ot.HIDE_DIALOG_CLIMATE_SETTINGS_ACTIONS]?(Ct(Bt.DIALOG_CLIMATE_CONTROL_SELECT,t),pt(At.CACHE)&&(this.options[Ot.HIDE_DIALOG_CLIMATE_ACTIONS]&&ft(Ot.HIDE_DIALOG_CLIMATE_ACTIONS,dt),this.options[Ot.HIDE_DIALOG_CLIMATE_SETTINGS_ACTIONS]&&ft(Ot.HIDE_DIALOG_CLIMATE_SETTINGS_ACTIONS,dt))):Gt(t)})),s.element.then((t=>{this.options[Ot.HIDE_DIALOG_CLIMATE_ACTIONS]||this.options[Ot.HIDE_DIALOG_CLIMATE_TEMPERATURE_ACTIONS]?(Ct(Bt.DIALOG_CLIMATE_TEMPERATURE_BUTTONS,t),pt(At.CACHE)&&this.options[Ot.HIDE_DIALOG_CLIMATE_TEMPERATURE_ACTIONS]&&ft(Ot.HIDE_DIALOG_CLIMATE_TEMPERATURE_ACTIONS,dt)):Gt(t)})),n.element.then((t=>{this.options[Ot.HIDE_DIALOG_CLIMATE_ACTIONS]||this.options[Ot.HIDE_DIALOG_CLIMATE_TEMPERATURE_ACTIONS]?Ct(Bt.DIALOG_CLIMATE_CIRCULAR_SLIDER_INTERACTION,t):Gt(t)})),o.query(ct.HA_DIALOG_HISTORY).$.element.then((t=>{this.options[Ot.HIDE_DIALOG_HISTORY_SHOW_MORE]?(Ct(Bt.DIALOG_SHOW_MORE,t),pt(At.CACHE)&&ft(Ot.HIDE_DIALOG_HISTORY_SHOW_MORE,dt)):Gt(t)})),o.query(ct.HA_DIALOG_LOGBOOK).$.element.then((t=>{this.options[Ot.HIDE_DIALOG_LOGBOOK_SHOW_MORE]?(Ct(Bt.DIALOG_SHOW_MORE,t),pt(At.CACHE)&&ft(Ot.HIDE_DIALOG_LOGBOOK_SHOW_MORE,dt)):Gt(t)}));(t?o.query([`${ct.HA_DIALOG_MORE_INFO_CONTENT} > ${ct.HA_DIALOG_DEFAULT}`,`${ct.HA_DIALOG_MORE_INFO_CONTENT} > ${ct.HA_DIALOG_VACUUM}`,`${ct.HA_DIALOG_MORE_INFO_CONTENT} > ${ct.HA_DIALOG_TIMER}`,`${ct.HA_DIALOG_MORE_INFO_CONTENT} > ${ct.HA_DIALOG_LIGHT}`,`${ct.HA_DIALOG_MORE_INFO_CONTENT} > ${ct.HA_DIALOG_MEDIA_PLAYER}`].join(",")).$.element:o.query(ct.HA_DIALOG_MORE_INFO_CONTENT).$.query([ct.HA_DIALOG_DEFAULT,ct.HA_DIALOG_VACUUM,ct.HA_DIALOG_TIMER,ct.HA_DIALOG_LIGHT,ct.HA_DIALOG_MEDIA_PLAYER].join(",")).$.element).then((t=>{if(this.options[Ot.HIDE_DIALOG_ATTRIBUTES]||this.options[Ot.HIDE_DIALOG_TIMER_ACTIONS]||this.options[Ot.HIDE_DIALOG_MEDIA_ACTIONS]){const e=[this.options[Ot.HIDE_DIALOG_ATTRIBUTES]?Bt.DIALOG_ATTRIBUTES:"",this.options[Ot.HIDE_DIALOG_TIMER_ACTIONS]?Bt.DIALOG_TIMER_ACTIONS:"",this.options[Ot.HIDE_DIALOG_MEDIA_ACTIONS]&&t.host.localName===ct.HA_DIALOG_MEDIA_PLAYER?Bt.DIALOG_MEDIA_ACTIONS:""];Ct(e.join(""),t),pt(At.CACHE)&&(this.options[Ot.HIDE_DIALOG_ATTRIBUTES]&&ft(Ot.HIDE_DIALOG_ATTRIBUTES,dt),this.options[Ot.HIDE_DIALOG_TIMER_ACTIONS]&&ft(Ot.HIDE_DIALOG_TIMER_ACTIONS,dt),this.options[Ot.HIDE_DIALOG_MEDIA_ACTIONS]&&ft(Ot.HIDE_DIALOG_MEDIA_ACTIONS,dt))}else Gt(t)}));(t?o.query(`${ct.HA_DIALOG_MORE_INFO_CONTENT} > ${ct.HA_DIALOG_UPDATE}`).$.element:o.query(ct.HA_DIALOG_MORE_INFO_CONTENT).$.query(ct.HA_DIALOG_UPDATE).$.element).then((t=>{this.options[Ot.HIDE_DIALOG_UPDATE_ACTIONS]?(Ct(Bt.DIALOG_UPDATE_ACTIONS,t),pt(At.CACHE)&&ft(Ot.HIDE_DIALOG_UPDATE_ACTIONS,dt)):Gt(t)}))}))}resizeWindow(){window.clearTimeout(this.resizeDelay),this.resizeDelay=window.setTimeout((()=>{this.updateMenuItemsLabels()}),250)}updateMenuItemsLabels(){this.menuTranslations&&(this.HAElements.HEADER.selector.query(`${ct.TOOLBAR} > ${ct.ACTION_ITEMS} > ${ct.MENU_ITEM}`).all.then((t=>{$t(t,this.menuTranslations)})),this.user.is_admin&&this.HAElements.HEADER.selector.query(`${ct.TOOLBAR} ${ct.OVERLAY_MENU_ITEM}`).all.then((t=>{t.forEach((t=>{if(t&&t.dataset&&!t.dataset.selector){const e=t.textContent.trim();t.dataset.selector=this.menuTranslations[e]}}))})))}entityWatch(){return t(this,void 0,void 0,(function*(){(yield window.hassConnection).conn.subscribeMessage((t=>this.entityWatchCallback(t)),{type:"subscribe_events",event_type:Rt})}))}entityWatchCallback(e){return t(this,void 0,void 0,(function*(){const t=window.kioskModeEntities[this.ha.hass.panelUrl]||[];!t.length||e.event_type!==Rt||!t.includes(e.data.entity_id)||e.data.old_state&&e.data.new_state.state===e.data.old_state.state||(yield this.run(),this.runDialogs())}))}blockEventHandler(t){t.preventDefault(),t.stopImmediatePropagation()}setOptions(t,e){Object.values(Ot).forEach((e=>{e in t&&(this.options[e]=t[e])})),e&&Object.values(It).forEach((e=>{e in t&&(this.options[e]=t[e])}))}}(new class{constructor(){this.lines=[{content:"%c≡ kiosk-mode",color:"white",background:"#03a9f4"},{content:"%cversion 5.0.0"}]}log(){const t=[],e=[],o=this.lines.length-1,i={"border-color":"#424242","border-style":"solid",display:"inline-block","font-family":"monospace","font-size":"12px"};this.lines.forEach(((_,s)=>{t.push(_.content.padEnd(27)),t.push("%c⋮"),s!==o&&t.push("%c\n");let n="0 0 0 1px",E="0 1px 0 1px";0===o?(n="1px 0 1px 1px",E="1px 1px 1px 0"):0===s?(n="1px 0 0 1px",E="1px 1px 0 0"):s===o&&(n="0 0 1px 1px",E="0 1px 1px 0"),e.push(wt(Object.assign(Object.assign({},i),{background:_.background||"white",color:_.color||"#424242",padding:0===s?"1px 0px 1px 5px":"1px 0px 1px 10px","border-width":n}))),e.push(wt(Object.assign(Object.assign({},i),{background:_.background||"white",color:_.color||"white",padding:0===s?"1px 5px":"1px 5px 1px 0px","border-width":E}))),s!==o&&e.push("")})),console.info(t.join(""),...e)}}).log(),Promise.resolve(customElements.whenDefined(ct.HUI_VIEW)).then((()=>{window.KioskMode=new bt}))}();