"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 © 2021 Sagemath, Inc.
 *  License: AGPLv3 s.t. "Commons Clause" – see LICENSE.md for details
 */
const antd_1 = require("antd");
const sign_in_1 = __importDefault(require("components/landing/sign-in"));
const sanitized_markdown_1 = __importDefault(require("components/misc/sanitized-markdown"));
const image_1 = __importDefault(require("./image"));
const use_customize_1 = __importDefault(require("lib/use-customize"));
const path_1 = __importDefault(require("components/app/path"));
function Logo({ logo, title }) {
    if (!logo)
        return null;
    if (typeof logo == "string" || logo?.src != null) {
        return ((0, jsx_runtime_1.jsx)(image_1.default, { src: logo, style: { width: "200px" }, alt: `${title} logo` }));
    }
    return logo;
}
function Content(props) {
    const { title, alt, caption, description, image, aboveImage, indexInfo, logo, startup, subtitle, subtitleBelow = false, } = props;
    const { sandboxProjectId } = (0, use_customize_1.default)();
    function renderIndexInfo() {
        if (!indexInfo)
            return;
        return ((0, jsx_runtime_1.jsx)(antd_1.Col, { xs: 20, children: (0, jsx_runtime_1.jsx)(sanitized_markdown_1.default, { value: indexInfo, style: { padding: "20xp" } }) }));
    }
    function renderSubtitleTop() {
        if (subtitleBelow)
            return;
        return (0, jsx_runtime_1.jsx)("h2", { style: { color: "#333" }, children: subtitle });
    }
    function renderSubtitleBelow() {
        if (!subtitleBelow)
            return;
        return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(antd_1.Col, { xs: 0, sm: 4 }), (0, jsx_runtime_1.jsx)(antd_1.Col, { xs: 24, sm: 16, children: (0, jsx_runtime_1.jsx)("h2", { style: { color: "#333", textAlign: "center", marginTop: "30px" }, children: subtitle }) })] }));
    }
    function renderImage() {
        // if the index info is anything more than an empty string, we render this here instead
        if (!!indexInfo)
            return renderIndexInfo();
        if (!image)
            return;
        return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(image_1.default, { src: image, priority: true, style: { padding: "15px" }, alt: alt ?? `Image illustrating ${title}` }), (0, jsx_runtime_1.jsx)("div", { style: { textAlign: "center", color: "#333", fontSize: "12pt" }, children: caption })] }));
    }
    function renderAboveImage() {
        return aboveImage != null
            ? aboveImage
            : sandboxProjectId && ((0, jsx_runtime_1.jsx)("div", { style: { margin: "15px" }, children: (0, jsx_runtime_1.jsx)(path_1.default, { style: { marginBottom: "15px" }, project_id: sandboxProjectId, description: "Public Sandbox" }) }));
    }
    return ((0, jsx_runtime_1.jsxs)("div", { style: { padding: "30px 0" }, children: [(0, jsx_runtime_1.jsxs)(antd_1.Row, { children: [(0, jsx_runtime_1.jsx)(antd_1.Col, { sm: 10, xs: 24, style: {
                            display: "flex",
                            alignItems: "center",
                            paddingTop: "15px",
                        }, children: (0, jsx_runtime_1.jsxs)("div", { style: { textAlign: "center", margin: "auto", padding: "0 10%" }, children: [(0, jsx_runtime_1.jsx)(Logo, { logo: logo, title: title }), (0, jsx_runtime_1.jsx)("br", {}), (0, jsx_runtime_1.jsx)("br", {}), (0, jsx_runtime_1.jsx)("h1", { style: { color: "#333" }, children: title }), renderSubtitleTop(), (0, jsx_runtime_1.jsx)("h3", { style: { color: "#666" }, children: description })] }) }), (0, jsx_runtime_1.jsxs)(antd_1.Col, { sm: 14, xs: 24, children: [renderAboveImage(), renderImage()] }), renderSubtitleBelow()] }), (0, jsx_runtime_1.jsx)(sign_in_1.default, { startup: startup ?? title, hideFree: true })] }));
}
exports.default = Content;
//# sourceMappingURL=content.js.map