"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 © 2020 Sagemath, Inc.
 *  License: AGPLv3 s.t. "Commons Clause" – see LICENSE.md for details
 */
const link_1 = __importDefault(require("next/link"));
function LinkedPath({ id, path, relativePath, isDir }) {
    let href = `/share/public_paths/${id}`;
    const first = ((0, jsx_runtime_1.jsx)(link_1.default, { href: href, children: (0, jsx_runtime_1.jsx)("a", { children: path }) }, href));
    const slash = (key) => (0, jsx_runtime_1.jsx)("span", { children: " / " }, "slash" + key);
    const segments = [first, slash(href)];
    for (const segment of relativePath.split("/")) {
        if (!segment)
            continue;
        href += `/${encodeURIComponent(segment)}`;
        segments.push((0, jsx_runtime_1.jsx)(link_1.default, { href: href, children: (0, jsx_runtime_1.jsx)("a", { children: segment }) }, href));
        segments.push(slash(href));
    }
    if (!isDir) {
        segments.pop();
    }
    return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: segments });
}
exports.default = LinkedPath;
//# sourceMappingURL=linked-path.js.map