document.addEventListener("alpine:init",()=>{Alpine.data("detailLiveDraw",()=>({isLive:!1,timer:{hours:0,minutes:0,seconds:0},countdown:null,resultDefault:{periode:"----",dates:moment().format("dddd, DD MMMM YYYY HH:mm:ss"),p1:"----",p2:"----",p3:"----",lp:["----","----","----","----","----","----","----","----","----","----"],cn:["----","----","----","----","----","----","----","----","----","----"]},result:null,timeLoop:1e4,init(){this.result=this.resultDefault,this.getData()},get statIsLive(){let t=document.querySelector('meta[name="timeClose"]').getAttribute("content"),e=moment().unix(),s=moment(t,"HH:mm:ss").unix(),i=moment(t,"HH:mm:ss").add(30,"minutes").unix();return e>=s&&e<=i},getData(){let t=document.querySelector('meta[name="timeClose"]').getAttribute("content"),e=moment().unix(),s=moment(t,"HH:mm:ss").unix(),i=moment(t,"HH:mm:ss").add(30,"minutes").unix();this.isLive=e>=s&&e<=i;let n=s>e?moment(t,"HH:mm:ss").format("YYYY-MM-DD HH:mm:ss"):moment(t,"HH:mm:ss").add(1,"day").format("YYYY-MM-DD HH:mm:ss");$this=this,this.countdown=this.isLive?null:countdown(new Date(n),m=>$this.updateTimer(m),countdown.HOURS|countdown.MINUTES|countdown.SECONDS)},stopCountDown(){setTimeout(()=>{this.isLive=!0,window.clearInterval(this.countdown),this.stream()})},updateTimer(t){const{hours:e,minutes:s,seconds:i}=t;setTimeout(()=>{this.timer={hours:e,minutes:s,seconds:i}}),e==0&&s==0&&i==0&&this.stopCountDown()},addZero(t){return t.toString().length==1?"0"+t:t},stream(){let e="/client/blog/liveDraw/stream/"+document.querySelector('meta[name="idPas"]').getAttribute("content");axios.get(e).then(s=>{const{status:i,data:n,message:m}=s.data;i?(this.result=n,this.getStatIsLive&&setTimeout(()=>this.stream(),this.timeLoop)):Toast(m)}).catch(s=>{Toast(s.message)})}}))});
