var TF_Video_Init=function(){function e(){this.players=[],this.init()}var i=e.prototype;return i.init=function(){var e,t,i;this.initEvents(),window.IntersectionObserver&&(e=document.querySelectorAll(".nrf-widget.tf-video:not(.done)"))&&(t=this,i=new IntersectionObserver(function(e,i){e.forEach(function(e){var i;e.isIntersecting?(i=e.target).classList.contains("done")||i.querySelector(".tf-video-embed-overlay")&&!i.classList.contains("hiddenOverlay")&&"true"!==i.querySelector(".tf-video-embed").dataset.videoAutoplay||t.startVideo(i):(i=e.target).classList.contains("done")&&"videoAutopause"in i.querySelector(".tf-video-embed").dataset&&"false"!==i.querySelector(".tf-video-embed").dataset.videoAutopause&&t.pauseVideo(i)})},{rootMargin:"0px 0px 0px 0px"}),e.forEach(function(e){i.observe(e)}))},i.startVideo=function(e){switch(e.classList.add("done"),e.querySelector(".tf-video-embed").dataset.videoType){case"youtube":this.players[e.id]=new TF_YouTube_Video(e),this.players[e.id].init();break;case"vimeo":this.players[e.id]=new TF_Vimeo_Video(e),this.players[e.id].init();break;case"facebookvideo":this.players[e.id]=new TF_FacebookVideo_Video(e),this.players[e.id].init();break;case"dailymotion":this.players[e.id]=new TF_Dailymotion_Video(e),this.players[e.id].init();break;case"selfhostedvideo":this.players[e.id]=new TF_SelfHostedVideo_Video(e),this.players[e.id].init()}},i.pauseVideo=function(e){this.players[e.id].pause()},i.initEvents=function(){document.addEventListener("click",function(e){this.onCoverClose(e)}.bind(this))},i.onCoverClose=function(e){var e=e.target.closest(".tf-video-embed-overlay");e&&((e=e.closest(".nrf-widget.tf-video")).classList.add("hiddenOverlay"),this.startVideo(e))},e}();document.addEventListener("DOMContentLoaded",function(){new TF_Video_Init});

