import { attachInternals as e } from "../utils/a11y.js";
//#region src/internal/controllers/type-expandable.controller.ts
var t = class {
	#e = !1;
	#t = !1;
	constructor(e, t = {}) {
		this.host = e, this.#t = t.useHidden ?? !1, this.host.addController(this);
	}
	hostConnected() {
		e(this.host), this.host.addEventListener("command", ((e) => {
			this.#e = !0, e.command === "--toggle" && this.toggle(), e.command === "--open" && this.open(), e.command === "--close" && this.close(), this.#e = !1;
		}));
	}
	hostUpdated() {
		this.host.expandable ? this.host._internals.states.add("expandable") : this.host._internals.states.delete("expandable");
	}
	open() {
		(this.host.behaviorExpand || this.#e) && (this.host.expanded = !0, this.#t && (this.host.hidden = !1)), this.host.dispatchEvent(new CustomEvent("open", {
			bubbles: !0,
			composed: !0
		}));
	}
	close() {
		(this.host.behaviorExpand || this.#e) && (this.host.expanded = !1, this.#t && (this.host.hidden = !0)), this.host.dispatchEvent(new CustomEvent("close", {
			bubbles: !0,
			composed: !0
		}));
	}
	toggle() {
		this.host.expanded || this.#t && !this.host.hidden ? this.close() : this.open();
	}
};
//#endregion
export { t as TypeExpandableController };

//# sourceMappingURL=type-expandable.controller.js.map