"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const getRole = require("./getRole.cjs");
function isElement(node) {
  return node !== null && node.nodeType === node.ELEMENT_NODE;
}
function isHTMLTableCaptionElement(node) {
  return isElement(node) && getRole.getLocalName(node) === "caption";
}
function isHTMLInputElement(node) {
  return isElement(node) && getRole.getLocalName(node) === "input";
}
function isHTMLOptGroupElement(node) {
  return isElement(node) && getRole.getLocalName(node) === "optgroup";
}
function isHTMLSelectElement(node) {
  return isElement(node) && getRole.getLocalName(node) === "select";
}
function isHTMLTableElement(node) {
  return isElement(node) && getRole.getLocalName(node) === "table";
}
function isHTMLTextAreaElement(node) {
  return isElement(node) && getRole.getLocalName(node) === "textarea";
}
function safeWindow(node) {
  var _ref = node.ownerDocument === null ? node : node.ownerDocument, defaultView = _ref.defaultView;
  if (defaultView === null) {
    throw new TypeError("no window available");
  }
  return defaultView;
}
function isHTMLFieldSetElement(node) {
  return isElement(node) && getRole.getLocalName(node) === "fieldset";
}
function isHTMLLegendElement(node) {
  return isElement(node) && getRole.getLocalName(node) === "legend";
}
function isHTMLSlotElement(node) {
  return isElement(node) && getRole.getLocalName(node) === "slot";
}
function isSVGElement(node) {
  return isElement(node) && node.ownerSVGElement !== void 0;
}
function isSVGSVGElement(node) {
  return isElement(node) && getRole.getLocalName(node) === "svg";
}
function isSVGTitleElement(node) {
  return isSVGElement(node) && getRole.getLocalName(node) === "title";
}
function queryIdRefs(node, attributeName) {
  if (isElement(node) && node.hasAttribute(attributeName)) {
    var ids = node.getAttribute(attributeName).split(" ");
    var root = node.getRootNode ? node.getRootNode() : node.ownerDocument;
    return ids.map(function(id) {
      return root.getElementById(id);
    }).filter(
      function(element) {
        return element !== null;
      }
      // TODO: why does this not narrow?
    );
  }
  return [];
}
function hasAnyConcreteRoles(node, roles) {
  if (isElement(node)) {
    return roles.indexOf(getRole.default(node)) !== -1;
  }
  return false;
}
exports.getLocalName = getRole.getLocalName;
exports.hasAnyConcreteRoles = hasAnyConcreteRoles;
exports.isElement = isElement;
exports.isHTMLFieldSetElement = isHTMLFieldSetElement;
exports.isHTMLInputElement = isHTMLInputElement;
exports.isHTMLLegendElement = isHTMLLegendElement;
exports.isHTMLOptGroupElement = isHTMLOptGroupElement;
exports.isHTMLSelectElement = isHTMLSelectElement;
exports.isHTMLSlotElement = isHTMLSlotElement;
exports.isHTMLTableCaptionElement = isHTMLTableCaptionElement;
exports.isHTMLTableElement = isHTMLTableElement;
exports.isHTMLTextAreaElement = isHTMLTextAreaElement;
exports.isSVGElement = isSVGElement;
exports.isSVGSVGElement = isSVGSVGElement;
exports.isSVGTitleElement = isSVGTitleElement;
exports.queryIdRefs = queryIdRefs;
exports.safeWindow = safeWindow;
//# sourceMappingURL=util.cjs.map
