from pydantic import BaseModel, EmailStr, constr
from typing import Optional, List
from enum import Enum

class UserRole(str, Enum):
    user = "user"
    manager = "manager"
    admin = "admin"

class UserOut(BaseModel):
    id: int
    name: str
    email: EmailStr
    alias: Optional[str] = None
    paypal_email: Optional[EmailStr] = None
    role: UserRole
    is_active: bool
    balance_cents: int
    favorites: List[int]
    # NEU:
    avatar_url: Optional[str] = None
    public_stats: bool  

    class Config:
        orm_mode = True

class UserCreate(BaseModel):
    name: str
    email: EmailStr
    password: constr(min_length=8)
    pin: constr(min_length=6, max_length=6)
    alias: Optional[str] = None
    paypal_email: Optional[EmailStr] = None
    role: Optional[UserRole] = UserRole.user

class UserUpdate(BaseModel):
    name: Optional[str] = None
    email: Optional[EmailStr] = None
    password: Optional[constr(min_length=8)] = None
    pin: Optional[constr(min_length=6, max_length=6)] = None
    alias: Optional[str] = None
    paypal_email: Optional[EmailStr] = None
    role: Optional[UserRole] = None
    is_active: Optional[bool] = None
    balance_cents: Optional[int] = None
    favorites: Optional[List[int]] = None
