import { t as e } from "../../utils-C_mWfcFX.js";
//#region src/primitives/label/index.ts
var t = class {
	el;
	textNode;
	requiredEl = null;
	constructor(t) {
		this.el = document.createElement("label"), this.el.className = "cmm-label", t.className && this.el.classList.add(t.className), t.htmlFor !== void 0 && (this.el.htmlFor = t.htmlFor), this.textNode = document.createTextNode(t.text), this.el.appendChild(this.textNode), t.required === !0 && this.appendRequiredIndicator(), t.container !== void 0 && e(t.container).appendChild(this.el);
	}
	setText(e) {
		this.textNode.textContent = e;
	}
	setRequired(e) {
		e && this.requiredEl === null ? this.appendRequiredIndicator() : !e && this.requiredEl !== null && (this.requiredEl.remove(), this.requiredEl = null);
	}
	setFor(e) {
		this.el.htmlFor = e;
	}
	destroy() {
		this.el.remove();
	}
	appendRequiredIndicator() {
		this.requiredEl = document.createElement("span"), this.requiredEl.className = "cmm-label__required", this.requiredEl.setAttribute("aria-hidden", "true"), this.requiredEl.textContent = "*", this.el.appendChild(this.requiredEl);
	}
};
//#endregion
export { t as Label };

//# sourceMappingURL=index.js.map