import KeyIcon from 'mdi-react/KeyIcon';
import * as React from 'react';
import { Redirect } from 'react-router-dom';
import { HeroPage } from '../components/HeroPage';
import { PageTitle } from '../components/PageTitle';
import { eventLogger } from '../tracking/eventLogger';
import { getReturnTo } from './SignInSignUpCommon';
import { UsernamePasswordSignInForm } from './UsernamePasswordSignInForm';
export class SignInPage extends React.Component {
    componentDidMount() {
        eventLogger.logViewEvent('SignIn', {}, false);
    }
    render() {
        if (this.props.user) {
            const returnTo = getReturnTo(this.props.location);
            return React.createElement(Redirect, { to: returnTo });
        }
        return (React.createElement("div", { className: "signin-signup-page sign-in-page" },
            React.createElement(PageTitle, { title: "Sign in" }),
            React.createElement(HeroPage, { icon: KeyIcon, title: "Sign into Sourcegraph", body: window.context.authProviders && window.context.authProviders.length > 0 ? (window.context.authProviders.map((p, i) => p.isBuiltin ? (React.createElement(UsernamePasswordSignInForm, Object.assign({ key: i }, this.props))) : (React.createElement("a", { key: i, href: p.authenticationURL, className: "btn btn-primary mt-3 mb-1" },
                    "Sign in with ",
                    p.displayName)))) : (React.createElement("div", { className: "alert alert-info mt-3" }, "No authentication providers are available. Contact a site administrator for help.")) })));
    }
}
//# sourceMappingURL=SignInPage.js.map