"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.EditRunLimit = exports.RunLimit = exports.MAX_ALLOWED_RUN_LIMIT = 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"));
exports.MAX_ALLOWED_RUN_LIMIT = 10000;
function RunLimit(_a) {
    var showExplanations = _a.showExplanations, form = _a.form, onChange = _a.onChange, _b = _a.disabled, disabled = _b === void 0 ? false : _b, _c = _a.boost, boost = _c === void 0 ? false : _c;
    function extra() {
        if (!showExplanations)
            return;
        return ((0, jsx_runtime_1.jsxs)("div", __assign({ style: { marginTop: "5px" } }, { children: [boost ? ((0, jsx_runtime_1.jsx)("div", __assign({ 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, __assign({ 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, __assign({ plain: true }, { children: "Maximum number of simultaneously upgraded projects" })), (0, jsx_runtime_1.jsx)(antd_1.Form.Item, __assign({ label: "Run Limit", name: "run_limit", initialValue: 1, extra: extra() }, { children: (0, jsx_runtime_1.jsx)(EditRunLimit, { disabled: disabled, onChange: function (run_limit) {
                        form.setFieldsValue({ run_limit: run_limit });
                        onChange();
                    } }) }))] }));
}
exports.RunLimit = RunLimit;
function EditRunLimit(_a) {
    var value = _a.value, onChange = _a.onChange, disabled = _a.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