import { playerContext } from "../../player/context.js";
import { MediaElement } from "../media-element.js";
import { PlayerController } from "../../player/player-controller.js";
import { applyElementProps, applyStateDataAttrs, logMissingFeature, selectTime } from "@videojs/core/dom";
import { TimeCore, TimeDataAttrs } from "@videojs/core";

//#region src/ui/time/time-element.ts
var TimeElement = class extends MediaElement {
	static {
		this.tagName = "media-time";
	}
	static {
		this.properties = {
			type: { type: String },
			negativeSign: {
				type: String,
				attribute: "negative-sign"
			},
			label: { type: String }
		};
	}
	#core = new TimeCore();
	#state = new PlayerController(this, playerContext, selectTime);
	#signSpan = document.createElement("span");
	#textNode = document.createTextNode("");
	constructor() {
		super();
		this.type = TimeCore.defaultProps.type;
		this.negativeSign = TimeCore.defaultProps.negativeSign;
		this.label = TimeCore.defaultProps.label;
		this.#signSpan.setAttribute("aria-hidden", "true");
		this.#signSpan.hidden = true;
		this.appendChild(this.#signSpan);
		this.appendChild(this.#textNode);
	}
	connectedCallback() {
		super.connectedCallback();
		if (!this.#state.value) logMissingFeature(this.localName, this.#state.displayName);
	}
	willUpdate(changed) {
		super.willUpdate(changed);
		this.#core.setProps(this);
	}
	update(changed) {
		super.update(changed);
		const media = this.#state.value;
		if (!media) return;
		this.#core.setMedia(media);
		const state = this.#core.getState();
		this.#signSpan.hidden = !state.negative;
		this.#signSpan.textContent = state.negative ? this.negativeSign : "";
		this.#textNode.textContent = state.text;
		applyElementProps(this, this.#core.getAttrs(state));
		applyStateDataAttrs(this, state, TimeDataAttrs);
	}
};

//#endregion
export { TimeElement };
//# sourceMappingURL=time-element.js.map