"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 __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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __generator = (this && this.__generator) || function (thisArg, body) {
    var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
    return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
    function verb(n) { return function (v) { return step([n, v]); }; }
    function step(op) {
        if (f) throw new TypeError("Generator is already executing.");
        while (_) try {
            if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
            if (y = 0, t) op = [op[0] & 2, t.value];
            switch (op[0]) {
                case 0: case 1: t = op; break;
                case 4: _.label++; return { value: op[1], done: false };
                case 5: _.label++; y = op[1]; op = [0]; continue;
                case 7: op = _.ops.pop(); _.trys.pop(); continue;
                default:
                    if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
                    if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
                    if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
                    if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
                    if (t[2]) _.ops.pop();
                    _.trys.pop(); continue;
            }
            op = body.call(thisArg, _);
        } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
        if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
    }
};
var __read = (this && this.__read) || function (o, n) {
    var m = typeof Symbol === "function" && o[Symbol.iterator];
    if (!m) return o;
    var i = m.call(o), r, ar = [], e;
    try {
        while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
    }
    catch (error) { e = { error: error }; }
    finally {
        try {
            if (r && !r.done && (m = i["return"])) m.call(i);
        }
        finally { if (e) throw e.error; }
    }
    return ar;
};
var __values = (this && this.__values) || function(o) {
    var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
    if (m) return m.call(o);
    if (o && typeof o.length === "number") return {
        next: function () {
            if (o && i >= o.length) o = void 0;
            return { value: o && o[i++], done: !o };
        }
    };
    throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Quota = exports.quotaColumn = void 0;
var jsx_runtime_1 = require("react/jsx-runtime");
var react_1 = require("react");
var api_1 = __importDefault(require("lib/hooks/api"));
var post_1 = __importDefault(require("lib/api/post"));
var loading_1 = __importDefault(require("components/share/loading"));
var antd_1 = require("antd");
var license_1 = require("./license");
var avatar_1 = __importDefault(require("components/account/avatar"));
var name_1 = __importDefault(require("components/account/name"));
var editable_license_1 = require("./editable-license");
var misc_1 = require("@cocalc/util/misc");
var misc_2 = require("@cocalc/util/misc");
var icon_1 = require("@cocalc/frontend/components/icon");
var timestamp_1 = __importDefault(require("components/misc/timestamp"));
var license_2 = __importStar(require("./license"));
var select_users_1 = __importDefault(require("components/account/select-users"));
var use_customize_1 = __importDefault(require("lib/use-customize"));
var A_1 = __importDefault(require("components/misc/A"));
var renderTimestamp = function (epoch) { return (0, jsx_runtime_1.jsx)(timestamp_1.default, { epoch: epoch }); };
exports.quotaColumn = {
    title: ((0, jsx_runtime_1.jsxs)(antd_1.Popover, __assign({ title: "Quota", content: (0, jsx_runtime_1.jsx)("div", __assign({ style: { maxWidth: "75ex" } }, { children: "This is the license quota. If the license is active on a project, its quotas will be set to at least the values listed here." })) }, { children: ["Quota", " "] }))),
    width: "35%",
    responsive: ["sm"],
    render: function (_, license) { return (0, jsx_runtime_1.jsx)(Quota, __assign({}, license)); },
};
function Quota(_a) {
    var quota = _a.quota, state = _a.state, upgrades = _a.upgrades;
    return state != null && state != "running" ? ((0, jsx_runtime_1.jsx)("span", { children: "\u2014" })) : ((0, jsx_runtime_1.jsxs)("span", __assign({ style: {
            wordWrap: "break-word",
            wordBreak: "break-word",
        } }, { children: [quota && (0, jsx_runtime_1.jsx)(license_1.Quota, { quota: quota }), upgrades && (0, jsx_runtime_1.jsx)("pre", { children: JSON.stringify(upgrades) })] })));
}
exports.Quota = Quota;
function TitleDescId(_a) {
    var title = _a.title, description = _a.description, id = _a.id, onChange = _a.onChange;
    return ((0, jsx_runtime_1.jsxs)("div", __assign({ style: {
            wordWrap: "break-word",
            wordBreak: "break-word",
            color: "#333",
        } }, { children: [(0, jsx_runtime_1.jsx)("div", __assign({ style: { fontFamily: "monospace", fontSize: "9pt" } }, { children: (0, jsx_runtime_1.jsx)(license_2.default, { license_id: id }) })), (0, jsx_runtime_1.jsx)(editable_license_1.EditableTitle, { license_id: id, title: title, onChange: onChange }), (0, jsx_runtime_1.jsx)(editable_license_1.EditableDescription, { license_id: id, description: description, onChange: onChange })] })));
}
function Managers(_a) {
    var managers = _a.managers, id = _a.id, onChange = _a.onChange;
    return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", __assign({ style: { maxHeight: "65px", overflowY: "auto" } }, { children: managers.map(function (account_id) { return ((0, jsx_runtime_1.jsx)(avatar_1.default, { style: { margin: "0 5px 5px 0" }, account_id: account_id, size: 24, extra: (0, jsx_runtime_1.jsx)(RemoveManager, { license_id: id, managers: managers, account_id: account_id, onChange: onChange }) }, account_id)); }) })), (0, jsx_runtime_1.jsx)(AddManagers, { license_id: id, managers: managers, onChange: onChange })] }));
}
function RunLimit(_a) {
    var run_limit = _a.run_limit;
    return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: run_limit });
}
function LastUsed(_a) {
    var last_used = _a.last_used;
    return renderTimestamp(last_used);
}
function Created(_a) {
    var created = _a.created;
    return renderTimestamp(created);
}
function columns(onChange) {
    return [
        {
            responsive: ["xs"],
            title: "Managed Licenses",
            render: function (_, license) { return ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)(TitleDescId, __assign({}, license, { onChange: onChange })), (0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)(license_2.DateRange, __assign({}, license)) }), " ", "Run Limit: ", (0, jsx_runtime_1.jsx)(RunLimit, __assign({}, license)), (0, jsx_runtime_1.jsxs)("div", { children: ["Quota: ", (0, jsx_runtime_1.jsx)(Quota, __assign({}, license))] }), "Last Used: ", (0, jsx_runtime_1.jsx)(LastUsed, __assign({}, license)), (0, jsx_runtime_1.jsx)("br", {}), "Created: ", (0, jsx_runtime_1.jsx)(Created, __assign({}, license)), (0, jsx_runtime_1.jsxs)("div", __assign({ style: { border: "1px solid lightgrey", padding: "5px 15px" } }, { children: ["Managers ", (0, jsx_runtime_1.jsx)(Managers, __assign({}, license, { onChange: onChange }))] }))] })); },
        },
        {
            responsive: ["sm"],
            title: ((0, jsx_runtime_1.jsx)(antd_1.Popover, __assign({ placement: "top", title: "Id, Title and Description of the License", content: (0, jsx_runtime_1.jsx)("div", __assign({ style: { maxWidth: "75ex" } }, { children: "The first line is the id of the license, which anybody can enter in various places to upgrade projects or courses. The title and description of the license help you keep track of what the license is for, and you can edit both fields here as well by clicking on them." })) }, { children: "License" }))),
            key: "title",
            width: "40%",
            sorter: { compare: function (a, b) { return (0, misc_2.cmp)(a.title, b.title); } },
            render: function (_, license) { return ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)(TitleDescId, __assign({}, license, { onChange: onChange })), (0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)(license_2.DateRange, __assign({}, license)) })] })); },
        },
        {
            responsive: ["sm"],
            width: "15%",
            title: ((0, jsx_runtime_1.jsx)(antd_1.Popover, __assign({ title: "Managers", content: (0, jsx_runtime_1.jsx)("div", __assign({ style: { maxWidth: "75ex" } }, { children: "These are the managers of this license. They can see extra information about the license, the license is included in any dropdown where they can select a license, and they can add or remove other license managers. You are a manager of all licenses listed here." })) }, { children: "Managers" }))),
            key: "managers",
            render: function (_, license) { return (0, jsx_runtime_1.jsx)(Managers, __assign({}, license, { onChange: onChange })); },
        },
        {
            responsive: ["sm"],
            title: ((0, jsx_runtime_1.jsx)(antd_1.Popover, __assign({ placement: "top", title: "Run Limit", content: (0, jsx_runtime_1.jsx)("div", __assign({ style: { maxWidth: "75ex" } }, { children: "The maximum number of simultaneous running projects that this license can upgrade. You can apply the license to any number of projects, but it only impacts this many projects at once." })) }, { children: "Run Limit" }))),
            align: "center",
            render: function (_, license) { return (0, jsx_runtime_1.jsx)(RunLimit, __assign({}, license)); },
            sorter: { compare: function (a, b) { return (0, misc_2.cmp)(a.run_limit, b.run_limit); } },
        },
        exports.quotaColumn,
        {
            responsive: ["sm"],
            title: ((0, jsx_runtime_1.jsxs)(antd_1.Popover, __assign({ placement: "top", title: "When License was Last Used", content: (0, jsx_runtime_1.jsx)("div", __assign({ style: { maxWidth: "75ex" } }, { children: "This is when this license was last used to upgrade a project when the project was starting. It's the point in time when the project started." })) }, { children: ["Last Used", " "] }))),
            render: function (_, license) { return (0, jsx_runtime_1.jsx)(LastUsed, __assign({}, license)); },
            sorter: { compare: function (a, b) { return (0, misc_2.cmp)(a.last_used, b.last_used); } },
        },
        /*   {
          responsive: ["sm"],
          title: (
            <Popover
              placement="top"
              title="When License Becomes Activate"
              content={
                <div style={{ maxWidth: "75ex" }}>
                  This is when the license becomes active. In can be in the future,
                  in which case the license will be valid and useful in the future,
                  but not right now.
                </div>
              }
            >
              Activates{" "}
            </Popover>
          ),
          render: (_, license) => <Activates {...license} />,
          sorter: { compare: (a, b) => cmp(a.activates, b.activates) },
        },
        {
          responsive: ["sm"],
          title: (
            <Popover
              placement="top"
              title="When License Expires"
              content={
                <div style={{ maxWidth: "75ex" }}>
                  This is when the license expires. Unless there is a subscription
                  that renews it, after this point in time the license will stop
                  upgrading projects.
                </div>
              }
            >
              Expires{" "}
            </Popover>
          ),
          render: (_, license) => <Expires {...license} />,
          sorter: { compare: (a, b) => cmp(a.expires, b.expires) },
        },*/
        {
            responsive: ["sm"],
            title: ((0, jsx_runtime_1.jsxs)(antd_1.Popover, __assign({ placement: "top", title: "When License was Created", content: (0, jsx_runtime_1.jsx)("div", __assign({ style: { maxWidth: "75ex" } }, { children: "This is when the license was created." })) }, { children: ["Created", " "] }))),
            render: function (_, license) { return (0, jsx_runtime_1.jsx)(Created, __assign({}, license)); },
            sorter: { compare: function (a, b) { return (0, misc_2.cmp)(a.created, b.created); } },
        },
    ];
}
function ManagedLicenses() {
    var _a = (0, api_1.default)("licenses/get-managed"), result = _a.result, error = _a.error, call = _a.call;
    var _b = __read((0, react_1.useState)(""), 2), search = _b[0], setSearch = _b[1];
    var _c = __read((0, react_1.useState)(false), 2), showExpired = _c[0], setShowExpired = _c[1];
    var numExpired = (0, react_1.useMemo)(function () {
        var e_1, _a;
        if (!result)
            return 0;
        var n = 0;
        var t = new Date().valueOf();
        try {
            for (var result_1 = __values(result), result_1_1 = result_1.next(); !result_1_1.done; result_1_1 = result_1.next()) {
                var x = result_1_1.value;
                if (x.expires && x.expires <= t) {
                    n += 1;
                }
            }
        }
        catch (e_1_1) { e_1 = { error: e_1_1 }; }
        finally {
            try {
                if (result_1_1 && !result_1_1.done && (_a = result_1.return)) _a.call(result_1);
            }
            finally { if (e_1) throw e_1.error; }
        }
        return n;
    }, [result]);
    if (error) {
        return (0, jsx_runtime_1.jsx)(antd_1.Alert, { type: "error", message: error });
    }
    if (!result) {
        return (0, jsx_runtime_1.jsx)(loading_1.default, { style: { fontSize: "16pt", margin: "auto" } });
    }
    if (search) {
        result = doSearch(result, search);
    }
    if (!showExpired) {
        // filter out anything that is expired
        result = removeExpired(result);
    }
    function onChange() {
        call();
    }
    return ((0, jsx_runtime_1.jsxs)("div", __assign({ style: { width: "100%", overflowX: "auto", minHeight: "50vh" } }, { children: [(0, jsx_runtime_1.jsxs)("h3", { children: ["Licenses that you Manage (", result.length, ")"] }), "These are the licenses that you have purchased or been added to manage. You can add other people as managers of any of these licenses, if they need to be able to use these licenses to upgrade projects. You can also", " ", (0, jsx_runtime_1.jsx)(A_1.default, __assign({ href: "/billing/subscriptions" }, { children: "manage your purchased subscriptions" })), " ", "and browse ", (0, jsx_runtime_1.jsx)(A_1.default, __assign({ href: "/billing/receipts" }, { children: "your receipts and invoices" })), ".", (0, jsx_runtime_1.jsxs)("div", __assign({ style: { margin: "15px 0" } }, { children: [(0, jsx_runtime_1.jsxs)(antd_1.Checkbox, __assign({ disabled: numExpired == 0, style: { float: "right" }, checked: showExpired, onChange: function (e) { return setShowExpired(e.target.checked); } }, { children: ["Show Expired (", numExpired, ")"] })), (0, jsx_runtime_1.jsx)(antd_1.Input.Search, { placeholder: "Search...", allowClear: true, onChange: function (e) { return setSearch(e.target.value); }, style: { width: "50ex", maxWidth: "100%" } })] })), (0, jsx_runtime_1.jsx)(antd_1.Table, { columns: columns(onChange), dataSource: result, rowKey: "id", style: { marginTop: "15px" }, pagination: { hideOnSinglePage: true, pageSize: 100 } })] })));
}
exports.default = ManagedLicenses;
function doSearch(data, search) {
    var e_2, _a;
    var _b, _c, _d, _e;
    var v = (0, misc_1.search_split)(search.toLowerCase().trim());
    var w = [];
    try {
        for (var data_1 = __values(data), data_1_1 = data_1.next(); !data_1_1.done; data_1_1 = data_1.next()) {
            var x = data_1_1.value;
            if (x["search"] == null) {
                x["search"] = "".concat((_b = x["title"]) !== null && _b !== void 0 ? _b : "", " ").concat((_c = x["description"]) !== null && _c !== void 0 ? _c : "", " ").concat(x["id"], " ").concat((_e = (_d = x["info"]) === null || _d === void 0 ? void 0 : _d.purchased) === null || _e === void 0 ? void 0 : _e.subscription).toLowerCase();
            }
            if ((0, misc_1.search_match)(x["search"], v)) {
                w.push(x);
            }
        }
    }
    catch (e_2_1) { e_2 = { error: e_2_1 }; }
    finally {
        try {
            if (data_1_1 && !data_1_1.done && (_a = data_1.return)) _a.call(data_1);
        }
        finally { if (e_2) throw e_2.error; }
    }
    return w;
}
function removeExpired(data) {
    var e_3, _a;
    var data1 = [];
    var now = new Date().valueOf();
    try {
        for (var data_2 = __values(data), data_2_1 = data_2.next(); !data_2_1.done; data_2_1 = data_2.next()) {
            var x = data_2_1.value;
            if (!(x.expires != null && x.expires <= now)) {
                data1.push(x);
            }
        }
    }
    catch (e_3_1) { e_3 = { error: e_3_1 }; }
    finally {
        try {
            if (data_2_1 && !data_2_1.done && (_a = data_2.return)) _a.call(data_2);
        }
        finally { if (e_3) throw e_3.error; }
    }
    return data1;
}
function AddManagers(_a) {
    var _this = this;
    var license_id = _a.license_id, managers = _a.managers, onChange = _a.onChange;
    var _b = __read((0, react_1.useState)(false), 2), adding = _b[0], setAdding = _b[1];
    var _c = __read((0, react_1.useState)([]), 2), accountIds = _c[0], setAccountIds = _c[1];
    var _d = __read((0, react_1.useState)(""), 2), error = _d[0], setError = _d[1];
    var account = (0, use_customize_1.default)().account;
    return ((0, jsx_runtime_1.jsxs)("div", { children: [adding && ((0, jsx_runtime_1.jsx)(antd_1.Button, __assign({ size: "small", style: { float: "right" }, onClick: function () {
                    setAdding(false);
                    setError("");
                    setAccountIds([]);
                } }, { children: "Cancel" }))), (0, jsx_runtime_1.jsxs)(antd_1.Button, __assign({ disabled: adding, style: { marginTop: "5px" }, size: "small", onClick: function () {
                    setAdding(true);
                    setAccountIds([]);
                    setError("");
                } }, { children: [(0, jsx_runtime_1.jsx)(icon_1.Icon, { name: "plus-circle" }), " Add"] })), adding && ((0, jsx_runtime_1.jsxs)("div", __assign({ style: { width: "300px", marginTop: "5px" } }, { children: [error && (0, jsx_runtime_1.jsx)(antd_1.Alert, { type: "error", message: error }), (0, jsx_runtime_1.jsxs)(antd_1.Button, __assign({ disabled: accountIds.length == 0, onClick: function () { return __awaiter(_this, void 0, void 0, function () {
                            var query, err_1;
                            return __generator(this, function (_a) {
                                switch (_a.label) {
                                    case 0:
                                        setError("");
                                        query = {
                                            manager_site_licenses: {
                                                id: license_id,
                                                managers: managers.concat(accountIds),
                                            },
                                        };
                                        _a.label = 1;
                                    case 1:
                                        _a.trys.push([1, 3, , 4]);
                                        return [4 /*yield*/, (0, post_1.default)("/user-query", { query: query })];
                                    case 2:
                                        _a.sent();
                                        setAdding(false);
                                        onChange === null || onChange === void 0 ? void 0 : onChange();
                                        return [3 /*break*/, 4];
                                    case 3:
                                        err_1 = _a.sent();
                                        setError(err_1.message);
                                        return [3 /*break*/, 4];
                                    case 4: return [2 /*return*/];
                                }
                            });
                        }); }, style: { marginBottom: "5px", width: "100%" }, type: "primary" }, { children: [(0, jsx_runtime_1.jsx)(icon_1.Icon, { name: "check" }), " Add ", accountIds.length, " ", (0, misc_2.plural)(accountIds.length, "selected user")] })), (0, jsx_runtime_1.jsx)(select_users_1.default, { autoFocus: true, onChange: setAccountIds, exclude: managers.concat((account === null || account === void 0 ? void 0 : account.account_id) ? [account.account_id] : []) })] })))] }));
}
function RemoveManager(_a) {
    var _this = this;
    var license_id = _a.license_id, managers = _a.managers, account_id = _a.account_id, onChange = _a.onChange;
    var _b = __read((0, react_1.useState)(""), 2), error = _b[0], setError = _b[1];
    var account = (0, use_customize_1.default)().account;
    return ((0, jsx_runtime_1.jsx)(antd_1.Popconfirm, __assign({ zIndex: 20000 /* compare with user search */, title: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(account === null || account === void 0 ? void 0 : account.account_id) == account_id ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: ["Remove ", (0, jsx_runtime_1.jsx)("b", { children: "yourself" }), " as a manager of this license?"] })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: ["Remove manager", " ", (0, jsx_runtime_1.jsxs)("b", { children: [(0, jsx_runtime_1.jsx)(name_1.default, { account_id: account_id }), "?"] }), (0, jsx_runtime_1.jsx)("br", {}), (0, jsx_runtime_1.jsx)(name_1.default, { account_id: account_id }), " will no longer see this license listed under licenses they manage."] })), (0, jsx_runtime_1.jsx)("br", {}), " The license will ", (0, jsx_runtime_1.jsx)("i", { children: "not" }), " be automatically removed from any projects."] }), onConfirm: function () { return __awaiter(_this, void 0, void 0, function () {
            var query, err_2;
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0:
                        setError("");
                        query = {
                            manager_site_licenses: {
                                id: license_id,
                                managers: managers.filter(function (x) { return x != account_id; }),
                            },
                        };
                        _a.label = 1;
                    case 1:
                        _a.trys.push([1, 3, , 4]);
                        return [4 /*yield*/, (0, post_1.default)("/user-query", { query: query })];
                    case 2:
                        _a.sent();
                        onChange === null || onChange === void 0 ? void 0 : onChange();
                        return [3 /*break*/, 4];
                    case 3:
                        err_2 = _a.sent();
                        setError(err_2.message);
                        return [3 /*break*/, 4];
                    case 4: return [2 /*return*/];
                }
            });
        }); }, okText: "Remove", cancelText: "Cancel" }, { children: (0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("a", { children: "Remove as Manager..." }), error && ((0, jsx_runtime_1.jsx)(antd_1.Alert, { type: "error", message: "Error Removing Manager", description: error }))] }) })));
}
//# sourceMappingURL=managed.js.map