"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getServerSideProps = void 0;
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
 */
const icon_1 = require("@cocalc/frontend/components/icon");
const site_license_1 = require("@cocalc/util/consts/site-license");
const compute_cost_1 = require("@cocalc/util/licenses/purchase/compute-cost");
const consts_1 = require("@cocalc/util/licenses/purchase/consts");
const utils_1 = require("@cocalc/util/licenses/purchase/utils");
const theme_1 = require("@cocalc/util/theme");
const antd_1 = require("antd");
const footer_1 = __importDefault(require("components/landing/footer"));
const head_1 = __importDefault(require("components/landing/head"));
const header_1 = __importDefault(require("components/landing/header"));
const pricing_item_1 = __importStar(require("components/landing/pricing-item"));
const A_1 = __importDefault(require("components/misc/A"));
const link_1 = require("components/store/link");
const config_1 = require("lib/config");
const customize_1 = require("lib/customize");
const with_customize_1 = __importDefault(require("lib/with-customize"));
const pricing_1 = require("components/share/pricing");
const hobby = (() => {
    const conf = {
        run_limit: 2,
        disk: 3,
        ram: 2,
        cpu: 1,
        uptime: "short",
        user: "academic",
    };
    const info = {
        type: "quota",
        user: conf.user,
        upgrade: "custom",
        quantity: conf.run_limit,
        subscription: "monthly",
        start: new Date(),
        custom_ram: conf.ram,
        custom_cpu: conf.cpu,
        custom_disk: conf.disk,
        custom_member: true,
        custom_dedicated_ram: 0,
        custom_dedicated_cpu: 0,
        custom_uptime: conf.uptime,
    };
    const priceM = (0, compute_cost_1.compute_cost)(info);
    const priceY = (0, compute_cost_1.compute_cost)({ ...info, subscription: "yearly" });
    return {
        title: "Hobbyist",
        icon: "battery-quarter",
        projects: conf.run_limit,
        shared_ram: conf.ram,
        shared_cores: conf.cpu,
        disk: conf.disk,
        academic: true,
        uptime: site_license_1.LicenseIdleTimeouts[conf.uptime].labelShort,
        monthly: priceM.discounted_cost,
        yearly: priceY.discounted_cost,
        conf,
    };
})();
const academic = (() => {
    const conf = {
        run_limit: 3,
        disk: 10,
        ram: 5,
        cpu: 2,
        uptime: "day",
        user: "academic",
    };
    const info = {
        type: "quota",
        user: conf.user,
        upgrade: "custom",
        quantity: conf.run_limit,
        subscription: "monthly",
        start: new Date(),
        custom_ram: conf.ram,
        custom_cpu: conf.cpu,
        custom_disk: conf.disk,
        custom_member: true,
        custom_dedicated_ram: 0,
        custom_dedicated_cpu: 0,
        custom_uptime: conf.uptime,
    };
    const priceM = (0, compute_cost_1.compute_cost)(info);
    const priceY = (0, compute_cost_1.compute_cost)({ ...info, subscription: "yearly" });
    return {
        title: "Academic Researcher Group",
        icon: "battery-half",
        projects: conf.run_limit,
        shared_ram: conf.ram,
        shared_cores: conf.cpu,
        disk: conf.disk,
        dedicated_cores: 0,
        academic: true,
        uptime: site_license_1.LicenseIdleTimeouts[conf.uptime].labelShort,
        monthly: priceM.discounted_cost,
        yearly: priceY.discounted_cost,
        conf,
    };
})();
const business = (() => {
    const conf = {
        run_limit: 5,
        disk: 5,
        ram: 4,
        cpu: 1,
        uptime: "medium",
        user: "business",
    };
    const info = {
        type: "quota",
        user: conf.user,
        upgrade: "custom",
        quantity: conf.run_limit,
        subscription: "monthly",
        start: new Date(),
        custom_ram: conf.ram,
        custom_cpu: conf.cpu,
        custom_disk: conf.disk,
        custom_member: true,
        custom_dedicated_ram: 0,
        custom_dedicated_cpu: 0,
        custom_uptime: conf.uptime,
    };
    const priceM = (0, compute_cost_1.compute_cost)(info);
    const priceY = (0, compute_cost_1.compute_cost)({ ...info, subscription: "yearly" });
    return {
        title: "Business Working Group",
        icon: "battery-full",
        projects: conf.run_limit,
        shared_ram: conf.ram,
        shared_cores: conf.cpu,
        disk: conf.disk,
        academic: false,
        uptime: site_license_1.LicenseIdleTimeouts[conf.uptime].labelShort,
        monthly: priceM.discounted_cost,
        yearly: priceY.discounted_cost,
        conf,
    };
})();
const data = [hobby, academic, business];
function dedicated() {
    return ((0, jsx_runtime_1.jsx)(antd_1.Alert, { style: { margin: "15px 0" }, message: "Dedicated Virtual Machines", description: (0, jsx_runtime_1.jsxs)("span", { style: { fontSize: "11pt" }, children: ["For more intensive workloads you can also rent a", " ", (0, jsx_runtime_1.jsx)(A_1.default, { href: "/pricing/dedicated", children: "dedicated virtual machine or disk" }), "."] }), type: "info", showIcon: true }));
}
function Subscriptions({ customize }) {
    return ((0, jsx_runtime_1.jsxs)(customize_1.Customize, { value: customize, children: [(0, jsx_runtime_1.jsx)(head_1.default, { title: "Subscriptions" }), (0, jsx_runtime_1.jsxs)(antd_1.Layout, { children: [(0, jsx_runtime_1.jsx)(header_1.default, { page: "pricing", subPage: "subscriptions" }), (0, jsx_runtime_1.jsxs)(antd_1.Layout.Content, { style: {
                            backgroundColor: "white",
                        }, children: [(0, jsx_runtime_1.jsx)(Body, {}), (0, jsx_runtime_1.jsx)(footer_1.default, {})] })] })] }));
}
exports.default = Subscriptions;
function Body() {
    return ((0, jsx_runtime_1.jsxs)("div", { style: {
            maxWidth: config_1.MAX_WIDTH,
            margin: "15px auto",
            padding: "15px",
            backgroundColor: "white",
        }, children: [(0, jsx_runtime_1.jsx)("div", { style: { textAlign: "center", color: "#444" }, children: (0, jsx_runtime_1.jsxs)("h1", { style: { fontSize: "28pt" }, children: [(0, jsx_runtime_1.jsx)(icon_1.Icon, { name: "calendar", style: { marginRight: "30px" } }), " CoCalc - Subscriptions"] }) }), (0, jsx_runtime_1.jsxs)("div", { style: { fontSize: "12pt" }, children: [(0, jsx_runtime_1.jsx)("a", { id: "subscriptions" }), (0, jsx_runtime_1.jsxs)("p", { children: ["Initially, you start using CoCalc under a", " ", (0, jsx_runtime_1.jsx)(A_1.default, { href: "https://doc.cocalc.com/trial.html", children: "free trial plan" }), " in order to test out the service. If CoCalc works for you, please purchase a license."] }), (0, jsx_runtime_1.jsxs)("p", { children: ["A subscription provides you with a", " ", (0, jsx_runtime_1.jsx)(A_1.default, { href: "https://doc.cocalc.com/licenses.html", children: "license key" }), " for", " ", (0, jsx_runtime_1.jsx)(A_1.default, { href: "https://doc.cocalc.com/project-settings.html#licenses", children: "upgrading your projects" }), " ", "or other projects where you are a collaborator \u2014 everyone using an upgraded project benefits equally. Such a", " ", (0, jsx_runtime_1.jsx)(A_1.default, { href: "/billing/subscriptions", children: "subscription" }), " ", (0, jsx_runtime_1.jsx)("b", { children: "automatically renews" }), " at the end of each period. You can", " ", (0, jsx_runtime_1.jsx)(A_1.default, { href: "/billing/subscriptions", children: (0, jsx_runtime_1.jsx)("b", { children: "cancel at any time" }) }), "."] }), (0, pricing_1.applyLicense)(), (0, jsx_runtime_1.jsx)("h2", { children: "Examples" }), (0, jsx_runtime_1.jsxs)("p", { children: ["We list three typical configurations below, which you can", " ", (0, jsx_runtime_1.jsx)(A_1.default, { href: "/store/site-license", children: "modify and purchase here" }), ". All parameters can be adjusted to fit your needs. Listed upgrades are for each project. Exact prices may vary. Below $", consts_1.MIN_QUOTE, ", only online purchases are available (no purchase orders). Subscriptions receive a", " ", consts_1.discount_monthly_pct, "% discount for monthly and ", consts_1.discount_yearly_pct, "% for yearly periods."] }), (0, jsx_runtime_1.jsx)(antd_1.List, { grid: { gutter: 16, column: 3, xs: 1, sm: 1 }, dataSource: data, renderItem: (item) => ((0, jsx_runtime_1.jsxs)(pricing_item_1.default, { title: item.title, icon: item.icon, children: [(0, jsx_runtime_1.jsx)(pricing_item_1.Line, { amount: item.projects, desc: "Projects" }), (0, jsx_runtime_1.jsx)(pricing_item_1.Line, { amount: item.shared_ram, desc: "Shared RAM per project" }), (0, jsx_runtime_1.jsx)(pricing_item_1.Line, { amount: item.shared_cores, desc: "Shared CPU per project" }), (0, jsx_runtime_1.jsx)(pricing_item_1.Line, { amount: item.disk, desc: "Disk space per project" }), (0, jsx_runtime_1.jsx)(pricing_item_1.Line, { amount: item.uptime, desc: "Idle timeout" }), (0, jsx_runtime_1.jsx)(pricing_item_1.Line, { amount: "Unlimited", desc: "Collaborators" }), item.academic ? ((0, jsx_runtime_1.jsx)(pricing_item_1.Line, { amount: "40%", desc: "Academic discount" })) : ((0, jsx_runtime_1.jsx)(pricing_item_1.Line, { amount: "", desc: "" })), (0, jsx_runtime_1.jsx)("br", {}), (0, jsx_runtime_1.jsx)("br", {}), (0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("span", { style: {
                                                fontWeight: "bold",
                                                fontSize: "18pt",
                                                color: theme_1.COLORS.GRAY_DD,
                                            }, children: (0, utils_1.money)(item.monthly, true) }), " ", "/ month"] }), (0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("span", { style: {
                                                fontWeight: "bold",
                                                fontSize: "18pt",
                                                color: theme_1.COLORS.GRAY_DD,
                                            }, children: (0, utils_1.money)(item.yearly, true) }), " ", "/ year"] }), (0, jsx_runtime_1.jsx)(link_1.LinkToStore, { conf: item.conf })] })) }), (0, pricing_1.listedPrices)(), (0, pricing_1.pricingQuestions)()] }), dedicated()] }));
}
async function getServerSideProps(context) {
    return await (0, with_customize_1.default)({ context });
}
exports.getServerSideProps = getServerSideProps;
//# sourceMappingURL=subscriptions.js.map