# DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/python/mod.rs
# Based on "crates/store/re_sdk_types/definitions/rerun/blueprint/components/eye3d_kind.fbs".

# You can extend this class by creating a "Eye3DKindExt" class in "eye3d_kind_ext.py".

from __future__ import annotations

from collections.abc import Sequence
from typing import Literal

import pyarrow as pa

from ..._baseclasses import (
    BaseBatch,
    ComponentBatchMixin,
)

__all__ = ["Eye3DKind", "Eye3DKindArrayLike", "Eye3DKindBatch", "Eye3DKindLike"]


from enum import Enum


class Eye3DKind(Enum):
    """
    **Component**: The kind of the 3D eye to view a scene in a [`views.Spatial3DView`][rerun.blueprint.views.Spatial3DView].

    This is used to specify how the controls of the view react to user input (such as mouse gestures).
    """

    FirstPerson = 1
    """
    First person point of view.

    The camera perspective as if one is seeing it through the eyes of a person as popularized by first-person games.
    The center of rotation is the position of the eye (the camera).
    Dragging the mouse on the spatial 3D view, will rotation the scene as if one is moving
    their head around.
    """

    Orbital = 2
    """
    Orbital eye.

    The center of rotation is located to a center location in front of the eye (it is different from the eye
    location itself), as if the eye was orbiting around the scene.
    """

    @classmethod
    def auto(cls, val: str | int | Eye3DKind) -> Eye3DKind:
        """Best-effort converter, including a case-insensitive string matcher."""
        if isinstance(val, Eye3DKind):
            return val
        if isinstance(val, int):
            return cls(val)
        try:
            return cls[val]
        except KeyError:
            val_lower = val.lower()
            for variant in cls:
                if variant.name.lower() == val_lower:
                    return variant
        raise ValueError(f"Cannot convert {val} to {cls.__name__}")

    def __str__(self) -> str:
        """Returns the variant name."""
        return self.name


Eye3DKindLike = Eye3DKind | Literal["FirstPerson", "Orbital", "firstperson", "orbital"] | int
"""A type alias for any Eye3DKind-like object."""

Eye3DKindArrayLike = (
    Eye3DKind | Literal["FirstPerson", "Orbital", "firstperson", "orbital"] | int | Sequence[Eye3DKindLike]
)
"""A type alias for any Eye3DKind-like array object."""


class Eye3DKindBatch(BaseBatch[Eye3DKindArrayLike], ComponentBatchMixin):
    _ARROW_DATATYPE = pa.uint8()
    _COMPONENT_TYPE: str = "rerun.blueprint.components.Eye3DKind"

    @staticmethod
    def _native_to_pa_array(data: Eye3DKindArrayLike, data_type: pa.DataType) -> pa.Array:
        if isinstance(data, (Eye3DKind, int, str)):
            data = [data]

        pa_data = [Eye3DKind.auto(v).value if v is not None else None for v in data]  # type: ignore[redundant-expr]  # ty: ignore[not-iterable]

        return pa.array(pa_data, type=data_type)
