import { jsx as _jsx } from "react/jsx-runtime";
// (C) 2021-2025 GoodData Corporation
import { useMemo } from "react";
import { GranularPermissionsWorkspaceItem } from "./WorkspaceItem/GranularPermissionsWorkspaceItem.js";
import { WorkspaceListEmpty } from "./WorkspaceListEmpty.js";
import { sortByName } from "../utils.js";
export function WorkspaceList({ workspaces, subjectType, mode, onDelete, onClick }) {
    const sortedWorkspaces = useMemo(() => {
        return workspaces ? [...workspaces].sort(sortByName) : [];
    }, [workspaces]);
    if (sortedWorkspaces.length === 0) {
        return _jsx(WorkspaceListEmpty, { mode: mode, subjectType: subjectType });
    }
    return (_jsx("div", { className: "gd-share-dialog-grantee-list s-user-management-workspaces", children: sortedWorkspaces.map((workspace) => {
            return (_jsx(GranularPermissionsWorkspaceItem, { workspace: workspace, onDelete: onDelete, onClick: onClick }, workspace.id));
        }) }));
}
//# sourceMappingURL=WorkspaceList.js.map