import { attachInternals as e } from "../utils/a11y.js";
//#region src/internal/controllers/state-active.controller.ts
function t() {
	return (e) => e.addInitializer((e) => new n(e));
}
var n = class {
	constructor(e) {
		this.host = e, this.host.addController(this);
	}
	hostConnected() {
		e(this.host), this.host.addEventListener("keypress", this.#e), this.host.addEventListener("mousedown", this.#e), this.host.addEventListener("keyup", this.#t), this.host.addEventListener("blur", this.#t), this.host.addEventListener("mouseup", this.#t);
	}
	hostDisconnected() {
		this.host.removeEventListener("keypress", this.#e), this.host.removeEventListener("mousedown", this.#e), this.host.removeEventListener("keyup", this.#t), this.host.removeEventListener("blur", this.#t), this.host.removeEventListener("mouseup", this.#t);
	}
	#e = (e) => {
		!this.host.disabled && this.#n(e) && this.host._internals.states.add("active"), e instanceof KeyboardEvent && e.code === "Space" && e.target === this.host && e.preventDefault();
	};
	#t = () => {
		this.host._internals.states.delete("active");
	};
	#n(e) {
		return e instanceof KeyboardEvent ? e.code === "Space" || e.code === "Enter" : !0;
	}
};
//#endregion
export { n as StateActiveController, t as stateActive };

//# sourceMappingURL=state-active.controller.js.map