from __future__ import annotations
from typing import Protocol, runtime_checkable, Optional, Any,TYPE_CHECKING
from pathlib import Path
from zempy.zosapi.enums.system_type import SystemType
from zempy.zosapi.enums.session_modes import SessionModes

if TYPE_CHECKING:
    from zempy.zosapi.core.IZosapi import IZosapi
    from zempy.zosapi.analysis.protocols.IAnalyses import IAnalyses
    from zempy.zosapi.system.protocols.IMetadata import IMetadata
    from zempy.zosapi.tools.protocols.system_tools import ISystemTools

PathLike = str | Path

@runtime_checkable
class IOpticalSystem(Protocol):

    @property
    def zosapi(self) -> IZosapi: ...
    @property
    def raw(self) -> Any: ...
    @property
    def application(self) -> Any: ...

    def copy(self) -> IOpticalSystem: ...
    def load_file(self, lens_file: PathLike, save_if_needed: bool = False) -> None: ...
    def new(self, save_if_needed: bool = False) -> None: ...
    def save(self) -> None: ...
    def save_as(self, target: PathLike) -> None: ...
    def close_all_analyses(self) -> None: ...
    def close(self, save_if_needed: bool = False) -> None: ...
    def update_file_lists(self) -> None: ...

    def get_current_status(self) -> str: ...
    def update_status(self) -> str: ...

    @property
    def id(self) -> int: ...
    @property
    def name(self) -> str: ...
    @name.setter
    def name(self, value: str) -> None: ...
    @property
    def file(self) -> str: ...
    @property
    def needs_save(self) -> bool: ...
    @property
    def is_non_axial(self) -> bool: ...
    @property
    def is_project_directory(self) -> bool: ...

    @property
    def mode(self) -> SystemType: ...
    def set_mode(self, mode: SystemType) -> bool: ...

    @property
    def session_mode(self) -> SessionModes: ...
    @session_mode.setter
    def session_mode(self, value: SessionModes) -> None: ...

    @property
    def update_mode(self) -> Any: ...
    @update_mode.setter
    def update_mode(self, value: Any) -> None: ...

    def convert_to_project_directory(self, folder_path: str) -> bool: ...
    def turn_off_project_directory(self) -> bool: ...

    def get_metadata(self) -> Optional[IMetadata]: ...

    @property
    def system_data(self) -> Any: ...   # ISystemData
    @property
    def lde(self) -> Any: ...           # ILensDataEditor
    @property
    def nce(self) -> Any: ...           # INonSeqEditor
    @property
    def tde(self) -> Any: ...           # IToleranceDataEditor
    @property
    def mfe(self) -> Any: ...           # IMeritFunctionEditor
    @property
    def mce(self) -> Any: ...           # IMultiConfigEditor

    @property
    def analyses(self) -> IAnalyses: ...
    @property
    def tools(self) -> ISystemTools: ...


__all__ = ["IOpticalSystem"]
