import { b as e, e as t } from "./chunk.BlbRoQQ3.js";
import { b as n, c as r } from "./patterns.CVV2epWU.js";
import "./cjs.S1Glohke.js";
var i = /* @__PURE__ */ e(((exports, i) => {
	var a = Object.create, o = Object.defineProperty, s = Object.getOwnPropertyDescriptor, c = Object.getOwnPropertyNames, l = Object.getPrototypeOf, u = Object.prototype.hasOwnProperty, d = (e, t, n) => t in e ? o(e, t, {
		enumerable: !0,
		configurable: !0,
		writable: !0,
		value: n
	}) : e[t] = n, f = (e, t) => {
		for (var n in t) o(e, n, {
			get: t[n],
			enumerable: !0
		});
	}, p = (e, t, n, r) => {
		if (t && typeof t == "object" || typeof t == "function") for (let i of c(t)) !u.call(e, i) && i !== n && o(e, i, {
			get: () => t[i],
			enumerable: !(r = s(t, i)) || r.enumerable
		});
		return e;
	}, m = (e, t, n) => (n = e == null ? {} : a(l(e)), p(t || !e || !e.__esModule ? o(n, "default", {
		value: e,
		enumerable: !0
	}) : n, e)), h = (e) => p(o({}, "__esModule", { value: !0 }), e), g = (e, t, n) => (d(e, typeof t == "symbol" ? t : t + "", n), n), _ = {};
	f(_, { default: () => x }), i.exports = h(_);
	var v = m(t("react")), y = r(), b = n(), x = class extends v.Component {
		constructor() {
			super(...arguments), g(this, "callPlayer", y.callPlayer), g(this, "playerID", this.props.config.playerId || `twitch-player-${(0, y.randomString)()}`), g(this, "mute", () => {
				this.callPlayer("setMuted", !0);
			}), g(this, "unmute", () => {
				this.callPlayer("setMuted", !1);
			});
		}
		componentDidMount() {
			this.props.onMount && this.props.onMount(this);
		}
		load(e, t) {
			let { playsinline: n, onError: r, config: i, controls: a } = this.props, o = b.MATCH_URL_TWITCH_CHANNEL.test(e), s = o ? e.match(b.MATCH_URL_TWITCH_CHANNEL)[1] : e.match(b.MATCH_URL_TWITCH_VIDEO)[1];
			if (t) {
				o ? this.player.setChannel(s) : this.player.setVideo("v" + s);
				return;
			}
			(0, y.getSDK)("https://player.twitch.tv/js/embed/v1.js", "Twitch").then((t) => {
				this.player = new t.Player(this.playerID, {
					video: o ? "" : s,
					channel: o ? s : "",
					height: "100%",
					width: "100%",
					playsinline: n,
					autoplay: this.props.playing,
					muted: this.props.muted,
					controls: o ? !0 : a,
					time: (0, y.parseStartTime)(e),
					...i.options
				});
				let { READY: r, PLAYING: c, PAUSE: l, ENDED: u, ONLINE: d, OFFLINE: f, SEEK: p } = t.Player;
				this.player.addEventListener(r, this.props.onReady), this.player.addEventListener(c, this.props.onPlay), this.player.addEventListener(l, this.props.onPause), this.player.addEventListener(u, this.props.onEnded), this.player.addEventListener(p, this.props.onSeek), this.player.addEventListener(d, this.props.onLoaded), this.player.addEventListener(f, this.props.onLoaded);
			}, r);
		}
		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() {
			let e = {
				width: "100%",
				height: "100%"
			};
			return /* @__PURE__ */ v.default.createElement("div", {
				style: e,
				id: this.playerID
			});
		}
	};
	g(x, "displayName", "Twitch"), g(x, "canPlay", b.canPlay.twitch), g(x, "loopOnEnded", !0);
}));
export default i();

//# sourceMappingURL=Twitch.CbkEiTbZ.js.map