(self.webpackChunkhome_assistant_frontend=self.webpackChunkhome_assistant_frontend||[]).push([[8664],{62021:function(e,t,n){"use strict";n.d(t,{HD:function(){return r},oO:function(){return i},p6:function(){return o},jt:function(){return a}});var r=function(e){return e.callWS({type:"person/list"})},i=function(e,t){return e.callWS(Object.assign({type:"person/create"},t))},o=function(e,t,n){return e.callWS(Object.assign({type:"person/update",person_id:t},n))},a=function(e,t){return e.callWS({type:"person/delete",person_id:t})}},65253:function(e,t,n){"use strict";function r(e,t,n,r,i,o,a){try{var s=e[o](a),c=s.value}catch(u){return void n(u)}s.done?t(c):Promise.resolve(c).then(r,i)}function i(e){return function(){var t=this,n=arguments;return new Promise((function(i,o){var a=e.apply(t,n);function s(e){r(a,i,o,s,c,"next",e)}function c(e){r(a,i,o,s,c,"throw",e)}s(void 0)}))}}n.d(t,{Pb:function(){return o},CE:function(){return a},uh:function(){return s},r4:function(){return c},Nq:function(){return u},h8:function(){return l}});var o="system-admin",a="system-users",s=function(){var e=i(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",t.callWS({type:"config/auth/list"}));case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),c=function(){var e=i(regeneratorRuntime.mark((function e(t,n,r){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",t.callWS({type:"config/auth/create",name:n,group_ids:r}));case 1:case"end":return e.stop()}}),e)})));return function(t,n,r){return e.apply(this,arguments)}}(),u=function(){var e=i(regeneratorRuntime.mark((function e(t,n,r){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",t.callWS(Object.assign({},r,{type:"config/auth/update",user_id:n})));case 1:case"end":return e.stop()}}),e)})));return function(t,n,r){return e.apply(this,arguments)}}(),l=function(){var e=i(regeneratorRuntime.mark((function e(t,n){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",t.callWS({type:"config/auth/delete",user_id:n}));case 1:case"end":return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}()},18873:function(e,t,n){"use strict";n.r(t),n.d(t,{HaPanelLogbook:function(){return F}});var r=n(55317),i=(n(53268),n(12730),n(15652)),o=n(87744),a=(n(74535),n(31206),n(44491),n(10983),n(48932),n(55422)),s=n(62021),c=n(65253),u=(n(27849),n(11654));n(97740);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 f(){var e=w(["\n        ha-logbook,\n        .progress-wrapper {\n          height: calc(100vh - 136px);\n        }\n\n        :host([narrow]) ha-logbook,\n        :host([narrow]) .progress-wrapper {\n          height: calc(100vh - 198px);\n        }\n\n        ha-date-range-picker {\n          margin-right: 16px;\n          max-width: 100%;\n        }\n\n        :host([narrow]) ha-date-range-picker {\n          margin-right: 0;\n        }\n\n        .progress-wrapper {\n          position: relative;\n        }\n\n        ha-circular-progress {\n          position: absolute;\n          left: 50%;\n          top: 50%;\n          transform: translate(-50%, -50%);\n        }\n\n        .filters {\n          display: flex;\n          align-items: flex-end;\n          padding: 0 16px;\n        }\n\n        :host([narrow]) .filters {\n          flex-wrap: wrap;\n        }\n\n        ha-entity-picker {\n          display: inline-block;\n          flex-grow: 1;\n          max-width: 400px;\n        }\n\n        :host([narrow]) ha-entity-picker {\n          max-width: none;\n          width: 100%;\n        }\n      "]);return f=function(){return e},e}function d(e,t){return M(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var n=[],r=!0,i=!1,o=void 0;try{for(var a,s=e[Symbol.iterator]();!(r=(a=s.next()).done)&&(n.push(a.value),!t||n.length!==t);r=!0);}catch(c){i=!0,o=c}finally{try{r||null==s.return||s.return()}finally{if(i)throw o}}return n}(e,t)||A(e,t)||T()}function h(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=A(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}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 o,a=!0,s=!1;return{s:function(){n=e[Symbol.iterator]()},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw o}}}}function p(e,t,n,r,i,o,a){try{var s=e[o](a),c=s.value}catch(u){return void n(u)}s.done?t(c):Promise.resolve(c).then(r,i)}function y(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var o=e.apply(t,n);function a(e){p(o,r,i,a,s,"next",e)}function s(e){p(o,r,i,a,s,"throw",e)}a(void 0)}))}}function m(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function v(){var e=w(["\n              <ha-logbook\n                .hass=","\n                .entries=","\n                .userIdToName=","\n                virtualize\n              ></ha-logbook>\n            "]);return v=function(){return e},e}function g(){var e=w(['\n              <div class="progress-wrapper">\n                <ha-circular-progress\n                  active\n                  alt=',"\n                ></ha-circular-progress>\n              </div>\n            "]);return g=function(){return e},e}function b(){var e=w([""]);return b=function(){return e},e}function k(){var e=w(['\n      <ha-app-layout>\n        <app-header slot="header" fixed>\n          <app-toolbar>\n            <ha-menu-button\n              .hass=',"\n              .narrow=","\n            ></ha-menu-button>\n            <div main-title>","</div>\n            <mwc-icon-button\n              @click=","\n              .disabled=","\n            >\n              <ha-svg-icon .path=","></ha-svg-icon>\n            </mwc-icon-button>\n          </app-toolbar>\n        </app-header>\n\n        ",'\n\n        <div class="filters">\n          <ha-date-range-picker\n            .hass=',"\n            ?disabled=","\n            .startDate=","\n            .endDate=","\n            .ranges=","\n            @change=","\n          ></ha-date-range-picker>\n\n          <ha-entity-picker\n            .hass=","\n            .value=","\n            .label=","\n            .disabled=","\n            @change=","\n          ></ha-entity-picker>\n        </div>\n\n        ","\n      </ha-app-layout>\n    "]);return k=function(){return e},e}function w(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 _(e){var t=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}}();return function(){var n,r=H(e);if(t){var i=H(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return E(this,n)}}function E(e,t){return!t||"object"!==l(t)&&"function"!=typeof t?S(e):t}function S(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function x(){x=function(){return e};var e={elementsDefinitionOrder:[["method"],["field"]],initializeInstanceElements:function(e,t){["method","field"].forEach((function(n){t.forEach((function(t){t.kind===n&&"own"===t.placement&&this.defineClassElement(e,t)}),this)}),this)},initializeClassElements:function(e,t){var n=e.prototype;["method","field"].forEach((function(r){t.forEach((function(t){var i=t.placement;if(t.kind===r&&("static"===i||"prototype"===i)){var o="static"===i?e:n;this.defineClassElement(o,t)}}),this)}),this)},defineClassElement:function(e,t){var n=t.descriptor;if("field"===t.kind){var r=t.initializer;n={enumerable:n.enumerable,writable:n.writable,configurable:n.configurable,value:void 0===r?void 0:r.call(e)}}Object.defineProperty(e,t.key,n)},decorateClass:function(e,t){var n=[],r=[],i={static:[],prototype:[],own:[]};if(e.forEach((function(e){this.addElementPlacement(e,i)}),this),e.forEach((function(e){if(!C(e))return n.push(e);var t=this.decorateElement(e,i);n.push(t.element),n.push.apply(n,t.extras),r.push.apply(r,t.finishers)}),this),!t)return{elements:n,finishers:r};var o=this.decorateConstructor(n,t);return r.push.apply(r,o.finishers),o.finishers=r,o},addElementPlacement:function(e,t,n){var r=t[e.placement];if(!n&&-1!==r.indexOf(e.key))throw new TypeError("Duplicated element ("+e.key+")");r.push(e.key)},decorateElement:function(e,t){for(var n=[],r=[],i=e.decorators,o=i.length-1;o>=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&&r.push(c.finisher);var u=c.extras;if(u){for(var l=0;l<u.length;l++)this.addElementPlacement(u[l],t);n.push.apply(n,u)}}return{element:e,finishers:r,extras:n}},decorateConstructor:function(e,t){for(var n=[],r=t.length-1;r>=0;r--){var i=this.fromClassDescriptor(e),o=this.toClassDescriptor((0,t[r])(i)||i);if(void 0!==o.finisher&&n.push(o.finisher),void 0!==o.elements){e=o.elements;for(var a=0;a<e.length-1;a++)for(var s=a+1;s<e.length;s++)if(e[a].key===e[s].key&&e[a].placement===e[s].placement)throw new TypeError("Duplicated element ("+e[a].key+")")}}return{elements:e,finishers:n}},fromElementDescriptor:function(e){var t={kind:e.kind,key:e.key,placement:e.placement,descriptor:e.descriptor};return Object.defineProperty(t,Symbol.toStringTag,{value:"Descriptor",configurable:!0}),"field"===e.kind&&(t.initializer=e.initializer),t},toElementDescriptors:function(e){var t;if(void 0!==e)return(t=e,M(t)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(t)||A(t)||T()).map((function(e){var t=this.toElementDescriptor(e);return this.disallowProperty(e,"finisher","An element descriptor"),this.disallowProperty(e,"extras","An element descriptor"),t}),this)},toElementDescriptor:function(e){var t=String(e.kind);if("method"!==t&&"field"!==t)throw new TypeError('An element descriptor\'s .kind property must be either "method" or "field", but a decorator created an element descriptor with .kind "'+t+'"');var n=z(e.key),r=String(e.placement);if("static"!==r&&"prototype"!==r&&"own"!==r)throw new TypeError('An element descriptor\'s .placement property must be one of "static", "prototype" or "own", but a decorator created an element descriptor with .placement "'+r+'"');var i=e.descriptor;this.disallowProperty(e,"elements","An element descriptor");var o={kind:t,key:n,placement:r,descriptor:Object.assign({},i)};return"field"!==t?this.disallowProperty(e,"initializer","A method descriptor"):(this.disallowProperty(i,"get","The property descriptor of a field descriptor"),this.disallowProperty(i,"set","The property descriptor of a field descriptor"),this.disallowProperty(i,"value","The property descriptor of a field descriptor"),o.initializer=e.initializer),o},toElementFinisherExtras:function(e){return{element:this.toElementDescriptor(e),finisher:R(e,"finisher"),extras:this.toElementDescriptors(e.extras)}},fromClassDescriptor:function(e){var t={kind:"class",elements:e.map(this.fromElementDescriptor,this)};return Object.defineProperty(t,Symbol.toStringTag,{value:"Descriptor",configurable:!0}),t},toClassDescriptor:function(e){var t=String(e.kind);if("class"!==t)throw new TypeError('A class descriptor\'s .kind property must be "class", but a decorator created a class descriptor with .kind "'+t+'"');this.disallowProperty(e,"key","A class descriptor"),this.disallowProperty(e,"placement","A class descriptor"),this.disallowProperty(e,"descriptor","A class descriptor"),this.disallowProperty(e,"initializer","A class descriptor"),this.disallowProperty(e,"extras","A class descriptor");var n=R(e,"finisher");return{elements:this.toElementDescriptors(e.elements),finisher:n}},runClassFinishers:function(e,t){for(var n=0;n<t.length;n++){var r=(0,t[n])(e);if(void 0!==r){if("function"!=typeof r)throw new TypeError("Finishers must return a constructor.");e=r}}return e},disallowProperty:function(e,t,n){if(void 0!==e[t])throw new TypeError(n+" can't have a ."+t+" property.")}};return e}function P(e){var t,n=z(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 r={kind:"field"===e.kind?"field":"method",key:n,placement:e.static?"static":"field"===e.kind?"own":"prototype",descriptor:t};return e.decorators&&(r.decorators=e.decorators),"field"===e.kind&&(r.initializer=e.value),r}function O(e,t){void 0!==e.descriptor.get?t.descriptor.get=e.descriptor.get:t.descriptor.set=e.descriptor.set}function C(e){return e.decorators&&e.decorators.length}function j(e){return void 0!==e&&!(void 0===e.value&&void 0===e.writable)}function R(e,t){var n=e[t];if(void 0!==n&&"function"!=typeof n)throw new TypeError("Expected '"+t+"' to be a function");return n}function z(e){var t=function(e,t){if("object"!==l(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!==l(r))return r;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 T(){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 A(e,t){if(e){if("string"==typeof e)return I(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?I(e,t):void 0}}function I(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function M(e){if(Array.isArray(e))return e}function L(e,t,n){return(L="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,n){var r=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=H(e)););return e}(e,t);if(r){var i=Object.getOwnPropertyDescriptor(r,t);return i.get?i.get.call(n):i.value}})(e,t,n||e)}function H(e){return(H=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var F=function(e,t,n,r){var i=x();if(r)for(var o=0;o<r.length;o++)i=r[o](i);var a=t((function(e){i.initializeInstanceElements(e,s.elements)}),n),s=i.decorateClass(function(e){for(var t=[],n=function(e){return"method"===e.kind&&e.key===o.key&&e.placement===o.placement},r=0;r<e.length;r++){var i,o=e[r];if("method"===o.kind&&(i=t.find(n)))if(j(o.descriptor)||j(i.descriptor)){if(C(o)||C(i))throw new ReferenceError("Duplicated methods ("+o.key+") can't be decorated.");i.descriptor=o.descriptor}else{if(C(o)){if(C(i))throw new ReferenceError("Decorators can't be placed on different accessors with for the same property ("+o.key+").");i.decorators=o.decorators}O(o,i)}else t.push(o)}return t}(a.d.map(P)),e);return i.initializeClassElements(a.F,s.elements),i.runClassFinishers(a.F,s.finishers)}([(0,i.Mo)("ha-panel-logbook")],(function(e,t){var n,l,p=function(t){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&D(e,t)}(r,t);var n=_(r);function r(){var t;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,r),t=n.call(this),e(S(t));var i=new Date;i.setHours(i.getHours()-2),i.setMinutes(0),i.setSeconds(0),i.setMilliseconds(0),t._startDate=i;var o=new Date;return o.setHours(o.getHours()+1),o.setMinutes(0),o.setSeconds(0),o.setMilliseconds(0),t._endDate=o,t}return r}(t);return{F:p,d:[{kind:"field",decorators:[(0,i.Cb)()],key:"hass",value:void 0},{kind:"field",decorators:[(0,i.Cb)({reflect:!0,type:Boolean})],key:"narrow",value:void 0},{kind:"field",decorators:[(0,i.Cb)({attribute:!1})],key:"_userIdToName",value:function(){return{}}},{kind:"field",decorators:[(0,i.Cb)()],key:"_startDate",value:void 0},{kind:"field",decorators:[(0,i.Cb)()],key:"_endDate",value:void 0},{kind:"field",decorators:[(0,i.Cb)()],key:"_entityId",value:function(){return""}},{kind:"field",decorators:[(0,i.Cb)()],key:"_isLoading",value:function(){return!1}},{kind:"field",decorators:[(0,i.Cb)()],key:"_entries",value:function(){return[]}},{kind:"field",decorators:[(0,i.Cb)({reflect:!0,type:Boolean})],key:"rtl",value:function(){return!1}},{kind:"field",decorators:[(0,i.sz)()],key:"_ranges",value:void 0},{kind:"field",key:"_fetchUserDone",value:void 0},{kind:"method",key:"render",value:function(){return(0,i.dy)(k(),this.hass,this.narrow,this.hass.localize("panel.logbook"),this._refreshLogbook,this._isLoading,r.jcD,this._isLoading?(0,i.dy)(b()):"",this.hass,this._isLoading,this._startDate,this._endDate,this._ranges,this._dateRangeChanged,this.hass,this._entityId,this.hass.localize("ui.components.entity.entity-picker.entity"),this._isLoading,this._entityPicked,this._isLoading?(0,i.dy)(g(),this.hass.localize("ui.common.loading")):(0,i.dy)(v(),this.hass,this._entries,this._userIdToName))}},{kind:"method",key:"firstUpdated",value:function(e){var t;L(H(p.prototype),"firstUpdated",this).call(this,e),this.hass.loadBackendTranslation("title"),this._fetchUserDone=this._fetchUserNames();var n=new Date;n.setHours(0,0,0,0);var r=new Date(n);r.setDate(r.getDate()+1),r.setMilliseconds(r.getMilliseconds()-1);var i=new Date(n),o=new Date(i.setDate(n.getDate()-1)),a=new Date(o);a.setDate(a.getDate()+1),a.setMilliseconds(a.getMilliseconds()-1);var s=new Date(i.setDate(n.getDate()-n.getDay())),c=new Date(i.setDate(s.getDate()+7));c.setMilliseconds(c.getMilliseconds()-1);var u=new Date(i.setDate(n.getDate()-n.getDay()-7)),l=new Date(i.setDate(u.getDate()+7));l.setMilliseconds(l.getMilliseconds()-1),this._ranges=(m(t={},this.hass.localize("ui.panel.logbook.ranges.today"),[n,r]),m(t,this.hass.localize("ui.panel.logbook.ranges.yesterday"),[o,a]),m(t,this.hass.localize("ui.panel.logbook.ranges.this_week"),[s,c]),m(t,this.hass.localize("ui.panel.logbook.ranges.last_week"),[u,l]),t)}},{kind:"method",key:"updated",value:function(e){if((e.has("_startDate")||e.has("_endDate")||e.has("_entityId"))&&this._getData(),e.has("hass")){var t=e.get("hass");t&&t.language===this.hass.language||(this.rtl=(0,o.HE)(this.hass))}}},{kind:"method",key:"_fetchUserNames",value:(l=y(regeneratorRuntime.mark((function e(){var t,n,r,i,o,a,u,l,f,d,p,y,m,v;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t={},n=(0,s.HD)(this.hass),r=this.hass.user.is_admin&&(0,c.uh)(this.hass),e.next=5,n;case 5:i=e.sent,o=h(i.storage);try{for(o.s();!(a=o.n()).done;)(u=a.value).user_id&&(t[u.user_id]=u.name)}catch(g){o.e(g)}finally{o.f()}l=h(i.config);try{for(l.s();!(f=l.n()).done;)(d=f.value).user_id&&(t[d.user_id]=d.name)}catch(g){l.e(g)}finally{l.f()}if(!r){e.next=16;break}return e.next=13,r;case 13:p=e.sent,y=h(p);try{for(y.s();!(m=y.n()).done;)(v=m.value).id in t||(t[v.id]=v.name)}catch(g){y.e(g)}finally{y.f()}case 16:this._userIdToName=t;case 17:case"end":return e.stop()}}),e,this)}))),function(){return l.apply(this,arguments)})},{kind:"method",key:"_dateRangeChanged",value:function(e){this._startDate=e.detail.startDate;var t=e.detail.endDate;0===t.getHours()&&0===t.getMinutes()&&(t.setDate(t.getDate()+1),t.setMilliseconds(t.getMilliseconds()-1)),this._endDate=t}},{kind:"method",key:"_entityPicked",value:function(e){this._entityId=e.target.value}},{kind:"method",key:"_refreshLogbook",value:function(){this._entries=[],(0,a.tf)(this._startDate.toISOString(),this._endDate.toISOString()),this._getData()}},{kind:"method",key:"_getData",value:(n=y(regeneratorRuntime.mark((function e(){var t,n,r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._isLoading=!0,e.next=3,Promise.all([(0,a.rM)(this.hass,this._startDate.toISOString(),this._endDate.toISOString(),this._entityId),this._fetchUserDone]);case 3:t=e.sent,n=d(t,1),r=n[0],this._entries=r,this._isLoading=!1;case 8:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{kind:"get",static:!0,key:"styles",value:function(){return[u.Qx,(0,i.iv)(f())]}}]}}),i.oi)}}]);
//# sourceMappingURL=chunk.fb0956124dc1eafbc119.js.map