"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 });
var jsx_runtime_1 = require("react/jsx-runtime");
/*
 *  This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.
 *  License: AGPLv3 s.t. "Commons Clause" – see LICENSE.md for details
 */
var path_1 = require("path");
var antd_1 = require("antd");
var icon_1 = require("@cocalc/frontend/components/icon");
var use_customize_1 = __importDefault(require("lib/use-customize"));
var open_directly_1 = __importDefault(require("./open-directly"));
var open_anonymously_1 = __importDefault(require("./open-anonymously"));
var choose_project_1 = __importDefault(require("./choose-project"));
var in_place_sign_in_or_up_1 = __importDefault(require("components/auth/in-place-sign-in-or-up"));
var misc_1 = require("@cocalc/util/misc");
function EditOptions(_a) {
    var id = _a.id, path = _a.path, url = _a.url, relativePath = _a.relativePath, project_id = _a.project_id, image = _a.image, onClose = _a.onClose, description = _a.description;
    var account = (0, use_customize_1.default)().account;
    return ((0, jsx_runtime_1.jsxs)(antd_1.Card, __assign({ style: { margin: "30px 0" }, title: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", __assign({ style: { position: "absolute", right: "30px", cursor: "pointer" }, onClick: onClose }, { children: (0, jsx_runtime_1.jsx)(icon_1.Icon, { name: "times-circle" }) })), (0, jsx_runtime_1.jsx)(icon_1.Icon, { style: { marginRight: "10px" }, name: "pencil" }), " Edit", " ", (0, jsx_runtime_1.jsx)("b", { children: (0, misc_1.trunc_middle)((0, path_1.join)(path, relativePath), 60) })] }) }, { children: [(account === null || account === void 0 ? void 0 : account.account_id) != null && ((0, jsx_runtime_1.jsx)(SignedInOptions, { id: id, path: path, url: url, relativePath: relativePath, project_id: project_id, image: image, description: description })), (account === null || account === void 0 ? void 0 : account.account_id) == null && (0, jsx_runtime_1.jsx)(NotSignedInOptions, {}), (0, jsx_runtime_1.jsx)("br", {})] })));
}
exports.default = EditOptions;
function SignedInOptions(_a) {
    var id = _a.id, path = _a.path, url = _a.url, relativePath = _a.relativePath, project_id = _a.project_id, image = _a.image, description = _a.description;
    var isCollaborator = (0, use_customize_1.default)().isCollaborator;
    return !url && isCollaborator ? ((0, jsx_runtime_1.jsx)(open_directly_1.default, { id: id, project_id: project_id, path: path, relativePath: relativePath })) : ((0, jsx_runtime_1.jsx)(choose_project_1.default, { id: id, src_project_id: project_id, path: path, url: url, relativePath: relativePath, image: image, description: description ? description : path ? path : relativePath }));
}
function NotSignedInOptions() {
    var anonymousSignup = (0, use_customize_1.default)().anonymousSignup;
    return ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)(in_place_sign_in_or_up_1.default, { title: "Choose Project", why: "to edit in one of your projects" }), anonymousSignup && (0, jsx_runtime_1.jsx)(open_anonymously_1.default, {})] }));
}
//# sourceMappingURL=edit-options.js.map