"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 r_join_1 = require("@cocalc/frontend/components/r_join");
var A_1 = __importDefault(require("components/misc/A"));
var icon_1 = require("@cocalc/frontend/components/icon");
var customize_1 = require("lib/customize");
var software = {
    index: {},
    executables: { label: "Executables" },
    python: { label: "Python" },
    r: { label: "R Stats" },
    julia: { label: "Julia" },
    octave: { label: "Octave" },
};
var features = {
    index: {},
    "jupyter-notebook": { label: "Jupyter" },
    "whiteboard": { label: "Whiteboard" },
    "latex-editor": { label: "LaTeX" },
    linux: { label: "Linux" },
    python: { label: "Python" },
    "r-statistical-software": { label: "R Stats" },
    sage: { label: "SageMath" },
    octave: { label: "Octave" },
    julia: { label: "Julia" },
    teaching: { label: "Teaching" },
    terminal: { label: "Terminal" },
    x11: { label: "X11" },
    compare: { label: "Compare" },
    api: { label: "API" },
};
var pricing = {
    index: {},
    products: { label: "Products" },
    subscriptions: { label: "Subscriptions" },
    courses: { label: "Courses" },
    dedicated: { label: "Dedicated" },
    onprem: { label: "OnPrem" },
};
var policies = {
    index: {},
    terms: { label: "Terms of Service", hide: function (c) { return !c.onCoCalcCom; } },
    copyright: { label: "Copyright", hide: function (c) { return !c.onCoCalcCom; } },
    privacy: { label: "Privacy", hide: function (c) { return !c.onCoCalcCom; } },
    thirdparties: { label: "Third Parties", hide: function (c) { return !c.onCoCalcCom; } },
    ferpa: { label: "FERPA", hide: function (c) { return !c.onCoCalcCom; } },
    accessibility: { label: "Accessibility", hide: function (c) { return !c.onCoCalcCom; } },
    imprint: { label: "Imprint", hide: function (c) { return !c.imprint; } },
    policies: { label: "Policies", hide: function (c) { return !c.policies; } },
};
var info = {
    index: {},
    doc: { label: "Documentation" },
    status: { label: "Status" },
    run: { label: "Run CoCalc" },
};
var sign_in = {
    "sign-in": { label: "Sign In", href: "/auth/sign-in" },
    "password-reset": { label: "Password Reset", href: "/auth/password-reset" },
};
var support = {
    index: {},
    community: { label: "Community" },
    new: { label: "New Ticket", hide: function (customize) { return !customize.zendesk; } },
    tickets: { label: "Tickets", hide: function (customize) { return !customize.zendesk; } },
};
var PAGES = {
    features: features,
    software: software,
    pricing: pricing,
    policies: policies,
    share: {},
    info: info,
    "sign-up": {},
    "sign-in": sign_in,
    try: {},
    support: support,
};
function SubNav(_a) {
    var _b, _c, _d;
    var page = _a.page, subPage = _a.subPage;
    var customize = (0, customize_1.useCustomize)();
    var tabs = [];
    var p = PAGES[page];
    if (p == null)
        return null;
    for (var name_1 in p) {
        if ((_b = p[name_1]) === null || _b === void 0 ? void 0 : _b.disabled)
            continue;
        if ((_d = (_c = p[name_1]) === null || _c === void 0 ? void 0 : _c.hide) === null || _d === void 0 ? void 0 : _d.call(_c, customize))
            continue;
        var _e = p[name_1], label = _e.label, href = _e.href, icon = _e.icon;
        if (name_1 == "index") {
            if (!href)
                href = "/".concat(page);
            if (!icon)
                icon = "home";
        }
        var selected = name_1 == "index" ? !subPage : subPage == name_1;
        tabs.push((0, jsx_runtime_1.jsx)(SubPageTab, { page: page, selected: selected, name: name_1, label: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [icon && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(icon_1.Icon, { name: icon }), label ? " " : ""] })), label] }), href: href }, name_1));
    }
    return ((0, jsx_runtime_1.jsx)("div", __assign({ style: {
            backgroundColor: "white",
            textAlign: "center",
            color: "#666",
            padding: "15px 0",
        } }, { children: (0, r_join_1.r_join)(tabs, (0, jsx_runtime_1.jsx)("div", { style: { width: "16px", display: "inline-block" } })) })));
}
exports.default = SubNav;
function SubPageTab(_a) {
    var page = _a.page, name = _a.name, selected = _a.selected, label = _a.label, href = _a.href;
    return ((0, jsx_runtime_1.jsx)(A_1.default, __assign({ href: href !== null && href !== void 0 ? href : "/".concat(page, "/").concat(name), style: selected
            ? {
                fontWeight: "bold",
                color: "blue",
                paddingBottom: "3px",
                borderBottom: "3px solid blue",
            }
            : { color: "#555" } }, { children: label })));
}
//# sourceMappingURL=sub-nav.js.map