import { useLocation } from 'react-router-dom';
import { useUser } from './useUser';
import { useIsAuthenticated, useMsal } from '@azure/msal-react';
//import { getStoredAccessToken } from '../storage/UnitySessionStorage';
/**
 * Hook that provides a returnTo string for the current location
 */
export function useCurrentPageReturnTo() {
    const { pathname, search, hash } = useLocation();
    // Avoid shorthand to satisfy isolatedDeclarations
    return { pathname: String(pathname), search: String(search), hash: String(hash) };
}
export const useIsAuthed = () => {
    const isAADAuthenticated = useIsAuthenticated();
    return isAADAuthenticated;
};
/**
 * Hook used on routes that require a logged in user to ensure that the user is logged in
 * @see {@link useUser}
 */
export const useAuthedUser = () => {
    const { inProgress } = useMsal();
    const isAuthenticated = useIsAuthed();
    const user = useUser();
    //const login = useLoginAction();
    if (isAuthenticated ||
        (inProgress)) {
        return user;
    }
    else {
        return null;
    }
    // else {
    //   login();
    //   return null;
    // }
};
//# sourceMappingURL=useAuthedUser.js.map