"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.EditRunLimit = exports.RunLimit = exports.MAX_ALLOWED_RUN_LIMIT = 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 antd_1 = require("antd");
const A_1 = __importDefault(require("components/misc/A"));
const integer_slider_1 = __importDefault(require("components/misc/integer-slider"));
exports.MAX_ALLOWED_RUN_LIMIT = 10000;
function RunLimit({ showExplanations, form, onChange, disabled = false, boost = false, }) {
    function extra() {
        if (!showExplanations)
            return;
        return ((0, jsx_runtime_1.jsxs)("div", { style: { marginTop: "5px" }, children: [boost ? ((0, jsx_runtime_1.jsx)("div", { style: { fontWeight: "bold" }, children: "It's not necessary to match the run limit of the license you want to boost!" })) : undefined, "Simultaneously run this many projects using this license. You, and anyone you share the license code with, can apply the license to an unlimited number of projects, but it will only be used up to the run limit. When", " ", (0, jsx_runtime_1.jsx)(A_1.default, { href: "https://doc.cocalc.com/teaching-instructors.html", children: "teaching a course" }), ",", " ", (0, jsx_runtime_1.jsx)("b", { children: (0, jsx_runtime_1.jsx)("i", { children: "the run limit is typically 2 more than the number of students" }) }), "."] }));
    }
    return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(antd_1.Divider, { plain: true, children: "Maximum number of simultaneously upgraded projects" }), (0, jsx_runtime_1.jsx)(antd_1.Form.Item, { label: "Run Limit", name: "run_limit", initialValue: 1, extra: extra(), children: (0, jsx_runtime_1.jsx)(EditRunLimit, { disabled: disabled, onChange: (run_limit) => {
                        form.setFieldsValue({ run_limit });
                        onChange();
                    } }) })] }));
}
exports.RunLimit = RunLimit;
function EditRunLimit({ value, onChange, disabled, }) {
    return ((0, jsx_runtime_1.jsx)(integer_slider_1.default, { value: value, min: 1, disabled: disabled, max: 300, maxText: exports.MAX_ALLOWED_RUN_LIMIT, onChange: onChange, units: "projects", presets: [1, 2, 10, 50, 100, 250, 500] }));
}
exports.EditRunLimit = EditRunLimit;
//# sourceMappingURL=run-limit.js.map