import { playerContext } from "../../player/context.js";
import { MediaElement } from "../media-element.js";
import { PlayerController } from "../../player/player-controller.js";
import { applyStateDataAttrs, logMissingFeature, selectPlayback } from "@videojs/core/dom";
import { BufferingIndicatorCore, BufferingIndicatorDataAttrs } from "@videojs/core";

//#region src/ui/buffering-indicator/buffering-indicator-element.ts
var BufferingIndicatorElement = class extends MediaElement {
	constructor(..._args) {
		super(..._args);
		this.delay = BufferingIndicatorCore.defaultProps.delay;
	}
	static {
		this.tagName = "media-buffering-indicator";
	}
	static {
		this.properties = { delay: { type: Number } };
	}
	#core = new BufferingIndicatorCore();
	#state = new PlayerController(this, playerContext, selectPlayback);
	#disconnect = null;
	connectedCallback() {
		super.connectedCallback();
		this.#disconnect = new AbortController();
		this.#core.state.subscribe(() => this.requestUpdate(), { signal: this.#disconnect.signal });
		if (!this.#state.value) logMissingFeature(this.localName, this.#state.displayName);
	}
	disconnectedCallback() {
		super.disconnectedCallback();
		this.#disconnect?.abort();
		this.#disconnect = null;
	}
	willUpdate(changed) {
		super.willUpdate(changed);
		this.#core.setProps(this);
	}
	update(changed) {
		super.update(changed);
		const media = this.#state.value;
		if (!media) return;
		this.#core.update(media);
		applyStateDataAttrs(this, this.#core.state.current, BufferingIndicatorDataAttrs);
	}
};

//#endregion
export { BufferingIndicatorElement };
//# sourceMappingURL=buffering-indicator-element.js.map