var focusableSelectors = [
    'a[href]',
    'area[href]',
    'input:not([disabled]):not([type="hidden"])',
    'textarea:not([disabled])',
    'button:not([disabled])',
    '[tabindex="0"]'
];
var canFocusSelectors = focusableSelectors.join(', ');
var isFocusable = function (element) {
    return element && element.matches && element.matches(canFocusSelectors);
};
var getFocusable = function (element) {
    return Array.from(element.querySelectorAll(canFocusSelectors));
};
var focusBounds = function (element) {
    var els = getFocusable(element);
    return [els[0], els[els.length - 1]];
};
var constrainFocus = function (event, element) {
    var active = element.ownerDocument.activeElement;
    var _a = focusBounds(element), first = _a[0], last = _a[1];
    if (event.shiftKey && active === first) {
        event.preventDefault();
        last.focus();
    }
    else if (active === last) {
        event.preventDefault();
        first.focus();
    }
};
export { constrainFocus as c, getFocusable as g, isFocusable as i };
