import { TWMixin } from "../gui/TWMixin2.js";
import { PRIORITY_AUDIO } from "../preview/FrameController.js";
import { __decorate } from "../_virtual/_@oxc-project_runtime@0.95.0/helpers/decorate.js";
import { EFMedia } from "./EFMedia.js";
import { html } from "lit";
import { customElement, property } from "lit/decorators.js";
import { createRef, ref } from "lit/directives/ref.js";

//#region src/elements/EFAudio.ts
let EFAudio = class EFAudio$1 extends TWMixin(EFMedia) {
	constructor(..._args) {
		super(..._args);
		this.volume = 1;
		this.audioElementRef = createRef();
	}
	/**
	* EFAudio only requires audio tracks - skip video track validation
	* to avoid unnecessary network requests to transcoding service.
	*/
	get requiredTracks() {
		return "audio";
	}
	#mediaEngineLoaded = false;
	updated(changedProperties) {
		super.updated(changedProperties);
		if (this.audioElementRef.value) {
			if (changedProperties.has("volume") || changedProperties.size === 0) this.audioElementRef.value.volume = this.volume;
		}
	}
	render() {
		return html`<audio ${ref(this.audioElementRef)}></audio>`;
	}
	/**
	* Query readiness state for a given time.
	* @implements FrameRenderable
	*/
	getFrameState(_timeMs) {
		const isReady = this.#mediaEngineLoaded && this.mediaEngineTask.status === 2;
		return {
			needsPreparation: !isReady,
			isReady,
			priority: PRIORITY_AUDIO
		};
	}
	/**
	* Async preparation - waits for media engine to load.
	* @implements FrameRenderable
	*/
	async prepareFrame(_timeMs, signal) {
		this.#mediaEngineLoaded = !!await this.getMediaEngine(signal);
		signal.throwIfAborted();
	}
	/**
	* Synchronous render - audio plays via HTMLAudioElement, no explicit render needed.
	* @implements FrameRenderable
	*/
	renderFrame(_timeMs) {}
};
__decorate([property({
	type: Number,
	attribute: "volume",
	reflect: true
})], EFAudio.prototype, "volume", void 0);
EFAudio = __decorate([customElement("ef-audio")], EFAudio);

//#endregion
export { EFAudio };
//# sourceMappingURL=EFAudio.js.map