"""Writing-style check for forecast text (app/style.py)."""

from __future__ import annotations

from fastapi import APIRouter, Depends
from pydantic import BaseModel, Field

from ..auth import User, current_user
from ..style import check

router = APIRouter(tags=["style"])


class StyleIn(BaseModel):
    text: str = Field(max_length=10000)
    field: str = Field(pattern="^(bottom_line|problem)$")


@router.post("/style/check")
def style_check(body: StyleIn, user: User = Depends(current_user)):
    return {"findings": check(body.text, body.field)}
