import focusNonInteractiveElement from './focusNonInteractiveElement';
/**
 * Focuses the highest level heading element in a container, or the container itself if there are no headings.
 * @param container Node to query for a heading.
 * @param label Fallback label to apply to the container if focused.
 * @returns boolean whether the focus was successful or not (eg. element is not visible).
 */
const focusHeadingOrContainer = (container, label) => {
    const heading = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'].reduce((el, tag) => el ?? container.querySelector(tag), null);
    const target = heading ?? container;
    if (!(target instanceof HTMLElement || target instanceof SVGElement))
        return false;
    return focusNonInteractiveElement(target, target === heading ? undefined : label);
};
export default focusHeadingOrContainer;
//# sourceMappingURL=focusHeadingOrContainer.js.map