text: define(["exports","../../../lit-element/lit-element.js"],(function(t,e){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.A11yMediaYoutube=void 0;
  /**
     * Copyright 2018 The Pennsylvania State University
     * @license Apache-2.0, see License.md for full text.
     */
  class A11yMediaYoutube extends e.LitElement{static get tag(){return"a11y-media-youtube"}static get styles(){return[e.css`
          iframe .ytp-pause-overlay {
            display: none !important;
          }
        `]}render(){return e.html`
        <slot></slot>
      `}static get properties(){return{...super.properties,id:{type:String},autoplay:{type:Boolean},height:{type:String},loop:{type:Boolean},muted:{type:Boolean},preload:{type:String,attribute:"preload",reflect:!0},playbackRate:{type:Number},t:{type:Number,attribute:"t",reflect:!0},videoId:{type:String,attribute:"video-id",reflect:!0},volume:{type:Number},width:{type:String},__video:{type:Object},__yt:{type:Object}}}constructor(){super(),this.autoplay=!1,this.height="100%",this.loop=!1,this.playbackRate=1,this.preload="metadata",this.muted=!1,this.volume=.7,this.width="100%",this.__video=null,this.__yt=null}get api(){let t=window.document.getElementById("a11y-media-youtube-api");return t||(t=document.createElement("script"),t.setAttribute("id","a11y-media-youtube-api"),t.setAttribute("src","https://www.youtube.com/iframe_api"),t.setAttribute("type","text/javascript"),window.document.body.appendChild(t)),t}get buffered(){return this.__yt&&this.__yt.buffered&&this.__yt.buffered.length>0?this.__yt.buffered.end(0):-1}get currentTime(){return this.__yt&&this.__yt.getCurrentTime?this.__yt.getCurrentTime():void 0}get duration(){return this.__yt&&this.__yt.getDuration?this.__yt.getDuration():0}get paused(){return!this.__yt||!this.__yt.getPlayerState||1!==this.__yt.getPlayerState()}get seekable(){let t={length:0};return this.duration>0&&(t.length=1,t.start=t=>0,t.end=t=>this.duration),t}init(){window.A11yMediaYoutubeManager=window.A11yMediaYoutubeManager||{getIframes:()=>{window.A11yMediaYoutubeManager.queue.forEach(t=>t.__yt=t._preloadVideo(!0)),window.A11yMediaYoutubeManager.queue=[]},queue:[]},window.A11yMediaYoutubeManager.queue.push(this),window.A11yMediaYoutubeManager.api?window.YT&&window.A11yMediaYoutubeManager.getIframes():(window.onYouTubeIframeAPIReady=t=>window.A11yMediaYoutubeManager.getIframes(),window.A11yMediaYoutubeManager.api=this.api)}updated(t){let e=!1,i=!1,a=!1;t.forEach((t,s)=>{"muted"===s&&this.setMute(this.muted),"loop"===s&&this.setLoop(this.loop),"currentTime"===s&&this.seek(this.currentTime),"playbackRate"===s&&this.setPlaybackRate(this.playbackRate),"volume"===s&&this.setVolume(this.volume),"videoId"===s&&this.videoId&&!this.__yt&&this.init(),["id","height","width","preload"].includes(s)&&this.__yt&&(e=!0),["autoplay","videoId","__video"].includes(s)&&this.__video&&(i=!0),["preload","t"].includes(s)&&("auto"===this.preload||this.t)&&(a=!0)}),e?this.__yt=this._preloadVideo(!0):i&&(this._loadVideo(),a&&this._autoMetadata())}play(){this.__yt||(this.__yt=this._preloadVideo(!1)),this.__yt&&this.__yt.playVideo&&this.__yt.playVideo()}pause(){this.__yt&&this.__yt.pauseVideo&&this.__yt.pauseVideo()}seek(t=0){this.__yt&&this.__yt.seekTo&&this.__yt.seekTo(t,!0)}setLoop(t){this.__yt&&this.__yt.setLoop&&this.media.setLoop(t)}setMute(t){this.__yt&&(t&&this.__yt.mute?this.__yt.mute():this.__yt.unMute&&this.__yt.unMute())}setPlaybackRate(t){this.__yt&&this.__yt.setPlaybackRate&&this.__yt.setPlaybackRate(t)}setVolume(t=.7){this.__yt&&this.__yt.setVolume(100*t)}_getSeconds(t=0){let e=t.replace(/[hm]{1,2}&?/g,":0").replace(/[s]{1,2}$/g,"").split(/:/);return 3600*(e.length>2?parseInt(e[e.length-3]):0)+60*(e.length>1?parseInt(e[e.length-2]):0)+(e.length>0?parseFloat(e[e.length-1]):0)}_handleMediaLoaded(t){this.dispatchEvent(new CustomEvent("loadedmetadata",{bubbles:!0,cancelable:!0,composed:!0,detail:this}))}_handleTimeupdate(){this.dispatchEvent(new CustomEvent("timeupdate",{bubbles:!0,cancelable:!0,composed:!0,detail:this}))}_autoMetadata(){let t=this.t||0,e=this.autoplay;this.setMute(!0),this.__yt.playVideo();let i=12e4,a=setInterval(()=>{i--,(this.duration&&this.duration>0||i<=0)&&(this.pause(),this.setMute(this.muted),clearInterval(a),this.seek(t),e&&this.play())},1);this.seek(t)}_loadVideo(t=this.preload){this.videoId&&this.__video.cueVideoById({videoId:this.videoId})}_preloadVideo(t=!1){let e=this,i=(!t||"none"!==this.preload)&&this.videoId&&!this.__video,a=document.createElement("div"),s=`container-${this.id}`,o=null;if(document.body.appendChild(a),a.setAttribute("id",s),i){let setYT=t=>this.__video=t.target,t=window.location.port?`:${window.location.port}`:"",i=`//${window.location.hostname}${t}`;o=new YT.Player(s,{width:e.width,height:e.height,events:{onReady:setYT},playerVars:{color:"white",controls:0,autoplay:e.autoplay,disablekb:1,enablejsapi:1,origin:i,iv_load_policy:3,modestbranding:1,rel:0,widget_referrer:window.location.href}}),o.timeupdate,o.addEventListener("onStateChange",()=>{e.paused?clearInterval(o.timeupdate):o.timeupdate=setInterval(()=>e._handleTimeupdate(),1)}),this.appendChild(o.getIframe()),a.remove()}return o}_removeIframe(){this.__yt&&(this.__yt.remove,this.__yt.destroy()),this.innerHTML=""}disconnectedCallback(){this._removeIframe(),super.disconnectedCallback()}}t.A11yMediaYoutube=A11yMediaYoutube,window.customElements.define(A11yMediaYoutube.tag,A11yMediaYoutube)}));