from typing import Dict


def fix_covered_model_text(raw) -> str:
    """Apply fixes to the text for what models a manual covers.

    What models the manual covers is sometimes listed as, e.g.
    "1993 1993 Chevrolet Camaro" -> "1993 Chevrolet Camaro".
    Similarly, dashes should be inserted for date ranges, e.g.
    "1982 1992 Chevrolet Camaro" -> "1982-1992 Chevrolet Camaro"

    Collapse repetitive manufacturer labels like
    "Chevrolet Chevelle, Chevrolet Camaro, Chevrolet Corvair"
    into
    "Chevrolet Chevelle, Camaro, Corvair"
    """
    # Fix date range text
    begin = raw[:4]
    end = raw[5:9]
    rawtext = raw[10:]

    if begin == end:
        date = begin
    else:
        date = "{}-{}".format(begin, end)

    # Collapse repetitive manufacturer labels
    makes: Dict[str, list] = {}
    makes = {}
    models = rawtext.split(", ")

    for model in models:
        idx = model.find(" ")
        if idx > 0:
            mfr = model[:idx]
            idx_next = idx + 1
            make = model[idx_next:]

            if mfr in makes:
                makes[mfr].append(make)
            else:
                makes[mfr] = [make]

    # Create string list
    text = ", ".join(["{} {}".format(mfr, ", ".join(makes[mfr])) for mfr in makes])

    return "{} {}".format(date, text)