from __future__ import annotations

import random
from dataclasses import dataclass
from datetime import datetime


@dataclass(frozen=True)
class EnterpriseRegistrationData:
    phone: str
    password: str
    enterprise_name: str
    contact_name: str


def random_mainland_phone(prefix: str = "19") -> str:
    clean_prefix = "".join(ch for ch in prefix if ch.isdigit()) or "19"
    clean_prefix = clean_prefix[:3]
    remaining = 11 - len(clean_prefix)
    return clean_prefix + "".join(str(random.randint(0, 9)) for _ in range(remaining))


def enterprise_data(password: str, prefix: str, enterprise_prefix: str) -> EnterpriseRegistrationData:
    suffix = datetime.now().strftime("%m%d%H%M%S") + str(random.randint(100, 999))
    return EnterpriseRegistrationData(
        phone=random_mainland_phone(prefix),
        password=password,
        enterprise_name=f"{enterprise_prefix}{suffix}",
        contact_name=f"E2E联系人{suffix[-4:]}",
    )
