from __future__ import annotations

import re
from dataclasses import dataclass

CITY_NAMES = (
    "北京",
    "上海",
    "广州",
    "深圳",
    "杭州",
    "南京",
    "苏州",
    "成都",
    "重庆",
    "天津",
    "武汉",
    "西安",
    "长沙",
    "郑州",
    "青岛",
    "厦门",
    "福州",
    "合肥",
    "济南",
    "沈阳",
    "大连",
    "宁波",
    "无锡",
)

# 业务信号关键词：用于判定输入是否与小财管家支持的财务事项相关。
# 只要清洗后的消息命中其中任意一个关键词，就视为业务相关；否则进入 off_topic 拦截。
STEWARD_BUSINESS_SIGNAL_KEYWORDS: tuple[str, ...] = (
    # 动作词
    "申请", "报销", "草稿", "提交", "审批", "保存", "发起", "创建", "核对", "归集",
    # 差旅场景
    "出差", "差旅", "费用", "交通", "住宿", "招待", "酒店", "机票", "航班", "高铁",
    "动车", "火车", "出租车", "的士", "网约车", "打车", "地铁", "公交", "用餐", "餐饮", "宴请",
    # 票据/凭证
    "票据", "发票", "凭证", "行程单", "付款截图", "付款", "小票", "收据",
    # 业务对象
    "客户", "项目", "拜访", "会议", "培训", "部署", "实施", "支撑", "支持", "协助",
    "调研", "驻场", "上线", "验收", "审核",
    # 时间信号
    "昨天", "前天", "明天", "后天", "下周", "下月", "近期", "月底", "今天", "上周", "上月",
    # 金额/数量（"天"用于"出差3天"等表达）
    "金额", "元", "块", "万", "千", "天",
    # 复用城市名信号
    *CITY_NAMES,
)


# 业务无关输入的场景分类
STEWARD_OFF_TOPIC_SCENARIO_GREETING = "greeting"
STEWARD_OFF_TOPIC_SCENARIO_MEANINGLESS = "meaningless"
STEWARD_OFF_TOPIC_SCENARIO_OFF_BUSINESS = "off_business"


# 问候词：用于将"你好"等礼貌问候单独归类为 greeting 场景
STEWARD_GREETING_KEYWORDS: tuple[str, ...] = (
    "你好", "您好", "hi", "hello", "hey", "嗨", "哈喽",
    "早上好", "上午好", "中午好", "下午好", "晚上好", "早安", "晚安",
    "您好呀", "你好呀", "在吗", "在么", "在不在",
)

APPLICATION_SPLIT_PATTERN = re.compile(r"(?:^|[，,。；;])[^，,。；;]*?(?:申请|出差申请|差旅申请)[^，,。；;]*")
REIMBURSEMENT_PATTERN = re.compile(r"(?:我要报销|还需要报销|需要报销|报销)([^，,。；;！？?!\n]+)")

BUSINESS_FIELD_LABELS = {
    "expense_type": "费用类型",
    "time_range": "时间",
    "location": "地点",
    "reason": "事由",
    "amount": "金额",
    "transport_mode": "出行方式",
    "attachments": "附件/凭证",
    "customer_name": "客户或项目对象",
    "merchant_name": "商户/开票方",
    "department_name": "所属部门",
    "employee_name": "申请人",
    "employee_no": "员工编号",
}

EXPENSE_TYPE_LABELS = {
    "travel": "差旅",
    "transport": "交通费",
    "entertainment": "业务招待费",
    "office": "办公用品",
    "meeting": "会议费",
    "training": "培训费",
    "other": "其他费用",
}

TRANSPORT_MODE_LABELS = {
    "train": "火车/高铁",
    "flight": "飞机",
    "taxi": "出租车/网约车",
    "subway": "地铁",
    "other": "其他交通方式",
}


@dataclass(frozen=True)
class PlannedTaskDraft:
    task_type: str
    segment: str
    index: int


