import{a3 as x,a2 as V,_ as B,R as L,S as O,u as $,W as q,k as i,o as y,c as g,d as M,s as v,a as o,p as A,y as u,t as d,l as S,b as H,Q as R}from"./BDipKYNj.js";import{_ as F}from"./WebContentItem-Bpw6xJnG.mjs";import"./WebImage-CIpNTik-.mjs";import"./nuxt-link-BWzEhDJx.mjs";import"./useImageUrl-1XbeiwSF.mjs";/*! vue-countdown v2.1.2 | (c) 2018-present Chen Fengyuan | MIT */const h=1e3,m=60*h,f=60*m,b=24*f,E="abort",w="end",C="progress",N="start",_="visibilitychange";var P=x({name:"VueCountdown",props:{autoStart:{type:Boolean,default:!0},emitEvents:{type:Boolean,default:!0},interval:{type:Number,default:1e3,validator:t=>t>=0},now:{type:Function,default:()=>Date.now()},tag:{type:String,default:"span"},time:{type:Number,default:0,validator:t=>t>=0},transform:{type:Function,default:t=>t}},emits:[E,w,C,N],data(){return{counting:!1,endTime:0,totalMilliseconds:0,requestId:0}},computed:{days(){return Math.floor(this.totalMilliseconds/b)},hours(){return Math.floor(this.totalMilliseconds%b/f)},minutes(){return Math.floor(this.totalMilliseconds%f/m)},seconds(){return Math.floor(this.totalMilliseconds%m/h)},milliseconds(){return Math.floor(this.totalMilliseconds%h)},totalDays(){return this.days},totalHours(){return Math.floor(this.totalMilliseconds/f)},totalMinutes(){return Math.floor(this.totalMilliseconds/m)},totalSeconds(){return Math.floor(this.totalMilliseconds/h)}},watch:{$props:{deep:!0,immediate:!0,handler(){this.totalMilliseconds=this.time,this.endTime=this.now()+this.time,this.autoStart&&this.start()}}},mounted(){document.addEventListener(_,this.handleVisibilityChange)},beforeUnmount(){document.removeEventListener(_,this.handleVisibilityChange),this.pause()},methods:{start(){this.counting||(this.counting=!0,this.autoStart||(this.totalMilliseconds=this.time,this.endTime=this.now()+this.time),this.emitEvents&&this.$emit(N),document.visibilityState==="visible"&&this.continue())},continue(){if(!this.counting)return;const t=Math.min(this.totalMilliseconds,this.interval);if(t>0){let e,l;const s=n=>{e||(e=n),l||(l=n);const a=n-e;a>=t||a+(n-l)/2>=t?this.progress():this.requestId=requestAnimationFrame(s),l=n};this.requestId=requestAnimationFrame(s)}else this.end()},pause(){cancelAnimationFrame(this.requestId)},progress(){this.counting&&(this.update(),this.emitEvents&&this.totalMilliseconds>0&&this.$emit(C,{days:this.days,hours:this.hours,minutes:this.minutes,seconds:this.seconds,milliseconds:this.milliseconds,totalDays:this.totalDays,totalHours:this.totalHours,totalMinutes:this.totalMinutes,totalSeconds:this.totalSeconds,totalMilliseconds:this.totalMilliseconds}),this.continue())},abort(){this.counting&&(this.pause(),this.counting=!1,this.emitEvents&&this.$emit(E))},end(){this.counting&&(this.pause(),this.totalMilliseconds=0,this.counting=!1,this.emitEvents&&this.$emit(w))},update(){this.counting&&(this.totalMilliseconds=Math.max(0,this.endTime-this.now()))},restart(){this.pause(),this.totalMilliseconds=this.time,this.endTime=this.now()+this.time,this.counting=!1,this.start()},handleVisibilityChange(){switch(document.visibilityState){case"visible":this.update(),this.continue();break;case"hidden":this.pause();break}}},render(){return V(this.tag,this.$slots.default?[this.$slots.default(this.transform({days:this.days,hours:this.hours,minutes:this.minutes,seconds:this.seconds,milliseconds:this.milliseconds,totalDays:this.totalDays,totalHours:this.totalHours,totalMinutes:this.totalMinutes,totalSeconds:this.totalSeconds,totalMilliseconds:this.totalMilliseconds}))]:void 0)}});const U={key:0,class:"ebm-countdown-timer"},W={key:0,class:"countdown-timer"},z={__name:"WebCountdownTimer",props:{date:{type:Number},timerStyle:{type:String},timerBackgroundColor:{type:String},textColor:{type:String},webinarSelection:{type:Number},eventSelection:{type:Number},showTitle:{type:Boolean},imagePosition:{type:String},showSummary:{type:Boolean}},setup(t){const e=t,l=a=>{const r={};return Object.entries(a).forEach(([p,c])=>{r[p]=c<10?`0${c}`:String(c)}),r},s=L();O(async()=>{if(e.webinarSelection||e.eventSelection){const{$gql:a}=$(),r=await a.query("getContent",{id:e.webinarSelection||e.eventSelection});r.data&&(s.value=r.data)}});const n=q(()=>({"--timer-background-color":e.timerBackgroundColor?e.timerBackgroundColor:"#fff","--text-color":e.textColor?e.textColor:"#000"}));return(a,r)=>{const p=R,c=F;return t.date||i(s)?(y(),g("div",U,[t.date&&t.date>Date.now()||i(s)&&i(s).startDate>Date.now()?(y(),g("div",W,[M(p,null,{default:v(()=>[M(i(P),{transform:l,time:i(s)?i(s).startDate-Date.now():t.date-Date.now()},{default:v(({days:D,hours:I,minutes:T,seconds:k})=>[o("div",{class:"timer",style:A(i(n))},[o("div",{class:u(["days",t.timerStyle==="circle"?"circle":""])},[o("span",null,d(D),1)],2),o("div",{class:u(["hours",t.timerStyle==="circle"?"circle":""])},[o("span",null,d(I),1)],2),o("div",{class:u(["minutes",t.timerStyle==="circle"?"circle":""])},[o("span",null,d(T),1)],2),o("div",{class:u(["seconds",t.timerStyle==="circle"?"circle":""])},[o("span",null,d(k),1)],2)],4)]),_:1},8,["time"])]),_:1})])):S("",!0),i(s)&&t.showTitle?(y(),H(c,{key:1,class:"content-item",item:i(s),"show-summary":t.showSummary,"show-upcoming-indicator":!1,"hide-primary-section":!0,"hide-published-date":!0,"hide-company-date":!0,"show-date":!1,"display-full-headline":!1,"image-position":t.imagePosition,"image-shaping":"crop","page-company-name":i(s).company,"item-mask":!1},null,8,["item","show-summary","image-position","page-company-name"])):S("",!0)])):S("",!0)}}},K=B(z,[["__scopeId","data-v-3eed1d50"]]);export{K as default};