/** Characters that must not reach the browser as markup. */
const ESCAPES = {
    "&": "&amp;",
    "<": "&lt;",
    ">": "&gt;",
    '"': "&quot;",
    "'": "&#39;",
};
/**
 * Escape a string for interpolation into HTML.
 * @param value - Raw text
 * @returns Escaped text
 */
export function escapeHtml(value) {
    return value.replace(/[&<>"']/g, character => ESCAPES[character] ?? character);
}
/**
 * One chip.
 * @param variant - The chip's state class
 * @param text - Its label
 * @param title - Hover text explaining it
 * @returns One chip of HTML
 */
export function chip(variant, text, title = "") {
    const attribute = title === "" ? "" : ` title="${escapeHtml(title)}"`;
    return `<span class="lgr-chip lgr-${escapeHtml(variant)}"${attribute}>${escapeHtml(text)}</span>`;
}
/**
 * The chip for a finding this run could not determine.
 *
 * Carries the human message as hover text rather than dropping it: a report
 * that says "not checked here" without saying why is indistinguishable from a
 * bug in the report.
 * @param finding - An unknown or not-applicable finding
 * @param label - What to call it
 * @returns One chip of HTML
 */
export function unknownChip(finding, label = "not checked here") {
    return chip("unknown", label, finding.message);
}
/**
 * One monospaced fragment.
 * @param value - Raw text
 * @returns The text inside a `code` element, escaped
 */
export function code(value) {
    return `<code>${escapeHtml(value)}</code>`;
}
//# sourceMappingURL=gate-report-html.js.map