\n "]);return C=function(){return e},e}function T(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function z(e,t){return(z=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function R(e){return function(){var t,r=F(e);if(function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(e){return!1}}()){var n=F(this).constructor;t=Reflect.construct(r,arguments,n)}else t=r.apply(this,arguments);return function(e,t){if(t&&("object"===j(t)||"function"==typeof t))return t;return I(e)}(this,t)}}function I(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function F(e){return(F=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function N(e){var t,r=H(e.key);"method"===e.kind?t={value:e.value,writable:!0,configurable:!0,enumerable:!1}:"get"===e.kind?t={get:e.value,configurable:!0,enumerable:!1}:"set"===e.kind?t={set:e.value,configurable:!0,enumerable:!1}:"field"===e.kind&&(t={configurable:!0,writable:!0,enumerable:!0});var n={kind:"field"===e.kind?"field":"method",key:r,placement:e.static?"static":"field"===e.kind?"own":"prototype",descriptor:t};return e.decorators&&(n.decorators=e.decorators),"field"===e.kind&&(n.initializer=e.value),n}function L(e,t){void 0!==e.descriptor.get?t.descriptor.get=e.descriptor.get:t.descriptor.set=e.descriptor.set}function U(e){return e.decorators&&e.decorators.length}function M(e){return void 0!==e&&!(void 0===e.value&&void 0===e.writable)}function B(e,t){var r=e[t];if(void 0!==r&&"function"!=typeof r)throw new TypeError("Expected '"+t+"' to be a function");return r}function H(e){var t=function(e,t){if("object"!==j(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!==j(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"===j(t)?t:String(t)}function $(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r=0;o--){var a=t[e.placement];a.splice(a.indexOf(e.key),1);var s=this.fromElementDescriptor(e),c=this.toElementFinisherExtras((0,i[o])(s)||s);e=c.element,this.addElementPlacement(e,t),c.finisher&&n.push(c.finisher);var l=c.extras;if(l){for(var u=0;u=0;n--){var i=this.fromClassDescriptor(e),o=this.toClassDescriptor((0,t[n])(i)||i);if(void 0!==o.finisher&&r.push(o.finisher),void 0!==o.elements){e=o.elements;for(var a=0;a\n \n \n "]);return a=function(){return e},e}function s(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function c(e,t){return(c=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function l(e){return function(){var t,r=f(e);if(function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(e){return!1}}()){var n=f(this).constructor;t=Reflect.construct(r,arguments,n)}else t=r.apply(this,arguments);return function(e,t){if(t&&("object"===i(t)||"function"==typeof t))return t;return u(e)}(this,t)}}function u(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function f(e){return(f=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function d(e){var t,r=v(e.key);"method"===e.kind?t={value:e.value,writable:!0,configurable:!0,enumerable:!1}:"get"===e.kind?t={get:e.value,configurable:!0,enumerable:!1}:"set"===e.kind?t={set:e.value,configurable:!0,enumerable:!1}:"field"===e.kind&&(t={configurable:!0,writable:!0,enumerable:!0});var n={kind:"field"===e.kind?"field":"method",key:r,placement:e.static?"static":"field"===e.kind?"own":"prototype",descriptor:t};return e.decorators&&(n.decorators=e.decorators),"field"===e.kind&&(n.initializer=e.value),n}function p(e,t){void 0!==e.descriptor.get?t.descriptor.get=e.descriptor.get:t.descriptor.set=e.descriptor.set}function h(e){return e.decorators&&e.decorators.length}function m(e){return void 0!==e&&!(void 0===e.value&&void 0===e.writable)}function y(e,t){var r=e[t];if(void 0!==r&&"function"!=typeof r)throw new TypeError("Expected '"+t+"' to be a function");return r}function v(e){var t=function(e,t){if("object"!==i(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!==i(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"===i(t)?t:String(t)}function b(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r=0;o--){var a=t[e.placement];a.splice(a.indexOf(e.key),1);var s=this.fromElementDescriptor(e),c=this.toElementFinisherExtras((0,i[o])(s)||s);e=c.element,this.addElementPlacement(e,t),c.finisher&&n.push(c.finisher);var l=c.extras;if(l){for(var u=0;u=0;n--){var i=this.fromClassDescriptor(e),o=this.toClassDescriptor((0,t[n])(i)||i);if(void 0!==o.finisher&&r.push(o.finisher),void 0!==o.elements){e=o.elements;for(var a=0;a\n \n "]);return a=function(){return e},e}function s(e,t){return(s=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function c(e){return function(){var t,r=b(e);if(function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(e){return!1}}()){var n=b(this).constructor;t=Reflect.construct(r,arguments,n)}else t=r.apply(this,arguments);return function(e,t){if(t&&("object"===o(t)||"function"==typeof t))return t;return l(e)}(this,t)}}function l(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function u(e){var t,r=m(e.key);"method"===e.kind?t={value:e.value,writable:!0,configurable:!0,enumerable:!1}:"get"===e.kind?t={get:e.value,configurable:!0,enumerable:!1}:"set"===e.kind?t={set:e.value,configurable:!0,enumerable:!1}:"field"===e.kind&&(t={configurable:!0,writable:!0,enumerable:!0});var n={kind:"field"===e.kind?"field":"method",key:r,placement:e.static?"static":"field"===e.kind?"own":"prototype",descriptor:t};return e.decorators&&(n.decorators=e.decorators),"field"===e.kind&&(n.initializer=e.value),n}function f(e,t){void 0!==e.descriptor.get?t.descriptor.get=e.descriptor.get:t.descriptor.set=e.descriptor.set}function d(e){return e.decorators&&e.decorators.length}function p(e){return void 0!==e&&!(void 0===e.value&&void 0===e.writable)}function h(e,t){var r=e[t];if(void 0!==r&&"function"!=typeof r)throw new TypeError("Expected '"+t+"' to be a function");return r}function m(e){var t=function(e,t){if("object"!==o(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!==o(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"===o(t)?t:String(t)}function y(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r=0;o--){var a=t[e.placement];a.splice(a.indexOf(e.key),1);var s=this.fromElementDescriptor(e),c=this.toElementFinisherExtras((0,i[o])(s)||s);e=c.element,this.addElementPlacement(e,t),c.finisher&&n.push(c.finisher);var l=c.extras;if(l){for(var u=0;u=0;n--){var i=this.fromClassDescriptor(e),o=this.toClassDescriptor((0,t[n])(i)||i);if(void 0!==o.finisher&&r.push(o.finisher),void 0!==o.elements){e=o.elements;for(var a=0;a "]);return a=function(){return e},e}function s(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function c(e,t){return(c=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function l(e){return function(){var t,r=f(e);if(function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(e){return!1}}()){var n=f(this).constructor;t=Reflect.construct(r,arguments,n)}else t=r.apply(this,arguments);return function(e,t){if(t&&("object"===i(t)||"function"==typeof t))return t;return u(e)}(this,t)}}function u(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function f(e){return(f=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function d(e){var t,r=v(e.key);"method"===e.kind?t={value:e.value,writable:!0,configurable:!0,enumerable:!1}:"get"===e.kind?t={get:e.value,configurable:!0,enumerable:!1}:"set"===e.kind?t={set:e.value,configurable:!0,enumerable:!1}:"field"===e.kind&&(t={configurable:!0,writable:!0,enumerable:!0});var n={kind:"field"===e.kind?"field":"method",key:r,placement:e.static?"static":"field"===e.kind?"own":"prototype",descriptor:t};return e.decorators&&(n.decorators=e.decorators),"field"===e.kind&&(n.initializer=e.value),n}function p(e,t){void 0!==e.descriptor.get?t.descriptor.get=e.descriptor.get:t.descriptor.set=e.descriptor.set}function h(e){return e.decorators&&e.decorators.length}function m(e){return void 0!==e&&!(void 0===e.value&&void 0===e.writable)}function y(e,t){var r=e[t];if(void 0!==r&&"function"!=typeof r)throw new TypeError("Expected '"+t+"' to be a function");return r}function v(e){var t=function(e,t){if("object"!==i(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!==i(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"===i(t)?t:String(t)}function b(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r=0;o--){var a=t[e.placement];a.splice(a.indexOf(e.key),1);var s=this.fromElementDescriptor(e),c=this.toElementFinisherExtras((0,i[o])(s)||s);e=c.element,this.addElementPlacement(e,t),c.finisher&&n.push(c.finisher);var l=c.extras;if(l){for(var u=0;u=0;n--){var i=this.fromClassDescriptor(e),o=this.toClassDescriptor((0,t[n])(i)||i);if(void 0!==o.finisher&&r.push(o.finisher),void 0!==o.elements){e=o.elements;for(var a=0;ae.length)&&(t=e.length);for(var r=0,n=new Array(t);r\n e.length)&&(t=e.length);for(var r=0,n=new Array(t);rt||Number(o)===t&&Number(a)>=r}},97:function(e,t,r){"use strict";var n=r(6),i=r(13),o=r(198),a=function(e){return e.sendMessagePromise({type:"persistent_notification/get"})},s=function(e,t){return e.subscribeEvents(function(){return a(e).then(function(e){return t.setState(e,!0)})},"persistent_notifications_updated")},c=(r(77),r(16));function l(e){return(l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function u(){var e=p(["\n :host {\n position: relative;\n }\n .dot {\n pointer-events: none;\n position: absolute;\n background-color: var(--accent-color);\n width: 12px;\n height: 12px;\n top: 9px;\n right: 7px;\n border-radius: 50%;\n border: 2px solid var(--app-header-background-color);\n }\n "]);return u=function(){return e},e}function f(){var e=p([' ']);return f=function(){return e},e}function d(){var e=p(["\n \n \n \n ","\n "]);return d=function(){return e},e}function p(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function h(e,t){return(h=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function m(e){return function(){var t,r=j(e);if(function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(e){return!1}}()){var n=j(this).constructor;t=Reflect.construct(r,arguments,n)}else t=r.apply(this,arguments);return function(e,t){if(t&&("object"===l(t)||"function"==typeof t))return t;return y(e)}(this,t)}}function y(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function v(e){var t,r=E(e.key);"method"===e.kind?t={value:e.value,writable:!0,configurable:!0,enumerable:!1}:"get"===e.kind?t={get:e.value,configurable:!0,enumerable:!1}:"set"===e.kind?t={set:e.value,configurable:!0,enumerable:!1}:"field"===e.kind&&(t={configurable:!0,writable:!0,enumerable:!0});var n={kind:"field"===e.kind?"field":"method",key:r,placement:e.static?"static":"field"===e.kind?"own":"prototype",descriptor:t};return e.decorators&&(n.decorators=e.decorators),"field"===e.kind&&(n.initializer=e.value),n}function b(e,t){void 0!==e.descriptor.get?t.descriptor.get=e.descriptor.get:t.descriptor.set=e.descriptor.set}function g(e){return e.decorators&&e.decorators.length}function w(e){return void 0!==e&&!(void 0===e.value&&void 0===e.writable)}function k(e,t){var r=e[t];if(void 0!==r&&"function"!=typeof r)throw new TypeError("Expected '"+t+"' to be a function");return r}function E(e){var t=function(e,t){if("object"!==l(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!==l(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"===l(t)?t:String(t)}function O(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r=0;o--){var a=t[e.placement];a.splice(a.indexOf(e.key),1);var s=this.fromElementDescriptor(e),c=this.toElementFinisherExtras((0,i[o])(s)||s);e=c.element,this.addElementPlacement(e,t),c.finisher&&n.push(c.finisher);var l=c.extras;if(l){for(var u=0;u=0;n--){var i=this.fromClassDescriptor(e),o=this.toClassDescriptor((0,t[n])(i)||i);if(void 0!==o.finisher&&r.push(o.finisher),void 0!==o.elements){e=o.elements;for(var a=0;a0},Object(o.a)("_ntf",a,s,e,t))}},{kind:"method",key:"_toggleMenu",value:function(){Object(i.a)(this,"hass-toggle-menu")}},{kind:"get",static:!0,key:"styles",value:function(){return Object(n.c)(u())}}]}},n.a)},98:function(e,t,r){"use strict";r(107);var n=r(145),i=r(6),o=(r(23),r(146));function a(e){return(a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function s(){var e=f(["\n :host {\n fill: currentcolor;\n }\n "]);return s=function(){return e},e}function c(){var e=f([""]);return c=function(){return e},e}function l(){var e=f([""]);return l=function(){return e},e}function u(){var e=f([""]);return u=function(){return e},e}function f(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function d(e,t){return(d=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function p(e){return function(){var t,r=m(e);if(function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(e){return!1}}()){var n=m(this).constructor;t=Reflect.construct(r,arguments,n)}else t=r.apply(this,arguments);return function(e,t){if(t&&("object"===a(t)||"function"==typeof t))return t;return h(e)}(this,t)}}function h(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function m(e){return(m=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function y(e){var t,r=k(e.key);"method"===e.kind?t={value:e.value,writable:!0,configurable:!0,enumerable:!1}:"get"===e.kind?t={get:e.value,configurable:!0,enumerable:!1}:"set"===e.kind?t={set:e.value,configurable:!0,enumerable:!1}:"field"===e.kind&&(t={configurable:!0,writable:!0,enumerable:!0});var n={kind:"field"===e.kind?"field":"method",key:r,placement:e.static?"static":"field"===e.kind?"own":"prototype",descriptor:t};return e.decorators&&(n.decorators=e.decorators),"field"===e.kind&&(n.initializer=e.value),n}function v(e,t){void 0!==e.descriptor.get?t.descriptor.get=e.descriptor.get:t.descriptor.set=e.descriptor.set}function b(e){return e.decorators&&e.decorators.length}function g(e){return void 0!==e&&!(void 0===e.value&&void 0===e.writable)}function w(e,t){var r=e[t];if(void 0!==r&&"function"!=typeof r)throw new TypeError("Expected '"+t+"' to be a function");return r}function k(e){var t=function(e,t){if("object"!==a(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!==a(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"===a(t)?t:String(t)}function E(e,t,r,n,i,o,a){try{var s=e[o](a),c=s.value}catch(l){return void r(l)}s.done?t(c):Promise.resolve(c).then(n,i)}function O(e){return function(){var t=this,r=arguments;return new Promise(function(n,i){var o=e.apply(t,r);function a(e){E(o,n,i,a,s,"next",e)}function s(e){E(o,n,i,a,s,"throw",e)}a(void 0)})}}function P(e,t){return x(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var r=[],n=!0,i=!1,o=void 0;try{for(var a,s=e[Symbol.iterator]();!(n=(a=s.next()).done)&&(r.push(a.value),!t||r.length!==t);n=!0);}catch(c){i=!0,o=c}finally{try{n||null==s.return||s.return()}finally{if(i)throw o}}return r}(e,t)||D(e,t)||j()}function j(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function x(e){if(Array.isArray(e))return e}function S(e){if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(e=D(e))){var t=0,r=function(){};return{s:r,n:function(){return t>=e.length?{done:!0}:{done:!1,value:e[t++]}},e:function(e){throw e},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var n,i,o=!0,a=!1;return{s:function(){n=e[Symbol.iterator]()},n:function(){var e=n.next();return o=e.done,e},e:function(e){a=!0,i=e},f:function(){try{o||null==n.return||n.return()}finally{if(a)throw i}}}}function D(e,t){if(e){if("string"==typeof e)return _(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(r):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_(e,t):void 0}}function _(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r1)){var r=[];A._withIDBStore("readonly",function(e){var t,n=S(z);try{for(n.s();!(t=n.n()).done;){var i=P(t.value,2),o=i[0],a=i[1];r.push([a,e.get(o)])}}catch(s){n.e(s)}finally{n.f()}z=[]}).then(function(){var e,t=S(r);try{for(t.s();!(e=t.n()).done;){var n=P(e.value,2);(0,n[0])(n[1].result)}}catch(i){t.e(i)}finally{t.f()}})}})},I=function(e){var t,r,n=S(o.parts);try{for(n.s();!(r=n.n()).done;){var i=r.value;if(void 0!==i.start&&e2&&void 0!==arguments[2]&&arguments[2];return function(){for(var i=arguments.length,o=new Array(i),a=0;a=0;o--){var a=t[e.placement];a.splice(a.indexOf(e.key),1);var s=this.fromElementDescriptor(e),c=this.toElementFinisherExtras((0,i[o])(s)||s);e=c.element,this.addElementPlacement(e,t),c.finisher&&n.push(c.finisher);var l=c.extras;if(l){for(var u=0;u=0;n--){var i=this.fromClassDescriptor(e),o=this.toClassDescriptor((0,t[n])(i)||i);if(void 0!==o.finisher&&r.push(o.finisher),void 0!==o.elements){e=o.elements;for(var a=0;a\n
\n
${this.error}
\n \n go back\n \n
\n \n `;\n }\n\n private _backTapped(): void {\n history.back();\n }\n\n static get styles(): CSSResultArray {\n return [\n css`\n .content {\n height: calc(100% - 64px);\n display: flex;\n align-items: center;\n justify-content: center;\n flex-direction: column;\n }\n `,\n ];\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"hass-error-screen\": HassErrorScreen;\n }\n}\n","import { property, PropertyValues, UpdatingElement } from \"lit-element\";\nimport memoizeOne from \"memoize-one\";\nimport { navigate } from \"../common/navigate\";\nimport { Route } from \"../types\";\nimport \"./hass-error-screen\";\nimport \"./hass-loading-screen\";\n\nconst extractPage = (path: string, defaultPage: string) => {\n if (path === \"\") {\n return defaultPage;\n }\n const subpathStart = path.indexOf(\"/\", 1);\n return subpathStart === -1\n ? path.substr(1)\n : path.substr(1, subpathStart - 1);\n};\n\nexport interface RouteOptions {\n // HTML tag of the route page.\n tag: string;\n // Function to load the page.\n load?: () => Promise;\n cache?: boolean;\n}\n\nexport interface RouterOptions {\n // The default route to show if path does not define a page.\n defaultPage?: string;\n // If all routes should be preloaded\n preloadAll?: boolean;\n // If a route has been shown, should we keep the element in memory\n cacheAll?: boolean;\n // Should we show a loading spinner while we load the element for the route\n showLoading?: boolean;\n // Promise that resolves when the initial data is loaded which is needed to show any route.\n initialLoad?: () => Promise;\n // Hook that is called before rendering a new route. Allowing redirects.\n // If string returned, that page will be rendered instead.\n beforeRender?: (page: string) => string | undefined;\n routes: {\n // If it's a string, it is another route whose options should be adopted.\n [route: string]: RouteOptions | string;\n };\n}\n\n// Time to wait for code to load before we show loading screen.\nconst LOADING_SCREEN_THRESHOLD = 400; // ms\n\nexport class HassRouterPage extends UpdatingElement {\n @property() public route?: Route;\n\n protected routerOptions!: RouterOptions;\n\n protected _currentPage = \"\";\n\n private _currentLoadProm?: Promise;\n\n private _cache = {};\n\n private _initialLoadDone = false;\n\n private _computeTail = memoizeOne((route: Route) => {\n const dividerPos = route.path.indexOf(\"/\", 1);\n return dividerPos === -1\n ? {\n prefix: route.prefix + route.path,\n path: \"\",\n }\n : {\n prefix: route.prefix + route.path.substr(0, dividerPos),\n path: route.path.substr(dividerPos),\n };\n });\n\n protected update(changedProps: PropertyValues) {\n super.update(changedProps);\n\n const routerOptions = this.routerOptions || { routes: {} };\n\n if (routerOptions && routerOptions.initialLoad && !this._initialLoadDone) {\n return;\n }\n\n if (!changedProps.has(\"route\")) {\n // Do not update if we have a currentLoadProm, because that means\n // that there is still an old panel shown and we're moving to a new one.\n if (this.lastChild && !this._currentLoadProm) {\n this.updatePageEl(this.lastChild, changedProps);\n }\n return;\n }\n\n const route = this.route;\n const defaultPage = routerOptions.defaultPage;\n\n if (route && route.path === \"\" && defaultPage !== undefined) {\n navigate(this, `${route.prefix}/${defaultPage}`, true);\n }\n\n let newPage = route\n ? extractPage(route.path, defaultPage || \"\")\n : \"not_found\";\n let routeOptions = routerOptions.routes[newPage];\n\n // Handle redirects\n while (typeof routeOptions === \"string\") {\n newPage = routeOptions;\n routeOptions = routerOptions.routes[newPage];\n }\n\n if (routerOptions.beforeRender) {\n const result = routerOptions.beforeRender(newPage);\n if (result !== undefined) {\n newPage = result;\n routeOptions = routerOptions.routes[newPage];\n\n // Handle redirects\n while (typeof routeOptions === \"string\") {\n newPage = routeOptions;\n routeOptions = routerOptions.routes[newPage];\n }\n\n // Update the url if we know where we're mounted.\n if (route) {\n navigate(this, `${route.prefix}/${result}`, true);\n }\n }\n }\n\n if (this._currentPage === newPage) {\n if (this.lastChild) {\n this.updatePageEl(this.lastChild, changedProps);\n }\n return;\n }\n\n if (!routeOptions) {\n this._currentPage = \"\";\n if (this.lastChild) {\n this.removeChild(this.lastChild);\n }\n return;\n }\n\n this._currentPage = newPage;\n const loadProm = routeOptions.load\n ? routeOptions.load()\n : Promise.resolve();\n\n // Check when loading the page source failed.\n loadProm.catch((err) => {\n // eslint-disable-next-line\n console.error(\"Error loading page\", newPage, err);\n\n // Verify that we're still trying to show the same page.\n if (this._currentPage !== newPage) {\n return;\n }\n\n // Removes either loading screen or the panel\n this.removeChild(this.lastChild!);\n\n // Show error screen\n const errorEl = document.createElement(\"hass-error-screen\");\n errorEl.error = `Error while loading page ${newPage}.`;\n this.appendChild(errorEl);\n });\n\n // If we don't show loading screen, just show the panel.\n // It will be automatically upgraded when loading done.\n if (!routerOptions.showLoading) {\n this._createPanel(routerOptions, newPage, routeOptions);\n return;\n }\n\n // We are only going to show the loading screen after some time.\n // That way we won't have a double fast flash on fast connections.\n let created = false;\n\n setTimeout(() => {\n if (created || this._currentPage !== newPage) {\n return;\n }\n\n // Show a loading screen.\n if (this.lastChild) {\n this.removeChild(this.lastChild);\n }\n this.appendChild(this.createLoadingScreen());\n }, LOADING_SCREEN_THRESHOLD);\n\n this._currentLoadProm = loadProm.then(\n () => {\n this._currentLoadProm = undefined;\n // Check if we're still trying to show the same page.\n if (this._currentPage !== newPage) {\n return;\n }\n\n created = true;\n this._createPanel(\n routerOptions,\n newPage,\n // @ts-ignore TS forgot this is not a string.\n routeOptions\n );\n },\n () => {\n this._currentLoadProm = undefined;\n }\n );\n }\n\n protected firstUpdated(changedProps: PropertyValues) {\n super.firstUpdated(changedProps);\n\n const options = this.routerOptions;\n\n if (!options) {\n return;\n }\n\n if (options.preloadAll) {\n Object.values(options.routes).forEach(\n (route) => typeof route === \"object\" && route.load && route.load()\n );\n }\n\n if (options.initialLoad) {\n setTimeout(() => {\n if (!this._initialLoadDone) {\n this.appendChild(this.createLoadingScreen());\n }\n }, LOADING_SCREEN_THRESHOLD);\n\n options.initialLoad().then(() => {\n this._initialLoadDone = true;\n this.requestUpdate(\"route\");\n });\n }\n }\n\n protected createLoadingScreen() {\n return document.createElement(\"hass-loading-screen\");\n }\n\n /**\n * Rebuild the current panel.\n *\n * Promise will resolve when rebuilding is done and DOM updated.\n */\n protected async rebuild(): Promise {\n const oldRoute = this.route;\n\n if (oldRoute === undefined) {\n return;\n }\n\n this.route = undefined;\n await this.updateComplete;\n // Make sure that the parent didn't override this in the meanwhile.\n if (this.route === undefined) {\n this.route = oldRoute;\n }\n }\n\n /**\n * Promise that resolves when the page has rendered.\n */\n protected get pageRendered(): Promise {\n return this.updateComplete.then(() => this._currentLoadProm);\n }\n\n protected createElement(tag: string) {\n return document.createElement(tag);\n }\n\n protected updatePageEl(_pageEl, _changedProps?: PropertyValues) {\n // default we do nothing\n }\n\n protected get routeTail(): Route {\n return this._computeTail(this.route!);\n }\n\n private _createPanel(\n routerOptions: RouterOptions,\n page: string,\n routeOptions: RouteOptions\n ) {\n if (this.lastChild) {\n this.removeChild(this.lastChild);\n }\n\n const panelEl = this._cache[page] || this.createElement(routeOptions.tag);\n this.updatePageEl(panelEl);\n this.appendChild(panelEl);\n\n if (routerOptions.cacheAll || routeOptions.cache) {\n this._cache[page] = panelEl;\n }\n }\n}\n","import {\n css,\n CSSResult,\n customElement,\n html,\n LitElement,\n property,\n TemplateResult,\n} from \"lit-element\";\nimport { classMap } from \"lit-html/directives/class-map\";\nimport \"../components/ha-menu-button\";\nimport \"../components/ha-icon-button-arrow-prev\";\n\n@customElement(\"hass-subpage\")\nclass HassSubpage extends LitElement {\n @property()\n public header?: string;\n\n @property({ type: Boolean })\n public showBackButton = true;\n\n @property({ type: Boolean })\n public hassio = false;\n\n protected render(): TemplateResult {\n return html`\n