import { AttributeVisitorMixin, getAttributeName, getAttributes } from "./rule-utils.js";
class AriaRoleHeadingRequiresLevel extends AttributeVisitorMixin {
    // We want to check 2 attributes here:
    // 1. role="heading"
    // 2. aria-level (which must be present if role="heading")
    checkAttribute(attributeName, attributeValue, attributeNode, parentNode) {
        if (!(attributeName === "role" && attributeValue === "heading")) {
            return;
        }
        const allAttributes = getAttributes(parentNode);
        // If we have a role="heading", we must check for aria-level
        const ariaLevelAttr = allAttributes.find(attr => getAttributeName(attr) === "aria-level");
        if (!ariaLevelAttr) {
            this.addOffense(`Element with \`role="heading"\` must have an \`aria-level\` attribute.`, attributeNode.location, "error");
        }
    }
}
export class HTMLAriaRoleHeadingRequiresLevelRule {
    name = "html-aria-role-heading-requires-level";
    check(node) {
        const visitor = new AriaRoleHeadingRequiresLevel(this.name);
        visitor.visit(node);
        return visitor.offenses;
    }
}
//# sourceMappingURL=html-aria-role-heading-requires-level.js.map