import{g as e,r as t}from"./vendor-CZtH_kdS.js";import{u as r,a}from"./index-Re8qxHhK.js";function s(e,t){for(var r=0;r<t.length;r++){const a=t[r];if("string"!=typeof a&&!Array.isArray(a))for(const t in a)if("default"!==t&&!(t in e)){const r=Object.getOwnPropertyDescriptor(a,t);r&&Object.defineProperty(e,t,r.get?r:{enumerable:!0,get:()=>a[t]})}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}var l=Object.create,n=Object.defineProperty,o=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,p=Object.getPrototypeOf,h=Object.prototype.hasOwnProperty,y=(e,t,r,a)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let s of i(t))h.call(e,s)||s===r||n(e,s,{get:()=>t[s],enumerable:!(a=o(t,s))||a.enumerable});return e},d=(e,t,r)=>(((e,t,r)=>{t in e?n(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r})(e,"symbol"!=typeof t?t+"":t,r),r),c={};((e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})})(c,{default:()=>b});var u,m=(u=c,y(n({},"__esModule",{value:!0}),u)),f=((e,t,r)=>(r=null!=e?l(p(e)):{},y(e&&e.__esModule?r:n(r,"default",{value:e,enumerable:!0}),e)))(t),P=r,g=a;class b extends f.Component{constructor(){super(...arguments),d(this,"callPlayer",P.callPlayer),d(this,"playerID",this.props.config.playerId||`twitch-player-${(0,P.randomString)()}`),d(this,"mute",()=>{this.callPlayer("setMuted",!0)}),d(this,"unmute",()=>{this.callPlayer("setMuted",!1)})}componentDidMount(){this.props.onMount&&this.props.onMount(this)}load(e,t){const{playsinline:r,onError:a,config:s,controls:l}=this.props,n=g.MATCH_URL_TWITCH_CHANNEL.test(e),o=n?e.match(g.MATCH_URL_TWITCH_CHANNEL)[1]:e.match(g.MATCH_URL_TWITCH_VIDEO)[1];t?n?this.player.setChannel(o):this.player.setVideo("v"+o):(0,P.getSDK)("https://player.twitch.tv/js/embed/v1.js","Twitch").then(t=>{this.player=new t.Player(this.playerID,{video:n?"":o,channel:n?o:"",height:"100%",width:"100%",playsinline:r,autoplay:this.props.playing,muted:this.props.muted,controls:!!n||l,time:(0,P.parseStartTime)(e),...s.options});const{READY:a,PLAYING:i,PAUSE:p,ENDED:h,ONLINE:y,OFFLINE:d,SEEK:c}=t.Player;this.player.addEventListener(a,this.props.onReady),this.player.addEventListener(i,this.props.onPlay),this.player.addEventListener(p,this.props.onPause),this.player.addEventListener(h,this.props.onEnded),this.player.addEventListener(c,this.props.onSeek),this.player.addEventListener(y,this.props.onLoaded),this.player.addEventListener(d,this.props.onLoaded)},a)}play(){this.callPlayer("play")}pause(){this.callPlayer("pause")}stop(){this.callPlayer("pause")}seekTo(e,t=!0){this.callPlayer("seek",e),t||this.pause()}setVolume(e){this.callPlayer("setVolume",e)}getDuration(){return this.callPlayer("getDuration")}getCurrentTime(){return this.callPlayer("getCurrentTime")}getSecondsLoaded(){return null}render(){return f.default.createElement("div",{style:{width:"100%",height:"100%"},id:this.playerID})}}d(b,"displayName","Twitch"),d(b,"canPlay",g.canPlay.twitch),d(b,"loopOnEnded",!0);const E=s({__proto__:null,default:e(m)},[m]);export{E as T};
