"""
constants/enums.py — Clover 命名中心
DB枚举约束在此定义，消除三套命名打架。
业务参数（品类/数量/角度）不在此定义（基石A）。
"""

from enum import Enum


# ── 用户角色 ────────────────────────────────────────────
class UserRole(str, Enum):
    ADMIN = "admin"
    SUPERVISOR = "supervisor"
    OPERATOR = "operator"


# ── 任务状态机 ──────────────────────────────────────────
class TaskStatus(str, Enum):
    PENDING = "pending"
    GENERATING = "generating"
    PENDING_SELECTION = "pending_selection"
    PENDING_REVIEW = "pending_review"
    APPROVED = "approved"
    REJECTED = "rejected"
    ARCHIVED = "archived"


# ── 审核状态（generation_tasks 平铺字段）──────────────────
class ReviewStatus(str, Enum):
    PENDING = "pending"
    APPROVED = "approved"
    REJECTED = "rejected"


# ── 文案候选来源 ───────────────────────────────────────
class CandidateSource(str, Enum):
    AI = "ai"
    IMPORT = "import"


# ── 违禁词等级 ────────────────────────────────────────
class BannedWordLevel(str, Enum):
    AUTO_FIX = "auto_fix"
    SOFT_WARN = "soft_warn"
    HARD_BLOCK = "hard_block"


# ── 违禁词扫描结果 ───────────────────────────────────
class BannedWordStatus(str, Enum):
    PASS = "pass"
    AUTO_FIXED = "auto_fixed"
    SOFT_WARN = "soft_warn"
    HARD_BLOCK = "hard_block"


# ── 飞轮信号类型 ─────────────────────────────────────
class SignalType(str, Enum):
    TEXT_SELECT = "text_select"
    IMAGE_SELECT = "image_select"
    APPROVE = "approve"
    REJECT_WITH_REASON = "reject_with_reason"
    REGENERATE = "regenerate"


# ── 飞轮信号权重默认值（北哥可校准）─────────────────────
SIGNAL_WEIGHTS: dict[str, int] = {
    SignalType.TEXT_SELECT: 3,
    SignalType.IMAGE_SELECT: 3,
    SignalType.APPROVE: 5,
    SignalType.REJECT_WITH_REASON: -3,
    SignalType.REGENERATE: -1,
}


# ── 数据归属 ──────────────────────────────────────────
class DataOwnership(str, Enum):
    CLIENT_DATA = "client_data"       # 原始输入产出，客户可导出
    PLATFORM_ASSET = "platform_asset"  # 飞轮蒸馏成果，归平台


# ── 交付包状态 ────────────────────────────────────────
class PackageStatus(str, Enum):
    PENDING = "pending"
    READY = "ready"
    DOWNLOADED = "downloaded"


# ── 图片分镜角色（G5坑修复：对齐 storyboard.py 实际角色名）────
class ImageRole(str, Enum):
    # storyboard 实际输出角色名
    HOOK = "hook"
    PAIN_SCENE = "pain_scene"
    PRODUCT_CLOSEUP = "product_closeup"
    INGREDIENT = "ingredient"
    APPLIED_PROOF = "applied_proof"
    TEXTURE = "texture"
    SOCIAL_PROOF = "social_proof"
    CLOSER = "closer"
    SCENARIO = "scenario"
    TUTORIAL = "tutorial"
    # 旧值保留向后兼容
    PAIN = "pain"
    PROOF = "proof"
    QUALITY = "quality"
    CREDIT = "credit"
    CONVERT = "convert"
    MAIN = "main"


# ── AI 图片提供商 ─────────────────────────────────────
class ImageProvider(str, Enum):
    GPT = "gpt"
    GEMINI = "gemini"


# ── 产品来源 ──────────────────────────────────────────
class ProductSource(str, Enum):
    PRESET = "preset"
    CUSTOM = "custom"


# ── 错误码（契约§0七类）─────────────────────────────────
class ErrorCode:
    SUCCESS = 0
    PARAM_INVALID = 40001
    UNAUTHORIZED = 40101
    FORBIDDEN = 40301
    NOT_FOUND = 40401
    STATE_INVALID = 40901
    BUSINESS_ERROR = 42201
    SERVER_ERROR = 50001
    AI_CALL_FAILED = 50002
