from typing import List
from typing import Tuple


def extract_meeting_summaries(
    meetings: List[str], split_meetings: List[Tuple[str, str, str]]
) -> Tuple[str, str, str]:
    """
    Get meeting time and location summary strings.

    Used in extract_meetings.

    Parameters
    ----------
    meetings:
        meeting strings from extract_meetings
    split_meetings:
        split meetings from extract_split_meetings. List of meeting [days, time, location]

    Returns
    -------
    times_summary, locations_summary
    """
    # produce long_summary
    times_long_summary = "\n".join(meetings)

    # make times summary as first listed
    times_summary = split_meetings[0][0] + " " + split_meetings[0][1]

    # collapse additional times
    if len(split_meetings) > 1:
        times_summary = times_summary + f" + {len(split_meetings)-1}"

    # make locations summary as first listed
    locations_summary = split_meetings[0][2]
    # locations_summary = location_urls[0] if len(location_urls) else ""

    # collapse additional locations
    if len(split_meetings) > 1:
        locations_summary = locations_summary + f" + {len(split_meetings)-1}"

    # some final touches
    times_summary = times_summary.replace("MTWThF", "M-F")
    locations_summary = locations_summary.replace("MTWThF", "M-F")
    times_long_summary = times_long_summary.replace("MTWThF", "M-F")

    if locations_summary == "" or locations_summary[:3] == " + ":
        locations_summary = "TBA"

    # handle redundant dash-delimited format (introduced in fall 2020)
    if locations_summary.count(" - ") == 1:

        locations_1, locations_2 = locations_summary.split(" - ")

        # if location is redundant
        if locations_2.startswith(locations_1):

            locations_summary = locations_2

    return times_summary, locations_summary, times_long_summary