import re


def trim_whitespaces(string: str) -> str:
    """Replaces all multiple whitespaces with one and calls default strip function on a result

    Example:
    >>> trim_whitespaces('hello     friend')
    hello friend
    >>> trim_whitespaces('     hello     old       friend             ')
    hello old friend

    Args:
        string: A string to be trimmed.
    Returns:
        Trimmed string.
    """
    return re.sub(r"\s+", " ", string).strip()