"""Reverse filter — reverses the LED order in a 1D strip."""

from typing import List, Optional

import numpy as np

from wled_controller.core.filters.base import FilterOptionDef, PostprocessingFilter
from wled_controller.core.filters.image_pool import ImagePool
from wled_controller.core.filters.registry import FilterRegistry


@FilterRegistry.register
class ReverseFilter(PostprocessingFilter):
    """Reverses the order of LEDs in a color strip."""

    filter_id = "reverse"
    filter_name = "Reverse"
    supports_strip = True

    @classmethod
    def get_options_schema(cls) -> List[FilterOptionDef]:
        return []

    def process_image(self, image: np.ndarray, image_pool: ImagePool) -> Optional[np.ndarray]:
        """Reverse image horizontally (for 2D fallback)."""
        return image[:, ::-1].copy()

    def process_strip(self, strip: np.ndarray) -> Optional[np.ndarray]:
        """Reverse the LED array order."""
        return strip[::-1].copy()
