import { filterAutoFocusable } from "./DOMutils.js";
import { pickFirstFocus } from "./firstFocus.js";
import { getDataset } from "./is.js";
var findAutoFocused = function(autoFocusables) {
  return function(node) {
    var _a;
    var autofocus = (_a = 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 = filterAutoFocusable(nodes.filter(findAutoFocused(groups)));
  if (autoFocusable && autoFocusable.length) {
    return pickFirstFocus(autoFocusable);
  }
  return pickFirstFocus(filterAutoFocusable(orderedNodes));
};
export {
  pickAutofocus
};
//# sourceMappingURL=auto-focus.js.map
