import{useState as e,useEffect as t,useMemo as n}from"react";let getCountDownTime=e=>new Date(e).getTime()-new Date().getTime(),useCountdown=n=>{let[r,u]=e(getCountDownTime(n));return t(()=>{let e=null;return r>0&&(e=setInterval(()=>{r>0?u(getCountDownTime(n)):e&&(clearInterval(e),e=null)},1e3)),()=>{e&&clearInterval(e)}},[r,n]),t(()=>{u(getCountDownTime(n))},[n]),getReturnValues(r)},getReturnValues=e=>{let t=Math.floor(e/6e4),n=Math.floor(e%6e4/1e3),r=`${t<10?"0":""}${t}:${n<10?"0":""}${n}`;return{isExpired:t+n<=0,format:r}},useGetTextExpired=e=>{let{isExpired:t,expiredText:r,conditionText:u,format:l}=e,o=n(()=>t?r:`${u} <span dir="ltr">${l}</span>`,[t,l,u,r]);return{text:o}};export{useCountdown,useGetTextExpired};
