import { V as e, W as t, Y as n, i as r, r as i } from "./vidstack-D9mvYVIz-DesuYgKV.js";
import { d as a, m as o, p as s } from "./useVidstackSrc-epUQZhkL.js";
import { n as c, t as l } from "./vidstack-CI5oafcm-DAV7Lilr.js";
import { n as u, t as d } from "./vidstack-DYPyTdYw-BzqKxwCK.js";
//#region node_modules/vidstack/prod/chunks/vidstack-C6nBVWwn.js
var f = class {
	#e;
	#t;
	constructor(e, n) {
		this.#e = e, this.#t = n, e.textTracks.onaddtrack = this.#n.bind(this), t(this.#r.bind(this));
	}
	#n(e) {
		let t = e.track;
		if (!t || p(this.#e, t)) return;
		let n = new d({
			id: t.id,
			kind: t.kind,
			label: t.label ?? "",
			language: t.language,
			type: "vtt"
		});
		n[u.native] = { track: t }, n[u.readyState] = 2, n[u.nativeHLS] = !0;
		let r = 0, i = (e) => {
			if (t.cues) for (let i = r; i < t.cues.length; i++) n.addCue(t.cues[i], e), r++;
		};
		i(e), t.oncuechange = i, this.#t.textTracks.add(n, e), n.setMode(t.mode, e);
	}
	#r() {
		this.#e.textTracks.onaddtrack = null;
		for (let e of this.#t.textTracks) {
			let t = e[u.native]?.track;
			t?.oncuechange && (t.oncuechange = null);
		}
	}
};
function p(e, t) {
	return Array.from(e.children).find((e) => e.track === t);
}
var m = class {
	#e;
	#t;
	constructor(e, t) {
		this.#e = e, this.#t = t, new r(e).add("enterpictureinpicture", this.#n.bind(this)).add("leavepictureinpicture", this.#r.bind(this));
	}
	get active() {
		return document.pictureInPictureElement === this.#e;
	}
	get supported() {
		return s(this.#e);
	}
	async enter() {
		return this.#e.requestPictureInPicture();
	}
	exit() {
		return document.exitPictureInPicture();
	}
	#n(e) {
		this.#i(!0, e);
	}
	#r(e) {
		this.#i(!1, e);
	}
	#i = (e, t) => {
		this.#t.notify("picture-in-picture-change", e, t);
	};
}, h = class {
	#e;
	#t;
	#n = "inline";
	get mode() {
		return this.#n;
	}
	constructor(t, n) {
		this.#e = t, this.#t = n, e(t, "webkitpresentationmodechanged", this.#r.bind(this));
	}
	get supported() {
		return o(this.#e);
	}
	async setPresentationMode(e) {
		this.#n !== e && this.#e.webkitSetPresentationMode(e);
	}
	#r(e) {
		let t = this.#n;
		this.#n = this.#e.webkitPresentationMode, this.#t.player?.dispatch(new i("video-presentation-change", {
			detail: this.#n,
			trigger: e
		})), ["fullscreen", "picture-in-picture"].forEach((n) => {
			(this.#n === n || t === n) && this.#t.notify(`${n}-change`, this.#n === n, e);
		});
	}
}, g = class {
	#e;
	get active() {
		return this.#e.mode === "fullscreen";
	}
	get supported() {
		return this.#e.supported;
	}
	constructor(e) {
		this.#e = e;
	}
	async enter() {
		this.#e.setPresentationMode("fullscreen");
	}
	async exit() {
		this.#e.setPresentationMode("inline");
	}
}, _ = class {
	#e;
	get active() {
		return this.#e.mode === "picture-in-picture";
	}
	get supported() {
		return this.#e.supported;
	}
	constructor(e) {
		this.#e = e;
	}
	async enter() {
		this.#e.setPresentationMode("picture-in-picture");
	}
	async exit() {
		this.#e.setPresentationMode("inline");
	}
}, v = class extends c {
	$$PROVIDER_TYPE = "VIDEO";
	get type() {
		return "video";
	}
	airPlay;
	fullscreen;
	pictureInPicture;
	constructor(e, t) {
		super(e, t), n(() => {
			if (this.airPlay = new l(e, t), o(e)) {
				let n = new h(e, t);
				this.fullscreen = new g(n), this.pictureInPicture = new _(n);
			} else s(e) && (this.pictureInPicture = new m(e, t));
		}, this.scope);
	}
	setup() {
		super.setup(), a(this.video) && new f(this.video, this.ctx), this.ctx.textRenderers.attachVideo(this.video), t(() => {
			this.ctx.textRenderers.attachVideo(null);
		}), this.type === "video" && this.ctx.notify("provider-setup", this);
	}
	get video() {
		return this.media;
	}
};
//#endregion
export { v as t };
