"use strict";function onYouTubeIframeAPIReady(){for(var t=document.querySelectorAll("div[data-selector='youtubeVideo']"),n=0;n<t.length;n++)EC.YoutubeInserter.SetVideoDimension(EC.YoutubeInserter.CreatePlayer(t[n]))}var EC=EC||{};EC.YoutubeInserter=EC.YoutubeInserter||{};EC.YoutubeInserter.Object={apiInserted:!1,players:[]};EC.YoutubeInserter.Debounce=function(n,t,i){var r;return function(){var u=this,f=arguments,e=function(){r=null;i||n.apply(u,f)},o=i&&!r;clearTimeout(r);r=setTimeout(e,t);o&&n.apply(u,f)}};EC.YoutubeInserter.InsertApi=function(){var t=document.createElement("script"),n;t.src="https://www.youtube.com/iframe_api";n=document.getElementsByTagName("script")[0];n.parentNode.insertBefore(t,n);EC.YoutubeInserter.Object.apiInserted=!0};EC.YoutubeInserter.CreatePlayer=function(n){if(!YT)return console.error("YT is undefined. Please insert the youtube iframe api: https://www.youtube.com/iframe_api"),undefined;var t=new YT.Player(n.id,{height:"390",width:"640",videoId:n.id,events:{onReady:EC.YoutubeInserter.OnPlayerReady,onStateChange:EC.YoutubeInserter.OnPlayerStateChange}});return EC.YoutubeInserter.Object.players.push(t),t};EC.YoutubeInserter.SetVideoDimensions=EC.YoutubeInserter.Debounce(function(){for(var t,n=0;n<EC.YoutubeInserter.Object.players.length;n++)t=EC.YoutubeInserter.Object.players[n],EC.YoutubeInserter.SetVideoDimension(t)},250,!1);EC.YoutubeInserter.SetVideoDimension=function(n){var r=n.h.parentElement.getBoundingClientRect().width-5,t=n.h.getBoundingClientRect().width,u=n.h.getBoundingClientRect().height,i=Math.round(r/t*100)/100;n.h.width=t*i;n.h.height=u*i};EC.YoutubeInserter.Init=function(){EC.YoutubeInserter.Object.apiInserted||EC.YoutubeInserter.InsertApi()};window.onload=function(){EC.YoutubeInserter.Init();window.addEventListener("resize",EC.YoutubeInserter.SetVideoDimensions)}