"""Mock device provider — virtual LED strip for testing."""

from __future__ import annotations

from datetime import datetime, timezone
from typing import TYPE_CHECKING, List

from ledgrab.core.devices.led_client import (
    DeviceHealth,
    DiscoveredDevice,
    LEDClient,
    LEDDeviceProvider,
    ProviderDeps,
)
from ledgrab.core.devices.mock_client import MockClient

if TYPE_CHECKING:
    from ledgrab.core.devices.device_config import MockConfig


class MockDeviceProvider(LEDDeviceProvider):
    """Provider for virtual mock LED devices."""

    @property
    def device_type(self) -> str:
        return "mock"

    @property
    def capabilities(self) -> set:
        return {"manual_led_count", "power_control", "brightness_control"}

    def create_client(self, config: "MockConfig", *, deps: ProviderDeps) -> LEDClient:
        return MockClient(
            config.device_url,
            led_count=config.led_count,
            send_latency_ms=config.send_latency_ms,
        )

    async def check_health(self, url: str, http_client, prev_health=None) -> DeviceHealth:
        return DeviceHealth(online=True, latency_ms=0.0, last_checked=datetime.now(timezone.utc))

    async def validate_device(self, url: str) -> dict:
        return {}

    async def discover(self, timeout: float = 3.0) -> List[DiscoveredDevice]:
        return []

    async def get_power(self, url: str, **kwargs) -> bool:
        return True

    async def set_power(self, url: str, on: bool, **kwargs) -> None:
        pass
