"use strict";
var __assign = (this && this.__assign) || function () {
    __assign = Object.assign || function(t) {
        for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                t[p] = s[p];
        }
        return t;
    };
    return __assign.apply(this, arguments);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var 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
 */
var antd_1 = require("antd");
var sign_in_1 = __importDefault(require("components/landing/sign-in"));
var sanitized_markdown_1 = __importDefault(require("components/misc/sanitized-markdown"));
var image_1 = __importDefault(require("./image"));
var use_customize_1 = __importDefault(require("lib/use-customize"));
var path_1 = __importDefault(require("components/app/path"));
function Logo(_a) {
    var logo = _a.logo, title = _a.title;
    if (!logo)
        return null;
    if (typeof logo == "string" || (logo === null || logo === void 0 ? void 0 : logo.src) != null) {
        return ((0, jsx_runtime_1.jsx)(image_1.default, { src: logo, style: { width: "200px" }, alt: "".concat(title, " logo") }));
    }
    return logo;
}
function Content(props) {
    var title = props.title, alt = props.alt, caption = props.caption, description = props.description, image = props.image, aboveImage = props.aboveImage, indexInfo = props.indexInfo, logo = props.logo, startup = props.startup, subtitle = props.subtitle, _a = props.subtitleBelow, subtitleBelow = _a === void 0 ? false : _a;
    var sandboxProjectId = (0, use_customize_1.default)().sandboxProjectId;
    function renderIndexInfo() {
        if (!indexInfo)
            return;
        return ((0, jsx_runtime_1.jsx)(antd_1.Col, __assign({ 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", __assign({ 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, __assign({ xs: 24, sm: 16 }, { children: (0, jsx_runtime_1.jsx)("h2", __assign({ 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 !== null && alt !== void 0 ? alt : "Image illustrating ".concat(title) }), (0, jsx_runtime_1.jsx)("div", __assign({ style: { textAlign: "center", color: "#333", fontSize: "12pt" } }, { children: caption }))] }));
    }
    function renderAboveImage() {
        return aboveImage != null
            ? aboveImage
            : sandboxProjectId && ((0, jsx_runtime_1.jsx)("div", __assign({ 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", __assign({ style: { padding: "30px 0" } }, { children: [(0, jsx_runtime_1.jsxs)(antd_1.Row, { children: [(0, jsx_runtime_1.jsx)(antd_1.Col, __assign({ sm: 10, xs: 24, style: {
                            display: "flex",
                            alignItems: "center",
                            paddingTop: "15px",
                        } }, { children: (0, jsx_runtime_1.jsxs)("div", __assign({ 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", __assign({ style: { color: "#333" } }, { children: title })), renderSubtitleTop(), (0, jsx_runtime_1.jsx)("h3", __assign({ style: { color: "#666" } }, { children: description }))] })) })), (0, jsx_runtime_1.jsxs)(antd_1.Col, __assign({ sm: 14, xs: 24 }, { children: [renderAboveImage(), renderImage()] })), renderSubtitleBelow()] }), (0, jsx_runtime_1.jsx)(sign_in_1.default, { startup: startup !== null && startup !== void 0 ? startup : title, hideFree: true })] })));
}
exports.default = Content;
//# sourceMappingURL=content.js.map