text: "use strict";
  Object.defineProperty(exports, "__esModule", { value: true });
  const rule_1 = require("../rule");
  class NoDupID extends rule_1.Rule {
      documentation() {
          return {
              description: "The ID of an element must be unique.",
              url: rule_1.ruleDocumentationUrl(__filename),
          };
      }
      setup() {
          this.on("dom:ready", (event) => {
              const { document } = event;
              const existing = new Set();
              const elements = document.querySelectorAll("[id]");
              const relevant = elements.filter(isRelevant);
              for (const el of relevant) {
                  const attr = el.getAttribute("id");
                  const id = attr.value.toString();
                  if (existing.has(id)) {
                      this.report(el, `Duplicate ID "${id}"`, attr.valueLocation);
                  }
                  existing.add(id);
              }
          });
      }
  }
  exports.default = NoDupID;
  function isRelevant(element) {
      const attr = element.getAttribute("id");
      /* id without value is not relevant, e.g. <p id></p> */
      if (!attr.value) {
          return false;
      }
      /* dynamic id (interpolated or otherwise currently unknown value) is not relevant */
      if (attr.isDynamic) {
          return false;
      }
      return true;
  }
  