"use strict";
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 © 2021 Sagemath, Inc.
 *  License: AGPLv3 s.t. "Commons Clause" – see LICENSE.md for details
 */
/*
Edit a file using the CoCalc app.
*/
var antd_1 = require("antd");
var base_path_1 = __importDefault(require("lib/base-path"));
var edit_url_1 = __importDefault(require("lib/share/edit-url"));
var path_1 = require("path");
var iframe_1 = __importDefault(require("./iframe"));
var use_customize_1 = __importDefault(require("lib/use-customize"));
var in_place_sign_in_or_up_1 = __importDefault(require("components/auth/in-place-sign-in-or-up"));
var open_anonymously_1 = __importDefault(require("components/share/edit/open-anonymously"));
function Path(props) {
    var project_id = props.project_id, path = props.path, style = props.style, fullscreen = props.fullscreen, embed = props.embed, description = props.description, start = props.start;
    var _a = (0, use_customize_1.default)(), account = _a.account, anonymousSignup = _a.anonymousSignup;
    if (!account) {
        return ((0, jsx_runtime_1.jsx)(antd_1.Alert, { type: "success", style: style, message: (0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)(in_place_sign_in_or_up_1.default, { title: "To use ".concat(description !== null && description !== void 0 ? description : "this", "...") }), anonymousSignup && (0, jsx_runtime_1.jsx)(open_anonymously_1.default, {})] }) }));
    }
    var appURL = (0, edit_url_1.default)({ type: "collaborator", project_id: project_id, path: path });
    var src = embed
        ? (0, path_1.join)(base_path_1.default, "static/embed.html?target=projects/".concat(project_id, "/files/").concat(path !== null && path !== void 0 ? path : ""))
        : appURL + "?fullscreen=project&session=";
    return ((0, jsx_runtime_1.jsx)(iframe_1.default, { src: src, appURL: appURL, path: path, style: style, fullscreen: fullscreen, description: description, start: start }));
}
exports.default = Path;
//# sourceMappingURL=path.js.map