def mask_long_homopolymers(bases: str, min_long_hp_length: int, mask_base: str = 'N') -> str:
    """Returns the bases masked for regions with long homopolymers

    Args:
        bases: the bases to mask.
        min_long_hp_length: the minimum homopolymer length (inclusive) to mask.
        mask_base: the base to use when masking
    """
    masked = list(bases)
    count = 1
    last_base = bases[0]
    for i in range(1, len(bases)):
        cur_base = bases[i]
        if last_base == cur_base:
            count += 1
        else:
            if count >= min_long_hp_length:
                masked[i - count:i] = mask_base * count
            last_base = cur_base
            count = 1
    if count >= min_long_hp_length:
        masked[-count:] = mask_base * count
    return ''.join(masked)