from pydantic import BaseModel, EmailStr, ConfigDict
from datetime import datetime
from typing import Optional

class UserBase(BaseModel):
    email: EmailStr
    name: Optional[str] = None

class UserCreate(UserBase):
    password: str

    def create_update_dict(self):
        return {
            "email": self.email,
            "name": self.name,
            "password": self.password,
            "is_active": True,
            "is_superuser": False,
            "is_verified": False
        }

class UserUpdate(UserBase):
    password: Optional[str] = None
    is_active: Optional[bool] = None
    is_superuser: Optional[bool] = None
    is_verified: Optional[bool] = None

class UserClaim(BaseModel):
    email: EmailStr
    password: str

class UserInDBBase(UserBase):
    id: int
    password_hash: str
    created_at: datetime
    model_config = ConfigDict(from_attributes=True)

class UserPublic(UserBase):
    id: int
    created_at: datetime
    model_config = ConfigDict(from_attributes=True)

class User(UserInDBBase):
    pass