import { i as e } from "../../sanitize-CDxuPfMB.js";
import { t } from "../../utils-C_mWfcFX.js";
//#region src/display/empty-state/index.ts
var n = class {
	el;
	titleEl;
	descriptionEl = null;
	actionBtn = null;
	actionClickHandler = null;
	constructor(n) {
		if (this.el = document.createElement("div"), this.el.className = "cmm-empty-state", n.className && this.el.classList.add(n.className), n.icon !== void 0) {
			let t = document.createElement("div");
			t.className = "cmm-empty-state__icon", e(t, n.icon), this.el.appendChild(t);
		}
		if (this.titleEl = document.createElement("h3"), this.titleEl.className = "cmm-empty-state__title", this.titleEl.textContent = n.title, this.el.appendChild(this.titleEl), n.description !== void 0 && (this.descriptionEl = document.createElement("p"), this.descriptionEl.className = "cmm-empty-state__description", this.descriptionEl.textContent = n.description, this.el.appendChild(this.descriptionEl)), n.action !== void 0) {
			let e = document.createElement("div");
			e.className = "cmm-empty-state__action", this.actionBtn = document.createElement("button"), this.actionBtn.className = "cmm-btn cmm-btn--primary", this.actionBtn.textContent = n.action.label, this.actionClickHandler = n.action.onClick, this.actionBtn.addEventListener("click", this.actionClickHandler), e.appendChild(this.actionBtn), this.el.appendChild(e);
		}
		n.container !== void 0 && t(n.container).appendChild(this.el);
	}
	setTitle(e) {
		this.titleEl.textContent = e;
	}
	setDescription(e) {
		if (e === null) {
			this.descriptionEl &&= (this.descriptionEl.remove(), null);
			return;
		}
		if (this.descriptionEl) this.descriptionEl.textContent = e;
		else {
			this.descriptionEl = document.createElement("p"), this.descriptionEl.className = "cmm-empty-state__description", this.descriptionEl.textContent = e;
			let t = this.el.querySelector(".cmm-empty-state__action");
			t ? this.el.insertBefore(this.descriptionEl, t) : this.el.appendChild(this.descriptionEl);
		}
	}
	destroy() {
		this.actionBtn && this.actionClickHandler && this.actionBtn.removeEventListener("click", this.actionClickHandler), this.el.remove();
	}
};
//#endregion
export { n as EmptyState };

//# sourceMappingURL=index.js.map