import{a as v,p as n,fs as x,j as S,O as h,fB as g,i as l,fj as T}from"./bundle.CHKSNOJF.js";l.extend(T);const b=t=>{const r=Math.floor(t/3600),c=Math.floor(t%3600/60),s=t%60;return`${r}:${c.toString().padStart(2,"0")}:${s.toString().padStart(2,"0")}`};function y(t){const r=v(),[c,s]=n.useState(0),i=t.task&&x(t.task),e=n.useRef(void 0),u=n.useRef(0),m=n.useRef(0),f=()=>{const a=Number(g(t.task.time_log,{inSeconds:!0,calculateLastTimeLog:!!t.calculateLastTimeLog}));m.current=a,u.current=l().unix(),s(a)},d=()=>{e.current&&clearInterval(e.current),e.current=setInterval(()=>{const a=l().unix()-u.current;s(m.current+a)},1e3)},o=()=>{document.visibilityState==="visible"&&i&&(f(),d())};return n.useEffect(()=>(e.current&&(clearInterval(e.current),document.removeEventListener("visibilitychange",o)),i&&(f(),d(),document.addEventListener("visibilitychange",o)),()=>{e.current&&clearInterval(e.current),document.removeEventListener("visibilitychange",o)}),[t.task.updated_at]),S.jsx("p",{className:h("font-mono",{"text-xs":t.extraSmallText,"text-sm":!t.extraSmallText}),style:{color:r.$17},children:i&&b(c)})}export{y as T,b as f};
