import { removeEmptyTextNode as e } from "../utils/dom.js";
import { attachInternals as t } from "../utils/a11y.js";
//#region src/internal/controllers/type-anchor.controller.ts
function n() {
	return (e) => e.addInitializer((e) => new r(e));
}
var r = class {
	get #e() {
		return this.#t ? this.#t : this.#n;
	}
	get #t() {
		return this.host.shadowRoot.querySelector("slot, slot[name=anchor]")?.assignedElements()?.find((e) => e?.tagName === "A");
	}
	get #n() {
		return this.host.parentElement?.tagName === "A" ? this.host.parentElement : null;
	}
	get #r() {
		return this.host.shadowRoot.querySelector("slot:not([name])");
	}
	get #i() {
		return this.host.shadowRoot.querySelector("slot[name=anchor]");
	}
	constructor(e) {
		this.host = e, this.host.addController(this);
	}
	async hostConnected() {
		t(this.host), await this.host.updateComplete, this.#a(), this.#e ? (this.host.readOnly = !0, this.host._internals?.states.add("anchor")) : this.host._internals?.states.delete("anchor"), this.#n && (this.#n.style.textDecoration = "none", this.host.style.cursor = "pointer"), this.#e?.addEventListener("click", (e) => {
			this.host.disabled && (e.preventDefault(), e.stopImmediatePropagation());
		});
	}
	#a() {
		this.#e && this.#i && (this.#e.slot = "anchor", this.#r?.assignedNodes().forEach((t) => e(t)));
	}
};
//#endregion
export { r as TypeAnchorController, n as typeAnchor };

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