"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const 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.
*/
const antd_1 = require("antd");
const base_path_1 = __importDefault(require("lib/base-path"));
const edit_url_1 = __importDefault(require("lib/share/edit-url"));
const path_1 = require("path");
const iframe_1 = __importDefault(require("./iframe"));
const use_customize_1 = __importDefault(require("lib/use-customize"));
const in_place_sign_in_or_up_1 = __importDefault(require("components/auth/in-place-sign-in-or-up"));
const open_anonymously_1 = __importDefault(require("components/share/edit/open-anonymously"));
function Path(props) {
    const { project_id, path, style, fullscreen, embed, description, start } = props;
    const { account, anonymousSignup } = (0, use_customize_1.default)();
    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 ${description ?? "this"}...` }), anonymousSignup && (0, jsx_runtime_1.jsx)(open_anonymously_1.default, {})] }) }));
    }
    const appURL = (0, edit_url_1.default)({ type: "collaborator", project_id, path });
    const src = embed
        ? (0, path_1.join)(base_path_1.default, `static/embed.html?target=projects/${project_id}/files/${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