"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const array = require("./array.js");
const is = require("./is.js");
const tabOrder = require("./tabOrder.js");
const tabUtils = require("./tabUtils.js");
var filterFocusable = function(nodes, visibilityCache) {
  return array.toArray(nodes).filter(function(node) {
    return is.isVisibleCached(visibilityCache, node);
  }).filter(function(node) {
    return is.notHiddenInput(node);
  });
};
var filterAutoFocusable = function(nodes, cache) {
  if (cache === void 0) {
    cache = /* @__PURE__ */ new Map();
  }
  return array.toArray(nodes).filter(function(node) {
    return is.isAutoFocusAllowedCached(cache, node);
  });
};
var getTabbableNodes = function(topNodes, visibilityCache, withGuards) {
  return tabOrder.orderByTabIndex(filterFocusable(tabUtils.getFocusables(topNodes, withGuards), visibilityCache), true, withGuards);
};
var getAllTabbableNodes = function(topNodes, visibilityCache) {
  return tabOrder.orderByTabIndex(filterFocusable(tabUtils.getFocusables(topNodes), visibilityCache), false);
};
var parentAutofocusables = function(topNode, visibilityCache) {
  return filterFocusable(tabUtils.getParentAutofocusables(topNode), visibilityCache);
};
var contains = function(scope, element) {
  if (scope.shadowRoot) {
    return contains(scope.shadowRoot, element);
  } else {
    if (Object.getPrototypeOf(scope).contains !== void 0 && Object.getPrototypeOf(scope).contains.call(scope, element)) {
      return true;
    }
    return array.toArray(scope.children).some(function(child) {
      return contains(child, element);
    });
  }
};
exports.contains = contains;
exports.filterAutoFocusable = filterAutoFocusable;
exports.filterFocusable = filterFocusable;
exports.getAllTabbableNodes = getAllTabbableNodes;
exports.getTabbableNodes = getTabbableNodes;
exports.parentAutofocusables = parentAutofocusables;
//# sourceMappingURL=DOMutils.js.map
