import '../../../../../node_modules/preact/compat/dist/compat.module.mjs';
import { useGetRoleDescription } from './useGetRoleDescription.mjs';
import { useGetRoleDisplayName } from './useGetRoleDisplayName.mjs';
import { useRoles } from './useRoles.mjs';
import { useMemo as F, useCallback as T } from '../../../../../node_modules/preact/hooks/dist/hooks.module.mjs';

const useRoleDisplayInfo = (includeOrgRoles = false)=>{
    const allRoles = useRoles(includeOrgRoles);
    const getRoleDisplayName = useGetRoleDisplayName();
    const getRoleDescription = useGetRoleDescription();
    const roleInfo = F(()=>{
        return allRoles?.reduce((acc, role)=>{
            acc[role.role_id] = {
                description: getRoleDescription(role),
                label: getRoleDisplayName(role)
            };
            return acc;
        }, {}) ?? {};
    }, [
        allRoles,
        getRoleDescription,
        getRoleDisplayName
    ]);
    const getRoleIdDisplayName = T((roleId)=>roleInfo[roleId].label ?? roleId, [
        roleInfo
    ]);
    return {
        roleInfo,
        getRoleIdDisplayName
    };
};

export { useRoleDisplayInfo };
//# sourceMappingURL=useRoleDisplayInfo.mjs.map
