from dataclasses import dataclass
from datetime import datetime


@dataclass(frozen=True, slots=True)
class H5User:
    id: str
    mobile: str
    mobile_masked: str
    display_name: str
    status: str
    created_at: datetime


@dataclass(frozen=True, slots=True)
class AdminUser:
    id: str
    username: str
    password_hash: str
    display_name: str
    status: str
    roles: tuple[str, ...]
    permissions: tuple[str, ...]
    data_scope: str


@dataclass(frozen=True, slots=True)
class AdminRole:
    code: str
    name: str
    data_scope: str
    status: str
    permissions: tuple[str, ...]


@dataclass(slots=True)
class AuthSession:
    id: str
    subject_type: str
    subject_id: str
    refresh_jti_hash: str
    expires_at: datetime
    revoked_at: datetime | None = None

    @property
    def active(self) -> bool:
        from datetime import UTC, datetime

        return self.revoked_at is None and self.expires_at > datetime.now(UTC)
