"""Recognize Xcode's compiled single-size iOS app-icon representation."""
import re


def single_size_idioms(renditions: list[dict]) -> set[str]:
    """Require a 1024 icon image AND its matching multi-size index for each idiom.

    Xcode 26.3 expands a universal iOS source slot into phone/pad records. It
    does not retain the source's universal idiom or emit every smaller square.
    A bare large image is insufficient evidence of this compiled icon format.
    """
    images = {
        (row.get("Name"), row.get("Idiom"), row.get("Icon Index"))
        for row in renditions
        if row.get("AssetType") == "Icon Image"
        and row.get("PixelWidth") == 1024 and row.get("PixelHeight") == 1024
        and row.get("Scale") == 1 and row.get("Idiom") in {"phone", "pad"}
        and type(row.get("Icon Index")) is int
    }
    covered = set()
    for row in renditions:
        if row.get("AssetType") != "MultiSized Image" or row.get("Scale") != 1:
            continue
        sizes = row.get("Sizes")
        if not isinstance(sizes, list):
            continue
        for size in sizes:
            match = re.fullmatch(r"1024x1024 index:(\d+) idiom:(phone|pad)", str(size))
            if not match or row.get("Idiom") != match[2]:
                continue
            if (row.get("Name"), match[2], int(match[1])) in images:
                covered.add(match[2])
    return covered
