"use strict";(self.webpackChunkhome_assistant_frontend=self.webpackChunkhome_assistant_frontend||[]).push([["20283"],{90409:function(t,e,n){n.d(e,{A:function(){return i}});n(18111),n(61701);function i(t){const e=t.split(":").map(Number);return 3600*e[0]+60*e[1]+e[2]}},27167:function(t,e,n){n.d(e,{A:function(){return a}});const i=t=>t<10?`0${t}`:t;function a(t){const e=Math.floor(t/3600),n=Math.floor(t%3600/60),a=Math.floor(t%3600%60);return e>0?`${e}:${i(n)}:${i(a)}`:n>0?`${n}:${i(a)}`:a>0?""+a:null}},49141:function(t,e,n){n.d(e,{CR:function(){return s},PF:function(){return o},kL:function(){return r},ls:function(){return c},pZ:function(){return u},r9:function(){return l}});var i=n(90409),a=n(27167);const r=t=>t.callWS({type:"timer/list"}),s=(t,e)=>t.callWS(Object.assign({type:"timer/create"},e)),l=(t,e,n)=>t.callWS(Object.assign({type:"timer/update",timer_id:e},n)),u=(t,e)=>t.callWS({type:"timer/delete",timer_id:e}),c=t=>{if(!t.attributes.remaining)return;let e=(0,i.A)(t.attributes.remaining);if("active"===t.state){const n=(new Date).getTime(),i=new Date(t.attributes.finishes_at).getTime();e=Math.max((i-n)/1e3,0)}return e},o=(t,e,n)=>{if(!e)return null;if("idle"===e.state||0===n)return t.formatEntityState(e);let i=(0,a.A)(n||0)||"0";return"paused"===e.state&&(i=`${i} (${t.formatEntityState(e)})`),i}},5078:function(t,e,n){n.r(e);var i=n(40445),a=n(96196),r=n(77845),s=n(49141);class l extends a.mN{createRenderRoot(){return this}update(t){var e;super.update(t),this.innerHTML=null!==(e=(0,s.PF)(this.hass,this.stateObj,this.timeRemaining))&&void 0!==e?e:"-"}connectedCallback(){super.connectedCallback(),this.stateObj&&this._startInterval(this.stateObj)}disconnectedCallback(){super.disconnectedCallback(),this._clearInterval()}willUpdate(t){super.willUpdate(t),t.has("stateObj")&&this._startInterval(this.stateObj)}_clearInterval(){this._updateRemaining&&(clearInterval(this._updateRemaining),this._updateRemaining=null)}_startInterval(t){this._clearInterval(),this._calculateRemaining(t),"active"===t.state&&(this._updateRemaining=setInterval(()=>this._calculateRemaining(this.stateObj),1e3))}_calculateRemaining(t){this.timeRemaining=(0,s.ls)(t)}}(0,i.Cg)([(0,r.MZ)({attribute:!1})],l.prototype,"hass",void 0),(0,i.Cg)([(0,r.MZ)({attribute:!1})],l.prototype,"stateObj",void 0),(0,i.Cg)([(0,r.wk)()],l.prototype,"timeRemaining",void 0),l=(0,i.Cg)([(0,r.EM)("ha-timer-remaining-time")],l)}}]);
//# sourceMappingURL=20283.a8d57b5b2303b9cb.js.map