#!/usr/bin/env python3
"""Test script for Kitty graphics display."""

import sys


def test_kitty_simple():
    """Test simple Kitty graphics output with embedded PNG."""
    import base64

    # Minimal 1x1 red pixel PNG (pre-encoded)
    # This is a tiny valid PNG with a red pixel
    png_red_1x1 = (
        b"\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00"
        b"\x01\x00\x00\x00\x01\x08\x02\x00\x00\x00\x90wS\xde"
        b"\x00\x00\x00\x0cIDATx\x9cc\xf8\xcf\xc0\x00\x00\x00"
        b"\x03\x00\x01\x00\x05\xfe\xd4\x00\x00\x00\x00IEND\xaeB`\x82"
    )

    encoded = base64.b64encode(png_red_1x1).decode("ascii")

    graphic = f"\x1b_Gf=100,t=d,s=1,v=1,c=1,r=1;{encoded}\x1b\\"
    sys.stdout.buffer.write(graphic.encode("utf-8"))
    sys.stdout.flush()

    print("\n[If you see a red dot above, Kitty graphics is working!]")
    print("[If you see nothing or garbage, it's not working]")


if __name__ == "__main__":
    test_kitty_simple()
