from datetime import datetime
from typing import NamedTuple

from bclearer_orchestration_services.identification_services.b_identity_ecosystem.bie_id_creation_module.common_knowledge.types.bie_vector_structure_types import (
    BieVectorStructureTypes,
)
from bclearer_orchestration_services.identification_services.b_identity_ecosystem.bie_id_creation_module.identity_vectors import (
    CommonIdentityVector,
)
from bclearer_orchestration_services.identification_services.b_identity_ecosystem.common_knowledge.bie_types import (
    BieTypes,
)
from bclearer_orchestration_services.identification_services.b_identity_ecosystem.objects.bie_ids import (
    BieIds,
)


# --- Operating System ---


class OperatingSystemObjectIdentityVectorPlaces(
    NamedTuple,
):
    operating_system_type_bie_id: BieIds
    machine_sid: str


class OperatingSystemObjectIdentityVector(
    CommonIdentityVector,
):
    def __init__(
        self,
        *,
        bie_type: BieTypes,
        bie_hr_name: str,
        places: OperatingSystemObjectIdentityVectorPlaces,
    ) -> None:
        super().__init__(
            bie_domain_type=bie_type,
            bie_hr_name=bie_hr_name,
            places=places,
            bie_vector_structure_type=BieVectorStructureTypes.MULTI_DIMENSIONAL_ORDER_SENSITIVE,
        )


# --- OS User Profile ---


class OsUserProfileObjectIdentityVectorPlaces(
    NamedTuple,
):
    os_user_profile_type_bie_id: BieIds
    user_sid: str
    operating_system_type_bie_id: BieIds


class OsUserProfileObjectIdentityVector(
    CommonIdentityVector,
):
    def __init__(
        self,
        *,
        bie_type: BieTypes,
        bie_hr_name: str,
        places: OsUserProfileObjectIdentityVectorPlaces,
    ) -> None:
        super().__init__(
            bie_domain_type=bie_type,
            bie_hr_name=bie_hr_name,
            places=places,
            bie_vector_structure_type=BieVectorStructureTypes.MULTI_DIMENSIONAL_ORDER_SENSITIVE,
        )


# --- OS User Profile Session ---


class OsUserProfileSessionObjectIdentityVectorPlaces(
    NamedTuple,
):
    os_user_session_type_bie_id: BieIds
    windows_session_id: int
    session_start_date_time: datetime
    owning_operating_system_bie_id: BieIds

    @property
    def os_user_session_id(self) -> int:
        return self.windows_session_id


class OsUserProfileSessionObjectIdentityVector(
    CommonIdentityVector,
):
    def __init__(
        self,
        *,
        bie_type: BieTypes,
        bie_hr_name: str,
        places: OsUserProfileSessionObjectIdentityVectorPlaces,
    ) -> None:
        super().__init__(
            bie_domain_type=bie_type,
            bie_hr_name=bie_hr_name,
            places=places,
            bie_vector_structure_type=BieVectorStructureTypes.MULTI_DIMENSIONAL_ORDER_SENSITIVE,
        )


# --- App Run Session ---


class AppRunSessionObjectIdentityVectorPlaces(
    NamedTuple,
):
    app_run_session_type_bie_id: BieIds
    owning_os_user_profile_session_bie_id: BieIds
    app_run_session_date_time: datetime


class AppRunSessionObjectIdentityVector(
    CommonIdentityVector,
):
    def __init__(
        self,
        *,
        bie_type: BieTypes,
        bie_hr_name: str,
        places: AppRunSessionObjectIdentityVectorPlaces,
    ) -> None:
        super().__init__(
            bie_domain_type=bie_type,
            bie_hr_name=bie_hr_name,
            places=places,
            bie_vector_structure_type=BieVectorStructureTypes.MULTI_DIMENSIONAL_ORDER_SENSITIVE,
        )
