from __future__ import annotations

from collections.abc import Iterable, Sequence
from typing import Callable, overload

from ._types import Direction, MouseButton
from .shapes import Box, BoxSpec

class BoxArray(Sequence[Box]):
    """An immutable sequence of Box objects that proxies methods to its contents."""

    def __init__(self, boxes: Iterable[Box] | None = None) -> None: ...
    @overload
    def __getitem__(self, index: int) -> Box: ...
    @overload
    def __getitem__(self, index: slice) -> BoxArray: ...
    def __getitem__(self, index: int | slice) -> Box | BoxArray: ...
    def __len__(self) -> int: ...
    def __add__(self, boxes: object) -> BoxArray: ...

    # `BoxArray` methods
    def first(self) -> Box: ...
    def last(self) -> Box: ...
    def select(self, *, i: int) -> Box: ...
    def pick(self, region: BoxSpec) -> BoxArray: ...
    def filter_by(self, condition: Callable[[Box], bool]) -> BoxArray: ...
    def relative_to(self, direction: Direction, *, of: BoxSpec) -> BoxArray: ...

    # `Box` proxies
    def resolve(self, base: BoxSpec | None = None) -> BoxArray: ...
    def click(self, clicks: int = 1, button: MouseButton = "left") -> BoxArray: ...
    def offset(self, direction: Direction, shift: int = 0) -> BoxArray: ...
    def find_color(
        self,
        color: tuple[int, int, int],
        towards: Direction,
        *,
        region: BoxSpec | None = None,
    ) -> BoxArray: ...
