import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
import { useSyncExternalStore } from "react";
import { useEditContext } from "./client/editContext";
import { ActiveUsers } from "./menubar/ActiveUsers";
import { OpenInNewTabButton } from "./menubar/OpenInNewTabButton";
import { cn } from "../lib/utils";
import { NotificationCenter } from "./notifications/NotificationCenter";
import { OperationsIndicator } from "./menubar/OperationsIndicator";
import { WorkspaceTitleSwitcher } from "./WorkspaceTitleSwitcher";
import { WorkflowButton } from "./menubar/WorkflowButton";
import { getTaskBoardNavSnapshot, subscribeTaskBoardNav, } from "../task-board/taskBoardNavStore";
/**
 * GlobalMenuBar - Persistent top menu bar with workspace-specific titlebar and user menu
 * Visible on all workspaces except Home (when workspace.hideToolbar is true)
 * Spans only the content area width (not including the sidebar)
 */
export function GlobalMenuBar() {
    const editContext = useEditContext();
    const taskBoardNav = useSyncExternalStore(subscribeTaskBoardNav, getTaskBoardNavSnapshot, getTaskBoardNavSnapshot);
    if (!editContext)
        return null;
    const currentItemDescriptor = editContext.currentItemDescriptor;
    const isMobile = editContext.isMobile;
    const isHomeWorkspace = editContext.workspace?.id === "home";
    const isAgentsWorkspace = editContext.workspace?.id === "agents";
    const isTaskboardWorkspace = editContext.workspace?.id === "taskboard";
    const isTranslationManagementWorkspace = editContext.workspace?.id === "translation-management";
    const watchTarget = isHomeWorkspace
        ? null
        : isAgentsWorkspace
            ? editContext.selectedAgentsWorkspaceAgentId
                ? {
                    targetType: "agent-run",
                    targetId: editContext.selectedAgentsWorkspaceAgentId,
                }
                : null
            : isTaskboardWorkspace
                ? taskBoardNav.selectedProjectId
                    ? {
                        targetType: "project",
                        targetId: taskBoardNav.selectedProjectId,
                    }
                    : null
                : isTranslationManagementWorkspace
                    ? null
                    : currentItemDescriptor?.id
                        ? {
                            targetType: "item",
                            targetId: currentItemDescriptor.id,
                        }
                        : null;
    return (_jsxs("div", { className: cn("border-border-default box-border flex items-center overflow-hidden border-b bg-white", isMobile
            ? "h-11 max-h-11 min-h-11 gap-1.5 px-1.5"
            : "h-[50px] max-h-[50px] min-h-[50px] gap-3 px-2", "z-10"), "data-testid": "global-menu-bar", children: [_jsx(WorkspaceTitleSwitcher, { variant: isMobile ? "compact" : "default" }), _jsx("div", { className: "flex h-full max-h-full min-h-0 min-w-0 flex-1 items-center overflow-hidden", children: editContext.workspace?.titlebar }), _jsxs("div", { className: cn("ml-auto flex h-full min-w-0 shrink-0 items-center justify-end overflow-hidden", isMobile ? "gap-1" : "gap-2"), children: [!isMobile && (_jsxs(_Fragment, { children: [_jsx(OperationsIndicator, {}), _jsx(OpenInNewTabButton, {}), _jsx(NotificationCenter, { watchTarget: watchTarget }), _jsx(ActiveUsers, {})] })), editContext.workspaceId === "editor" ? _jsx(WorkflowButton, {}) : null, isMobile && editContext.workspaceId === "editor" ? (_jsx(ActiveUsers, {})) : null] })] }));
}
//# sourceMappingURL=GlobalMenuBar.js.map