import { focusHeadingOrContainer, focusNonInteractiveElement } from '../../utils';
export const followingNodes = (source, startingNode) => {
    const prevNodes = [];
    source.nextNode();
    while (source.referenceNode !== null && source.referenceNode !== startingNode) {
        prevNodes.push(source.referenceNode);
        source.nextNode();
    }
    const nodes = [];
    while (source.nextNode() !== null) {
        nodes.push(source.referenceNode);
    }
    return nodes.concat(prevNodes);
};
/**
 * Focuses the provided region element.
 * If the region has an aria-label, it focuses the region directly.
 * Otherwise, it attempts to focus the highest level heading within the region,
 * or the region itself if no headings are found.
 * @param region - The region HTMLElement to focus.
 * @returns boolean indicating whether the focus was successful.
 */
export const focusRegion = (region) => {
    const ariaLabel = region.getAttribute('aria-label');
    if (ariaLabel) {
        return focusNonInteractiveElement(region);
    }
    return focusHeadingOrContainer(region);
};
//# sourceMappingURL=utils.js.map