from typing import Union, Optional

from attrs import field, define
from attrs.validators import instance_of, deep_iterable, optional
from src.data_classes.parameters_visualization import PlotParameters


@define
class ForestPlotParameters(PlotParameters):
    regression_model_names: list[str] = field(
        validator=deep_iterable(
            member_validator=instance_of(str), iterable_validator=instance_of(list)
        )
    )
    regression_model_labels: list[str] = field(
        validator=[
            deep_iterable(
                member_validator=instance_of(str),
                iterable_validator=instance_of(list),
            ),
        ],
    )
    coefficient_names: list[str] = field(
        validator=deep_iterable(
            member_validator=instance_of(str), iterable_validator=instance_of(list)
        )
    )
    sort_by_size: Optional[bool] = field(
        default=False, validator=optional(instance_of(bool))
    )
    x_axis_minimum: Optional[Union[int, float]] = field(
        default=None, validator=optional(instance_of((int, float)))
    )
    x_axis_maximum: Optional[Union[int, float]] = field(
        default=None, validator=optional(instance_of((int, float)))
    )
    dotsize: Optional[int] = field(default=5, validator=optional(instance_of(int)))
    colors: Optional[list[str]] = field(
        default=["orange", "royalblue", "forestgreen", "firebrick"], validator=optional(instance_of(list))
    )
    dataset: str = "data"
