!function(){"use strict";var t,e=function(){return e=Object.assign||function(t){for(var e,i=1,n=arguments.length;i0&&o[o.length-1])||6!==a[0]&&2!==a[0])){r=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1] ha-sidebar":{display:"none"},".header":{width:"100% !important"}}),ASIDE:m(".mdc-drawer"),OVERFLOW_MENU:m("".concat(L," > ").concat(y," > ").concat(B)),BLOCK_OVERFLOW:k((O={},O["".concat(L," > ").concat(y," > ").concat(B)]={"pointer-events":"none !important"},O)),SEARCH:m("".concat(L," > ").concat(y,' > ha-icon-button[data-selector="').concat(E.SEARCH,'"]'),"".concat(L," > ").concat(y," > ").concat(B," > ").concat(g,'[data-selector="').concat(E.SEARCH,'"]')),ASSISTANT:m("".concat(L," > ").concat(y,' > ha-icon-button[data-selector="').concat(E.ASSIST,'"]'),"".concat(L," > ").concat(y," > ").concat(B," > ").concat(g,'[data-selector="').concat(E.ASSIST,'"]')),REFRESH:m("".concat(L," > ").concat(y," > ").concat(B," > ").concat(g,'[data-selector="').concat(E.REFRESH,'"]')),UNUSED_ENTITIES:m("".concat(L," > ").concat(y," > ").concat(B," > ").concat(g,'[data-selector="').concat(E.UNUSED_ENTITIES,'"]')),RELOAD_RESOURCES:m("".concat(L," > ").concat(y," > ").concat(B," > ").concat(g,'[data-selector="').concat(E.RELOAD_RESOURCES,'"]')),EDIT_DASHBOARD:m("".concat(L," > ").concat(y," > ").concat(B," > ").concat(g,'[data-selector="').concat(E.EDIT_DASHBOARD,'"]'))},x=function(){function t(){this.lines=[{content:"%c≡ kiosk-mode",color:"white",background:"#03a9f4"},{content:"%cversion ".concat("2.0.0")}]}return t.prototype.log=function(){var t=[],i=[],n=this.lines.length-1,o={"border-color":"#424242","border-style":"solid",display:"inline-block","font-family":"monospace","font-size":"12px"};this.lines.forEach((function(s,r){t.push(s.content.padEnd(27)),t.push("%c⋮"),r!==n&&t.push("%c\n");var a="0 0 0 1px",c="0 1px 0 1px";0===n?(a="1px 0 1px 1px",c="1px 1px 1px 0"):0===r?(a="1px 0 0 1px",c="1px 1px 0 0"):r===n&&(a="0 0 1px 1px",c="0 1px 1px 0"),i.push(N(e(e({},o),{background:s.background||"white",color:s.color||"#424242",padding:0===r?"1px 0px 1px 5px":"1px 0px 1px 10px","border-width":a}))),i.push(N(e(e({},o),{background:s.background||"white",color:s.color||"white",padding:0===r?"1px 5px":"1px 5px 1px 0px","border-width":c}))),r!==n&&i.push("")})),console.info.apply(console,function(t,e,i){if(i||2===arguments.length)for(var n,o=0,s=e.length;o hass > user"))];case 3:return i.user=n.sent(),[4,M((function(){return s.main.querySelector(_.PARTIAL_PANEL_RESOLVER)}),(function(t){return!!t}),"".concat(_.HOME_ASSISTANT_MAIN," > ").concat(_.PARTIAL_PANEL_RESOLVER))];case 4:return o=n.sent(),this.run(),this.entityWatch(),new MutationObserver(this.watchDashboards).observe(o,{childList:!0}),[2]}}))})),this.resizeWindowBinded=this.resizeWindow.bind(this)}return t.prototype.run=function(t){var e=this;void 0===t&&(t=this.main.querySelector(_.HA_PANEL_LOVELACE)),t&&(this.lovelace=t,M((function(){var e;return null===(e=null==t?void 0:t.lovelace)||void 0===e?void 0:e.config}),(function(t){return!!t}),"Lovelace config").then((function(t){e.processConfig(t.kiosk_mode||{})})))},t.prototype.processConfig=function(t){return i(this,void 0,void 0,(function(){var e,a,E,d,u,l,S,O,A,f,I,T,H,p,b=this;return n(this,(function(U){switch(U.label){case 0:return e=this.ha.hass.panelUrl,window.kioskModeEntities[e]||(window.kioskModeEntities[e]=[]),this.hideHeader=!1,this.hideSidebar=!1,this.hideOverflow=!1,this.hideMenuButton=!1,this.hideAccount=!1,this.hideSearch=!1,this.hideAssistant=!1,this.hideRefresh=!1,this.hideUnusedEntities=!1,this.hideReloadResources=!1,this.hideEditDashboard=!1,this.blockOverflow=!1,this.blockMouse=!1,this.ignoreEntity=!1,this.ignoreMobile=!1,this.ignoreDisableKm=!1,a=this,[4,M((function(){var t,e,i;return null===(i=null===(e=null===(t=b.lovelace)||void 0===t?void 0:t.shadowRoot)||void 0===e?void 0:e.querySelector(_.HUI_ROOT))||void 0===i?void 0:i.shadowRoot}),(function(t){return!!t}),"".concat(_.HUI_ROOT).concat(h))];case 1:return a.huiRoot=U.sent(),E=this,[4,M((function(){return b.main.querySelector(_.HA_DRAWER)}),(function(t){return!!t}),_.HA_DRAWER)];case 2:return E.drawerLayout=U.sent(),d=this,[4,M((function(){return b.huiRoot.querySelector(_.TOOLBAR)}),(function(t){return!!t}),_.TOOLBAR)];case 3:return d.appToolbar=U.sent(),u=this,[4,M((function(){var t;return null===(t=b.drawerLayout.querySelector(_.HA_SIDEBAR))||void 0===t?void 0:t.shadowRoot}),(function(t){return!!t}),"".concat(_.HA_SIDEBAR).concat(h))];case 4:if(u.sideBarRoot=U.sent(),(N=this.ha,i(void 0,void 0,void 0,(function(){var t,e,i,o,s;return n(this,(function(n){switch(n.label){case 0:return[4,C(N)];case 1:return t=n.sent(),e=N.hass.language,i=t[e],o=Object.entries(R),s=o.map((function(t){var e=t[0],n=t[1];return[i[n],e]})),[2,Object.fromEntries(s)]}}))}))).then((function(t){b.menuTranslations=t,b.updateMenuItemsLabels()})).catch((function(){console.warn("".concat(r,": ").concat(c," Cannot get resources translations"))})),(l=v([o.HEADER,o.SIDEBAR,o.OVERFLOW,o.MENU_BUTTON,o.ACCOUNT,o.SEARCH,o.ASSISTANT,o.REFRESH,o.UNUSED_ENTITIES,o.RELOAD_RESOURCES,o.EDIT_DASHBOARD,o.OVERFLOW_MOUSE,o.MOUSE])||w([s.KIOSK,s.HIDE_HEADER,s.HIDE_SIDEBAR,s.HIDE_OVERFLOW,s.HIDE_MENU_BUTTON,s.HIDE_ACCOUNT,s.HIDE_SEARCH,s.HIDE_ASSISTANT,s.HIDE_REFRESH,s.HIDE_RELOAD_RESOURCES,s.HIDE_UNUSED_ENTITIES,s.HIDE_EDIT_DASHBOARD,s.BLOCK_OVERFLOW,s.BLOCK_MOUSE]))&&(this.hideHeader=v(o.HEADER)||w([s.KIOSK,s.HIDE_HEADER]),this.hideSidebar=v(o.SIDEBAR)||w([s.KIOSK,s.HIDE_SIDEBAR]),this.hideOverflow=v(o.OVERFLOW)||w([s.KIOSK,s.HIDE_OVERFLOW]),this.hideMenuButton=v(o.MENU_BUTTON)||w([s.KIOSK,s.HIDE_MENU_BUTTON]),this.hideAccount=v(o.ACCOUNT)||w([s.KIOSK,s.HIDE_ACCOUNT]),this.hideSearch=v(o.SEARCH)||w([s.KIOSK,s.HIDE_SEARCH]),this.hideAssistant=v(o.ASSISTANT)||w([s.KIOSK,s.HIDE_ASSISTANT]),this.hideRefresh=v(o.REFRESH)||w([s.KIOSK,s.HIDE_REFRESH]),this.hideUnusedEntities=v(o.UNUSED_ENTITIES)||w([s.KIOSK,s.HIDE_UNUSED_ENTITIES]),this.hideReloadResources=v(o.RELOAD_RESOURCES)||w([s.KIOSK,s.HIDE_RELOAD_RESOURCES]),this.hideEditDashboard=v(o.EDIT_DASHBOARD)||w([s.KIOSK,s.HIDE_EDIT_DASHBOARD]),this.blockOverflow=v(o.OVERFLOW_MOUSE)||w([s.BLOCK_OVERFLOW]),this.blockMouse=v(o.MOUSE)||w([s.BLOCK_MOUSE])),this.hideHeader=l?this.hideHeader:t.kiosk||t.hide_header,this.hideSidebar=l?this.hideSidebar:t.kiosk||t.hide_sidebar,this.hideOverflow=l?this.hideOverflow:t.kiosk||t.hide_overflow,this.hideMenuButton=l?this.hideMenuButton:t.kiosk||t.hide_menubutton,this.hideAccount=l?this.hideAccount:t.kiosk||t.hide_account,this.hideSearch=l?this.hideSearch:t.kiosk||t.hide_search,this.hideAssistant=l?this.hideAssistant:t.kiosk||t.hide_assistant,this.hideRefresh=l?this.hideRefresh:t.kiosk||t.hide_refresh,this.hideUnusedEntities=l?this.hideUnusedEntities:t.kiosk||t.hide_unused_entities,this.hideReloadResources=l?this.hideReloadResources:t.kiosk||t.hide_reload_resources,this.hideEditDashboard=l?this.hideEditDashboard:t.kiosk||t.hide_edit_dashboard,this.blockOverflow=l?this.blockOverflow:t.block_overflow,this.blockMouse=l?this.blockMouse:t.block_mouse,(S=this.user.is_admin?t.admin_settings:t.non_admin_settings)&&this.setOptions(S),t.user_settings&&D(t.user_settings).forEach((function(t){D(t.users).some((function(t){return t.toLowerCase()===b.user.name.toLowerCase()}))&&b.setOptions(t)})),(O=this.ignoreMobile?null:t.mobile_settings)&&(A=O.custom_width?O.custom_width:812,window.innerWidth<=A&&this.setOptions(O)),f=this.ignoreEntity?null:t.entity_settings)for(I=0,T=f;I ").concat(_.ACTION_ITEMS," > ").concat(_.MENU_ITEM))}),(function(t){return!!t}),":scope > ".concat(_.ACTION_ITEMS," > ").concat(_.MENU_ITEM)).then((function(e){e.forEach((function(e){if(e&&e.dataset&&!e.dataset.selector){var i=e.shadowRoot.querySelector(_.MENU_ITEM_ICON);e.dataset.selector=t.menuTranslations[i.title]}}))})).catch((function(t){console.warn("".concat(r,": ").concat(c," ").concat(t))})),this.user.is_admin&&M((function(){return t.appToolbar.querySelectorAll(_.OVERLAY_MENU_ITEM)}),(function(t){return!(!t||!t.length)}),"".concat(_.TOOLBAR," > ").concat(_.OVERLAY_MENU_ITEM)).then((function(e){e.forEach((function(e){if(e&&e.dataset&&!e.dataset.selector){var i=e.textContent.trim();e.dataset.selector=t.menuTranslations[i]}}))})).catch((function(t){console.warn("".concat(r,": ").concat(c," ").concat(t))})))},t.prototype.entityWatch=function(){return i(this,void 0,void 0,(function(){var t=this;return n(this,(function(e){switch(e.label){case 0:return[4,window.hassConnection];case 1:return e.sent().conn.subscribeMessage((function(e){return t.entityWatchCallback(e)}),{type:"subscribe_events",event_type:I}),[2]}}))}))},t.prototype.entityWatchCallback=function(t){var e=window.kioskModeEntities[this.ha.hass.panelUrl]||[];!e.length||t.event_type!==I||!e.includes(t.data.entity_id)||t.data.old_state&&t.data.new_state.state===t.data.old_state.state||this.run()},t.prototype.setOptions=function(t){this.hideHeader=t.kiosk||t.hide_header,this.hideSidebar=t.kiosk||t.hide_sidebar,this.hideOverflow=t.kiosk||t.hide_overflow,this.hideMenuButton=t.kiosk||t.hide_menubutton,this.hideAccount=t.kiosk||t.hide_account,this.hideSearch=t.kiosk||t.hide_search,this.hideAssistant=t.kiosk||t.hide_assistant,this.hideRefresh=t.kiosk||t.hide_refresh,this.hideUnusedEntities=t.kiosk||t.hide_unused_entities,this.hideReloadResources=t.kiosk||t.hide_reload_resources,this.hideEditDashboard=t.kiosk||t.hide_edit_dashboard,this.blockOverflow=t.block_overflow,this.blockMouse=t.block_mouse,this.ignoreEntity=typeof t.ignore_entity_settings===f?t.ignore_entity_settings:this.ignoreEntity,this.ignoreMobile=typeof t.ignore_mobile_settings===f?t.ignore_mobile_settings:this.ignoreMobile,this.ignoreDisableKm=typeof t.ignore_disable_km===f?t.ignore_disable_km:this.ignoreDisableKm},t}();(new x).log(),Promise.resolve(customElements.whenDefined(_.HUI_VIEW)).then((function(){window.KioskMode=new F}))}();