"""CSS Filter Template meta-filter — references a color strip processing template.

This filter exists in the registry for UI discovery only.  It is never
instantiated at runtime: the store expands it into the referenced
template's filters when building the processing pipeline.
"""

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 CSSFilterTemplateFilter(PostprocessingFilter):
    """Include another color strip processing template's chain at this position."""

    filter_id = "css_filter_template"
    filter_name = "Strip Filter Template"
    supports_strip = True

    @classmethod
    def get_options_schema(cls) -> List[FilterOptionDef]:
        return [
            FilterOptionDef(
                key="template_id",
                label="Template",
                option_type="select",
                default="",
                min_value=None,
                max_value=None,
                step=None,
                choices=[],  # populated dynamically by GET /api/v1/strip-filters
            ),
        ]

    def process_image(self, image: np.ndarray, image_pool: ImagePool) -> Optional[np.ndarray]:
        # Never called — expanded at pipeline build time.
        return None

    def process_strip(self, strip: np.ndarray) -> Optional[np.ndarray]:
        # Never called — expanded at pipeline build time.
        return None
