import { n as e, t } from "../../utils-C_mWfcFX.js";
//#region src/security/cvss-badge/index.ts
function n(e) {
	return e <= 0 ? "None" : e <= 3.9 ? "Low" : e <= 6.9 ? "Medium" : e <= 8.9 ? "High" : "Critical";
}
function r(e) {
	switch (e) {
		case "None": return "none";
		case "Low": return "low";
		case "Medium": return "medium";
		case "High": return "high";
		case "Critical": return "critical";
	}
}
var i = class {
	el;
	badgeId;
	size;
	scoreEl;
	severityEl;
	vectorEl = null;
	versionEl = null;
	currentScore;
	showVector;
	constructor(i) {
		this.badgeId = e("cmm-cvss-badge"), this.size = i.size ?? "md", this.currentScore = Math.max(0, Math.min(10, i.score)), this.showVector = i.showVector === !0;
		let a = n(this.currentScore), o = r(a);
		this.el = document.createElement("div"), this.el.id = this.badgeId, this.el.className = this.buildClassName(o, i.className), this.el.setAttribute("role", "status"), this.el.setAttribute("aria-label", `CVSS Score: ${String(this.currentScore)} - ${a}`), this.scoreEl = document.createElement("span"), this.scoreEl.className = "cmm-cvss-badge__score", this.scoreEl.textContent = this.currentScore.toFixed(1), this.el.appendChild(this.scoreEl), this.severityEl = document.createElement("span"), this.severityEl.className = "cmm-cvss-badge__severity", this.severityEl.textContent = a, this.el.appendChild(this.severityEl), i.version !== void 0 && (this.versionEl = document.createElement("span"), this.versionEl.className = "cmm-cvss-badge__version", this.versionEl.textContent = `CVSS v${i.version}`, this.el.appendChild(this.versionEl)), this.showVector && i.vector !== void 0 && (this.vectorEl = document.createElement("span"), this.vectorEl.className = "cmm-cvss-badge__vector", this.vectorEl.textContent = i.vector, this.vectorEl.title = i.vector, this.el.appendChild(this.vectorEl)), t(i.container).appendChild(this.el);
	}
	update(e, t) {
		this.currentScore = Math.max(0, Math.min(10, e));
		let i = n(this.currentScore), a = r(i);
		this.scoreEl.textContent = this.currentScore.toFixed(1), this.severityEl.textContent = i, this.el.className = this.buildClassName(a), this.el.setAttribute("aria-label", `CVSS Score: ${String(this.currentScore)} - ${i}`), this.vectorEl !== null && t !== void 0 && (this.vectorEl.textContent = t, this.vectorEl.title = t);
	}
	destroy() {
		this.el.remove();
	}
	buildClassName(e, t) {
		let n = [
			"cmm-cvss-badge",
			`cmm-cvss-badge--${e}`,
			`cmm-cvss-badge--${this.size}`
		];
		return t && n.push(t), n.join(" ");
	}
};
//#endregion
export { i as CvssBadge };

//# sourceMappingURL=index.js.map