"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isElementTabbable = exports.getPreviousElement = exports.getNextElement = exports.setUIFocusVisibility = exports.getUILastFocusable = exports.getUIFirstFocusable = void 0;
exports.focusToSibling = focusToSibling;
const react_1 = require("@fluentui/react");
Object.defineProperty(exports, "getUIFirstFocusable", { enumerable: true, get: function () { return react_1.getFirstFocusable; } });
Object.defineProperty(exports, "getUILastFocusable", { enumerable: true, get: function () { return react_1.getLastFocusable; } });
Object.defineProperty(exports, "setUIFocusVisibility", { enumerable: true, get: function () { return react_1.setFocusVisibility; } });
Object.defineProperty(exports, "getNextElement", { enumerable: true, get: function () { return react_1.getNextElement; } });
Object.defineProperty(exports, "getPreviousElement", { enumerable: true, get: function () { return react_1.getPreviousElement; } });
Object.defineProperty(exports, "isElementTabbable", { enumerable: true, get: function () { return react_1.isElementTabbable; } });
/**
 * Method redirects focus to next or previous element based on source element in stack/sequence in DOM.
 *
 * @param source Source/current element.
 * @param next `true` if should focus next or `false` if should focus previous.
 * @returns Redirected element.
 */
function focusToSibling(source, next) {
    const document = (0, react_1.getDocument)();
    if (document) {
        let element = null;
        if (next) {
            element = (0, react_1.getNextElement)(document.body, source, false, false, true, true);
        }
        else {
            element = (0, react_1.getPreviousElement)(document.body, source, false, false, true, true);
        }
        if (element) {
            element.focus();
            return element;
        }
    }
    return null;
}
//# sourceMappingURL=Focus.js.map