function getActiveDocument() {
    var _a;
    if (getWindowsCount() <= 1) {
        return mainWindow.document;
    }
    const documents = Array.from(getWindows()).map(({ window }) => window.document);
    return (_a = documents.find(doc => doc.hasFocus())) !== null && _a !== void 0 ? _a : mainWindow.document;
}
Returns the active document across main and child windows.
Prefers the window with focus, otherwise falls back to
the main windows document.