from typing import Optional, List

from pydantic import BaseModel, Field


class LeadPersonalInfo(BaseModel):
    name: Optional[str] = Field(None, description="The full name of the lead.")
    job_title: Optional[str] = Field(None, description="The job title of the lead.")
    email: Optional[str] = Field(None, description="The email address of the lead.")
    phone: Optional[str] = Field(None, description="The phone number of the lead.")
    additional_info: Optional[str] = Field(None, description="Additional information about the lead.")


class LeadCompanyInfo(BaseModel):
    company_name: Optional[str] = Field(..., description="The name of the company the lead works for.")
    company_website: Optional[str] = Field(None, description="The website of the company the lead works for.")
    industry: Optional[str] = Field(..., description="The industry in which the company operates.")
    company_size: Optional[int] = Field(..., description="The size of the company in terms of employee count.")
    additional_info: Optional[str] = Field(None, description="Additional information about the lead's company.")


class LeadInfoOutput(BaseModel):
    personal_info: Optional[LeadPersonalInfo] = Field(None, description="Personal information of the lead.")
    company_info: Optional[LeadCompanyInfo] = Field(None, description="Company information related to the lead.")
    questions: Optional[str] = Field(None, description="Additional questions to further clarify Identification")

    def __str__(self):
        output = ""
        if self.personal_info:
            output += (f"PERSONAL INFO:\n\n"
                       f"Name: {self.personal_info.name or 'N/A'}\n"
                       f"Job Title: {self.personal_info.job_title or 'N/A'}\n"
                       f"Email: {self.personal_info.email or 'N/A'}\n"
                       f"Phone: {self.personal_info.phone or 'N/A'}\n"
                       f"Additional Info: {self.personal_info.additional_info or 'N/A'}\n\n")

        if self.company_info:
            output += (f"COMPANY INFO:\n\n"
                       f"Company Name: {self.company_info.company_name or 'N/A'}\n"
                       f"Industry: {self.company_info.industry or 'N/A'}\n"
                       f"Company Size: {self.company_info.company_size or 'N/A'}\n"
                       f"Additional Info: {self.company_info.additional_info or 'N/A'}\n\n")

        if self.questions:
            output += f"QUESTIONS:\n\n{self.questions}\n\n"
