def parse_brackets(line: str) -> tuple[int, str]:
    """
    Returns the index at which closing brackets don't align anymore,
    or if all closing ones do match, the string needed to complete it.
    """
    stack: list[str] = []
    opening_map = {
        ")": "(",
        "]": "[",
        "}": "{",
        ">": "<",
    }
    for index, bracket in enumerate(line):
        if bracket in "([{<":
            stack.append(bracket)
            continue

        opening_bracket = opening_map[bracket]
        if stack.pop() != opening_bracket:
            return index, ""

    # Now, there's stuff left on the stack. Which means, we need more
    # closing brackets here, for part 2. Disregard the integer.
    closing_map = {value: key for key, value in opening_map.items()}

    autocomplete = ""
    while len(stack) > 0:
        bracket = stack.pop()
        autocomplete += closing_map[bracket]

    return -1, autocomplete