"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const DOMutils = require("./DOMutils.js");
const firstFocus = require("./firstFocus.js");
const is = require("./is.js");
var findAutoFocused = function(autoFocusables) {
  return function(node) {
    var _a;
    var autofocus = (_a = is.getDataset(node)) === null || _a === void 0 ? void 0 : _a.autofocus;
    return node.autofocus || autofocus !== void 0 && autofocus !== "false" || autoFocusables.indexOf(node) >= 0;
  };
};
var pickAutofocus = function(nodesIndexes, orderedNodes, groups) {
  var nodes = nodesIndexes.map(function(_a) {
    var node = _a.node;
    return node;
  });
  var autoFocusable = DOMutils.filterAutoFocusable(nodes.filter(findAutoFocused(groups)));
  if (autoFocusable && autoFocusable.length) {
    return firstFocus.pickFirstFocus(autoFocusable);
  }
  return firstFocus.pickFirstFocus(DOMutils.filterAutoFocusable(orderedNodes));
};
exports.pickAutofocus = pickAutofocus;
//# sourceMappingURL=auto-focus.js.map
