"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 });
exports.QuotaConfig = void 0;
var 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
 */
var antd_1 = require("antd");
var A_1 = __importDefault(require("components/misc/A"));
var integer_slider_1 = __importDefault(require("components/misc/integer-slider"));
var QuotaConfig = function (props) {
    var showExplanations = props.showExplanations, form = props.form, _a = props.disabled, disabled = _a === void 0 ? false : _a, onChange = props.onChange, _b = props.boost, boost = _b === void 0 ? false : _b;
    function title() {
        if (boost) {
            return "Booster";
        }
        else {
            return "Quota upgrades";
        }
    }
    var min = boost ? 0 : 1;
    // e.g. since we can't go beyond the max cpu, but the base license already provides one, don't let users select the max
    var adjMax = boost ? 1 : 0;
    function ram() {
        var defaultRam = 2; // 2gb highly recommended
        var maxRam = 16 - adjMax;
        return ((0, jsx_runtime_1.jsx)(antd_1.Form.Item, __assign({ label: "Shared RAM", name: "ram", initialValue: boost ? 0 : defaultRam, extra: showExplanations ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: ["Each project can use up to this much of RAM. Note that RAM may be limited, if many other users are using the same host \u2013 though member hosting significantly reduces competition for RAM. We recommend at least 2G! Beyond that, we also offer", " ", (0, jsx_runtime_1.jsx)(A_1.default, __assign({ href: "/store/dedicated?type=vm" }, { children: "dedicated virtual machines" })), " ", "with larger memory options."] })) : undefined }, { children: (0, jsx_runtime_1.jsx)(integer_slider_1.default, { disabled: disabled, min: min, max: maxRam, onChange: function (ram) {
                    form.setFieldsValue({ ram: ram });
                    onChange();
                }, units: "G RAM", presets: boost ? [0, 2, 4, 8, 10] : [1, 2, 4, 8, 16] }) })));
    }
    function cpu() {
        return ((0, jsx_runtime_1.jsx)(antd_1.Form.Item, __assign({ label: "Shared CPUs", name: "cpu", initialValue: min, extra: showExplanations ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(A_1.default, __assign({ href: "https://cloud.google.com/compute/docs/faq#virtualcpu" }, { children: "Google cloud vCPU's." })), " ", "To keep prices low, these vCPU's may be shared with other projects, though member hosting very significantly reduces competition for CPUs. We also offer", " ", (0, jsx_runtime_1.jsx)(A_1.default, __assign({ href: "/store/dedicated?type=vm" }, { children: "dedicated virtual machines" })), " ", "with more CPU options."] })) : undefined }, { children: (0, jsx_runtime_1.jsx)(integer_slider_1.default, { disabled: disabled, min: min, max: 3 - adjMax, onChange: function (cpu) {
                    form.setFieldsValue({ cpu: cpu });
                    onChange();
                }, units: "vCPU", presets: boost ? [0, 1, 2] : [1, 2, 3] }) })));
    }
    function disk() {
        // 2022-06: price increase "version 2": minimum disk we sell (also the free quota) is 3gb, not 1gb
        var defaultDisk = 3;
        var minDisk = boost ? 0 : defaultDisk;
        var maxDisk = 15 - adjMax * defaultDisk;
        return ((0, jsx_runtime_1.jsx)(antd_1.Form.Item, __assign({ label: "Disk space", name: "disk", initialValue: minDisk, extra: showExplanations ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: ["Extra disk space lets you store a larger number of files. Snapshots and file edit history is included at no additional charge. Each project receives at least ", defaultDisk, "G of storage space. We also offer much larger", " ", (0, jsx_runtime_1.jsx)(A_1.default, __assign({ href: "/store/dedicated?type=disk" }, { children: "dedicated disks" })), "."] })) : undefined }, { children: (0, jsx_runtime_1.jsx)(integer_slider_1.default, { disabled: disabled, min: minDisk, max: maxDisk, onChange: function (disk) {
                    form.setFieldsValue({ disk: disk });
                    onChange();
                }, units: "G Disk", presets: boost ? [0, 3, 6, maxDisk] : [3, 5, 10, maxDisk] }) })));
    }
    return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(antd_1.Divider, __assign({ plain: true }, { children: title() })), ram(), cpu(), disk()] }));
};
exports.QuotaConfig = QuotaConfig;
//# sourceMappingURL=quota-config.js.map