"use strict";(self.webpackChunkWebComponents=self.webpackChunkWebComponents||[]).push([[915],{86915:(e,t,n)=>{n.r(t);var o=n(78673);class a extends o.A{constructor(e){if(super(e),this.divid=e.orig.id,this.container=$(`#${this.divid}`),this.caption="YouTube",null==document.getElementById("youtubescript")){let e=document.createElement("script");e.id="youtubescript",e.src="https://www.youtube.com/player_api",document.body.appendChild(e)}this.containerDiv=this.container[0].parentElement,this.addCaption("runestone"),this.indicate_component_ready()}}window.onPlayerStateChange=function(e){let t=new o.A,n=e.target.getCurrentTime(),a={event:"video",div_id:e.target.getIframe().id};e.data==YT.PlayerState.PLAYING?(console.log("playing "+e.target.getIframe().id),a.act="play:"+n):e.data==YT.PlayerState.ENDED?(console.log("ended "+e.target.getIframe().id),a.act="complete"):e.data==YT.PlayerState.PAUSED?(console.log("paused at "+n),a.act="pause:"+n):(console.log(`YT Player State: ${YT.PlayerState}`),a.act="ready"),t.logBookEvent(a)},window.onYouTubeIframeAPIReady=function(){$(".youtube-video").each((function(e,t){let n={};n.start=$(t).data("video-start"),-1!=$(t).data("video-end")&&(n.end=$(t).data("video-end")),new YT.Player($(t).data("video-divid"),{height:$(t).data("video-height"),width:$(t).data("video-width"),videoId:$(t).data("video-videoid"),align:"center",playerVars:n,events:{onStateChange:window.onPlayerStateChange}})}))},$((function(){let e=document.createElement("script");e.src="https://www.youtube.com/player_api",document.body.appendChild(e)})),$(document).on("runestone:login-complete",(function(){$("[data-component=youtube]").each((function(e){var t={orig:this,useRunestoneServices:eBookConfig.useRunestoneServices};window.componentMap[this.id]=new a(t)}))})),void 0===window.component_factory&&(window.component_factory={}),window.component_factory.youtube=function(e){return new a(e)},window.component_factory.vimeo=function(e){return new a(e)}}}]);
//# sourceMappingURL=915.js.map