import { TWMixin } from "./TWMixin2.js";
import { __decorate } from "../_virtual/_@oxc-project_runtime@0.95.0/helpers/decorate.js";
import { isEFTemporal } from "../elements/EFTemporal.js";
import { targetTemporalContext } from "./ContextMixin.js";
import { TargetController } from "../elements/TargetController.js";
import "./timeline/EFTimeline.js";
import { consume } from "@lit/context";
import { LitElement, css, html } from "lit";
import { customElement, property, state } from "lit/decorators.js";
import { createRef, ref } from "lit/directives/ref.js";

//#region src/gui/EFFilmstrip.ts
let EFFilmstrip = class EFFilmstrip$1 extends TWMixin(LitElement) {
	constructor(..._args) {
		super(..._args);
		this.target = "";
		this.pixelsPerMs = .04;
		this.hidePlayhead = false;
		this.disableInternalScroll = false;
		this.hide = "";
		this.show = "";
		this.targetElement = null;
		this.timelineRef = createRef();
	}
	static {
		this.styles = [css`
      :host {
        display: block;
        width: 100%;
        height: 100%;
      }
    `];
	}
	#targetController;
	#lastTargetTemporal;
	get targetTemporal() {
		const fromTarget = this.targetElement && isEFTemporal(this.targetElement) ? this.targetElement : null;
		const fromContext = this._contextProvidedTemporal;
		if (fromTarget && fromContext && fromTarget !== fromContext) console.warn("EFFilmstrip: Both target attribute and parent context found. Using target attribute.", {
			target: this.target,
			fromTarget,
			fromContext
		});
		return fromTarget ?? fromContext ?? null;
	}
	get hideSelectors() {
		if (!this.hide) return void 0;
		return this.hide.split(",").map((s) => s.trim()).filter((s) => s.length > 0);
	}
	get showSelectors() {
		if (!this.show) return void 0;
		return this.show.split(",").map((s) => s.trim()).filter((s) => s.length > 0);
	}
	connectedCallback() {
		super.connectedCallback();
		if (this.target) this.#targetController = new TargetController(this);
	}
	willUpdate(changedProperties) {
		if (changedProperties.has("target")) {
			if (this.target && !this.#targetController) this.#targetController = new TargetController(this);
		}
		const currentTargetTemporal = this.targetTemporal;
		if (this.#lastTargetTemporal !== currentTargetTemporal) {
			this.#lastTargetTemporal = currentTargetTemporal;
			const timeline = this.timelineRef.value;
			if (timeline) timeline.requestUpdate();
		}
		super.willUpdate(changedProperties);
	}
	render() {
		const targetId = this.targetTemporal ? this.targetTemporal.id || this.target : this.target;
		return html`
      <ef-timeline
        ${ref(this.timelineRef)}
        target=${targetId}
        control-target=${targetId}
        pixels-per-ms=${this.pixelsPerMs}
        .showPlayhead=${!this.hidePlayhead}
        .showControls=${true}
        hide=${this.hide}
        show=${this.show}
      ></ef-timeline>
    `;
	}
};
__decorate([property({ type: String })], EFFilmstrip.prototype, "target", void 0);
__decorate([property({
	type: Number,
	attribute: "pixels-per-ms"
})], EFFilmstrip.prototype, "pixelsPerMs", void 0);
__decorate([property({
	type: Boolean,
	attribute: "hide-playhead"
})], EFFilmstrip.prototype, "hidePlayhead", void 0);
__decorate([property({
	type: Boolean,
	attribute: "disable-internal-scroll"
})], EFFilmstrip.prototype, "disableInternalScroll", void 0);
__decorate([property({ type: String })], EFFilmstrip.prototype, "hide", void 0);
__decorate([property({ type: String })], EFFilmstrip.prototype, "show", void 0);
__decorate([state()], EFFilmstrip.prototype, "targetElement", void 0);
__decorate([consume({
	context: targetTemporalContext,
	subscribe: true
}), state()], EFFilmstrip.prototype, "_contextProvidedTemporal", void 0);
EFFilmstrip = __decorate([customElement("ef-filmstrip")], EFFilmstrip);

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