"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const jsx_runtime_1 = require("react/jsx-runtime");
/*
 *  This file is part of CoCalc: Copyright © 2022 Sagemath, Inc.
 *  License: AGPLv3 s.t. "Commons Clause" – see LICENSE.md for details
 */
// TODO: below we need to get the strategies!
// and also requiresToken for SignUp!
const icon_1 = require("@cocalc/frontend/components/icon");
const antd_1 = require("antd");
const sign_in_1 = __importDefault(require("components/auth/sign-in"));
const sign_up_1 = __importDefault(require("components/auth/sign-up"));
const router_1 = require("next/router");
const react_1 = require("react");
function InPlaceSignInOrUp(props) {
    const { title, why, onSuccess } = props;
    const router = (0, router_1.useRouter)();
    const [show, setShow] = (0, react_1.useState)("");
    return ((0, jsx_runtime_1.jsxs)("div", { style: { textAlign: "center" }, children: [(0, jsx_runtime_1.jsxs)(antd_1.Divider, { children: [(0, jsx_runtime_1.jsx)(icon_1.Icon, { name: "sign-in", style: { marginRight: "10px" } }), " ", title] }), (0, jsx_runtime_1.jsx)("a", { onClick: () => setShow("sign-in"), children: "Sign In" }), " or", " ", (0, jsx_runtime_1.jsx)("a", { onClick: () => setShow("sign-up"), children: "Sign Up" }), why == null ? "." : (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [" ", why, "."] }), (0, jsx_runtime_1.jsx)("br", {}), (0, jsx_runtime_1.jsx)("br", {}), show == "sign-in" && ((0, jsx_runtime_1.jsx)(sign_in_1.default, { minimal: true, onSuccess: onSuccess ??
                    (() => router.push({
                        pathname: router.asPath.split("?")[0],
                        query: { edit: "true" },
                    })) })), show == "sign-up" && ((0, jsx_runtime_1.jsx)(sign_up_1.default, { minimal: true, onSuccess: onSuccess ??
                    (() => router.push({
                        pathname: router.asPath.split("?")[0],
                        query: { edit: "true" },
                    })) }))] }));
}
exports.default = InPlaceSignInOrUp;
//# sourceMappingURL=in-place-sign-in-or-up.js.map