import { n as e, t } from "./utils-C_mWfcFX.js";
//#region src/display/badge/presets.ts
var n = {
	critical: "Critical",
	high: "High",
	medium: "Medium",
	low: "Low",
	info: "Info"
}, r = {
	active: "Active",
	inactive: "Inactive",
	pending: "Pending",
	error: "Error"
};
function i(e, t) {
	return new o({
		label: n[e],
		severity: e,
		dot: !0,
		...t
	});
}
function a(e, t) {
	return new o({
		label: r[e],
		status: e,
		dot: !0,
		...t
	});
}
//#endregion
//#region src/display/badge/index.ts
var o = class {
	el;
	badgeId;
	currentVariant;
	labelEl;
	dotEl = null;
	removeBtn = null;
	removeHandler;
	removeBtnClickHandler = null;
	constructor(n) {
		if (this.badgeId = e("cmm-badge"), this.currentVariant = n.variant ?? "default", this.removeHandler = n.onRemove, this.el = document.createElement("span"), this.el.id = this.badgeId, this.el.className = this.buildClassName(n), n.dot === !0 && (this.dotEl = document.createElement("span"), this.dotEl.className = "cmm-badge__dot", this.dotEl.setAttribute("aria-hidden", "true"), this.el.appendChild(this.dotEl)), this.labelEl = document.createElement("span"), this.labelEl.className = "cmm-badge__label", this.labelEl.textContent = n.label, this.el.appendChild(this.labelEl), n.removable === !0) {
			this.removeBtn = document.createElement("button"), this.removeBtn.className = "cmm-badge__remove", this.removeBtn.setAttribute("aria-label", "Remove"), this.removeBtn.type = "button", this.removeBtn.textContent = "×";
			let e = () => {
				this.removeHandler !== void 0 && this.removeHandler();
			};
			this.removeBtn.addEventListener("click", e), this.removeBtnClickHandler = e, this.el.appendChild(this.removeBtn);
		}
		n.container !== void 0 && t(n.container).appendChild(this.el);
	}
	setLabel(e) {
		this.labelEl.textContent = e;
	}
	setVariant(e) {
		this.el.classList.remove(`cmm-badge--${this.currentVariant}`), this.currentVariant = e, this.el.classList.add(`cmm-badge--${this.currentVariant}`);
	}
	destroy() {
		this.removeBtn !== null && this.removeBtnClickHandler !== null && this.removeBtn.removeEventListener("click", this.removeBtnClickHandler), this.el.remove();
	}
	buildClassName(e) {
		let t = ["cmm-badge", `cmm-badge--${this.currentVariant}`];
		return e.severity !== void 0 && t.push(`cmm-badge--severity-${e.severity}`), e.status !== void 0 && t.push(`cmm-badge--status-${e.status}`), e.className && t.push(e.className), t.join(" ");
	}
};
//#endregion
export { i as n, a as r, o as t };

//# sourceMappingURL=badge-CAvV5GE2.js.map