import re


def pad_numeric_only_string_enclosed_in_round_brackets(text: str):
    """
    Pad numeric-only strings enclosed in round brackets with spaces on both sides or behind
    Or numeric-only string enclosed in round brackets when the extension appears immediately after the brackets.

    Example:
        xxx (1) yyy.epub -> xxx 01 yyy.epub
        xxx(1) yyy.epub  -> xxx 01 yyy.epub
        xxx (1).epub     -> xxx 01.epub

    Args:
        text (str): Text to pad.

    Returns:
        text (str): Padded text.
    """
    match_result = re.search(r'\s*\(\s*(\d+)\s*\)\s+', text)
    if match_result:
        number = f' {str(int(match_result.group(1))).zfill(2)} '
        text = re.sub(r'\s*\(\s*\d+\s*\)\s*', number, text)

    match_result = re.search(r'\s*\(\s*(\d+)\s*\)\s*\.epub', text)
    if match_result:
        number = f' {str(int(match_result.group(1))).zfill(2)}'
        text = re.sub(r'\s*\(\s*\d+\s*\)\s*(?=\.epub)', number, text)

    return text