from dataclasses import dataclass, field
from typing import Dict, List, Optional, Any
from datetime import datetime
from pydantic import BaseModel, StringConstraints, Field
from typing_extensions import Annotated
from pif_compiler.classes.types_enum import CosmeticType, PhysicalForm, PlaceApplication, NormalUser, RoutesExposure, NanoRoutes


class Ingredient(BaseModel):

    inci_name : str = Annotated[
        str, 
        StringConstraints(
            min_length=3,
            max_length=50,
            strip_whitespace=True,
            to_upper=True)
            ]
    
    cas : str = Annotated[str, StringConstraints(
        min_length=5,
        max_length=13,
        strip_whitespace=True
    )]

    quantity : float = Annotated[float, Field(gt=0.001, lt=100.0, allow_inf_nan = False)]

    # pubchem data x dap
    mol_weight : Optional[int]
    degree_ioniz : Optional[bool]
    log_pow : Optional[int]
    melting_pnt : Optional[int]

    # toxicity values
    sed : Optional[float]
    dap : float = 0.5
    sedd : Optional[float]
    noael : Optional[int]
    mos : Optional[int]

    # riferimenti
    ref : Optional[str]
    restriction: Optional[str]

class ExpositionInfo(BaseModel):
    type: CosmeticType
    target_population: NormalUser
    consumer_weight: str = "60 kg"
    place_application: PlaceApplication
    routes_exposure: RoutesExposure
    nano_routes: NanoRoutes
    surface_area: int
    frequency: int
    
    # to be approximated by LLM
    estimated_daily_amount_applied: float
    relative_daily_amount_applied: float
    retention_factor: float
    calculated_daily_exposure: float
    calculated_relative_daily_exposure: float

class SedTable(BaseModel):
    surface : int
    total_exposition : int
    frequency : int
    retention : int
    consumer_weight : int
    total_sed : int

class ProdCompany(BaseModel):
    prod_company_name : str
    prod_vat: int
    prod_address : str