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