from __future__ import annotations
from typing import Protocol, runtime_checkable, Sequence, TYPE_CHECKING
from zemax.zos.lde.protocols.ISurface import ISurface
from zemax.zos.lde.protocols.IEditorCell import IEditorCell
from zemax.zos.lde.enums.surface_type import SurfaceType


# Optional: tighten these imports once your concrete enums/protocols exist.
if TYPE_CHECKING:
    from zemax.zos.zosapi.editors.lde.isurface import ISurface
    from zemax.zos.zosapi.editors.ieditor_cell import IEditorCell
    from zemax.zos.zosapi.editors.lde.surface_type import SurfaceType
    from zemax.zos.zosapi.editors.lde.surface_column import SurfaceColumn
    from zemax.zos.zosapi.editors.lde.isurface_type_settings import ISurfaceTypeSettings
    from zemax.zos.zosapi.common.imetadata import IMetadata
    from zemax.zos.zosapi.editors.lde.icoating_performance_data import ICoatingPerformanceData
    from zemax.zos.zosapi.editors.lde.ildetype_data import ILDETypeData
    from zemax.zos.zosapi.editors.lde.ildedraw_data import ILDEDrawData
    from zemax.zos.zosapi.editors.lde.ildeaperture_data import ILDEApertureData
    from zemax.zos.zosapi.editors.lde.ildescattering_data import ILDEScatteringData
    from zemax.zos.zosapi.editors.lde.ildetilt_decenter_data import ILDETiltDecenterData
    from zemax.zos.zosapi.editors.lde.ildephysical_optics_data import ILDEPhysicalOpticsData
    from zemax.zos.zosapi.editors.lde.ildecoating_data import ILDECoatingData
    from zemax.zos.zosapi.editors.lde.ildeimport_data import ILDEImportData
    from zemax.zos.zosapi.editors.lde.ildecomposite_data import ILDECompositeData
    from zemax.zos.zosapi.editors.lde.istar_data import ISTAR_Data
else:
    # String annotations cover runtime; mypy/pyright still understand them.
    ISurface = "ISurface"
    IEditorCell = "IEditorCell"
    SurfaceType = "SurfaceType"
    SurfaceColumn = "SurfaceColumn"
    ISurfaceTypeSettings = "ISurfaceTypeSettings"
    IMetadata = "IMetadata"
    ICoatingPerformanceData = "ICoatingPerformanceData"
    ILDETypeData = "ILDETypeData"
    ILDEDrawData = "ILDEDrawData"
    ILDEApertureData = "ILDEApertureData"
    ILDEScatteringData = "ILDEScatteringData"
    ILDETiltDecenterData = "ILDETiltDecenterData"
    ILDEPhysicalOpticsData = "ILDEPhysicalOpticsData"
    ILDECoatingData = "ILDECoatingData"
    ILDEImportData = "ILDEImportData"
    ILDECompositeData = "ILDECompositeData"
    ISTAR_Data = "ISTAR_Data"


@runtime_checkable
class IEditorRow(Protocol):
    """Base row protocol (ZOSAPI.Editors.IEditorRow). Extend when needed."""
    ...


@runtime_checkable
class ILDERow(IEditorRow, Protocol):
    """
    Python protocol for ZOSAPI.Editors.LDE.ILDERow.
    All data for a Lens Data Editor surface.
    """

    # ----------------------------
    # Methods
    # ----------------------------
    def GetSurfaceCell(self, Col: SurfaceColumn) -> IEditorCell: ...
    def AvailableSurfaceTypes(self) -> Sequence[SurfaceType]: ...
    def GetSurfaceTypeSettings(self, type: SurfaceType) -> ISurfaceTypeSettings: ...
    def ChangeType(self, settings: ISurfaceTypeSettings) -> bool: ...
    def GetMetadata(self) -> IMetadata: ...
    def GetCoatingPerformanceData(self) -> ICoatingPerformanceData: ...

    # ----------------------------
    # Properties
    # ----------------------------
    @property
    def IsActive(self) -> bool: ...
    @property
    def SurfaceNumber(self) -> int: ...
    @property
    def TypeName(self) -> str: ...
    @property
    def Type(self) -> SurfaceType: ...
    @property
    def CurrentTypeSettings(self) -> ISurfaceTypeSettings: ...
    @property
    def IsObject(self) -> bool: ...
    @property
    def IsImage(self) -> bool: ...

    @property
    def IsStop(self) -> bool: ...
    @IsStop.setter
    def IsStop(self, value: bool) -> None: ...

    @property
    def SurfaceData(self) -> ISurface: ...
    @property
    def TypeData(self) -> ILDETypeData: ...
    @property
    def DrawData(self) -> ILDEDrawData: ...
    @property
    def ApertureData(self) -> ILDEApertureData: ...
    @property
    def ScatteringData(self) -> ILDEScatteringData: ...
    @property
    def TiltDecenterData(self) -> ILDETiltDecenterData: ...
    @property
    def PhysicalOpticsData(self) -> ILDEPhysicalOpticsData: ...
    @property
    def CoatingData(self) -> ILDECoatingData: ...
    @property
    def ImportData(self) -> ILDEImportData: ...
    @property
    def CompositeData(self) -> ILDECompositeData: ...

    @property
    def Comment(self) -> str: ...
    @Comment.setter
    def Comment(self, text: str) -> None: ...
    @property
    def CommentCell(self) -> IEditorCell: ...

    @property
    def Radius(self) -> float: ...
    @Radius.setter
    def Radius(self, value: float) -> None: ...
    @property
    def RadiusCell(self) -> IEditorCell: ...

    @property
    def Thickness(self) -> float: ...
    @Thickness.setter
    def Thickness(self, value: float) -> None: ...
    @property
    def ThicknessCell(self) -> IEditorCell: ...

    @property
    def Material(self) -> str: ...
    @Material.setter
    def Material(self, name: str) -> None: ...
    @property
    def MaterialCell(self) -> IEditorCell: ...

    @property
    def Coating(self) -> str: ...
    @Coating.setter
    def Coating(self, name: str) -> None: ...
    @property
    def CoatingCell(self) -> IEditorCell: ...

    @property
    def SemiDiameter(self) -> float: ...
    @SemiDiameter.setter
    def SemiDiameter(self, value: float) -> None: ...
    @property
    def SemiDiameterCell(self) -> IEditorCell: ...

    @property
    def ChipZone(self) -> float: ...
    @ChipZone.setter
    def ChipZone(self, value: float) -> None: ...
    @property
    def ChipZoneCell(self) -> IEditorCell: ...

    @property
    def MechanicalSemiDiameter(self) -> float: ...
    @MechanicalSemiDiameter.setter
    def MechanicalSemiDiameter(self, value: float) -> None: ...
    @property
    def MechanicalSemiDiameterCell(self) -> IEditorCell: ...

    @property
    def Conic(self) -> float: ...
    @Conic.setter
    def Conic(self, value: float) -> None: ...
    @property
    def ConicCell(self) -> IEditorCell: ...

    @property
    def TCE(self) -> float: ...
    @TCE.setter
    def TCE(self, value: float) -> None: ...
    @property
    def TCECell(self) -> IEditorCell: ...

    @property
    def SurfaceId(self) -> int: ...
    @property
    def STARData(self) -> ISTAR_Data: ...
    @property
    def MaterialCatalog(self) -> str: ...


__all__ = ["ILDERow", "IEditorRow"]
