import { jsx as _jsx } from "react/jsx-runtime";
// (C) 2023-2025 GoodData Corporation
import { useMemo } from "react";
import { UserGroupItem } from "./UserGroupItem.js";
import { UserGroupsListEmpty } from "./UserGroupsListEmpty.js";
import { sortByName } from "../utils.js";
export function UserGroupsList({ userGroups, mode, onDelete, isBootstrapUser, bootstrapUserGroupId, }) {
    const sortedUserGroups = useMemo(() => {
        return userGroups ? [...userGroups].sort(sortByName) : [];
    }, [userGroups]);
    if (sortedUserGroups.length === 0) {
        return _jsx(UserGroupsListEmpty, { mode: mode });
    }
    return (_jsx("div", { className: "gd-share-dialog-grantee-list s-user-management-user-list", children: sortedUserGroups.map((userGroup) => {
            const isDeleteDisabled = isBootstrapUser && userGroup.id === bootstrapUserGroupId;
            return (_jsx(UserGroupItem, { userGroup: userGroup, onDelete: onDelete, isDeleteDisabled: isDeleteDisabled, mode: mode }, userGroup.id));
        }) }));
}
//# sourceMappingURL=UserGroupsList.js.map