"use client";
import { jsx as _jsx } from "react/jsx-runtime";
import { useEditContext } from "../client/editContext";
/**
 * Internal link component for navigating to items within Parhelia.
 * - Regular click: opens item in current editor slot
 * - Alt+click: opens item in a new editor slot
 */
export function InternalLink({ item, workspace = "editor", children, className, title, ...rest }) {
    const editContext = useEditContext();
    const handleClick = (e) => {
        e.preventDefault();
        e.stopPropagation();
        const openInNewSlot = e.altKey;
        editContext?.loadItem({
            id: item.id,
            language: item.language,
            version: item.version,
            database: item.database,
        }, {
            openInNewSlot,
        });
        editContext?.switchWorkspace(workspace);
    };
    return (_jsx("span", { className: `cursor-pointer hover:underline ${className || ""}`, onClick: handleClick, title: title || "Click to open, Alt+click to open in new editor", ...rest, children: children }));
}
//# sourceMappingURL=InternalLink.js.map