from typing import Optional, override
from flut._flut.engine import FlutImmutableObject
from flut._flut.runtime import _flut_unpack_optional_field


class ColorScheme(FlutImmutableObject):
    def __init__(
        self,
        *,
        seedColor=None,
        primary=None,
        onPrimary=None,
        secondary=None,
        onSecondary=None,
        surface=None,
        onSurface=None,
        error=None,
        onError=None,
        inversePrimary=None,
    ):
        super().__init__("ColorScheme")
        self.seedColor = seedColor
        self.primary = primary
        self.onPrimary = onPrimary
        self.secondary = secondary
        self.onSecondary = onSecondary
        self.surface = surface
        self.onSurface = onSurface
        self.error = error
        self.onError = onError
        self.inversePrimary = inversePrimary

    @staticmethod
    def fromSeed(*, seedColor):
        return ColorScheme(seedColor=seedColor)

    @override
    def _flut_pack(self) -> dict:
        result = self._flut_base_props()
        if self.seedColor is not None:
            result["seedColor"] = self.seedColor._flut_pack()
        if self.primary is not None:
            result["primary"] = self.primary._flut_pack()
        if self.onPrimary is not None:
            result["onPrimary"] = self.onPrimary._flut_pack()
        if self.secondary is not None:
            result["secondary"] = self.secondary._flut_pack()
        if self.onSecondary is not None:
            result["onSecondary"] = self.onSecondary._flut_pack()
        if self.surface is not None:
            result["surface"] = self.surface._flut_pack()
        if self.onSurface is not None:
            result["onSurface"] = self.onSurface._flut_pack()
        if self.error is not None:
            result["error"] = self.error._flut_pack()
        if self.onError is not None:
            result["onError"] = self.onError._flut_pack()
        if self.inversePrimary is not None:
            result["inversePrimary"] = self.inversePrimary._flut_pack()
        return result

    @staticmethod
    def _flut_unpack(data: dict) -> "ColorScheme":
        return ColorScheme(
            primary=_flut_unpack_optional_field(data, "primary"),
            onPrimary=_flut_unpack_optional_field(data, "onPrimary"),
            secondary=_flut_unpack_optional_field(data, "secondary"),
            onSecondary=_flut_unpack_optional_field(data, "onSecondary"),
            surface=_flut_unpack_optional_field(data, "surface"),
            onSurface=_flut_unpack_optional_field(data, "onSurface"),
            error=_flut_unpack_optional_field(data, "error"),
            onError=_flut_unpack_optional_field(data, "onError"),
            inversePrimary=_flut_unpack_optional_field(data, "inversePrimary"),
        )