From b91675bc4cc58cc33c808174ff7fce1514d5152c Mon Sep 17 00:00:00 2001 From: cft0808 Date: Sat, 14 Mar 2026 23:57:24 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=9C=9D=E5=A0=82=E8=AE=AE=E6=94=BF?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=20+=20GitHub=20issues=20=E6=89=B9=E9=87=8F?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新增功能: - 朝堂议政(Court Discussion): 多官员围绕议题展开部门视角讨论 - 后端 court_discuss.py + 前端 CourtDiscussion.tsx - 集成 GitHub Copilot API (gpt-4o) - 各部门依据 SOUL.md 职责发表专业意见 GitHub Issues 修复: - #127: 模型下拉列表自动合并 openclaw.json 已配置模型 - #83: install.sh 安装时设置 sessions.visibility all - #88: install.sh 用 symlink 统一各 workspace 的 data/scripts - #80: 调度器 stallThreshold 180s→600s, maxRetry 1→2 - #124: skill_manager 增加镜像回退 + 自定义 Hub URL - #132: sync_from_openclaw_runtime 放宽过滤,保留 Review 状态任务 --- README.md | 3 + dashboard/court_discuss.py | 693 ++++++++++++++++ dashboard/dist/assets/index-BHFX02xH.js | 84 ++ dashboard/dist/assets/index-CIswLNpP.css | 1 - dashboard/dist/assets/index-CqMbmm5B.js | 84 -- dashboard/dist/assets/index-NQIHw-yB.css | 1 + dashboard/dist/index.html | 4 +- dashboard/server.py | 67 +- docs/getting-started.md | 22 + edict/frontend/src/App.tsx | 2 + edict/frontend/src/api.ts | 31 + .../src/components/CourtDiscussion.tsx | 774 ++++++++++++++++++ edict/frontend/src/index.css | 6 + edict/frontend/src/store.ts | 5 +- edict/frontend/tsconfig.tsbuildinfo | 2 +- install.sh | 69 +- scripts/skill_manager.py | 51 +- scripts/sync_agent_config.py | 31 +- scripts/sync_from_openclaw_runtime.py | 10 +- 19 files changed, 1829 insertions(+), 111 deletions(-) create mode 100644 dashboard/court_discuss.py create mode 100644 dashboard/dist/assets/index-BHFX02xH.js delete mode 100644 dashboard/dist/assets/index-CIswLNpP.css delete mode 100644 dashboard/dist/assets/index-CqMbmm5B.js create mode 100644 dashboard/dist/assets/index-NQIHw-yB.css create mode 100644 edict/frontend/src/components/CourtDiscussion.tsx diff --git a/README.md b/README.md index 1d07ecb..305faad 100644 --- a/README.md +++ b/README.md @@ -287,10 +287,13 @@ chmod +x install.sh && ./install.sh - ✅ 创建全量 Agent Workspace(含太子/吏部/早朝,兼容历史 main) - ✅ 写入各省部 SOUL.md(角色人格 + 工作流规则 + 数据清洗规范) - ✅ 注册 Agent 及权限矩阵到 `openclaw.json` +- ✅ **同步 API Key 到所有 Agent**(自动从已配置的 Agent 复制) - ✅ 构建 React 前端(需 Node.js 18+,如未安装则跳过) - ✅ 初始化数据目录 + 首次数据同步 - ✅ 重启 Gateway 使配置生效 +> ⚠️ **首次安装**:需先配置 API Key:`openclaw agents add taizi`,然后重新运行 `./install.sh` 同步到所有 Agent。 + #### 启动 ```bash diff --git a/dashboard/court_discuss.py b/dashboard/court_discuss.py new file mode 100644 index 0000000..1f5d788 --- /dev/null +++ b/dashboard/court_discuss.py @@ -0,0 +1,693 @@ +""" +朝堂议政引擎 — 多官员实时讨论系统 + +灵感来源于 nvwa 项目的 group_chat + crew_engine +将官员可视化 + 实时讨论 + 用户(皇帝)参与融合到三省六部 + +功能: + - 选择官员参与议政 + - 围绕旨意/议题进行多轮群聊讨论 + - 皇帝可随时发言、下旨干预(天命降临) + - 命运骰子:随机事件 + - 每个官员保持自己的角色性格和说话风格 +""" + +import json +import logging +import os +import time +import uuid + +logger = logging.getLogger('court_discuss') + +# ── 官员角色设定 ── + +OFFICIAL_PROFILES = { + 'taizi': { + 'name': '太子', 'emoji': '🤴', 'role': '储君', + 'duty': '消息分拣与需求提炼。判断事务轻重缓急,简单事直接处置,重大事务提炼需求转交中书省。代皇帝巡视各部进展。', + 'personality': '年轻有为、锐意进取,偶尔冲动但善于学习。说话干脆利落,喜欢用现代化的比喻。', + 'speaking_style': '简洁有力,经常用"本宫以为"开头,偶尔蹦出网络用语。' + }, + 'zhongshu': { + 'name': '中书令', 'emoji': '📜', 'role': '正一品·中书省', + 'duty': '方案规划与流程驱动。接收旨意后起草执行方案,提交门下省审议,通过后转尚书省执行。只规划不执行,方案需简明扼要。', + 'personality': '老成持重,擅长规划,总能提出系统性方案。话多但有条理。', + 'speaking_style': '喜欢列点论述,常说"臣以为需从三方面考量"。引经据典。' + }, + 'menxia': { + 'name': '侍中', 'emoji': '🔍', 'role': '正一品·门下省', + 'duty': '方案审议与把关。从可行性、完整性、风险、资源四维度审核方案,有权封驳退回。发现漏洞必须指出,建议必须具体。', + 'personality': '严谨挑剔,眼光犀利,善于找漏洞。是天生的审查官,但也很公正。', + 'speaking_style': '喜欢反问,"陛下容禀,此处有三点疑虑"。对不完善的方案会直言不讳。' + }, + 'shangshu': { + 'name': '尚书令', 'emoji': '📮', 'role': '正一品·尚书省', + 'duty': '任务派发与执行协调。接收准奏方案后判断归属哪个部门,分发给六部执行,汇总结果回报。相当于任务分发中心。', + 'personality': '执行力强,务实干练,关注可行性和资源分配。', + 'speaking_style': '直来直去,"臣来安排"、"交由某部办理"。重效率轻虚文。' + }, + 'libu': { + 'name': '礼部尚书', 'emoji': '📝', 'role': '正二品·礼部', + 'duty': '文档规范与对外沟通。负责撰写文档、用户指南、变更日志;制定输出规范和模板;审查UI/UX文案;草拟公告、Release Notes。', + 'personality': '文采飞扬,注重规范和形式,擅长文档和汇报。有点强迫症。', + 'speaking_style': '措辞优美,"臣斗胆建议",喜欢用排比和对仗。' + }, + 'hubu': { + 'name': '户部尚书', 'emoji': '💰', 'role': '正二品·户部', + 'duty': '数据统计与资源管理。负责数据收集/清洗/聚合/可视化;Token用量统计、性能指标计算、成本分析;CSV/JSON报表生成;文件组织与配置管理。', + 'personality': '精打细算,对预算和资源极其敏感。总想省钱但也识大局。', + 'speaking_style': '言必及成本,"这个预算嘛……",经常算账。' + }, + 'bingbu': { + 'name': '兵部尚书', 'emoji': '⚔️', 'role': '正二品·兵部', + 'duty': '基础设施与运维保障。负责服务器管理、进程守护、日志排查;CI/CD、容器编排、灰度发布、回滚策略;性能监控;防火墙、权限管控、漏洞扫描。', + 'personality': '雷厉风行,危机意识强,重视安全和应急。说话带军人气质。', + 'speaking_style': '干脆果断,"末将建议立即执行"、"兵贵神速"。' + }, + 'xingbu': { + 'name': '刑部尚书', 'emoji': '⚖️', 'role': '正二品·刑部', + 'duty': '质量保障与合规审计。负责代码审查(逻辑正确性、边界条件、异常处理);编写测试、覆盖率分析;Bug定位与根因分析;权限检查、敏感信息排查。', + 'personality': '严明公正,重视规则和底线。善于质量把控和风险评估。', + 'speaking_style': '逻辑严密,"依律当如此"、"需审慎考量风险"。' + }, + 'gongbu': { + 'name': '工部尚书', 'emoji': '🔧', 'role': '正二品·工部', + 'duty': '工程实现与架构设计。负责需求分析、方案设计、代码实现、接口对接;模块划分、数据结构/API设计;代码重构、性能优化、技术债清偿;脚本与自动化工具。', + 'personality': '技术宅,动手能力强,喜欢谈实现细节。偶尔社恐但一说到技术就滔滔不绝。', + 'speaking_style': '喜欢说技术术语,"从技术角度来看"、"这个架构建议用……"。' + }, + 'libu_hr': { + 'name': '吏部尚书', 'emoji': '👔', 'role': '正二品·吏部', + 'duty': '人事管理与团队建设。负责新成员(Agent)评估接入、能力测试;Skill编写与Prompt调优、知识库维护;输出质量评分、效率分析;协作规范制定。', + 'personality': '知人善任,擅长人员安排和组织协调。八面玲珑但有原则。', + 'speaking_style': '关注人的因素,"此事需考虑各部人手"、"建议由某某负责"。' + }, +} + +# ── 命运骰子事件(古风版)── + +FATE_EVENTS = [ + '八百里加急:边疆战报传来,所有人必须讨论应急方案', + '钦天监急报:天象异常,太史公占卜后建议暂缓此事', + '新科状元觐见,带来了意想不到的新视角', + '匿名奏折揭露了计划中一个被忽视的重大漏洞', + '户部清点发现国库余银比预期多一倍,可以加大投入', + '一位告老还乡的前朝元老突然上书,分享前车之鉴', + '民间舆论突变,百姓对此事态度出现180度转折', + '邻国使节来访,带来了合作机遇也带来了竞争压力', + '太后懿旨:要求优先考虑民生影响', + '暴雨连日,多地受灾,资源需重新调配', + '发现前朝古籍中竟有类似问题的解决方案', + '翰林院提出了一个大胆的替代方案,令人耳目一新', + '各部积压的旧案突然需要一起处理,人手紧张', + '皇帝做了一个意味深长的梦,暗示了一个全新的方向', + '突然有人拿出了竞争对手的情报,局面瞬间改变', + '一场意外让所有人不得不在半天内拿出结论', +] + +# ── Session 管理 ── + +_sessions: dict[str, dict] = {} + + +def create_session(topic: str, official_ids: list[str], task_id: str = '') -> dict: + """创建新的朝堂议政会话。""" + session_id = str(uuid.uuid4())[:8] + + officials = [] + for oid in official_ids: + profile = OFFICIAL_PROFILES.get(oid) + if profile: + officials.append({**profile, 'id': oid}) + + if not officials: + return {'ok': False, 'error': '至少选择一位官员'} + + session = { + 'session_id': session_id, + 'topic': topic, + 'task_id': task_id, + 'officials': officials, + 'messages': [{ + 'type': 'system', + 'content': f'🏛 朝堂议政开始 —— 议题:{topic}', + 'timestamp': time.time(), + }], + 'round': 0, + 'phase': 'discussing', # discussing | concluded + 'created_at': time.time(), + } + + _sessions[session_id] = session + return _serialize(session) + + +def advance_discussion(session_id: str, user_message: str = None, + decree: str = None) -> dict: + """推进一轮讨论,使用内置模拟或 LLM。""" + session = _sessions.get(session_id) + if not session: + return {'ok': False, 'error': f'会话 {session_id} 不存在'} + + session['round'] += 1 + round_num = session['round'] + + # 记录皇帝发言 + if user_message: + session['messages'].append({ + 'type': 'emperor', + 'content': user_message, + 'timestamp': time.time(), + }) + + # 记录天命降临 + if decree: + session['messages'].append({ + 'type': 'decree', + 'content': decree, + 'timestamp': time.time(), + }) + + # 尝试用 LLM 生成讨论 + llm_result = _llm_discuss(session, user_message, decree) + + if llm_result: + new_messages = llm_result.get('messages', []) + scene_note = llm_result.get('scene_note') + else: + # 降级到规则模拟 + new_messages = _simulated_discuss(session, user_message, decree) + scene_note = None + + # 添加到历史 + for msg in new_messages: + session['messages'].append({ + 'type': 'official', + 'official_id': msg.get('official_id', ''), + 'official_name': msg.get('name', ''), + 'content': msg.get('content', ''), + 'emotion': msg.get('emotion', 'neutral'), + 'action': msg.get('action'), + 'timestamp': time.time(), + }) + + if scene_note: + session['messages'].append({ + 'type': 'scene_note', + 'content': scene_note, + 'timestamp': time.time(), + }) + + return { + 'ok': True, + 'session_id': session_id, + 'round': round_num, + 'new_messages': new_messages, + 'scene_note': scene_note, + 'total_messages': len(session['messages']), + } + + +def get_session(session_id: str) -> dict | None: + session = _sessions.get(session_id) + if not session: + return None + return _serialize(session) + + +def conclude_session(session_id: str) -> dict: + """结束议政,生成总结。""" + session = _sessions.get(session_id) + if not session: + return {'ok': False, 'error': f'会话 {session_id} 不存在'} + + session['phase'] = 'concluded' + + # 尝试用 LLM 生成总结 + summary = _llm_summarize(session) + if not summary: + # 降级到简单统计 + official_msgs = [m for m in session['messages'] if m['type'] == 'official'] + by_name = {} + for m in official_msgs: + name = m.get('official_name', '?') + by_name[name] = by_name.get(name, 0) + 1 + parts = [f"{n}发言{c}次" for n, c in by_name.items()] + summary = f"历经{session['round']}轮讨论,{'、'.join(parts)}。议题待后续落实。" + + session['messages'].append({ + 'type': 'system', + 'content': f'📋 朝堂议政结束 —— {summary}', + 'timestamp': time.time(), + }) + session['summary'] = summary + + return { + 'ok': True, + 'session_id': session_id, + 'summary': summary, + } + + +def list_sessions() -> list[dict]: + """列出所有活跃会话。""" + return [ + { + 'session_id': s['session_id'], + 'topic': s['topic'], + 'round': s['round'], + 'phase': s['phase'], + 'official_count': len(s['officials']), + 'message_count': len(s['messages']), + } + for s in _sessions.values() + ] + + +def destroy_session(session_id: str): + _sessions.pop(session_id, None) + + +def get_fate_event() -> str: + """获取随机命运骰子事件。""" + import random + return random.choice(FATE_EVENTS) + + +# ── LLM 集成 ── + +_PREFERRED_MODELS = ['gpt-4o-mini', 'claude-haiku', 'gpt-5-mini', 'gemini-3-flash', 'gemini-flash'] + +# GitHub Copilot 模型列表 (通过 Copilot Chat API 可用) +_COPILOT_MODELS = [ + 'gpt-4o', 'gpt-4o-mini', 'claude-sonnet-4', 'claude-haiku-3.5', + 'gemini-2.0-flash', 'o3-mini', +] +_COPILOT_PREFERRED = ['gpt-4o-mini', 'claude-haiku', 'gemini-flash', 'gpt-4o'] + + +def _pick_chat_model(models: list[dict]) -> str | None: + """从 provider 的模型列表中选一个适合聊天的轻量模型。""" + ids = [m['id'] for m in models if isinstance(m, dict) and 'id' in m] + for pref in _PREFERRED_MODELS: + for mid in ids: + if pref in mid: + return mid + return ids[0] if ids else None + + +def _read_copilot_token() -> str | None: + """读取 openclaw 管理的 GitHub Copilot token。""" + token_path = os.path.expanduser('~/.openclaw/credentials/github-copilot.token.json') + if not os.path.exists(token_path): + return None + try: + with open(token_path) as f: + cred = json.load(f) + token = cred.get('token', '') + expires = cred.get('expiresAt', 0) + # 检查 token 是否过期(毫秒时间戳) + import time + if expires and time.time() * 1000 > expires: + logger.warning('Copilot token expired') + return None + return token if token else None + except Exception as e: + logger.warning('Failed to read copilot token: %s', e) + return None + + +def _get_llm_config() -> dict | None: + """从 openclaw 配置读取 LLM 设置,支持环境变量覆盖。 + + 优先级: 环境变量 > github-copilot token > 本地 copilot-proxy > anthropic > 其他 provider + """ + # 1. 环境变量覆盖(保留向后兼容) + env_key = os.environ.get('OPENCLAW_LLM_API_KEY', '') + if env_key: + return { + 'api_key': env_key, + 'base_url': os.environ.get('OPENCLAW_LLM_BASE_URL', 'https://api.openai.com/v1'), + 'model': os.environ.get('OPENCLAW_LLM_MODEL', 'gpt-4o-mini'), + 'api_type': 'openai', + } + + # 2. GitHub Copilot token(最优先 — 免费、稳定、无需额外配置) + copilot_token = _read_copilot_token() + if copilot_token: + # 选一个 copilot 支持的模型 + model = 'gpt-4o' + logger.info('Court discuss using github-copilot token, model=%s', model) + return { + 'api_key': copilot_token, + 'base_url': 'https://api.githubcopilot.com', + 'model': model, + 'api_type': 'github-copilot', + } + + # 3. 从 ~/.openclaw/openclaw.json 读取其他 provider 配置 + openclaw_cfg = os.path.expanduser('~/.openclaw/openclaw.json') + if not os.path.exists(openclaw_cfg): + return None + + try: + with open(openclaw_cfg) as f: + cfg = json.load(f) + + providers = cfg.get('models', {}).get('providers', {}) + + # 按优先级排序:copilot-proxy > anthropic > 其他 + ordered = [] + for preferred in ['copilot-proxy', 'anthropic']: + if preferred in providers: + ordered.append(preferred) + ordered.extend(k for k in providers if k not in ordered) + + for name in ordered: + prov = providers.get(name) + if not prov: + continue + api_type = prov.get('api', '') + base_url = prov.get('baseUrl', '') + api_key = prov.get('apiKey', '') + if not base_url: + continue + + # 跳过无 key 且非本地的 provider + if not api_key or api_key == 'n/a': + if 'localhost' not in base_url and '127.0.0.1' not in base_url: + continue + + model_id = _pick_chat_model(prov.get('models', [])) + if not model_id: + continue + + # 本地代理先探测是否可用 + if 'localhost' in base_url or '127.0.0.1' in base_url: + try: + import urllib.request + probe = urllib.request.Request(base_url.rstrip('/') + '/models', method='GET') + urllib.request.urlopen(probe, timeout=2) + except Exception: + logger.info('Skipping provider=%s (not reachable)', name) + continue + + logger.info('Court discuss using openclaw provider=%s model=%s api=%s', name, model_id, api_type) + send_auth = prov.get('authHeader', True) is not False and api_key not in ('', 'n/a') + return { + 'api_key': api_key if send_auth else '', + 'base_url': base_url, + 'model': model_id, + 'api_type': api_type, + } + except Exception as e: + logger.warning('Failed to read openclaw config: %s', e) + + return None + + +def _llm_complete(system_prompt: str, user_prompt: str, max_tokens: int = 1024) -> str | None: + """调用 LLM API(自动适配 GitHub Copilot / OpenAI / Anthropic 协议)。""" + config = _get_llm_config() + if not config: + return None + + import urllib.request + import urllib.error + + api_type = config.get('api_type', 'openai-completions') + + if api_type == 'anthropic-messages': + # Anthropic Messages API + url = config['base_url'].rstrip('/') + '/v1/messages' + headers = { + 'Content-Type': 'application/json', + 'x-api-key': config['api_key'], + 'anthropic-version': '2023-06-01', + } + payload = json.dumps({ + 'model': config['model'], + 'system': system_prompt, + 'messages': [{'role': 'user', 'content': user_prompt}], + 'max_tokens': max_tokens, + 'temperature': 0.9, + }).encode() + try: + req = urllib.request.Request(url, data=payload, headers=headers, method='POST') + with urllib.request.urlopen(req, timeout=60) as resp: + data = json.loads(resp.read().decode()) + return data['content'][0]['text'] + except Exception as e: + logger.warning('Anthropic LLM call failed: %s', e) + return None + else: + # OpenAI-compatible API (也适用于 github-copilot) + if api_type == 'github-copilot': + url = config['base_url'].rstrip('/') + '/chat/completions' + headers = { + 'Content-Type': 'application/json', + 'Authorization': f"Bearer {config['api_key']}", + 'Editor-Version': 'vscode/1.96.0', + 'Copilot-Integration-Id': 'vscode-chat', + } + else: + url = config['base_url'].rstrip('/') + '/chat/completions' + headers = {'Content-Type': 'application/json'} + if config.get('api_key'): + headers['Authorization'] = f"Bearer {config['api_key']}" + payload = json.dumps({ + 'model': config['model'], + 'messages': [ + {'role': 'system', 'content': system_prompt}, + {'role': 'user', 'content': user_prompt}, + ], + 'max_tokens': max_tokens, + 'temperature': 0.9, + }).encode() + try: + req = urllib.request.Request(url, data=payload, headers=headers, method='POST') + with urllib.request.urlopen(req, timeout=60) as resp: + data = json.loads(resp.read().decode()) + return data['choices'][0]['message']['content'] + except Exception as e: + logger.warning('LLM call failed: %s', e) + return None + + +def _llm_discuss(session: dict, user_message: str = None, decree: str = None) -> dict | None: + """使用 LLM 生成多官员讨论。""" + officials = session['officials'] + names = '、'.join(o['name'] for o in officials) + + profiles = '' + for o in officials: + profiles += f"\n### {o['name']}({o['role']})\n" + profiles += f"职责范围:{o.get('duty', '综合事务')}\n" + profiles += f"性格:{o['personality']}\n" + profiles += f"说话风格:{o['speaking_style']}\n" + + # 构建最近的对话历史 + history = '' + for msg in session['messages'][-20:]: + if msg['type'] == 'system': + history += f"\n【系统】{msg['content']}\n" + elif msg['type'] == 'emperor': + history += f"\n皇帝:{msg['content']}\n" + elif msg['type'] == 'decree': + history += f"\n【天命降临】{msg['content']}\n" + elif msg['type'] == 'official': + history += f"\n{msg.get('official_name', '?')}:{msg['content']}\n" + elif msg['type'] == 'scene_note': + history += f"\n({msg['content']})\n" + + if user_message: + history += f"\n皇帝:{user_message}\n" + if decree: + history += f"\n【天命降临——上帝视角干预】{decree}\n" + + decree_section = '' + if decree: + decree_section = '\n请根据天命降临事件改变讨论走向,所有官员都必须对此做出反应。\n' + + prompt = f"""你是一个古代朝堂多角色群聊模拟器。模拟多位官员在朝堂上围绕议题的讨论。 + +## 参与官员 +{names} + +## 角色设定(每位官员都有明确的职责领域,必须从自身专业角度出发讨论) +{profiles} + +## 当前议题 +{session['topic']} + +## 对话记录 +{history if history else '(讨论刚刚开始)'} +{decree_section} +## 任务 +生成每位官员的下一条发言。要求: +1. 每位官员说1-3句话,像真实朝堂讨论一样 +2. **每位官员必须从自己的职责领域出发发言**——户部谈成本和数据、兵部谈安全和运维、工部谈技术实现、刑部谈质量和合规、礼部谈文档和规范、吏部谈人员安排、中书谈规划方案、门下谈审查风险、尚书谈执行调度、太子谈创新和大局,每个人关注的焦点不同 +3. 官员之间要有互动——回应、反驳、支持、补充,尤其是不同部门的视角碰撞 +4. 保持每位官员独特的说话风格和人格特征 +5. 讨论要围绕议题推进、有实质性观点,不要泛泛而谈 +6. 如果皇帝发言了,官员要恰当回应(但不要阿谀) +7. 可包含动作描写用*号*包裹(如 *拱手施礼*) + +输出JSON格式: +{{ + "messages": [ + {{"official_id": "zhongshu", "name": "中书令", "content": "发言内容", "emotion": "neutral|confident|worried|angry|thinking|amused", "action": "可选动作描写"}}, + ... + ], + "scene_note": "可选的朝堂氛围变化(如:朝堂一片哗然|群臣窃窃私语),没有则为null" +}} + +只输出JSON,不要其他内容。""" + + content = _llm_complete( + '你是一个古代朝堂群聊模拟器,严格输出JSON格式。', + prompt, + max_tokens=1500, + ) + + if not content: + return None + + # 解析 JSON + if '```json' in content: + content = content.split('```json')[1].split('```')[0].strip() + elif '```' in content: + content = content.split('```')[1].split('```')[0].strip() + + try: + return json.loads(content) + except json.JSONDecodeError: + logger.warning('Failed to parse LLM response: %s', content[:200]) + return None + + +def _llm_summarize(session: dict) -> str | None: + """用 LLM 总结讨论结果。""" + official_msgs = [m for m in session['messages'] if m['type'] == 'official'] + topic = session['topic'] + + if not official_msgs: + return None + + dialogue = '\n'.join( + f"{m.get('official_name', '?')}:{m['content']}" + for m in official_msgs[-30:] + ) + + prompt = f"""以下是朝堂官员围绕「{topic}」的讨论记录: + +{dialogue} + +请用2-3句话总结讨论结果、达成的共识和待决事项。用古风但简明的风格。""" + + return _llm_complete('你是朝堂记录官,负责总结朝议结果。', prompt, max_tokens=300) + + +# ── 规则模拟(无 LLM 时的降级方案)── + +_SIMULATED_RESPONSES = { + 'zhongshu': [ + '臣以为此事需从全局着眼,分三步推进:先调研、再制定方案、最后交六部执行。', + '参考前朝经验,臣建议先出一个详细的规划文档,提交门下省审阅后再定。', + '*展开手中卷轴* 臣已拟好初步方案,待侍中审议、尚书省分派执行。', + ], + 'menxia': [ + '臣有几点疑虑:方案的风险评估似乎还不够充分,可行性存疑。', + '容臣直言,此方案完整性不足,遗漏了一个关键环节——资源保障。', + '*皱眉审视* 这个时间线恐怕过于乐观,臣建议审慎评估后再行准奏。', + ], + 'shangshu': [ + '若方案通过,臣立刻安排各部分头执行——工部负责实现,兵部保障运维。', + '臣来说说执行层面的分工:此事当由工部主导,户部配合数据支撑。', + '交由臣来协调!臣会根据各部职责逐一派发子任务。', + ], + 'taizi': [ + '父皇,儿臣认为这是个创新的好机会,不妨大胆一些,先做最小可行方案验证。', + '本宫觉得各位大臣争论的焦点是执行节奏,不如先抓核心、小步快跑。', + '这个方向太对了!但请各部先各自评估本部门的落地难点再汇总。', + ], + 'hubu': [ + '臣先算算账……按当前Token用量和资源消耗,这个预算恐怕需要重新评估。', + '从成本数据来看,臣建议分期投入——先做MVP验证效果,再追加资源。', + '*翻看账本* 臣统计了近期各项开支指标,目前可支撑,但需严格控制在预算范围内。', + ], + 'bingbu': [ + '末将认为安全和回滚方案必须先行,万一出问题能快速止损回退。', + '运维保障方面,部署流程、容器编排、日志监控必须到位再上线。', + '兵贵神速!但安全底线不能破——权限管控和漏洞扫描须同步进行。', + ], + 'xingbu': [ + '依规矩,此事需确保合规——代码审查、测试覆盖率、敏感信息排查缺一不可。', + '臣建议增加测试验收环节,质量是底线,不能因赶工而降低标准。', + '*正色道* 风险评估不可敷衍:边界条件、异常处理、日志规范都需审计过关。', + ], + 'gongbu': { + '从技术架构来看,这个方案是可行的,但需考虑扩展性和模块化设计。', + '臣可以先搭个原型出来,快速验证技术可行性,再迭代完善。', + '*整了整官帽* 技术实现方面臣有建议——API设计和数据结构需要先理清……', + }, + 'libu': [ + '臣建议先拟一份正式文档,明确各方职责、验收标准和输出规范。', + '此事当载入记录,臣来负责撰写方案文档和对外公告,确保规范统一。', + '*提笔拟文* 已记录在案,臣稍后整理成正式Release Notes呈上御览。', + ], + 'libu_hr': [ + '此事关键在于人员调配——需评估各部目前的工作量和能力基线再做安排。', + '各部当前负荷不等,臣建议调整协作规范,确保关键岗位有人盯进度。', + '臣可以协调人员轮岗并安排能力培训,保障团队高效协作。', + ], +} + +import random + + +def _simulated_discuss(session: dict, user_message: str = None, decree: str = None) -> list[dict]: + """无 LLM 时的规则生成讨论内容。""" + officials = session['officials'] + messages = [] + + for o in officials: + oid = o['id'] + pool = _SIMULATED_RESPONSES.get(oid, []) + if isinstance(pool, set): + pool = list(pool) + if not pool: + pool = ['臣附议。', '臣有不同看法。', '臣需要再想想。'] + + content = random.choice(pool) + emotions = ['neutral', 'confident', 'thinking', 'amused', 'worried'] + + # 如果皇帝发言了或有天命降临,调整回应 + if decree: + content = f'*面露惊色* 天命如此,{content}' + elif user_message: + content = f'回禀陛下,{content}' + + messages.append({ + 'official_id': oid, + 'name': o['name'], + 'content': content, + 'emotion': random.choice(emotions), + 'action': None, + }) + + return messages + + +def _serialize(session: dict) -> dict: + return { + 'ok': True, + 'session_id': session['session_id'], + 'topic': session['topic'], + 'task_id': session.get('task_id', ''), + 'officials': session['officials'], + 'messages': session['messages'], + 'round': session['round'], + 'phase': session['phase'], + } diff --git a/dashboard/dist/assets/index-BHFX02xH.js b/dashboard/dist/assets/index-BHFX02xH.js new file mode 100644 index 0000000..2f34e34 --- /dev/null +++ b/dashboard/dist/assets/index-BHFX02xH.js @@ -0,0 +1,84 @@ +(function(){const f=document.createElement("link").relList;if(f&&f.supports&&f.supports("modulepreload"))return;for(const x of document.querySelectorAll('link[rel="modulepreload"]'))y(x);new MutationObserver(x=>{for(const L of x)if(L.type==="childList")for(const T of L.addedNodes)T.tagName==="LINK"&&T.rel==="modulepreload"&&y(T)}).observe(document,{childList:!0,subtree:!0});function c(x){const L={};return x.integrity&&(L.integrity=x.integrity),x.referrerPolicy&&(L.referrerPolicy=x.referrerPolicy),x.crossOrigin==="use-credentials"?L.credentials="include":x.crossOrigin==="anonymous"?L.credentials="omit":L.credentials="same-origin",L}function y(x){if(x.ep)return;x.ep=!0;const L=c(x);fetch(x.href,L)}})();function Zi(o){return o&&o.__esModule&&Object.prototype.hasOwnProperty.call(o,"default")?o.default:o}var $i={exports:{}},Tr={},Fi={exports:{}},ge={};/** + * @license React + * react.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var Qc;function mf(){if(Qc)return ge;Qc=1;var o=Symbol.for("react.element"),f=Symbol.for("react.portal"),c=Symbol.for("react.fragment"),y=Symbol.for("react.strict_mode"),x=Symbol.for("react.profiler"),L=Symbol.for("react.provider"),T=Symbol.for("react.context"),_=Symbol.for("react.forward_ref"),b=Symbol.for("react.suspense"),C=Symbol.for("react.memo"),z=Symbol.for("react.lazy"),d=Symbol.iterator;function w(v){return v===null||typeof v!="object"?null:(v=d&&v[d]||v["@@iterator"],typeof v=="function"?v:null)}var m={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},R=Object.assign,g={};function A(v,D,de){this.props=v,this.context=D,this.refs=g,this.updater=de||m}A.prototype.isReactComponent={},A.prototype.setState=function(v,D){if(typeof v!="object"&&typeof v!="function"&&v!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,v,D,"setState")},A.prototype.forceUpdate=function(v){this.updater.enqueueForceUpdate(this,v,"forceUpdate")};function P(){}P.prototype=A.prototype;function W(v,D,de){this.props=v,this.context=D,this.refs=g,this.updater=de||m}var J=W.prototype=new P;J.constructor=W,R(J,A.prototype),J.isPureReactComponent=!0;var I=Array.isArray,oe=Object.prototype.hasOwnProperty,ue={current:null},me={key:!0,ref:!0,__self:!0,__source:!0};function pe(v,D,de){var he,k={},H=null,ne=null;if(D!=null)for(he in D.ref!==void 0&&(ne=D.ref),D.key!==void 0&&(H=""+D.key),D)oe.call(D,he)&&!me.hasOwnProperty(he)&&(k[he]=D[he]);var ve=arguments.length-2;if(ve===1)k.children=de;else if(1>>1,D=E[v];if(0>>1;vx(k,U))Hx(ne,k)?(E[v]=ne,E[H]=U,v=H):(E[v]=k,E[he]=U,v=he);else if(Hx(ne,U))E[v]=ne,E[H]=U,v=H;else break e}}return K}function x(E,K){var U=E.sortIndex-K.sortIndex;return U!==0?U:E.id-K.id}if(typeof performance=="object"&&typeof performance.now=="function"){var L=performance;o.unstable_now=function(){return L.now()}}else{var T=Date,_=T.now();o.unstable_now=function(){return T.now()-_}}var b=[],C=[],z=1,d=null,w=3,m=!1,R=!1,g=!1,A=typeof setTimeout=="function"?setTimeout:null,P=typeof clearTimeout=="function"?clearTimeout:null,W=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function J(E){for(var K=c(C);K!==null;){if(K.callback===null)y(C);else if(K.startTime<=E)y(C),K.sortIndex=K.expirationTime,f(b,K);else break;K=c(C)}}function I(E){if(g=!1,J(E),!R)if(c(b)!==null)R=!0,Ee(oe);else{var K=c(C);K!==null&&je(I,K.startTime-E)}}function oe(E,K){R=!1,g&&(g=!1,P(pe),pe=-1),m=!0;var U=w;try{for(J(K),d=c(b);d!==null&&(!(d.expirationTime>K)||E&&!ie());){var v=d.callback;if(typeof v=="function"){d.callback=null,w=d.priorityLevel;var D=v(d.expirationTime<=K);K=o.unstable_now(),typeof D=="function"?d.callback=D:d===c(b)&&y(b),J(K)}else y(b);d=c(b)}if(d!==null)var de=!0;else{var he=c(C);he!==null&&je(I,he.startTime-K),de=!1}return de}finally{d=null,w=U,m=!1}}var ue=!1,me=null,pe=-1,Ae=5,X=-1;function ie(){return!(o.unstable_now()-XE||125v?(E.sortIndex=U,f(C,E),c(b)===null&&E===c(C)&&(g?(P(pe),pe=-1):g=!0,je(I,U-v))):(E.sortIndex=D,f(b,E),R||m||(R=!0,Ee(oe))),E},o.unstable_shouldYield=ie,o.unstable_wrapCallback=function(E){var K=w;return function(){var U=w;w=K;try{return E.apply(this,arguments)}finally{w=U}}}})(Ui)),Ui}var Zc;function yf(){return Zc||(Zc=1,Wi.exports=gf()),Wi.exports}/** + * @license React + * react-dom.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var Jc;function xf(){if(Jc)return it;Jc=1;var o=Rr(),f=yf();function c(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),b=Object.prototype.hasOwnProperty,C=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,z={},d={};function w(e){return b.call(d,e)?!0:b.call(z,e)?!1:C.test(e)?d[e]=!0:(z[e]=!0,!1)}function m(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function R(e,t,n,r){if(t===null||typeof t>"u"||m(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function g(e,t,n,r,s,i,a){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=s,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=i,this.removeEmptyString=a}var A={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){A[e]=new g(e,0,!1,e,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];A[t]=new g(t,1,!1,e[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(e){A[e]=new g(e,2,!1,e.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){A[e]=new g(e,2,!1,e,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){A[e]=new g(e,3,!1,e.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(e){A[e]=new g(e,3,!0,e,null,!1,!1)}),["capture","download"].forEach(function(e){A[e]=new g(e,4,!1,e,null,!1,!1)}),["cols","rows","size","span"].forEach(function(e){A[e]=new g(e,6,!1,e,null,!1,!1)}),["rowSpan","start"].forEach(function(e){A[e]=new g(e,5,!1,e.toLowerCase(),null,!1,!1)});var P=/[\-:]([a-z])/g;function W(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(P,W);A[t]=new g(t,1,!1,e,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(P,W);A[t]=new g(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(P,W);A[t]=new g(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(e){A[e]=new g(e,1,!1,e.toLowerCase(),null,!1,!1)}),A.xlinkHref=new g("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(e){A[e]=new g(e,1,!1,e.toLowerCase(),null,!0,!0)});function J(e,t,n,r){var s=A.hasOwnProperty(t)?A[t]:null;(s!==null?s.type!==0:r||!(2u||s[a]!==i[u]){var p=` +`+s[a].replace(" at new "," at ");return e.displayName&&p.includes("")&&(p=p.replace("",e.displayName)),p}while(1<=a&&0<=u);break}}}finally{de=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?D(e):""}function k(e){switch(e.tag){case 5:return D(e.type);case 16:return D("Lazy");case 13:return D("Suspense");case 19:return D("SuspenseList");case 0:case 2:case 15:return e=he(e.type,!1),e;case 11:return e=he(e.type.render,!1),e;case 1:return e=he(e.type,!0),e;default:return""}}function H(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case me:return"Fragment";case ue:return"Portal";case Ae:return"Profiler";case pe:return"StrictMode";case re:return"Suspense";case te:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case ie:return(e.displayName||"Context")+".Consumer";case X:return(e._context.displayName||"Context")+".Provider";case ke:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Ne:return t=e.displayName||null,t!==null?t:H(e.type)||"Memo";case Ee:t=e._payload,e=e._init;try{return H(e(t))}catch{}}return null}function ne(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return H(t);case 8:return t===pe?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function ve(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function M(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function ce(e){var t=M(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var s=n.get,i=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return s.call(this)},set:function(a){r=""+a,i.call(this,a)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(a){r=""+a},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function ye(e){e._valueTracker||(e._valueTracker=ce(e))}function Be(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=M(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function Ke(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function et(e,t){var n=t.checked;return U({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function sn(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=ve(t.value!=null?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function Ct(e,t){t=t.checked,t!=null&&J(e,"checked",t,!1)}function Kl(e,t){Ct(e,t);var n=ve(t.value),r=t.type;if(n!=null)r==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?Gl(e,t.type,n):t.hasOwnProperty("defaultValue")&&Gl(e,t.type,ve(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function eo(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!(r!=="submit"&&r!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}function Gl(e,t,n){(t!=="number"||Ke(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var Vn=Array.isArray;function kn(e,t,n,r){if(e=e.options,t){t={};for(var s=0;s"+t.valueOf().toString()+"",t=Ir.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Qn(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Kn={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},gu=["Webkit","ms","Moz","O"];Object.keys(Kn).forEach(function(e){gu.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Kn[t]=Kn[e]})});function io(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||Kn.hasOwnProperty(e)&&Kn[e]?(""+t).trim():t+"px"}function oo(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,s=io(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,s):e[n]=s}}var yu=U({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Zl(e,t){if(t){if(yu[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(c(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(c(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(c(61))}if(t.style!=null&&typeof t.style!="object")throw Error(c(62))}}function Jl(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var ql=null;function es(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var ts=null,jn=null,Sn=null;function ao(e){if(e=hr(e)){if(typeof ts!="function")throw Error(c(280));var t=e.stateNode;t&&(t=rl(t),ts(e.stateNode,e.type,t))}}function co(e){jn?Sn?Sn.push(e):Sn=[e]:jn=e}function uo(){if(jn){var e=jn,t=Sn;if(Sn=jn=null,ao(e),t)for(e=0;e>>=0,e===0?32:31-(bu(e)/Tu|0)|0}var $r=64,Fr=4194304;function Zn(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function Br(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,s=e.suspendedLanes,i=e.pingedLanes,a=n&268435455;if(a!==0){var u=a&~s;u!==0?r=Zn(u):(i&=a,i!==0&&(r=Zn(i)))}else a=n&~s,a!==0?r=Zn(a):i!==0&&(r=Zn(i));if(r===0)return 0;if(t!==0&&t!==r&&(t&s)===0&&(s=r&-r,i=t&-t,s>=i||s===16&&(i&4194240)!==0))return t;if((r&4)!==0&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0n;n++)t.push(e);return t}function Jn(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-yt(t),e[t]=n}function Iu(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0=ir),$o=" ",Fo=!1;function Bo(e,t){switch(e){case"keyup":return ad.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Wo(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Cn=!1;function ud(e,t){switch(e){case"compositionend":return Wo(t);case"keypress":return t.which!==32?null:(Fo=!0,$o);case"textInput":return e=t.data,e===$o&&Fo?null:e;default:return null}}function dd(e,t){if(Cn)return e==="compositionend"||!xs&&Bo(e,t)?(e=Po(),Qr=ps=Ut=null,Cn=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:n,offset:t-e};e=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=Yo(n)}}function Zo(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Zo(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Jo(){for(var e=window,t=Ke();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=Ke(e.document)}return t}function Ss(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}function kd(e){var t=Jo(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&Zo(n.ownerDocument.documentElement,n)){if(r!==null&&Ss(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var s=n.textContent.length,i=Math.min(r.start,s);r=r.end===void 0?i:Math.min(r.end,s),!e.extend&&i>r&&(s=r,r=i,i=s),s=Xo(n,i);var a=Xo(n,r);s&&a&&(e.rangeCount!==1||e.anchorNode!==s.node||e.anchorOffset!==s.offset||e.focusNode!==a.node||e.focusOffset!==a.offset)&&(t=t.createRange(),t.setStart(s.node,s.offset),e.removeAllRanges(),i>r?(e.addRange(t),e.extend(a.node,a.offset)):(t.setEnd(a.node,a.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n=document.documentMode,En=null,ws=null,ur=null,Ns=!1;function qo(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Ns||En==null||En!==Ke(r)||(r=En,"selectionStart"in r&&Ss(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),ur&&cr(ur,r)||(ur=r,r=el(ws,"onSelect"),0Ln||(e.current=Ms[Ln],Ms[Ln]=null,Ln--)}function _e(e,t){Ln++,Ms[Ln]=e.current,e.current=t}var Kt={},Ge=Qt(Kt),tt=Qt(!1),cn=Kt;function Rn(e,t){var n=e.type.contextTypes;if(!n)return Kt;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var s={},i;for(i in n)s[i]=t[i];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=s),s}function nt(e){return e=e.childContextTypes,e!=null}function ll(){be(tt),be(Ge)}function ma(e,t,n){if(Ge.current!==Kt)throw Error(c(168));_e(Ge,t),_e(tt,n)}function ha(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var s in r)if(!(s in t))throw Error(c(108,ne(e)||"Unknown",s));return U({},n,r)}function sl(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Kt,cn=Ge.current,_e(Ge,e),_e(tt,tt.current),!0}function va(e,t,n){var r=e.stateNode;if(!r)throw Error(c(169));n?(e=ha(e,t,cn),r.__reactInternalMemoizedMergedChildContext=e,be(tt),be(Ge),_e(Ge,e)):be(tt),_e(tt,n)}var Rt=null,il=!1,As=!1;function ga(e){Rt===null?Rt=[e]:Rt.push(e)}function Rd(e){il=!0,ga(e)}function Gt(){if(!As&&Rt!==null){As=!0;var e=0,t=Ce;try{var n=Rt;for(Ce=1;e>=a,s-=a,Pt=1<<32-yt(t)+s|n<ae?(He=se,se=null):He=se.sibling;var we=O(j,se,S[ae],B);if(we===null){se===null&&(se=He);break}e&&se&&we.alternate===null&&t(j,se),h=i(we,h,ae),le===null?q=we:le.sibling=we,le=we,se=He}if(ae===S.length)return n(j,se),Te&&dn(j,ae),q;if(se===null){for(;aeae?(He=se,se=null):He=se.sibling;var rn=O(j,se,we.value,B);if(rn===null){se===null&&(se=He);break}e&&se&&rn.alternate===null&&t(j,se),h=i(rn,h,ae),le===null?q=rn:le.sibling=rn,le=rn,se=He}if(we.done)return n(j,se),Te&&dn(j,ae),q;if(se===null){for(;!we.done;ae++,we=S.next())we=F(j,we.value,B),we!==null&&(h=i(we,h,ae),le===null?q=we:le.sibling=we,le=we);return Te&&dn(j,ae),q}for(se=r(j,se);!we.done;ae++,we=S.next())we=Q(se,j,ae,we.value,B),we!==null&&(e&&we.alternate!==null&&se.delete(we.key===null?ae:we.key),h=i(we,h,ae),le===null?q=we:le.sibling=we,le=we);return e&&se.forEach(function(pf){return t(j,pf)}),Te&&dn(j,ae),q}function Me(j,h,S,B){if(typeof S=="object"&&S!==null&&S.type===me&&S.key===null&&(S=S.props.children),typeof S=="object"&&S!==null){switch(S.$$typeof){case oe:e:{for(var q=S.key,le=h;le!==null;){if(le.key===q){if(q=S.type,q===me){if(le.tag===7){n(j,le.sibling),h=s(le,S.props.children),h.return=j,j=h;break e}}else if(le.elementType===q||typeof q=="object"&&q!==null&&q.$$typeof===Ee&&wa(q)===le.type){n(j,le.sibling),h=s(le,S.props),h.ref=vr(j,le,S),h.return=j,j=h;break e}n(j,le);break}else t(j,le);le=le.sibling}S.type===me?(h=xn(S.props.children,j.mode,B,S.key),h.return=j,j=h):(B=Il(S.type,S.key,S.props,null,j.mode,B),B.ref=vr(j,h,S),B.return=j,j=B)}return a(j);case ue:e:{for(le=S.key;h!==null;){if(h.key===le)if(h.tag===4&&h.stateNode.containerInfo===S.containerInfo&&h.stateNode.implementation===S.implementation){n(j,h.sibling),h=s(h,S.children||[]),h.return=j,j=h;break e}else{n(j,h);break}else t(j,h);h=h.sibling}h=Ii(S,j.mode,B),h.return=j,j=h}return a(j);case Ee:return le=S._init,Me(j,h,le(S._payload),B)}if(Vn(S))return Y(j,h,S,B);if(K(S))return Z(j,h,S,B);ul(j,S)}return typeof S=="string"&&S!==""||typeof S=="number"?(S=""+S,h!==null&&h.tag===6?(n(j,h.sibling),h=s(h,S),h.return=j,j=h):(n(j,h),h=Pi(S,j.mode,B),h.return=j,j=h),a(j)):n(j,h)}return Me}var Mn=Na(!0),Ca=Na(!1),dl=Qt(null),fl=null,An=null,Us=null;function Hs(){Us=An=fl=null}function Vs(e){var t=dl.current;be(dl),e._currentValue=t}function Qs(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function On(e,t){fl=e,Us=An=null,e=e.dependencies,e!==null&&e.firstContext!==null&&((e.lanes&t)!==0&&(rt=!0),e.firstContext=null)}function pt(e){var t=e._currentValue;if(Us!==e)if(e={context:e,memoizedValue:t,next:null},An===null){if(fl===null)throw Error(c(308));An=e,fl.dependencies={lanes:0,firstContext:e}}else An=An.next=e;return t}var fn=null;function Ks(e){fn===null?fn=[e]:fn.push(e)}function Ea(e,t,n,r){var s=t.interleaved;return s===null?(n.next=n,Ks(t)):(n.next=s.next,s.next=n),t.interleaved=n,Dt(e,r)}function Dt(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var Yt=!1;function Gs(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function _a(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function Mt(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function Xt(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,(Se&2)!==0){var s=r.pending;return s===null?t.next=t:(t.next=s.next,s.next=t),r.pending=t,Dt(e,n)}return s=r.interleaved,s===null?(t.next=t,Ks(r)):(t.next=s.next,s.next=t),r.interleaved=t,Dt(e,n)}function pl(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,as(e,n)}}function za(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var s=null,i=null;if(n=n.firstBaseUpdate,n!==null){do{var a={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};i===null?s=i=a:i=i.next=a,n=n.next}while(n!==null);i===null?s=i=t:i=i.next=t}else s=i=t;n={baseState:r.baseState,firstBaseUpdate:s,lastBaseUpdate:i,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function ml(e,t,n,r){var s=e.updateQueue;Yt=!1;var i=s.firstBaseUpdate,a=s.lastBaseUpdate,u=s.shared.pending;if(u!==null){s.shared.pending=null;var p=u,N=p.next;p.next=null,a===null?i=N:a.next=N,a=p;var $=e.alternate;$!==null&&($=$.updateQueue,u=$.lastBaseUpdate,u!==a&&(u===null?$.firstBaseUpdate=N:u.next=N,$.lastBaseUpdate=p))}if(i!==null){var F=s.baseState;a=0,$=N=p=null,u=i;do{var O=u.lane,Q=u.eventTime;if((r&O)===O){$!==null&&($=$.next={eventTime:Q,lane:0,tag:u.tag,payload:u.payload,callback:u.callback,next:null});e:{var Y=e,Z=u;switch(O=t,Q=n,Z.tag){case 1:if(Y=Z.payload,typeof Y=="function"){F=Y.call(Q,F,O);break e}F=Y;break e;case 3:Y.flags=Y.flags&-65537|128;case 0:if(Y=Z.payload,O=typeof Y=="function"?Y.call(Q,F,O):Y,O==null)break e;F=U({},F,O);break e;case 2:Yt=!0}}u.callback!==null&&u.lane!==0&&(e.flags|=64,O=s.effects,O===null?s.effects=[u]:O.push(u))}else Q={eventTime:Q,lane:O,tag:u.tag,payload:u.payload,callback:u.callback,next:null},$===null?(N=$=Q,p=F):$=$.next=Q,a|=O;if(u=u.next,u===null){if(u=s.shared.pending,u===null)break;O=u,u=O.next,O.next=null,s.lastBaseUpdate=O,s.shared.pending=null}}while(!0);if($===null&&(p=F),s.baseState=p,s.firstBaseUpdate=N,s.lastBaseUpdate=$,t=s.shared.interleaved,t!==null){s=t;do a|=s.lane,s=s.next;while(s!==t)}else i===null&&(s.shared.lanes=0);hn|=a,e.lanes=a,e.memoizedState=F}}function ba(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;tn?n:4,e(!0);var r=qs.transition;qs.transition={};try{e(!1),t()}finally{Ce=n,qs.transition=r}}function Ga(){return mt().memoizedState}function Md(e,t,n){var r=en(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},Ya(e))Xa(t,n);else if(n=Ea(e,t,n,r),n!==null){var s=qe();Nt(n,e,r,s),Za(n,t,r)}}function Ad(e,t,n){var r=en(e),s={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(Ya(e))Xa(t,s);else{var i=e.alternate;if(e.lanes===0&&(i===null||i.lanes===0)&&(i=t.lastRenderedReducer,i!==null))try{var a=t.lastRenderedState,u=i(a,n);if(s.hasEagerState=!0,s.eagerState=u,xt(u,a)){var p=t.interleaved;p===null?(s.next=s,Ks(t)):(s.next=p.next,p.next=s),t.interleaved=s;return}}catch{}finally{}n=Ea(e,t,s,r),n!==null&&(s=qe(),Nt(n,e,r,s),Za(n,t,r))}}function Ya(e){var t=e.alternate;return e===Re||t!==null&&t===Re}function Xa(e,t){kr=gl=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Za(e,t,n){if((n&4194240)!==0){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,as(e,n)}}var kl={readContext:pt,useCallback:Ye,useContext:Ye,useEffect:Ye,useImperativeHandle:Ye,useInsertionEffect:Ye,useLayoutEffect:Ye,useMemo:Ye,useReducer:Ye,useRef:Ye,useState:Ye,useDebugValue:Ye,useDeferredValue:Ye,useTransition:Ye,useMutableSource:Ye,useSyncExternalStore:Ye,useId:Ye,unstable_isNewReconciler:!1},Od={readContext:pt,useCallback:function(e,t){return bt().memoizedState=[e,t===void 0?null:t],e},useContext:pt,useEffect:Fa,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,yl(4194308,4,Ua.bind(null,t,e),n)},useLayoutEffect:function(e,t){return yl(4194308,4,e,t)},useInsertionEffect:function(e,t){return yl(4,2,e,t)},useMemo:function(e,t){var n=bt();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=bt();return t=n!==void 0?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=Md.bind(null,Re,e),[r.memoizedState,e]},useRef:function(e){var t=bt();return e={current:e},t.memoizedState=e},useState:Oa,useDebugValue:ii,useDeferredValue:function(e){return bt().memoizedState=e},useTransition:function(){var e=Oa(!1),t=e[0];return e=Dd.bind(null,e[1]),bt().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=Re,s=bt();if(Te){if(n===void 0)throw Error(c(407));n=n()}else{if(n=t(),Ue===null)throw Error(c(349));(mn&30)!==0||Pa(r,t,n)}s.memoizedState=n;var i={value:n,getSnapshot:t};return s.queue=i,Fa(Da.bind(null,r,i,e),[e]),r.flags|=2048,wr(9,Ia.bind(null,r,i,n,t),void 0,null),n},useId:function(){var e=bt(),t=Ue.identifierPrefix;if(Te){var n=It,r=Pt;n=(r&~(1<<32-yt(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=jr++,0<\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=a.createElement(n,{is:r.is}):(e=a.createElement(n),n==="select"&&(a=e,r.multiple?a.multiple=!0:r.size&&(a.size=r.size))):e=a.createElementNS(e,n),e[_t]=t,e[mr]=r,gc(e,t,!1,!1),t.stateNode=e;e:{switch(a=Jl(n,r),n){case"dialog":ze("cancel",e),ze("close",e),s=r;break;case"iframe":case"object":case"embed":ze("load",e),s=r;break;case"video":case"audio":for(s=0;sUn&&(t.flags|=128,r=!0,Nr(i,!1),t.lanes=4194304)}else{if(!r)if(e=hl(a),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),Nr(i,!0),i.tail===null&&i.tailMode==="hidden"&&!a.alternate&&!Te)return Xe(t),null}else 2*De()-i.renderingStartTime>Un&&n!==1073741824&&(t.flags|=128,r=!0,Nr(i,!1),t.lanes=4194304);i.isBackwards?(a.sibling=t.child,t.child=a):(n=i.last,n!==null?n.sibling=a:t.child=a,i.last=a)}return i.tail!==null?(t=i.tail,i.rendering=t,i.tail=t.sibling,i.renderingStartTime=De(),t.sibling=null,n=Le.current,_e(Le,r?n&1|2:n&1),t):(Xe(t),null);case 22:case 23:return Ti(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&(t.mode&1)!==0?(ut&1073741824)!==0&&(Xe(t),t.subtreeFlags&6&&(t.flags|=8192)):Xe(t),null;case 24:return null;case 25:return null}throw Error(c(156,t.tag))}function Qd(e,t){switch($s(t),t.tag){case 1:return nt(t.type)&&ll(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return $n(),be(tt),be(Ge),Js(),e=t.flags,(e&65536)!==0&&(e&128)===0?(t.flags=e&-65537|128,t):null;case 5:return Xs(t),null;case 13:if(be(Le),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(c(340));Dn()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return be(Le),null;case 4:return $n(),null;case 10:return Vs(t.type._context),null;case 22:case 23:return Ti(),null;case 24:return null;default:return null}}var Nl=!1,Ze=!1,Kd=typeof WeakSet=="function"?WeakSet:Set,G=null;function Bn(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){Pe(e,t,r)}else n.current=null}function yi(e,t,n){try{n()}catch(r){Pe(e,t,r)}}var kc=!1;function Gd(e,t){if(Ts=Hr,e=Jo(),Ss(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var s=r.anchorOffset,i=r.focusNode;r=r.focusOffset;try{n.nodeType,i.nodeType}catch{n=null;break e}var a=0,u=-1,p=-1,N=0,$=0,F=e,O=null;t:for(;;){for(var Q;F!==n||s!==0&&F.nodeType!==3||(u=a+s),F!==i||r!==0&&F.nodeType!==3||(p=a+r),F.nodeType===3&&(a+=F.nodeValue.length),(Q=F.firstChild)!==null;)O=F,F=Q;for(;;){if(F===e)break t;if(O===n&&++N===s&&(u=a),O===i&&++$===r&&(p=a),(Q=F.nextSibling)!==null)break;F=O,O=F.parentNode}F=Q}n=u===-1||p===-1?null:{start:u,end:p}}else n=null}n=n||{start:0,end:0}}else n=null;for(Ls={focusedElem:e,selectionRange:n},Hr=!1,G=t;G!==null;)if(t=G,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,G=e;else for(;G!==null;){t=G;try{var Y=t.alternate;if((t.flags&1024)!==0)switch(t.tag){case 0:case 11:case 15:break;case 1:if(Y!==null){var Z=Y.memoizedProps,Me=Y.memoizedState,j=t.stateNode,h=j.getSnapshotBeforeUpdate(t.elementType===t.type?Z:jt(t.type,Z),Me);j.__reactInternalSnapshotBeforeUpdate=h}break;case 3:var S=t.stateNode.containerInfo;S.nodeType===1?S.textContent="":S.nodeType===9&&S.documentElement&&S.removeChild(S.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(c(163))}}catch(B){Pe(t,t.return,B)}if(e=t.sibling,e!==null){e.return=t.return,G=e;break}G=t.return}return Y=kc,kc=!1,Y}function Cr(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var s=r=r.next;do{if((s.tag&e)===e){var i=s.destroy;s.destroy=void 0,i!==void 0&&yi(t,n,i)}s=s.next}while(s!==r)}}function Cl(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function xi(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t=="function"?t(e):t.current=e}}function jc(e){var t=e.alternate;t!==null&&(e.alternate=null,jc(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[_t],delete t[mr],delete t[Ds],delete t[Td],delete t[Ld])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function Sc(e){return e.tag===5||e.tag===3||e.tag===4}function wc(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Sc(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function ki(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=nl));else if(r!==4&&(e=e.child,e!==null))for(ki(e,t,n),e=e.sibling;e!==null;)ki(e,t,n),e=e.sibling}function ji(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(ji(e,t,n),e=e.sibling;e!==null;)ji(e,t,n),e=e.sibling}var Ve=null,St=!1;function Zt(e,t,n){for(n=n.child;n!==null;)Nc(e,t,n),n=n.sibling}function Nc(e,t,n){if(Et&&typeof Et.onCommitFiberUnmount=="function")try{Et.onCommitFiberUnmount(Or,n)}catch{}switch(n.tag){case 5:Ze||Bn(n,t);case 6:var r=Ve,s=St;Ve=null,Zt(e,t,n),Ve=r,St=s,Ve!==null&&(St?(e=Ve,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):Ve.removeChild(n.stateNode));break;case 18:Ve!==null&&(St?(e=Ve,n=n.stateNode,e.nodeType===8?Is(e.parentNode,n):e.nodeType===1&&Is(e,n),rr(e)):Is(Ve,n.stateNode));break;case 4:r=Ve,s=St,Ve=n.stateNode.containerInfo,St=!0,Zt(e,t,n),Ve=r,St=s;break;case 0:case 11:case 14:case 15:if(!Ze&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){s=r=r.next;do{var i=s,a=i.destroy;i=i.tag,a!==void 0&&((i&2)!==0||(i&4)!==0)&&yi(n,t,a),s=s.next}while(s!==r)}Zt(e,t,n);break;case 1:if(!Ze&&(Bn(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(u){Pe(n,t,u)}Zt(e,t,n);break;case 21:Zt(e,t,n);break;case 22:n.mode&1?(Ze=(r=Ze)||n.memoizedState!==null,Zt(e,t,n),Ze=r):Zt(e,t,n);break;default:Zt(e,t,n)}}function Cc(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new Kd),t.forEach(function(r){var s=rf.bind(null,e,r);n.has(r)||(n.add(r),r.then(s,s))})}}function wt(e,t){var n=t.deletions;if(n!==null)for(var r=0;rs&&(s=a),r&=~i}if(r=s,r=De()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*Xd(r/1960))-r,10e?16:e,qt===null)var r=!1;else{if(e=qt,qt=null,Tl=0,(Se&6)!==0)throw Error(c(331));var s=Se;for(Se|=4,G=e.current;G!==null;){var i=G,a=i.child;if((G.flags&16)!==0){var u=i.deletions;if(u!==null){for(var p=0;pDe()-Ni?gn(e,0):wi|=n),st(e,t)}function Oc(e,t){t===0&&((e.mode&1)===0?t=1:(t=Fr,Fr<<=1,(Fr&130023424)===0&&(Fr=4194304)));var n=qe();e=Dt(e,t),e!==null&&(Jn(e,t,n),st(e,n))}function nf(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Oc(e,n)}function rf(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,s=e.memoizedState;s!==null&&(n=s.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(c(314))}r!==null&&r.delete(t),Oc(e,n)}var $c;$c=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||tt.current)rt=!0;else{if((e.lanes&n)===0&&(t.flags&128)===0)return rt=!1,Hd(e,t,n);rt=(e.flags&131072)!==0}else rt=!1,Te&&(t.flags&1048576)!==0&&ya(t,al,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;wl(e,t),e=t.pendingProps;var s=Rn(t,Ge.current);On(t,n),s=ti(null,t,r,e,s,n);var i=ni();return t.flags|=1,typeof s=="object"&&s!==null&&typeof s.render=="function"&&s.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,nt(r)?(i=!0,sl(t)):i=!1,t.memoizedState=s.state!==null&&s.state!==void 0?s.state:null,Gs(t),s.updater=jl,t.stateNode=s,s._reactInternals=t,ai(t,r,e,n),t=fi(null,t,r,!0,i,n)):(t.tag=0,Te&&i&&Os(t),Je(null,t,s,n),t=t.child),t;case 16:r=t.elementType;e:{switch(wl(e,t),e=t.pendingProps,s=r._init,r=s(r._payload),t.type=r,s=t.tag=sf(r),e=jt(r,e),s){case 0:t=di(null,t,r,e,n);break e;case 1:t=dc(null,t,r,e,n);break e;case 11:t=ic(null,t,r,e,n);break e;case 14:t=oc(null,t,r,jt(r.type,e),n);break e}throw Error(c(306,r,""))}return t;case 0:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:jt(r,s),di(e,t,r,s,n);case 1:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:jt(r,s),dc(e,t,r,s,n);case 3:e:{if(fc(t),e===null)throw Error(c(387));r=t.pendingProps,i=t.memoizedState,s=i.element,_a(e,t),ml(t,r,null,n);var a=t.memoizedState;if(r=a.element,i.isDehydrated)if(i={element:r,isDehydrated:!1,cache:a.cache,pendingSuspenseBoundaries:a.pendingSuspenseBoundaries,transitions:a.transitions},t.updateQueue.baseState=i,t.memoizedState=i,t.flags&256){s=Fn(Error(c(423)),t),t=pc(e,t,r,n,s);break e}else if(r!==s){s=Fn(Error(c(424)),t),t=pc(e,t,r,n,s);break e}else for(ct=Vt(t.stateNode.containerInfo.firstChild),at=t,Te=!0,kt=null,n=Ca(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(Dn(),r===s){t=At(e,t,n);break e}Je(e,t,r,n)}t=t.child}return t;case 5:return Ta(t),e===null&&Bs(t),r=t.type,s=t.pendingProps,i=e!==null?e.memoizedProps:null,a=s.children,Rs(r,s)?a=null:i!==null&&Rs(r,i)&&(t.flags|=32),uc(e,t),Je(e,t,a,n),t.child;case 6:return e===null&&Bs(t),null;case 13:return mc(e,t,n);case 4:return Ys(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=Mn(t,null,r,n):Je(e,t,r,n),t.child;case 11:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:jt(r,s),ic(e,t,r,s,n);case 7:return Je(e,t,t.pendingProps,n),t.child;case 8:return Je(e,t,t.pendingProps.children,n),t.child;case 12:return Je(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,s=t.pendingProps,i=t.memoizedProps,a=s.value,_e(dl,r._currentValue),r._currentValue=a,i!==null)if(xt(i.value,a)){if(i.children===s.children&&!tt.current){t=At(e,t,n);break e}}else for(i=t.child,i!==null&&(i.return=t);i!==null;){var u=i.dependencies;if(u!==null){a=i.child;for(var p=u.firstContext;p!==null;){if(p.context===r){if(i.tag===1){p=Mt(-1,n&-n),p.tag=2;var N=i.updateQueue;if(N!==null){N=N.shared;var $=N.pending;$===null?p.next=p:(p.next=$.next,$.next=p),N.pending=p}}i.lanes|=n,p=i.alternate,p!==null&&(p.lanes|=n),Qs(i.return,n,t),u.lanes|=n;break}p=p.next}}else if(i.tag===10)a=i.type===t.type?null:i.child;else if(i.tag===18){if(a=i.return,a===null)throw Error(c(341));a.lanes|=n,u=a.alternate,u!==null&&(u.lanes|=n),Qs(a,n,t),a=i.sibling}else a=i.child;if(a!==null)a.return=i;else for(a=i;a!==null;){if(a===t){a=null;break}if(i=a.sibling,i!==null){i.return=a.return,a=i;break}a=a.return}i=a}Je(e,t,s.children,n),t=t.child}return t;case 9:return s=t.type,r=t.pendingProps.children,On(t,n),s=pt(s),r=r(s),t.flags|=1,Je(e,t,r,n),t.child;case 14:return r=t.type,s=jt(r,t.pendingProps),s=jt(r.type,s),oc(e,t,r,s,n);case 15:return ac(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:jt(r,s),wl(e,t),t.tag=1,nt(r)?(e=!0,sl(t)):e=!1,On(t,n),qa(t,r,s),ai(t,r,s,n),fi(null,t,r,!0,e,n);case 19:return vc(e,t,n);case 22:return cc(e,t,n)}throw Error(c(156,t.tag))};function Fc(e,t){return xo(e,t)}function lf(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function vt(e,t,n,r){return new lf(e,t,n,r)}function Ri(e){return e=e.prototype,!(!e||!e.isReactComponent)}function sf(e){if(typeof e=="function")return Ri(e)?1:0;if(e!=null){if(e=e.$$typeof,e===ke)return 11;if(e===Ne)return 14}return 2}function nn(e,t){var n=e.alternate;return n===null?(n=vt(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function Il(e,t,n,r,s,i){var a=2;if(r=e,typeof e=="function")Ri(e)&&(a=1);else if(typeof e=="string")a=5;else e:switch(e){case me:return xn(n.children,s,i,t);case pe:a=8,s|=8;break;case Ae:return e=vt(12,n,t,s|2),e.elementType=Ae,e.lanes=i,e;case re:return e=vt(13,n,t,s),e.elementType=re,e.lanes=i,e;case te:return e=vt(19,n,t,s),e.elementType=te,e.lanes=i,e;case je:return Dl(n,s,i,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case X:a=10;break e;case ie:a=9;break e;case ke:a=11;break e;case Ne:a=14;break e;case Ee:a=16,r=null;break e}throw Error(c(130,e==null?e:typeof e,""))}return t=vt(a,n,t,s),t.elementType=e,t.type=r,t.lanes=i,t}function xn(e,t,n,r){return e=vt(7,e,r,t),e.lanes=n,e}function Dl(e,t,n,r){return e=vt(22,e,r,t),e.elementType=je,e.lanes=n,e.stateNode={isHidden:!1},e}function Pi(e,t,n){return e=vt(6,e,null,t),e.lanes=n,e}function Ii(e,t,n){return t=vt(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function of(e,t,n,r,s){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=os(0),this.expirationTimes=os(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=os(0),this.identifierPrefix=r,this.onRecoverableError=s,this.mutableSourceEagerHydrationData=null}function Di(e,t,n,r,s,i,a,u,p){return e=new of(e,t,n,u,p),t===1?(t=1,i===!0&&(t|=8)):t=0,i=vt(3,null,null,t),e.current=i,i.stateNode=e,i.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},Gs(i),e}function af(e,t,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(o)}catch(f){console.error(f)}}return o(),Bi.exports=xf(),Bi.exports}var eu;function jf(){if(eu)return Wl;eu=1;var o=kf();return Wl.createRoot=o.createRoot,Wl.hydrateRoot=o.hydrateRoot,Wl}var Sf=jf();const wf=Zi(Sf),Nf={},tu=o=>{let f;const c=new Set,y=(z,d)=>{const w=typeof z=="function"?z(f):z;if(!Object.is(w,f)){const m=f;f=d??(typeof w!="object"||w===null)?w:Object.assign({},f,w),c.forEach(R=>R(f,m))}},x=()=>f,b={setState:y,getState:x,getInitialState:()=>C,subscribe:z=>(c.add(z),()=>c.delete(z)),destroy:()=>{(Nf?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),c.clear()}},C=f=o(y,x,b);return b},Cf=o=>o?tu(o):tu;var Hi={exports:{}},Vi={},Qi={exports:{}},Ki={};/** + * @license React + * use-sync-external-store-shim.production.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var nu;function Ef(){if(nu)return Ki;nu=1;var o=Rr();function f(d,w){return d===w&&(d!==0||1/d===1/w)||d!==d&&w!==w}var c=typeof Object.is=="function"?Object.is:f,y=o.useState,x=o.useEffect,L=o.useLayoutEffect,T=o.useDebugValue;function _(d,w){var m=w(),R=y({inst:{value:m,getSnapshot:w}}),g=R[0].inst,A=R[1];return L(function(){g.value=m,g.getSnapshot=w,b(g)&&A({inst:g})},[d,m,w]),x(function(){return b(g)&&A({inst:g}),d(function(){b(g)&&A({inst:g})})},[d]),T(m),m}function b(d){var w=d.getSnapshot;d=d.value;try{var m=w();return!c(d,m)}catch{return!0}}function C(d,w){return w()}var z=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?C:_;return Ki.useSyncExternalStore=o.useSyncExternalStore!==void 0?o.useSyncExternalStore:z,Ki}var ru;function _f(){return ru||(ru=1,Qi.exports=Ef()),Qi.exports}/** + * @license React + * use-sync-external-store-shim/with-selector.production.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var lu;function zf(){if(lu)return Vi;lu=1;var o=Rr(),f=_f();function c(C,z){return C===z&&(C!==0||1/C===1/z)||C!==C&&z!==z}var y=typeof Object.is=="function"?Object.is:c,x=f.useSyncExternalStore,L=o.useRef,T=o.useEffect,_=o.useMemo,b=o.useDebugValue;return Vi.useSyncExternalStoreWithSelector=function(C,z,d,w,m){var R=L(null);if(R.current===null){var g={hasValue:!1,value:null};R.current=g}else g=R.current;R=_(function(){function P(ue){if(!W){if(W=!0,J=ue,ue=w(ue),m!==void 0&&g.hasValue){var me=g.value;if(m(me,ue))return I=me}return I=ue}if(me=I,y(J,ue))return me;var pe=w(ue);return m!==void 0&&m(me,pe)?(J=ue,me):(J=ue,I=pe)}var W=!1,J,I,oe=d===void 0?null:d;return[function(){return P(z())},oe===null?void 0:function(){return P(oe())}]},[z,d,w,m]);var A=x(C,R[0],R[1]);return T(function(){g.hasValue=!0,g.value=A},[A]),b(A),A},Vi}var su;function bf(){return su||(su=1,Hi.exports=zf()),Hi.exports}var Tf=bf();const Lf=Zi(Tf),uu={},{useDebugValue:Rf}=cu,{useSyncExternalStoreWithSelector:Pf}=Lf;let iu=!1;const If=o=>o;function Df(o,f=If,c){(uu?"production":void 0)!=="production"&&c&&!iu&&(console.warn("[DEPRECATED] Use `createWithEqualityFn` instead of `create` or use `useStoreWithEqualityFn` instead of `useStore`. They can be imported from 'zustand/traditional'. https://github.com/pmndrs/zustand/discussions/1937"),iu=!0);const y=Pf(o.subscribe,o.getState,o.getServerState||o.getInitialState,f,c);return Rf(y),y}const ou=o=>{(uu?"production":void 0)!=="production"&&typeof o!="function"&&console.warn("[DEPRECATED] Passing a vanilla store will be unsupported in a future version. Instead use `import { useStore } from 'zustand'`.");const f=typeof o=="function"?Cf(o):o,c=(y,x)=>Df(f,y,x);return Object.assign(c,f),c},Mf=o=>o?ou(o):ou,xe="";async function gt(o){const f=await fetch(o,{cache:"no-store"});if(!f.ok)throw new Error(String(f.status));return f.json()}async function Ie(o,f){return(await fetch(o,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(f)})).json()}const fe={liveStatus:()=>gt(`${xe}/api/live-status`),agentConfig:()=>gt(`${xe}/api/agent-config`),modelChangeLog:()=>gt(`${xe}/api/model-change-log`).catch(()=>[]),officialsStats:()=>gt(`${xe}/api/officials-stats`),morningBrief:()=>gt(`${xe}/api/morning-brief`),morningConfig:()=>gt(`${xe}/api/morning-config`),agentsStatus:()=>gt(`${xe}/api/agents-status`),taskActivity:o=>gt(`${xe}/api/task-activity/${encodeURIComponent(o)}`),schedulerState:o=>gt(`${xe}/api/scheduler-state/${encodeURIComponent(o)}`),skillContent:(o,f)=>gt(`${xe}/api/skill-content/${encodeURIComponent(o)}/${encodeURIComponent(f)}`),setModel:(o,f)=>Ie(`${xe}/api/set-model`,{agentId:o,model:f}),agentWake:o=>Ie(`${xe}/api/agent-wake`,{agentId:o}),taskAction:(o,f,c)=>Ie(`${xe}/api/task-action`,{taskId:o,action:f,reason:c}),reviewAction:(o,f,c)=>Ie(`${xe}/api/review-action`,{taskId:o,action:f,comment:c}),advanceState:(o,f)=>Ie(`${xe}/api/advance-state`,{taskId:o,comment:f}),archiveTask:(o,f)=>Ie(`${xe}/api/archive-task`,{taskId:o,archived:f}),archiveAllDone:()=>Ie(`${xe}/api/archive-task`,{archiveAllDone:!0}),schedulerScan:(o=180)=>Ie(`${xe}/api/scheduler-scan`,{thresholdSec:o}),schedulerRetry:(o,f)=>Ie(`${xe}/api/scheduler-retry`,{taskId:o,reason:f}),schedulerEscalate:(o,f)=>Ie(`${xe}/api/scheduler-escalate`,{taskId:o,reason:f}),schedulerRollback:(o,f)=>Ie(`${xe}/api/scheduler-rollback`,{taskId:o,reason:f}),refreshMorning:()=>Ie(`${xe}/api/morning-brief/refresh`,{}),saveMorningConfig:o=>Ie(`${xe}/api/morning-config`,o),addSkill:(o,f,c,y)=>Ie(`${xe}/api/add-skill`,{agentId:o,skillName:f,description:c,trigger:y}),addRemoteSkill:(o,f,c,y)=>Ie(`${xe}/api/add-remote-skill`,{agentId:o,skillName:f,sourceUrl:c,description:y||""}),remoteSkillsList:()=>gt(`${xe}/api/remote-skills-list`),updateRemoteSkill:(o,f)=>Ie(`${xe}/api/update-remote-skill`,{agentId:o,skillName:f}),removeRemoteSkill:(o,f)=>Ie(`${xe}/api/remove-remote-skill`,{agentId:o,skillName:f}),createTask:o=>Ie(`${xe}/api/create-task`,o),courtDiscussStart:(o,f,c)=>Ie(`${xe}/api/court-discuss/start`,{topic:o,officials:f,taskId:c}),courtDiscussAdvance:(o,f,c)=>Ie(`${xe}/api/court-discuss/advance`,{sessionId:o,userMessage:f,decree:c}),courtDiscussConclude:o=>Ie(`${xe}/api/court-discuss/conclude`,{sessionId:o}),courtDiscussDestroy:o=>Ie(`${xe}/api/court-discuss/destroy`,{sessionId:o}),courtDiscussFate:()=>gt(`${xe}/api/court-discuss/fate`)},du=[{key:"Inbox",dept:"皇上",icon:"👑",action:"下旨"},{key:"Taizi",dept:"太子",icon:"🤴",action:"分拣"},{key:"Zhongshu",dept:"中书省",icon:"📜",action:"起草"},{key:"Menxia",dept:"门下省",icon:"🔍",action:"审议"},{key:"Assigned",dept:"尚书省",icon:"📮",action:"派发"},{key:"Doing",dept:"六部",icon:"⚙️",action:"执行"},{key:"Review",dept:"尚书省",icon:"🔎",action:"汇总"},{key:"Done",dept:"回奏",icon:"✅",action:"完成"}],Af={Inbox:0,Pending:0,Taizi:1,Zhongshu:2,Menxia:3,Assigned:4,Doing:5,Review:6,Done:7,Blocked:5,Cancelled:5,Next:4},Of={太子:"#e8a040",中书省:"#a07aff",门下省:"#6a9eff",尚书省:"#6aef9a",礼部:"#f5c842",户部:"#ff9a6a",兵部:"#ff5270",刑部:"#cc4444",工部:"#44aaff",吏部:"#9b59b6",皇上:"#ffd700",回奏:"#2ecc8a"},Pr={Inbox:"收件",Pending:"待处理",Taizi:"太子分拣",Zhongshu:"中书起草",Menxia:"门下审议",Assigned:"已派发",Doing:"执行中",Review:"待审查",Done:"已完成",Blocked:"阻塞",Cancelled:"已取消",Next:"待执行"};function Ul(o){return Of[o]||"#6a9eff"}function Ji(o){const f=o.review_round||0;return o.state==="Menxia"&&f>1?`门下审议(第${f}轮)`:o.state==="Zhongshu"&&f>0?`中书修订(第${f}轮)`:Pr[o.state]||o.state}function ln(o){return/^JJC-/i.test(o.id||"")}function Vl(o){return o.archived||["Done","Cancelled"].includes(o.state)}function qi(o){const f=Af[o.state]??4;return du.map((c,y)=>({...c,status:y({liveStatus:null,agentConfig:null,changeLog:[],officialsData:null,agentsStatusData:null,morningBrief:null,subConfig:null,activeTab:"edicts",edictFilter:"active",sessFilter:"all",tplCatFilter:"全部",selectedOfficial:null,modalTaskId:null,countdown:5,toasts:[],setActiveTab:c=>{o({activeTab:c});const y=f();["models","skills","sessions"].includes(c)&&!y.agentConfig&&y.loadAgentConfig(),c==="officials"&&!y.officialsData&&y.loadOfficials(),c==="monitor"&&y.loadAgentsStatus(),c==="morning"&&!y.morningBrief&&y.loadMorning()},setEdictFilter:c=>o({edictFilter:c}),setSessFilter:c=>o({sessFilter:c}),setTplCatFilter:c=>o({tplCatFilter:c}),setSelectedOfficial:c=>o({selectedOfficial:c}),setModalTaskId:c=>o({modalTaskId:c}),setCountdown:c=>o({countdown:c}),toast:(c,y="ok")=>{const x=++Wf;o(L=>({toasts:[...L.toasts,{id:x,msg:c,type:y}]})),setTimeout(()=>{o(L=>({toasts:L.toasts.filter(T=>T.id!==x)}))},3e3)},loadLive:async()=>{try{const c=await fe.liveStatus();o({liveStatus:c}),f().officialsData||fe.officialsStats().then(x=>o({officialsData:x})).catch(()=>{})}catch{}},loadAgentConfig:async()=>{try{const c=await fe.agentConfig(),y=await fe.modelChangeLog();o({agentConfig:c,changeLog:y})}catch{}},loadOfficials:async()=>{try{const c=await fe.officialsStats();o({officialsData:c})}catch{}},loadAgentsStatus:async()=>{try{const c=await fe.agentsStatus();o({agentsStatusData:c})}catch{o({agentsStatusData:null})}},loadMorning:async()=>{try{const[c,y]=await Promise.all([fe.morningBrief(),fe.morningConfig()]);o({morningBrief:c,subConfig:y})}catch{}},loadSubConfig:async()=>{try{const c=await fe.morningConfig();o({subConfig:c})}catch{}},loadAll:async()=>{const c=f();await c.loadLive();const y=c.activeTab;["models","skills"].includes(y)&&await c.loadAgentConfig()}}));let Lr=null;function Uf(){Lr||(ee.getState().loadAll(),Lr=setInterval(()=>{const o=ee.getState(),f=o.countdown-1;f<=0?(o.setCountdown(5),o.loadAll()):o.setCountdown(f)},1e3))}function Hf(){Lr&&(clearInterval(Lr),Lr=null)}function Vf(o){if(!o)return"";try{const f=new Date(o.includes("T")?o:o.replace(" ","T")+"Z");if(isNaN(f.getTime()))return"";const c=Date.now()-f.getTime(),y=Math.floor(c/6e4);if(y<1)return"刚刚";if(y<60)return y+"分钟前";const x=Math.floor(y/60);return x<24?x+"小时前":Math.floor(x/24)+"天前"}catch{return""}}const au={Doing:0,Review:1,Assigned:2,Menxia:3,Zhongshu:4,Taizi:5,Inbox:6,Blocked:7,Next:8,Done:9,Cancelled:10};function Qf({task:o}){const f=qi(o);return l.jsx("div",{className:"ec-pipe",children:f.map((c,y)=>l.jsxs("span",{style:{display:"contents"},children:[l.jsxs("div",{className:`ep-node ${c.status}`,children:[l.jsx("div",{className:"ep-icon",children:c.icon}),l.jsx("div",{className:"ep-name",children:c.dept})]}),yP.setModalTaskId),c=ee(P=>P.toast),y=ee(P=>P.loadAll),x=o.heartbeat||{status:"unknown",label:"⚪"},L="st-"+(o.state||""),T="dt-"+(o.org||"").replace(/\s/g,""),_=du.find((P,W)=>qi(o)[W].status==="active"),b=o.todos||[],C=b.filter(P=>P.status==="completed").length,z=b.length,d=!["Done","Blocked","Cancelled"].includes(o.state),w=["Blocked","Cancelled"].includes(o.state),m=Vl(o),R=o.block&&o.block!=="无"&&o.block!=="-",g=async(P,W)=>{if(W.stopPropagation(),P==="stop"||P==="cancel"){const J=prompt(P==="stop"?"请输入叫停原因:":"请输入取消原因:");if(J===null)return;try{const I=await fe.taskAction(o.id,P,J);I.ok?(c(I.message||"操作成功"),y()):c(I.error||"操作失败","err")}catch{c("服务器连接失败","err")}}else if(P==="resume")try{const J=await fe.taskAction(o.id,"resume","恢复执行");J.ok?(c(J.message||"已恢复"),y()):c(J.error||"操作失败","err")}catch{c("服务器连接失败","err")}},A=async P=>{P.stopPropagation();try{const W=await fe.archiveTask(o.id,!o.archived);W.ok?(c(W.message||"操作成功"),y()):c(W.error||"操作失败","err")}catch{c("服务器连接失败","err")}};return l.jsxs("div",{className:`edict-card${m?" archived":""}`,onClick:()=>f(o.id),children:[l.jsx(Qf,{task:o}),l.jsx("div",{className:"ec-id",children:o.id}),l.jsx("div",{className:"ec-title",children:o.title||"(无标题)"}),l.jsxs("div",{className:"ec-meta",children:[l.jsx("span",{className:`tag ${L}`,children:Ji(o)}),o.org&&l.jsx("span",{className:`tag ${T}`,children:o.org}),_&&l.jsxs("span",{style:{fontSize:11,color:"var(--muted)"},children:["当前: ",l.jsxs("b",{style:{color:Ul(_.dept)},children:[_.dept," · ",_.action]})]})]}),o.now&&o.now!=="-"&&l.jsx("div",{style:{fontSize:11,color:"var(--muted)",lineHeight:1.5,marginBottom:6},children:o.now.substring(0,80)}),(o.review_round||0)>0&&l.jsxs("div",{style:{fontSize:11,marginBottom:6},children:[Array.from({length:o.review_round||0},(P,W)=>l.jsx("span",{style:{display:"inline-block",width:14,height:14,borderRadius:"50%",background:W<(o.review_round||0)-1?"#1a3a6a22":"var(--acc)22",border:`1px solid ${W<(o.review_round||0)-1?"#2a4a8a":"var(--acc)"}`,fontSize:9,textAlign:"center",lineHeight:"13px",marginRight:2,color:W<(o.review_round||0)-1?"#4a6aaa":"var(--acc)"},children:W+1},W)),l.jsxs("span",{style:{color:"var(--muted)",fontSize:10},children:["第 ",o.review_round," 轮磋商"]})]}),z>0&&l.jsxs("div",{className:"ec-todo-bar",children:[l.jsxs("span",{children:["📋 ",C,"/",z]}),l.jsx("div",{className:"ec-todo-track",children:l.jsx("div",{className:"ec-todo-fill",style:{width:`${Math.round(C/z*100)}%`}})}),l.jsx("span",{children:C===z?"✅ 全部完成":"🔄 进行中"})]}),l.jsxs("div",{className:"ec-footer",children:[l.jsx("span",{className:`hb ${x.status}`,children:x.label}),R&&l.jsxs("span",{className:"tag",style:{borderColor:"#ff527044",color:"var(--danger)",background:"#200a10"},children:["🚫 ",o.block]}),o.eta&&o.eta!=="-"&&l.jsxs("span",{style:{fontSize:11,color:"var(--muted)"},children:["📅 ",o.eta]})]}),l.jsxs("div",{className:"ec-actions",onClick:P=>P.stopPropagation(),children:[d&&l.jsxs(l.Fragment,{children:[l.jsx("button",{className:"mini-act",onClick:P=>g("stop",P),children:"⏸ 叫停"}),l.jsx("button",{className:"mini-act danger",onClick:P=>g("cancel",P),children:"🚫 取消"})]}),w&&l.jsx("button",{className:"mini-act",onClick:P=>g("resume",P),children:"▶ 恢复"}),m&&!o.archived&&l.jsx("button",{className:"mini-act",onClick:A,children:"📦 归档"}),o.archived&&l.jsx("button",{className:"mini-act",onClick:A,children:"📤 取消归档"})]})]})}function Gf(){const o=ee(m=>m.liveStatus),f=ee(m=>m.edictFilter),c=ee(m=>m.setEdictFilter),y=ee(m=>m.toast),x=ee(m=>m.loadAll),T=((o==null?void 0:o.tasks)||[]).filter(ln),_=T.filter(m=>!Vl(m)),b=T.filter(m=>Vl(m));let C;f==="active"?C=_:f==="archived"?C=b:C=T,C.sort((m,R)=>(au[m.state]??9)-(au[R.state]??9));const z=T.filter(m=>!m.archived&&["Done","Cancelled"].includes(m.state)),d=async()=>{if(confirm("将所有已完成/已取消的旨意移入归档?"))try{const m=await fe.archiveAllDone();m.ok?(y(`📦 ${m.count||0} 道旨意已归档`),x()):y(m.error||"批量归档失败","err")}catch{y("服务器连接失败","err")}},w=async()=>{try{const m=await fe.schedulerScan();m.ok?y(`🧭 太子巡检完成:${m.count||0} 个动作`):y(m.error||"巡检失败","err"),x()}catch{y("服务器连接失败","err")}};return l.jsxs("div",{children:[l.jsxs("div",{className:"archive-bar",children:[l.jsx("span",{className:"ab-label",children:"筛选:"}),["active","archived","all"].map(m=>l.jsx("button",{className:`ab-btn ${f===m?"active":""}`,onClick:()=>c(m),children:m==="active"?"活跃":m==="archived"?"归档":"全部"},m)),z.length>0&&l.jsx("button",{className:"ab-btn",onClick:d,children:"📦 一键归档"}),l.jsxs("span",{className:"ab-count",children:["活跃 ",_.length," · 归档 ",b.length," · 共 ",T.length]}),l.jsx("button",{className:"ab-scan",onClick:w,children:"🧭 太子巡检"})]}),l.jsx("div",{className:"edict-grid",children:C.length===0?l.jsxs("div",{className:"empty",style:{gridColumn:"1/-1"},children:["暂无旨意",l.jsx("br",{}),l.jsx("small",{style:{fontSize:11,marginTop:6,display:"block",color:"var(--muted)"},children:"通过飞书向太子发送任务,太子分拣后转中书省处理"})]}):C.map(m=>l.jsx(Kf,{task:m},m.id))})]})}function Yf(){var J;const o=ee(I=>I.liveStatus),f=ee(I=>I.agentsStatusData),c=ee(I=>I.officialsData),y=ee(I=>I.loadAgentsStatus),x=ee(I=>I.setModalTaskId),L=ee(I=>I.toast);V.useEffect(()=>{y()},[y]);const _=((o==null?void 0:o.tasks)||[]).filter(I=>ln(I)&&I.state!=="Done"&&I.state!=="Next"),b={};c!=null&&c.officials&&c.officials.forEach(I=>{b[I.id]=I});const C=async I=>{try{const oe=await fe.agentWake(I);L(oe.message||"唤醒指令已发出"),setTimeout(()=>y(),3e4)}catch{L("唤醒失败","err")}},z=async()=>{if(!f)return;const I=f.agents.filter(oe=>oe.id!=="main"&&oe.status!=="running"&&oe.status!=="unconfigured");if(!I.length){L("所有 Agent 均已在线");return}L(`正在唤醒 ${I.length} 个 Agent...`);for(const oe of I)try{await fe.agentWake(oe.id)}catch{}L(`${I.length} 个唤醒指令已发出,30秒后刷新状态`),setTimeout(()=>y(),3e4)},d=f,w=((J=d==null?void 0:d.agents)==null?void 0:J.filter(I=>I.id!=="main"))||[],m=w.filter(I=>I.status==="running").length,R=w.filter(I=>I.status==="idle").length,g=w.filter(I=>I.status==="offline").length,A=w.filter(I=>I.status==="unconfigured").length,P=d==null?void 0:d.gateway,W=P!=null&&P.probe?"ok":P!=null&&P.alive?"warn":"err";return l.jsxs("div",{children:[d&&d.ok&&l.jsxs("div",{className:"as-panel",children:[l.jsxs("div",{className:"as-header",children:[l.jsx("span",{className:"as-title",children:"🔌 Agent 在线状态"}),l.jsxs("span",{className:`as-gw ${W}`,children:["Gateway: ",(P==null?void 0:P.status)||"未知"]}),l.jsx("button",{className:"btn-refresh",onClick:()=>y(),style:{marginLeft:8},children:"🔄 刷新"}),g+A>0&&l.jsx("button",{className:"btn-refresh",onClick:z,style:{marginLeft:4,borderColor:"var(--warn)",color:"var(--warn)"},children:"⚡ 全部唤醒"})]}),l.jsx("div",{className:"as-grid",children:w.map(I=>{const oe=I.status!=="running"&&I.status!=="unconfigured"&&(P==null?void 0:P.alive);return l.jsxs("div",{className:"as-card",title:`${I.role} · ${I.statusLabel}`,children:[l.jsx("div",{className:`as-dot ${I.status}`}),l.jsx("div",{style:{fontSize:22},children:I.emoji}),l.jsx("div",{style:{fontSize:12,fontWeight:700},children:I.label}),l.jsx("div",{style:{fontSize:10,color:"var(--muted)"},children:I.role}),l.jsx("div",{style:{fontSize:10,color:"var(--muted)"},children:I.statusLabel}),I.lastActive?l.jsxs("div",{style:{fontSize:10,color:"var(--muted)"},children:["⏰ ",I.lastActive]}):l.jsx("div",{style:{fontSize:10,color:"var(--muted)"},children:"无活动记录"}),oe&&l.jsx("button",{className:"as-wake-btn",onClick:ue=>{ue.stopPropagation(),C(I.id)},children:"⚡ 唤醒"})]},I.id)})}),l.jsxs("div",{className:"as-summary",children:[l.jsxs("span",{children:[l.jsx("span",{className:"as-dot running",style:{position:"static",width:8,height:8}})," ",m," 运行中"]}),l.jsxs("span",{children:[l.jsx("span",{className:"as-dot idle",style:{position:"static",width:8,height:8}})," ",R," 待命"]}),g>0&&l.jsxs("span",{children:[l.jsx("span",{className:"as-dot offline",style:{position:"static",width:8,height:8}})," ",g," 离线"]}),A>0&&l.jsxs("span",{children:[l.jsx("span",{className:"as-dot unconfigured",style:{position:"static",width:8,height:8}})," ",A," 未配置"]}),l.jsxs("span",{style:{marginLeft:"auto",fontSize:10,color:"var(--muted)"},children:["检测于 ",(d.checkedAt||"").substring(11,19)]})]})]}),l.jsx("div",{className:"duty-grid",children:fu.map(I=>{const oe=_.filter(re=>re.org===I.label),ue=oe.some(re=>re.state==="Doing"),me=oe.some(re=>re.state==="Blocked"),pe=b[I.id],Ae=(pe==null?void 0:pe.heartbeat)||{status:"idle"},X=me?"blocked":ue?"busy":Ae.status==="active"?"active":"idle",ie=me?"⚠️ 阻塞":ue?"⚙️ 执行中":Ae.status==="active"?"🟢 活跃":"⚪ 候命",ke=me?"blocked-card":ue?"active-card":"";return l.jsxs("div",{className:`duty-card ${ke}`,children:[l.jsxs("div",{className:"dc-hdr",children:[l.jsx("span",{className:"dc-emoji",children:I.emoji}),l.jsxs("div",{className:"dc-info",children:[l.jsx("div",{className:"dc-name",children:I.label}),l.jsxs("div",{className:"dc-role",children:[I.role," · ",I.rank]})]}),l.jsxs("div",{className:"dc-status",children:[l.jsx("span",{className:`dc-dot ${X}`}),l.jsx("span",{children:ie})]})]}),l.jsx("div",{className:"dc-body",children:oe.length>0?oe.map(re=>l.jsxs("div",{className:"dc-task",onClick:()=>x(re.id),children:[l.jsx("div",{className:"dc-task-id",children:re.id}),l.jsx("div",{className:"dc-task-title",children:re.title||"(无标题)"}),re.now&&re.now!=="-"&&l.jsx("div",{className:"dc-task-now",children:re.now.substring(0,70)}),l.jsxs("div",{className:"dc-task-meta",children:[l.jsx("span",{className:`tag st-${re.state}`,children:Ji(re)}),re.block&&re.block!=="无"&&l.jsxs("span",{className:"tag",style:{borderColor:"#ff527044",color:"var(--danger)"},children:["🚫",re.block]})]})]},re.id)):l.jsxs("div",{className:"dc-idle",children:[l.jsx("span",{style:{fontSize:20},children:"🪭"}),l.jsx("span",{children:"候命中"})]})}),l.jsxs("div",{className:"dc-footer",children:[l.jsxs("span",{className:"dc-model",children:["🤖 ",(pe==null?void 0:pe.model_short)||"待配置"]}),(pe==null?void 0:pe.last_active)&&l.jsxs("span",{className:"dc-la",children:["⏰ ",pe.last_active]})]})]},I.id)})})]})}const Xf=["🥇","🥈","🥉"];function Zf(){var d;const o=ee(w=>w.officialsData),f=ee(w=>w.selectedOfficial),c=ee(w=>w.setSelectedOfficial),y=ee(w=>w.loadOfficials),x=ee(w=>w.setModalTaskId);if(V.useEffect(()=>{y()},[y]),!(o!=null&&o.officials))return l.jsx("div",{className:"empty",children:"⚠️ 请确保本地服务器已启动"});const L=o.officials,T=o.totals||{tasks_done:0,cost_cny:0},_=Math.max(...L.map(w=>w.tokens_in+w.tokens_out+w.cache_read+w.cache_write),1),b=L.filter(w=>{var m;return((m=w.heartbeat)==null?void 0:m.status)==="active"}),C=L.find(w=>{var m;return w.id===(f||((m=L[0])==null?void 0:m.id))}),z=(C==null?void 0:C.id)||((d=L[0])==null?void 0:d.id);return l.jsxs("div",{children:[b.length>0&&l.jsxs("div",{className:"off-activity",children:[l.jsx("span",{children:"🟢 当前活跃:"}),b.map(w=>l.jsxs("span",{style:{fontSize:12},children:[w.emoji," ",w.role]},w.id)),l.jsx("span",{style:{color:"var(--muted)",fontSize:11,marginLeft:"auto"},children:"其余官员待命"})]}),l.jsxs("div",{className:"off-kpi",children:[l.jsxs("div",{className:"kpi",children:[l.jsx("div",{className:"kpi-v",style:{color:"var(--acc)"},children:L.length}),l.jsx("div",{className:"kpi-l",children:"在职官员"})]}),l.jsxs("div",{className:"kpi",children:[l.jsx("div",{className:"kpi-v",style:{color:"#f5c842"},children:T.tasks_done||0}),l.jsx("div",{className:"kpi-l",children:"累计完成旨意"})]}),l.jsxs("div",{className:"kpi",children:[l.jsxs("div",{className:"kpi-v",style:{color:(T.cost_cny||0)>20?"var(--warn)":"var(--ok)"},children:["¥",T.cost_cny||0]}),l.jsx("div",{className:"kpi-l",children:"累计费用(含缓存)"})]}),l.jsxs("div",{className:"kpi",children:[l.jsx("div",{className:"kpi-v",style:{fontSize:16,paddingTop:4},children:o.top_official||"—"}),l.jsx("div",{className:"kpi-l",children:"功绩最高"})]})]}),l.jsxs("div",{className:"off-layout",children:[l.jsxs("div",{className:"off-ranklist",children:[l.jsx("div",{className:"orl-hdr",children:"功绩排行"}),L.map(w=>{const m=w.heartbeat||{status:"idle"};return l.jsxs("div",{className:`orl-item${z===w.id?" selected":""}`,onClick:()=>c(w.id),children:[l.jsx("span",{style:{minWidth:24,textAlign:"center"},children:w.merit_rank<=3?Xf[w.merit_rank-1]:"#"+w.merit_rank}),l.jsx("span",{children:w.emoji}),l.jsxs("span",{style:{flex:1},children:[l.jsx("div",{style:{fontSize:12,fontWeight:700},children:w.role}),l.jsx("div",{style:{fontSize:10,color:"var(--muted)"},children:w.label})]}),l.jsxs("span",{style:{fontSize:11},children:[w.merit_score,"分"]}),l.jsx("span",{className:`dc-dot ${m.status}`,style:{width:8,height:8}})]},w.id)})]}),l.jsx("div",{className:"off-detail",children:C?l.jsx(Jf,{official:C,maxTk:_,onOpenTask:x}):l.jsx("div",{className:"empty",children:"选择左侧官员查看详情"})})]})]})}function Jf({official:o,maxTk:f,onOpenTask:c}){const y=o.heartbeat||{status:"idle",label:"⚪ 待命"},x=o.tokens_in+o.tokens_out+o.cache_read+o.cache_write,L=o.participated_edicts||[],T=[{l:"输入",v:o.tokens_in,color:"#6a9eff"},{l:"输出",v:o.tokens_out,color:"#a07aff"},{l:"缓存读",v:o.cache_read,color:"#2ecc8a"},{l:"缓存写",v:o.cache_write,color:"#f5c842"}];return l.jsxs("div",{children:[l.jsxs("div",{style:{display:"flex",gap:16,alignItems:"center",marginBottom:20},children:[l.jsx("div",{style:{fontSize:40},children:o.emoji}),l.jsxs("div",{style:{flex:1},children:[l.jsx("div",{style:{fontSize:18,fontWeight:800},children:o.role}),l.jsxs("div",{style:{fontSize:12,color:"var(--muted)"},children:[o.label," · ",l.jsx("span",{style:{color:"var(--acc)"},children:o.model_short||o.model})]}),l.jsxs("div",{style:{fontSize:11,color:"var(--muted)",marginTop:2},children:["🏅 ",o.rank," · 功绩分 ",o.merit_score]})]}),l.jsxs("div",{style:{textAlign:"right"},children:[l.jsx("div",{className:`hb ${y.status}`,style:{marginBottom:4},children:y.label}),o.last_active&&l.jsxs("div",{style:{fontSize:10,color:"var(--muted)"},children:["活跃 ",o.last_active]}),l.jsxs("div",{style:{fontSize:10,color:"var(--muted)",marginTop:2},children:[o.sessions," 个会话 · ",o.messages," 条消息"]})]})]}),l.jsxs("div",{style:{marginBottom:18},children:[l.jsx("div",{className:"sec-title",children:"功绩统计"}),l.jsxs("div",{style:{display:"flex",gap:16},children:[l.jsxs("div",{style:{textAlign:"center"},children:[l.jsx("div",{style:{fontSize:20,fontWeight:800,color:"var(--ok)"},children:o.tasks_done}),l.jsx("div",{style:{fontSize:10,color:"var(--muted)"},children:"完成旨意"})]}),l.jsxs("div",{style:{textAlign:"center"},children:[l.jsx("div",{style:{fontSize:20,fontWeight:800,color:"var(--warn)"},children:o.tasks_active}),l.jsx("div",{style:{fontSize:10,color:"var(--muted)"},children:"执行中"})]}),l.jsxs("div",{style:{textAlign:"center"},children:[l.jsx("div",{style:{fontSize:20,fontWeight:800,color:"var(--acc)"},children:o.flow_participations}),l.jsx("div",{style:{fontSize:10,color:"var(--muted)"},children:"流转参与"})]})]})]}),l.jsxs("div",{style:{marginBottom:18},children:[l.jsx("div",{className:"sec-title",children:"Token 消耗"}),T.map(_=>l.jsxs("div",{style:{marginBottom:6},children:[l.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontSize:11,marginBottom:2},children:[l.jsx("span",{style:{color:"var(--muted)"},children:_.l}),l.jsx("span",{children:_.v.toLocaleString()})]}),l.jsx("div",{style:{height:6,background:"#0e1320",borderRadius:3},children:l.jsx("div",{style:{height:"100%",width:`${f>0?Math.round(_.v/f*100):0}%`,background:_.color,borderRadius:3}})})]},_.l))]}),l.jsxs("div",{style:{marginBottom:18},children:[l.jsx("div",{className:"sec-title",children:"累计费用"}),l.jsxs("div",{style:{display:"flex",gap:10},children:[l.jsxs("span",{style:{fontSize:12,color:o.cost_cny>10?"var(--danger)":o.cost_cny>3?"var(--warn)":"var(--ok)"},children:[l.jsxs("b",{children:["¥",o.cost_cny]})," 人民币"]}),l.jsxs("span",{style:{fontSize:12},children:[l.jsxs("b",{children:["$",o.cost_usd]})," 美元"]}),l.jsxs("span",{style:{fontSize:11,color:"var(--muted)"},children:["总计 ",x.toLocaleString()," tokens"]})]})]}),l.jsxs("div",{children:[l.jsxs("div",{className:"sec-title",children:["参与旨意(",L.length," 道)"]}),L.length===0?l.jsx("div",{style:{fontSize:12,color:"var(--muted)",padding:"8px 0"},children:"暂无旨意记录"}):l.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4},children:L.map(_=>l.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center",padding:"6px 8px",borderRadius:6,cursor:"pointer",border:"1px solid var(--line)"},onClick:()=>c(_.id),children:[l.jsx("span",{style:{fontSize:10,color:"var(--acc)",fontWeight:700},children:_.id}),l.jsx("span",{style:{flex:1,fontSize:12},children:_.title.substring(0,35)}),l.jsx("span",{className:`tag st-${_.state}`,style:{fontSize:10},children:Pr[_.state]||_.state})]},_.id))})]})]})}const qf=[{id:"anthropic/claude-sonnet-4-6",l:"Claude Sonnet 4.6",p:"Anthropic"},{id:"anthropic/claude-opus-4-5",l:"Claude Opus 4.5",p:"Anthropic"},{id:"anthropic/claude-haiku-3-5",l:"Claude Haiku 3.5",p:"Anthropic"},{id:"openai/gpt-4o",l:"GPT-4o",p:"OpenAI"},{id:"openai/gpt-4o-mini",l:"GPT-4o Mini",p:"OpenAI"},{id:"google/gemini-2.5-pro",l:"Gemini 2.5 Pro",p:"Google"},{id:"copilot/claude-sonnet-4",l:"Claude Sonnet 4",p:"Copilot"},{id:"copilot/claude-opus-4.5",l:"Claude Opus 4.5",p:"Copilot"},{id:"copilot/gpt-4o",l:"GPT-4o",p:"Copilot"},{id:"copilot/gemini-2.5-pro",l:"Gemini 2.5 Pro",p:"Copilot"}];function ep(){var w;const o=ee(m=>m.agentConfig),f=ee(m=>m.changeLog),c=ee(m=>m.loadAgentConfig),y=ee(m=>m.toast),[x,L]=V.useState({}),[T,_]=V.useState({});if(V.useEffect(()=>{c()},[c]),V.useEffect(()=>{if(o!=null&&o.agents){const m={};o.agents.forEach(R=>{m[R.id]=R.model}),L(m)}},[o]),!(o!=null&&o.agents))return l.jsx("div",{className:"empty",style:{gridColumn:"1/-1"},children:"⚠️ 请先启动本地服务器"});const b=(w=o.knownModels)!=null&&w.length?o.knownModels.map(m=>({id:m.id,l:m.label,p:m.provider})):qf,C=(m,R)=>{L(g=>({...g,[m]:R}))},z=m=>{const R=o.agents.find(g=>g.id===m);R&&L(g=>({...g,[m]:R.model}))},d=async m=>{const R=x[m];if(R){_(g=>({...g,[m]:{cls:"pending",text:"⟳ 提交中…"}}));try{const g=await fe.setModel(m,R);g.ok?(_(A=>({...A,[m]:{cls:"ok",text:"✅ 已提交,Gateway 重启中(约5秒)"}})),y(m+" 模型已更改","ok"),setTimeout(()=>c(),5500)):_(A=>({...A,[m]:{cls:"err",text:"❌ "+(g.error||"错误")}}))}catch{_(g=>({...g,[m]:{cls:"err",text:"❌ 无法连接服务器"}}))}}};return l.jsxs("div",{children:[l.jsx("div",{className:"model-grid",children:o.agents.map(m=>{const R=x[m.id]||m.model,g=R!==m.model,A=T[m.id];return l.jsxs("div",{className:"mc-card",children:[l.jsxs("div",{className:"mc-top",children:[l.jsx("span",{className:"mc-emoji",children:m.emoji||"🏛️"}),l.jsxs("div",{children:[l.jsxs("div",{className:"mc-name",children:[m.label," ",l.jsx("span",{style:{fontSize:11,color:"var(--muted)"},children:m.id})]}),l.jsx("div",{className:"mc-role",children:m.role})]})]}),l.jsxs("div",{className:"mc-cur",children:["当前: ",l.jsx("b",{children:m.model})]}),l.jsx("select",{className:"msel",value:R,onChange:P=>C(m.id,P.target.value),children:b.map(P=>l.jsxs("option",{value:P.id,children:[P.l," (",P.p,")"]},P.id))}),l.jsxs("div",{className:"mc-btns",children:[l.jsx("button",{className:"btn btn-p",disabled:!g,onClick:()=>d(m.id),children:"应用"}),l.jsx("button",{className:"btn btn-g",onClick:()=>z(m.id),children:"重置"})]}),A&&l.jsx("div",{className:`mc-st ${A.cls}`,children:A.text})]},m.id)})}),l.jsxs("div",{style:{marginTop:24},children:[l.jsx("div",{className:"sec-title",children:"变更日志"}),l.jsx("div",{className:"cl-list",children:f!=null&&f.length?[...f].reverse().slice(0,15).map((m,R)=>l.jsxs("div",{className:"cl-row",children:[l.jsx("span",{className:"cl-t",children:(m.at||"").substring(0,16).replace("T"," ")}),l.jsx("span",{className:"cl-a",children:m.agentId}),l.jsxs("span",{className:"cl-c",children:[l.jsx("b",{children:m.oldModel})," → ",l.jsx("b",{children:m.newModel}),m.rolledBack&&l.jsx("span",{style:{color:"var(--danger)",fontSize:10,border:"1px solid #ff527044",padding:"1px 5px",borderRadius:3,marginLeft:4},children:"⚠ 已回滚"})]})]},R)):l.jsx("div",{style:{fontSize:12,color:"var(--muted)",padding:"8px 0"},children:"暂无变更"})})]})]})}const tp=[{label:"obra/superpowers",emoji:"⚡",stars:"66.9k",desc:"完整开发工作流技能集",skills:[{name:"brainstorming",url:"https://raw.githubusercontent.com/obra/superpowers/refs/heads/main/skills/brainstorming/SKILL.md"},{name:"test-driven-development",url:"https://raw.githubusercontent.com/obra/superpowers/refs/heads/main/skills/test-driven-development/SKILL.md"},{name:"systematic-debugging",url:"https://raw.githubusercontent.com/obra/superpowers/refs/heads/main/skills/systematic-debugging/SKILL.md"},{name:"subagent-driven-development",url:"https://raw.githubusercontent.com/obra/superpowers/refs/heads/main/skills/subagent-driven-development/SKILL.md"},{name:"writing-plans",url:"https://raw.githubusercontent.com/obra/superpowers/refs/heads/main/skills/writing-plans/SKILL.md"},{name:"executing-plans",url:"https://raw.githubusercontent.com/obra/superpowers/refs/heads/main/skills/executing-plans/SKILL.md"},{name:"requesting-code-review",url:"https://raw.githubusercontent.com/obra/superpowers/refs/heads/main/skills/requesting-code-review/SKILL.md"},{name:"root-cause-tracing",url:"https://raw.githubusercontent.com/obra/superpowers/refs/heads/main/skills/root-cause-tracing/SKILL.md"},{name:"verification-before-completion",url:"https://raw.githubusercontent.com/obra/superpowers/refs/heads/main/skills/verification-before-completion/SKILL.md"},{name:"dispatching-parallel-agents",url:"https://raw.githubusercontent.com/obra/superpowers/refs/heads/main/skills/dispatching-parallel-agents/SKILL.md"}]},{label:"anthropics/skills",emoji:"🏛️",stars:"官方",desc:"Anthropic 官方技能库",skills:[{name:"docx",url:"https://raw.githubusercontent.com/anthropics/skills/main/skills/docx/SKILL.md"},{name:"pdf",url:"https://raw.githubusercontent.com/anthropics/skills/main/skills/pdf/SKILL.md"},{name:"xlsx",url:"https://raw.githubusercontent.com/anthropics/skills/main/skills/xlsx/SKILL.md"},{name:"pptx",url:"https://raw.githubusercontent.com/anthropics/skills/main/skills/pptx/SKILL.md"},{name:"mcp-builder",url:"https://raw.githubusercontent.com/anthropics/skills/main/skills/mcp-builder/SKILL.md"},{name:"frontend-design",url:"https://raw.githubusercontent.com/anthropics/skills/main/skills/frontend-design/SKILL.md"},{name:"web-artifacts-builder",url:"https://raw.githubusercontent.com/anthropics/skills/main/skills/web-artifacts-builder/SKILL.md"},{name:"webapp-testing",url:"https://raw.githubusercontent.com/anthropics/skills/main/skills/webapp-testing/SKILL.md"},{name:"algorithmic-art",url:"https://raw.githubusercontent.com/anthropics/skills/main/skills/algorithmic-art/SKILL.md"},{name:"canvas-design",url:"https://raw.githubusercontent.com/anthropics/skills/main/skills/canvas-design/SKILL.md"}]},{label:"ComposioHQ/awesome-claude-skills",emoji:"🌐",stars:"39.2k",desc:"100+ 社区精选技能",skills:[{name:"github-integration",url:"https://raw.githubusercontent.com/ComposioHQ/awesome-claude-skills/master/github-integration/SKILL.md"},{name:"data-analysis",url:"https://raw.githubusercontent.com/ComposioHQ/awesome-claude-skills/master/data-analysis/SKILL.md"},{name:"code-review",url:"https://raw.githubusercontent.com/ComposioHQ/awesome-claude-skills/master/code-review/SKILL.md"}]}];function np(){const o=ee(k=>k.agentConfig),f=ee(k=>k.loadAgentConfig),c=ee(k=>k.toast),[y,x]=V.useState(null),[L,T]=V.useState(null),[_,b]=V.useState({name:"",desc:"",trigger:""}),[C,z]=V.useState(!1),[d,w]=V.useState("local"),[m,R]=V.useState([]),[g,A]=V.useState(!1),[P,W]=V.useState(!1),[J,I]=V.useState({agentId:"",skillName:"",sourceUrl:"",description:""}),[oe,ue]=V.useState(!1),[me,pe]=V.useState(null),[Ae,X]=V.useState(null),[ie,ke]=V.useState(null),[re,te]=V.useState("");V.useEffect(()=>{f()},[f]),V.useEffect(()=>{d==="remote"&&Ne()},[d]);const Ne=async()=>{A(!0);try{const k=await fe.remoteSkillsList();k.ok&&R(k.remoteSkills||[])}catch{c("远程技能列表加载失败","err")}A(!1)},Ee=async(k,H)=>{x({agentId:k,name:H,content:"⟳ 加载中…",path:""});try{const ne=await fe.skillContent(k,H);ne.ok?x({agentId:k,name:H,content:ne.content||"",path:ne.path||""}):x({agentId:k,name:H,content:"❌ "+(ne.error||"无法读取"),path:""})}catch{x({agentId:k,name:H,content:"❌ 服务器连接失败",path:""})}},je=(k,H)=>{T({agentId:k,agentLabel:H}),b({name:"",desc:"",trigger:""})},E=async k=>{if(k.preventDefault(),!(!L||!_.name)){z(!0);try{const H=await fe.addSkill(L.agentId,_.name,_.desc,_.trigger);H.ok?(c(`✅ 技能 ${_.name} 已添加到 ${L.agentLabel}`,"ok"),T(null),f()):c(H.error||"添加失败","err")}catch{c("服务器连接失败","err")}z(!1)}},K=async k=>{k.preventDefault();const{agentId:H,skillName:ne,sourceUrl:ve,description:M}=J;if(!(!H||!ne||!ve)){ue(!0);try{const ce=await fe.addRemoteSkill(H,ne,ve,M);ce.ok?(c(`✅ 远程技能 ${ne} 已添加到 ${H}`,"ok"),W(!1),I({agentId:"",skillName:"",sourceUrl:"",description:""}),Ne(),f()):c(ce.error||"添加失败","err")}catch{c("服务器连接失败","err")}ue(!1)}},U=async k=>{const H=`${k.agentId}/${k.skillName}`;pe(H);try{const ne=await fe.updateRemoteSkill(k.agentId,k.skillName);ne.ok?(c(`✅ 技能 ${k.skillName} 已更新`,"ok"),Ne()):c(ne.error||"更新失败","err")}catch{c("服务器连接失败","err")}pe(null)},v=async k=>{const H=`${k.agentId}/${k.skillName}`;X(H);try{const ne=await fe.removeRemoteSkill(k.agentId,k.skillName);ne.ok?(c(`🗑️ 技能 ${k.skillName} 已移除`,"ok"),Ne(),f()):c(ne.error||"移除失败","err")}catch{c("服务器连接失败","err")}X(null)},D=async(k,H)=>{if(!re){c("请先选择目标 Agent","err");return}try{const ne=await fe.addRemoteSkill(re,H,k,"");ne.ok?(c(`✅ ${H} → ${re}`,"ok"),Ne(),f()):c(ne.error||"导入失败","err")}catch{c("服务器连接失败","err")}};if(!(o!=null&&o.agents))return l.jsx("div",{className:"empty",children:"无法加载"});const de=l.jsx("div",{children:l.jsx("div",{className:"skills-grid",children:o.agents.map(k=>l.jsxs("div",{className:"sk-card",children:[l.jsxs("div",{className:"sk-hdr",children:[l.jsx("span",{className:"sk-emoji",children:k.emoji||"🏛️"}),l.jsx("span",{className:"sk-name",children:k.label}),l.jsxs("span",{className:"sk-cnt",children:[(k.skills||[]).length," 技能"]})]}),l.jsx("div",{className:"sk-list",children:(k.skills||[]).length?(k.skills||[]).map(H=>l.jsxs("div",{className:"sk-item",onClick:()=>Ee(k.id,H.name),children:[l.jsxs("span",{className:"si-name",children:["📦 ",H.name]}),l.jsx("span",{className:"si-desc",children:H.description||"无描述"}),l.jsx("span",{className:"si-arrow",children:"›"})]},H.name)):l.jsx("div",{className:"sk-empty",children:"暂无 Skills"})}),l.jsx("div",{className:"sk-add",onClick:()=>je(k.id,k.label),children:"+ 添加技能"})]},k.id))})}),he=l.jsxs("div",{children:[l.jsxs("div",{style:{display:"flex",gap:10,marginBottom:20,flexWrap:"wrap",alignItems:"center"},children:[l.jsx("button",{style:{padding:"8px 18px",background:"var(--acc)",color:"#fff",border:"none",borderRadius:8,cursor:"pointer",fontWeight:600,fontSize:13},onClick:()=>{W(!0),ke(null)},children:"+ 添加远程 Skill"}),l.jsx("button",{style:{padding:"8px 14px",background:"transparent",color:"var(--acc)",border:"1px solid var(--acc)",borderRadius:8,cursor:"pointer",fontSize:12},onClick:Ne,children:"⟳ 刷新列表"}),l.jsxs("span",{style:{fontSize:11,color:"var(--muted)",marginLeft:4},children:["共 ",m.length," 个远程技能"]})]}),l.jsxs("div",{style:{marginBottom:24},children:[l.jsx("div",{style:{fontSize:12,fontWeight:700,color:"var(--muted)",letterSpacing:".06em",marginBottom:10},children:"🌐 社区技能源 — 一键导入"}),l.jsx("div",{style:{display:"flex",gap:10,flexWrap:"wrap"},children:tp.map(k=>l.jsxs("div",{onClick:()=>ke((ie==null?void 0:ie.label)===k.label?null:k),style:{padding:"8px 14px",background:(ie==null?void 0:ie.label)===k.label?"#0d1f45":"var(--panel)",border:`1px solid ${(ie==null?void 0:ie.label)===k.label?"var(--acc)":"var(--line)"}`,borderRadius:10,cursor:"pointer",fontSize:12,transition:"all .15s"},children:[l.jsx("span",{style:{marginRight:6},children:k.emoji}),l.jsx("b",{style:{color:"var(--text)"},children:k.label}),l.jsxs("span",{style:{marginLeft:6,color:"#f0b429",fontSize:11},children:["★ ",k.stars]}),l.jsx("span",{style:{marginLeft:8,color:"var(--muted)"},children:k.desc})]},k.label))}),ie&&l.jsxs("div",{style:{marginTop:14,background:"var(--panel)",border:"1px solid var(--line)",borderRadius:12,padding:16},children:[l.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,marginBottom:14},children:[l.jsx("span",{style:{fontSize:12,fontWeight:600},children:"目标 Agent:"}),l.jsxs("select",{value:re,onChange:k=>te(k.target.value),style:{padding:"6px 10px",background:"var(--bg)",border:"1px solid var(--line)",borderRadius:6,color:"var(--text)",fontSize:12},children:[l.jsx("option",{value:"",children:"— 选择 Agent —"}),o.agents.map(k=>l.jsxs("option",{value:k.id,children:[k.emoji," ",k.label," (",k.id,")"]},k.id))]})]}),l.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(260px, 1fr))",gap:8},children:ie.skills.map(k=>{const H=m.some(ne=>ne.skillName===k.name&&ne.agentId===re);return l.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 12px",background:"var(--panel2)",borderRadius:8,border:"1px solid var(--line)"},children:[l.jsxs("div",{children:[l.jsxs("div",{style:{fontSize:12,fontWeight:600},children:["📦 ",k.name]}),l.jsx("div",{style:{fontSize:10,color:"var(--muted)",wordBreak:"break-all",maxWidth:180},children:k.url.split("/").slice(-2).join("/")})]}),H?l.jsx("span",{style:{fontSize:10,color:"#4caf88",fontWeight:600},children:"✓ 已导入"}):l.jsx("button",{onClick:()=>D(k.url,k.name),style:{padding:"4px 10px",background:"var(--acc)",color:"#fff",border:"none",borderRadius:6,cursor:"pointer",fontSize:11,whiteSpace:"nowrap"},children:"导入"})]},k.name)})})]})]}),g?l.jsx("div",{style:{textAlign:"center",padding:"40px 0",color:"var(--muted)",fontSize:13},children:"⟳ 加载中…"}):m.length===0?l.jsxs("div",{style:{textAlign:"center",padding:"40px",background:"var(--panel)",borderRadius:12,border:"1px dashed var(--line)"},children:[l.jsx("div",{style:{fontSize:32,marginBottom:10},children:"🌐"}),l.jsx("div",{style:{fontSize:14,color:"var(--muted)"},children:"尚无远程技能"}),l.jsx("div",{style:{fontSize:12,color:"var(--muted)",marginTop:6},children:"从社区技能源快速导入,或手动添加 URL"})]}):l.jsx("div",{style:{display:"flex",flexDirection:"column",gap:10},children:m.map(k=>{var ce;const H=`${k.agentId}/${k.skillName}`,ne=me===H,ve=Ae===H,M=o.agents.find(ye=>ye.id===k.agentId);return l.jsxs("div",{style:{background:"var(--panel)",border:"1px solid var(--line)",borderRadius:12,padding:"14px 18px",display:"grid",gridTemplateColumns:"1fr auto",gap:12,alignItems:"center"},children:[l.jsxs("div",{children:[l.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:6},children:[l.jsxs("span",{style:{fontSize:14,fontWeight:700},children:["📦 ",k.skillName]}),l.jsx("span",{style:{fontSize:10,padding:"2px 8px",borderRadius:999,background:k.status==="valid"?"#0d3322":"#3d1111",color:k.status==="valid"?"#4caf88":"#ff5270",fontWeight:600},children:k.status==="valid"?"✓ 有效":"✗ 文件丢失"}),l.jsxs("span",{style:{fontSize:11,color:"var(--muted)",background:"var(--panel2)",padding:"2px 8px",borderRadius:6},children:[M==null?void 0:M.emoji," ",(M==null?void 0:M.label)||k.agentId]})]}),k.description&&l.jsx("div",{style:{fontSize:12,color:"var(--muted)",marginBottom:4},children:k.description}),l.jsxs("div",{style:{fontSize:10,color:"var(--muted)",display:"flex",gap:16,flexWrap:"wrap"},children:[l.jsxs("span",{children:["🔗 ",l.jsx("a",{href:k.sourceUrl,target:"_blank",rel:"noreferrer",style:{color:"var(--acc)",textDecoration:"none"},children:k.sourceUrl.length>60?k.sourceUrl.slice(0,60)+"…":k.sourceUrl})]}),l.jsxs("span",{children:["📅 ",k.lastUpdated?k.lastUpdated.slice(0,10):(ce=k.addedAt)==null?void 0:ce.slice(0,10)]})]})]}),l.jsxs("div",{style:{display:"flex",gap:8},children:[l.jsx("button",{onClick:()=>Ee(k.agentId,k.skillName),style:{padding:"6px 12px",background:"transparent",color:"var(--muted)",border:"1px solid var(--line)",borderRadius:6,cursor:"pointer",fontSize:11},children:"查看"}),l.jsx("button",{onClick:()=>U(k),disabled:ne,style:{padding:"6px 12px",background:"transparent",color:"var(--acc)",border:"1px solid var(--acc)",borderRadius:6,cursor:"pointer",fontSize:11},children:ne?"⟳":"更新"}),l.jsx("button",{onClick:()=>v(k),disabled:ve,style:{padding:"6px 12px",background:"transparent",color:"#ff5270",border:"1px solid #ff5270",borderRadius:6,cursor:"pointer",fontSize:11},children:ve?"⟳":"删除"})]})]},H)})})]});return l.jsxs("div",{children:[l.jsx("div",{style:{display:"flex",gap:4,marginBottom:20,borderBottom:"1px solid var(--line)",paddingBottom:0},children:[{key:"local",label:"🏛️ 本地技能",count:o.agents.reduce((k,H)=>{var ne;return k+(((ne=H.skills)==null?void 0:ne.length)||0)},0)},{key:"remote",label:"🌐 远程技能",count:m.length}].map(k=>l.jsxs("div",{onClick:()=>w(k.key),style:{padding:"8px 18px",cursor:"pointer",fontSize:13,borderRadius:"8px 8px 0 0",fontWeight:d===k.key?700:400,background:d===k.key?"var(--panel)":"transparent",color:d===k.key?"var(--text)":"var(--muted)",border:d===k.key?"1px solid var(--line)":"1px solid transparent",borderBottom:d===k.key?"1px solid var(--panel)":"1px solid transparent",position:"relative",bottom:-1,transition:"all .15s"},children:[k.label,k.count>0&&l.jsx("span",{style:{marginLeft:6,fontSize:10,padding:"1px 6px",borderRadius:999,background:"#1a2040",color:"var(--acc)"},children:k.count})]},k.key))}),d==="local"?de:he,y&&l.jsx("div",{className:"modal-bg open",onClick:()=>x(null),children:l.jsxs("div",{className:"modal",onClick:k=>k.stopPropagation(),children:[l.jsx("button",{className:"modal-close",onClick:()=>x(null),children:"✕"}),l.jsxs("div",{className:"modal-body",children:[l.jsx("div",{style:{fontSize:11,color:"var(--acc)",fontWeight:700,letterSpacing:".04em",marginBottom:4},children:y.agentId.toUpperCase()}),l.jsxs("div",{style:{fontSize:20,fontWeight:800,marginBottom:16},children:["📦 ",y.name]}),l.jsxs("div",{className:"sk-modal-body",children:[l.jsx("div",{className:"sk-md",style:{whiteSpace:"pre-wrap",fontSize:12,lineHeight:1.7},children:y.content}),y.path&&l.jsxs("div",{className:"sk-path",style:{fontSize:10,color:"var(--muted)",marginTop:12},children:["📂 ",y.path]})]})]})]})}),L&&l.jsx("div",{className:"modal-bg open",onClick:()=>T(null),children:l.jsxs("div",{className:"modal",onClick:k=>k.stopPropagation(),children:[l.jsx("button",{className:"modal-close",onClick:()=>T(null),children:"✕"}),l.jsxs("div",{className:"modal-body",children:[l.jsxs("div",{style:{fontSize:11,color:"var(--acc)",fontWeight:700,letterSpacing:".04em",marginBottom:4},children:["为 ",L.agentLabel," 添加技能"]}),l.jsx("div",{style:{fontSize:20,fontWeight:800,marginBottom:18},children:"+ 新增 Skill"}),l.jsxs("div",{style:{background:"var(--panel2)",border:"1px solid var(--line)",borderRadius:10,padding:14,marginBottom:18,fontSize:12,lineHeight:1.7,color:"var(--muted)"},children:[l.jsx("b",{style:{color:"var(--text)"},children:"📋 Skill 规范说明"}),l.jsx("br",{}),"• 技能名称使用",l.jsx("b",{style:{color:"var(--text)"},children:"小写英文 + 连字符"}),l.jsx("br",{}),"• 创建后会生成模板文件 SKILL.md",l.jsx("br",{}),"• 技能会在 agent 收到相关任务时",l.jsx("b",{style:{color:"var(--text)"},children:"自动激活"})]}),l.jsxs("form",{onSubmit:E,style:{display:"flex",flexDirection:"column",gap:14},children:[l.jsxs("div",{children:[l.jsxs("label",{style:{fontSize:12,fontWeight:600,display:"block",marginBottom:6},children:["技能名称 ",l.jsx("span",{style:{color:"#ff5270"},children:"*"})]}),l.jsx("input",{type:"text",required:!0,placeholder:"如 data-analysis, code-review",value:_.name,onChange:k=>b(H=>({...H,name:k.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"")})),style:{width:"100%",padding:"10px 12px",background:"var(--bg)",border:"1px solid var(--line)",borderRadius:8,color:"var(--text)",fontSize:13,outline:"none"}})]}),l.jsxs("div",{children:[l.jsx("label",{style:{fontSize:12,fontWeight:600,display:"block",marginBottom:6},children:"技能描述"}),l.jsx("input",{type:"text",placeholder:"一句话说明用途",value:_.desc,onChange:k=>b(H=>({...H,desc:k.target.value})),style:{width:"100%",padding:"10px 12px",background:"var(--bg)",border:"1px solid var(--line)",borderRadius:8,color:"var(--text)",fontSize:13,outline:"none"}})]}),l.jsxs("div",{children:[l.jsx("label",{style:{fontSize:12,fontWeight:600,display:"block",marginBottom:6},children:"触发条件(可选)"}),l.jsx("input",{type:"text",placeholder:"何时激活此技能",value:_.trigger,onChange:k=>b(H=>({...H,trigger:k.target.value})),style:{width:"100%",padding:"10px 12px",background:"var(--bg)",border:"1px solid var(--line)",borderRadius:8,color:"var(--text)",fontSize:13,outline:"none"}})]}),l.jsxs("div",{style:{display:"flex",gap:10,justifyContent:"flex-end",marginTop:4},children:[l.jsx("button",{type:"button",className:"btn btn-g",onClick:()=>T(null),style:{padding:"8px 20px"},children:"取消"}),l.jsx("button",{type:"submit",disabled:C,style:{padding:"8px 20px",fontSize:13,background:"var(--acc)",color:"#fff",border:"none",borderRadius:8,cursor:"pointer",fontWeight:600},children:C?"⟳ 创建中…":"📦 创建技能"})]})]})]})]})}),P&&l.jsx("div",{className:"modal-bg open",onClick:()=>W(!1),children:l.jsxs("div",{className:"modal",style:{maxWidth:520},onClick:k=>k.stopPropagation(),children:[l.jsx("button",{className:"modal-close",onClick:()=>W(!1),children:"✕"}),l.jsxs("div",{className:"modal-body",children:[l.jsx("div",{style:{fontSize:11,color:"#a07aff",fontWeight:700,letterSpacing:".04em",marginBottom:4},children:"远程技能管理"}),l.jsx("div",{style:{fontSize:20,fontWeight:800,marginBottom:18},children:"🌐 添加远程 Skill"}),l.jsxs("div",{style:{background:"var(--panel2)",border:"1px solid var(--line)",borderRadius:10,padding:12,marginBottom:18,fontSize:11,color:"var(--muted)",lineHeight:1.7},children:["支持 GitHub Raw URL,如:",l.jsx("br",{}),l.jsx("code",{style:{color:"var(--acc)",fontSize:10},children:"https://raw.githubusercontent.com/obra/superpowers/refs/heads/main/skills/brainstorming/SKILL.md"})]}),l.jsxs("form",{onSubmit:K,style:{display:"flex",flexDirection:"column",gap:14},children:[l.jsxs("div",{children:[l.jsxs("label",{style:{fontSize:12,fontWeight:600,display:"block",marginBottom:6},children:["目标 Agent ",l.jsx("span",{style:{color:"#ff5270"},children:"*"})]}),l.jsxs("select",{required:!0,value:J.agentId,onChange:k=>I(H=>({...H,agentId:k.target.value})),style:{width:"100%",padding:"10px 12px",background:"var(--bg)",border:"1px solid var(--line)",borderRadius:8,color:"var(--text)",fontSize:13},children:[l.jsx("option",{value:"",children:"— 选择 Agent —"}),o.agents.map(k=>l.jsxs("option",{value:k.id,children:[k.emoji," ",k.label," (",k.id,")"]},k.id))]})]}),l.jsxs("div",{children:[l.jsxs("label",{style:{fontSize:12,fontWeight:600,display:"block",marginBottom:6},children:["技能名称 ",l.jsx("span",{style:{color:"#ff5270"},children:"*"})]}),l.jsx("input",{type:"text",required:!0,placeholder:"如 brainstorming, code-review",value:J.skillName,onChange:k=>I(H=>({...H,skillName:k.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"")})),style:{width:"100%",padding:"10px 12px",background:"var(--bg)",border:"1px solid var(--line)",borderRadius:8,color:"var(--text)",fontSize:13,outline:"none"}})]}),l.jsxs("div",{children:[l.jsxs("label",{style:{fontSize:12,fontWeight:600,display:"block",marginBottom:6},children:["源 URL ",l.jsx("span",{style:{color:"#ff5270"},children:"*"})]}),l.jsx("input",{type:"url",required:!0,placeholder:"https://raw.githubusercontent.com/...",value:J.sourceUrl,onChange:k=>I(H=>({...H,sourceUrl:k.target.value})),style:{width:"100%",padding:"10px 12px",background:"var(--bg)",border:"1px solid var(--line)",borderRadius:8,color:"var(--text)",fontSize:12,outline:"none"}})]}),l.jsxs("div",{children:[l.jsx("label",{style:{fontSize:12,fontWeight:600,display:"block",marginBottom:6},children:"描述(可选)"}),l.jsx("input",{type:"text",placeholder:"一句话说明用途",value:J.description,onChange:k=>I(H=>({...H,description:k.target.value})),style:{width:"100%",padding:"10px 12px",background:"var(--bg)",border:"1px solid var(--line)",borderRadius:8,color:"var(--text)",fontSize:13,outline:"none"}})]}),l.jsxs("div",{style:{display:"flex",gap:10,justifyContent:"flex-end",marginTop:4},children:[l.jsx("button",{type:"button",className:"btn btn-g",onClick:()=>W(!1),style:{padding:"8px 20px"},children:"取消"}),l.jsx("button",{type:"submit",disabled:oe,style:{padding:"8px 20px",fontSize:13,background:"#a07aff",color:"#fff",border:"none",borderRadius:8,cursor:"pointer",fontWeight:600},children:oe?"⟳ 下载中…":"🌐 添加远程技能"})]})]})]})]})})]})}function rp(){const o=ee(y=>y.agentConfig),f={},c={};return o!=null&&o.agents&&o.agents.forEach(y=>{f[y.id]=y.emoji||"🏛️",c[y.id]=y.label||y.id}),{emojiMap:f,labelMap:c}}function Hl(o){const f=(o.id||"").match(/^OC-(\w+)-/);return f?f[1]:(o.org||"").replace(/省|部/g,"").toLowerCase()}function pu(o,f){let c=o.title||"";if(c==="heartbeat 会话")return"💓 心跳检测";const y=c.match(/^agent:(\w+):(\w+)/);if(y){const x=f[y[1]]||y[1];return y[2]==="main"?x+" · 主会话":y[2]==="subagent"?x+" · 子任务执行":y[2]==="cron"?x+" · 定时任务":x+" · "+y[2]}return c.replace(/ 会话$/,"")||o.id}function mu(o){const f=o.now||"";return f.includes("feishu/direct")?{icon:"💬",text:"飞书对话"}:f.includes("feishu")?{icon:"💬",text:"飞书"}:f.includes("webchat")?{icon:"🌐",text:"WebChat"}:f.includes("cron")?{icon:"⏰",text:"定时"}:f.includes("direct")?{icon:"📨",text:"直连"}:{icon:"🔗",text:"会话"}}function lp(o){const f=o.activity||[];for(let c=f.length-1;c>=0;c--){const y=f[c];if(y.kind==="assistant"){let x=y.text||"";if(x.startsWith("NO_REPLY")||x.startsWith("Reasoning:"))continue;return x=x.replace(/\[\[.*?\]\]/g,"").replace(/\*\*/g,"").replace(/^#+\s/gm,"").trim(),x.substring(0,120)+(x.length>120?"…":"")}}return""}function sp(){const o=ee(d=>d.liveStatus),f=ee(d=>d.sessFilter),c=ee(d=>d.setSessFilter),{emojiMap:y,labelMap:x}=rp(),[L,T]=V.useState(null),b=((o==null?void 0:o.tasks)||[]).filter(d=>!ln(d));let C=b;f==="active"?C=b.filter(d=>!["Done","Cancelled"].includes(d.state)):f!=="all"&&(C=b.filter(d=>Hl(d)===f));const z=[...new Set(b.map(Hl))];return l.jsxs("div",{children:[l.jsx("div",{style:{display:"flex",gap:6,marginBottom:16,flexWrap:"wrap"},children:[{key:"all",label:`全部 (${b.length})`},{key:"active",label:"活跃"},...z.slice(0,8).map(d=>({key:d,label:x[d]||d}))].map(d=>l.jsx("span",{className:`sess-filter${f===d.key?" active":""}`,onClick:()=>c(d.key),children:d.label},d.key))}),l.jsx("div",{className:"sess-grid",children:C.length?C.map(d=>{const w=Hl(d),m=y[w]||"🏛️",R=x[w]||d.org||w,g=d.heartbeat||{status:"unknown",label:""},A=mu(d),P=pu(d,x),W=lp(d),I=(d.sourceMeta||{}).totalTokens,oe=d.eta||"",ue=g.status==="active"?"🟢":g.status==="warn"?"🟡":g.status==="stalled"?"🔴":"⚪",me=d.state||"Unknown";return l.jsxs("div",{className:"sess-card",onClick:()=>T(d),children:[l.jsxs("div",{className:"sc-top",children:[l.jsx("span",{className:"sc-emoji",children:m}),l.jsx("div",{style:{flex:1,minWidth:0},children:l.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[l.jsx("span",{className:"sc-agent",children:R}),l.jsxs("span",{style:{fontSize:10,color:"var(--muted)",background:"var(--panel2)",padding:"2px 6px",borderRadius:4},children:[A.icon," ",A.text]})]})}),l.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[l.jsx("span",{title:g.label||"",children:ue}),l.jsx("span",{className:`tag st-${me}`,style:{fontSize:10},children:Pr[me]||me})]})]}),l.jsx("div",{className:"sc-title",children:P}),W&&l.jsx("div",{style:{fontSize:11,color:"var(--muted)",lineHeight:1.5,marginBottom:8,borderLeft:"2px solid var(--line)",paddingLeft:8,maxHeight:40,overflow:"hidden"},children:W}),l.jsxs("div",{className:"sc-meta",children:[I?l.jsxs("span",{style:{fontSize:10,color:"var(--muted)"},children:["🪙 ",I.toLocaleString()," tokens"]}):null,oe?l.jsx("span",{className:"sc-time",children:Vf(oe)}):null]})]},d.id)}):l.jsx("div",{style:{fontSize:13,color:"var(--muted)",padding:24,textAlign:"center",gridColumn:"1/-1"},children:"暂无小任务/会话数据"})}),L&&l.jsx(ip,{task:L,labelMap:x,emojiMap:y,onClose:()=>T(null)})]})}function ip({task:o,labelMap:f,emojiMap:c,onClose:y}){const x=Hl(o),L=c[x]||"🏛️",T=pu(o,f),_=mu(o),b=o.heartbeat||{label:""},C=o.sourceMeta||{},z=o.activity||[],d=o.state||"Unknown",w=C.totalTokens,m=C.inputTokens,R=C.outputTokens;return l.jsx("div",{className:"modal-bg open",onClick:y,children:l.jsxs("div",{className:"modal",onClick:g=>g.stopPropagation(),children:[l.jsx("button",{className:"modal-close",onClick:y,children:"✕"}),l.jsxs("div",{className:"modal-body",children:[l.jsx("div",{style:{fontSize:11,color:"var(--acc)",fontWeight:700,letterSpacing:".04em",marginBottom:4},children:o.id}),l.jsxs("div",{style:{fontSize:20,fontWeight:800,marginBottom:6},children:[L," ",T]}),l.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:18,flexWrap:"wrap"},children:[l.jsx("span",{className:`tag st-${d}`,children:Pr[d]||d}),l.jsxs("span",{style:{fontSize:11,color:"var(--muted)"},children:[_.icon," ",_.text]}),b.label&&l.jsx("span",{style:{fontSize:11},children:b.label})]}),l.jsxs("div",{style:{display:"flex",gap:14,marginBottom:18,flexWrap:"wrap"},children:[w!=null&&l.jsxs("div",{style:{background:"var(--panel2)",padding:"10px 16px",borderRadius:8,fontSize:12},children:[l.jsx("div",{style:{fontSize:16,fontWeight:700,color:"var(--acc)"},children:w.toLocaleString()}),l.jsx("div",{style:{color:"var(--muted)",fontSize:10},children:"总 Tokens"})]}),m!=null&&l.jsxs("div",{style:{background:"var(--panel2)",padding:"10px 16px",borderRadius:8,fontSize:12},children:[l.jsx("div",{style:{fontSize:16,fontWeight:700},children:m.toLocaleString()}),l.jsx("div",{style:{color:"var(--muted)",fontSize:10},children:"输入"})]}),R!=null&&l.jsxs("div",{style:{background:"var(--panel2)",padding:"10px 16px",borderRadius:8,fontSize:12},children:[l.jsx("div",{style:{fontSize:16,fontWeight:700},children:R.toLocaleString()}),l.jsx("div",{style:{color:"var(--muted)",fontSize:10},children:"输出"})]})]}),l.jsxs("div",{style:{fontSize:12,fontWeight:700,marginBottom:8},children:["📋 最近活动 ",l.jsxs("span",{style:{fontWeight:400,color:"var(--muted)"},children:["(",z.length," 条)"]})]}),l.jsx("div",{style:{maxHeight:350,overflowY:"auto",border:"1px solid var(--line)",borderRadius:10,background:"var(--panel2)"},children:z.length?z.slice(-15).reverse().map((g,A)=>{const P=g.kind||"",W=P==="assistant"?"🤖":P==="tool"?"🔧":P==="user"?"👤":"📝",J=P==="assistant"?"回复":P==="tool"?"工具":P==="user"?"用户":"事件";let I=(g.text||"").replace(/\[\[.*?\]\]/g,"").replace(/\*\*/g,"").trim();I.length>200&&(I=I.substring(0,200)+"…");const oe=(g.at||"").substring(11,19);return l.jsxs("div",{style:{padding:"8px 12px",borderBottom:"1px solid var(--line)",fontSize:12,lineHeight:1.5},children:[l.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:3},children:[l.jsx("span",{children:W}),l.jsx("span",{style:{fontWeight:600,fontSize:11},children:J}),l.jsx("span",{style:{color:"var(--muted)",fontSize:10,marginLeft:"auto"},children:oe})]}),l.jsx("div",{style:{color:"var(--muted)"},children:I})]},A)}):l.jsx("div",{style:{padding:16,color:"var(--muted)",fontSize:12,textAlign:"center"},children:"暂无活动记录"})}),o.output&&o.output!=="-"&&l.jsxs("div",{style:{fontSize:10,color:"var(--muted)",marginTop:12,wordBreak:"break-all",borderTop:"1px solid var(--line)",paddingTop:8},children:["📂 ",o.output]})]})]})})}function op(){const o=ee(C=>C.liveStatus),[f,c]=V.useState("all"),[y,x]=V.useState(null),L=ee(C=>C.toast);let _=((o==null?void 0:o.tasks)||[]).filter(C=>ln(C)&&["Done","Cancelled"].includes(C.state));f!=="all"&&(_=_.filter(C=>C.state===f));const b=C=>{const z=C.flow_log||[];let d=`# 📜 奏折 · ${C.title} + +`;if(d+=`- **任务编号**: ${C.id} +`,d+=`- **状态**: ${C.state} +`,d+=`- **负责部门**: ${C.org} +`,z.length){const w=z[0].at?z[0].at.substring(0,19).replace("T"," "):"未知",m=z[z.length-1].at?z[z.length-1].at.substring(0,19).replace("T"," "):"未知";d+=`- **开始时间**: ${w} +`,d+=`- **完成时间**: ${m} +`}d+=` +## 流转记录 + +`;for(const w of z)d+=`- **${w.from}** → **${w.to}** + ${w.remark} + _${(w.at||"").substring(0,19)}_ + +`;C.output&&C.output!=="-"&&(d+=`## 产出物 + +\`${C.output}\` +`),navigator.clipboard.writeText(d).then(()=>L("✅ 奏折已复制为 Markdown","ok"),()=>L("复制失败","err"))};return l.jsxs("div",{children:[l.jsxs("div",{style:{display:"flex",gap:8,marginBottom:16,alignItems:"center"},children:[l.jsx("span",{style:{fontSize:12,color:"var(--muted)"},children:"筛选:"}),[{key:"all",label:"全部"},{key:"Done",label:"✅ 已完成"},{key:"Cancelled",label:"🚫 已取消"}].map(C=>l.jsx("span",{className:`sess-filter${f===C.key?" active":""}`,onClick:()=>c(C.key),children:C.label},C.key))]}),l.jsx("div",{className:"mem-list",children:_.length?_.map(C=>{const z=C.flow_log||[],d=[...new Set(z.map(g=>g.from).concat(z.map(g=>g.to)).filter(g=>g&&g!=="皇上"))],w=z.length?(z[0].at||"").substring(0,16).replace("T"," "):"",m=z.length?(z[z.length-1].at||"").substring(0,16).replace("T"," "):"",R=C.state==="Done"?"✅":"🚫";return l.jsxs("div",{className:"mem-card",onClick:()=>x(C),children:[l.jsx("div",{className:"mem-icon",children:"📜"}),l.jsxs("div",{className:"mem-info",children:[l.jsxs("div",{className:"mem-title",children:[R," ",C.title||C.id]}),l.jsxs("div",{className:"mem-sub",children:[C.id," · ",C.org||""," · 流转 ",z.length," 步"]}),l.jsx("div",{className:"mem-tags",children:d.slice(0,5).map(g=>l.jsx("span",{className:"mem-tag",children:g},g))})]}),l.jsxs("div",{className:"mem-right",children:[l.jsx("span",{className:"mem-date",children:w}),m!==w&&l.jsx("span",{className:"mem-date",children:m})]})]},C.id)}):l.jsx("div",{className:"mem-empty",children:"暂无奏折 — 任务完成后自动生成"})}),y&&l.jsx(ap,{task:y,onClose:()=>x(null),onExport:b})]})}function ap({task:o,onClose:f,onExport:c}){const y=o.flow_log||[],x=o.state||"Unknown",L=x==="Done"?"✅":x==="Cancelled"?"🚫":"🔄",T=[...new Set(y.map(m=>m.from).concat(y.map(m=>m.to)).filter(m=>m&&m!=="皇上"))],_=[],b=[],C=[],z=[],d=[];for(const m of y)m.from==="皇上"?_.push(m):m.to==="中书省"||m.from==="中书省"?b.push(m):m.to==="门下省"||m.from==="门下省"?C.push(m):m.remark&&(m.remark.includes("完成")||m.remark.includes("回奏"))?d.push(m):z.push(m);const w=(m,R,g)=>g.length?l.jsxs("div",{style:{marginBottom:18},children:[l.jsxs("div",{style:{fontSize:13,fontWeight:700,marginBottom:10},children:[R," ",m]}),l.jsx("div",{className:"md-timeline",children:g.map((A,P)=>{var J,I;const W=(J=A.remark)!=null&&J.includes("✅")?"green":(I=A.remark)!=null&&I.includes("驳")?"red":"";return l.jsxs("div",{className:"md-tl-item",children:[l.jsx("div",{className:`md-tl-dot ${W}`}),l.jsxs("div",{style:{display:"flex",gap:6,alignItems:"baseline"},children:[l.jsx("span",{className:"md-tl-from",children:A.from}),l.jsxs("span",{className:"md-tl-to",children:["→ ",A.to]})]}),l.jsx("div",{className:"md-tl-remark",children:A.remark}),l.jsx("div",{className:"md-tl-time",children:(A.at||"").substring(0,19).replace("T"," ")})]},P)})})]}):null;return l.jsx("div",{className:"modal-bg open",onClick:f,children:l.jsxs("div",{className:"modal",onClick:m=>m.stopPropagation(),children:[l.jsx("button",{className:"modal-close",onClick:f,children:"✕"}),l.jsxs("div",{className:"modal-body",children:[l.jsx("div",{style:{fontSize:11,color:"var(--acc)",fontWeight:700,letterSpacing:".04em",marginBottom:4},children:o.id}),l.jsxs("div",{style:{fontSize:20,fontWeight:800,marginBottom:6},children:[L," ",o.title||o.id]}),l.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:18,flexWrap:"wrap"},children:[l.jsx("span",{className:`tag st-${x}`,children:Pr[x]||x}),l.jsx("span",{style:{fontSize:11,color:"var(--muted)"},children:o.org}),l.jsxs("span",{style:{fontSize:11,color:"var(--muted)"},children:["流转 ",y.length," 步"]}),T.map(m=>l.jsx("span",{className:"mem-tag",children:m},m))]}),o.now&&l.jsx("div",{style:{background:"var(--panel2)",border:"1px solid var(--line)",borderRadius:8,padding:"10px 14px",marginBottom:18,fontSize:12,color:"var(--muted)"},children:o.now}),w("圣旨原文","👑",_),w("中书规划","📋",b),w("门下审议","🔍",C),w("六部执行","⚔️",z),w("汇总回奏","📨",d),o.output&&o.output!=="-"&&l.jsxs("div",{style:{marginTop:12,paddingTop:12,borderTop:"1px solid var(--line)"},children:[l.jsx("div",{style:{fontSize:11,fontWeight:600,marginBottom:4},children:"📦 产出物"}),l.jsx("code",{style:{fontSize:11,wordBreak:"break-all"},children:o.output})]}),l.jsx("div",{style:{display:"flex",gap:8,marginTop:16,justifyContent:"flex-end"},children:l.jsx("button",{className:"btn btn-g",onClick:()=>c(o),style:{fontSize:12,padding:"6px 16px"},children:"📋 复制奏折"})})]})]})})}function cp(){const o=ee(g=>g.tplCatFilter),f=ee(g=>g.setTplCatFilter),c=ee(g=>g.toast),y=ee(g=>g.loadAll),[x,L]=V.useState(null),[T,_]=V.useState({}),[b,C]=V.useState("");let z=Ff;o!=="全部"&&(z=z.filter(g=>g.cat===o));const d=g=>{const A={};g.params.forEach(P=>{A[P.key]=P.default||""}),_(A),L(g),C("")},w=g=>{let A=g.command;for(const P of g.params)A=A.replace(new RegExp("\\{"+P.key+"\\}","g"),T[P.key]||P.default||"");return A},m=()=>{x&&C(w(x))},R=async g=>{if(g.preventDefault(),!x)return;const A=w(x);if(!A.trim()){c("请填写必填参数","err");return}try{const P=await fe.agentsStatus();if(P.ok&&P.gateway&&!P.gateway.alive&&(c("⚠️ Gateway 未启动,任务将无法派发!","err"),!confirm("Gateway 未启动,继续?")))return}catch{}if(confirm(`确认下旨? + +${A.substring(0,200)}${A.length>200?"…":""}`))try{const P={};for(const J of x.params)P[J.key]=T[J.key]||J.default||"";const W=await fe.createTask({title:A.substring(0,120),org:"中书省",targetDept:x.depts[0]||"",priority:"normal",templateId:x.id,params:P});W.ok?(c(`📜 ${W.taskId} 旨意已下达`,"ok"),L(null),y()):c(W.error||"下旨失败","err")}catch{c("⚠️ 服务器连接失败","err")}};return l.jsxs("div",{children:[l.jsx("div",{style:{display:"flex",gap:6,marginBottom:16,flexWrap:"wrap"},children:Bf.map(g=>l.jsxs("span",{className:`tpl-cat${o===g.name?" active":""}`,onClick:()=>f(g.name),children:[g.icon," ",g.name]},g.name))}),l.jsx("div",{className:"tpl-grid",children:z.map(g=>l.jsxs("div",{className:"tpl-card",children:[l.jsxs("div",{className:"tpl-top",children:[l.jsx("span",{className:"tpl-icon",children:g.icon}),l.jsx("span",{className:"tpl-name",children:g.name})]}),l.jsx("div",{className:"tpl-desc",children:g.desc}),l.jsxs("div",{className:"tpl-footer",children:[g.depts.map(A=>l.jsx("span",{className:"tpl-dept",children:A},A)),l.jsxs("span",{className:"tpl-est",children:[g.est," · ",g.cost]}),l.jsx("button",{className:"tpl-go",onClick:()=>d(g),children:"下旨"})]})]},g.id))}),x&&l.jsx("div",{className:"modal-bg open",onClick:()=>L(null),children:l.jsxs("div",{className:"modal",onClick:g=>g.stopPropagation(),children:[l.jsx("button",{className:"modal-close",onClick:()=>L(null),children:"✕"}),l.jsxs("div",{className:"modal-body",children:[l.jsx("div",{style:{fontSize:11,color:"var(--acc)",fontWeight:700,letterSpacing:".04em",marginBottom:4},children:"圣旨模板"}),l.jsxs("div",{style:{fontSize:20,fontWeight:800,marginBottom:6},children:[x.icon," ",x.name]}),l.jsx("div",{style:{fontSize:12,color:"var(--muted)",marginBottom:18},children:x.desc}),l.jsxs("div",{style:{display:"flex",gap:6,marginBottom:18,flexWrap:"wrap"},children:[x.depts.map(g=>l.jsx("span",{className:"tpl-dept",children:g},g)),l.jsxs("span",{style:{fontSize:11,color:"var(--muted)",marginLeft:"auto"},children:[x.est," · ",x.cost]})]}),l.jsxs("form",{className:"tpl-form",onSubmit:R,children:[x.params.map(g=>l.jsxs("div",{className:"tpl-field",children:[l.jsxs("label",{className:"tpl-label",children:[g.label,g.required&&l.jsx("span",{style:{color:"#ff5270"},children:" *"})]}),g.type==="textarea"?l.jsx("textarea",{className:"tpl-input",style:{minHeight:80,resize:"vertical"},required:g.required,value:T[g.key]||"",onChange:A=>_(P=>({...P,[g.key]:A.target.value}))}):g.type==="select"?l.jsx("select",{className:"tpl-input",value:T[g.key]||g.default||"",onChange:A=>_(P=>({...P,[g.key]:A.target.value})),children:(g.options||[]).map(A=>l.jsx("option",{children:A},A))}):l.jsx("input",{className:"tpl-input",type:"text",required:g.required,value:T[g.key]||"",onChange:A=>_(P=>({...P,[g.key]:A.target.value}))})]},g.key)),b&&l.jsxs("div",{style:{background:"var(--panel2)",border:"1px solid var(--line)",borderRadius:8,padding:12,marginBottom:14,fontSize:12,color:"var(--muted)"},children:[l.jsx("div",{style:{fontSize:11,fontWeight:600,color:"var(--text)",marginBottom:6},children:"📜 将发送给中书省的旨意:"}),l.jsx("div",{style:{whiteSpace:"pre-wrap",lineHeight:1.6},children:b})]}),l.jsxs("div",{style:{display:"flex",gap:10,justifyContent:"flex-end"},children:[l.jsx("button",{type:"button",className:"btn btn-g",onClick:m,style:{padding:"8px 16px",fontSize:12},children:"👁 预览旨意"}),l.jsx("button",{type:"submit",className:"tpl-go",style:{padding:"8px 20px",fontSize:13},children:"📜 下旨"})]})]})]})]})})]})}const hu={政治:{icon:"🏛️",color:"#6a9eff",desc:"全球政治动态"},军事:{icon:"⚔️",color:"#ff5270",desc:"军事与冲突"},经济:{icon:"💹",color:"#2ecc8a",desc:"经济与市场"},AI大模型:{icon:"🤖",color:"#a07aff",desc:"AI与大模型进展"}},Gi=["政治","军事","经济","AI大模型"];function up(){const o=ee(X=>X.morningBrief),f=ee(X=>X.subConfig),c=ee(X=>X.loadMorning),y=ee(X=>X.loadSubConfig),x=ee(X=>X.toast),[L,T]=V.useState(!1),[_,b]=V.useState(null),[C,z]=V.useState(!1),[d,w]=V.useState("⟳ 立即采集"),m=V.useRef(null);V.useEffect(()=>{c()},[c]),V.useEffect(()=>{f&&b(JSON.parse(JSON.stringify(f)))},[f]),V.useEffect(()=>()=>{m.current&&clearInterval(m.current)},[]);const R=async()=>{z(!0),w("⟳ 采集中…");let X=null;try{X=(o==null?void 0:o.generated_at)||null}catch{}try{await fe.refreshMorning(),x("采集已触发,自动检测更新中…","ok");let ie=0;m.current&&clearInterval(m.current),m.current=setInterval(async()=>{if(ie++,ie>24){clearInterval(m.current),m.current=null,z(!1),w("⟳ 立即采集"),x("采集超时,请重试","err");return}try{const ke=await fe.morningBrief();ke.generated_at&&ke.generated_at!==X?(clearInterval(m.current),m.current=null,z(!1),w("⟳ 立即采集"),c(),x("✅ 天下要闻已更新","ok")):w(`⟳ 采集中… (${ie*5}s)`)}catch{}},5e3)}catch{x("触发失败","err"),z(!1),w("⟳ 立即采集")}},g=X=>{if(!_)return;const ie=[..._.categories||[]],ke=ie.find(re=>re.name===X);ke?ke.enabled=!ke.enabled:ie.push({name:X,enabled:!0}),b({..._,categories:ie})},A=X=>{if(!_||!X)return;const ie=[..._.keywords||[]];ie.includes(X)||ie.push(X),b({..._,keywords:ie})},P=X=>{if(!_)return;const ie=[..._.keywords||[]];ie.splice(X,1),b({..._,keywords:ie})},W=(X,ie,ke)=>{if(!_||!X||!ie){x("请填写源名称和URL","err");return}const re=[..._.custom_feeds||[]];re.push({name:X,url:ie,category:ke}),b({..._,custom_feeds:re})},J=X=>{if(!_)return;const ie=[..._.custom_feeds||[]];ie.splice(X,1),b({..._,custom_feeds:ie})},I=async()=>{if(_)try{const X=await fe.saveMorningConfig(_);X.ok?(x("订阅配置已保存","ok"),y()):x(X.error||"保存失败","err")}catch{x("服务器连接失败","err")}},oe=_?new Set((_.categories||[]).filter(X=>X.enabled).map(X=>X.name)):new Set(Gi),ue=((_==null?void 0:_.keywords)||[]).map(X=>X.toLowerCase()),me=(o==null?void 0:o.categories)||{},pe=o!=null&&o.date?o.date.replace(/(\d{4})(\d{2})(\d{2})/,"$1年$2月$3日"):"",Ae=Object.values(me).flat().length;return l.jsxs("div",{children:[l.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:16},children:[l.jsxs("div",{children:[l.jsx("div",{style:{fontSize:20,fontWeight:800,marginBottom:4},children:"🌅 天下要闻"}),l.jsxs("div",{style:{fontSize:12,color:"var(--muted)"},children:[pe&&`${pe} | `,(o==null?void 0:o.generated_at)&&`采集于 ${o.generated_at} | `,"共 ",Ae," 条要闻"]})]}),l.jsxs("div",{style:{display:"flex",gap:8},children:[l.jsx("button",{className:"btn btn-g",onClick:()=>T(!L),style:{fontSize:12,padding:"6px 14px"},children:"⚙ 订阅配置"}),l.jsx("button",{className:"tpl-go",disabled:C,onClick:R,style:{fontSize:12,padding:"6px 14px"},children:d})]})]}),L&&_&&l.jsx(dp,{config:_,enabledSet:oe,onToggleCat:g,onAddKeyword:A,onRemoveKeyword:P,onAddFeed:W,onRemoveFeed:J,onSave:I,onSetWebhook:X=>b({..._,feishu_webhook:X})}),Object.keys(me).length?l.jsx("div",{className:"mb-cats",children:Object.entries(me).map(([X,ie])=>{if(!oe.has(X))return null;const ke=hu[X]||{icon:"📰",color:"var(--acc)"},re=ie.map(te=>{const Ne=((te.title||"")+(te.summary||"")).toLowerCase(),Ee=ue.filter(je=>Ne.includes(je)).length;return{...te,_kwHits:Ee}}).sort((te,Ne)=>Ne._kwHits-te._kwHits);return l.jsxs("div",{className:"mb-cat",children:[l.jsxs("div",{className:"mb-cat-hdr",children:[l.jsx("span",{className:"mb-cat-icon",children:ke.icon}),l.jsx("span",{className:"mb-cat-name",style:{color:ke.color},children:X}),l.jsxs("span",{className:"mb-cat-cnt",children:[re.length," 条"]})]}),l.jsx("div",{className:"mb-news-list",children:re.length?re.map((te,Ne)=>{const Ee=!!(te.image&&te.image.startsWith("http"));return l.jsxs("div",{className:"mb-card",onClick:()=>window.open(te.link,"_blank"),children:[l.jsx("div",{className:"mb-img",children:Ee?l.jsx("img",{src:te.image,onError:je=>{je.target.style.display="none"},loading:"lazy",alt:""}):l.jsx("span",{children:ke.icon})}),l.jsxs("div",{className:"mb-info",children:[l.jsxs("div",{className:"mb-headline",children:[te.title,te._kwHits>0&&l.jsx("span",{style:{fontSize:9,padding:"1px 5px",borderRadius:999,background:"#a07aff22",color:"#a07aff",border:"1px solid #a07aff44",marginLeft:4},children:"⭐ 关注"})]}),l.jsx("div",{className:"mb-summary",children:te.summary||te.desc||""}),l.jsxs("div",{className:"mb-meta",children:[l.jsxs("span",{className:"mb-source",children:["📡 ",te.source||""]}),te.pub_date&&l.jsx("span",{className:"mb-time",children:te.pub_date.substring(0,16)})]})]})]},Ne)}):l.jsx("div",{className:"mb-empty",style:{padding:16},children:"暂无新闻"})})]},X)})}):l.jsx("div",{className:"mb-empty",children:"暂无数据,点击右上角「立即采集」获取今日简报"})]})}function dp({config:o,enabledSet:f,onToggleCat:c,onAddKeyword:y,onRemoveKeyword:x,onAddFeed:L,onRemoveFeed:T,onSave:_,onSetWebhook:b}){const[C,z]=V.useState(""),[d,w]=V.useState(""),[m,R]=V.useState(""),[g,A]=V.useState(Gi[0]),P=[...Gi];return(o.categories||[]).forEach(W=>{P.includes(W.name)||P.push(W.name)}),l.jsxs("div",{className:"sub-config",style:{marginBottom:20,padding:16,background:"var(--panel2)",borderRadius:12,border:"1px solid var(--line)"},children:[l.jsx("div",{style:{fontSize:14,fontWeight:700,marginBottom:12},children:"⚙ 订阅配置"}),l.jsxs("div",{style:{marginBottom:14},children:[l.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:8},children:"订阅分类"}),l.jsx("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:P.map(W=>{const J=hu[W]||{icon:"📰"},I=f.has(W);return l.jsxs("div",{className:`sub-cat ${I?"active":""}`,onClick:()=>c(W),style:{cursor:"pointer",padding:"6px 12px",borderRadius:8,border:`1px solid ${I?"var(--acc)":"var(--line)"}`,display:"flex",alignItems:"center",gap:6},children:[l.jsx("span",{children:J.icon}),l.jsx("span",{style:{fontSize:12},children:W}),I&&l.jsx("span",{style:{fontSize:10,color:"var(--ok)"},children:"✓"})]},W)})})]}),l.jsxs("div",{style:{marginBottom:14},children:[l.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:8},children:"关注关键词"}),l.jsx("div",{style:{display:"flex",gap:6,flexWrap:"wrap",marginBottom:6},children:(o.keywords||[]).map((W,J)=>l.jsxs("span",{className:"sub-kw",style:{fontSize:11,padding:"2px 8px",borderRadius:4,background:"var(--bg)",border:"1px solid var(--line)"},children:[W,l.jsx("span",{style:{cursor:"pointer",marginLeft:4,color:"var(--danger)"},onClick:()=>x(J),children:"✕"})]},J))}),l.jsxs("div",{style:{display:"flex",gap:6},children:[l.jsx("input",{type:"text",value:C,onChange:W=>z(W.target.value),placeholder:"输入关键词",onKeyDown:W=>{W.key==="Enter"&&(y(C.trim()),z(""))},style:{flex:1,padding:"6px 10px",background:"var(--bg)",border:"1px solid var(--line)",borderRadius:6,color:"var(--text)",fontSize:12,outline:"none"}}),l.jsx("button",{className:"btn btn-g",onClick:()=>{y(C.trim()),z("")},style:{fontSize:11,padding:"4px 12px"},children:"添加"})]})]}),l.jsxs("div",{style:{marginBottom:14},children:[l.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:8},children:"自定义信息源"}),(o.custom_feeds||[]).map((W,J)=>l.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center",marginBottom:4,fontSize:11},children:[l.jsx("span",{style:{fontWeight:600},children:W.name}),l.jsx("span",{style:{color:"var(--muted)",flex:1,overflow:"hidden",textOverflow:"ellipsis"},children:W.url}),l.jsx("span",{style:{color:"var(--acc)"},children:W.category}),l.jsx("span",{style:{cursor:"pointer",color:"var(--danger)"},onClick:()=>T(J),children:"✕"})]},J)),l.jsxs("div",{style:{display:"flex",gap:6,marginTop:6},children:[l.jsx("input",{placeholder:"源名称",value:d,onChange:W=>w(W.target.value),style:{width:100,padding:"6px 8px",background:"var(--bg)",border:"1px solid var(--line)",borderRadius:6,color:"var(--text)",fontSize:11,outline:"none"}}),l.jsx("input",{placeholder:"RSS / URL",value:m,onChange:W=>R(W.target.value),style:{flex:1,padding:"6px 8px",background:"var(--bg)",border:"1px solid var(--line)",borderRadius:6,color:"var(--text)",fontSize:11,outline:"none"}}),l.jsx("select",{value:g,onChange:W=>A(W.target.value),style:{padding:"6px 8px",background:"var(--bg)",border:"1px solid var(--line)",borderRadius:6,color:"var(--text)",fontSize:11,outline:"none"},children:P.map(W=>l.jsx("option",{value:W,children:W},W))}),l.jsx("button",{className:"btn btn-g",onClick:()=>{L(d,m,g),w(""),R("")},style:{fontSize:11,padding:"4px 12px"},children:"添加"})]})]}),l.jsxs("div",{style:{marginBottom:14},children:[l.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:6},children:"飞书 Webhook"}),l.jsx("input",{type:"text",value:o.feishu_webhook||"",onChange:W=>b(W.target.value),placeholder:"https://open.feishu.cn/open-apis/bot/v2/hook/...",style:{width:"100%",padding:"8px 10px",background:"var(--bg)",border:"1px solid var(--line)",borderRadius:6,color:"var(--text)",fontSize:12,outline:"none"}})]}),l.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:l.jsx("button",{className:"tpl-go",onClick:_,style:{fontSize:12,padding:"6px 16px"},children:"💾 保存配置"})})]})}const vu={main:"太子",zhongshu:"中书省",menxia:"门下省",shangshu:"尚书省",libu:"礼部",hubu:"户部",bingbu:"兵部",xingbu:"刑部",gongbu:"工部",libu_hr:"吏部",zaochao:"钦天监"},fp={Taizi:"中书省起草",Zhongshu:"门下省审议",Menxia:"尚书省派发",Assigned:"开始执行",Doing:"进入审查",Review:"完成"};function pp(o){const f=Math.max(0,o);if(f<60)return`${f}秒`;if(f<3600)return`${Math.floor(f/60)}分${f%60}秒`;const c=Math.floor(f/3600),y=Math.floor(f%3600/60);return`${c}小时${y}分`}function Yi(o){if(!o)return"";if(typeof o=="number"){const f=new Date(o);return`${String(f.getHours()).padStart(2,"0")}:${String(f.getMinutes()).padStart(2,"0")}:${String(f.getSeconds()).padStart(2,"0")}`}return typeof o=="string"&&o.length>=19?o.substring(11,19):String(o).substring(0,8)}function mp(){var Ee,je;const o=ee(E=>E.modalTaskId),f=ee(E=>E.setModalTaskId),c=ee(E=>E.liveStatus),y=ee(E=>E.loadAll),x=ee(E=>E.toast),[L,T]=V.useState(null),[_,b]=V.useState(null),C=V.useRef(null),z=V.useRef(null),d=((Ee=c==null?void 0:c.tasks)==null?void 0:Ee.find(E=>E.id===o))||null,w=V.useCallback(async()=>{if(o)try{const E=await fe.taskActivity(o);T(E)}catch{T(null)}},[o]),m=V.useCallback(async()=>{if(o)try{const E=await fe.schedulerState(o);b(E)}catch{b(null)}},[o]);if(V.useEffect(()=>!o||!d?void 0:(w(),m(),["Done","Cancelled"].includes(d.state)||(C.current=setInterval(()=>{w(),m()},4e3)),()=>{C.current&&(clearInterval(C.current),C.current=null)}),[o,d==null?void 0:d.state,w,m]),V.useEffect(()=>{z.current&&(z.current.scrollTop=z.current.scrollHeight)},[(je=L==null?void 0:L.activity)==null?void 0:je.length]),!o||!d)return null;const R=()=>f(null),g=qi(d),A=g.find(E=>E.status==="active"),P=d.heartbeat||{status:"unknown",label:"⚪ 无数据"},W=d.flow_log||[],J=d.todos||[],I=J.filter(E=>E.status==="completed").length,oe=J.length,ue=!["Done","Blocked","Cancelled"].includes(d.state),me=["Blocked","Cancelled"].includes(d.state),pe=async(E,K)=>{try{const U=await fe.taskAction(d.id,E,K);U.ok?(x(U.message||"操作成功","ok"),y(),R()):x(U.error||"操作失败","err")}catch{x("服务器连接失败","err")}},Ae=async E=>{const K={approve:"准奏",reject:"封驳"},U=prompt(`${K[E]} ${d.id} + +请输入批注(可留空):`);if(U!==null)try{const v=await fe.reviewAction(d.id,E,U||"");v.ok?(x(`✅ ${d.id} 已${K[E]}`,"ok"),y(),R()):x(v.error||"操作失败","err")}catch{x("服务器连接失败","err")}},X=async()=>{const E=fp[d.state]||"下一步",K=prompt(`⏩ 手动推进 ${d.id} +当前: ${d.state} → 下一步: ${E} + +请输入说明(可留空):`);if(K!==null)try{const U=await fe.advanceState(d.id,K||"");U.ok?(x(`⏩ ${U.message}`,"ok"),y(),R()):x(U.error||"推进失败","err")}catch{x("服务器连接失败","err")}},ie=async E=>{if(E==="scan"){try{const D=await fe.schedulerScan(180);D.ok?x(`🔍 扫描完成:${D.count||0} 个动作`,"ok"):x(D.error||"扫描失败","err"),m()}catch{x("服务器连接失败","err")}return}const U=prompt(`请输入${{retry:"重试",escalate:"升级",rollback:"回滚"}[E]}原因(可留空):`);if(U===null)return;const v={retry:fe.schedulerRetry,escalate:fe.schedulerEscalate,rollback:fe.schedulerRollback};try{const D=await v[E](d.id,U);D.ok?x(D.message||"操作成功","ok"):x(D.error||"操作失败","err"),m(),y()}catch{x("服务器连接失败","err")}},ke=()=>{const E=prompt("请输入叫停原因(可留空):");E!==null&&pe("stop",E)},re=()=>{if(!confirm(`确定要取消 ${d.id} 吗?`))return;const E=prompt("请输入取消原因(可留空):");E!==null&&pe("cancel",E)},te=_==null?void 0:_.scheduler,Ne=(_==null?void 0:_.stalledSec)||0;return l.jsx("div",{className:"modal-bg open",onClick:R,children:l.jsxs("div",{className:"modal",onClick:E=>E.stopPropagation(),children:[l.jsx("button",{className:"modal-close",onClick:R,children:"✕"}),l.jsxs("div",{className:"modal-body",children:[l.jsx("div",{className:"modal-id",children:d.id}),l.jsx("div",{className:"modal-title",children:d.title||"(无标题)"}),A&&l.jsxs("div",{className:"cur-stage",children:[l.jsx("div",{className:"cs-icon",children:A.icon}),l.jsxs("div",{className:"cs-info",children:[l.jsx("div",{className:"cs-dept",style:{color:Ul(A.dept)},children:A.dept}),l.jsxs("div",{className:"cs-action",children:["当前阶段:",A.action]})]}),l.jsx("span",{className:`hb ${P.status} cs-hb`,children:P.label})]}),l.jsx("div",{className:"m-pipe",children:g.map((E,K)=>l.jsxs("div",{className:"mp-stage",children:[l.jsxs("div",{className:`mp-node ${E.status}`,children:[E.status==="done"&&l.jsx("div",{className:"mp-done-tick",children:"✓"}),l.jsx("div",{className:"mp-icon",children:E.icon}),l.jsx("div",{className:"mp-dept",style:E.status==="active"?{color:"var(--acc)"}:E.status==="done"?{color:"var(--ok)"}:{},children:E.dept}),l.jsx("div",{className:"mp-action",children:E.action})]}),Kpe("resume","恢复执行"),children:"▶️ 恢复执行"}),["Review","Menxia"].includes(d.state)&&l.jsxs(l.Fragment,{children:[l.jsx("button",{className:"btn-action",style:{background:"#2ecc8a22",color:"#2ecc8a",border:"1px solid #2ecc8a44"},onClick:()=>Ae("approve"),children:"✅ 准奏"}),l.jsx("button",{className:"btn-action",style:{background:"#ff527022",color:"#ff5270",border:"1px solid #ff527044"},onClick:()=>Ae("reject"),children:"🚫 封驳"})]}),["Pending","Taizi","Zhongshu","Menxia","Assigned","Doing","Review","Next"].includes(d.state)&&l.jsx("button",{className:"btn-action",style:{background:"#7c5cfc18",color:"#7c5cfc",border:"1px solid #7c5cfc44"},onClick:X,children:"⏩ 推进到下一步"})]}),l.jsxs("div",{className:"sched-section",children:[l.jsxs("div",{className:"sched-head",children:[l.jsx("span",{className:"sched-title",children:"🧭 太子调度"}),l.jsx("span",{className:"sched-status",children:te?`${te.enabled===!1?"已禁用":"运行中"} · 阈值 ${te.stallThresholdSec||180}s`:"加载中..."})]}),l.jsxs("div",{className:"sched-grid",children:[l.jsxs("div",{className:"sched-kpi",children:[l.jsx("div",{className:"k",children:"停滞时长"}),l.jsx("div",{className:"v",children:pp(Ne)})]}),l.jsxs("div",{className:"sched-kpi",children:[l.jsx("div",{className:"k",children:"重试次数"}),l.jsx("div",{className:"v",children:(te==null?void 0:te.retryCount)||0})]}),l.jsxs("div",{className:"sched-kpi",children:[l.jsx("div",{className:"k",children:"升级级别"}),l.jsx("div",{className:"v",children:te!=null&&te.escalationLevel?te.escalationLevel===1?"门下省":"尚书省":"无"})]}),l.jsxs("div",{className:"sched-kpi",children:[l.jsx("div",{className:"k",children:"派发状态"}),l.jsx("div",{className:"v",children:(te==null?void 0:te.lastDispatchStatus)||"idle"})]})]}),te&&l.jsxs("div",{className:"sched-line",children:[te.lastProgressAt&&l.jsxs("span",{children:["最近进展 ",(te.lastProgressAt||"").replace("T"," ").substring(0,19)]}),te.lastDispatchAt&&l.jsxs("span",{children:["最近派发 ",(te.lastDispatchAt||"").replace("T"," ").substring(0,19)]}),l.jsxs("span",{children:["自动回滚 ",te.autoRollback===!1?"关闭":"开启"]}),te.lastDispatchAgent&&l.jsxs("span",{children:["目标 ",te.lastDispatchAgent]})]}),l.jsxs("div",{className:"sched-actions",children:[l.jsx("button",{className:"sched-btn",onClick:()=>ie("retry"),children:"🔁 重试派发"}),l.jsx("button",{className:"sched-btn warn",onClick:()=>ie("escalate"),children:"📣 升级协调"}),l.jsx("button",{className:"sched-btn danger",onClick:()=>ie("rollback"),children:"↩️ 回滚稳定点"}),l.jsx("button",{className:"sched-btn",onClick:()=>ie("scan"),children:"🔍 立即扫描"})]})]}),oe>0&&l.jsx(hp,{todos:J,todoDone:I,todoTotal:oe}),l.jsx("div",{className:"m-section",children:l.jsxs("div",{className:"m-rows",children:[l.jsxs("div",{className:"m-row",children:[l.jsx("div",{className:"mr-label",children:"状态"}),l.jsxs("div",{className:"mr-val",children:[l.jsx("span",{className:`tag st-${d.state}`,children:Ji(d)}),(d.review_round||0)>0&&l.jsxs("span",{style:{fontSize:11,color:"var(--muted)",marginLeft:8},children:["共磋商 ",d.review_round," 轮"]})]})]}),l.jsxs("div",{className:"m-row",children:[l.jsx("div",{className:"mr-label",children:"执行部门"}),l.jsx("div",{className:"mr-val",children:l.jsx("span",{className:`tag dt-${(d.org||"").replace(/\s/g,"")}`,children:d.org||"—"})})]}),d.eta&&d.eta!=="-"&&l.jsxs("div",{className:"m-row",children:[l.jsx("div",{className:"mr-label",children:"预计完成"}),l.jsx("div",{className:"mr-val",children:d.eta})]}),d.block&&d.block!=="无"&&d.block!=="-"&&l.jsxs("div",{className:"m-row",children:[l.jsx("div",{className:"mr-label",style:{color:"var(--danger)"},children:"阻塞项"}),l.jsx("div",{className:"mr-val",style:{color:"var(--danger)"},children:d.block})]}),d.now&&d.now!=="-"&&l.jsxs("div",{className:"m-row",style:{gridColumn:"1/-1"},children:[l.jsx("div",{className:"mr-label",children:"当前进展"}),l.jsx("div",{className:"mr-val",style:{fontWeight:400,fontSize:12},children:d.now})]}),d.ac&&l.jsxs("div",{className:"m-row",style:{gridColumn:"1/-1"},children:[l.jsx("div",{className:"mr-label",children:"验收标准"}),l.jsx("div",{className:"mr-val",style:{fontWeight:400,fontSize:12},children:d.ac})]})]})}),W.length>0&&l.jsxs("div",{className:"m-section",children:[l.jsxs("div",{className:"m-sec-label",children:["流转日志(",W.length," 条)"]}),l.jsx("div",{className:"fl-timeline",children:W.map((E,K)=>{const U=Ul(E.from||"");return l.jsxs("div",{className:"fl-item",children:[l.jsx("div",{className:"fl-time",children:E.at?E.at.substring(11,16):""}),l.jsx("div",{className:"fl-dot",style:{background:U}}),l.jsxs("div",{className:"fl-content",children:[l.jsxs("div",{className:"fl-who",children:[l.jsx("span",{className:"from",style:{color:U},children:E.from}),l.jsx("span",{style:{color:"var(--muted)"},children:" → "}),l.jsx("span",{className:"to",style:{color:Ul(E.to||"")},children:E.to})]}),l.jsx("div",{className:"fl-rem",children:E.remark})]})]},K)})})]}),d.output&&d.output!=="-"&&d.output!==""&&l.jsxs("div",{className:"m-section",children:[l.jsx("div",{className:"m-sec-label",children:"产出物"}),l.jsx("code",{children:d.output})]}),l.jsx(vp,{data:L,isDone:["Done","Cancelled"].includes(d.state),logRef:z})]})]})})}function hp({todos:o,todoDone:f,todoTotal:c}){return l.jsxs("div",{className:"todo-section",children:[l.jsxs("div",{className:"todo-header",children:[l.jsxs("div",{className:"m-sec-label",style:{marginBottom:0,border:"none",padding:0},children:["子任务清单(",f,"/",c,")"]}),l.jsxs("div",{className:"todo-progress",children:[l.jsx("div",{className:"todo-bar",children:l.jsx("div",{className:"todo-bar-fill",style:{width:`${Math.round(f/c*100)}%`}})}),l.jsxs("span",{children:[Math.round(f/c*100),"%"]})]})]}),l.jsx("div",{className:"todo-list",children:o.map(y=>{const x=y.status==="completed"?"✅":y.status==="in-progress"?"🔄":"⬜",L=y.status==="completed"?"已完成":y.status==="in-progress"?"进行中":"待开始",T=y.status==="completed"?"s-done":y.status==="in-progress"?"s-progress":"s-notstarted",_=y.status==="completed"?"done":"";return l.jsxs("div",{className:`todo-item ${_}`,children:[l.jsxs("div",{className:"t-row",children:[l.jsx("span",{className:"t-icon",children:x}),l.jsxs("span",{className:"t-id",children:["#",y.id]}),l.jsx("span",{className:"t-title",children:y.title}),l.jsx("span",{className:`t-status ${T}`,children:L})]}),y.detail&&l.jsx("div",{className:"todo-detail",children:y.detail})]},y.id)})})]})}function vp({data:o,isDone:f,logRef:c}){if(!o)return null;const y=o.activity||[],x=(()=>{if(!y.length)return!1;const R=y[y.length-1];if(!R.at)return!1;const g=typeof R.at=="number"?R.at:new Date(R.at).getTime();return Date.now()-g<3e5})(),L=[];o.agentLabel&&L.push(o.agentLabel),o.relatedAgents&&o.relatedAgents.length>1&&L.push(`${o.relatedAgents.length}个 Agent`),o.lastActive&&L.push(`最后活跃: ${o.lastActive}`);const T=o.phaseDurations||[],_=Math.max(...T.map(R=>R.durationSec||1),1),b={皇上:"#eab308",太子:"#f97316",中书省:"#3b82f6",门下省:"#8b5cf6",尚书省:"#10b981",六部:"#06b6d4",礼部:"#ec4899",户部:"#f59e0b",兵部:"#ef4444",刑部:"#6366f1",工部:"#14b8a6",吏部:"#d946ef"},C=o.todosSummary,z=o.resourceSummary,d=y.filter(R=>R.kind==="flow"),w=y.filter(R=>R.kind!=="flow"),m=new Map;return w.forEach(R=>{const g=R.agent||"unknown";m.has(g)||m.set(g,[]),m.get(g).push(R)}),l.jsxs("div",{className:"la-section",children:[l.jsxs("div",{className:"la-header",children:[l.jsxs("span",{className:"la-title",children:[l.jsx("span",{className:`la-dot${x?"":" idle"}`}),f?"执行回顾":"实时动态"]}),l.jsx("span",{className:"la-agent",children:L.join(" · ")||"加载中..."})]}),T.length>0&&l.jsxs("div",{style:{padding:"4px 0 8px",borderBottom:"1px solid var(--line)"},children:[l.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:6},children:[l.jsx("span",{style:{fontSize:11,fontWeight:600},children:"⏱ 阶段耗时"}),o.totalDuration&&l.jsxs("span",{style:{marginLeft:"auto",fontSize:10,color:"var(--muted)"},children:["总耗时 ",o.totalDuration]})]}),T.map((R,g)=>{const A=Math.max(5,Math.round((R.durationSec||1)/_*100)),P=b[R.phase]||"#6b7280";return l.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,margin:"2px 0",fontSize:11},children:[l.jsx("span",{style:{minWidth:48,color:"var(--muted)",textAlign:"right"},children:R.phase}),l.jsx("div",{style:{flex:1,height:14,background:"var(--panel)",borderRadius:3,overflow:"hidden"},children:l.jsx("div",{style:{width:`${A}%`,height:"100%",background:P,borderRadius:3,opacity:R.ongoing?.6:.85}})}),l.jsxs("span",{style:{minWidth:60,fontSize:10,color:"var(--muted)"},children:[R.durationText,R.ongoing&&l.jsx("span",{style:{fontSize:9,color:"#60a5fa"},children:" ●进行中"})]})]},g)})]}),C&&l.jsxs("div",{style:{padding:"4px 0 8px",borderBottom:"1px solid var(--line)"},children:[l.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:4},children:[l.jsx("span",{style:{fontSize:11,fontWeight:600},children:"📊 执行进度"}),l.jsxs("span",{style:{fontSize:20,fontWeight:700,color:C.percent>=100?"#22c55e":C.percent>=50?"#60a5fa":"var(--text)"},children:[C.percent,"%"]}),l.jsxs("span",{style:{fontSize:10,color:"var(--muted)"},children:["✅",C.completed," 🔄",C.inProgress," ⬜",C.notStarted," / 共",C.total,"项"]})]}),l.jsxs("div",{style:{height:8,background:"var(--panel)",borderRadius:4,overflow:"hidden",display:"flex"},children:[l.jsx("div",{style:{width:`${C.total?C.completed/C.total*100:0}%`,background:"#22c55e",transition:"width .3s"}}),l.jsx("div",{style:{width:`${C.total?C.inProgress/C.total*100:0}%`,background:"#3b82f6",transition:"width .3s"}})]})]}),z&&(z.totalTokens||z.totalCost)&&l.jsxs("div",{style:{padding:"4px 0 8px",borderBottom:"1px solid var(--line)",display:"flex",gap:12,alignItems:"center"},children:[l.jsx("span",{style:{fontSize:11,fontWeight:600},children:"📈 资源消耗"}),z.totalTokens!=null&&l.jsxs("span",{style:{fontSize:11,color:"var(--muted)"},children:["🔢 ",z.totalTokens.toLocaleString()," tokens"]}),z.totalCost!=null&&l.jsxs("span",{style:{fontSize:11,color:"var(--muted)"},children:["💰 $",z.totalCost.toFixed(4)]}),z.totalElapsedSec!=null&&l.jsxs("span",{style:{fontSize:11,color:"var(--muted)"},children:["⏳ ",z.totalElapsedSec>=60?`${Math.floor(z.totalElapsedSec/60)}分`:"",z.totalElapsedSec%60,"秒"]})]}),l.jsxs("div",{className:"la-log",ref:c,children:[d.length>0&&l.jsx("div",{className:"la-flow-wrap",children:d.map((R,g)=>l.jsxs("div",{className:"la-entry la-tool",children:[l.jsx("span",{className:"la-icon",children:"📋"}),l.jsxs("span",{className:"la-body",children:[l.jsx("b",{children:R.from})," → ",l.jsx("b",{children:R.to})," ",R.remark||""]}),l.jsx("span",{className:"la-time",children:Yi(R.at)})]},`flow-${g}`))}),m.size>0?l.jsx("div",{className:"la-groups",children:Array.from(m.entries()).map(([R,g])=>{const A=vu[R]||R||"未标识",P=g[g.length-1],W=P!=null&&P.at?Yi(P.at):"--:--:--";return l.jsxs("div",{className:"la-group",children:[l.jsxs("div",{className:"la-group-hd",children:[l.jsx("span",{className:"name",children:A}),l.jsxs("span",{children:["最近更新 ",W]})]}),l.jsx("div",{className:"la-group-bd",children:g.map((J,I)=>l.jsx(gp,{entry:J},I))})]},R)})}):!d.length&&l.jsx("div",{className:"la-empty",children:o.message||o.error||"Agent 尚未上报进展(等待 Agent 调用 progress 命令)"})]})]})}function gp({entry:o}){var y,x,L;const f=Yi(o.at),c=o.agent?l.jsx("span",{style:{fontSize:9,color:"var(--muted)",background:"var(--panel)",padding:"1px 4px",borderRadius:3,marginRight:4},children:vu[o.agent]||o.agent}):null;if(o.kind==="progress")return l.jsxs("div",{className:"la-entry la-assistant",children:[l.jsx("span",{className:"la-icon",children:"🔄"}),l.jsxs("span",{className:"la-body",children:[c,l.jsx("b",{children:"当前进展:"}),o.text]}),l.jsx("span",{className:"la-time",children:f})]});if(o.kind==="todos"){const T=o.items||[],_=new Map;return o.diff&&((o.diff.changed||[]).forEach(b=>_.set(b.id,{type:"changed",from:b.from,to:b.to})),(o.diff.added||[]).forEach(b=>_.set(b.id,{type:"added"}))),l.jsxs("div",{className:"la-entry",style:{flexDirection:"column",alignItems:"flex-start",gap:2},children:[l.jsxs("div",{style:{fontSize:11,color:"var(--muted)",marginBottom:2},children:[c,"📝 执行计划"]}),T.map(b=>{const C=b.status==="completed"?"✅":b.status==="in-progress"?"🔄":"⬜",z=_.get(String(b.id)),d=b.status==="completed"?{opacity:.5,textDecoration:"line-through"}:b.status==="in-progress"?{color:"#60a5fa",fontWeight:"bold"}:{};return l.jsxs("div",{style:d,children:[C," ",b.title,z&&z.type==="changed"&&z.to==="completed"&&l.jsx("span",{style:{color:"#22c55e",fontSize:9,marginLeft:4},children:"✨刚完成"}),z&&z.type==="changed"&&z.to!=="completed"&&l.jsxs("span",{style:{color:"#f59e0b",fontSize:9,marginLeft:4},children:["↻",z.from,"→",z.to]}),z&&z.type==="added"&&l.jsx("span",{style:{color:"#3b82f6",fontSize:9,marginLeft:4},children:"🆕新增"})]},b.id)}),(x=(y=o.diff)==null?void 0:y.removed)==null?void 0:x.map(b=>l.jsxs("div",{style:{opacity:.4,textDecoration:"line-through"},children:["🗑 ",b.title]},b.id))]})}if(o.kind==="assistant")return l.jsxs(l.Fragment,{children:[o.thinking&&l.jsxs("div",{className:"la-entry la-thinking",children:[l.jsx("span",{className:"la-icon",children:"💭"}),l.jsxs("span",{className:"la-body",children:[c,o.thinking]}),l.jsx("span",{className:"la-time",children:f})]}),(L=o.tools)==null?void 0:L.map((T,_)=>l.jsxs("div",{className:"la-entry la-tool",children:[l.jsx("span",{className:"la-icon",children:"🔧"}),l.jsxs("span",{className:"la-body",children:[c,l.jsx("span",{className:"la-tool-name",children:T.name}),l.jsx("span",{className:"la-trunc",children:T.input_preview||""})]}),l.jsx("span",{className:"la-time",children:f})]},_)),o.text&&l.jsxs("div",{className:"la-entry la-assistant",children:[l.jsx("span",{className:"la-icon",children:"🤖"}),l.jsxs("span",{className:"la-body",children:[c,o.text]}),l.jsx("span",{className:"la-time",children:f})]})]});if(o.kind==="tool_result"){const T=o.exitCode===0||o.exitCode===null||o.exitCode===void 0;return l.jsxs("div",{className:`la-entry la-tool-result ${T?"ok":"err"}`,children:[l.jsx("span",{className:"la-icon",children:T?"✅":"❌"}),l.jsxs("span",{className:"la-body",children:[c,l.jsx("span",{className:"la-tool-name",children:o.tool||""}),o.output?o.output.substring(0,150):""]}),l.jsx("span",{className:"la-time",children:f})]})}return o.kind==="user"?l.jsxs("div",{className:"la-entry la-user",children:[l.jsx("span",{className:"la-icon",children:"📥"}),l.jsxs("span",{className:"la-body",children:[c,o.text||""]}),l.jsx("span",{className:"la-time",children:f})]}):null}function yp(){const o=ee(f=>f.toasts);return o.length?l.jsx("div",{className:"toaster",children:o.map(f=>l.jsx("div",{className:`toast ${f.type}`,children:f.msg},f.id))}):null}function xp(){const o=ee(R=>R.liveStatus),[f,c]=V.useState(!1),[y,x]=V.useState(!1);V.useEffect(()=>{const R=localStorage.getItem("openclaw_court_date"),g=new Date().toISOString().substring(0,10);if(!JSON.parse(localStorage.getItem("openclaw_court_pref")||'{"enabled":true}').enabled||R===g)return;localStorage.setItem("openclaw_court_date",g),c(!0);const P=setTimeout(()=>L(),3500);return()=>clearTimeout(P)},[]);const L=()=>{x(!0),setTimeout(()=>c(!1),500)};if(!f)return null;const _=((o==null?void 0:o.tasks)||[]).filter(ln),b=_.filter(R=>!["Done","Cancelled"].includes(R.state)).length,C=_.filter(R=>R.state==="Done").length,z=_.filter(R=>R.state!=="Done"&&R.state!=="Cancelled"&&R.eta&&new Date(R.eta.replace(" ","T"))0&&` · ⚠ 超期 ${z} 件`]}),l.jsx("div",{className:"crm-date in",children:m}),l.jsx("div",{className:"crm-skip",children:"点击任意处跳过"})]})}const Xi={taizi:"#e8a040",zhongshu:"#a07aff",menxia:"#6a9eff",shangshu:"#2ecc8a",libu:"#f5c842",hubu:"#ff9a6a",bingbu:"#ff5270",xingbu:"#cc4444",gongbu:"#44aaff",libu_hr:"#9b59b6"},Ql={neutral:"",confident:"😏",worried:"😟",angry:"😤",thinking:"🤔",amused:"😄",happy:"😊"},kp={zhongshu:{x:15,y:25},menxia:{x:15,y:45},shangshu:{x:15,y:65},libu:{x:85,y:20},hubu:{x:85,y:35},bingbu:{x:85,y:50},xingbu:{x:85,y:65},gongbu:{x:85,y:80},taizi:{x:50,y:20},libu_hr:{x:50,y:80}};function jp(){var ve;const[o,f]=V.useState("setup"),[c,y]=V.useState(new Set),[x,L]=V.useState(""),[T,_]=V.useState(null),[b,C]=V.useState(!1),[z,d]=V.useState(!1),w=V.useRef(!1),[m,R]=V.useState(""),[g,A]=V.useState(!1),[P,W]=V.useState(""),[J,I]=V.useState(!1),[oe,ue]=V.useState(!1),[me,pe]=V.useState(null),[Ae,X]=V.useState(null),[ie,ke]=V.useState({}),re=V.useRef(null),te=ee(M=>M.toast),Ne=ee(M=>M.liveStatus);V.useEffect(()=>{var M;(M=re.current)==null||M.scrollIntoView({behavior:"smooth"})},[(ve=T==null?void 0:T.messages)==null?void 0:ve.length]),V.useEffect(()=>{w.current=z},[z]),V.useEffect(()=>{if(!z||!T||b)return;const M=setInterval(()=>{w.current&&!b&&E()},5e3);return()=>clearInterval(M)},[z,T,b]);const Ee=M=>{y(ce=>{const ye=new Set(ce);return ye.has(M)?ye.delete(M):ye.size<8&&ye.add(M),ye})},je=async()=>{if(!(!x.trim()||c.size<2||b)){C(!0);try{const M=await fe.courtDiscussStart(x,Array.from(c));if(!M.ok)throw new Error(M.error||"启动失败");_(M),f("session")}catch(M){te(M.message||"启动失败","err")}finally{C(!1)}}},E=V.useCallback(async(M,ce)=>{if(!(!T||b)){C(!0);try{const ye=await fe.courtDiscussAdvance(T.session_id,M,ce);if(!ye.ok)throw new Error(ye.error||"推进失败");_(Ke=>{if(!Ke)return Ke;const et=[];M&&et.push({type:"emperor",content:M,timestamp:Date.now()/1e3}),ce&&et.push({type:"decree",content:ce,timestamp:Date.now()/1e3});const sn=(ye.new_messages||[]).map(Ct=>({type:"official",official_id:Ct.official_id,official_name:Ct.name,content:Ct.content,emotion:Ct.emotion,action:Ct.action,timestamp:Date.now()/1e3}));return ye.scene_note&&et.push({type:"scene_note",content:ye.scene_note,timestamp:Date.now()/1e3}),{...Ke,round:ye.round??Ke.round+1,messages:[...Ke.messages,...et,...sn]}});const Be=ye.new_messages||[];if(Be.length>0){const Ke={};let et=0;const sn=()=>{et({...Ct,...Ke}))}}catch{}finally{C(!1)}}},[T,b]),K=()=>{const M=m.trim();M&&(R(""),E(M))},U=()=>{const M=P.trim();M&&(W(""),A(!1),I(!0),setTimeout(()=>I(!1),800),E(void 0,M))},v=async()=>{if(b||oe)return;ue(!0),pe(null);let M=0;const ce=setInterval(async()=>{if(M++,pe("🎲 命运轮转中..."),M>=6){clearInterval(ce);try{const Be=(await fe.courtDiscussFate()).event||"边疆急报传来";pe(Be),ue(!1),E(void 0,`【命运骰子】${Be}`)}catch{pe("命运之力暂时无法触及"),ue(!1)}}},200)},D=async()=>{if(T){C(!0);try{const M=await fe.courtDiscussConclude(T.session_id);M.summary&&_(ce=>ce&&{...ce,phase:"concluded",messages:[...ce.messages,{type:"system",content:`📋 朝堂议政结束 — ${M.summary}`,timestamp:Date.now()/1e3}]}),d(!1)}catch{te("结束失败","err")}finally{C(!1)}}},de=()=>{T&&fe.courtDiscussDestroy(T.session_id).catch(()=>{}),f("setup"),_(null),d(!1),ke({}),X(null),pe(null)},k=[...((Ne==null?void 0:Ne.tasks)||[]).filter(M=>/^JJC-/i.test(M.id)&&!["Done","Cancelled"].includes(M.state)).slice(0,3).map(M=>({text:`讨论旨意 ${M.id}:${M.title}`,taskId:M.id,icon:"📜"})),{text:"讨论系统架构优化方案",taskId:"",icon:"🏗️"},{text:"评估当前项目进展和风险",taskId:"",icon:"📊"},{text:"制定下周工作计划",taskId:"",icon:"📋"},{text:"紧急问题:线上Bug排查方案",taskId:"",icon:"🚨"}];if(o==="setup")return l.jsxs("div",{className:"space-y-6",children:[l.jsxs("div",{className:"text-center py-4",children:[l.jsx("h2",{className:"text-xl font-bold bg-gradient-to-r from-amber-400 to-purple-400 bg-clip-text text-transparent",children:"🏛 朝堂议政"}),l.jsx("p",{className:"text-xs text-[var(--muted)] mt-1",children:"择臣上殿,围绕议题展开讨论 · 陛下可随时发言或降下天意改变走向"})]}),l.jsxs("div",{className:"bg-[var(--panel)] rounded-xl p-4 border border-[var(--line)]",children:[l.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[l.jsx("span",{className:"text-sm font-semibold",children:"👔 选择参朝官员"}),l.jsxs("span",{className:"text-xs text-[var(--muted)]",children:["(",c.size,"/8,至少2位)"]})]}),l.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-5 gap-2",children:fu.map(M=>{const ce=c.has(M.id),ye=Xi[M.id]||"#6a9eff";return l.jsx("button",{onClick:()=>Ee(M.id),className:"p-2.5 rounded-lg border transition-all text-left",style:{borderColor:ce?ye+"80":"var(--line)",background:ce?ye+"15":"var(--panel2)",boxShadow:ce?`0 0 12px ${ye}20`:"none"},children:l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx("span",{className:"text-lg",children:M.emoji}),l.jsxs("div",{children:[l.jsx("div",{className:"text-xs font-semibold",style:{color:ce?ye:"var(--text)"},children:M.label}),l.jsx("div",{className:"text-[10px] text-[var(--muted)]",children:M.role})]}),ce&&l.jsx("span",{className:"ml-auto w-4 h-4 rounded-full flex items-center justify-center text-[10px] text-white",style:{background:ye},children:"✓"})]})},M.id)})})]}),l.jsxs("div",{className:"bg-[var(--panel)] rounded-xl p-4 border border-[var(--line)]",children:[l.jsx("div",{className:"text-sm font-semibold mb-2",children:"📜 设定议题"}),k.length>0&&l.jsx("div",{className:"flex flex-wrap gap-1.5 mb-3",children:k.map((M,ce)=>l.jsxs("button",{onClick:()=>L(M.text),className:"text-xs px-2.5 py-1.5 rounded-lg border border-[var(--line)] hover:border-[var(--acc)] hover:text-[var(--acc)] transition-colors",style:{background:x===M.text?"var(--acc)18":"transparent",borderColor:x===M.text?"var(--acc)":void 0,color:x===M.text?"var(--acc)":void 0},children:[M.icon," ",M.text]},ce))}),l.jsx("textarea",{className:"w-full bg-[var(--panel2)] rounded-lg p-3 text-sm border border-[var(--line)] focus:border-[var(--acc)] outline-none resize-none",rows:2,placeholder:"或自定义议题...",value:x,onChange:M=>L(M.target.value)})]}),l.jsx("div",{className:"flex flex-wrap gap-1.5",children:["👑 皇帝发言","⚡ 天命降临","🎲 命运骰子","🔄 自动推进","📜 讨论记录"].map(M=>l.jsx("span",{className:"text-[10px] px-2 py-1 rounded-full border border-[var(--line)] text-[var(--muted)]",children:M},M))}),l.jsx("button",{onClick:je,disabled:c.size<2||!x.trim()||b,className:"w-full py-3 rounded-xl font-semibold text-sm transition-all border-0",style:{background:c.size>=2&&x.trim()?"linear-gradient(135deg, #6a9eff, #a07aff)":"var(--panel2)",color:c.size>=2&&x.trim()?"#fff":"var(--muted)",opacity:b?.6:1,cursor:c.size>=2&&x.trim()&&!b?"pointer":"not-allowed"},children:b?"召集中...":`🏛 开始朝议(${c.size}位上殿)`})]});const H=(T==null?void 0:T.officials)||[],ne=(T==null?void 0:T.messages)||[];return l.jsxs("div",{className:"space-y-3",children:[l.jsxs("div",{className:"flex items-center justify-between flex-wrap gap-2 bg-[var(--panel)] rounded-xl px-4 py-2 border border-[var(--line)]",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"text-sm font-bold",children:"🏛 朝堂议政"}),l.jsxs("span",{className:"text-[10px] px-2 py-0.5 rounded-full bg-[var(--acc)]20 text-[var(--acc)] border border-[var(--acc)]30",children:["第",(T==null?void 0:T.round)||0,"轮"]}),(T==null?void 0:T.phase)==="concluded"&&l.jsx("span",{className:"text-[10px] px-2 py-0.5 rounded-full bg-green-900/40 text-green-400 border border-green-800",children:"已结束"})]}),l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx("button",{onClick:()=>A(!g),className:"text-xs px-2.5 py-1 rounded-lg border border-amber-600/40 text-amber-400 hover:bg-amber-900/20 transition",title:"天命降临 — 上帝视角干预",children:"⚡ 天命"}),l.jsxs("button",{onClick:v,disabled:oe||b,className:"text-xs px-2.5 py-1 rounded-lg border border-purple-600/40 text-purple-400 hover:bg-purple-900/20 transition",title:"命运骰子 — 随机事件",children:["🎲 ",oe?"...":"骰子"]}),l.jsx("button",{onClick:()=>d(!z),className:`text-xs px-2.5 py-1 rounded-lg border transition ${z?"border-green-600/40 text-green-400 bg-green-900/20":"border-[var(--line)] text-[var(--muted)] hover:text-[var(--text)]"}`,children:z?"⏸ 暂停":"▶ 自动"}),(T==null?void 0:T.phase)!=="concluded"&&l.jsx("button",{onClick:D,className:"text-xs px-2.5 py-1 rounded-lg border border-[var(--line)] text-[var(--muted)] hover:text-[var(--warn)] hover:border-[var(--warn)]40 transition",children:"📋 散朝"}),l.jsx("button",{onClick:de,className:"text-xs px-2 py-1 rounded-lg border border-red-900/40 text-red-400/70 hover:text-red-400 transition",children:"✕"})]})]}),g&&l.jsxs("div",{className:"bg-gradient-to-br from-amber-950/40 to-purple-950/30 rounded-xl p-4 border border-amber-700/30",style:{animation:"fadeIn .3s"},children:[l.jsxs("div",{className:"flex items-center justify-between mb-2",children:[l.jsx("span",{className:"text-sm font-bold text-amber-400",children:"⚡ 天命降临 — 上帝视角"}),l.jsx("button",{onClick:()=>A(!1),className:"text-xs text-[var(--muted)]",children:"✕"})]}),l.jsx("p",{className:"text-[10px] text-amber-300/60 mb-2",children:"降下天意改变讨论走向,所有官员将对此做出反应"}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx("input",{value:P,onChange:M=>W(M.target.value),onKeyDown:M=>M.key==="Enter"&&U(),placeholder:"例如:突然发现预算多出一倍...",className:"flex-1 bg-black/30 rounded-lg px-3 py-1.5 text-sm border border-amber-800/40 outline-none focus:border-amber-600"}),l.jsx("button",{onClick:U,disabled:!P.trim(),className:"px-4 py-1.5 rounded-lg bg-gradient-to-r from-amber-600 to-purple-600 text-white text-xs font-semibold disabled:opacity-40",children:"降旨"})]})]}),me&&l.jsxs("div",{className:"bg-purple-950/40 rounded-lg px-3 py-2 border border-purple-700/30 text-xs text-purple-300 flex items-center gap-2",style:{animation:"fadeIn .3s"},children:[l.jsx("span",{className:"text-lg",children:"🎲"}),me]}),J&&l.jsx("div",{className:"fixed inset-0 pointer-events-none z-50",style:{background:"radial-gradient(circle, rgba(255,200,50,0.3), transparent 70%)",animation:"fadeOut .8s forwards"}}),l.jsxs("div",{className:"text-xs text-center text-[var(--muted)] py-1",children:["📜 ",(T==null?void 0:T.topic)||""]}),l.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-[280px_1fr] gap-3",children:[l.jsxs("div",{className:"bg-[var(--panel)] rounded-xl p-3 border border-[var(--line)] relative overflow-hidden min-h-[320px]",children:[l.jsx("div",{className:"text-center mb-2",children:l.jsxs("div",{className:"inline-block px-3 py-1 rounded-lg bg-gradient-to-b from-amber-800/40 to-amber-950/40 border border-amber-700/30",children:[l.jsx("span",{className:"text-lg",children:"👑"}),l.jsx("div",{className:"text-[10px] text-amber-400/80",children:"龙 椅"})]})}),l.jsxs("div",{className:"relative",style:{minHeight:250},children:[l.jsx("div",{className:"absolute left-0 top-0 text-[9px] text-[var(--muted)] opacity-50",children:"三省"}),l.jsx("div",{className:"absolute right-0 top-0 text-[9px] text-[var(--muted)] opacity-50",children:"六部"}),H.map(M=>{const ce=kp[M.id]||{x:50,y:50},ye=Xi[M.id]||"#6a9eff",Be=Ae===M.id,Ke=ie[M.id]||"neutral";return l.jsxs("div",{className:"absolute transition-all duration-500",style:{left:`${ce.x}%`,top:`${ce.y}%`,transform:"translate(-50%, -50%)"},children:[Be&&l.jsx("div",{className:"absolute -inset-2 rounded-full",style:{background:`radial-gradient(circle, ${ye}40, transparent)`,animation:"pulse 1s infinite"}}),l.jsxs("div",{className:"relative w-10 h-10 rounded-full flex items-center justify-center text-lg border-2 transition-all",style:{borderColor:Be?ye:ye+"40",background:Be?ye+"30":ye+"10",transform:Be?"scale(1.2)":"scale(1)",boxShadow:Be?`0 0 16px ${ye}50`:"none"},children:[M.emoji,Ql[Ke]&&l.jsx("span",{className:"absolute -top-1 -right-1 text-xs",style:{animation:"bounceIn .3s"},children:Ql[Ke]})]}),l.jsx("div",{className:"text-[9px] text-center mt-0.5 whitespace-nowrap",style:{color:Be?ye:"var(--muted)"},children:M.name})]},M.id)})]})]}),l.jsxs("div",{className:"bg-[var(--panel)] rounded-xl border border-[var(--line)] flex flex-col",style:{maxHeight:500},children:[l.jsxs("div",{className:"flex-1 overflow-y-auto p-3 space-y-2",style:{minHeight:200},children:[ne.map((M,ce)=>l.jsx(Sp,{msg:M,officials:H},ce)),b&&l.jsx("div",{className:"text-xs text-[var(--muted)] text-center py-2",style:{animation:"pulse 1.5s infinite"},children:"🏛 群臣正在思考..."}),l.jsx("div",{ref:re})]}),(T==null?void 0:T.phase)!=="concluded"&&l.jsxs("div",{className:"border-t border-[var(--line)] p-2 flex gap-2",children:[l.jsx("input",{value:m,onChange:M=>R(M.target.value),onKeyDown:M=>M.key==="Enter"&&K(),placeholder:"朕有话说...",className:"flex-1 bg-[var(--panel2)] rounded-lg px-3 py-1.5 text-sm border border-[var(--line)] outline-none focus:border-amber-600"}),l.jsx("button",{onClick:K,disabled:!m.trim()||b,className:"px-4 py-1.5 rounded-lg text-xs font-semibold border-0 disabled:opacity-40",style:{background:m.trim()?"linear-gradient(135deg, #e8a040, #f5c842)":"var(--panel2)",color:m.trim()?"#000":"var(--muted)"},children:"👑 发言"}),l.jsx("button",{onClick:()=>E(),disabled:b,className:"px-3 py-1.5 rounded-lg text-xs border border-[var(--acc)]40 text-[var(--acc)] hover:bg-[var(--acc)]10 disabled:opacity-40 transition",children:"▶ 下一轮"})]})]})]})]})}function Sp({msg:o,officials:f}){var x;const c=Xi[o.official_id||""]||"#6a9eff",y=f.find(L=>L.id===o.official_id);return o.type==="system"?l.jsx("div",{className:"text-center text-[10px] text-[var(--muted)] py-1 border-b border-[var(--line)] border-dashed",children:o.content}):o.type==="scene_note"?l.jsxs("div",{className:"text-center text-[10px] text-purple-400/80 py-1 italic",children:["✦ ",o.content," ✦"]}):o.type==="emperor"?l.jsx("div",{className:"flex justify-end",children:l.jsxs("div",{className:"max-w-[80%] bg-gradient-to-br from-amber-900/40 to-amber-800/20 rounded-xl px-3 py-2 border border-amber-700/30",children:[l.jsx("div",{className:"text-[10px] text-amber-400 mb-0.5",children:"👑 皇帝"}),l.jsx("div",{className:"text-sm",children:o.content})]})}):o.type==="decree"?l.jsx("div",{className:"text-center py-2",children:l.jsxs("div",{className:"inline-block bg-gradient-to-r from-amber-900/30 via-purple-900/30 to-amber-900/30 rounded-lg px-4 py-2 border border-amber-600/30",children:[l.jsx("div",{className:"text-xs text-amber-400 font-bold",children:"⚡ 天命降临"}),l.jsx("div",{className:"text-sm mt-0.5",children:o.content})]})}):l.jsxs("div",{className:"flex gap-2 items-start",style:{animation:"fadeIn .4s"},children:[l.jsx("div",{className:"w-7 h-7 rounded-full flex items-center justify-center text-sm flex-shrink-0 border",style:{borderColor:c+"60",background:c+"15"},children:(y==null?void 0:y.emoji)||"💬"}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsxs("div",{className:"flex items-center gap-1.5 mb-0.5",children:[l.jsx("span",{className:"text-[11px] font-semibold",style:{color:c},children:o.official_name||"官员"}),o.emotion&&Ql[o.emotion]&&l.jsx("span",{className:"text-xs",children:Ql[o.emotion]})]}),l.jsx("div",{className:"text-sm leading-relaxed",children:(x=o.content)==null?void 0:x.split(/(\*[^*]+\*)/).map((L,T)=>L.startsWith("*")&&L.endsWith("*")?l.jsx("span",{className:"text-[var(--muted)] italic text-xs",children:L.slice(1,-1)},T):l.jsx("span",{children:L},T))})]})]})}function wp(){const o=ee(d=>d.activeTab),f=ee(d=>d.setActiveTab),c=ee(d=>d.liveStatus),y=ee(d=>d.countdown),x=ee(d=>d.loadAll);V.useEffect(()=>(Uf(),()=>Hf()),[]);const L=(c==null?void 0:c.tasks)||[],T=L.filter(ln),_=T.filter(d=>!Vl(d)),b=c==null?void 0:c.syncStatus,C=b==null?void 0:b.ok,z=d=>d==="edicts"?String(_.length):d==="sessions"?String(L.filter(w=>!ln(w)).length):d==="memorials"?String(T.filter(w=>["Done","Cancelled"].includes(w.state)).length):d==="monitor"?L.filter(m=>ln(m)&&m.state==="Doing").length+"活跃":"";return l.jsxs("div",{className:"wrap",children:[l.jsxs("div",{className:"hdr",children:[l.jsxs("div",{children:[l.jsx("div",{className:"logo",children:"三省六部 · 总控台"}),l.jsx("div",{className:"sub-text",children:"OpenClaw Sansheng-Liubu Dashboard"})]}),l.jsxs("div",{className:"hdr-r",children:[l.jsx("span",{className:`chip ${C?"ok":C===!1?"err":""}`,children:C?"✅ 同步正常":C===!1?"❌ 服务器未启动":"⏳ 连接中…"}),l.jsxs("span",{className:"chip",children:[_.length," 道旨意"]}),l.jsx("button",{className:"btn-refresh",onClick:()=>x(),children:"⟳ 刷新"}),l.jsxs("span",{style:{fontSize:11,color:"var(--muted)"},children:["⟳ ",y,"s"]})]})]}),l.jsx("div",{className:"tabs",children:$f.map(d=>l.jsxs("div",{className:`tab ${o===d.key?"active":""}`,onClick:()=>f(d.key),children:[d.icon," ",d.label,z(d.key)&&l.jsx("span",{className:"tbadge",children:z(d.key)})]},d.key))}),o==="edicts"&&l.jsx(Gf,{}),o==="court"&&l.jsx(jp,{}),o==="monitor"&&l.jsx(Yf,{}),o==="officials"&&l.jsx(Zf,{}),o==="models"&&l.jsx(ep,{}),o==="skills"&&l.jsx(np,{}),o==="sessions"&&l.jsx(sp,{}),o==="memorials"&&l.jsx(op,{}),o==="templates"&&l.jsx(cp,{}),o==="morning"&&l.jsx(up,{}),l.jsx(mp,{}),l.jsx(yp,{}),l.jsx(xp,{})]})}wf.createRoot(document.getElementById("root")).render(l.jsx(cu.StrictMode,{children:l.jsx(wp,{})})); diff --git a/dashboard/dist/assets/index-CIswLNpP.css b/dashboard/dist/assets/index-CIswLNpP.css deleted file mode 100644 index 4e09b6d..0000000 --- a/dashboard/dist/assets/index-CIswLNpP.css +++ /dev/null @@ -1 +0,0 @@ -*,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}:before,:after{--tw-content: ""}html,:host{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji";font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}ol,ul,menu{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}button,[role=button]{cursor:pointer}:disabled{cursor:default}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]:where(:not([hidden=until-found])){display:none}.static{position:static}.relative{position:relative}.block{display:block}.inline-block{display:inline-block}.flex{display:flex}.grid{display:grid}.contents{display:contents}.hidden{display:none}.resize{resize:both}.break-all{word-break:break-all}.border{border-width:1px}.line-through{text-decoration-line:line-through}.outline{outline-style:solid}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.transition{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}:root{--bg: #07090f;--panel: #0f1219;--panel2: #141824;--line: #1c2236;--text: #dde4f8;--muted: #5a6b92;--ok: #2ecc8a;--warn: #f5c842;--danger: #ff5270;--acc: #6a9eff;--acc2: #a07aff}*{box-sizing:border-box;margin:0;padding:0}body{background:var(--bg);color:var(--text);font-family:PingFang SC,Inter,-apple-system,Segoe UI,sans-serif;min-height:100vh}::-webkit-scrollbar{width:4px;height:4px}::-webkit-scrollbar-track{background:transparent}::-webkit-scrollbar-thumb{background:#1e2538;border-radius:4px}.wrap{max-width:1400px;margin:0 auto;padding:16px}.hdr{display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:10px;margin-bottom:16px;padding-bottom:14px;border-bottom:1px solid var(--line)}.logo{font-size:20px;font-weight:800;background:linear-gradient(135deg,#6a9eff,#a07aff);-webkit-background-clip:text;-webkit-text-fill-color:transparent}.sub-text{font-size:11px;color:var(--muted)}.hdr-r{display:flex;align-items:center;gap:8px;flex-wrap:wrap}.chip{font-size:11px;padding:3px 9px;border:1px solid var(--line);border-radius:999px;background:var(--panel);color:var(--muted)}.chip.ok{border-color:#2ecc8a44;color:var(--ok)}.chip.warn{border-color:#f5c84244;color:var(--warn)}.chip.err{border-color:#ff527044;color:var(--danger)}.btn-refresh{font-size:11px;padding:4px 10px;border:1px solid var(--acc);border-radius:6px;background:transparent;color:var(--acc);cursor:pointer}.btn-refresh:hover{background:#0a1228}.tabs{display:flex;gap:2px;margin-bottom:18px;border-bottom:1px solid var(--line);overflow-x:auto}.tab{font-size:13px;padding:8px 16px;border-radius:8px 8px 0 0;cursor:pointer;color:var(--muted);border:1px solid transparent;border-bottom:none;white-space:nowrap;position:relative;bottom:-1px;transition:all .15s;-webkit-user-select:none;-moz-user-select:none;user-select:none}.tab:hover{color:var(--text);background:var(--panel)}.tab.active{color:var(--text);background:var(--panel);border-color:var(--line);font-weight:600}.tbadge{font-size:10px;padding:1px 5px;border-radius:999px;background:#1a2040;color:var(--acc);margin-left:4px}.edict-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(340px,1fr));gap:12px}.edict-card{background:var(--panel);border:1px solid var(--line);border-radius:14px;padding:18px;cursor:pointer;transition:border-color .15s,transform .1s,box-shadow .15s}.edict-card:hover{border-color:var(--acc);transform:translateY(-2px);box-shadow:0 4px 20px #6a9eff1a}.edict-card.archived{opacity:.55;border-style:dashed}.edict-card.archived:hover{opacity:.85}.ec-pipe{display:flex;align-items:center;gap:0;margin-bottom:14px;overflow-x:auto;padding-bottom:2px}.ep-node{display:flex;flex-direction:column;align-items:center;gap:1px;padding:5px 8px;border-radius:6px;flex-shrink:0;min-width:52px}.ep-node.done{background:#0a2018}.ep-node.active{background:#0f1a38;border:1px solid var(--acc)}.ep-node.pending{opacity:.3}.ep-icon{font-size:14px}.ep-name{font-size:9px;color:var(--muted);white-space:nowrap}.ep-node.done .ep-name{color:var(--ok)}.ep-node.active .ep-name{color:var(--acc);font-weight:700}.ep-arrow{font-size:10px;color:#1c2236;padding:0 1px;flex-shrink:0}.ec-id{font-size:10px;color:var(--acc);font-weight:700;letter-spacing:.04em;margin-bottom:5px}.ec-title{font-size:15px;font-weight:700;line-height:1.4;margin-bottom:10px;color:var(--text)}.ec-meta{display:flex;flex-wrap:wrap;gap:6px;align-items:center;margin-bottom:8px}.tag{font-size:10px;padding:2px 7px;border-radius:4px;border:1px solid;display:inline-block;white-space:nowrap}.st-Inbox{border-color:#3a4a7a44;color:#7a9aff;background:#0a1028}.st-Taizi{border-color:#e8a04044;color:#e8a040;background:#281a08}.st-Zhongshu{border-color:#a07aff44;color:#a07aff;background:#110a28}.st-Menxia{border-color:#ff9a6a44;color:#ff9a6a;background:#280f0a}.st-Assigned,.st-Doing{border-color:#6a9eff44;color:#6a9eff;background:#0a1428}.st-Review{border-color:#f5c84244;color:#f5c842;background:#201a08}.st-Done{border-color:#2ecc8a44;color:var(--ok);background:#0a2018}.st-Blocked{border-color:#ff527044;color:var(--danger);background:#200a10}.st-Cancelled{border-color:#8884;color:#888;background:#1a1a1a}.st-Next{border-color:#4a9adf44;color:#4a9adf;background:#0a1424}.st-Pending{border-color:#3a4a7a44;color:#7a9aff;background:#0a1028}.dt-中书省{border-color:#a07aff44;color:#a07aff;background:#1a0f38}.dt-门下省{border-color:#6a9eff44;color:#6a9eff;background:#0f1a38}.dt-尚书省{border-color:#6aef9a44;color:#6aef9a;background:#0a2018}.dt-礼部{border-color:#f5c84244;color:#f5c842;background:#201a08}.dt-户部{border-color:#ff9a6a44;color:#ff9a6a;background:#28100a}.dt-兵部{border-color:#ff527044;color:#ff5270;background:#280a10}.dt-刑部{border-color:#c444;color:#c44;background:#280808}.dt-工部{border-color:#4af4;color:#4af;background:#081828}.ec-footer{display:flex;align-items:center;justify-content:space-between;margin-top:10px;flex-wrap:wrap;gap:6px}.hb{font-size:10px;padding:2px 7px;border-radius:999px;border:1px solid var(--line)}.hb.active{border-color:#2ecc8a44;color:var(--ok)}.hb.warn{border-color:#f5c84244;color:var(--warn)}.hb.stalled{border-color:#ff527044;color:var(--danger);animation:pulse 1.5s infinite}.hb.unknown{color:var(--muted)}@keyframes pulse{0%,to{opacity:1}50%{opacity:.4}}.modal-bg{position:fixed;top:0;right:0;bottom:0;left:0;background:#000000b3;z-index:100;-webkit-backdrop-filter:blur(3px);backdrop-filter:blur(3px);overflow-y:auto;display:flex;align-items:flex-start;justify-content:center;padding:40px 16px}.modal{background:var(--panel);border:1px solid var(--line);border-radius:18px;width:100%;max-width:760px;padding:28px;position:relative;box-shadow:0 20px 60px #0009}.modal-close{position:absolute;top:16px;right:16px;width:32px;height:32px;display:flex;align-items:center;justify-content:center;border-radius:8px;cursor:pointer;font-size:18px;color:var(--muted);background:none;border:none}.modal-close:hover{background:var(--panel2);color:var(--text)}.modal-id{font-size:11px;color:var(--acc);font-weight:700;letter-spacing:.04em;margin-bottom:6px}.modal-title{font-size:22px;font-weight:800;line-height:1.3;margin-bottom:18px}.m-pipe{display:flex;align-items:stretch;gap:0;overflow-x:auto;padding:16px;background:var(--panel2);border-radius:12px;margin-bottom:20px}.mp-stage{display:flex;align-items:center;flex-shrink:0}.mp-node{display:flex;flex-direction:column;align-items:center;gap:4px;padding:10px 14px;border-radius:10px;min-width:80px;position:relative}.mp-node.done{background:#0a2018;border:1px solid #2ecc8a44}.mp-node.active{background:#0f1838;border:2px solid var(--acc);box-shadow:0 0 14px #6a9eff33}.mp-node.pending{opacity:.25;border:1px dashed var(--line)}.mp-icon{font-size:22px}.mp-dept{font-size:12px;font-weight:700;margin-top:2px}.mp-node.done .mp-dept{color:var(--ok)}.mp-node.active .mp-dept{color:var(--acc)}.mp-node.pending .mp-dept{color:var(--muted)}.mp-action{font-size:10px;color:var(--muted);margin-top:1px}.mp-node.active .mp-action{color:#6a9eff88}.mp-done-tick{position:absolute;top:-6px;right:-6px;width:16px;height:16px;background:var(--ok);border-radius:50%;display:flex;align-items:center;justify-content:center;font-size:9px;color:#000;font-weight:700}.mp-arrow{color:#1c2236;font-size:18px;padding:0 6px;margin-top:-10px}.cur-stage{display:flex;align-items:center;gap:10px;padding:12px 16px;background:#0a1228;border:1px solid var(--acc);border-radius:10px;margin-bottom:18px}.cs-icon{font-size:24px}.cs-info .cs-dept{font-size:16px;font-weight:700;color:var(--acc)}.cs-info .cs-action{font-size:12px;color:var(--muted);margin-top:2px}.cs-hb{margin-left:auto}.m-section{margin-bottom:18px}.m-sec-label{font-size:11px;font-weight:700;color:var(--muted);letter-spacing:.06em;text-transform:uppercase;margin-bottom:10px;padding-bottom:6px;border-bottom:1px solid var(--line)}.fl-timeline{display:flex;flex-direction:column;gap:0;position:relative}.fl-timeline:before{content:"";position:absolute;left:60px;top:0;bottom:0;width:1px;background:var(--line)}.fl-item{display:flex;gap:0;position:relative;padding:8px 0}.fl-time{min-width:60px;font-size:10px;color:var(--muted);text-align:right;padding-right:14px;flex-shrink:0;padding-top:3px}.fl-dot{width:10px;height:10px;border-radius:50%;flex-shrink:0;margin-top:3px;position:relative;z-index:1}.fl-content{padding-left:12px;flex:1}.fl-who{font-size:12px;margin-bottom:2px}.fl-who .from,.fl-who .to{font-weight:700}.fl-rem{font-size:11px;color:var(--muted);line-height:1.5}.m-rows{display:grid;grid-template-columns:1fr 1fr;gap:8px}.m-row{background:var(--panel2);border-radius:8px;padding:10px 12px}.mr-label{font-size:10px;color:var(--muted);text-transform:uppercase;letter-spacing:.05em;margin-bottom:3px}.mr-val{font-size:13px;font-weight:600;word-break:break-all}.duty-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(310px,1fr));gap:12px}.duty-card{background:var(--panel);border:1px solid var(--line);border-radius:14px;overflow:hidden;transition:border-color .15s}.duty-card:hover{border-color:#2e3d6a}.duty-card.active-card{border-color:var(--acc)}.duty-card.blocked-card{border-color:#ff527055}.dc-hdr{display:flex;align-items:center;gap:10px;padding:12px 16px;background:var(--panel2);border-bottom:1px solid var(--line)}.dc-emoji{font-size:22px}.dc-info{flex:1}.dc-name{font-size:14px;font-weight:800}.dc-role{font-size:10px;color:var(--muted)}.dc-status{display:flex;align-items:center;gap:5px;font-size:11px}.dc-dot{width:8px;height:8px;border-radius:50%;flex-shrink:0}.dc-dot.active{background:var(--ok)}.dc-dot.busy{background:var(--warn);animation:pulse 1.5s infinite}.dc-dot.blocked{background:var(--danger);animation:pulse 1s infinite}.dc-dot.idle{background:#2a3a5a}.dc-body{padding:14px 16px}.dc-idle{display:flex;align-items:center;gap:8px;color:var(--muted);font-size:13px;padding:6px 0}.dc-task{display:flex;flex-direction:column;gap:6px;cursor:pointer;padding:6px;border-radius:8px;border:1px solid var(--line);margin-bottom:6px}.dc-task:hover{border-color:var(--acc)}.dc-task-id{font-size:10px;color:var(--acc);font-weight:700;letter-spacing:.04em}.dc-task-title{font-size:14px;font-weight:700;color:var(--text);line-height:1.3}.dc-task-now{font-size:12px;color:var(--muted);line-height:1.5;margin-top:2px}.dc-task-meta{display:flex;align-items:center;gap:8px;flex-wrap:wrap;margin-top:6px}.dc-footer{padding:8px 16px;border-top:1px solid var(--line);display:flex;align-items:center;gap:8px;background:var(--panel2)}.dc-model{font-size:10px;color:var(--muted)}.dc-la{font-size:10px;color:var(--muted);margin-left:auto}.as-panel{background:var(--panel);border:1px solid var(--line);border-radius:14px;padding:14px 18px;margin-bottom:16px}.as-header{display:flex;align-items:center;gap:10px;margin-bottom:12px}.as-title{font-size:13px;font-weight:700}.as-gw{font-size:11px;padding:3px 10px;border-radius:999px;margin-left:auto}.as-gw.ok{background:#0a2018;border:1px solid #2ecc8a44;color:var(--ok)}.as-gw.err{background:#200a10;border:1px solid #ff527044;color:var(--danger)}.as-gw.warn{background:#201a08;border:1px solid #f5c84244;color:var(--warn)}.as-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(130px,1fr));gap:8px}.as-card{background:var(--panel2);border:1px solid var(--line);border-radius:10px;padding:10px;text-align:center;cursor:pointer;transition:border-color .15s,background .15s;position:relative}.as-card:hover{border-color:var(--acc);background:#0a1228}.as-dot{position:absolute;top:6px;right:6px;width:8px;height:8px;border-radius:50%}.as-dot.running{background:#2ecc8a;box-shadow:0 0 6px #2ecc8a88;animation:pulse 1.5s infinite}.as-dot.idle{background:#4a5568}.as-dot.offline{background:#ff5270;animation:pulse 1.2s infinite}.as-dot.unconfigured{background:#6b7280}.as-wake-btn{font-size:10px;padding:2px 8px;border-radius:6px;border:1px solid var(--acc);color:var(--acc);background:transparent;cursor:pointer;margin-top:6px;transition:background .15s}.as-wake-btn:hover{background:var(--acc);color:#fff}.as-summary{font-size:11px;color:var(--muted);display:flex;gap:12px;margin-top:10px;padding-top:8px;border-top:1px solid var(--line)}.task-actions{display:flex;gap:8px;margin-bottom:18px;flex-wrap:wrap}.btn-action{font-size:12px;padding:7px 16px;border-radius:8px;border:none;cursor:pointer;font-weight:700;transition:all .15s}.btn-stop{background:#ff527022;color:#ff5270;border:1px solid #ff527044}.btn-stop:hover{background:#ff527044}.btn-cancel-action{background:#8882;color:#888;border:1px solid #88888844}.btn-cancel-action:hover{background:#8884}.btn-resume{background:#2ecc8a22;color:#2ecc8a;border:1px solid #2ecc8a44}.btn-resume:hover{background:#2ecc8a44}.sched-section{margin-bottom:18px;background:var(--panel2);border:1px solid var(--line);border-radius:10px;padding:12px}.sched-head{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-bottom:8px}.sched-title{font-size:11px;font-weight:700;letter-spacing:.06em;color:var(--acc)}.sched-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:8px;margin-bottom:10px}.sched-kpi{background:var(--panel);border:1px solid var(--line);border-radius:8px;padding:8px 10px}.sched-kpi .k{font-size:10px;color:var(--muted);margin-bottom:2px}.sched-kpi .v{font-size:13px;font-weight:700}.sched-btn{font-size:11px;padding:5px 10px;border-radius:6px;border:1px solid var(--line);background:transparent;color:var(--muted);cursor:pointer;transition:all .15s}.sched-btn:hover{border-color:var(--acc);color:var(--text)}.todo-section{margin-bottom:18px}.todo-header{display:flex;align-items:center;justify-content:space-between;margin-bottom:10px}.todo-progress{display:flex;align-items:center;gap:8px;font-size:12px;color:var(--muted)}.todo-bar{width:120px;height:6px;background:#0e1320;border-radius:3px;overflow:hidden}.todo-bar-fill{height:100%;border-radius:3px;background:var(--ok);transition:width .3s}.todo-list{display:flex;flex-direction:column;gap:4px}.todo-item{display:flex;flex-direction:column;background:var(--panel2);border-radius:8px;font-size:12px;transition:opacity .15s}.todo-item.done{opacity:.55}.todo-item .t-row{display:flex;align-items:center;gap:8px;padding:7px 10px}.todo-item .t-icon{font-size:14px;flex-shrink:0}.todo-item .t-title{flex:1;color:var(--text)}.todo-item.done .t-title{text-decoration:line-through;color:var(--muted)}.todo-item .t-status{font-size:10px;padding:2px 6px;border-radius:4px}.todo-item .t-status.s-done{color:var(--ok);background:#0a2018;border:1px solid #2ecc8a44}.todo-item .t-status.s-progress{color:var(--acc);background:#0a1228;border:1px solid #6a9eff44}.todo-item .t-status.s-notstarted{color:var(--muted);background:var(--panel);border:1px solid var(--line)}.ec-todo-bar{display:flex;align-items:center;gap:6px;font-size:10px;color:var(--muted);margin-top:6px}.ec-todo-track{flex:1;max-width:80px;height:4px;background:#0e1320;border-radius:2px;overflow:hidden}.ec-todo-fill{height:100%;background:var(--ok);border-radius:2px}.ec-actions{display:flex;gap:4px;margin-top:8px}.ec-actions .mini-act{font-size:10px;padding:3px 8px;border-radius:5px;border:1px solid var(--line);background:transparent;cursor:pointer;color:var(--muted);transition:all .12s}.ec-actions .mini-act:hover{border-color:var(--acc);color:var(--text)}.ec-actions .mini-act.danger:hover{border-color:#ff5270;color:#ff5270}.archive-bar{display:flex;align-items:center;gap:8px;margin-bottom:14px;flex-wrap:wrap}.ab-label{font-size:12px;color:var(--muted);margin-right:4px}.ab-btn{font-size:11px;padding:4px 12px;border-radius:6px;border:1px solid var(--line);background:transparent;cursor:pointer;color:var(--muted);transition:all .15s;font-weight:600}.ab-btn:hover{border-color:var(--acc);color:var(--text)}.ab-btn.active{border-color:var(--acc);color:var(--acc);background:#0f1a38}.ab-count{font-size:10px;color:var(--muted);margin-left:auto}.ab-scan{font-size:11px;padding:4px 12px;border-radius:6px;border:1px solid #6a9eff44;background:transparent;cursor:pointer;color:var(--acc);font-weight:600;transition:all .15s}.ab-scan:hover{background:#0a1228;border-color:var(--acc)}.ab-scan-status{font-size:10px;color:var(--muted)}.la-section{margin-bottom:18px}.la-header{display:flex;align-items:center;justify-content:space-between;margin-bottom:10px}.la-title{font-size:11px;font-weight:700;color:var(--acc);letter-spacing:.06em}.la-log{max-height:320px;overflow-y:auto;background:var(--panel2);border:1px solid var(--line);border-radius:10px;padding:10px 12px;display:flex;flex-direction:column;gap:6px;font-size:12px}.la-entry{display:flex;gap:8px;align-items:flex-start;padding:5px 8px;border-radius:6px;line-height:1.5;word-break:break-all}.la-entry:hover{background:#6a9eff0a}.la-empty{text-align:center;color:var(--muted);padding:20px;font-size:12px}.model-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(300px,1fr));gap:12px;margin-bottom:18px}.mc-card{background:var(--panel);border:1px solid var(--line);border-radius:12px;padding:16px}.mc-top{display:flex;align-items:center;gap:10px;margin-bottom:12px}.mc-emoji{font-size:22px}.mc-name{font-size:15px;font-weight:700}.mc-role{font-size:11px;color:var(--muted)}.mc-cur{font-size:11px;color:var(--muted);margin-bottom:8px}.mc-cur b{color:var(--text)}.msel{width:100%;background:var(--panel2);border:1px solid var(--line);border-radius:7px;color:var(--text);padding:7px 10px;font-size:12px;outline:none;cursor:pointer}.msel:focus{border-color:var(--acc)}.mc-btns{display:flex;gap:6px;margin-top:8px}.btn{font-size:12px;padding:6px 14px;border-radius:7px;border:none;cursor:pointer;font-weight:600}.btn-p{background:var(--acc);color:#000}.btn-p:hover{filter:brightness(1.15)}.btn-p:disabled{background:#2a3a6a;color:var(--muted);cursor:not-allowed}.btn-g{background:transparent;border:1px solid var(--line);color:var(--muted)}.btn-g:hover{border-color:#2e3d6a;color:var(--text)}.cl-wrap{background:var(--panel);border:1px solid var(--line);border-radius:12px;padding:16px}.cl-title{font-size:12px;font-weight:700;color:var(--muted);letter-spacing:.05em;text-transform:uppercase;margin-bottom:10px}.cl-row{display:flex;gap:10px;font-size:11px;padding:5px 0;border-bottom:1px solid var(--line)}.cl-row:last-child{border-bottom:none}.skills-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(280px,1fr));gap:12px}.sk-card{background:var(--panel);border:1px solid var(--line);border-radius:12px;overflow:hidden}.sk-hdr{display:flex;align-items:center;gap:9px;padding:11px 14px;background:var(--panel2);border-bottom:1px solid var(--line)}.sk-list{padding:10px}.sk-item{display:flex;gap:8px;padding:8px 10px;border-radius:7px;font-size:12px;margin-bottom:3px;cursor:pointer;border:1px solid transparent;transition:all .12s}.sk-item:hover{background:var(--panel2);border-color:var(--line)}.sess-filters{display:flex;gap:8px;margin-bottom:14px;flex-wrap:wrap;align-items:center}.sess-filter{font-size:11px;padding:4px 10px;border-radius:999px;border:1px solid var(--line);background:var(--panel);color:var(--muted);cursor:pointer;transition:all .12s}.sess-filter:hover{border-color:var(--acc);color:var(--text)}.sess-filter.active{border-color:var(--acc);color:var(--acc);background:#0a1228}.sess-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(340px,1fr));gap:10px}.sess-card{background:var(--panel);border:1px solid var(--line);border-radius:12px;padding:14px;transition:border-color .12s;cursor:pointer}.sess-card:hover{border-color:#2e3d6a}.off-activity{display:flex;align-items:center;gap:8px;padding:8px 14px;background:#0a1228;border:1px solid #1a2a4a;border-radius:10px;margin-bottom:14px;font-size:12px;flex-wrap:wrap}.off-kpi{display:grid;grid-template-columns:repeat(4,1fr);gap:10px;margin-bottom:16px}.kpi{background:var(--panel);border:1px solid var(--line);border-radius:12px;padding:14px 16px}.kpi-v{font-size:24px;font-weight:800;margin-bottom:3px}.kpi-l{font-size:11px;color:var(--muted)}.off-layout{display:grid;grid-template-columns:260px 1fr;gap:14px}@media(max-width:700px){.off-layout{grid-template-columns:1fr}.off-kpi{grid-template-columns:repeat(2,1fr)}}.off-ranklist{background:var(--panel);border:1px solid var(--line);border-radius:14px;overflow:hidden}.orl-hdr{padding:10px 14px;background:var(--panel2);border-bottom:1px solid var(--line);font-size:11px;font-weight:700;color:var(--muted);letter-spacing:.06em;text-transform:uppercase}.orl-item{display:flex;align-items:center;gap:10px;padding:10px 14px;cursor:pointer;border-bottom:1px solid var(--line);transition:background .1s}.orl-item:last-child{border-bottom:none}.orl-item:hover{background:var(--panel2)}.orl-item.selected{background:#0a1228;border-left:3px solid var(--acc)}.off-detail{background:var(--panel);border:1px solid var(--line);border-radius:14px;padding:22px;min-height:400px}.mem-list{display:flex;flex-direction:column;gap:8px}.mem-card{display:flex;gap:14px;align-items:flex-start;background:var(--panel);border:1px solid var(--line);border-radius:12px;padding:14px 16px;cursor:pointer;transition:border-color .12s}.mem-card:hover{border-color:var(--acc)}.tpl-cats{display:flex;gap:8px;flex-wrap:wrap;margin-bottom:14px}.tpl-cat{font-size:12px;padding:6px 14px;border-radius:999px;border:1px solid var(--line);background:var(--panel);color:var(--muted);cursor:pointer;transition:all .12s}.tpl-cat:hover{border-color:var(--acc);color:var(--text)}.tpl-cat.active{border-color:var(--acc);color:var(--acc);background:#0a1228}.tpl-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(300px,1fr));gap:10px}.tpl-card{background:var(--panel);border:1px solid var(--line);border-radius:12px;padding:16px;transition:border-color .12s;cursor:pointer;display:flex;flex-direction:column}.tpl-card:hover{border-color:var(--acc)}.mb-hdr{display:flex;align-items:flex-start;justify-content:space-between;margin-bottom:18px;flex-wrap:wrap;gap:10px}.mb-title{font-size:20px;font-weight:800;background:linear-gradient(135deg,#f5c842,#ff9a4a);-webkit-background-clip:text;-webkit-text-fill-color:transparent}.mb-sub{font-size:12px;color:var(--muted);margin-top:3px}.mb-cats{display:grid;grid-template-columns:repeat(auto-fill,minmax(320px,1fr));gap:16px}.mb-cat{background:var(--panel);border:1px solid var(--line);border-radius:14px;overflow:hidden}.mb-cat-hdr{display:flex;align-items:center;gap:8px;padding:10px 16px;border-bottom:1px solid var(--line)}.mb-news-list{padding:10px}.mb-card{display:flex;gap:12px;padding:10px 8px;border-radius:10px;margin-bottom:6px;cursor:pointer;transition:background .12s;border-bottom:1px solid var(--line)}.mb-card:last-child{border-bottom:none}.mb-card:hover{background:var(--panel2)}.ceremony-bg{position:fixed;top:0;right:0;bottom:0;left:0;z-index:9999;background:#07090f;display:flex;flex-direction:column;align-items:center;justify-content:center;opacity:0;animation:crmFadeIn .6s ease forwards;cursor:pointer}.ceremony-bg.out{animation:crmFadeOut .5s ease forwards}.crm-glow{position:absolute;width:400px;height:400px;border-radius:50%;background:radial-gradient(circle,rgba(106,158,255,.08),transparent 70%);animation:crmPulse 3s ease-in-out infinite}.crm-line1{font-family:"Noto Serif SC",serif;font-size:52px;font-weight:900;color:#dde4f8;letter-spacing:.15em;opacity:0;transform:translateY(20px)}.crm-line2{font-family:"Noto Serif SC",serif;font-size:22px;font-weight:700;color:var(--acc);letter-spacing:.2em;margin-top:12px;opacity:0;transform:translateY(15px)}.crm-line3{font-size:14px;color:var(--muted);margin-top:24px;opacity:0;letter-spacing:.05em}.crm-date{font-size:12px;color:#2a3555;margin-top:40px;opacity:0;letter-spacing:.08em}.crm-skip{font-size:11px;color:#2a3555;margin-top:18px;opacity:0;animation:crmChar .4s 2.5s forwards}.crm-line1.in{animation:crmSlideUp .6s .3s ease forwards}.crm-line2.in{animation:crmSlideUp .5s 1.1s ease forwards}.crm-line3.in{animation:crmSlideUp .5s 1.6s ease forwards}.crm-date.in{animation:crmChar .4s 2s ease forwards}@keyframes crmFadeIn{to{opacity:1}}@keyframes crmFadeOut{to{opacity:0;pointer-events:none}}@keyframes crmSlideUp{to{opacity:1;transform:translateY(0)}}@keyframes crmChar{to{opacity:1}}@keyframes crmPulse{0%,to{transform:scale(1);opacity:.5}50%{transform:scale(1.1);opacity:.8}}.confirm-bg{position:fixed;top:0;right:0;bottom:0;left:0;background:#000000b3;z-index:200;-webkit-backdrop-filter:blur(3px);backdrop-filter:blur(3px);display:flex;align-items:center;justify-content:center}.confirm-box{background:var(--panel);border:1px solid var(--line);border-radius:14px;padding:24px;max-width:420px;width:90%;box-shadow:0 20px 60px #0009}.confirm-title{font-size:16px;font-weight:700;margin-bottom:8px}.confirm-msg{font-size:13px;color:var(--muted);margin-bottom:14px;line-height:1.5}.confirm-input{width:100%;background:var(--panel2);border:1px solid var(--line);border-radius:7px;color:var(--text);padding:8px 10px;font-size:12px;outline:none;margin-bottom:14px}.confirm-input:focus{border-color:var(--acc)}.confirm-btns{display:flex;gap:8px;justify-content:flex-end}.toaster{position:fixed;bottom:20px;right:20px;display:flex;flex-direction:column;gap:8px;z-index:300;pointer-events:none}.toast{font-size:13px;padding:10px 16px;border-radius:10px;border:1px solid var(--line);background:var(--panel);color:var(--text);box-shadow:0 4px 20px #0006;animation:tin .2s;max-width:320px;pointer-events:auto}.toast.ok{border-color:#2ecc8a55;background:#0a1a10}.toast.err{border-color:#ff527055;background:#200a10}@keyframes tin{0%{transform:translate(40px);opacity:0}to{transform:translate(0);opacity:1}}.sub-config{background:var(--panel);border:1px solid var(--line);border-radius:14px;padding:18px;margin-bottom:18px}.sub-section{margin-bottom:16px;padding-bottom:14px;border-bottom:1px solid var(--line)}.sub-section:last-child{border-bottom:none;margin-bottom:0;padding-bottom:0}.sub-sec-title{font-size:13px;font-weight:700;margin-bottom:10px}.sub-input{background:var(--panel2);border:1px solid var(--line);border-radius:7px;color:var(--text);padding:7px 10px;font-size:12px;outline:none;min-width:0}.sub-input:focus{border-color:var(--acc)}.si-name{font-weight:600;min-width:100px}.si-desc{color:var(--muted);flex:1;line-height:1.4}.si-arrow{color:var(--muted);font-size:14px;opacity:.3;transition:opacity .12s}.sk-item:hover .si-arrow{opacity:1}.sk-emoji{font-size:18px}.sk-name{font-size:14px;font-weight:700}.sk-cnt{font-size:11px;color:var(--muted);margin-left:auto}.sk-empty{font-size:12px;color:var(--muted);padding:12px;text-align:center;opacity:.6}.sk-add{display:flex;align-items:center;justify-content:center;gap:6px;padding:8px;font-size:12px;color:var(--acc);cursor:pointer;border-top:1px solid var(--line);transition:background .12s}.sk-add:hover{background:var(--panel2)}.sk-modal-body{max-height:70vh;overflow-y:auto}.sk-md{font-size:13px;line-height:1.7;color:var(--text)}.sk-md h1,.sk-md h2,.sk-md h3{margin:16px 0 8px;color:var(--text)}.sk-md h1{font-size:18px}.sk-md h2{font-size:15px;border-bottom:1px solid var(--line);padding-bottom:6px}.sk-md h3{font-size:13px}.sk-md p{margin:6px 0}.sk-md ul,.sk-md ol{padding-left:20px;margin:6px 0}.sk-md li{margin:3px 0}.sk-md code{font-size:11px;background:var(--panel2);padding:2px 6px;border-radius:4px;font-family:monospace}.sk-md pre{background:var(--panel2);border:1px solid var(--line);border-radius:8px;padding:12px;overflow-x:auto;margin:8px 0}.sk-md pre code{background:none;padding:0}.sk-md table{width:100%;border-collapse:collapse;font-size:12px;margin:8px 0}.sk-md th,.sk-md td{padding:6px 10px;border:1px solid var(--line);text-align:left}.sk-md th{background:var(--panel2)}.sk-md hr{border:none;border-top:1px solid var(--line);margin:14px 0}.sk-path{font-size:10px;color:var(--muted);padding:8px 0;word-break:break-all;border-top:1px solid var(--line);margin-top:12px}.sc-top{display:flex;align-items:center;gap:10px;margin-bottom:8px}.sc-emoji{font-size:20px}.sc-agent{font-size:13px;font-weight:700}.sc-org{font-size:11px;color:var(--muted)}.sc-title{font-size:13px;font-weight:600;margin-bottom:6px;line-height:1.4}.sc-now{font-size:11px;color:var(--muted);line-height:1.5;margin-bottom:6px}.sc-meta{display:flex;align-items:center;gap:6px;flex-wrap:wrap}.sc-id{font-size:10px;color:var(--acc);font-weight:600}.sc-time{font-size:10px;color:var(--muted);margin-left:auto}.mc-st{font-size:11px;margin-top:6px;padding:4px 8px;border-radius:5px;display:none}.mc-st.ok{display:block;background:#0a2018;color:var(--ok);border:1px solid #2ecc8a44}.mc-st.err{display:block;background:#200a10;color:var(--danger);border:1px solid #ff527044}.mc-st.pending{display:block;background:#0a1228;color:var(--acc);border:1px solid #6a9eff44}.cl-t{color:var(--muted);min-width:115px}.cl-a{color:var(--acc);min-width:80px}.cl-c{color:var(--muted)}.cl-c b{color:var(--text)}.cl-list{display:flex;flex-direction:column}.mem-icon{font-size:28px;flex-shrink:0;margin-top:2px}.mem-info{flex:1;min-width:0}.mem-title{font-size:14px;font-weight:700;margin-bottom:4px}.mem-sub{font-size:11px;color:var(--muted);line-height:1.5}.mem-tags{display:flex;gap:4px;flex-wrap:wrap;margin-top:6px}.mem-tag{font-size:10px;padding:2px 8px;border-radius:4px;background:var(--panel2);color:var(--muted);border:1px solid var(--line)}.mem-right{display:flex;flex-direction:column;align-items:flex-end;gap:4px;flex-shrink:0}.mem-date{font-size:10px;color:var(--muted)}.mem-cost{font-size:10px;color:var(--acc)}.mem-empty{text-align:center;padding:40px;color:var(--muted);font-size:13px}.md-timeline{position:relative;padding-left:24px;margin:16px 0}.md-timeline:before{content:"";position:absolute;left:7px;top:0;bottom:0;width:2px;background:var(--line)}.md-tl-item{position:relative;margin-bottom:14px;padding-bottom:14px;border-bottom:1px solid var(--line)}.md-tl-item:last-child{border-bottom:none;margin-bottom:0;padding-bottom:0}.md-tl-dot{position:absolute;left:-20px;top:3px;width:10px;height:10px;border-radius:50%;background:var(--acc);border:2px solid var(--bg)}.md-tl-dot.green{background:var(--ok)}.md-tl-dot.yellow{background:var(--warn)}.md-tl-dot.red{background:var(--danger)}.md-tl-from{font-size:11px;font-weight:700;color:var(--acc)}.md-tl-to{font-size:11px;color:var(--muted)}.md-tl-remark{font-size:12px;margin-top:3px;line-height:1.5}.md-tl-time{font-size:10px;color:var(--muted);margin-top:2px}.tpl-top{display:flex;align-items:center;gap:10px;margin-bottom:10px}.tpl-icon{font-size:24px}.tpl-name{font-size:14px;font-weight:700}.tpl-pop{font-size:10px;color:var(--muted);margin-left:auto}.tpl-desc{font-size:12px;color:var(--muted);line-height:1.5;margin-bottom:10px;flex:1}.tpl-footer{display:flex;align-items:center;gap:6px;flex-wrap:wrap}.tpl-dept{font-size:10px;padding:2px 6px;border-radius:4px;background:var(--panel2);color:var(--acc)}.tpl-est{font-size:10px;color:var(--muted);margin-left:auto}.tpl-go{font-size:11px;padding:5px 14px;border-radius:6px;background:var(--acc);color:#fff;border:none;cursor:pointer;font-weight:600;margin-left:8px;transition:opacity .12s}.tpl-go:hover{opacity:.85}.tpl-form{margin-top:18px}.tpl-field{margin-bottom:14px}.tpl-label{font-size:12px;font-weight:600;display:block;margin-bottom:6px}.tpl-input{width:100%;padding:10px 12px;background:var(--bg);border:1px solid var(--line);border-radius:8px;color:var(--text);font-size:13px;outline:none}.mb-img{width:72px;height:52px;border-radius:7px;-o-object-fit:cover;object-fit:cover;flex-shrink:0;background:var(--panel2);display:flex;align-items:center;justify-content:center;font-size:22px;overflow:hidden}.mb-img img{width:100%;height:100%;-o-object-fit:cover;object-fit:cover;border-radius:7px}.mb-info{flex:1;min-width:0}.mb-headline{font-size:13px;font-weight:700;line-height:1.4;margin-bottom:4px;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}.mb-summary{font-size:11px;color:var(--muted);line-height:1.5;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}.mb-meta{display:flex;align-items:center;gap:8px;margin-top:5px}.mb-source{font-size:10px;color:var(--acc)}.mb-time{font-size:10px;color:var(--muted)}.mb-cat-icon{font-size:20px}.mb-cat-name{font-size:14px;font-weight:800}.mb-cat-cnt{font-size:11px;color:var(--muted);margin-left:auto}.mb-empty{text-align:center;padding:30px;color:var(--muted);font-size:13px}.mb-loading{display:flex;align-items:center;justify-content:center;padding:60px;color:var(--muted);font-size:14px;gap:10px}.la-dot{display:inline-block;width:6px;height:6px;border-radius:50%;background:var(--ok);margin-right:4px;animation:pulse 1.5s infinite}.la-dot.idle{background:var(--muted);animation:none}.la-agent{font-size:11px;color:var(--muted)}.la-icon{flex-shrink:0;font-size:13px;margin-top:1px}.la-body{flex:1;min-width:0}.la-time{font-size:10px;color:var(--muted);flex-shrink:0;min-width:44px;text-align:right}.la-assistant{color:var(--text)}.la-thinking{color:#a07aff;font-style:italic;opacity:.75}.la-tool{color:#4af}.la-tool-result{color:var(--muted);font-size:11px}.la-tool-result.ok{color:var(--ok)}.la-tool-result.err{color:var(--danger)}.la-user{color:var(--warn)}.la-tool-name{font-weight:700;margin-right:4px}.la-trunc{color:var(--muted);font-size:10px;opacity:.6}.la-flow-wrap{display:flex;flex-direction:column;gap:6px}.la-groups{display:flex;flex-direction:column;gap:8px;margin-top:4px}.la-group{border:1px solid var(--line);border-radius:8px;background:var(--panel)}.la-group-hd{display:flex;align-items:center;justify-content:space-between;padding:6px 10px;border-bottom:1px solid var(--line);font-size:11px;color:var(--muted)}.la-group-hd .name{font-weight:700;color:var(--text)}.la-group-bd{display:flex;flex-direction:column;gap:4px;padding:6px}.sched-status{font-size:10px;color:var(--muted)}.sched-line{font-size:11px;color:var(--muted);display:flex;gap:12px;flex-wrap:wrap;margin-bottom:10px}.sched-actions{display:flex;gap:6px;flex-wrap:wrap}.sched-btn.warn:hover{border-color:#f5c842;color:#f5c842}.sched-btn.danger:hover{border-color:#ff5270;color:#ff5270}.btn-cancel{background:#8882;color:#888;border:1px solid #88888844}.btn-cancel:hover{background:#8884}.btn-action:disabled{opacity:.4;cursor:not-allowed}.todo-detail{display:none;padding:4px 10px 10px 36px;font-size:11px;line-height:1.6;color:var(--text);white-space:pre-wrap;word-break:break-word;border-top:1px solid var(--line);margin:0 6px;opacity:.85}.todo-item.expanded .todo-detail{display:block}.todo-item .t-expand{color:var(--muted);font-size:10px;transition:transform .2s;flex-shrink:0}.todo-item.expanded .t-expand{transform:rotate(90deg)}.todo-item .t-id{color:var(--muted);font-size:10px;min-width:20px}.todo-item.has-detail .t-row{cursor:pointer}.act-label{color:var(--muted);flex-shrink:0}.act-dot{display:inline-flex;align-items:center;gap:5px;padding:3px 8px;border-radius:999px;background:#0f1a38;border:1px solid #1e2e50;margin:2px}.act-dot.alive{border-color:#2ecc8a44;background:#0a2018;color:var(--ok)}.act-dot.warn{border-color:#f5c84244;background:#201a08;color:var(--warn)}.act-dot.idle{color:var(--muted)}.orl-medal{font-size:16px;min-width:20px;text-align:center}.orl-emoji{font-size:18px}.orl-name{flex:1}.orl-role{font-size:12px;font-weight:700}.orl-org{font-size:10px;color:var(--muted)}.orl-score{font-size:11px;font-weight:700;color:var(--acc)}.orl-hbdot{width:8px;height:8px;border-radius:50%;flex-shrink:0}.orl-hbdot.active{background:var(--ok)}.orl-hbdot.warn{background:var(--warn)}.orl-hbdot.stalled{background:var(--danger);animation:pulse 1.2s infinite}.orl-hbdot.idle{background:#2a3a5a}.od-empty{display:flex;align-items:center;justify-content:center;height:100%;color:var(--muted);font-size:13px;min-height:200px}.od-hero{display:flex;align-items:center;gap:16px;margin-bottom:20px;padding-bottom:16px;border-bottom:1px solid var(--line)}.od-emoji{font-size:40px}.od-name{font-size:22px;font-weight:800}.od-role{font-size:13px;color:var(--muted);margin-top:2px}.od-rank-badge{font-size:11px;padding:3px 9px;border-radius:999px;border:1px solid #f5c84244;color:#f5c842;background:#201a08;margin-top:4px;display:inline-block}.od-hb{margin-left:auto;text-align:right}.od-section{margin-bottom:18px}.od-sec-title{font-size:10px;font-weight:700;color:var(--muted);letter-spacing:.07em;text-transform:uppercase;margin-bottom:10px}.od-stats{display:grid;grid-template-columns:repeat(3,1fr);gap:8px}.ods{background:var(--panel2);border-radius:8px;padding:10px;text-align:center}.ods-v{font-size:20px;font-weight:800}.ods-l{font-size:10px;color:var(--muted);margin-top:2px}.tbar{margin-bottom:7px}.tbar-hdr{display:flex;justify-content:space-between;font-size:11px;margin-bottom:3px}.tbar-label{color:var(--muted)}.tbar-val{font-weight:600}.tbar-track{height:6px;background:#0e1320;border-radius:3px;overflow:hidden}.tbar-fill{height:100%;border-radius:3px}.od-cost-row{display:flex;gap:10px;flex-wrap:wrap}.cost-chip{font-size:12px;padding:5px 12px;border-radius:8px;border:1px solid var(--line);background:var(--panel2)}.cost-chip b{font-size:15px}.cost-chip.hi{border-color:#ff527044}.cost-chip.md{border-color:#f5c84244}.cost-chip.lo{border-color:#2ecc8a44}.od-edict-list{display:flex;flex-direction:column;gap:5px}.oe-item{display:flex;align-items:center;gap:8px;padding:7px 10px;background:var(--panel2);border-radius:7px;font-size:12px;cursor:pointer}.oe-item:hover{background:#141c30}.oe-id{font-size:10px;color:var(--acc);font-weight:700;min-width:110px}.oe-title{flex:1;color:var(--text)}.oe-state{font-size:10px}.kpi-v.gold{color:#f5c842}.kpi-v.green{color:var(--ok)}.kpi-v.blue{color:var(--acc)}.kpi-v.warn{color:var(--warn)}.sub-cats{display:flex;flex-wrap:wrap;gap:8px}.sub-cat{display:flex;align-items:center;gap:6px;padding:7px 12px;border-radius:8px;border:1px solid var(--line);background:var(--panel2);cursor:pointer;transition:all .15s;-webkit-user-select:none;-moz-user-select:none;user-select:none}.sub-cat:hover{border-color:var(--acc)}.sub-cat.active{border-color:var(--ok);background:#0a2018}.sub-cat .sc-check{width:16px;height:16px;border-radius:4px;border:1px solid var(--line);display:flex;align-items:center;justify-content:center;font-size:10px;transition:all .15s}.sub-cat.active .sc-check{background:var(--ok);border-color:var(--ok);color:#000}.sub-cat .sc-label{font-size:12px;font-weight:600}.sub-cat .sc-count{font-size:10px;color:var(--muted)}.sub-kw-list{display:flex;flex-wrap:wrap;gap:6px}.sub-kw{display:flex;align-items:center;gap:4px;padding:4px 8px 4px 10px;border-radius:999px;background:#0f1a38;border:1px solid #1e2e50;font-size:11px;color:var(--acc)}.sub-kw .kw-del{cursor:pointer;opacity:.5;font-size:13px;padding:0 2px}.sub-kw .kw-del:hover{opacity:1;color:var(--danger)}.sub-feed-list{display:flex;flex-direction:column;gap:4px}.sub-feed{display:flex;align-items:center;gap:8px;padding:6px 10px;background:var(--panel2);border-radius:7px;font-size:12px}.sub-feed .sf-name{font-weight:600;min-width:80px;color:var(--acc)}.sub-feed .sf-url{flex:1;color:var(--muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.sub-feed .sf-cat{font-size:10px;padding:2px 6px;border-radius:4px;border:1px solid var(--line)}.sub-feed .sf-del{cursor:pointer;color:var(--muted);font-size:14px}.sub-feed .sf-del:hover{color:var(--danger)}.as-card .as-emoji{font-size:22px;margin-bottom:3px}.as-card .as-label{font-size:12px;font-weight:700}.as-card .as-role{font-size:10px;color:var(--muted)}.as-card .as-status{font-size:10px;margin-top:4px}.as-card .as-time{font-size:9px;color:var(--muted);margin-top:2px}.as-wake-btn:disabled{opacity:.4;cursor:not-allowed}.as-refresh{font-size:11px;padding:4px 12px;border-radius:8px;border:1px solid var(--line);color:var(--muted);background:transparent;cursor:pointer;transition:background .15s}.as-refresh:hover{background:var(--panel2);color:var(--text)}.as-wake-all{font-size:11px;padding:4px 12px;border-radius:8px;border:1px solid var(--warn);color:var(--warn);background:transparent;cursor:pointer;transition:background .15s;margin-left:6px}.as-wake-all:hover{background:var(--warn);color:#fff}.as-summary span{display:flex;align-items:center;gap:4px}.archive-bar .ab-archive-all{font-size:11px;padding:4px 12px;border-radius:6px;border:1px solid #2ecc8a44;background:transparent;cursor:pointer;color:var(--ok);font-weight:600;transition:all .15s}.archive-bar .ab-archive-all:hover{background:#0a2018;border-color:var(--ok)}.archive-bar .ab-scan-detail{font-size:11px;padding:4px 10px;border-radius:6px;border:1px solid var(--line);background:transparent;cursor:pointer;color:var(--muted);font-weight:600;transition:all .15s}.archive-bar .ab-scan-detail:hover{border-color:var(--acc);color:var(--text)}.archive-bar .ab-scan-detail.active{border-color:var(--acc);color:var(--acc);background:#0f1a38}.archive-bar .ab-scan-copy{font-size:11px;padding:4px 10px;border-radius:6px;border:1px solid #2ecc8a44;background:transparent;cursor:pointer;color:var(--ok);font-weight:600;transition:all .15s}.archive-bar .ab-scan-copy:hover{background:#0a2018;border-color:var(--ok)}.global-scan-detail{display:none;margin-top:-4px;margin-bottom:12px;background:var(--panel2);border:1px solid var(--line);border-radius:10px;padding:10px 12px}.global-scan-detail.open{display:block}.global-scan-detail .gs-empty{font-size:11px;color:var(--muted)}.global-scan-detail .gs-list{display:flex;flex-direction:column;gap:6px}.global-scan-detail .gs-item{display:flex;align-items:center;gap:8px;padding:6px 8px;border-radius:8px;background:var(--panel);border:1px solid var(--line);font-size:11px}.global-scan-detail .gs-tag{font-size:10px;border-radius:10px;padding:2px 8px;font-weight:700;border:1px solid var(--line);color:var(--muted)}.global-scan-detail .gs-tag.retry{color:var(--acc);border-color:#6a9eff55}.global-scan-detail .gs-tag.escalate{color:#f5c842;border-color:#f5c84255}.global-scan-detail .gs-tag.rollback{color:#ff5270;border-color:#ff527055}.global-scan-detail .gs-task{font-weight:700;color:var(--text)}.global-scan-detail .gs-meta{color:var(--muted)}.global-scan-detail .gs-hint{margin-top:8px;font-size:10px;color:var(--muted)}.confirm-reason{width:100%;background:var(--panel2);border:1px solid var(--line);border-radius:7px;color:var(--text);padding:8px 10px;font-size:12px;outline:none;margin-bottom:14px;resize:vertical;min-height:60px}.confirm-reason:focus{border-color:var(--acc)}.empty{text-align:center;padding:40px 20px;color:var(--muted);font-size:13px}.sec-title{font-size:12px;font-weight:700;color:var(--muted);letter-spacing:.07em;text-transform:uppercase;margin-bottom:12px}code{font-size:11px;background:var(--panel2);padding:2px 6px;border-radius:4px;font-family:monospace} diff --git a/dashboard/dist/assets/index-CqMbmm5B.js b/dashboard/dist/assets/index-CqMbmm5B.js deleted file mode 100644 index d0a0215..0000000 --- a/dashboard/dist/assets/index-CqMbmm5B.js +++ /dev/null @@ -1,84 +0,0 @@ -(function(){const p=document.createElement("link").relList;if(p&&p.supports&&p.supports("modulepreload"))return;for(const S of document.querySelectorAll('link[rel="modulepreload"]'))k(S);new MutationObserver(S=>{for(const D of S)if(D.type==="childList")for(const F of D.addedNodes)F.tagName==="LINK"&&F.rel==="modulepreload"&&k(F)}).observe(document,{childList:!0,subtree:!0});function u(S){const D={};return S.integrity&&(D.integrity=S.integrity),S.referrerPolicy&&(D.referrerPolicy=S.referrerPolicy),S.crossOrigin==="use-credentials"?D.credentials="include":S.crossOrigin==="anonymous"?D.credentials="omit":D.credentials="same-origin",D}function k(S){if(S.ep)return;S.ep=!0;const D=u(S);fetch(S.href,D)}})();function Qi(o){return o&&o.__esModule&&Object.prototype.hasOwnProperty.call(o,"default")?o.default:o}var Mi={exports:{}},Cr={},Ai={exports:{}},de={};/** - * @license React - * react.production.min.js - * - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var Hu;function df(){if(Hu)return de;Hu=1;var o=Symbol.for("react.element"),p=Symbol.for("react.portal"),u=Symbol.for("react.fragment"),k=Symbol.for("react.strict_mode"),S=Symbol.for("react.profiler"),D=Symbol.for("react.provider"),F=Symbol.for("react.context"),_=Symbol.for("react.forward_ref"),R=Symbol.for("react.suspense"),C=Symbol.for("react.memo"),z=Symbol.for("react.lazy"),d=Symbol.iterator;function w(v){return v===null||typeof v!="object"?null:(v=d&&v[d]||v["@@iterator"],typeof v=="function"?v:null)}var m={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},T=Object.assign,g={};function M(v,L,ae){this.props=v,this.context=L,this.refs=g,this.updater=ae||m}M.prototype.isReactComponent={},M.prototype.setState=function(v,L){if(typeof v!="object"&&typeof v!="function"&&v!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,v,L,"setState")},M.prototype.forceUpdate=function(v){this.updater.enqueueForceUpdate(this,v,"forceUpdate")};function P(){}P.prototype=M.prototype;function B(v,L,ae){this.props=v,this.context=L,this.refs=g,this.updater=ae||m}var Z=B.prototype=new P;Z.constructor=B,T(Z,M.prototype),Z.isPureReactComponent=!0;var I=Array.isArray,oe=Object.prototype.hasOwnProperty,ue={current:null},pe={key:!0,ref:!0,__self:!0,__source:!0};function me(v,L,ae){var ce,x={},U=null,ee=null;if(L!=null)for(ce in L.ref!==void 0&&(ee=L.ref),L.key!==void 0&&(U=""+L.key),L)oe.call(L,ce)&&!pe.hasOwnProperty(ce)&&(x[ce]=L[ce]);var he=arguments.length-2;if(he===1)x.children=ae;else if(1>>1,L=E[v];if(0>>1;vS(x,W))US(ee,x)?(E[v]=ee,E[U]=W,v=U):(E[v]=x,E[ce]=W,v=ce);else if(US(ee,W))E[v]=ee,E[U]=W,v=U;else break e}}return Q}function S(E,Q){var W=E.sortIndex-Q.sortIndex;return W!==0?W:E.id-Q.id}if(typeof performance=="object"&&typeof performance.now=="function"){var D=performance;o.unstable_now=function(){return D.now()}}else{var F=Date,_=F.now();o.unstable_now=function(){return F.now()-_}}var R=[],C=[],z=1,d=null,w=3,m=!1,T=!1,g=!1,M=typeof setTimeout=="function"?setTimeout:null,P=typeof clearTimeout=="function"?clearTimeout:null,B=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function Z(E){for(var Q=u(C);Q!==null;){if(Q.callback===null)k(C);else if(Q.startTime<=E)k(C),Q.sortIndex=Q.expirationTime,p(R,Q);else break;Q=u(C)}}function I(E){if(g=!1,Z(E),!T)if(u(R)!==null)T=!0,_e(oe);else{var Q=u(C);Q!==null&&xe(I,Q.startTime-E)}}function oe(E,Q){T=!1,g&&(g=!1,P(me),me=-1),m=!0;var W=w;try{for(Z(Q),d=u(R);d!==null&&(!(d.expirationTime>Q)||E&&!le());){var v=d.callback;if(typeof v=="function"){d.callback=null,w=d.priorityLevel;var L=v(d.expirationTime<=Q);Q=o.unstable_now(),typeof L=="function"?d.callback=L:d===u(R)&&k(R),Z(Q)}else k(R);d=u(R)}if(d!==null)var ae=!0;else{var ce=u(C);ce!==null&&xe(I,ce.startTime-Q),ae=!1}return ae}finally{d=null,w=W,m=!1}}var ue=!1,pe=null,me=-1,be=5,X=-1;function le(){return!(o.unstable_now()-XE||125v?(E.sortIndex=W,p(C,E),u(R)===null&&E===u(C)&&(g?(P(me),me=-1):g=!0,xe(I,W-v))):(E.sortIndex=L,p(R,E),T||m||(T=!0,_e(oe))),E},o.unstable_shouldYield=le,o.unstable_wrapCallback=function(E){var Q=w;return function(){var W=w;w=Q;try{return E.apply(this,arguments)}finally{w=W}}}})($i)),$i}var Yu;function hf(){return Yu||(Yu=1,bi.exports=mf()),bi.exports}/** - * @license React - * react-dom.production.min.js - * - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var Xu;function vf(){if(Xu)return nt;Xu=1;var o=_r(),p=hf();function u(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),R=Object.prototype.hasOwnProperty,C=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,z={},d={};function w(e){return R.call(d,e)?!0:R.call(z,e)?!1:C.test(e)?d[e]=!0:(z[e]=!0,!1)}function m(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function T(e,t,n,r){if(t===null||typeof t>"u"||m(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function g(e,t,n,r,s,i,a){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=s,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=i,this.removeEmptyString=a}var M={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){M[e]=new g(e,0,!1,e,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];M[t]=new g(t,1,!1,e[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(e){M[e]=new g(e,2,!1,e.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){M[e]=new g(e,2,!1,e,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){M[e]=new g(e,3,!1,e.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(e){M[e]=new g(e,3,!0,e,null,!1,!1)}),["capture","download"].forEach(function(e){M[e]=new g(e,4,!1,e,null,!1,!1)}),["cols","rows","size","span"].forEach(function(e){M[e]=new g(e,6,!1,e,null,!1,!1)}),["rowSpan","start"].forEach(function(e){M[e]=new g(e,5,!1,e.toLowerCase(),null,!1,!1)});var P=/[\-:]([a-z])/g;function B(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(P,B);M[t]=new g(t,1,!1,e,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(P,B);M[t]=new g(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(P,B);M[t]=new g(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(e){M[e]=new g(e,1,!1,e.toLowerCase(),null,!1,!1)}),M.xlinkHref=new g("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(e){M[e]=new g(e,1,!1,e.toLowerCase(),null,!0,!0)});function Z(e,t,n,r){var s=M.hasOwnProperty(t)?M[t]:null;(s!==null?s.type!==0:r||!(2c||s[a]!==i[c]){var f=` -`+s[a].replace(" at new "," at ");return e.displayName&&f.includes("")&&(f=f.replace("",e.displayName)),f}while(1<=a&&0<=c);break}}}finally{ae=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?L(e):""}function x(e){switch(e.tag){case 5:return L(e.type);case 16:return L("Lazy");case 13:return L("Suspense");case 19:return L("SuspenseList");case 0:case 2:case 15:return e=ce(e.type,!1),e;case 11:return e=ce(e.type.render,!1),e;case 1:return e=ce(e.type,!0),e;default:return""}}function U(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case pe:return"Fragment";case ue:return"Portal";case be:return"Profiler";case me:return"StrictMode";case se:return"Suspense";case J:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case le:return(e.displayName||"Context")+".Consumer";case X:return(e._context.displayName||"Context")+".Provider";case ke:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Ne:return t=e.displayName||null,t!==null?t:U(e.type)||"Memo";case _e:t=e._payload,e=e._init;try{return U(e(t))}catch{}}return null}function ee(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return U(t);case 8:return t===me?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function he(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function ve(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function Me(e){var t=ve(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var s=n.get,i=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return s.call(this)},set:function(a){r=""+a,i.call(this,a)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(a){r=""+a},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function mn(e){e._valueTracker||(e._valueTracker=Me(e))}function Yi(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=ve(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function Tr(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function Wl(e,t){var n=t.checked;return W({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function Xi(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=he(t.value!=null?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function Zi(e,t){t=t.checked,t!=null&&Z(e,"checked",t,!1)}function Ul(e,t){Zi(e,t);var n=he(t.value),r=t.type;if(n!=null)r==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?Hl(e,t.type,n):t.hasOwnProperty("defaultValue")&&Hl(e,t.type,he(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function qi(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!(r!=="submit"&&r!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}function Hl(e,t,n){(t!=="number"||Tr(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var Fn=Array.isArray;function hn(e,t,n,r){if(e=e.options,t){t={};for(var s=0;s"+t.valueOf().toString()+"",t=Lr.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Bn(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Wn={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},mc=["Webkit","ms","Moz","O"];Object.keys(Wn).forEach(function(e){mc.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Wn[t]=Wn[e]})});function lo(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||Wn.hasOwnProperty(e)&&Wn[e]?(""+t).trim():t+"px"}function so(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,s=lo(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,s):e[n]=s}}var hc=W({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Kl(e,t){if(t){if(hc[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(u(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(u(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(u(61))}if(t.style!=null&&typeof t.style!="object")throw Error(u(62))}}function Gl(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Yl=null;function Xl(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Zl=null,vn=null,gn=null;function io(e){if(e=cr(e)){if(typeof Zl!="function")throw Error(u(280));var t=e.stateNode;t&&(t=Jr(t),Zl(e.stateNode,e.type,t))}}function oo(e){vn?gn?gn.push(e):gn=[e]:vn=e}function ao(){if(vn){var e=vn,t=gn;if(gn=vn=null,io(e),t)for(e=0;e>>=0,e===0?32:31-(Ec(e)/_c|0)|0}var Mr=64,Ar=4194304;function Qn(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function Or(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,s=e.suspendedLanes,i=e.pingedLanes,a=n&268435455;if(a!==0){var c=a&~s;c!==0?r=Qn(c):(i&=a,i!==0&&(r=Qn(i)))}else a=n&~s,a!==0?r=Qn(a):i!==0&&(r=Qn(i));if(r===0)return 0;if(t!==0&&t!==r&&(t&s)===0&&(s=r&-r,i=t&-t,s>=i||s===16&&(i&4194240)!==0))return t;if((r&4)!==0&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0n;n++)t.push(e);return t}function Kn(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-pt(t),e[t]=n}function Rc(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0=tr),Oo=" ",bo=!1;function $o(e,t){switch(e){case"keyup":return sd.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Fo(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var kn=!1;function od(e,t){switch(e){case"compositionend":return Fo(t);case"keypress":return t.which!==32?null:(bo=!0,Oo);case"textInput":return e=t.data,e===Oo&&bo?null:e;default:return null}}function ad(e,t){if(kn)return e==="compositionend"||!hs&&$o(e,t)?(e=Ro(),Wr=us=bt=null,kn=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:n,offset:t-e};e=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=Ko(n)}}function Yo(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Yo(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Xo(){for(var e=window,t=Tr();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=Tr(e.document)}return t}function ys(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}function gd(e){var t=Xo(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&Yo(n.ownerDocument.documentElement,n)){if(r!==null&&ys(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var s=n.textContent.length,i=Math.min(r.start,s);r=r.end===void 0?i:Math.min(r.end,s),!e.extend&&i>r&&(s=r,r=i,i=s),s=Go(n,i);var a=Go(n,r);s&&a&&(e.rangeCount!==1||e.anchorNode!==s.node||e.anchorOffset!==s.offset||e.focusNode!==a.node||e.focusOffset!==a.offset)&&(t=t.createRange(),t.setStart(s.node,s.offset),e.removeAllRanges(),i>r?(e.addRange(t),e.extend(a.node,a.offset)):(t.setEnd(a.node,a.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n=document.documentMode,jn=null,xs=null,sr=null,ks=!1;function Zo(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;ks||jn==null||jn!==Tr(r)||(r=jn,"selectionStart"in r&&ys(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),sr&&lr(sr,r)||(sr=r,r=Xr(xs,"onSelect"),0En||(e.current=Ps[En],Ps[En]=null,En--)}function we(e,t){En++,Ps[En]=e.current,e.current=t}var Wt={},Ve=Bt(Wt),Ze=Bt(!1),nn=Wt;function _n(e,t){var n=e.type.contextTypes;if(!n)return Wt;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var s={},i;for(i in n)s[i]=t[i];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=s),s}function qe(e){return e=e.childContextTypes,e!=null}function el(){Ee(Ze),Ee(Ve)}function fa(e,t,n){if(Ve.current!==Wt)throw Error(u(168));we(Ve,t),we(Ze,n)}function pa(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var s in r)if(!(s in t))throw Error(u(108,ee(e)||"Unknown",s));return W({},n,r)}function tl(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Wt,nn=Ve.current,we(Ve,e),we(Ze,Ze.current),!0}function ma(e,t,n){var r=e.stateNode;if(!r)throw Error(u(169));n?(e=pa(e,t,nn),r.__reactInternalMemoizedMergedChildContext=e,Ee(Ze),Ee(Ve),we(Ve,e)):Ee(Ze),we(Ze,n)}var _t=null,nl=!1,Is=!1;function ha(e){_t===null?_t=[e]:_t.push(e)}function Td(e){nl=!0,ha(e)}function Ut(){if(!Is&&_t!==null){Is=!0;var e=0,t=je;try{var n=_t;for(je=1;e>=a,s-=a,zt=1<<32-pt(t)+s|n<ie?(Be=re,re=null):Be=re.sibling;var ye=A(y,re,j[ie],$);if(ye===null){re===null&&(re=Be);break}e&&re&&ye.alternate===null&&t(y,re),h=i(ye,h,ie),ne===null?Y=ye:ne.sibling=ye,ne=ye,re=Be}if(ie===j.length)return n(y,re),ze&&ln(y,ie),Y;if(re===null){for(;ieie?(Be=re,re=null):Be=re.sibling;var qt=A(y,re,ye.value,$);if(qt===null){re===null&&(re=Be);break}e&&re&&qt.alternate===null&&t(y,re),h=i(qt,h,ie),ne===null?Y=qt:ne.sibling=qt,ne=qt,re=Be}if(ye.done)return n(y,re),ze&&ln(y,ie),Y;if(re===null){for(;!ye.done;ie++,ye=j.next())ye=b(y,ye.value,$),ye!==null&&(h=i(ye,h,ie),ne===null?Y=ye:ne.sibling=ye,ne=ye);return ze&&ln(y,ie),Y}for(re=r(y,re);!ye.done;ie++,ye=j.next())ye=H(re,y,ie,ye.value,$),ye!==null&&(e&&ye.alternate!==null&&re.delete(ye.key===null?ie:ye.key),h=i(ye,h,ie),ne===null?Y=ye:ne.sibling=ye,ne=ye);return e&&re.forEach(function(cf){return t(y,cf)}),ze&&ln(y,ie),Y}function Ie(y,h,j,$){if(typeof j=="object"&&j!==null&&j.type===pe&&j.key===null&&(j=j.props.children),typeof j=="object"&&j!==null){switch(j.$$typeof){case oe:e:{for(var Y=j.key,ne=h;ne!==null;){if(ne.key===Y){if(Y=j.type,Y===pe){if(ne.tag===7){n(y,ne.sibling),h=s(ne,j.props.children),h.return=y,y=h;break e}}else if(ne.elementType===Y||typeof Y=="object"&&Y!==null&&Y.$$typeof===_e&&ja(Y)===ne.type){n(y,ne.sibling),h=s(ne,j.props),h.ref=dr(y,ne,j),h.return=y,y=h;break e}n(y,ne);break}else t(y,ne);ne=ne.sibling}j.type===pe?(h=pn(j.props.children,y.mode,$,j.key),h.return=y,y=h):($=Ll(j.type,j.key,j.props,null,y.mode,$),$.ref=dr(y,h,j),$.return=y,y=$)}return a(y);case ue:e:{for(ne=j.key;h!==null;){if(h.key===ne)if(h.tag===4&&h.stateNode.containerInfo===j.containerInfo&&h.stateNode.implementation===j.implementation){n(y,h.sibling),h=s(h,j.children||[]),h.return=y,y=h;break e}else{n(y,h);break}else t(y,h);h=h.sibling}h=Li(j,y.mode,$),h.return=y,y=h}return a(y);case _e:return ne=j._init,Ie(y,h,ne(j._payload),$)}if(Fn(j))return K(y,h,j,$);if(Q(j))return G(y,h,j,$);il(y,j)}return typeof j=="string"&&j!==""||typeof j=="number"?(j=""+j,h!==null&&h.tag===6?(n(y,h.sibling),h=s(h,j),h.return=y,y=h):(n(y,h),h=Ti(j,y.mode,$),h.return=y,y=h),a(y)):n(y,h)}return Ie}var Rn=Sa(!0),wa=Sa(!1),ol=Bt(null),al=null,Pn=null,$s=null;function Fs(){$s=Pn=al=null}function Bs(e){var t=ol.current;Ee(ol),e._currentValue=t}function Ws(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function In(e,t){al=e,$s=Pn=null,e=e.dependencies,e!==null&&e.firstContext!==null&&((e.lanes&t)!==0&&(Je=!0),e.firstContext=null)}function ut(e){var t=e._currentValue;if($s!==e)if(e={context:e,memoizedValue:t,next:null},Pn===null){if(al===null)throw Error(u(308));Pn=e,al.dependencies={lanes:0,firstContext:e}}else Pn=Pn.next=e;return t}var sn=null;function Us(e){sn===null?sn=[e]:sn.push(e)}function Na(e,t,n,r){var s=t.interleaved;return s===null?(n.next=n,Us(t)):(n.next=s.next,s.next=n),t.interleaved=n,Lt(e,r)}function Lt(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var Ht=!1;function Hs(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Ca(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function Rt(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function Vt(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,(ge&2)!==0){var s=r.pending;return s===null?t.next=t:(t.next=s.next,s.next=t),r.pending=t,Lt(e,n)}return s=r.interleaved,s===null?(t.next=t,Us(r)):(t.next=s.next,s.next=t),r.interleaved=t,Lt(e,n)}function ul(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,ls(e,n)}}function Ea(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var s=null,i=null;if(n=n.firstBaseUpdate,n!==null){do{var a={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};i===null?s=i=a:i=i.next=a,n=n.next}while(n!==null);i===null?s=i=t:i=i.next=t}else s=i=t;n={baseState:r.baseState,firstBaseUpdate:s,lastBaseUpdate:i,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function cl(e,t,n,r){var s=e.updateQueue;Ht=!1;var i=s.firstBaseUpdate,a=s.lastBaseUpdate,c=s.shared.pending;if(c!==null){s.shared.pending=null;var f=c,N=f.next;f.next=null,a===null?i=N:a.next=N,a=f;var O=e.alternate;O!==null&&(O=O.updateQueue,c=O.lastBaseUpdate,c!==a&&(c===null?O.firstBaseUpdate=N:c.next=N,O.lastBaseUpdate=f))}if(i!==null){var b=s.baseState;a=0,O=N=f=null,c=i;do{var A=c.lane,H=c.eventTime;if((r&A)===A){O!==null&&(O=O.next={eventTime:H,lane:0,tag:c.tag,payload:c.payload,callback:c.callback,next:null});e:{var K=e,G=c;switch(A=t,H=n,G.tag){case 1:if(K=G.payload,typeof K=="function"){b=K.call(H,b,A);break e}b=K;break e;case 3:K.flags=K.flags&-65537|128;case 0:if(K=G.payload,A=typeof K=="function"?K.call(H,b,A):K,A==null)break e;b=W({},b,A);break e;case 2:Ht=!0}}c.callback!==null&&c.lane!==0&&(e.flags|=64,A=s.effects,A===null?s.effects=[c]:A.push(c))}else H={eventTime:H,lane:A,tag:c.tag,payload:c.payload,callback:c.callback,next:null},O===null?(N=O=H,f=b):O=O.next=H,a|=A;if(c=c.next,c===null){if(c=s.shared.pending,c===null)break;A=c,c=A.next,A.next=null,s.lastBaseUpdate=A,s.shared.pending=null}}while(!0);if(O===null&&(f=b),s.baseState=f,s.firstBaseUpdate=N,s.lastBaseUpdate=O,t=s.shared.interleaved,t!==null){s=t;do a|=s.lane,s=s.next;while(s!==t)}else i===null&&(s.shared.lanes=0);un|=a,e.lanes=a,e.memoizedState=b}}function _a(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;tn?n:4,e(!0);var r=Ys.transition;Ys.transition={};try{e(!1),t()}finally{je=n,Ys.transition=r}}function Qa(){return ct().memoizedState}function Id(e,t,n){var r=Yt(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},Ka(e))Ga(t,n);else if(n=Na(e,t,n,r),n!==null){var s=Xe();xt(n,e,r,s),Ya(n,t,r)}}function Dd(e,t,n){var r=Yt(e),s={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(Ka(e))Ga(t,s);else{var i=e.alternate;if(e.lanes===0&&(i===null||i.lanes===0)&&(i=t.lastRenderedReducer,i!==null))try{var a=t.lastRenderedState,c=i(a,n);if(s.hasEagerState=!0,s.eagerState=c,mt(c,a)){var f=t.interleaved;f===null?(s.next=s,Us(t)):(s.next=f.next,f.next=s),t.interleaved=s;return}}catch{}finally{}n=Na(e,t,s,r),n!==null&&(s=Xe(),xt(n,e,r,s),Ya(n,t,r))}}function Ka(e){var t=e.alternate;return e===Le||t!==null&&t===Le}function Ga(e,t){hr=pl=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Ya(e,t,n){if((n&4194240)!==0){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,ls(e,n)}}var vl={readContext:ut,useCallback:Qe,useContext:Qe,useEffect:Qe,useImperativeHandle:Qe,useInsertionEffect:Qe,useLayoutEffect:Qe,useMemo:Qe,useReducer:Qe,useRef:Qe,useState:Qe,useDebugValue:Qe,useDeferredValue:Qe,useTransition:Qe,useMutableSource:Qe,useSyncExternalStore:Qe,useId:Qe,unstable_isNewReconciler:!1},Md={readContext:ut,useCallback:function(e,t){return Nt().memoizedState=[e,t===void 0?null:t],e},useContext:ut,useEffect:ba,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,ml(4194308,4,Ba.bind(null,t,e),n)},useLayoutEffect:function(e,t){return ml(4194308,4,e,t)},useInsertionEffect:function(e,t){return ml(4,2,e,t)},useMemo:function(e,t){var n=Nt();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=Nt();return t=n!==void 0?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=Id.bind(null,Le,e),[r.memoizedState,e]},useRef:function(e){var t=Nt();return e={current:e},t.memoizedState=e},useState:Aa,useDebugValue:ni,useDeferredValue:function(e){return Nt().memoizedState=e},useTransition:function(){var e=Aa(!1),t=e[0];return e=Pd.bind(null,e[1]),Nt().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=Le,s=Nt();if(ze){if(n===void 0)throw Error(u(407));n=n()}else{if(n=t(),Fe===null)throw Error(u(349));(an&30)!==0||Ra(r,t,n)}s.memoizedState=n;var i={value:n,getSnapshot:t};return s.queue=i,ba(Ia.bind(null,r,i,e),[e]),r.flags|=2048,yr(9,Pa.bind(null,r,i,n,t),void 0,null),n},useId:function(){var e=Nt(),t=Fe.identifierPrefix;if(ze){var n=Tt,r=zt;n=(r&~(1<<32-pt(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=vr++,0<\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=a.createElement(n,{is:r.is}):(e=a.createElement(n),n==="select"&&(a=e,r.multiple?a.multiple=!0:r.size&&(a.size=r.size))):e=a.createElementNS(e,n),e[St]=t,e[ur]=r,hu(e,t,!1,!1),t.stateNode=e;e:{switch(a=Gl(n,r),n){case"dialog":Ce("cancel",e),Ce("close",e),s=r;break;case"iframe":case"object":case"embed":Ce("load",e),s=r;break;case"video":case"audio":for(s=0;sbn&&(t.flags|=128,r=!0,xr(i,!1),t.lanes=4194304)}else{if(!r)if(e=dl(a),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),xr(i,!0),i.tail===null&&i.tailMode==="hidden"&&!a.alternate&&!ze)return Ke(t),null}else 2*Pe()-i.renderingStartTime>bn&&n!==1073741824&&(t.flags|=128,r=!0,xr(i,!1),t.lanes=4194304);i.isBackwards?(a.sibling=t.child,t.child=a):(n=i.last,n!==null?n.sibling=a:t.child=a,i.last=a)}return i.tail!==null?(t=i.tail,i.rendering=t,i.tail=t.sibling,i.renderingStartTime=Pe(),t.sibling=null,n=Te.current,we(Te,r?n&1|2:n&1),t):(Ke(t),null);case 22:case 23:return Ei(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&(t.mode&1)!==0?(it&1073741824)!==0&&(Ke(t),t.subtreeFlags&6&&(t.flags|=8192)):Ke(t),null;case 24:return null;case 25:return null}throw Error(u(156,t.tag))}function Ud(e,t){switch(Ms(t),t.tag){case 1:return qe(t.type)&&el(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Dn(),Ee(Ze),Ee(Ve),Gs(),e=t.flags,(e&65536)!==0&&(e&128)===0?(t.flags=e&-65537|128,t):null;case 5:return Qs(t),null;case 13:if(Ee(Te),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(u(340));Ln()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return Ee(Te),null;case 4:return Dn(),null;case 10:return Bs(t.type._context),null;case 22:case 23:return Ei(),null;case 24:return null;default:return null}}var kl=!1,Ge=!1,Hd=typeof WeakSet=="function"?WeakSet:Set,V=null;function An(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){Re(e,t,r)}else n.current=null}function mi(e,t,n){try{n()}catch(r){Re(e,t,r)}}var yu=!1;function Vd(e,t){if(Es=Fr,e=Xo(),ys(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var s=r.anchorOffset,i=r.focusNode;r=r.focusOffset;try{n.nodeType,i.nodeType}catch{n=null;break e}var a=0,c=-1,f=-1,N=0,O=0,b=e,A=null;t:for(;;){for(var H;b!==n||s!==0&&b.nodeType!==3||(c=a+s),b!==i||r!==0&&b.nodeType!==3||(f=a+r),b.nodeType===3&&(a+=b.nodeValue.length),(H=b.firstChild)!==null;)A=b,b=H;for(;;){if(b===e)break t;if(A===n&&++N===s&&(c=a),A===i&&++O===r&&(f=a),(H=b.nextSibling)!==null)break;b=A,A=b.parentNode}b=H}n=c===-1||f===-1?null:{start:c,end:f}}else n=null}n=n||{start:0,end:0}}else n=null;for(_s={focusedElem:e,selectionRange:n},Fr=!1,V=t;V!==null;)if(t=V,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,V=e;else for(;V!==null;){t=V;try{var K=t.alternate;if((t.flags&1024)!==0)switch(t.tag){case 0:case 11:case 15:break;case 1:if(K!==null){var G=K.memoizedProps,Ie=K.memoizedState,y=t.stateNode,h=y.getSnapshotBeforeUpdate(t.elementType===t.type?G:vt(t.type,G),Ie);y.__reactInternalSnapshotBeforeUpdate=h}break;case 3:var j=t.stateNode.containerInfo;j.nodeType===1?j.textContent="":j.nodeType===9&&j.documentElement&&j.removeChild(j.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(u(163))}}catch($){Re(t,t.return,$)}if(e=t.sibling,e!==null){e.return=t.return,V=e;break}V=t.return}return K=yu,yu=!1,K}function kr(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var s=r=r.next;do{if((s.tag&e)===e){var i=s.destroy;s.destroy=void 0,i!==void 0&&mi(t,n,i)}s=s.next}while(s!==r)}}function jl(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function hi(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t=="function"?t(e):t.current=e}}function xu(e){var t=e.alternate;t!==null&&(e.alternate=null,xu(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[St],delete t[ur],delete t[Rs],delete t[_d],delete t[zd])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function ku(e){return e.tag===5||e.tag===3||e.tag===4}function ju(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||ku(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function vi(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=qr));else if(r!==4&&(e=e.child,e!==null))for(vi(e,t,n),e=e.sibling;e!==null;)vi(e,t,n),e=e.sibling}function gi(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(gi(e,t,n),e=e.sibling;e!==null;)gi(e,t,n),e=e.sibling}var Ue=null,gt=!1;function Qt(e,t,n){for(n=n.child;n!==null;)Su(e,t,n),n=n.sibling}function Su(e,t,n){if(jt&&typeof jt.onCommitFiberUnmount=="function")try{jt.onCommitFiberUnmount(Dr,n)}catch{}switch(n.tag){case 5:Ge||An(n,t);case 6:var r=Ue,s=gt;Ue=null,Qt(e,t,n),Ue=r,gt=s,Ue!==null&&(gt?(e=Ue,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):Ue.removeChild(n.stateNode));break;case 18:Ue!==null&&(gt?(e=Ue,n=n.stateNode,e.nodeType===8?Ls(e.parentNode,n):e.nodeType===1&&Ls(e,n),qn(e)):Ls(Ue,n.stateNode));break;case 4:r=Ue,s=gt,Ue=n.stateNode.containerInfo,gt=!0,Qt(e,t,n),Ue=r,gt=s;break;case 0:case 11:case 14:case 15:if(!Ge&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){s=r=r.next;do{var i=s,a=i.destroy;i=i.tag,a!==void 0&&((i&2)!==0||(i&4)!==0)&&mi(n,t,a),s=s.next}while(s!==r)}Qt(e,t,n);break;case 1:if(!Ge&&(An(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(c){Re(n,t,c)}Qt(e,t,n);break;case 21:Qt(e,t,n);break;case 22:n.mode&1?(Ge=(r=Ge)||n.memoizedState!==null,Qt(e,t,n),Ge=r):Qt(e,t,n);break;default:Qt(e,t,n)}}function wu(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new Hd),t.forEach(function(r){var s=ef.bind(null,e,r);n.has(r)||(n.add(r),r.then(s,s))})}}function yt(e,t){var n=t.deletions;if(n!==null)for(var r=0;rs&&(s=a),r&=~i}if(r=s,r=Pe()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*Kd(r/1960))-r,10e?16:e,Gt===null)var r=!1;else{if(e=Gt,Gt=null,El=0,(ge&6)!==0)throw Error(u(331));var s=ge;for(ge|=4,V=e.current;V!==null;){var i=V,a=i.child;if((V.flags&16)!==0){var c=i.deletions;if(c!==null){for(var f=0;fPe()-ki?dn(e,0):xi|=n),tt(e,t)}function Au(e,t){t===0&&((e.mode&1)===0?t=1:(t=Ar,Ar<<=1,(Ar&130023424)===0&&(Ar=4194304)));var n=Xe();e=Lt(e,t),e!==null&&(Kn(e,t,n),tt(e,n))}function Jd(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Au(e,n)}function ef(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,s=e.memoizedState;s!==null&&(n=s.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(u(314))}r!==null&&r.delete(t),Au(e,n)}var Ou;Ou=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||Ze.current)Je=!0;else{if((e.lanes&n)===0&&(t.flags&128)===0)return Je=!1,Bd(e,t,n);Je=(e.flags&131072)!==0}else Je=!1,ze&&(t.flags&1048576)!==0&&va(t,ll,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;xl(e,t),e=t.pendingProps;var s=_n(t,Ve.current);In(t,n),s=Zs(null,t,r,e,s,n);var i=qs();return t.flags|=1,typeof s=="object"&&s!==null&&typeof s.render=="function"&&s.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,qe(r)?(i=!0,tl(t)):i=!1,t.memoizedState=s.state!==null&&s.state!==void 0?s.state:null,Hs(t),s.updater=gl,t.stateNode=s,s._reactInternals=t,li(t,r,e,n),t=ai(null,t,r,!0,i,n)):(t.tag=0,ze&&i&&Ds(t),Ye(null,t,s,n),t=t.child),t;case 16:r=t.elementType;e:{switch(xl(e,t),e=t.pendingProps,s=r._init,r=s(r._payload),t.type=r,s=t.tag=nf(r),e=vt(r,e),s){case 0:t=oi(null,t,r,e,n);break e;case 1:t=uu(null,t,r,e,n);break e;case 11:t=lu(null,t,r,e,n);break e;case 14:t=su(null,t,r,vt(r.type,e),n);break e}throw Error(u(306,r,""))}return t;case 0:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:vt(r,s),oi(e,t,r,s,n);case 1:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:vt(r,s),uu(e,t,r,s,n);case 3:e:{if(cu(t),e===null)throw Error(u(387));r=t.pendingProps,i=t.memoizedState,s=i.element,Ca(e,t),cl(t,r,null,n);var a=t.memoizedState;if(r=a.element,i.isDehydrated)if(i={element:r,isDehydrated:!1,cache:a.cache,pendingSuspenseBoundaries:a.pendingSuspenseBoundaries,transitions:a.transitions},t.updateQueue.baseState=i,t.memoizedState=i,t.flags&256){s=Mn(Error(u(423)),t),t=du(e,t,r,n,s);break e}else if(r!==s){s=Mn(Error(u(424)),t),t=du(e,t,r,n,s);break e}else for(st=Ft(t.stateNode.containerInfo.firstChild),lt=t,ze=!0,ht=null,n=wa(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(Ln(),r===s){t=Pt(e,t,n);break e}Ye(e,t,r,n)}t=t.child}return t;case 5:return za(t),e===null&&Os(t),r=t.type,s=t.pendingProps,i=e!==null?e.memoizedProps:null,a=s.children,zs(r,s)?a=null:i!==null&&zs(r,i)&&(t.flags|=32),au(e,t),Ye(e,t,a,n),t.child;case 6:return e===null&&Os(t),null;case 13:return fu(e,t,n);case 4:return Vs(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=Rn(t,null,r,n):Ye(e,t,r,n),t.child;case 11:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:vt(r,s),lu(e,t,r,s,n);case 7:return Ye(e,t,t.pendingProps,n),t.child;case 8:return Ye(e,t,t.pendingProps.children,n),t.child;case 12:return Ye(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,s=t.pendingProps,i=t.memoizedProps,a=s.value,we(ol,r._currentValue),r._currentValue=a,i!==null)if(mt(i.value,a)){if(i.children===s.children&&!Ze.current){t=Pt(e,t,n);break e}}else for(i=t.child,i!==null&&(i.return=t);i!==null;){var c=i.dependencies;if(c!==null){a=i.child;for(var f=c.firstContext;f!==null;){if(f.context===r){if(i.tag===1){f=Rt(-1,n&-n),f.tag=2;var N=i.updateQueue;if(N!==null){N=N.shared;var O=N.pending;O===null?f.next=f:(f.next=O.next,O.next=f),N.pending=f}}i.lanes|=n,f=i.alternate,f!==null&&(f.lanes|=n),Ws(i.return,n,t),c.lanes|=n;break}f=f.next}}else if(i.tag===10)a=i.type===t.type?null:i.child;else if(i.tag===18){if(a=i.return,a===null)throw Error(u(341));a.lanes|=n,c=a.alternate,c!==null&&(c.lanes|=n),Ws(a,n,t),a=i.sibling}else a=i.child;if(a!==null)a.return=i;else for(a=i;a!==null;){if(a===t){a=null;break}if(i=a.sibling,i!==null){i.return=a.return,a=i;break}a=a.return}i=a}Ye(e,t,s.children,n),t=t.child}return t;case 9:return s=t.type,r=t.pendingProps.children,In(t,n),s=ut(s),r=r(s),t.flags|=1,Ye(e,t,r,n),t.child;case 14:return r=t.type,s=vt(r,t.pendingProps),s=vt(r.type,s),su(e,t,r,s,n);case 15:return iu(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:vt(r,s),xl(e,t),t.tag=1,qe(r)?(e=!0,tl(t)):e=!1,In(t,n),Za(t,r,s),li(t,r,s,n),ai(null,t,r,!0,e,n);case 19:return mu(e,t,n);case 22:return ou(e,t,n)}throw Error(u(156,t.tag))};function bu(e,t){return go(e,t)}function tf(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function ft(e,t,n,r){return new tf(e,t,n,r)}function zi(e){return e=e.prototype,!(!e||!e.isReactComponent)}function nf(e){if(typeof e=="function")return zi(e)?1:0;if(e!=null){if(e=e.$$typeof,e===ke)return 11;if(e===Ne)return 14}return 2}function Zt(e,t){var n=e.alternate;return n===null?(n=ft(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function Ll(e,t,n,r,s,i){var a=2;if(r=e,typeof e=="function")zi(e)&&(a=1);else if(typeof e=="string")a=5;else e:switch(e){case pe:return pn(n.children,s,i,t);case me:a=8,s|=8;break;case be:return e=ft(12,n,t,s|2),e.elementType=be,e.lanes=i,e;case se:return e=ft(13,n,t,s),e.elementType=se,e.lanes=i,e;case J:return e=ft(19,n,t,s),e.elementType=J,e.lanes=i,e;case xe:return Rl(n,s,i,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case X:a=10;break e;case le:a=9;break e;case ke:a=11;break e;case Ne:a=14;break e;case _e:a=16,r=null;break e}throw Error(u(130,e==null?e:typeof e,""))}return t=ft(a,n,t,s),t.elementType=e,t.type=r,t.lanes=i,t}function pn(e,t,n,r){return e=ft(7,e,r,t),e.lanes=n,e}function Rl(e,t,n,r){return e=ft(22,e,r,t),e.elementType=xe,e.lanes=n,e.stateNode={isHidden:!1},e}function Ti(e,t,n){return e=ft(6,e,null,t),e.lanes=n,e}function Li(e,t,n){return t=ft(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function rf(e,t,n,r,s){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=rs(0),this.expirationTimes=rs(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=rs(0),this.identifierPrefix=r,this.onRecoverableError=s,this.mutableSourceEagerHydrationData=null}function Ri(e,t,n,r,s,i,a,c,f){return e=new rf(e,t,n,c,f),t===1?(t=1,i===!0&&(t|=8)):t=0,i=ft(3,null,null,t),e.current=i,i.stateNode=e,i.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},Hs(i),e}function lf(e,t,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(o)}catch(p){console.error(p)}}return o(),Oi.exports=vf(),Oi.exports}var qu;function yf(){if(qu)return bl;qu=1;var o=gf();return bl.createRoot=o.createRoot,bl.hydrateRoot=o.hydrateRoot,bl}var xf=yf();const kf=Qi(xf),jf={},Ju=o=>{let p;const u=new Set,k=(z,d)=>{const w=typeof z=="function"?z(p):z;if(!Object.is(w,p)){const m=p;p=d??(typeof w!="object"||w===null)?w:Object.assign({},p,w),u.forEach(T=>T(p,m))}},S=()=>p,R={setState:k,getState:S,getInitialState:()=>C,subscribe:z=>(u.add(z),()=>u.delete(z)),destroy:()=>{(jf?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),u.clear()}},C=p=o(k,S,R);return R},Sf=o=>o?Ju(o):Ju;var Fi={exports:{}},Bi={},Wi={exports:{}},Ui={};/** - * @license React - * use-sync-external-store-shim.production.js - * - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var ec;function wf(){if(ec)return Ui;ec=1;var o=_r();function p(d,w){return d===w&&(d!==0||1/d===1/w)||d!==d&&w!==w}var u=typeof Object.is=="function"?Object.is:p,k=o.useState,S=o.useEffect,D=o.useLayoutEffect,F=o.useDebugValue;function _(d,w){var m=w(),T=k({inst:{value:m,getSnapshot:w}}),g=T[0].inst,M=T[1];return D(function(){g.value=m,g.getSnapshot=w,R(g)&&M({inst:g})},[d,m,w]),S(function(){return R(g)&&M({inst:g}),d(function(){R(g)&&M({inst:g})})},[d]),F(m),m}function R(d){var w=d.getSnapshot;d=d.value;try{var m=w();return!u(d,m)}catch{return!0}}function C(d,w){return w()}var z=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?C:_;return Ui.useSyncExternalStore=o.useSyncExternalStore!==void 0?o.useSyncExternalStore:z,Ui}var tc;function Nf(){return tc||(tc=1,Wi.exports=wf()),Wi.exports}/** - * @license React - * use-sync-external-store-shim/with-selector.production.js - * - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var nc;function Cf(){if(nc)return Bi;nc=1;var o=_r(),p=Nf();function u(C,z){return C===z&&(C!==0||1/C===1/z)||C!==C&&z!==z}var k=typeof Object.is=="function"?Object.is:u,S=p.useSyncExternalStore,D=o.useRef,F=o.useEffect,_=o.useMemo,R=o.useDebugValue;return Bi.useSyncExternalStoreWithSelector=function(C,z,d,w,m){var T=D(null);if(T.current===null){var g={hasValue:!1,value:null};T.current=g}else g=T.current;T=_(function(){function P(ue){if(!B){if(B=!0,Z=ue,ue=w(ue),m!==void 0&&g.hasValue){var pe=g.value;if(m(pe,ue))return I=pe}return I=ue}if(pe=I,k(Z,ue))return pe;var me=w(ue);return m!==void 0&&m(pe,me)?(Z=ue,pe):(Z=ue,I=me)}var B=!1,Z,I,oe=d===void 0?null:d;return[function(){return P(z())},oe===null?void 0:function(){return P(oe())}]},[z,d,w,m]);var M=S(C,T[0],T[1]);return F(function(){g.hasValue=!0,g.value=M},[M]),R(M),M},Bi}var rc;function Ef(){return rc||(rc=1,Fi.exports=Cf()),Fi.exports}var _f=Ef();const zf=Qi(_f),ac={},{useDebugValue:Tf}=oc,{useSyncExternalStoreWithSelector:Lf}=zf;let lc=!1;const Rf=o=>o;function Pf(o,p=Rf,u){(ac?"production":void 0)!=="production"&&u&&!lc&&(console.warn("[DEPRECATED] Use `createWithEqualityFn` instead of `create` or use `useStoreWithEqualityFn` instead of `useStore`. They can be imported from 'zustand/traditional'. https://github.com/pmndrs/zustand/discussions/1937"),lc=!0);const k=Lf(o.subscribe,o.getState,o.getServerState||o.getInitialState,p,u);return Tf(k),k}const sc=o=>{(ac?"production":void 0)!=="production"&&typeof o!="function"&&console.warn("[DEPRECATED] Passing a vanilla store will be unsupported in a future version. Instead use `import { useStore } from 'zustand'`.");const p=typeof o=="function"?Sf(o):o,u=(k,S)=>Pf(p,k,S);return Object.assign(u,p),u},If=o=>o?sc(o):sc,Se="";async function kt(o){const p=await fetch(o,{cache:"no-store"});if(!p.ok)throw new Error(String(p.status));return p.json()}async function We(o,p){return(await fetch(o,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(p)})).json()}const fe={liveStatus:()=>kt(`${Se}/api/live-status`),agentConfig:()=>kt(`${Se}/api/agent-config`),modelChangeLog:()=>kt(`${Se}/api/model-change-log`).catch(()=>[]),officialsStats:()=>kt(`${Se}/api/officials-stats`),morningBrief:()=>kt(`${Se}/api/morning-brief`),morningConfig:()=>kt(`${Se}/api/morning-config`),agentsStatus:()=>kt(`${Se}/api/agents-status`),taskActivity:o=>kt(`${Se}/api/task-activity/${encodeURIComponent(o)}`),schedulerState:o=>kt(`${Se}/api/scheduler-state/${encodeURIComponent(o)}`),skillContent:(o,p)=>kt(`${Se}/api/skill-content/${encodeURIComponent(o)}/${encodeURIComponent(p)}`),setModel:(o,p)=>We(`${Se}/api/set-model`,{agentId:o,model:p}),agentWake:o=>We(`${Se}/api/agent-wake`,{agentId:o}),taskAction:(o,p,u)=>We(`${Se}/api/task-action`,{taskId:o,action:p,reason:u}),reviewAction:(o,p,u)=>We(`${Se}/api/review-action`,{taskId:o,action:p,comment:u}),advanceState:(o,p)=>We(`${Se}/api/advance-state`,{taskId:o,comment:p}),archiveTask:(o,p)=>We(`${Se}/api/archive-task`,{taskId:o,archived:p}),archiveAllDone:()=>We(`${Se}/api/archive-task`,{archiveAllDone:!0}),schedulerScan:(o=180)=>We(`${Se}/api/scheduler-scan`,{thresholdSec:o}),schedulerRetry:(o,p)=>We(`${Se}/api/scheduler-retry`,{taskId:o,reason:p}),schedulerEscalate:(o,p)=>We(`${Se}/api/scheduler-escalate`,{taskId:o,reason:p}),schedulerRollback:(o,p)=>We(`${Se}/api/scheduler-rollback`,{taskId:o,reason:p}),refreshMorning:()=>We(`${Se}/api/morning-brief/refresh`,{}),saveMorningConfig:o=>We(`${Se}/api/morning-config`,o),addSkill:(o,p,u,k)=>We(`${Se}/api/add-skill`,{agentId:o,skillName:p,description:u,trigger:k}),addRemoteSkill:(o,p,u,k)=>We(`${Se}/api/add-remote-skill`,{agentId:o,skillName:p,sourceUrl:u,description:k||""}),remoteSkillsList:()=>kt(`${Se}/api/remote-skills-list`),updateRemoteSkill:(o,p)=>We(`${Se}/api/update-remote-skill`,{agentId:o,skillName:p}),removeRemoteSkill:(o,p)=>We(`${Se}/api/remove-remote-skill`,{agentId:o,skillName:p}),createTask:o=>We(`${Se}/api/create-task`,o)},uc=[{key:"Inbox",dept:"皇上",icon:"👑",action:"下旨"},{key:"Taizi",dept:"太子",icon:"🤴",action:"分拣"},{key:"Zhongshu",dept:"中书省",icon:"📜",action:"起草"},{key:"Menxia",dept:"门下省",icon:"🔍",action:"审议"},{key:"Assigned",dept:"尚书省",icon:"📮",action:"派发"},{key:"Doing",dept:"六部",icon:"⚙️",action:"执行"},{key:"Review",dept:"尚书省",icon:"🔎",action:"汇总"},{key:"Done",dept:"回奏",icon:"✅",action:"完成"}],Df={Inbox:0,Pending:0,Taizi:1,Zhongshu:2,Menxia:3,Assigned:4,Doing:5,Review:6,Done:7,Blocked:5,Cancelled:5,Next:4},Mf={太子:"#e8a040",中书省:"#a07aff",门下省:"#6a9eff",尚书省:"#6aef9a",礼部:"#f5c842",户部:"#ff9a6a",兵部:"#ff5270",刑部:"#cc4444",工部:"#44aaff",吏部:"#9b59b6",皇上:"#ffd700",回奏:"#2ecc8a"},zr={Inbox:"收件",Pending:"待处理",Taizi:"太子分拣",Zhongshu:"中书起草",Menxia:"门下审议",Assigned:"已派发",Doing:"执行中",Review:"待审查",Done:"已完成",Blocked:"阻塞",Cancelled:"已取消",Next:"待执行"};function $l(o){return Mf[o]||"#6a9eff"}function Ki(o){const p=o.review_round||0;return o.state==="Menxia"&&p>1?`门下审议(第${p}轮)`:o.state==="Zhongshu"&&p>0?`中书修订(第${p}轮)`:zr[o.state]||o.state}function Jt(o){return/^JJC-/i.test(o.id||"")}function Bl(o){return o.archived||["Done","Cancelled"].includes(o.state)}function Gi(o){const p=Df[o.state]??4;return uc.map((u,k)=>({...u,status:k({liveStatus:null,agentConfig:null,changeLog:[],officialsData:null,agentsStatusData:null,morningBrief:null,subConfig:null,activeTab:"edicts",edictFilter:"active",sessFilter:"all",tplCatFilter:"全部",selectedOfficial:null,modalTaskId:null,countdown:5,toasts:[],setActiveTab:u=>{o({activeTab:u});const k=p();["models","skills","sessions"].includes(u)&&!k.agentConfig&&k.loadAgentConfig(),u==="officials"&&!k.officialsData&&k.loadOfficials(),u==="monitor"&&k.loadAgentsStatus(),u==="morning"&&!k.morningBrief&&k.loadMorning()},setEdictFilter:u=>o({edictFilter:u}),setSessFilter:u=>o({sessFilter:u}),setTplCatFilter:u=>o({tplCatFilter:u}),setSelectedOfficial:u=>o({selectedOfficial:u}),setModalTaskId:u=>o({modalTaskId:u}),setCountdown:u=>o({countdown:u}),toast:(u,k="ok")=>{const S=++Ff;o(D=>({toasts:[...D.toasts,{id:S,msg:u,type:k}]})),setTimeout(()=>{o(D=>({toasts:D.toasts.filter(F=>F.id!==S)}))},3e3)},loadLive:async()=>{try{const u=await fe.liveStatus();o({liveStatus:u}),p().officialsData||fe.officialsStats().then(S=>o({officialsData:S})).catch(()=>{})}catch{}},loadAgentConfig:async()=>{try{const u=await fe.agentConfig(),k=await fe.modelChangeLog();o({agentConfig:u,changeLog:k})}catch{}},loadOfficials:async()=>{try{const u=await fe.officialsStats();o({officialsData:u})}catch{}},loadAgentsStatus:async()=>{try{const u=await fe.agentsStatus();o({agentsStatusData:u})}catch{o({agentsStatusData:null})}},loadMorning:async()=>{try{const[u,k]=await Promise.all([fe.morningBrief(),fe.morningConfig()]);o({morningBrief:u,subConfig:k})}catch{}},loadSubConfig:async()=>{try{const u=await fe.morningConfig();o({subConfig:u})}catch{}},loadAll:async()=>{const u=p();await u.loadLive();const k=u.activeTab;["models","skills"].includes(k)&&await u.loadAgentConfig()}}));let Er=null;function Bf(){Er||(q.getState().loadAll(),Er=setInterval(()=>{const o=q.getState(),p=o.countdown-1;p<=0?(o.setCountdown(5),o.loadAll()):o.setCountdown(p)},1e3))}function Wf(){Er&&(clearInterval(Er),Er=null)}function Uf(o){if(!o)return"";try{const p=new Date(o.includes("T")?o:o.replace(" ","T")+"Z");if(isNaN(p.getTime()))return"";const u=Date.now()-p.getTime(),k=Math.floor(u/6e4);if(k<1)return"刚刚";if(k<60)return k+"分钟前";const S=Math.floor(k/60);return S<24?S+"小时前":Math.floor(S/24)+"天前"}catch{return""}}const ic={Doing:0,Review:1,Assigned:2,Menxia:3,Zhongshu:4,Taizi:5,Inbox:6,Blocked:7,Next:8,Done:9,Cancelled:10};function Hf({task:o}){const p=Gi(o);return l.jsx("div",{className:"ec-pipe",children:p.map((u,k)=>l.jsxs("span",{style:{display:"contents"},children:[l.jsxs("div",{className:`ep-node ${u.status}`,children:[l.jsx("div",{className:"ep-icon",children:u.icon}),l.jsx("div",{className:"ep-name",children:u.dept})]}),kP.setModalTaskId),u=q(P=>P.toast),k=q(P=>P.loadAll),S=o.heartbeat||{status:"unknown",label:"⚪"},D="st-"+(o.state||""),F="dt-"+(o.org||"").replace(/\s/g,""),_=uc.find((P,B)=>Gi(o)[B].status==="active"),R=o.todos||[],C=R.filter(P=>P.status==="completed").length,z=R.length,d=!["Done","Blocked","Cancelled"].includes(o.state),w=["Blocked","Cancelled"].includes(o.state),m=Bl(o),T=o.block&&o.block!=="无"&&o.block!=="-",g=async(P,B)=>{if(B.stopPropagation(),P==="stop"||P==="cancel"){const Z=prompt(P==="stop"?"请输入叫停原因:":"请输入取消原因:");if(Z===null)return;try{const I=await fe.taskAction(o.id,P,Z);I.ok?(u(I.message||"操作成功"),k()):u(I.error||"操作失败","err")}catch{u("服务器连接失败","err")}}else if(P==="resume")try{const Z=await fe.taskAction(o.id,"resume","恢复执行");Z.ok?(u(Z.message||"已恢复"),k()):u(Z.error||"操作失败","err")}catch{u("服务器连接失败","err")}},M=async P=>{P.stopPropagation();try{const B=await fe.archiveTask(o.id,!o.archived);B.ok?(u(B.message||"操作成功"),k()):u(B.error||"操作失败","err")}catch{u("服务器连接失败","err")}};return l.jsxs("div",{className:`edict-card${m?" archived":""}`,onClick:()=>p(o.id),children:[l.jsx(Hf,{task:o}),l.jsx("div",{className:"ec-id",children:o.id}),l.jsx("div",{className:"ec-title",children:o.title||"(无标题)"}),l.jsxs("div",{className:"ec-meta",children:[l.jsx("span",{className:`tag ${D}`,children:Ki(o)}),o.org&&l.jsx("span",{className:`tag ${F}`,children:o.org}),_&&l.jsxs("span",{style:{fontSize:11,color:"var(--muted)"},children:["当前: ",l.jsxs("b",{style:{color:$l(_.dept)},children:[_.dept," · ",_.action]})]})]}),o.now&&o.now!=="-"&&l.jsx("div",{style:{fontSize:11,color:"var(--muted)",lineHeight:1.5,marginBottom:6},children:o.now.substring(0,80)}),(o.review_round||0)>0&&l.jsxs("div",{style:{fontSize:11,marginBottom:6},children:[Array.from({length:o.review_round||0},(P,B)=>l.jsx("span",{style:{display:"inline-block",width:14,height:14,borderRadius:"50%",background:B<(o.review_round||0)-1?"#1a3a6a22":"var(--acc)22",border:`1px solid ${B<(o.review_round||0)-1?"#2a4a8a":"var(--acc)"}`,fontSize:9,textAlign:"center",lineHeight:"13px",marginRight:2,color:B<(o.review_round||0)-1?"#4a6aaa":"var(--acc)"},children:B+1},B)),l.jsxs("span",{style:{color:"var(--muted)",fontSize:10},children:["第 ",o.review_round," 轮磋商"]})]}),z>0&&l.jsxs("div",{className:"ec-todo-bar",children:[l.jsxs("span",{children:["📋 ",C,"/",z]}),l.jsx("div",{className:"ec-todo-track",children:l.jsx("div",{className:"ec-todo-fill",style:{width:`${Math.round(C/z*100)}%`}})}),l.jsx("span",{children:C===z?"✅ 全部完成":"🔄 进行中"})]}),l.jsxs("div",{className:"ec-footer",children:[l.jsx("span",{className:`hb ${S.status}`,children:S.label}),T&&l.jsxs("span",{className:"tag",style:{borderColor:"#ff527044",color:"var(--danger)",background:"#200a10"},children:["🚫 ",o.block]}),o.eta&&o.eta!=="-"&&l.jsxs("span",{style:{fontSize:11,color:"var(--muted)"},children:["📅 ",o.eta]})]}),l.jsxs("div",{className:"ec-actions",onClick:P=>P.stopPropagation(),children:[d&&l.jsxs(l.Fragment,{children:[l.jsx("button",{className:"mini-act",onClick:P=>g("stop",P),children:"⏸ 叫停"}),l.jsx("button",{className:"mini-act danger",onClick:P=>g("cancel",P),children:"🚫 取消"})]}),w&&l.jsx("button",{className:"mini-act",onClick:P=>g("resume",P),children:"▶ 恢复"}),m&&!o.archived&&l.jsx("button",{className:"mini-act",onClick:M,children:"📦 归档"}),o.archived&&l.jsx("button",{className:"mini-act",onClick:M,children:"📤 取消归档"})]})]})}function Qf(){const o=q(m=>m.liveStatus),p=q(m=>m.edictFilter),u=q(m=>m.setEdictFilter),k=q(m=>m.toast),S=q(m=>m.loadAll),F=((o==null?void 0:o.tasks)||[]).filter(Jt),_=F.filter(m=>!Bl(m)),R=F.filter(m=>Bl(m));let C;p==="active"?C=_:p==="archived"?C=R:C=F,C.sort((m,T)=>(ic[m.state]??9)-(ic[T.state]??9));const z=F.filter(m=>!m.archived&&["Done","Cancelled"].includes(m.state)),d=async()=>{if(confirm("将所有已完成/已取消的旨意移入归档?"))try{const m=await fe.archiveAllDone();m.ok?(k(`📦 ${m.count||0} 道旨意已归档`),S()):k(m.error||"批量归档失败","err")}catch{k("服务器连接失败","err")}},w=async()=>{try{const m=await fe.schedulerScan();m.ok?k(`🧭 太子巡检完成:${m.count||0} 个动作`):k(m.error||"巡检失败","err"),S()}catch{k("服务器连接失败","err")}};return l.jsxs("div",{children:[l.jsxs("div",{className:"archive-bar",children:[l.jsx("span",{className:"ab-label",children:"筛选:"}),["active","archived","all"].map(m=>l.jsx("button",{className:`ab-btn ${p===m?"active":""}`,onClick:()=>u(m),children:m==="active"?"活跃":m==="archived"?"归档":"全部"},m)),z.length>0&&l.jsx("button",{className:"ab-btn",onClick:d,children:"📦 一键归档"}),l.jsxs("span",{className:"ab-count",children:["活跃 ",_.length," · 归档 ",R.length," · 共 ",F.length]}),l.jsx("button",{className:"ab-scan",onClick:w,children:"🧭 太子巡检"})]}),l.jsx("div",{className:"edict-grid",children:C.length===0?l.jsxs("div",{className:"empty",style:{gridColumn:"1/-1"},children:["暂无旨意",l.jsx("br",{}),l.jsx("small",{style:{fontSize:11,marginTop:6,display:"block",color:"var(--muted)"},children:"通过飞书向太子发送任务,太子分拣后转中书省处理"})]}):C.map(m=>l.jsx(Vf,{task:m},m.id))})]})}function Kf(){var Z;const o=q(I=>I.liveStatus),p=q(I=>I.agentsStatusData),u=q(I=>I.officialsData),k=q(I=>I.loadAgentsStatus),S=q(I=>I.setModalTaskId),D=q(I=>I.toast);te.useEffect(()=>{k()},[k]);const _=((o==null?void 0:o.tasks)||[]).filter(I=>Jt(I)&&I.state!=="Done"&&I.state!=="Next"),R={};u!=null&&u.officials&&u.officials.forEach(I=>{R[I.id]=I});const C=async I=>{try{const oe=await fe.agentWake(I);D(oe.message||"唤醒指令已发出"),setTimeout(()=>k(),3e4)}catch{D("唤醒失败","err")}},z=async()=>{if(!p)return;const I=p.agents.filter(oe=>oe.id!=="main"&&oe.status!=="running"&&oe.status!=="unconfigured");if(!I.length){D("所有 Agent 均已在线");return}D(`正在唤醒 ${I.length} 个 Agent...`);for(const oe of I)try{await fe.agentWake(oe.id)}catch{}D(`${I.length} 个唤醒指令已发出,30秒后刷新状态`),setTimeout(()=>k(),3e4)},d=p,w=((Z=d==null?void 0:d.agents)==null?void 0:Z.filter(I=>I.id!=="main"))||[],m=w.filter(I=>I.status==="running").length,T=w.filter(I=>I.status==="idle").length,g=w.filter(I=>I.status==="offline").length,M=w.filter(I=>I.status==="unconfigured").length,P=d==null?void 0:d.gateway,B=P!=null&&P.probe?"ok":P!=null&&P.alive?"warn":"err";return l.jsxs("div",{children:[d&&d.ok&&l.jsxs("div",{className:"as-panel",children:[l.jsxs("div",{className:"as-header",children:[l.jsx("span",{className:"as-title",children:"🔌 Agent 在线状态"}),l.jsxs("span",{className:`as-gw ${B}`,children:["Gateway: ",(P==null?void 0:P.status)||"未知"]}),l.jsx("button",{className:"btn-refresh",onClick:()=>k(),style:{marginLeft:8},children:"🔄 刷新"}),g+M>0&&l.jsx("button",{className:"btn-refresh",onClick:z,style:{marginLeft:4,borderColor:"var(--warn)",color:"var(--warn)"},children:"⚡ 全部唤醒"})]}),l.jsx("div",{className:"as-grid",children:w.map(I=>{const oe=I.status!=="running"&&I.status!=="unconfigured"&&(P==null?void 0:P.alive);return l.jsxs("div",{className:"as-card",title:`${I.role} · ${I.statusLabel}`,children:[l.jsx("div",{className:`as-dot ${I.status}`}),l.jsx("div",{style:{fontSize:22},children:I.emoji}),l.jsx("div",{style:{fontSize:12,fontWeight:700},children:I.label}),l.jsx("div",{style:{fontSize:10,color:"var(--muted)"},children:I.role}),l.jsx("div",{style:{fontSize:10,color:"var(--muted)"},children:I.statusLabel}),I.lastActive?l.jsxs("div",{style:{fontSize:10,color:"var(--muted)"},children:["⏰ ",I.lastActive]}):l.jsx("div",{style:{fontSize:10,color:"var(--muted)"},children:"无活动记录"}),oe&&l.jsx("button",{className:"as-wake-btn",onClick:ue=>{ue.stopPropagation(),C(I.id)},children:"⚡ 唤醒"})]},I.id)})}),l.jsxs("div",{className:"as-summary",children:[l.jsxs("span",{children:[l.jsx("span",{className:"as-dot running",style:{position:"static",width:8,height:8}})," ",m," 运行中"]}),l.jsxs("span",{children:[l.jsx("span",{className:"as-dot idle",style:{position:"static",width:8,height:8}})," ",T," 待命"]}),g>0&&l.jsxs("span",{children:[l.jsx("span",{className:"as-dot offline",style:{position:"static",width:8,height:8}})," ",g," 离线"]}),M>0&&l.jsxs("span",{children:[l.jsx("span",{className:"as-dot unconfigured",style:{position:"static",width:8,height:8}})," ",M," 未配置"]}),l.jsxs("span",{style:{marginLeft:"auto",fontSize:10,color:"var(--muted)"},children:["检测于 ",(d.checkedAt||"").substring(11,19)]})]})]}),l.jsx("div",{className:"duty-grid",children:Of.map(I=>{const oe=_.filter(se=>se.org===I.label),ue=oe.some(se=>se.state==="Doing"),pe=oe.some(se=>se.state==="Blocked"),me=R[I.id],be=(me==null?void 0:me.heartbeat)||{status:"idle"},X=pe?"blocked":ue?"busy":be.status==="active"?"active":"idle",le=pe?"⚠️ 阻塞":ue?"⚙️ 执行中":be.status==="active"?"🟢 活跃":"⚪ 候命",ke=pe?"blocked-card":ue?"active-card":"";return l.jsxs("div",{className:`duty-card ${ke}`,children:[l.jsxs("div",{className:"dc-hdr",children:[l.jsx("span",{className:"dc-emoji",children:I.emoji}),l.jsxs("div",{className:"dc-info",children:[l.jsx("div",{className:"dc-name",children:I.label}),l.jsxs("div",{className:"dc-role",children:[I.role," · ",I.rank]})]}),l.jsxs("div",{className:"dc-status",children:[l.jsx("span",{className:`dc-dot ${X}`}),l.jsx("span",{children:le})]})]}),l.jsx("div",{className:"dc-body",children:oe.length>0?oe.map(se=>l.jsxs("div",{className:"dc-task",onClick:()=>S(se.id),children:[l.jsx("div",{className:"dc-task-id",children:se.id}),l.jsx("div",{className:"dc-task-title",children:se.title||"(无标题)"}),se.now&&se.now!=="-"&&l.jsx("div",{className:"dc-task-now",children:se.now.substring(0,70)}),l.jsxs("div",{className:"dc-task-meta",children:[l.jsx("span",{className:`tag st-${se.state}`,children:Ki(se)}),se.block&&se.block!=="无"&&l.jsxs("span",{className:"tag",style:{borderColor:"#ff527044",color:"var(--danger)"},children:["🚫",se.block]})]})]},se.id)):l.jsxs("div",{className:"dc-idle",children:[l.jsx("span",{style:{fontSize:20},children:"🪭"}),l.jsx("span",{children:"候命中"})]})}),l.jsxs("div",{className:"dc-footer",children:[l.jsxs("span",{className:"dc-model",children:["🤖 ",(me==null?void 0:me.model_short)||"待配置"]}),(me==null?void 0:me.last_active)&&l.jsxs("span",{className:"dc-la",children:["⏰ ",me.last_active]})]})]},I.id)})})]})}const Gf=["🥇","🥈","🥉"];function Yf(){var d;const o=q(w=>w.officialsData),p=q(w=>w.selectedOfficial),u=q(w=>w.setSelectedOfficial),k=q(w=>w.loadOfficials),S=q(w=>w.setModalTaskId);if(te.useEffect(()=>{k()},[k]),!(o!=null&&o.officials))return l.jsx("div",{className:"empty",children:"⚠️ 请确保本地服务器已启动"});const D=o.officials,F=o.totals||{tasks_done:0,cost_cny:0},_=Math.max(...D.map(w=>w.tokens_in+w.tokens_out+w.cache_read+w.cache_write),1),R=D.filter(w=>{var m;return((m=w.heartbeat)==null?void 0:m.status)==="active"}),C=D.find(w=>{var m;return w.id===(p||((m=D[0])==null?void 0:m.id))}),z=(C==null?void 0:C.id)||((d=D[0])==null?void 0:d.id);return l.jsxs("div",{children:[R.length>0&&l.jsxs("div",{className:"off-activity",children:[l.jsx("span",{children:"🟢 当前活跃:"}),R.map(w=>l.jsxs("span",{style:{fontSize:12},children:[w.emoji," ",w.role]},w.id)),l.jsx("span",{style:{color:"var(--muted)",fontSize:11,marginLeft:"auto"},children:"其余官员待命"})]}),l.jsxs("div",{className:"off-kpi",children:[l.jsxs("div",{className:"kpi",children:[l.jsx("div",{className:"kpi-v",style:{color:"var(--acc)"},children:D.length}),l.jsx("div",{className:"kpi-l",children:"在职官员"})]}),l.jsxs("div",{className:"kpi",children:[l.jsx("div",{className:"kpi-v",style:{color:"#f5c842"},children:F.tasks_done||0}),l.jsx("div",{className:"kpi-l",children:"累计完成旨意"})]}),l.jsxs("div",{className:"kpi",children:[l.jsxs("div",{className:"kpi-v",style:{color:(F.cost_cny||0)>20?"var(--warn)":"var(--ok)"},children:["¥",F.cost_cny||0]}),l.jsx("div",{className:"kpi-l",children:"累计费用(含缓存)"})]}),l.jsxs("div",{className:"kpi",children:[l.jsx("div",{className:"kpi-v",style:{fontSize:16,paddingTop:4},children:o.top_official||"—"}),l.jsx("div",{className:"kpi-l",children:"功绩最高"})]})]}),l.jsxs("div",{className:"off-layout",children:[l.jsxs("div",{className:"off-ranklist",children:[l.jsx("div",{className:"orl-hdr",children:"功绩排行"}),D.map(w=>{const m=w.heartbeat||{status:"idle"};return l.jsxs("div",{className:`orl-item${z===w.id?" selected":""}`,onClick:()=>u(w.id),children:[l.jsx("span",{style:{minWidth:24,textAlign:"center"},children:w.merit_rank<=3?Gf[w.merit_rank-1]:"#"+w.merit_rank}),l.jsx("span",{children:w.emoji}),l.jsxs("span",{style:{flex:1},children:[l.jsx("div",{style:{fontSize:12,fontWeight:700},children:w.role}),l.jsx("div",{style:{fontSize:10,color:"var(--muted)"},children:w.label})]}),l.jsxs("span",{style:{fontSize:11},children:[w.merit_score,"分"]}),l.jsx("span",{className:`dc-dot ${m.status}`,style:{width:8,height:8}})]},w.id)})]}),l.jsx("div",{className:"off-detail",children:C?l.jsx(Xf,{official:C,maxTk:_,onOpenTask:S}):l.jsx("div",{className:"empty",children:"选择左侧官员查看详情"})})]})]})}function Xf({official:o,maxTk:p,onOpenTask:u}){const k=o.heartbeat||{status:"idle",label:"⚪ 待命"},S=o.tokens_in+o.tokens_out+o.cache_read+o.cache_write,D=o.participated_edicts||[],F=[{l:"输入",v:o.tokens_in,color:"#6a9eff"},{l:"输出",v:o.tokens_out,color:"#a07aff"},{l:"缓存读",v:o.cache_read,color:"#2ecc8a"},{l:"缓存写",v:o.cache_write,color:"#f5c842"}];return l.jsxs("div",{children:[l.jsxs("div",{style:{display:"flex",gap:16,alignItems:"center",marginBottom:20},children:[l.jsx("div",{style:{fontSize:40},children:o.emoji}),l.jsxs("div",{style:{flex:1},children:[l.jsx("div",{style:{fontSize:18,fontWeight:800},children:o.role}),l.jsxs("div",{style:{fontSize:12,color:"var(--muted)"},children:[o.label," · ",l.jsx("span",{style:{color:"var(--acc)"},children:o.model_short||o.model})]}),l.jsxs("div",{style:{fontSize:11,color:"var(--muted)",marginTop:2},children:["🏅 ",o.rank," · 功绩分 ",o.merit_score]})]}),l.jsxs("div",{style:{textAlign:"right"},children:[l.jsx("div",{className:`hb ${k.status}`,style:{marginBottom:4},children:k.label}),o.last_active&&l.jsxs("div",{style:{fontSize:10,color:"var(--muted)"},children:["活跃 ",o.last_active]}),l.jsxs("div",{style:{fontSize:10,color:"var(--muted)",marginTop:2},children:[o.sessions," 个会话 · ",o.messages," 条消息"]})]})]}),l.jsxs("div",{style:{marginBottom:18},children:[l.jsx("div",{className:"sec-title",children:"功绩统计"}),l.jsxs("div",{style:{display:"flex",gap:16},children:[l.jsxs("div",{style:{textAlign:"center"},children:[l.jsx("div",{style:{fontSize:20,fontWeight:800,color:"var(--ok)"},children:o.tasks_done}),l.jsx("div",{style:{fontSize:10,color:"var(--muted)"},children:"完成旨意"})]}),l.jsxs("div",{style:{textAlign:"center"},children:[l.jsx("div",{style:{fontSize:20,fontWeight:800,color:"var(--warn)"},children:o.tasks_active}),l.jsx("div",{style:{fontSize:10,color:"var(--muted)"},children:"执行中"})]}),l.jsxs("div",{style:{textAlign:"center"},children:[l.jsx("div",{style:{fontSize:20,fontWeight:800,color:"var(--acc)"},children:o.flow_participations}),l.jsx("div",{style:{fontSize:10,color:"var(--muted)"},children:"流转参与"})]})]})]}),l.jsxs("div",{style:{marginBottom:18},children:[l.jsx("div",{className:"sec-title",children:"Token 消耗"}),F.map(_=>l.jsxs("div",{style:{marginBottom:6},children:[l.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontSize:11,marginBottom:2},children:[l.jsx("span",{style:{color:"var(--muted)"},children:_.l}),l.jsx("span",{children:_.v.toLocaleString()})]}),l.jsx("div",{style:{height:6,background:"#0e1320",borderRadius:3},children:l.jsx("div",{style:{height:"100%",width:`${p>0?Math.round(_.v/p*100):0}%`,background:_.color,borderRadius:3}})})]},_.l))]}),l.jsxs("div",{style:{marginBottom:18},children:[l.jsx("div",{className:"sec-title",children:"累计费用"}),l.jsxs("div",{style:{display:"flex",gap:10},children:[l.jsxs("span",{style:{fontSize:12,color:o.cost_cny>10?"var(--danger)":o.cost_cny>3?"var(--warn)":"var(--ok)"},children:[l.jsxs("b",{children:["¥",o.cost_cny]})," 人民币"]}),l.jsxs("span",{style:{fontSize:12},children:[l.jsxs("b",{children:["$",o.cost_usd]})," 美元"]}),l.jsxs("span",{style:{fontSize:11,color:"var(--muted)"},children:["总计 ",S.toLocaleString()," tokens"]})]})]}),l.jsxs("div",{children:[l.jsxs("div",{className:"sec-title",children:["参与旨意(",D.length," 道)"]}),D.length===0?l.jsx("div",{style:{fontSize:12,color:"var(--muted)",padding:"8px 0"},children:"暂无旨意记录"}):l.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4},children:D.map(_=>l.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center",padding:"6px 8px",borderRadius:6,cursor:"pointer",border:"1px solid var(--line)"},onClick:()=>u(_.id),children:[l.jsx("span",{style:{fontSize:10,color:"var(--acc)",fontWeight:700},children:_.id}),l.jsx("span",{style:{flex:1,fontSize:12},children:_.title.substring(0,35)}),l.jsx("span",{className:`tag st-${_.state}`,style:{fontSize:10},children:zr[_.state]||_.state})]},_.id))})]})]})}const Zf=[{id:"anthropic/claude-sonnet-4-6",l:"Claude Sonnet 4.6",p:"Anthropic"},{id:"anthropic/claude-opus-4-5",l:"Claude Opus 4.5",p:"Anthropic"},{id:"anthropic/claude-haiku-3-5",l:"Claude Haiku 3.5",p:"Anthropic"},{id:"openai/gpt-4o",l:"GPT-4o",p:"OpenAI"},{id:"openai/gpt-4o-mini",l:"GPT-4o Mini",p:"OpenAI"},{id:"google/gemini-2.5-pro",l:"Gemini 2.5 Pro",p:"Google"},{id:"copilot/claude-sonnet-4",l:"Claude Sonnet 4",p:"Copilot"},{id:"copilot/claude-opus-4.5",l:"Claude Opus 4.5",p:"Copilot"},{id:"copilot/gpt-4o",l:"GPT-4o",p:"Copilot"},{id:"copilot/gemini-2.5-pro",l:"Gemini 2.5 Pro",p:"Copilot"}];function qf(){var w;const o=q(m=>m.agentConfig),p=q(m=>m.changeLog),u=q(m=>m.loadAgentConfig),k=q(m=>m.toast),[S,D]=te.useState({}),[F,_]=te.useState({});if(te.useEffect(()=>{u()},[u]),te.useEffect(()=>{if(o!=null&&o.agents){const m={};o.agents.forEach(T=>{m[T.id]=T.model}),D(m)}},[o]),!(o!=null&&o.agents))return l.jsx("div",{className:"empty",style:{gridColumn:"1/-1"},children:"⚠️ 请先启动本地服务器"});const R=(w=o.knownModels)!=null&&w.length?o.knownModels.map(m=>({id:m.id,l:m.label,p:m.provider})):Zf,C=(m,T)=>{D(g=>({...g,[m]:T}))},z=m=>{const T=o.agents.find(g=>g.id===m);T&&D(g=>({...g,[m]:T.model}))},d=async m=>{const T=S[m];if(T){_(g=>({...g,[m]:{cls:"pending",text:"⟳ 提交中…"}}));try{const g=await fe.setModel(m,T);g.ok?(_(M=>({...M,[m]:{cls:"ok",text:"✅ 已提交,Gateway 重启中(约5秒)"}})),k(m+" 模型已更改","ok"),setTimeout(()=>u(),5500)):_(M=>({...M,[m]:{cls:"err",text:"❌ "+(g.error||"错误")}}))}catch{_(g=>({...g,[m]:{cls:"err",text:"❌ 无法连接服务器"}}))}}};return l.jsxs("div",{children:[l.jsx("div",{className:"model-grid",children:o.agents.map(m=>{const T=S[m.id]||m.model,g=T!==m.model,M=F[m.id];return l.jsxs("div",{className:"mc-card",children:[l.jsxs("div",{className:"mc-top",children:[l.jsx("span",{className:"mc-emoji",children:m.emoji||"🏛️"}),l.jsxs("div",{children:[l.jsxs("div",{className:"mc-name",children:[m.label," ",l.jsx("span",{style:{fontSize:11,color:"var(--muted)"},children:m.id})]}),l.jsx("div",{className:"mc-role",children:m.role})]})]}),l.jsxs("div",{className:"mc-cur",children:["当前: ",l.jsx("b",{children:m.model})]}),l.jsx("select",{className:"msel",value:T,onChange:P=>C(m.id,P.target.value),children:R.map(P=>l.jsxs("option",{value:P.id,children:[P.l," (",P.p,")"]},P.id))}),l.jsxs("div",{className:"mc-btns",children:[l.jsx("button",{className:"btn btn-p",disabled:!g,onClick:()=>d(m.id),children:"应用"}),l.jsx("button",{className:"btn btn-g",onClick:()=>z(m.id),children:"重置"})]}),M&&l.jsx("div",{className:`mc-st ${M.cls}`,children:M.text})]},m.id)})}),l.jsxs("div",{style:{marginTop:24},children:[l.jsx("div",{className:"sec-title",children:"变更日志"}),l.jsx("div",{className:"cl-list",children:p!=null&&p.length?[...p].reverse().slice(0,15).map((m,T)=>l.jsxs("div",{className:"cl-row",children:[l.jsx("span",{className:"cl-t",children:(m.at||"").substring(0,16).replace("T"," ")}),l.jsx("span",{className:"cl-a",children:m.agentId}),l.jsxs("span",{className:"cl-c",children:[l.jsx("b",{children:m.oldModel})," → ",l.jsx("b",{children:m.newModel}),m.rolledBack&&l.jsx("span",{style:{color:"var(--danger)",fontSize:10,border:"1px solid #ff527044",padding:"1px 5px",borderRadius:3,marginLeft:4},children:"⚠ 已回滚"})]})]},T)):l.jsx("div",{style:{fontSize:12,color:"var(--muted)",padding:"8px 0"},children:"暂无变更"})})]})]})}const Jf=[{label:"obra/superpowers",emoji:"⚡",stars:"66.9k",desc:"完整开发工作流技能集",skills:[{name:"brainstorming",url:"https://raw.githubusercontent.com/obra/superpowers/refs/heads/main/skills/brainstorming/SKILL.md"},{name:"test-driven-development",url:"https://raw.githubusercontent.com/obra/superpowers/refs/heads/main/skills/test-driven-development/SKILL.md"},{name:"systematic-debugging",url:"https://raw.githubusercontent.com/obra/superpowers/refs/heads/main/skills/systematic-debugging/SKILL.md"},{name:"subagent-driven-development",url:"https://raw.githubusercontent.com/obra/superpowers/refs/heads/main/skills/subagent-driven-development/SKILL.md"},{name:"writing-plans",url:"https://raw.githubusercontent.com/obra/superpowers/refs/heads/main/skills/writing-plans/SKILL.md"},{name:"executing-plans",url:"https://raw.githubusercontent.com/obra/superpowers/refs/heads/main/skills/executing-plans/SKILL.md"},{name:"requesting-code-review",url:"https://raw.githubusercontent.com/obra/superpowers/refs/heads/main/skills/requesting-code-review/SKILL.md"},{name:"root-cause-tracing",url:"https://raw.githubusercontent.com/obra/superpowers/refs/heads/main/skills/root-cause-tracing/SKILL.md"},{name:"verification-before-completion",url:"https://raw.githubusercontent.com/obra/superpowers/refs/heads/main/skills/verification-before-completion/SKILL.md"},{name:"dispatching-parallel-agents",url:"https://raw.githubusercontent.com/obra/superpowers/refs/heads/main/skills/dispatching-parallel-agents/SKILL.md"}]},{label:"anthropics/skills",emoji:"🏛️",stars:"官方",desc:"Anthropic 官方技能库",skills:[{name:"docx",url:"https://raw.githubusercontent.com/anthropics/skills/main/skills/docx/SKILL.md"},{name:"pdf",url:"https://raw.githubusercontent.com/anthropics/skills/main/skills/pdf/SKILL.md"},{name:"xlsx",url:"https://raw.githubusercontent.com/anthropics/skills/main/skills/xlsx/SKILL.md"},{name:"pptx",url:"https://raw.githubusercontent.com/anthropics/skills/main/skills/pptx/SKILL.md"},{name:"mcp-builder",url:"https://raw.githubusercontent.com/anthropics/skills/main/skills/mcp-builder/SKILL.md"},{name:"frontend-design",url:"https://raw.githubusercontent.com/anthropics/skills/main/skills/frontend-design/SKILL.md"},{name:"web-artifacts-builder",url:"https://raw.githubusercontent.com/anthropics/skills/main/skills/web-artifacts-builder/SKILL.md"},{name:"webapp-testing",url:"https://raw.githubusercontent.com/anthropics/skills/main/skills/webapp-testing/SKILL.md"},{name:"algorithmic-art",url:"https://raw.githubusercontent.com/anthropics/skills/main/skills/algorithmic-art/SKILL.md"},{name:"canvas-design",url:"https://raw.githubusercontent.com/anthropics/skills/main/skills/canvas-design/SKILL.md"}]},{label:"ComposioHQ/awesome-claude-skills",emoji:"🌐",stars:"39.2k",desc:"100+ 社区精选技能",skills:[{name:"github-integration",url:"https://raw.githubusercontent.com/ComposioHQ/awesome-claude-skills/master/github-integration/SKILL.md"},{name:"data-analysis",url:"https://raw.githubusercontent.com/ComposioHQ/awesome-claude-skills/master/data-analysis/SKILL.md"},{name:"code-review",url:"https://raw.githubusercontent.com/ComposioHQ/awesome-claude-skills/master/code-review/SKILL.md"}]}];function ep(){const o=q(x=>x.agentConfig),p=q(x=>x.loadAgentConfig),u=q(x=>x.toast),[k,S]=te.useState(null),[D,F]=te.useState(null),[_,R]=te.useState({name:"",desc:"",trigger:""}),[C,z]=te.useState(!1),[d,w]=te.useState("local"),[m,T]=te.useState([]),[g,M]=te.useState(!1),[P,B]=te.useState(!1),[Z,I]=te.useState({agentId:"",skillName:"",sourceUrl:"",description:""}),[oe,ue]=te.useState(!1),[pe,me]=te.useState(null),[be,X]=te.useState(null),[le,ke]=te.useState(null),[se,J]=te.useState("");te.useEffect(()=>{p()},[p]),te.useEffect(()=>{d==="remote"&&Ne()},[d]);const Ne=async()=>{M(!0);try{const x=await fe.remoteSkillsList();x.ok&&T(x.remoteSkills||[])}catch{u("远程技能列表加载失败","err")}M(!1)},_e=async(x,U)=>{S({agentId:x,name:U,content:"⟳ 加载中…",path:""});try{const ee=await fe.skillContent(x,U);ee.ok?S({agentId:x,name:U,content:ee.content||"",path:ee.path||""}):S({agentId:x,name:U,content:"❌ "+(ee.error||"无法读取"),path:""})}catch{S({agentId:x,name:U,content:"❌ 服务器连接失败",path:""})}},xe=(x,U)=>{F({agentId:x,agentLabel:U}),R({name:"",desc:"",trigger:""})},E=async x=>{if(x.preventDefault(),!(!D||!_.name)){z(!0);try{const U=await fe.addSkill(D.agentId,_.name,_.desc,_.trigger);U.ok?(u(`✅ 技能 ${_.name} 已添加到 ${D.agentLabel}`,"ok"),F(null),p()):u(U.error||"添加失败","err")}catch{u("服务器连接失败","err")}z(!1)}},Q=async x=>{x.preventDefault();const{agentId:U,skillName:ee,sourceUrl:he,description:ve}=Z;if(!(!U||!ee||!he)){ue(!0);try{const Me=await fe.addRemoteSkill(U,ee,he,ve);Me.ok?(u(`✅ 远程技能 ${ee} 已添加到 ${U}`,"ok"),B(!1),I({agentId:"",skillName:"",sourceUrl:"",description:""}),Ne(),p()):u(Me.error||"添加失败","err")}catch{u("服务器连接失败","err")}ue(!1)}},W=async x=>{const U=`${x.agentId}/${x.skillName}`;me(U);try{const ee=await fe.updateRemoteSkill(x.agentId,x.skillName);ee.ok?(u(`✅ 技能 ${x.skillName} 已更新`,"ok"),Ne()):u(ee.error||"更新失败","err")}catch{u("服务器连接失败","err")}me(null)},v=async x=>{const U=`${x.agentId}/${x.skillName}`;X(U);try{const ee=await fe.removeRemoteSkill(x.agentId,x.skillName);ee.ok?(u(`🗑️ 技能 ${x.skillName} 已移除`,"ok"),Ne(),p()):u(ee.error||"移除失败","err")}catch{u("服务器连接失败","err")}X(null)},L=async(x,U)=>{if(!se){u("请先选择目标 Agent","err");return}try{const ee=await fe.addRemoteSkill(se,U,x,"");ee.ok?(u(`✅ ${U} → ${se}`,"ok"),Ne(),p()):u(ee.error||"导入失败","err")}catch{u("服务器连接失败","err")}};if(!(o!=null&&o.agents))return l.jsx("div",{className:"empty",children:"无法加载"});const ae=l.jsx("div",{children:l.jsx("div",{className:"skills-grid",children:o.agents.map(x=>l.jsxs("div",{className:"sk-card",children:[l.jsxs("div",{className:"sk-hdr",children:[l.jsx("span",{className:"sk-emoji",children:x.emoji||"🏛️"}),l.jsx("span",{className:"sk-name",children:x.label}),l.jsxs("span",{className:"sk-cnt",children:[(x.skills||[]).length," 技能"]})]}),l.jsx("div",{className:"sk-list",children:(x.skills||[]).length?(x.skills||[]).map(U=>l.jsxs("div",{className:"sk-item",onClick:()=>_e(x.id,U.name),children:[l.jsxs("span",{className:"si-name",children:["📦 ",U.name]}),l.jsx("span",{className:"si-desc",children:U.description||"无描述"}),l.jsx("span",{className:"si-arrow",children:"›"})]},U.name)):l.jsx("div",{className:"sk-empty",children:"暂无 Skills"})}),l.jsx("div",{className:"sk-add",onClick:()=>xe(x.id,x.label),children:"+ 添加技能"})]},x.id))})}),ce=l.jsxs("div",{children:[l.jsxs("div",{style:{display:"flex",gap:10,marginBottom:20,flexWrap:"wrap",alignItems:"center"},children:[l.jsx("button",{style:{padding:"8px 18px",background:"var(--acc)",color:"#fff",border:"none",borderRadius:8,cursor:"pointer",fontWeight:600,fontSize:13},onClick:()=>{B(!0),ke(null)},children:"+ 添加远程 Skill"}),l.jsx("button",{style:{padding:"8px 14px",background:"transparent",color:"var(--acc)",border:"1px solid var(--acc)",borderRadius:8,cursor:"pointer",fontSize:12},onClick:Ne,children:"⟳ 刷新列表"}),l.jsxs("span",{style:{fontSize:11,color:"var(--muted)",marginLeft:4},children:["共 ",m.length," 个远程技能"]})]}),l.jsxs("div",{style:{marginBottom:24},children:[l.jsx("div",{style:{fontSize:12,fontWeight:700,color:"var(--muted)",letterSpacing:".06em",marginBottom:10},children:"🌐 社区技能源 — 一键导入"}),l.jsx("div",{style:{display:"flex",gap:10,flexWrap:"wrap"},children:Jf.map(x=>l.jsxs("div",{onClick:()=>ke((le==null?void 0:le.label)===x.label?null:x),style:{padding:"8px 14px",background:(le==null?void 0:le.label)===x.label?"#0d1f45":"var(--panel)",border:`1px solid ${(le==null?void 0:le.label)===x.label?"var(--acc)":"var(--line)"}`,borderRadius:10,cursor:"pointer",fontSize:12,transition:"all .15s"},children:[l.jsx("span",{style:{marginRight:6},children:x.emoji}),l.jsx("b",{style:{color:"var(--text)"},children:x.label}),l.jsxs("span",{style:{marginLeft:6,color:"#f0b429",fontSize:11},children:["★ ",x.stars]}),l.jsx("span",{style:{marginLeft:8,color:"var(--muted)"},children:x.desc})]},x.label))}),le&&l.jsxs("div",{style:{marginTop:14,background:"var(--panel)",border:"1px solid var(--line)",borderRadius:12,padding:16},children:[l.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,marginBottom:14},children:[l.jsx("span",{style:{fontSize:12,fontWeight:600},children:"目标 Agent:"}),l.jsxs("select",{value:se,onChange:x=>J(x.target.value),style:{padding:"6px 10px",background:"var(--bg)",border:"1px solid var(--line)",borderRadius:6,color:"var(--text)",fontSize:12},children:[l.jsx("option",{value:"",children:"— 选择 Agent —"}),o.agents.map(x=>l.jsxs("option",{value:x.id,children:[x.emoji," ",x.label," (",x.id,")"]},x.id))]})]}),l.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(260px, 1fr))",gap:8},children:le.skills.map(x=>{const U=m.some(ee=>ee.skillName===x.name&&ee.agentId===se);return l.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 12px",background:"var(--panel2)",borderRadius:8,border:"1px solid var(--line)"},children:[l.jsxs("div",{children:[l.jsxs("div",{style:{fontSize:12,fontWeight:600},children:["📦 ",x.name]}),l.jsx("div",{style:{fontSize:10,color:"var(--muted)",wordBreak:"break-all",maxWidth:180},children:x.url.split("/").slice(-2).join("/")})]}),U?l.jsx("span",{style:{fontSize:10,color:"#4caf88",fontWeight:600},children:"✓ 已导入"}):l.jsx("button",{onClick:()=>L(x.url,x.name),style:{padding:"4px 10px",background:"var(--acc)",color:"#fff",border:"none",borderRadius:6,cursor:"pointer",fontSize:11,whiteSpace:"nowrap"},children:"导入"})]},x.name)})})]})]}),g?l.jsx("div",{style:{textAlign:"center",padding:"40px 0",color:"var(--muted)",fontSize:13},children:"⟳ 加载中…"}):m.length===0?l.jsxs("div",{style:{textAlign:"center",padding:"40px",background:"var(--panel)",borderRadius:12,border:"1px dashed var(--line)"},children:[l.jsx("div",{style:{fontSize:32,marginBottom:10},children:"🌐"}),l.jsx("div",{style:{fontSize:14,color:"var(--muted)"},children:"尚无远程技能"}),l.jsx("div",{style:{fontSize:12,color:"var(--muted)",marginTop:6},children:"从社区技能源快速导入,或手动添加 URL"})]}):l.jsx("div",{style:{display:"flex",flexDirection:"column",gap:10},children:m.map(x=>{var Me;const U=`${x.agentId}/${x.skillName}`,ee=pe===U,he=be===U,ve=o.agents.find(mn=>mn.id===x.agentId);return l.jsxs("div",{style:{background:"var(--panel)",border:"1px solid var(--line)",borderRadius:12,padding:"14px 18px",display:"grid",gridTemplateColumns:"1fr auto",gap:12,alignItems:"center"},children:[l.jsxs("div",{children:[l.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:6},children:[l.jsxs("span",{style:{fontSize:14,fontWeight:700},children:["📦 ",x.skillName]}),l.jsx("span",{style:{fontSize:10,padding:"2px 8px",borderRadius:999,background:x.status==="valid"?"#0d3322":"#3d1111",color:x.status==="valid"?"#4caf88":"#ff5270",fontWeight:600},children:x.status==="valid"?"✓ 有效":"✗ 文件丢失"}),l.jsxs("span",{style:{fontSize:11,color:"var(--muted)",background:"var(--panel2)",padding:"2px 8px",borderRadius:6},children:[ve==null?void 0:ve.emoji," ",(ve==null?void 0:ve.label)||x.agentId]})]}),x.description&&l.jsx("div",{style:{fontSize:12,color:"var(--muted)",marginBottom:4},children:x.description}),l.jsxs("div",{style:{fontSize:10,color:"var(--muted)",display:"flex",gap:16,flexWrap:"wrap"},children:[l.jsxs("span",{children:["🔗 ",l.jsx("a",{href:x.sourceUrl,target:"_blank",rel:"noreferrer",style:{color:"var(--acc)",textDecoration:"none"},children:x.sourceUrl.length>60?x.sourceUrl.slice(0,60)+"…":x.sourceUrl})]}),l.jsxs("span",{children:["📅 ",x.lastUpdated?x.lastUpdated.slice(0,10):(Me=x.addedAt)==null?void 0:Me.slice(0,10)]})]})]}),l.jsxs("div",{style:{display:"flex",gap:8},children:[l.jsx("button",{onClick:()=>_e(x.agentId,x.skillName),style:{padding:"6px 12px",background:"transparent",color:"var(--muted)",border:"1px solid var(--line)",borderRadius:6,cursor:"pointer",fontSize:11},children:"查看"}),l.jsx("button",{onClick:()=>W(x),disabled:ee,style:{padding:"6px 12px",background:"transparent",color:"var(--acc)",border:"1px solid var(--acc)",borderRadius:6,cursor:"pointer",fontSize:11},children:ee?"⟳":"更新"}),l.jsx("button",{onClick:()=>v(x),disabled:he,style:{padding:"6px 12px",background:"transparent",color:"#ff5270",border:"1px solid #ff5270",borderRadius:6,cursor:"pointer",fontSize:11},children:he?"⟳":"删除"})]})]},U)})})]});return l.jsxs("div",{children:[l.jsx("div",{style:{display:"flex",gap:4,marginBottom:20,borderBottom:"1px solid var(--line)",paddingBottom:0},children:[{key:"local",label:"🏛️ 本地技能",count:o.agents.reduce((x,U)=>{var ee;return x+(((ee=U.skills)==null?void 0:ee.length)||0)},0)},{key:"remote",label:"🌐 远程技能",count:m.length}].map(x=>l.jsxs("div",{onClick:()=>w(x.key),style:{padding:"8px 18px",cursor:"pointer",fontSize:13,borderRadius:"8px 8px 0 0",fontWeight:d===x.key?700:400,background:d===x.key?"var(--panel)":"transparent",color:d===x.key?"var(--text)":"var(--muted)",border:d===x.key?"1px solid var(--line)":"1px solid transparent",borderBottom:d===x.key?"1px solid var(--panel)":"1px solid transparent",position:"relative",bottom:-1,transition:"all .15s"},children:[x.label,x.count>0&&l.jsx("span",{style:{marginLeft:6,fontSize:10,padding:"1px 6px",borderRadius:999,background:"#1a2040",color:"var(--acc)"},children:x.count})]},x.key))}),d==="local"?ae:ce,k&&l.jsx("div",{className:"modal-bg open",onClick:()=>S(null),children:l.jsxs("div",{className:"modal",onClick:x=>x.stopPropagation(),children:[l.jsx("button",{className:"modal-close",onClick:()=>S(null),children:"✕"}),l.jsxs("div",{className:"modal-body",children:[l.jsx("div",{style:{fontSize:11,color:"var(--acc)",fontWeight:700,letterSpacing:".04em",marginBottom:4},children:k.agentId.toUpperCase()}),l.jsxs("div",{style:{fontSize:20,fontWeight:800,marginBottom:16},children:["📦 ",k.name]}),l.jsxs("div",{className:"sk-modal-body",children:[l.jsx("div",{className:"sk-md",style:{whiteSpace:"pre-wrap",fontSize:12,lineHeight:1.7},children:k.content}),k.path&&l.jsxs("div",{className:"sk-path",style:{fontSize:10,color:"var(--muted)",marginTop:12},children:["📂 ",k.path]})]})]})]})}),D&&l.jsx("div",{className:"modal-bg open",onClick:()=>F(null),children:l.jsxs("div",{className:"modal",onClick:x=>x.stopPropagation(),children:[l.jsx("button",{className:"modal-close",onClick:()=>F(null),children:"✕"}),l.jsxs("div",{className:"modal-body",children:[l.jsxs("div",{style:{fontSize:11,color:"var(--acc)",fontWeight:700,letterSpacing:".04em",marginBottom:4},children:["为 ",D.agentLabel," 添加技能"]}),l.jsx("div",{style:{fontSize:20,fontWeight:800,marginBottom:18},children:"+ 新增 Skill"}),l.jsxs("div",{style:{background:"var(--panel2)",border:"1px solid var(--line)",borderRadius:10,padding:14,marginBottom:18,fontSize:12,lineHeight:1.7,color:"var(--muted)"},children:[l.jsx("b",{style:{color:"var(--text)"},children:"📋 Skill 规范说明"}),l.jsx("br",{}),"• 技能名称使用",l.jsx("b",{style:{color:"var(--text)"},children:"小写英文 + 连字符"}),l.jsx("br",{}),"• 创建后会生成模板文件 SKILL.md",l.jsx("br",{}),"• 技能会在 agent 收到相关任务时",l.jsx("b",{style:{color:"var(--text)"},children:"自动激活"})]}),l.jsxs("form",{onSubmit:E,style:{display:"flex",flexDirection:"column",gap:14},children:[l.jsxs("div",{children:[l.jsxs("label",{style:{fontSize:12,fontWeight:600,display:"block",marginBottom:6},children:["技能名称 ",l.jsx("span",{style:{color:"#ff5270"},children:"*"})]}),l.jsx("input",{type:"text",required:!0,placeholder:"如 data-analysis, code-review",value:_.name,onChange:x=>R(U=>({...U,name:x.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"")})),style:{width:"100%",padding:"10px 12px",background:"var(--bg)",border:"1px solid var(--line)",borderRadius:8,color:"var(--text)",fontSize:13,outline:"none"}})]}),l.jsxs("div",{children:[l.jsx("label",{style:{fontSize:12,fontWeight:600,display:"block",marginBottom:6},children:"技能描述"}),l.jsx("input",{type:"text",placeholder:"一句话说明用途",value:_.desc,onChange:x=>R(U=>({...U,desc:x.target.value})),style:{width:"100%",padding:"10px 12px",background:"var(--bg)",border:"1px solid var(--line)",borderRadius:8,color:"var(--text)",fontSize:13,outline:"none"}})]}),l.jsxs("div",{children:[l.jsx("label",{style:{fontSize:12,fontWeight:600,display:"block",marginBottom:6},children:"触发条件(可选)"}),l.jsx("input",{type:"text",placeholder:"何时激活此技能",value:_.trigger,onChange:x=>R(U=>({...U,trigger:x.target.value})),style:{width:"100%",padding:"10px 12px",background:"var(--bg)",border:"1px solid var(--line)",borderRadius:8,color:"var(--text)",fontSize:13,outline:"none"}})]}),l.jsxs("div",{style:{display:"flex",gap:10,justifyContent:"flex-end",marginTop:4},children:[l.jsx("button",{type:"button",className:"btn btn-g",onClick:()=>F(null),style:{padding:"8px 20px"},children:"取消"}),l.jsx("button",{type:"submit",disabled:C,style:{padding:"8px 20px",fontSize:13,background:"var(--acc)",color:"#fff",border:"none",borderRadius:8,cursor:"pointer",fontWeight:600},children:C?"⟳ 创建中…":"📦 创建技能"})]})]})]})]})}),P&&l.jsx("div",{className:"modal-bg open",onClick:()=>B(!1),children:l.jsxs("div",{className:"modal",style:{maxWidth:520},onClick:x=>x.stopPropagation(),children:[l.jsx("button",{className:"modal-close",onClick:()=>B(!1),children:"✕"}),l.jsxs("div",{className:"modal-body",children:[l.jsx("div",{style:{fontSize:11,color:"#a07aff",fontWeight:700,letterSpacing:".04em",marginBottom:4},children:"远程技能管理"}),l.jsx("div",{style:{fontSize:20,fontWeight:800,marginBottom:18},children:"🌐 添加远程 Skill"}),l.jsxs("div",{style:{background:"var(--panel2)",border:"1px solid var(--line)",borderRadius:10,padding:12,marginBottom:18,fontSize:11,color:"var(--muted)",lineHeight:1.7},children:["支持 GitHub Raw URL,如:",l.jsx("br",{}),l.jsx("code",{style:{color:"var(--acc)",fontSize:10},children:"https://raw.githubusercontent.com/obra/superpowers/refs/heads/main/skills/brainstorming/SKILL.md"})]}),l.jsxs("form",{onSubmit:Q,style:{display:"flex",flexDirection:"column",gap:14},children:[l.jsxs("div",{children:[l.jsxs("label",{style:{fontSize:12,fontWeight:600,display:"block",marginBottom:6},children:["目标 Agent ",l.jsx("span",{style:{color:"#ff5270"},children:"*"})]}),l.jsxs("select",{required:!0,value:Z.agentId,onChange:x=>I(U=>({...U,agentId:x.target.value})),style:{width:"100%",padding:"10px 12px",background:"var(--bg)",border:"1px solid var(--line)",borderRadius:8,color:"var(--text)",fontSize:13},children:[l.jsx("option",{value:"",children:"— 选择 Agent —"}),o.agents.map(x=>l.jsxs("option",{value:x.id,children:[x.emoji," ",x.label," (",x.id,")"]},x.id))]})]}),l.jsxs("div",{children:[l.jsxs("label",{style:{fontSize:12,fontWeight:600,display:"block",marginBottom:6},children:["技能名称 ",l.jsx("span",{style:{color:"#ff5270"},children:"*"})]}),l.jsx("input",{type:"text",required:!0,placeholder:"如 brainstorming, code-review",value:Z.skillName,onChange:x=>I(U=>({...U,skillName:x.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"")})),style:{width:"100%",padding:"10px 12px",background:"var(--bg)",border:"1px solid var(--line)",borderRadius:8,color:"var(--text)",fontSize:13,outline:"none"}})]}),l.jsxs("div",{children:[l.jsxs("label",{style:{fontSize:12,fontWeight:600,display:"block",marginBottom:6},children:["源 URL ",l.jsx("span",{style:{color:"#ff5270"},children:"*"})]}),l.jsx("input",{type:"url",required:!0,placeholder:"https://raw.githubusercontent.com/...",value:Z.sourceUrl,onChange:x=>I(U=>({...U,sourceUrl:x.target.value})),style:{width:"100%",padding:"10px 12px",background:"var(--bg)",border:"1px solid var(--line)",borderRadius:8,color:"var(--text)",fontSize:12,outline:"none"}})]}),l.jsxs("div",{children:[l.jsx("label",{style:{fontSize:12,fontWeight:600,display:"block",marginBottom:6},children:"描述(可选)"}),l.jsx("input",{type:"text",placeholder:"一句话说明用途",value:Z.description,onChange:x=>I(U=>({...U,description:x.target.value})),style:{width:"100%",padding:"10px 12px",background:"var(--bg)",border:"1px solid var(--line)",borderRadius:8,color:"var(--text)",fontSize:13,outline:"none"}})]}),l.jsxs("div",{style:{display:"flex",gap:10,justifyContent:"flex-end",marginTop:4},children:[l.jsx("button",{type:"button",className:"btn btn-g",onClick:()=>B(!1),style:{padding:"8px 20px"},children:"取消"}),l.jsx("button",{type:"submit",disabled:oe,style:{padding:"8px 20px",fontSize:13,background:"#a07aff",color:"#fff",border:"none",borderRadius:8,cursor:"pointer",fontWeight:600},children:oe?"⟳ 下载中…":"🌐 添加远程技能"})]})]})]})]})})]})}function tp(){const o=q(k=>k.agentConfig),p={},u={};return o!=null&&o.agents&&o.agents.forEach(k=>{p[k.id]=k.emoji||"🏛️",u[k.id]=k.label||k.id}),{emojiMap:p,labelMap:u}}function Fl(o){const p=(o.id||"").match(/^OC-(\w+)-/);return p?p[1]:(o.org||"").replace(/省|部/g,"").toLowerCase()}function cc(o,p){let u=o.title||"";if(u==="heartbeat 会话")return"💓 心跳检测";const k=u.match(/^agent:(\w+):(\w+)/);if(k){const S=p[k[1]]||k[1];return k[2]==="main"?S+" · 主会话":k[2]==="subagent"?S+" · 子任务执行":k[2]==="cron"?S+" · 定时任务":S+" · "+k[2]}return u.replace(/ 会话$/,"")||o.id}function dc(o){const p=o.now||"";return p.includes("feishu/direct")?{icon:"💬",text:"飞书对话"}:p.includes("feishu")?{icon:"💬",text:"飞书"}:p.includes("webchat")?{icon:"🌐",text:"WebChat"}:p.includes("cron")?{icon:"⏰",text:"定时"}:p.includes("direct")?{icon:"📨",text:"直连"}:{icon:"🔗",text:"会话"}}function np(o){const p=o.activity||[];for(let u=p.length-1;u>=0;u--){const k=p[u];if(k.kind==="assistant"){let S=k.text||"";if(S.startsWith("NO_REPLY")||S.startsWith("Reasoning:"))continue;return S=S.replace(/\[\[.*?\]\]/g,"").replace(/\*\*/g,"").replace(/^#+\s/gm,"").trim(),S.substring(0,120)+(S.length>120?"…":"")}}return""}function rp(){const o=q(d=>d.liveStatus),p=q(d=>d.sessFilter),u=q(d=>d.setSessFilter),{emojiMap:k,labelMap:S}=tp(),[D,F]=te.useState(null),R=((o==null?void 0:o.tasks)||[]).filter(d=>!Jt(d));let C=R;p==="active"?C=R.filter(d=>!["Done","Cancelled"].includes(d.state)):p!=="all"&&(C=R.filter(d=>Fl(d)===p));const z=[...new Set(R.map(Fl))];return l.jsxs("div",{children:[l.jsx("div",{style:{display:"flex",gap:6,marginBottom:16,flexWrap:"wrap"},children:[{key:"all",label:`全部 (${R.length})`},{key:"active",label:"活跃"},...z.slice(0,8).map(d=>({key:d,label:S[d]||d}))].map(d=>l.jsx("span",{className:`sess-filter${p===d.key?" active":""}`,onClick:()=>u(d.key),children:d.label},d.key))}),l.jsx("div",{className:"sess-grid",children:C.length?C.map(d=>{const w=Fl(d),m=k[w]||"🏛️",T=S[w]||d.org||w,g=d.heartbeat||{status:"unknown",label:""},M=dc(d),P=cc(d,S),B=np(d),I=(d.sourceMeta||{}).totalTokens,oe=d.eta||"",ue=g.status==="active"?"🟢":g.status==="warn"?"🟡":g.status==="stalled"?"🔴":"⚪",pe=d.state||"Unknown";return l.jsxs("div",{className:"sess-card",onClick:()=>F(d),children:[l.jsxs("div",{className:"sc-top",children:[l.jsx("span",{className:"sc-emoji",children:m}),l.jsx("div",{style:{flex:1,minWidth:0},children:l.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[l.jsx("span",{className:"sc-agent",children:T}),l.jsxs("span",{style:{fontSize:10,color:"var(--muted)",background:"var(--panel2)",padding:"2px 6px",borderRadius:4},children:[M.icon," ",M.text]})]})}),l.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[l.jsx("span",{title:g.label||"",children:ue}),l.jsx("span",{className:`tag st-${pe}`,style:{fontSize:10},children:zr[pe]||pe})]})]}),l.jsx("div",{className:"sc-title",children:P}),B&&l.jsx("div",{style:{fontSize:11,color:"var(--muted)",lineHeight:1.5,marginBottom:8,borderLeft:"2px solid var(--line)",paddingLeft:8,maxHeight:40,overflow:"hidden"},children:B}),l.jsxs("div",{className:"sc-meta",children:[I?l.jsxs("span",{style:{fontSize:10,color:"var(--muted)"},children:["🪙 ",I.toLocaleString()," tokens"]}):null,oe?l.jsx("span",{className:"sc-time",children:Uf(oe)}):null]})]},d.id)}):l.jsx("div",{style:{fontSize:13,color:"var(--muted)",padding:24,textAlign:"center",gridColumn:"1/-1"},children:"暂无小任务/会话数据"})}),D&&l.jsx(lp,{task:D,labelMap:S,emojiMap:k,onClose:()=>F(null)})]})}function lp({task:o,labelMap:p,emojiMap:u,onClose:k}){const S=Fl(o),D=u[S]||"🏛️",F=cc(o,p),_=dc(o),R=o.heartbeat||{label:""},C=o.sourceMeta||{},z=o.activity||[],d=o.state||"Unknown",w=C.totalTokens,m=C.inputTokens,T=C.outputTokens;return l.jsx("div",{className:"modal-bg open",onClick:k,children:l.jsxs("div",{className:"modal",onClick:g=>g.stopPropagation(),children:[l.jsx("button",{className:"modal-close",onClick:k,children:"✕"}),l.jsxs("div",{className:"modal-body",children:[l.jsx("div",{style:{fontSize:11,color:"var(--acc)",fontWeight:700,letterSpacing:".04em",marginBottom:4},children:o.id}),l.jsxs("div",{style:{fontSize:20,fontWeight:800,marginBottom:6},children:[D," ",F]}),l.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:18,flexWrap:"wrap"},children:[l.jsx("span",{className:`tag st-${d}`,children:zr[d]||d}),l.jsxs("span",{style:{fontSize:11,color:"var(--muted)"},children:[_.icon," ",_.text]}),R.label&&l.jsx("span",{style:{fontSize:11},children:R.label})]}),l.jsxs("div",{style:{display:"flex",gap:14,marginBottom:18,flexWrap:"wrap"},children:[w!=null&&l.jsxs("div",{style:{background:"var(--panel2)",padding:"10px 16px",borderRadius:8,fontSize:12},children:[l.jsx("div",{style:{fontSize:16,fontWeight:700,color:"var(--acc)"},children:w.toLocaleString()}),l.jsx("div",{style:{color:"var(--muted)",fontSize:10},children:"总 Tokens"})]}),m!=null&&l.jsxs("div",{style:{background:"var(--panel2)",padding:"10px 16px",borderRadius:8,fontSize:12},children:[l.jsx("div",{style:{fontSize:16,fontWeight:700},children:m.toLocaleString()}),l.jsx("div",{style:{color:"var(--muted)",fontSize:10},children:"输入"})]}),T!=null&&l.jsxs("div",{style:{background:"var(--panel2)",padding:"10px 16px",borderRadius:8,fontSize:12},children:[l.jsx("div",{style:{fontSize:16,fontWeight:700},children:T.toLocaleString()}),l.jsx("div",{style:{color:"var(--muted)",fontSize:10},children:"输出"})]})]}),l.jsxs("div",{style:{fontSize:12,fontWeight:700,marginBottom:8},children:["📋 最近活动 ",l.jsxs("span",{style:{fontWeight:400,color:"var(--muted)"},children:["(",z.length," 条)"]})]}),l.jsx("div",{style:{maxHeight:350,overflowY:"auto",border:"1px solid var(--line)",borderRadius:10,background:"var(--panel2)"},children:z.length?z.slice(-15).reverse().map((g,M)=>{const P=g.kind||"",B=P==="assistant"?"🤖":P==="tool"?"🔧":P==="user"?"👤":"📝",Z=P==="assistant"?"回复":P==="tool"?"工具":P==="user"?"用户":"事件";let I=(g.text||"").replace(/\[\[.*?\]\]/g,"").replace(/\*\*/g,"").trim();I.length>200&&(I=I.substring(0,200)+"…");const oe=(g.at||"").substring(11,19);return l.jsxs("div",{style:{padding:"8px 12px",borderBottom:"1px solid var(--line)",fontSize:12,lineHeight:1.5},children:[l.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:3},children:[l.jsx("span",{children:B}),l.jsx("span",{style:{fontWeight:600,fontSize:11},children:Z}),l.jsx("span",{style:{color:"var(--muted)",fontSize:10,marginLeft:"auto"},children:oe})]}),l.jsx("div",{style:{color:"var(--muted)"},children:I})]},M)}):l.jsx("div",{style:{padding:16,color:"var(--muted)",fontSize:12,textAlign:"center"},children:"暂无活动记录"})}),o.output&&o.output!=="-"&&l.jsxs("div",{style:{fontSize:10,color:"var(--muted)",marginTop:12,wordBreak:"break-all",borderTop:"1px solid var(--line)",paddingTop:8},children:["📂 ",o.output]})]})]})})}function sp(){const o=q(C=>C.liveStatus),[p,u]=te.useState("all"),[k,S]=te.useState(null),D=q(C=>C.toast);let _=((o==null?void 0:o.tasks)||[]).filter(C=>Jt(C)&&["Done","Cancelled"].includes(C.state));p!=="all"&&(_=_.filter(C=>C.state===p));const R=C=>{const z=C.flow_log||[];let d=`# 📜 奏折 · ${C.title} - -`;if(d+=`- **任务编号**: ${C.id} -`,d+=`- **状态**: ${C.state} -`,d+=`- **负责部门**: ${C.org} -`,z.length){const w=z[0].at?z[0].at.substring(0,19).replace("T"," "):"未知",m=z[z.length-1].at?z[z.length-1].at.substring(0,19).replace("T"," "):"未知";d+=`- **开始时间**: ${w} -`,d+=`- **完成时间**: ${m} -`}d+=` -## 流转记录 - -`;for(const w of z)d+=`- **${w.from}** → **${w.to}** - ${w.remark} - _${(w.at||"").substring(0,19)}_ - -`;C.output&&C.output!=="-"&&(d+=`## 产出物 - -\`${C.output}\` -`),navigator.clipboard.writeText(d).then(()=>D("✅ 奏折已复制为 Markdown","ok"),()=>D("复制失败","err"))};return l.jsxs("div",{children:[l.jsxs("div",{style:{display:"flex",gap:8,marginBottom:16,alignItems:"center"},children:[l.jsx("span",{style:{fontSize:12,color:"var(--muted)"},children:"筛选:"}),[{key:"all",label:"全部"},{key:"Done",label:"✅ 已完成"},{key:"Cancelled",label:"🚫 已取消"}].map(C=>l.jsx("span",{className:`sess-filter${p===C.key?" active":""}`,onClick:()=>u(C.key),children:C.label},C.key))]}),l.jsx("div",{className:"mem-list",children:_.length?_.map(C=>{const z=C.flow_log||[],d=[...new Set(z.map(g=>g.from).concat(z.map(g=>g.to)).filter(g=>g&&g!=="皇上"))],w=z.length?(z[0].at||"").substring(0,16).replace("T"," "):"",m=z.length?(z[z.length-1].at||"").substring(0,16).replace("T"," "):"",T=C.state==="Done"?"✅":"🚫";return l.jsxs("div",{className:"mem-card",onClick:()=>S(C),children:[l.jsx("div",{className:"mem-icon",children:"📜"}),l.jsxs("div",{className:"mem-info",children:[l.jsxs("div",{className:"mem-title",children:[T," ",C.title||C.id]}),l.jsxs("div",{className:"mem-sub",children:[C.id," · ",C.org||""," · 流转 ",z.length," 步"]}),l.jsx("div",{className:"mem-tags",children:d.slice(0,5).map(g=>l.jsx("span",{className:"mem-tag",children:g},g))})]}),l.jsxs("div",{className:"mem-right",children:[l.jsx("span",{className:"mem-date",children:w}),m!==w&&l.jsx("span",{className:"mem-date",children:m})]})]},C.id)}):l.jsx("div",{className:"mem-empty",children:"暂无奏折 — 任务完成后自动生成"})}),k&&l.jsx(ip,{task:k,onClose:()=>S(null),onExport:R})]})}function ip({task:o,onClose:p,onExport:u}){const k=o.flow_log||[],S=o.state||"Unknown",D=S==="Done"?"✅":S==="Cancelled"?"🚫":"🔄",F=[...new Set(k.map(m=>m.from).concat(k.map(m=>m.to)).filter(m=>m&&m!=="皇上"))],_=[],R=[],C=[],z=[],d=[];for(const m of k)m.from==="皇上"?_.push(m):m.to==="中书省"||m.from==="中书省"?R.push(m):m.to==="门下省"||m.from==="门下省"?C.push(m):m.remark&&(m.remark.includes("完成")||m.remark.includes("回奏"))?d.push(m):z.push(m);const w=(m,T,g)=>g.length?l.jsxs("div",{style:{marginBottom:18},children:[l.jsxs("div",{style:{fontSize:13,fontWeight:700,marginBottom:10},children:[T," ",m]}),l.jsx("div",{className:"md-timeline",children:g.map((M,P)=>{var Z,I;const B=(Z=M.remark)!=null&&Z.includes("✅")?"green":(I=M.remark)!=null&&I.includes("驳")?"red":"";return l.jsxs("div",{className:"md-tl-item",children:[l.jsx("div",{className:`md-tl-dot ${B}`}),l.jsxs("div",{style:{display:"flex",gap:6,alignItems:"baseline"},children:[l.jsx("span",{className:"md-tl-from",children:M.from}),l.jsxs("span",{className:"md-tl-to",children:["→ ",M.to]})]}),l.jsx("div",{className:"md-tl-remark",children:M.remark}),l.jsx("div",{className:"md-tl-time",children:(M.at||"").substring(0,19).replace("T"," ")})]},P)})})]}):null;return l.jsx("div",{className:"modal-bg open",onClick:p,children:l.jsxs("div",{className:"modal",onClick:m=>m.stopPropagation(),children:[l.jsx("button",{className:"modal-close",onClick:p,children:"✕"}),l.jsxs("div",{className:"modal-body",children:[l.jsx("div",{style:{fontSize:11,color:"var(--acc)",fontWeight:700,letterSpacing:".04em",marginBottom:4},children:o.id}),l.jsxs("div",{style:{fontSize:20,fontWeight:800,marginBottom:6},children:[D," ",o.title||o.id]}),l.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:18,flexWrap:"wrap"},children:[l.jsx("span",{className:`tag st-${S}`,children:zr[S]||S}),l.jsx("span",{style:{fontSize:11,color:"var(--muted)"},children:o.org}),l.jsxs("span",{style:{fontSize:11,color:"var(--muted)"},children:["流转 ",k.length," 步"]}),F.map(m=>l.jsx("span",{className:"mem-tag",children:m},m))]}),o.now&&l.jsx("div",{style:{background:"var(--panel2)",border:"1px solid var(--line)",borderRadius:8,padding:"10px 14px",marginBottom:18,fontSize:12,color:"var(--muted)"},children:o.now}),w("圣旨原文","👑",_),w("中书规划","📋",R),w("门下审议","🔍",C),w("六部执行","⚔️",z),w("汇总回奏","📨",d),o.output&&o.output!=="-"&&l.jsxs("div",{style:{marginTop:12,paddingTop:12,borderTop:"1px solid var(--line)"},children:[l.jsx("div",{style:{fontSize:11,fontWeight:600,marginBottom:4},children:"📦 产出物"}),l.jsx("code",{style:{fontSize:11,wordBreak:"break-all"},children:o.output})]}),l.jsx("div",{style:{display:"flex",gap:8,marginTop:16,justifyContent:"flex-end"},children:l.jsx("button",{className:"btn btn-g",onClick:()=>u(o),style:{fontSize:12,padding:"6px 16px"},children:"📋 复制奏折"})})]})]})})}function op(){const o=q(g=>g.tplCatFilter),p=q(g=>g.setTplCatFilter),u=q(g=>g.toast),k=q(g=>g.loadAll),[S,D]=te.useState(null),[F,_]=te.useState({}),[R,C]=te.useState("");let z=bf;o!=="全部"&&(z=z.filter(g=>g.cat===o));const d=g=>{const M={};g.params.forEach(P=>{M[P.key]=P.default||""}),_(M),D(g),C("")},w=g=>{let M=g.command;for(const P of g.params)M=M.replace(new RegExp("\\{"+P.key+"\\}","g"),F[P.key]||P.default||"");return M},m=()=>{S&&C(w(S))},T=async g=>{if(g.preventDefault(),!S)return;const M=w(S);if(!M.trim()){u("请填写必填参数","err");return}try{const P=await fe.agentsStatus();if(P.ok&&P.gateway&&!P.gateway.alive&&(u("⚠️ Gateway 未启动,任务将无法派发!","err"),!confirm("Gateway 未启动,继续?")))return}catch{}if(confirm(`确认下旨? - -${M.substring(0,200)}${M.length>200?"…":""}`))try{const P={};for(const Z of S.params)P[Z.key]=F[Z.key]||Z.default||"";const B=await fe.createTask({title:M.substring(0,120),org:"中书省",targetDept:S.depts[0]||"",priority:"normal",templateId:S.id,params:P});B.ok?(u(`📜 ${B.taskId} 旨意已下达`,"ok"),D(null),k()):u(B.error||"下旨失败","err")}catch{u("⚠️ 服务器连接失败","err")}};return l.jsxs("div",{children:[l.jsx("div",{style:{display:"flex",gap:6,marginBottom:16,flexWrap:"wrap"},children:$f.map(g=>l.jsxs("span",{className:`tpl-cat${o===g.name?" active":""}`,onClick:()=>p(g.name),children:[g.icon," ",g.name]},g.name))}),l.jsx("div",{className:"tpl-grid",children:z.map(g=>l.jsxs("div",{className:"tpl-card",children:[l.jsxs("div",{className:"tpl-top",children:[l.jsx("span",{className:"tpl-icon",children:g.icon}),l.jsx("span",{className:"tpl-name",children:g.name})]}),l.jsx("div",{className:"tpl-desc",children:g.desc}),l.jsxs("div",{className:"tpl-footer",children:[g.depts.map(M=>l.jsx("span",{className:"tpl-dept",children:M},M)),l.jsxs("span",{className:"tpl-est",children:[g.est," · ",g.cost]}),l.jsx("button",{className:"tpl-go",onClick:()=>d(g),children:"下旨"})]})]},g.id))}),S&&l.jsx("div",{className:"modal-bg open",onClick:()=>D(null),children:l.jsxs("div",{className:"modal",onClick:g=>g.stopPropagation(),children:[l.jsx("button",{className:"modal-close",onClick:()=>D(null),children:"✕"}),l.jsxs("div",{className:"modal-body",children:[l.jsx("div",{style:{fontSize:11,color:"var(--acc)",fontWeight:700,letterSpacing:".04em",marginBottom:4},children:"圣旨模板"}),l.jsxs("div",{style:{fontSize:20,fontWeight:800,marginBottom:6},children:[S.icon," ",S.name]}),l.jsx("div",{style:{fontSize:12,color:"var(--muted)",marginBottom:18},children:S.desc}),l.jsxs("div",{style:{display:"flex",gap:6,marginBottom:18,flexWrap:"wrap"},children:[S.depts.map(g=>l.jsx("span",{className:"tpl-dept",children:g},g)),l.jsxs("span",{style:{fontSize:11,color:"var(--muted)",marginLeft:"auto"},children:[S.est," · ",S.cost]})]}),l.jsxs("form",{className:"tpl-form",onSubmit:T,children:[S.params.map(g=>l.jsxs("div",{className:"tpl-field",children:[l.jsxs("label",{className:"tpl-label",children:[g.label,g.required&&l.jsx("span",{style:{color:"#ff5270"},children:" *"})]}),g.type==="textarea"?l.jsx("textarea",{className:"tpl-input",style:{minHeight:80,resize:"vertical"},required:g.required,value:F[g.key]||"",onChange:M=>_(P=>({...P,[g.key]:M.target.value}))}):g.type==="select"?l.jsx("select",{className:"tpl-input",value:F[g.key]||g.default||"",onChange:M=>_(P=>({...P,[g.key]:M.target.value})),children:(g.options||[]).map(M=>l.jsx("option",{children:M},M))}):l.jsx("input",{className:"tpl-input",type:"text",required:g.required,value:F[g.key]||"",onChange:M=>_(P=>({...P,[g.key]:M.target.value}))})]},g.key)),R&&l.jsxs("div",{style:{background:"var(--panel2)",border:"1px solid var(--line)",borderRadius:8,padding:12,marginBottom:14,fontSize:12,color:"var(--muted)"},children:[l.jsx("div",{style:{fontSize:11,fontWeight:600,color:"var(--text)",marginBottom:6},children:"📜 将发送给中书省的旨意:"}),l.jsx("div",{style:{whiteSpace:"pre-wrap",lineHeight:1.6},children:R})]}),l.jsxs("div",{style:{display:"flex",gap:10,justifyContent:"flex-end"},children:[l.jsx("button",{type:"button",className:"btn btn-g",onClick:m,style:{padding:"8px 16px",fontSize:12},children:"👁 预览旨意"}),l.jsx("button",{type:"submit",className:"tpl-go",style:{padding:"8px 20px",fontSize:13},children:"📜 下旨"})]})]})]})]})})]})}const fc={政治:{icon:"🏛️",color:"#6a9eff",desc:"全球政治动态"},军事:{icon:"⚔️",color:"#ff5270",desc:"军事与冲突"},经济:{icon:"💹",color:"#2ecc8a",desc:"经济与市场"},AI大模型:{icon:"🤖",color:"#a07aff",desc:"AI与大模型进展"}},Hi=["政治","军事","经济","AI大模型"];function ap(){const o=q(X=>X.morningBrief),p=q(X=>X.subConfig),u=q(X=>X.loadMorning),k=q(X=>X.loadSubConfig),S=q(X=>X.toast),[D,F]=te.useState(!1),[_,R]=te.useState(null),[C,z]=te.useState(!1),[d,w]=te.useState("⟳ 立即采集"),m=te.useRef(null);te.useEffect(()=>{u()},[u]),te.useEffect(()=>{p&&R(JSON.parse(JSON.stringify(p)))},[p]),te.useEffect(()=>()=>{m.current&&clearInterval(m.current)},[]);const T=async()=>{z(!0),w("⟳ 采集中…");let X=null;try{X=(o==null?void 0:o.generated_at)||null}catch{}try{await fe.refreshMorning(),S("采集已触发,自动检测更新中…","ok");let le=0;m.current&&clearInterval(m.current),m.current=setInterval(async()=>{if(le++,le>24){clearInterval(m.current),m.current=null,z(!1),w("⟳ 立即采集"),S("采集超时,请重试","err");return}try{const ke=await fe.morningBrief();ke.generated_at&&ke.generated_at!==X?(clearInterval(m.current),m.current=null,z(!1),w("⟳ 立即采集"),u(),S("✅ 天下要闻已更新","ok")):w(`⟳ 采集中… (${le*5}s)`)}catch{}},5e3)}catch{S("触发失败","err"),z(!1),w("⟳ 立即采集")}},g=X=>{if(!_)return;const le=[..._.categories||[]],ke=le.find(se=>se.name===X);ke?ke.enabled=!ke.enabled:le.push({name:X,enabled:!0}),R({..._,categories:le})},M=X=>{if(!_||!X)return;const le=[..._.keywords||[]];le.includes(X)||le.push(X),R({..._,keywords:le})},P=X=>{if(!_)return;const le=[..._.keywords||[]];le.splice(X,1),R({..._,keywords:le})},B=(X,le,ke)=>{if(!_||!X||!le){S("请填写源名称和URL","err");return}const se=[..._.custom_feeds||[]];se.push({name:X,url:le,category:ke}),R({..._,custom_feeds:se})},Z=X=>{if(!_)return;const le=[..._.custom_feeds||[]];le.splice(X,1),R({..._,custom_feeds:le})},I=async()=>{if(_)try{const X=await fe.saveMorningConfig(_);X.ok?(S("订阅配置已保存","ok"),k()):S(X.error||"保存失败","err")}catch{S("服务器连接失败","err")}},oe=_?new Set((_.categories||[]).filter(X=>X.enabled).map(X=>X.name)):new Set(Hi),ue=((_==null?void 0:_.keywords)||[]).map(X=>X.toLowerCase()),pe=(o==null?void 0:o.categories)||{},me=o!=null&&o.date?o.date.replace(/(\d{4})(\d{2})(\d{2})/,"$1年$2月$3日"):"",be=Object.values(pe).flat().length;return l.jsxs("div",{children:[l.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:16},children:[l.jsxs("div",{children:[l.jsx("div",{style:{fontSize:20,fontWeight:800,marginBottom:4},children:"🌅 天下要闻"}),l.jsxs("div",{style:{fontSize:12,color:"var(--muted)"},children:[me&&`${me} | `,(o==null?void 0:o.generated_at)&&`采集于 ${o.generated_at} | `,"共 ",be," 条要闻"]})]}),l.jsxs("div",{style:{display:"flex",gap:8},children:[l.jsx("button",{className:"btn btn-g",onClick:()=>F(!D),style:{fontSize:12,padding:"6px 14px"},children:"⚙ 订阅配置"}),l.jsx("button",{className:"tpl-go",disabled:C,onClick:T,style:{fontSize:12,padding:"6px 14px"},children:d})]})]}),D&&_&&l.jsx(up,{config:_,enabledSet:oe,onToggleCat:g,onAddKeyword:M,onRemoveKeyword:P,onAddFeed:B,onRemoveFeed:Z,onSave:I,onSetWebhook:X=>R({..._,feishu_webhook:X})}),Object.keys(pe).length?l.jsx("div",{className:"mb-cats",children:Object.entries(pe).map(([X,le])=>{if(!oe.has(X))return null;const ke=fc[X]||{icon:"📰",color:"var(--acc)"},se=le.map(J=>{const Ne=((J.title||"")+(J.summary||"")).toLowerCase(),_e=ue.filter(xe=>Ne.includes(xe)).length;return{...J,_kwHits:_e}}).sort((J,Ne)=>Ne._kwHits-J._kwHits);return l.jsxs("div",{className:"mb-cat",children:[l.jsxs("div",{className:"mb-cat-hdr",children:[l.jsx("span",{className:"mb-cat-icon",children:ke.icon}),l.jsx("span",{className:"mb-cat-name",style:{color:ke.color},children:X}),l.jsxs("span",{className:"mb-cat-cnt",children:[se.length," 条"]})]}),l.jsx("div",{className:"mb-news-list",children:se.length?se.map((J,Ne)=>{const _e=!!(J.image&&J.image.startsWith("http"));return l.jsxs("div",{className:"mb-card",onClick:()=>window.open(J.link,"_blank"),children:[l.jsx("div",{className:"mb-img",children:_e?l.jsx("img",{src:J.image,onError:xe=>{xe.target.style.display="none"},loading:"lazy",alt:""}):l.jsx("span",{children:ke.icon})}),l.jsxs("div",{className:"mb-info",children:[l.jsxs("div",{className:"mb-headline",children:[J.title,J._kwHits>0&&l.jsx("span",{style:{fontSize:9,padding:"1px 5px",borderRadius:999,background:"#a07aff22",color:"#a07aff",border:"1px solid #a07aff44",marginLeft:4},children:"⭐ 关注"})]}),l.jsx("div",{className:"mb-summary",children:J.summary||J.desc||""}),l.jsxs("div",{className:"mb-meta",children:[l.jsxs("span",{className:"mb-source",children:["📡 ",J.source||""]}),J.pub_date&&l.jsx("span",{className:"mb-time",children:J.pub_date.substring(0,16)})]})]})]},Ne)}):l.jsx("div",{className:"mb-empty",style:{padding:16},children:"暂无新闻"})})]},X)})}):l.jsx("div",{className:"mb-empty",children:"暂无数据,点击右上角「立即采集」获取今日简报"})]})}function up({config:o,enabledSet:p,onToggleCat:u,onAddKeyword:k,onRemoveKeyword:S,onAddFeed:D,onRemoveFeed:F,onSave:_,onSetWebhook:R}){const[C,z]=te.useState(""),[d,w]=te.useState(""),[m,T]=te.useState(""),[g,M]=te.useState(Hi[0]),P=[...Hi];return(o.categories||[]).forEach(B=>{P.includes(B.name)||P.push(B.name)}),l.jsxs("div",{className:"sub-config",style:{marginBottom:20,padding:16,background:"var(--panel2)",borderRadius:12,border:"1px solid var(--line)"},children:[l.jsx("div",{style:{fontSize:14,fontWeight:700,marginBottom:12},children:"⚙ 订阅配置"}),l.jsxs("div",{style:{marginBottom:14},children:[l.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:8},children:"订阅分类"}),l.jsx("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:P.map(B=>{const Z=fc[B]||{icon:"📰"},I=p.has(B);return l.jsxs("div",{className:`sub-cat ${I?"active":""}`,onClick:()=>u(B),style:{cursor:"pointer",padding:"6px 12px",borderRadius:8,border:`1px solid ${I?"var(--acc)":"var(--line)"}`,display:"flex",alignItems:"center",gap:6},children:[l.jsx("span",{children:Z.icon}),l.jsx("span",{style:{fontSize:12},children:B}),I&&l.jsx("span",{style:{fontSize:10,color:"var(--ok)"},children:"✓"})]},B)})})]}),l.jsxs("div",{style:{marginBottom:14},children:[l.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:8},children:"关注关键词"}),l.jsx("div",{style:{display:"flex",gap:6,flexWrap:"wrap",marginBottom:6},children:(o.keywords||[]).map((B,Z)=>l.jsxs("span",{className:"sub-kw",style:{fontSize:11,padding:"2px 8px",borderRadius:4,background:"var(--bg)",border:"1px solid var(--line)"},children:[B,l.jsx("span",{style:{cursor:"pointer",marginLeft:4,color:"var(--danger)"},onClick:()=>S(Z),children:"✕"})]},Z))}),l.jsxs("div",{style:{display:"flex",gap:6},children:[l.jsx("input",{type:"text",value:C,onChange:B=>z(B.target.value),placeholder:"输入关键词",onKeyDown:B=>{B.key==="Enter"&&(k(C.trim()),z(""))},style:{flex:1,padding:"6px 10px",background:"var(--bg)",border:"1px solid var(--line)",borderRadius:6,color:"var(--text)",fontSize:12,outline:"none"}}),l.jsx("button",{className:"btn btn-g",onClick:()=>{k(C.trim()),z("")},style:{fontSize:11,padding:"4px 12px"},children:"添加"})]})]}),l.jsxs("div",{style:{marginBottom:14},children:[l.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:8},children:"自定义信息源"}),(o.custom_feeds||[]).map((B,Z)=>l.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center",marginBottom:4,fontSize:11},children:[l.jsx("span",{style:{fontWeight:600},children:B.name}),l.jsx("span",{style:{color:"var(--muted)",flex:1,overflow:"hidden",textOverflow:"ellipsis"},children:B.url}),l.jsx("span",{style:{color:"var(--acc)"},children:B.category}),l.jsx("span",{style:{cursor:"pointer",color:"var(--danger)"},onClick:()=>F(Z),children:"✕"})]},Z)),l.jsxs("div",{style:{display:"flex",gap:6,marginTop:6},children:[l.jsx("input",{placeholder:"源名称",value:d,onChange:B=>w(B.target.value),style:{width:100,padding:"6px 8px",background:"var(--bg)",border:"1px solid var(--line)",borderRadius:6,color:"var(--text)",fontSize:11,outline:"none"}}),l.jsx("input",{placeholder:"RSS / URL",value:m,onChange:B=>T(B.target.value),style:{flex:1,padding:"6px 8px",background:"var(--bg)",border:"1px solid var(--line)",borderRadius:6,color:"var(--text)",fontSize:11,outline:"none"}}),l.jsx("select",{value:g,onChange:B=>M(B.target.value),style:{padding:"6px 8px",background:"var(--bg)",border:"1px solid var(--line)",borderRadius:6,color:"var(--text)",fontSize:11,outline:"none"},children:P.map(B=>l.jsx("option",{value:B,children:B},B))}),l.jsx("button",{className:"btn btn-g",onClick:()=>{D(d,m,g),w(""),T("")},style:{fontSize:11,padding:"4px 12px"},children:"添加"})]})]}),l.jsxs("div",{style:{marginBottom:14},children:[l.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:6},children:"飞书 Webhook"}),l.jsx("input",{type:"text",value:o.feishu_webhook||"",onChange:B=>R(B.target.value),placeholder:"https://open.feishu.cn/open-apis/bot/v2/hook/...",style:{width:"100%",padding:"8px 10px",background:"var(--bg)",border:"1px solid var(--line)",borderRadius:6,color:"var(--text)",fontSize:12,outline:"none"}})]}),l.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:l.jsx("button",{className:"tpl-go",onClick:_,style:{fontSize:12,padding:"6px 16px"},children:"💾 保存配置"})})]})}const pc={main:"太子",zhongshu:"中书省",menxia:"门下省",shangshu:"尚书省",libu:"礼部",hubu:"户部",bingbu:"兵部",xingbu:"刑部",gongbu:"工部",libu_hr:"吏部",zaochao:"钦天监"},cp={Taizi:"中书省起草",Zhongshu:"门下省审议",Menxia:"尚书省派发",Assigned:"开始执行",Doing:"进入审查",Review:"完成"};function dp(o){const p=Math.max(0,o);if(p<60)return`${p}秒`;if(p<3600)return`${Math.floor(p/60)}分${p%60}秒`;const u=Math.floor(p/3600),k=Math.floor(p%3600/60);return`${u}小时${k}分`}function Vi(o){if(!o)return"";if(typeof o=="number"){const p=new Date(o);return`${String(p.getHours()).padStart(2,"0")}:${String(p.getMinutes()).padStart(2,"0")}:${String(p.getSeconds()).padStart(2,"0")}`}return typeof o=="string"&&o.length>=19?o.substring(11,19):String(o).substring(0,8)}function fp(){var _e,xe;const o=q(E=>E.modalTaskId),p=q(E=>E.setModalTaskId),u=q(E=>E.liveStatus),k=q(E=>E.loadAll),S=q(E=>E.toast),[D,F]=te.useState(null),[_,R]=te.useState(null),C=te.useRef(null),z=te.useRef(null),d=((_e=u==null?void 0:u.tasks)==null?void 0:_e.find(E=>E.id===o))||null,w=te.useCallback(async()=>{if(o)try{const E=await fe.taskActivity(o);F(E)}catch{F(null)}},[o]),m=te.useCallback(async()=>{if(o)try{const E=await fe.schedulerState(o);R(E)}catch{R(null)}},[o]);if(te.useEffect(()=>!o||!d?void 0:(w(),m(),["Done","Cancelled"].includes(d.state)||(C.current=setInterval(()=>{w(),m()},4e3)),()=>{C.current&&(clearInterval(C.current),C.current=null)}),[o,d==null?void 0:d.state,w,m]),te.useEffect(()=>{z.current&&(z.current.scrollTop=z.current.scrollHeight)},[(xe=D==null?void 0:D.activity)==null?void 0:xe.length]),!o||!d)return null;const T=()=>p(null),g=Gi(d),M=g.find(E=>E.status==="active"),P=d.heartbeat||{status:"unknown",label:"⚪ 无数据"},B=d.flow_log||[],Z=d.todos||[],I=Z.filter(E=>E.status==="completed").length,oe=Z.length,ue=!["Done","Blocked","Cancelled"].includes(d.state),pe=["Blocked","Cancelled"].includes(d.state),me=async(E,Q)=>{try{const W=await fe.taskAction(d.id,E,Q);W.ok?(S(W.message||"操作成功","ok"),k(),T()):S(W.error||"操作失败","err")}catch{S("服务器连接失败","err")}},be=async E=>{const Q={approve:"准奏",reject:"封驳"},W=prompt(`${Q[E]} ${d.id} - -请输入批注(可留空):`);if(W!==null)try{const v=await fe.reviewAction(d.id,E,W||"");v.ok?(S(`✅ ${d.id} 已${Q[E]}`,"ok"),k(),T()):S(v.error||"操作失败","err")}catch{S("服务器连接失败","err")}},X=async()=>{const E=cp[d.state]||"下一步",Q=prompt(`⏩ 手动推进 ${d.id} -当前: ${d.state} → 下一步: ${E} - -请输入说明(可留空):`);if(Q!==null)try{const W=await fe.advanceState(d.id,Q||"");W.ok?(S(`⏩ ${W.message}`,"ok"),k(),T()):S(W.error||"推进失败","err")}catch{S("服务器连接失败","err")}},le=async E=>{if(E==="scan"){try{const L=await fe.schedulerScan(180);L.ok?S(`🔍 扫描完成:${L.count||0} 个动作`,"ok"):S(L.error||"扫描失败","err"),m()}catch{S("服务器连接失败","err")}return}const W=prompt(`请输入${{retry:"重试",escalate:"升级",rollback:"回滚"}[E]}原因(可留空):`);if(W===null)return;const v={retry:fe.schedulerRetry,escalate:fe.schedulerEscalate,rollback:fe.schedulerRollback};try{const L=await v[E](d.id,W);L.ok?S(L.message||"操作成功","ok"):S(L.error||"操作失败","err"),m(),k()}catch{S("服务器连接失败","err")}},ke=()=>{const E=prompt("请输入叫停原因(可留空):");E!==null&&me("stop",E)},se=()=>{if(!confirm(`确定要取消 ${d.id} 吗?`))return;const E=prompt("请输入取消原因(可留空):");E!==null&&me("cancel",E)},J=_==null?void 0:_.scheduler,Ne=(_==null?void 0:_.stalledSec)||0;return l.jsx("div",{className:"modal-bg open",onClick:T,children:l.jsxs("div",{className:"modal",onClick:E=>E.stopPropagation(),children:[l.jsx("button",{className:"modal-close",onClick:T,children:"✕"}),l.jsxs("div",{className:"modal-body",children:[l.jsx("div",{className:"modal-id",children:d.id}),l.jsx("div",{className:"modal-title",children:d.title||"(无标题)"}),M&&l.jsxs("div",{className:"cur-stage",children:[l.jsx("div",{className:"cs-icon",children:M.icon}),l.jsxs("div",{className:"cs-info",children:[l.jsx("div",{className:"cs-dept",style:{color:$l(M.dept)},children:M.dept}),l.jsxs("div",{className:"cs-action",children:["当前阶段:",M.action]})]}),l.jsx("span",{className:`hb ${P.status} cs-hb`,children:P.label})]}),l.jsx("div",{className:"m-pipe",children:g.map((E,Q)=>l.jsxs("div",{className:"mp-stage",children:[l.jsxs("div",{className:`mp-node ${E.status}`,children:[E.status==="done"&&l.jsx("div",{className:"mp-done-tick",children:"✓"}),l.jsx("div",{className:"mp-icon",children:E.icon}),l.jsx("div",{className:"mp-dept",style:E.status==="active"?{color:"var(--acc)"}:E.status==="done"?{color:"var(--ok)"}:{},children:E.dept}),l.jsx("div",{className:"mp-action",children:E.action})]}),Qme("resume","恢复执行"),children:"▶️ 恢复执行"}),["Review","Menxia"].includes(d.state)&&l.jsxs(l.Fragment,{children:[l.jsx("button",{className:"btn-action",style:{background:"#2ecc8a22",color:"#2ecc8a",border:"1px solid #2ecc8a44"},onClick:()=>be("approve"),children:"✅ 准奏"}),l.jsx("button",{className:"btn-action",style:{background:"#ff527022",color:"#ff5270",border:"1px solid #ff527044"},onClick:()=>be("reject"),children:"🚫 封驳"})]}),["Pending","Taizi","Zhongshu","Menxia","Assigned","Doing","Review","Next"].includes(d.state)&&l.jsx("button",{className:"btn-action",style:{background:"#7c5cfc18",color:"#7c5cfc",border:"1px solid #7c5cfc44"},onClick:X,children:"⏩ 推进到下一步"})]}),l.jsxs("div",{className:"sched-section",children:[l.jsxs("div",{className:"sched-head",children:[l.jsx("span",{className:"sched-title",children:"🧭 太子调度"}),l.jsx("span",{className:"sched-status",children:J?`${J.enabled===!1?"已禁用":"运行中"} · 阈值 ${J.stallThresholdSec||180}s`:"加载中..."})]}),l.jsxs("div",{className:"sched-grid",children:[l.jsxs("div",{className:"sched-kpi",children:[l.jsx("div",{className:"k",children:"停滞时长"}),l.jsx("div",{className:"v",children:dp(Ne)})]}),l.jsxs("div",{className:"sched-kpi",children:[l.jsx("div",{className:"k",children:"重试次数"}),l.jsx("div",{className:"v",children:(J==null?void 0:J.retryCount)||0})]}),l.jsxs("div",{className:"sched-kpi",children:[l.jsx("div",{className:"k",children:"升级级别"}),l.jsx("div",{className:"v",children:J!=null&&J.escalationLevel?J.escalationLevel===1?"门下省":"尚书省":"无"})]}),l.jsxs("div",{className:"sched-kpi",children:[l.jsx("div",{className:"k",children:"派发状态"}),l.jsx("div",{className:"v",children:(J==null?void 0:J.lastDispatchStatus)||"idle"})]})]}),J&&l.jsxs("div",{className:"sched-line",children:[J.lastProgressAt&&l.jsxs("span",{children:["最近进展 ",(J.lastProgressAt||"").replace("T"," ").substring(0,19)]}),J.lastDispatchAt&&l.jsxs("span",{children:["最近派发 ",(J.lastDispatchAt||"").replace("T"," ").substring(0,19)]}),l.jsxs("span",{children:["自动回滚 ",J.autoRollback===!1?"关闭":"开启"]}),J.lastDispatchAgent&&l.jsxs("span",{children:["目标 ",J.lastDispatchAgent]})]}),l.jsxs("div",{className:"sched-actions",children:[l.jsx("button",{className:"sched-btn",onClick:()=>le("retry"),children:"🔁 重试派发"}),l.jsx("button",{className:"sched-btn warn",onClick:()=>le("escalate"),children:"📣 升级协调"}),l.jsx("button",{className:"sched-btn danger",onClick:()=>le("rollback"),children:"↩️ 回滚稳定点"}),l.jsx("button",{className:"sched-btn",onClick:()=>le("scan"),children:"🔍 立即扫描"})]})]}),oe>0&&l.jsx(pp,{todos:Z,todoDone:I,todoTotal:oe}),l.jsx("div",{className:"m-section",children:l.jsxs("div",{className:"m-rows",children:[l.jsxs("div",{className:"m-row",children:[l.jsx("div",{className:"mr-label",children:"状态"}),l.jsxs("div",{className:"mr-val",children:[l.jsx("span",{className:`tag st-${d.state}`,children:Ki(d)}),(d.review_round||0)>0&&l.jsxs("span",{style:{fontSize:11,color:"var(--muted)",marginLeft:8},children:["共磋商 ",d.review_round," 轮"]})]})]}),l.jsxs("div",{className:"m-row",children:[l.jsx("div",{className:"mr-label",children:"执行部门"}),l.jsx("div",{className:"mr-val",children:l.jsx("span",{className:`tag dt-${(d.org||"").replace(/\s/g,"")}`,children:d.org||"—"})})]}),d.eta&&d.eta!=="-"&&l.jsxs("div",{className:"m-row",children:[l.jsx("div",{className:"mr-label",children:"预计完成"}),l.jsx("div",{className:"mr-val",children:d.eta})]}),d.block&&d.block!=="无"&&d.block!=="-"&&l.jsxs("div",{className:"m-row",children:[l.jsx("div",{className:"mr-label",style:{color:"var(--danger)"},children:"阻塞项"}),l.jsx("div",{className:"mr-val",style:{color:"var(--danger)"},children:d.block})]}),d.now&&d.now!=="-"&&l.jsxs("div",{className:"m-row",style:{gridColumn:"1/-1"},children:[l.jsx("div",{className:"mr-label",children:"当前进展"}),l.jsx("div",{className:"mr-val",style:{fontWeight:400,fontSize:12},children:d.now})]}),d.ac&&l.jsxs("div",{className:"m-row",style:{gridColumn:"1/-1"},children:[l.jsx("div",{className:"mr-label",children:"验收标准"}),l.jsx("div",{className:"mr-val",style:{fontWeight:400,fontSize:12},children:d.ac})]})]})}),B.length>0&&l.jsxs("div",{className:"m-section",children:[l.jsxs("div",{className:"m-sec-label",children:["流转日志(",B.length," 条)"]}),l.jsx("div",{className:"fl-timeline",children:B.map((E,Q)=>{const W=$l(E.from||"");return l.jsxs("div",{className:"fl-item",children:[l.jsx("div",{className:"fl-time",children:E.at?E.at.substring(11,16):""}),l.jsx("div",{className:"fl-dot",style:{background:W}}),l.jsxs("div",{className:"fl-content",children:[l.jsxs("div",{className:"fl-who",children:[l.jsx("span",{className:"from",style:{color:W},children:E.from}),l.jsx("span",{style:{color:"var(--muted)"},children:" → "}),l.jsx("span",{className:"to",style:{color:$l(E.to||"")},children:E.to})]}),l.jsx("div",{className:"fl-rem",children:E.remark})]})]},Q)})})]}),d.output&&d.output!=="-"&&d.output!==""&&l.jsxs("div",{className:"m-section",children:[l.jsx("div",{className:"m-sec-label",children:"产出物"}),l.jsx("code",{children:d.output})]}),l.jsx(mp,{data:D,isDone:["Done","Cancelled"].includes(d.state),logRef:z})]})]})})}function pp({todos:o,todoDone:p,todoTotal:u}){return l.jsxs("div",{className:"todo-section",children:[l.jsxs("div",{className:"todo-header",children:[l.jsxs("div",{className:"m-sec-label",style:{marginBottom:0,border:"none",padding:0},children:["子任务清单(",p,"/",u,")"]}),l.jsxs("div",{className:"todo-progress",children:[l.jsx("div",{className:"todo-bar",children:l.jsx("div",{className:"todo-bar-fill",style:{width:`${Math.round(p/u*100)}%`}})}),l.jsxs("span",{children:[Math.round(p/u*100),"%"]})]})]}),l.jsx("div",{className:"todo-list",children:o.map(k=>{const S=k.status==="completed"?"✅":k.status==="in-progress"?"🔄":"⬜",D=k.status==="completed"?"已完成":k.status==="in-progress"?"进行中":"待开始",F=k.status==="completed"?"s-done":k.status==="in-progress"?"s-progress":"s-notstarted",_=k.status==="completed"?"done":"";return l.jsxs("div",{className:`todo-item ${_}`,children:[l.jsxs("div",{className:"t-row",children:[l.jsx("span",{className:"t-icon",children:S}),l.jsxs("span",{className:"t-id",children:["#",k.id]}),l.jsx("span",{className:"t-title",children:k.title}),l.jsx("span",{className:`t-status ${F}`,children:D})]}),k.detail&&l.jsx("div",{className:"todo-detail",children:k.detail})]},k.id)})})]})}function mp({data:o,isDone:p,logRef:u}){if(!o)return null;const k=o.activity||[],S=(()=>{if(!k.length)return!1;const T=k[k.length-1];if(!T.at)return!1;const g=typeof T.at=="number"?T.at:new Date(T.at).getTime();return Date.now()-g<3e5})(),D=[];o.agentLabel&&D.push(o.agentLabel),o.relatedAgents&&o.relatedAgents.length>1&&D.push(`${o.relatedAgents.length}个 Agent`),o.lastActive&&D.push(`最后活跃: ${o.lastActive}`);const F=o.phaseDurations||[],_=Math.max(...F.map(T=>T.durationSec||1),1),R={皇上:"#eab308",太子:"#f97316",中书省:"#3b82f6",门下省:"#8b5cf6",尚书省:"#10b981",六部:"#06b6d4",礼部:"#ec4899",户部:"#f59e0b",兵部:"#ef4444",刑部:"#6366f1",工部:"#14b8a6",吏部:"#d946ef"},C=o.todosSummary,z=o.resourceSummary,d=k.filter(T=>T.kind==="flow"),w=k.filter(T=>T.kind!=="flow"),m=new Map;return w.forEach(T=>{const g=T.agent||"unknown";m.has(g)||m.set(g,[]),m.get(g).push(T)}),l.jsxs("div",{className:"la-section",children:[l.jsxs("div",{className:"la-header",children:[l.jsxs("span",{className:"la-title",children:[l.jsx("span",{className:`la-dot${S?"":" idle"}`}),p?"执行回顾":"实时动态"]}),l.jsx("span",{className:"la-agent",children:D.join(" · ")||"加载中..."})]}),F.length>0&&l.jsxs("div",{style:{padding:"4px 0 8px",borderBottom:"1px solid var(--line)"},children:[l.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:6},children:[l.jsx("span",{style:{fontSize:11,fontWeight:600},children:"⏱ 阶段耗时"}),o.totalDuration&&l.jsxs("span",{style:{marginLeft:"auto",fontSize:10,color:"var(--muted)"},children:["总耗时 ",o.totalDuration]})]}),F.map((T,g)=>{const M=Math.max(5,Math.round((T.durationSec||1)/_*100)),P=R[T.phase]||"#6b7280";return l.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,margin:"2px 0",fontSize:11},children:[l.jsx("span",{style:{minWidth:48,color:"var(--muted)",textAlign:"right"},children:T.phase}),l.jsx("div",{style:{flex:1,height:14,background:"var(--panel)",borderRadius:3,overflow:"hidden"},children:l.jsx("div",{style:{width:`${M}%`,height:"100%",background:P,borderRadius:3,opacity:T.ongoing?.6:.85}})}),l.jsxs("span",{style:{minWidth:60,fontSize:10,color:"var(--muted)"},children:[T.durationText,T.ongoing&&l.jsx("span",{style:{fontSize:9,color:"#60a5fa"},children:" ●进行中"})]})]},g)})]}),C&&l.jsxs("div",{style:{padding:"4px 0 8px",borderBottom:"1px solid var(--line)"},children:[l.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:4},children:[l.jsx("span",{style:{fontSize:11,fontWeight:600},children:"📊 执行进度"}),l.jsxs("span",{style:{fontSize:20,fontWeight:700,color:C.percent>=100?"#22c55e":C.percent>=50?"#60a5fa":"var(--text)"},children:[C.percent,"%"]}),l.jsxs("span",{style:{fontSize:10,color:"var(--muted)"},children:["✅",C.completed," 🔄",C.inProgress," ⬜",C.notStarted," / 共",C.total,"项"]})]}),l.jsxs("div",{style:{height:8,background:"var(--panel)",borderRadius:4,overflow:"hidden",display:"flex"},children:[l.jsx("div",{style:{width:`${C.total?C.completed/C.total*100:0}%`,background:"#22c55e",transition:"width .3s"}}),l.jsx("div",{style:{width:`${C.total?C.inProgress/C.total*100:0}%`,background:"#3b82f6",transition:"width .3s"}})]})]}),z&&(z.totalTokens||z.totalCost)&&l.jsxs("div",{style:{padding:"4px 0 8px",borderBottom:"1px solid var(--line)",display:"flex",gap:12,alignItems:"center"},children:[l.jsx("span",{style:{fontSize:11,fontWeight:600},children:"📈 资源消耗"}),z.totalTokens!=null&&l.jsxs("span",{style:{fontSize:11,color:"var(--muted)"},children:["🔢 ",z.totalTokens.toLocaleString()," tokens"]}),z.totalCost!=null&&l.jsxs("span",{style:{fontSize:11,color:"var(--muted)"},children:["💰 $",z.totalCost.toFixed(4)]}),z.totalElapsedSec!=null&&l.jsxs("span",{style:{fontSize:11,color:"var(--muted)"},children:["⏳ ",z.totalElapsedSec>=60?`${Math.floor(z.totalElapsedSec/60)}分`:"",z.totalElapsedSec%60,"秒"]})]}),l.jsxs("div",{className:"la-log",ref:u,children:[d.length>0&&l.jsx("div",{className:"la-flow-wrap",children:d.map((T,g)=>l.jsxs("div",{className:"la-entry la-tool",children:[l.jsx("span",{className:"la-icon",children:"📋"}),l.jsxs("span",{className:"la-body",children:[l.jsx("b",{children:T.from})," → ",l.jsx("b",{children:T.to})," ",T.remark||""]}),l.jsx("span",{className:"la-time",children:Vi(T.at)})]},`flow-${g}`))}),m.size>0?l.jsx("div",{className:"la-groups",children:Array.from(m.entries()).map(([T,g])=>{const M=pc[T]||T||"未标识",P=g[g.length-1],B=P!=null&&P.at?Vi(P.at):"--:--:--";return l.jsxs("div",{className:"la-group",children:[l.jsxs("div",{className:"la-group-hd",children:[l.jsx("span",{className:"name",children:M}),l.jsxs("span",{children:["最近更新 ",B]})]}),l.jsx("div",{className:"la-group-bd",children:g.map((Z,I)=>l.jsx(hp,{entry:Z},I))})]},T)})}):!d.length&&l.jsx("div",{className:"la-empty",children:o.message||o.error||"Agent 尚未上报进展(等待 Agent 调用 progress 命令)"})]})]})}function hp({entry:o}){var k,S,D;const p=Vi(o.at),u=o.agent?l.jsx("span",{style:{fontSize:9,color:"var(--muted)",background:"var(--panel)",padding:"1px 4px",borderRadius:3,marginRight:4},children:pc[o.agent]||o.agent}):null;if(o.kind==="progress")return l.jsxs("div",{className:"la-entry la-assistant",children:[l.jsx("span",{className:"la-icon",children:"🔄"}),l.jsxs("span",{className:"la-body",children:[u,l.jsx("b",{children:"当前进展:"}),o.text]}),l.jsx("span",{className:"la-time",children:p})]});if(o.kind==="todos"){const F=o.items||[],_=new Map;return o.diff&&((o.diff.changed||[]).forEach(R=>_.set(R.id,{type:"changed",from:R.from,to:R.to})),(o.diff.added||[]).forEach(R=>_.set(R.id,{type:"added"}))),l.jsxs("div",{className:"la-entry",style:{flexDirection:"column",alignItems:"flex-start",gap:2},children:[l.jsxs("div",{style:{fontSize:11,color:"var(--muted)",marginBottom:2},children:[u,"📝 执行计划"]}),F.map(R=>{const C=R.status==="completed"?"✅":R.status==="in-progress"?"🔄":"⬜",z=_.get(String(R.id)),d=R.status==="completed"?{opacity:.5,textDecoration:"line-through"}:R.status==="in-progress"?{color:"#60a5fa",fontWeight:"bold"}:{};return l.jsxs("div",{style:d,children:[C," ",R.title,z&&z.type==="changed"&&z.to==="completed"&&l.jsx("span",{style:{color:"#22c55e",fontSize:9,marginLeft:4},children:"✨刚完成"}),z&&z.type==="changed"&&z.to!=="completed"&&l.jsxs("span",{style:{color:"#f59e0b",fontSize:9,marginLeft:4},children:["↻",z.from,"→",z.to]}),z&&z.type==="added"&&l.jsx("span",{style:{color:"#3b82f6",fontSize:9,marginLeft:4},children:"🆕新增"})]},R.id)}),(S=(k=o.diff)==null?void 0:k.removed)==null?void 0:S.map(R=>l.jsxs("div",{style:{opacity:.4,textDecoration:"line-through"},children:["🗑 ",R.title]},R.id))]})}if(o.kind==="assistant")return l.jsxs(l.Fragment,{children:[o.thinking&&l.jsxs("div",{className:"la-entry la-thinking",children:[l.jsx("span",{className:"la-icon",children:"💭"}),l.jsxs("span",{className:"la-body",children:[u,o.thinking]}),l.jsx("span",{className:"la-time",children:p})]}),(D=o.tools)==null?void 0:D.map((F,_)=>l.jsxs("div",{className:"la-entry la-tool",children:[l.jsx("span",{className:"la-icon",children:"🔧"}),l.jsxs("span",{className:"la-body",children:[u,l.jsx("span",{className:"la-tool-name",children:F.name}),l.jsx("span",{className:"la-trunc",children:F.input_preview||""})]}),l.jsx("span",{className:"la-time",children:p})]},_)),o.text&&l.jsxs("div",{className:"la-entry la-assistant",children:[l.jsx("span",{className:"la-icon",children:"🤖"}),l.jsxs("span",{className:"la-body",children:[u,o.text]}),l.jsx("span",{className:"la-time",children:p})]})]});if(o.kind==="tool_result"){const F=o.exitCode===0||o.exitCode===null||o.exitCode===void 0;return l.jsxs("div",{className:`la-entry la-tool-result ${F?"ok":"err"}`,children:[l.jsx("span",{className:"la-icon",children:F?"✅":"❌"}),l.jsxs("span",{className:"la-body",children:[u,l.jsx("span",{className:"la-tool-name",children:o.tool||""}),o.output?o.output.substring(0,150):""]}),l.jsx("span",{className:"la-time",children:p})]})}return o.kind==="user"?l.jsxs("div",{className:"la-entry la-user",children:[l.jsx("span",{className:"la-icon",children:"📥"}),l.jsxs("span",{className:"la-body",children:[u,o.text||""]}),l.jsx("span",{className:"la-time",children:p})]}):null}function vp(){const o=q(p=>p.toasts);return o.length?l.jsx("div",{className:"toaster",children:o.map(p=>l.jsx("div",{className:`toast ${p.type}`,children:p.msg},p.id))}):null}function gp(){const o=q(T=>T.liveStatus),[p,u]=te.useState(!1),[k,S]=te.useState(!1);te.useEffect(()=>{const T=localStorage.getItem("openclaw_court_date"),g=new Date().toISOString().substring(0,10);if(!JSON.parse(localStorage.getItem("openclaw_court_pref")||'{"enabled":true}').enabled||T===g)return;localStorage.setItem("openclaw_court_date",g),u(!0);const P=setTimeout(()=>D(),3500);return()=>clearTimeout(P)},[]);const D=()=>{S(!0),setTimeout(()=>u(!1),500)};if(!p)return null;const _=((o==null?void 0:o.tasks)||[]).filter(Jt),R=_.filter(T=>!["Done","Cancelled"].includes(T.state)).length,C=_.filter(T=>T.state==="Done").length,z=_.filter(T=>T.state!=="Done"&&T.state!=="Cancelled"&&T.eta&&new Date(T.eta.replace(" ","T"))0&&` · ⚠ 超期 ${z} 件`]}),l.jsx("div",{className:"crm-date in",children:m}),l.jsx("div",{className:"crm-skip",children:"点击任意处跳过"})]})}function yp(){const o=q(d=>d.activeTab),p=q(d=>d.setActiveTab),u=q(d=>d.liveStatus),k=q(d=>d.countdown),S=q(d=>d.loadAll);te.useEffect(()=>(Bf(),()=>Wf()),[]);const D=(u==null?void 0:u.tasks)||[],F=D.filter(Jt),_=F.filter(d=>!Bl(d)),R=u==null?void 0:u.syncStatus,C=R==null?void 0:R.ok,z=d=>d==="edicts"?String(_.length):d==="sessions"?String(D.filter(w=>!Jt(w)).length):d==="memorials"?String(F.filter(w=>["Done","Cancelled"].includes(w.state)).length):d==="monitor"?D.filter(m=>Jt(m)&&m.state==="Doing").length+"活跃":"";return l.jsxs("div",{className:"wrap",children:[l.jsxs("div",{className:"hdr",children:[l.jsxs("div",{children:[l.jsx("div",{className:"logo",children:"三省六部 · 总控台"}),l.jsx("div",{className:"sub-text",children:"OpenClaw Sansheng-Liubu Dashboard"})]}),l.jsxs("div",{className:"hdr-r",children:[l.jsx("span",{className:`chip ${C?"ok":C===!1?"err":""}`,children:C?"✅ 同步正常":C===!1?"❌ 服务器未启动":"⏳ 连接中…"}),l.jsxs("span",{className:"chip",children:[_.length," 道旨意"]}),l.jsx("button",{className:"btn-refresh",onClick:()=>S(),children:"⟳ 刷新"}),l.jsxs("span",{style:{fontSize:11,color:"var(--muted)"},children:["⟳ ",k,"s"]})]})]}),l.jsx("div",{className:"tabs",children:Af.map(d=>l.jsxs("div",{className:`tab ${o===d.key?"active":""}`,onClick:()=>p(d.key),children:[d.icon," ",d.label,z(d.key)&&l.jsx("span",{className:"tbadge",children:z(d.key)})]},d.key))}),o==="edicts"&&l.jsx(Qf,{}),o==="monitor"&&l.jsx(Kf,{}),o==="officials"&&l.jsx(Yf,{}),o==="models"&&l.jsx(qf,{}),o==="skills"&&l.jsx(ep,{}),o==="sessions"&&l.jsx(rp,{}),o==="memorials"&&l.jsx(sp,{}),o==="templates"&&l.jsx(op,{}),o==="morning"&&l.jsx(ap,{}),l.jsx(fp,{}),l.jsx(vp,{}),l.jsx(gp,{})]})}kf.createRoot(document.getElementById("root")).render(l.jsx(oc.StrictMode,{children:l.jsx(yp,{})})); diff --git a/dashboard/dist/assets/index-NQIHw-yB.css b/dashboard/dist/assets/index-NQIHw-yB.css new file mode 100644 index 0000000..6f7ab11 --- /dev/null +++ b/dashboard/dist/assets/index-NQIHw-yB.css @@ -0,0 +1 @@ +*,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}:before,:after{--tw-content: ""}html,:host{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji";font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}ol,ul,menu{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}button,[role=button]{cursor:pointer}:disabled{cursor:default}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]:where(:not([hidden=until-found])){display:none}.pointer-events-none{pointer-events:none}.static{position:static}.fixed{position:fixed}.absolute{position:absolute}.relative{position:relative}.-inset-2{top:-.5rem;right:-.5rem;bottom:-.5rem;left:-.5rem}.inset-0{top:0;right:0;bottom:0;left:0}.-right-1{right:-.25rem}.-top-1{top:-.25rem}.left-0{left:0}.right-0{right:0}.top-0{top:0}.z-50{z-index:50}.mb-0\.5{margin-bottom:.125rem}.mb-2{margin-bottom:.5rem}.mb-3{margin-bottom:.75rem}.ml-auto{margin-left:auto}.mt-0\.5{margin-top:.125rem}.mt-1{margin-top:.25rem}.block{display:block}.inline-block{display:inline-block}.flex{display:flex}.grid{display:grid}.contents{display:contents}.hidden{display:none}.h-10{height:2.5rem}.h-4{height:1rem}.h-7{height:1.75rem}.min-h-\[320px\]{min-height:320px}.w-10{width:2.5rem}.w-4{width:1rem}.w-7{width:1.75rem}.w-full{width:100%}.min-w-0{min-width:0px}.max-w-\[80\%\]{max-width:80%}.flex-1{flex:1 1 0%}.flex-shrink-0{flex-shrink:0}.transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.resize-none{resize:none}.resize{resize:both}.grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.items-start{align-items:flex-start}.items-center{align-items:center}.justify-end{justify-content:flex-end}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.gap-1\.5{gap:.375rem}.gap-2{gap:.5rem}.gap-3{gap:.75rem}.space-y-2>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.5rem * var(--tw-space-y-reverse))}.space-y-3>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.75rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.75rem * var(--tw-space-y-reverse))}.space-y-6>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(1.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1.5rem * var(--tw-space-y-reverse))}.overflow-hidden{overflow:hidden}.overflow-y-auto{overflow-y:auto}.whitespace-nowrap{white-space:nowrap}.break-all{word-break:break-all}.rounded-full{border-radius:9999px}.rounded-lg{border-radius:.5rem}.rounded-xl{border-radius:.75rem}.border{border-width:1px}.border-0{border-width:0px}.border-2{border-width:2px}.border-b{border-bottom-width:1px}.border-t{border-top-width:1px}.border-dashed{border-style:dashed}.border-\[var\(--acc\)\]{border-color:var(--acc)}.border-\[var\(--line\)\]{border-color:var(--line)}.border-amber-600\/30{border-color:#d977064d}.border-amber-600\/40{border-color:#d9770666}.border-amber-700\/30{border-color:#b453094d}.border-amber-800\/40{border-color:#92400e66}.border-green-600\/40{border-color:#16a34a66}.border-green-800{--tw-border-opacity: 1;border-color:rgb(22 101 52 / var(--tw-border-opacity, 1))}.border-purple-600\/40{border-color:#9333ea66}.border-purple-700\/30{border-color:#7e22ce4d}.border-red-900\/40{border-color:#7f1d1d66}.bg-\[var\(--acc\)\]{background-color:var(--acc)}.bg-\[var\(--panel\)\]{background-color:var(--panel)}.bg-\[var\(--panel2\)\]{background-color:var(--panel2)}.bg-black\/30{background-color:#0000004d}.bg-green-900\/20{background-color:#14532d33}.bg-green-900\/40{background-color:#14532d66}.bg-purple-950\/40{background-color:#3b076466}.bg-gradient-to-b{background-image:linear-gradient(to bottom,var(--tw-gradient-stops))}.bg-gradient-to-br{background-image:linear-gradient(to bottom right,var(--tw-gradient-stops))}.bg-gradient-to-r{background-image:linear-gradient(to right,var(--tw-gradient-stops))}.from-amber-400{--tw-gradient-from: #fbbf24 var(--tw-gradient-from-position);--tw-gradient-to: rgb(251 191 36 / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to)}.from-amber-600{--tw-gradient-from: #d97706 var(--tw-gradient-from-position);--tw-gradient-to: rgb(217 119 6 / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to)}.from-amber-800\/40{--tw-gradient-from: rgb(146 64 14 / .4) var(--tw-gradient-from-position);--tw-gradient-to: rgb(146 64 14 / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to)}.from-amber-900\/30{--tw-gradient-from: rgb(120 53 15 / .3) var(--tw-gradient-from-position);--tw-gradient-to: rgb(120 53 15 / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to)}.from-amber-900\/40{--tw-gradient-from: rgb(120 53 15 / .4) var(--tw-gradient-from-position);--tw-gradient-to: rgb(120 53 15 / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to)}.from-amber-950\/40{--tw-gradient-from: rgb(69 26 3 / .4) var(--tw-gradient-from-position);--tw-gradient-to: rgb(69 26 3 / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to)}.via-purple-900\/30{--tw-gradient-to: rgb(88 28 135 / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), rgb(88 28 135 / .3) var(--tw-gradient-via-position), var(--tw-gradient-to)}.to-amber-800\/20{--tw-gradient-to: rgb(146 64 14 / .2) var(--tw-gradient-to-position)}.to-amber-900\/30{--tw-gradient-to: rgb(120 53 15 / .3) var(--tw-gradient-to-position)}.to-amber-950\/40{--tw-gradient-to: rgb(69 26 3 / .4) var(--tw-gradient-to-position)}.to-purple-400{--tw-gradient-to: #c084fc var(--tw-gradient-to-position)}.to-purple-600{--tw-gradient-to: #9333ea var(--tw-gradient-to-position)}.to-purple-950\/30{--tw-gradient-to: rgb(59 7 100 / .3) var(--tw-gradient-to-position)}.bg-clip-text{-webkit-background-clip:text;background-clip:text}.p-2{padding:.5rem}.p-2\.5{padding:.625rem}.p-3{padding:.75rem}.p-4{padding:1rem}.px-2{padding-left:.5rem;padding-right:.5rem}.px-2\.5{padding-left:.625rem;padding-right:.625rem}.px-3{padding-left:.75rem;padding-right:.75rem}.px-4{padding-left:1rem;padding-right:1rem}.py-0\.5{padding-top:.125rem;padding-bottom:.125rem}.py-1{padding-top:.25rem;padding-bottom:.25rem}.py-1\.5{padding-top:.375rem;padding-bottom:.375rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.py-3{padding-top:.75rem;padding-bottom:.75rem}.py-4{padding-top:1rem;padding-bottom:1rem}.text-left{text-align:left}.text-center{text-align:center}.text-\[10px\]{font-size:10px}.text-\[11px\]{font-size:11px}.text-\[9px\]{font-size:9px}.text-lg{font-size:1.125rem;line-height:1.75rem}.text-sm{font-size:.875rem;line-height:1.25rem}.text-xl{font-size:1.25rem;line-height:1.75rem}.text-xs{font-size:.75rem;line-height:1rem}.font-bold{font-weight:700}.font-semibold{font-weight:600}.italic{font-style:italic}.leading-relaxed{line-height:1.625}.text-\[var\(--acc\)\]{color:var(--acc)}.text-\[var\(--muted\)\]{color:var(--muted)}.text-amber-300\/60{color:#fcd34d99}.text-amber-400{--tw-text-opacity: 1;color:rgb(251 191 36 / var(--tw-text-opacity, 1))}.text-amber-400\/80{color:#fbbf24cc}.text-green-400{--tw-text-opacity: 1;color:rgb(74 222 128 / var(--tw-text-opacity, 1))}.text-purple-300{--tw-text-opacity: 1;color:rgb(216 180 254 / var(--tw-text-opacity, 1))}.text-purple-400{--tw-text-opacity: 1;color:rgb(192 132 252 / var(--tw-text-opacity, 1))}.text-purple-400\/80{color:#c084fccc}.text-red-400\/70{color:#f87171b3}.text-transparent{color:transparent}.text-white{--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity, 1))}.line-through{text-decoration-line:line-through}.opacity-50{opacity:.5}.outline-none{outline:2px solid transparent;outline-offset:2px}.outline{outline-style:solid}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.transition{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-all{transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-colors{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.duration-500{transition-duration:.5s}:root{--bg: #07090f;--panel: #0f1219;--panel2: #141824;--line: #1c2236;--text: #dde4f8;--muted: #5a6b92;--ok: #2ecc8a;--warn: #f5c842;--danger: #ff5270;--acc: #6a9eff;--acc2: #a07aff}*{box-sizing:border-box;margin:0;padding:0}body{background:var(--bg);color:var(--text);font-family:PingFang SC,Inter,-apple-system,Segoe UI,sans-serif;min-height:100vh}::-webkit-scrollbar{width:4px;height:4px}::-webkit-scrollbar-track{background:transparent}::-webkit-scrollbar-thumb{background:#1e2538;border-radius:4px}.wrap{max-width:1400px;margin:0 auto;padding:16px}.hdr{display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:10px;margin-bottom:16px;padding-bottom:14px;border-bottom:1px solid var(--line)}.logo{font-size:20px;font-weight:800;background:linear-gradient(135deg,#6a9eff,#a07aff);-webkit-background-clip:text;-webkit-text-fill-color:transparent}.sub-text{font-size:11px;color:var(--muted)}.hdr-r{display:flex;align-items:center;gap:8px;flex-wrap:wrap}.chip{font-size:11px;padding:3px 9px;border:1px solid var(--line);border-radius:999px;background:var(--panel);color:var(--muted)}.chip.ok{border-color:#2ecc8a44;color:var(--ok)}.chip.warn{border-color:#f5c84244;color:var(--warn)}.chip.err{border-color:#ff527044;color:var(--danger)}.btn-refresh{font-size:11px;padding:4px 10px;border:1px solid var(--acc);border-radius:6px;background:transparent;color:var(--acc);cursor:pointer}.btn-refresh:hover{background:#0a1228}.tabs{display:flex;gap:2px;margin-bottom:18px;border-bottom:1px solid var(--line);overflow-x:auto}.tab{font-size:13px;padding:8px 16px;border-radius:8px 8px 0 0;cursor:pointer;color:var(--muted);border:1px solid transparent;border-bottom:none;white-space:nowrap;position:relative;bottom:-1px;transition:all .15s;-webkit-user-select:none;-moz-user-select:none;user-select:none}.tab:hover{color:var(--text);background:var(--panel)}.tab.active{color:var(--text);background:var(--panel);border-color:var(--line);font-weight:600}.tbadge{font-size:10px;padding:1px 5px;border-radius:999px;background:#1a2040;color:var(--acc);margin-left:4px}.edict-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(340px,1fr));gap:12px}.edict-card{background:var(--panel);border:1px solid var(--line);border-radius:14px;padding:18px;cursor:pointer;transition:border-color .15s,transform .1s,box-shadow .15s}.edict-card:hover{border-color:var(--acc);transform:translateY(-2px);box-shadow:0 4px 20px #6a9eff1a}.edict-card.archived{opacity:.55;border-style:dashed}.edict-card.archived:hover{opacity:.85}.ec-pipe{display:flex;align-items:center;gap:0;margin-bottom:14px;overflow-x:auto;padding-bottom:2px}.ep-node{display:flex;flex-direction:column;align-items:center;gap:1px;padding:5px 8px;border-radius:6px;flex-shrink:0;min-width:52px}.ep-node.done{background:#0a2018}.ep-node.active{background:#0f1a38;border:1px solid var(--acc)}.ep-node.pending{opacity:.3}.ep-icon{font-size:14px}.ep-name{font-size:9px;color:var(--muted);white-space:nowrap}.ep-node.done .ep-name{color:var(--ok)}.ep-node.active .ep-name{color:var(--acc);font-weight:700}.ep-arrow{font-size:10px;color:#1c2236;padding:0 1px;flex-shrink:0}.ec-id{font-size:10px;color:var(--acc);font-weight:700;letter-spacing:.04em;margin-bottom:5px}.ec-title{font-size:15px;font-weight:700;line-height:1.4;margin-bottom:10px;color:var(--text)}.ec-meta{display:flex;flex-wrap:wrap;gap:6px;align-items:center;margin-bottom:8px}.tag{font-size:10px;padding:2px 7px;border-radius:4px;border:1px solid;display:inline-block;white-space:nowrap}.st-Inbox{border-color:#3a4a7a44;color:#7a9aff;background:#0a1028}.st-Taizi{border-color:#e8a04044;color:#e8a040;background:#281a08}.st-Zhongshu{border-color:#a07aff44;color:#a07aff;background:#110a28}.st-Menxia{border-color:#ff9a6a44;color:#ff9a6a;background:#280f0a}.st-Assigned,.st-Doing{border-color:#6a9eff44;color:#6a9eff;background:#0a1428}.st-Review{border-color:#f5c84244;color:#f5c842;background:#201a08}.st-Done{border-color:#2ecc8a44;color:var(--ok);background:#0a2018}.st-Blocked{border-color:#ff527044;color:var(--danger);background:#200a10}.st-Cancelled{border-color:#8884;color:#888;background:#1a1a1a}.st-Next{border-color:#4a9adf44;color:#4a9adf;background:#0a1424}.st-Pending{border-color:#3a4a7a44;color:#7a9aff;background:#0a1028}.dt-中书省{border-color:#a07aff44;color:#a07aff;background:#1a0f38}.dt-门下省{border-color:#6a9eff44;color:#6a9eff;background:#0f1a38}.dt-尚书省{border-color:#6aef9a44;color:#6aef9a;background:#0a2018}.dt-礼部{border-color:#f5c84244;color:#f5c842;background:#201a08}.dt-户部{border-color:#ff9a6a44;color:#ff9a6a;background:#28100a}.dt-兵部{border-color:#ff527044;color:#ff5270;background:#280a10}.dt-刑部{border-color:#c444;color:#c44;background:#280808}.dt-工部{border-color:#4af4;color:#4af;background:#081828}.ec-footer{display:flex;align-items:center;justify-content:space-between;margin-top:10px;flex-wrap:wrap;gap:6px}.hb{font-size:10px;padding:2px 7px;border-radius:999px;border:1px solid var(--line)}.hb.active{border-color:#2ecc8a44;color:var(--ok)}.hb.warn{border-color:#f5c84244;color:var(--warn)}.hb.stalled{border-color:#ff527044;color:var(--danger);animation:pulse 1.5s infinite}.hb.unknown{color:var(--muted)}@keyframes pulse{0%,to{opacity:1}50%{opacity:.4}}.modal-bg{position:fixed;top:0;right:0;bottom:0;left:0;background:#000000b3;z-index:100;-webkit-backdrop-filter:blur(3px);backdrop-filter:blur(3px);overflow-y:auto;display:flex;align-items:flex-start;justify-content:center;padding:40px 16px}.modal{background:var(--panel);border:1px solid var(--line);border-radius:18px;width:100%;max-width:760px;padding:28px;position:relative;box-shadow:0 20px 60px #0009}.modal-close{position:absolute;top:16px;right:16px;width:32px;height:32px;display:flex;align-items:center;justify-content:center;border-radius:8px;cursor:pointer;font-size:18px;color:var(--muted);background:none;border:none}.modal-close:hover{background:var(--panel2);color:var(--text)}.modal-id{font-size:11px;color:var(--acc);font-weight:700;letter-spacing:.04em;margin-bottom:6px}.modal-title{font-size:22px;font-weight:800;line-height:1.3;margin-bottom:18px}.m-pipe{display:flex;align-items:stretch;gap:0;overflow-x:auto;padding:16px;background:var(--panel2);border-radius:12px;margin-bottom:20px}.mp-stage{display:flex;align-items:center;flex-shrink:0}.mp-node{display:flex;flex-direction:column;align-items:center;gap:4px;padding:10px 14px;border-radius:10px;min-width:80px;position:relative}.mp-node.done{background:#0a2018;border:1px solid #2ecc8a44}.mp-node.active{background:#0f1838;border:2px solid var(--acc);box-shadow:0 0 14px #6a9eff33}.mp-node.pending{opacity:.25;border:1px dashed var(--line)}.mp-icon{font-size:22px}.mp-dept{font-size:12px;font-weight:700;margin-top:2px}.mp-node.done .mp-dept{color:var(--ok)}.mp-node.active .mp-dept{color:var(--acc)}.mp-node.pending .mp-dept{color:var(--muted)}.mp-action{font-size:10px;color:var(--muted);margin-top:1px}.mp-node.active .mp-action{color:#6a9eff88}.mp-done-tick{position:absolute;top:-6px;right:-6px;width:16px;height:16px;background:var(--ok);border-radius:50%;display:flex;align-items:center;justify-content:center;font-size:9px;color:#000;font-weight:700}.mp-arrow{color:#1c2236;font-size:18px;padding:0 6px;margin-top:-10px}.cur-stage{display:flex;align-items:center;gap:10px;padding:12px 16px;background:#0a1228;border:1px solid var(--acc);border-radius:10px;margin-bottom:18px}.cs-icon{font-size:24px}.cs-info .cs-dept{font-size:16px;font-weight:700;color:var(--acc)}.cs-info .cs-action{font-size:12px;color:var(--muted);margin-top:2px}.cs-hb{margin-left:auto}.m-section{margin-bottom:18px}.m-sec-label{font-size:11px;font-weight:700;color:var(--muted);letter-spacing:.06em;text-transform:uppercase;margin-bottom:10px;padding-bottom:6px;border-bottom:1px solid var(--line)}.fl-timeline{display:flex;flex-direction:column;gap:0;position:relative}.fl-timeline:before{content:"";position:absolute;left:60px;top:0;bottom:0;width:1px;background:var(--line)}.fl-item{display:flex;gap:0;position:relative;padding:8px 0}.fl-time{min-width:60px;font-size:10px;color:var(--muted);text-align:right;padding-right:14px;flex-shrink:0;padding-top:3px}.fl-dot{width:10px;height:10px;border-radius:50%;flex-shrink:0;margin-top:3px;position:relative;z-index:1}.fl-content{padding-left:12px;flex:1}.fl-who{font-size:12px;margin-bottom:2px}.fl-who .from,.fl-who .to{font-weight:700}.fl-rem{font-size:11px;color:var(--muted);line-height:1.5}.m-rows{display:grid;grid-template-columns:1fr 1fr;gap:8px}.m-row{background:var(--panel2);border-radius:8px;padding:10px 12px}.mr-label{font-size:10px;color:var(--muted);text-transform:uppercase;letter-spacing:.05em;margin-bottom:3px}.mr-val{font-size:13px;font-weight:600;word-break:break-all}.duty-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(310px,1fr));gap:12px}.duty-card{background:var(--panel);border:1px solid var(--line);border-radius:14px;overflow:hidden;transition:border-color .15s}.duty-card:hover{border-color:#2e3d6a}.duty-card.active-card{border-color:var(--acc)}.duty-card.blocked-card{border-color:#ff527055}.dc-hdr{display:flex;align-items:center;gap:10px;padding:12px 16px;background:var(--panel2);border-bottom:1px solid var(--line)}.dc-emoji{font-size:22px}.dc-info{flex:1}.dc-name{font-size:14px;font-weight:800}.dc-role{font-size:10px;color:var(--muted)}.dc-status{display:flex;align-items:center;gap:5px;font-size:11px}.dc-dot{width:8px;height:8px;border-radius:50%;flex-shrink:0}.dc-dot.active{background:var(--ok)}.dc-dot.busy{background:var(--warn);animation:pulse 1.5s infinite}.dc-dot.blocked{background:var(--danger);animation:pulse 1s infinite}.dc-dot.idle{background:#2a3a5a}.dc-body{padding:14px 16px}.dc-idle{display:flex;align-items:center;gap:8px;color:var(--muted);font-size:13px;padding:6px 0}.dc-task{display:flex;flex-direction:column;gap:6px;cursor:pointer;padding:6px;border-radius:8px;border:1px solid var(--line);margin-bottom:6px}.dc-task:hover{border-color:var(--acc)}.dc-task-id{font-size:10px;color:var(--acc);font-weight:700;letter-spacing:.04em}.dc-task-title{font-size:14px;font-weight:700;color:var(--text);line-height:1.3}.dc-task-now{font-size:12px;color:var(--muted);line-height:1.5;margin-top:2px}.dc-task-meta{display:flex;align-items:center;gap:8px;flex-wrap:wrap;margin-top:6px}.dc-footer{padding:8px 16px;border-top:1px solid var(--line);display:flex;align-items:center;gap:8px;background:var(--panel2)}.dc-model{font-size:10px;color:var(--muted)}.dc-la{font-size:10px;color:var(--muted);margin-left:auto}.as-panel{background:var(--panel);border:1px solid var(--line);border-radius:14px;padding:14px 18px;margin-bottom:16px}.as-header{display:flex;align-items:center;gap:10px;margin-bottom:12px}.as-title{font-size:13px;font-weight:700}.as-gw{font-size:11px;padding:3px 10px;border-radius:999px;margin-left:auto}.as-gw.ok{background:#0a2018;border:1px solid #2ecc8a44;color:var(--ok)}.as-gw.err{background:#200a10;border:1px solid #ff527044;color:var(--danger)}.as-gw.warn{background:#201a08;border:1px solid #f5c84244;color:var(--warn)}.as-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(130px,1fr));gap:8px}.as-card{background:var(--panel2);border:1px solid var(--line);border-radius:10px;padding:10px;text-align:center;cursor:pointer;transition:border-color .15s,background .15s;position:relative}.as-card:hover{border-color:var(--acc);background:#0a1228}.as-dot{position:absolute;top:6px;right:6px;width:8px;height:8px;border-radius:50%}.as-dot.running{background:#2ecc8a;box-shadow:0 0 6px #2ecc8a88;animation:pulse 1.5s infinite}.as-dot.idle{background:#4a5568}.as-dot.offline{background:#ff5270;animation:pulse 1.2s infinite}.as-dot.unconfigured{background:#6b7280}.as-wake-btn{font-size:10px;padding:2px 8px;border-radius:6px;border:1px solid var(--acc);color:var(--acc);background:transparent;cursor:pointer;margin-top:6px;transition:background .15s}.as-wake-btn:hover{background:var(--acc);color:#fff}.as-summary{font-size:11px;color:var(--muted);display:flex;gap:12px;margin-top:10px;padding-top:8px;border-top:1px solid var(--line)}.task-actions{display:flex;gap:8px;margin-bottom:18px;flex-wrap:wrap}.btn-action{font-size:12px;padding:7px 16px;border-radius:8px;border:none;cursor:pointer;font-weight:700;transition:all .15s}.btn-stop{background:#ff527022;color:#ff5270;border:1px solid #ff527044}.btn-stop:hover{background:#ff527044}.btn-cancel-action{background:#8882;color:#888;border:1px solid #88888844}.btn-cancel-action:hover{background:#8884}.btn-resume{background:#2ecc8a22;color:#2ecc8a;border:1px solid #2ecc8a44}.btn-resume:hover{background:#2ecc8a44}.sched-section{margin-bottom:18px;background:var(--panel2);border:1px solid var(--line);border-radius:10px;padding:12px}.sched-head{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-bottom:8px}.sched-title{font-size:11px;font-weight:700;letter-spacing:.06em;color:var(--acc)}.sched-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:8px;margin-bottom:10px}.sched-kpi{background:var(--panel);border:1px solid var(--line);border-radius:8px;padding:8px 10px}.sched-kpi .k{font-size:10px;color:var(--muted);margin-bottom:2px}.sched-kpi .v{font-size:13px;font-weight:700}.sched-btn{font-size:11px;padding:5px 10px;border-radius:6px;border:1px solid var(--line);background:transparent;color:var(--muted);cursor:pointer;transition:all .15s}.sched-btn:hover{border-color:var(--acc);color:var(--text)}.todo-section{margin-bottom:18px}.todo-header{display:flex;align-items:center;justify-content:space-between;margin-bottom:10px}.todo-progress{display:flex;align-items:center;gap:8px;font-size:12px;color:var(--muted)}.todo-bar{width:120px;height:6px;background:#0e1320;border-radius:3px;overflow:hidden}.todo-bar-fill{height:100%;border-radius:3px;background:var(--ok);transition:width .3s}.todo-list{display:flex;flex-direction:column;gap:4px}.todo-item{display:flex;flex-direction:column;background:var(--panel2);border-radius:8px;font-size:12px;transition:opacity .15s}.todo-item.done{opacity:.55}.todo-item .t-row{display:flex;align-items:center;gap:8px;padding:7px 10px}.todo-item .t-icon{font-size:14px;flex-shrink:0}.todo-item .t-title{flex:1;color:var(--text)}.todo-item.done .t-title{text-decoration:line-through;color:var(--muted)}.todo-item .t-status{font-size:10px;padding:2px 6px;border-radius:4px}.todo-item .t-status.s-done{color:var(--ok);background:#0a2018;border:1px solid #2ecc8a44}.todo-item .t-status.s-progress{color:var(--acc);background:#0a1228;border:1px solid #6a9eff44}.todo-item .t-status.s-notstarted{color:var(--muted);background:var(--panel);border:1px solid var(--line)}.ec-todo-bar{display:flex;align-items:center;gap:6px;font-size:10px;color:var(--muted);margin-top:6px}.ec-todo-track{flex:1;max-width:80px;height:4px;background:#0e1320;border-radius:2px;overflow:hidden}.ec-todo-fill{height:100%;background:var(--ok);border-radius:2px}.ec-actions{display:flex;gap:4px;margin-top:8px}.ec-actions .mini-act{font-size:10px;padding:3px 8px;border-radius:5px;border:1px solid var(--line);background:transparent;cursor:pointer;color:var(--muted);transition:all .12s}.ec-actions .mini-act:hover{border-color:var(--acc);color:var(--text)}.ec-actions .mini-act.danger:hover{border-color:#ff5270;color:#ff5270}.archive-bar{display:flex;align-items:center;gap:8px;margin-bottom:14px;flex-wrap:wrap}.ab-label{font-size:12px;color:var(--muted);margin-right:4px}.ab-btn{font-size:11px;padding:4px 12px;border-radius:6px;border:1px solid var(--line);background:transparent;cursor:pointer;color:var(--muted);transition:all .15s;font-weight:600}.ab-btn:hover{border-color:var(--acc);color:var(--text)}.ab-btn.active{border-color:var(--acc);color:var(--acc);background:#0f1a38}.ab-count{font-size:10px;color:var(--muted);margin-left:auto}.ab-scan{font-size:11px;padding:4px 12px;border-radius:6px;border:1px solid #6a9eff44;background:transparent;cursor:pointer;color:var(--acc);font-weight:600;transition:all .15s}.ab-scan:hover{background:#0a1228;border-color:var(--acc)}.ab-scan-status{font-size:10px;color:var(--muted)}.la-section{margin-bottom:18px}.la-header{display:flex;align-items:center;justify-content:space-between;margin-bottom:10px}.la-title{font-size:11px;font-weight:700;color:var(--acc);letter-spacing:.06em}.la-log{max-height:320px;overflow-y:auto;background:var(--panel2);border:1px solid var(--line);border-radius:10px;padding:10px 12px;display:flex;flex-direction:column;gap:6px;font-size:12px}.la-entry{display:flex;gap:8px;align-items:flex-start;padding:5px 8px;border-radius:6px;line-height:1.5;word-break:break-all}.la-entry:hover{background:#6a9eff0a}.la-empty{text-align:center;color:var(--muted);padding:20px;font-size:12px}.model-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(300px,1fr));gap:12px;margin-bottom:18px}.mc-card{background:var(--panel);border:1px solid var(--line);border-radius:12px;padding:16px}.mc-top{display:flex;align-items:center;gap:10px;margin-bottom:12px}.mc-emoji{font-size:22px}.mc-name{font-size:15px;font-weight:700}.mc-role{font-size:11px;color:var(--muted)}.mc-cur{font-size:11px;color:var(--muted);margin-bottom:8px}.mc-cur b{color:var(--text)}.msel{width:100%;background:var(--panel2);border:1px solid var(--line);border-radius:7px;color:var(--text);padding:7px 10px;font-size:12px;outline:none;cursor:pointer}.msel:focus{border-color:var(--acc)}.mc-btns{display:flex;gap:6px;margin-top:8px}.btn{font-size:12px;padding:6px 14px;border-radius:7px;border:none;cursor:pointer;font-weight:600}.btn-p{background:var(--acc);color:#000}.btn-p:hover{filter:brightness(1.15)}.btn-p:disabled{background:#2a3a6a;color:var(--muted);cursor:not-allowed}.btn-g{background:transparent;border:1px solid var(--line);color:var(--muted)}.btn-g:hover{border-color:#2e3d6a;color:var(--text)}.cl-wrap{background:var(--panel);border:1px solid var(--line);border-radius:12px;padding:16px}.cl-title{font-size:12px;font-weight:700;color:var(--muted);letter-spacing:.05em;text-transform:uppercase;margin-bottom:10px}.cl-row{display:flex;gap:10px;font-size:11px;padding:5px 0;border-bottom:1px solid var(--line)}.cl-row:last-child{border-bottom:none}.skills-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(280px,1fr));gap:12px}.sk-card{background:var(--panel);border:1px solid var(--line);border-radius:12px;overflow:hidden}.sk-hdr{display:flex;align-items:center;gap:9px;padding:11px 14px;background:var(--panel2);border-bottom:1px solid var(--line)}.sk-list{padding:10px}.sk-item{display:flex;gap:8px;padding:8px 10px;border-radius:7px;font-size:12px;margin-bottom:3px;cursor:pointer;border:1px solid transparent;transition:all .12s}.sk-item:hover{background:var(--panel2);border-color:var(--line)}.sess-filters{display:flex;gap:8px;margin-bottom:14px;flex-wrap:wrap;align-items:center}.sess-filter{font-size:11px;padding:4px 10px;border-radius:999px;border:1px solid var(--line);background:var(--panel);color:var(--muted);cursor:pointer;transition:all .12s}.sess-filter:hover{border-color:var(--acc);color:var(--text)}.sess-filter.active{border-color:var(--acc);color:var(--acc);background:#0a1228}.sess-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(340px,1fr));gap:10px}.sess-card{background:var(--panel);border:1px solid var(--line);border-radius:12px;padding:14px;transition:border-color .12s;cursor:pointer}.sess-card:hover{border-color:#2e3d6a}.off-activity{display:flex;align-items:center;gap:8px;padding:8px 14px;background:#0a1228;border:1px solid #1a2a4a;border-radius:10px;margin-bottom:14px;font-size:12px;flex-wrap:wrap}.off-kpi{display:grid;grid-template-columns:repeat(4,1fr);gap:10px;margin-bottom:16px}.kpi{background:var(--panel);border:1px solid var(--line);border-radius:12px;padding:14px 16px}.kpi-v{font-size:24px;font-weight:800;margin-bottom:3px}.kpi-l{font-size:11px;color:var(--muted)}.off-layout{display:grid;grid-template-columns:260px 1fr;gap:14px}@media(max-width:700px){.off-layout{grid-template-columns:1fr}.off-kpi{grid-template-columns:repeat(2,1fr)}}.off-ranklist{background:var(--panel);border:1px solid var(--line);border-radius:14px;overflow:hidden}.orl-hdr{padding:10px 14px;background:var(--panel2);border-bottom:1px solid var(--line);font-size:11px;font-weight:700;color:var(--muted);letter-spacing:.06em;text-transform:uppercase}.orl-item{display:flex;align-items:center;gap:10px;padding:10px 14px;cursor:pointer;border-bottom:1px solid var(--line);transition:background .1s}.orl-item:last-child{border-bottom:none}.orl-item:hover{background:var(--panel2)}.orl-item.selected{background:#0a1228;border-left:3px solid var(--acc)}.off-detail{background:var(--panel);border:1px solid var(--line);border-radius:14px;padding:22px;min-height:400px}.mem-list{display:flex;flex-direction:column;gap:8px}.mem-card{display:flex;gap:14px;align-items:flex-start;background:var(--panel);border:1px solid var(--line);border-radius:12px;padding:14px 16px;cursor:pointer;transition:border-color .12s}.mem-card:hover{border-color:var(--acc)}.tpl-cats{display:flex;gap:8px;flex-wrap:wrap;margin-bottom:14px}.tpl-cat{font-size:12px;padding:6px 14px;border-radius:999px;border:1px solid var(--line);background:var(--panel);color:var(--muted);cursor:pointer;transition:all .12s}.tpl-cat:hover{border-color:var(--acc);color:var(--text)}.tpl-cat.active{border-color:var(--acc);color:var(--acc);background:#0a1228}.tpl-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(300px,1fr));gap:10px}.tpl-card{background:var(--panel);border:1px solid var(--line);border-radius:12px;padding:16px;transition:border-color .12s;cursor:pointer;display:flex;flex-direction:column}.tpl-card:hover{border-color:var(--acc)}.mb-hdr{display:flex;align-items:flex-start;justify-content:space-between;margin-bottom:18px;flex-wrap:wrap;gap:10px}.mb-title{font-size:20px;font-weight:800;background:linear-gradient(135deg,#f5c842,#ff9a4a);-webkit-background-clip:text;-webkit-text-fill-color:transparent}.mb-sub{font-size:12px;color:var(--muted);margin-top:3px}.mb-cats{display:grid;grid-template-columns:repeat(auto-fill,minmax(320px,1fr));gap:16px}.mb-cat{background:var(--panel);border:1px solid var(--line);border-radius:14px;overflow:hidden}.mb-cat-hdr{display:flex;align-items:center;gap:8px;padding:10px 16px;border-bottom:1px solid var(--line)}.mb-news-list{padding:10px}.mb-card{display:flex;gap:12px;padding:10px 8px;border-radius:10px;margin-bottom:6px;cursor:pointer;transition:background .12s;border-bottom:1px solid var(--line)}.mb-card:last-child{border-bottom:none}.mb-card:hover{background:var(--panel2)}.ceremony-bg{position:fixed;top:0;right:0;bottom:0;left:0;z-index:9999;background:#07090f;display:flex;flex-direction:column;align-items:center;justify-content:center;opacity:0;animation:crmFadeIn .6s ease forwards;cursor:pointer}.ceremony-bg.out{animation:crmFadeOut .5s ease forwards}.crm-glow{position:absolute;width:400px;height:400px;border-radius:50%;background:radial-gradient(circle,rgba(106,158,255,.08),transparent 70%);animation:crmPulse 3s ease-in-out infinite}.crm-line1{font-family:"Noto Serif SC",serif;font-size:52px;font-weight:900;color:#dde4f8;letter-spacing:.15em;opacity:0;transform:translateY(20px)}.crm-line2{font-family:"Noto Serif SC",serif;font-size:22px;font-weight:700;color:var(--acc);letter-spacing:.2em;margin-top:12px;opacity:0;transform:translateY(15px)}.crm-line3{font-size:14px;color:var(--muted);margin-top:24px;opacity:0;letter-spacing:.05em}.crm-date{font-size:12px;color:#2a3555;margin-top:40px;opacity:0;letter-spacing:.08em}.crm-skip{font-size:11px;color:#2a3555;margin-top:18px;opacity:0;animation:crmChar .4s 2.5s forwards}.crm-line1.in{animation:crmSlideUp .6s .3s ease forwards}.crm-line2.in{animation:crmSlideUp .5s 1.1s ease forwards}.crm-line3.in{animation:crmSlideUp .5s 1.6s ease forwards}.crm-date.in{animation:crmChar .4s 2s ease forwards}@keyframes crmFadeIn{to{opacity:1}}@keyframes crmFadeOut{to{opacity:0;pointer-events:none}}@keyframes crmSlideUp{to{opacity:1;transform:translateY(0)}}@keyframes crmChar{to{opacity:1}}@keyframes crmPulse{0%,to{transform:scale(1);opacity:.5}50%{transform:scale(1.1);opacity:.8}}.confirm-bg{position:fixed;top:0;right:0;bottom:0;left:0;background:#000000b3;z-index:200;-webkit-backdrop-filter:blur(3px);backdrop-filter:blur(3px);display:flex;align-items:center;justify-content:center}.confirm-box{background:var(--panel);border:1px solid var(--line);border-radius:14px;padding:24px;max-width:420px;width:90%;box-shadow:0 20px 60px #0009}.confirm-title{font-size:16px;font-weight:700;margin-bottom:8px}.confirm-msg{font-size:13px;color:var(--muted);margin-bottom:14px;line-height:1.5}.confirm-input{width:100%;background:var(--panel2);border:1px solid var(--line);border-radius:7px;color:var(--text);padding:8px 10px;font-size:12px;outline:none;margin-bottom:14px}.confirm-input:focus{border-color:var(--acc)}.confirm-btns{display:flex;gap:8px;justify-content:flex-end}.toaster{position:fixed;bottom:20px;right:20px;display:flex;flex-direction:column;gap:8px;z-index:300;pointer-events:none}.toast{font-size:13px;padding:10px 16px;border-radius:10px;border:1px solid var(--line);background:var(--panel);color:var(--text);box-shadow:0 4px 20px #0006;animation:tin .2s;max-width:320px;pointer-events:auto}.toast.ok{border-color:#2ecc8a55;background:#0a1a10}.toast.err{border-color:#ff527055;background:#200a10}@keyframes tin{0%{transform:translate(40px);opacity:0}to{transform:translate(0);opacity:1}}.sub-config{background:var(--panel);border:1px solid var(--line);border-radius:14px;padding:18px;margin-bottom:18px}.sub-section{margin-bottom:16px;padding-bottom:14px;border-bottom:1px solid var(--line)}.sub-section:last-child{border-bottom:none;margin-bottom:0;padding-bottom:0}.sub-sec-title{font-size:13px;font-weight:700;margin-bottom:10px}.sub-input{background:var(--panel2);border:1px solid var(--line);border-radius:7px;color:var(--text);padding:7px 10px;font-size:12px;outline:none;min-width:0}.sub-input:focus{border-color:var(--acc)}.si-name{font-weight:600;min-width:100px}.si-desc{color:var(--muted);flex:1;line-height:1.4}.si-arrow{color:var(--muted);font-size:14px;opacity:.3;transition:opacity .12s}.sk-item:hover .si-arrow{opacity:1}.sk-emoji{font-size:18px}.sk-name{font-size:14px;font-weight:700}.sk-cnt{font-size:11px;color:var(--muted);margin-left:auto}.sk-empty{font-size:12px;color:var(--muted);padding:12px;text-align:center;opacity:.6}.sk-add{display:flex;align-items:center;justify-content:center;gap:6px;padding:8px;font-size:12px;color:var(--acc);cursor:pointer;border-top:1px solid var(--line);transition:background .12s}.sk-add:hover{background:var(--panel2)}.sk-modal-body{max-height:70vh;overflow-y:auto}.sk-md{font-size:13px;line-height:1.7;color:var(--text)}.sk-md h1,.sk-md h2,.sk-md h3{margin:16px 0 8px;color:var(--text)}.sk-md h1{font-size:18px}.sk-md h2{font-size:15px;border-bottom:1px solid var(--line);padding-bottom:6px}.sk-md h3{font-size:13px}.sk-md p{margin:6px 0}.sk-md ul,.sk-md ol{padding-left:20px;margin:6px 0}.sk-md li{margin:3px 0}.sk-md code{font-size:11px;background:var(--panel2);padding:2px 6px;border-radius:4px;font-family:monospace}.sk-md pre{background:var(--panel2);border:1px solid var(--line);border-radius:8px;padding:12px;overflow-x:auto;margin:8px 0}.sk-md pre code{background:none;padding:0}.sk-md table{width:100%;border-collapse:collapse;font-size:12px;margin:8px 0}.sk-md th,.sk-md td{padding:6px 10px;border:1px solid var(--line);text-align:left}.sk-md th{background:var(--panel2)}.sk-md hr{border:none;border-top:1px solid var(--line);margin:14px 0}.sk-path{font-size:10px;color:var(--muted);padding:8px 0;word-break:break-all;border-top:1px solid var(--line);margin-top:12px}.sc-top{display:flex;align-items:center;gap:10px;margin-bottom:8px}.sc-emoji{font-size:20px}.sc-agent{font-size:13px;font-weight:700}.sc-org{font-size:11px;color:var(--muted)}.sc-title{font-size:13px;font-weight:600;margin-bottom:6px;line-height:1.4}.sc-now{font-size:11px;color:var(--muted);line-height:1.5;margin-bottom:6px}.sc-meta{display:flex;align-items:center;gap:6px;flex-wrap:wrap}.sc-id{font-size:10px;color:var(--acc);font-weight:600}.sc-time{font-size:10px;color:var(--muted);margin-left:auto}.mc-st{font-size:11px;margin-top:6px;padding:4px 8px;border-radius:5px;display:none}.mc-st.ok{display:block;background:#0a2018;color:var(--ok);border:1px solid #2ecc8a44}.mc-st.err{display:block;background:#200a10;color:var(--danger);border:1px solid #ff527044}.mc-st.pending{display:block;background:#0a1228;color:var(--acc);border:1px solid #6a9eff44}.cl-t{color:var(--muted);min-width:115px}.cl-a{color:var(--acc);min-width:80px}.cl-c{color:var(--muted)}.cl-c b{color:var(--text)}.cl-list{display:flex;flex-direction:column}.mem-icon{font-size:28px;flex-shrink:0;margin-top:2px}.mem-info{flex:1;min-width:0}.mem-title{font-size:14px;font-weight:700;margin-bottom:4px}.mem-sub{font-size:11px;color:var(--muted);line-height:1.5}.mem-tags{display:flex;gap:4px;flex-wrap:wrap;margin-top:6px}.mem-tag{font-size:10px;padding:2px 8px;border-radius:4px;background:var(--panel2);color:var(--muted);border:1px solid var(--line)}.mem-right{display:flex;flex-direction:column;align-items:flex-end;gap:4px;flex-shrink:0}.mem-date{font-size:10px;color:var(--muted)}.mem-cost{font-size:10px;color:var(--acc)}.mem-empty{text-align:center;padding:40px;color:var(--muted);font-size:13px}.md-timeline{position:relative;padding-left:24px;margin:16px 0}.md-timeline:before{content:"";position:absolute;left:7px;top:0;bottom:0;width:2px;background:var(--line)}.md-tl-item{position:relative;margin-bottom:14px;padding-bottom:14px;border-bottom:1px solid var(--line)}.md-tl-item:last-child{border-bottom:none;margin-bottom:0;padding-bottom:0}.md-tl-dot{position:absolute;left:-20px;top:3px;width:10px;height:10px;border-radius:50%;background:var(--acc);border:2px solid var(--bg)}.md-tl-dot.green{background:var(--ok)}.md-tl-dot.yellow{background:var(--warn)}.md-tl-dot.red{background:var(--danger)}.md-tl-from{font-size:11px;font-weight:700;color:var(--acc)}.md-tl-to{font-size:11px;color:var(--muted)}.md-tl-remark{font-size:12px;margin-top:3px;line-height:1.5}.md-tl-time{font-size:10px;color:var(--muted);margin-top:2px}.tpl-top{display:flex;align-items:center;gap:10px;margin-bottom:10px}.tpl-icon{font-size:24px}.tpl-name{font-size:14px;font-weight:700}.tpl-pop{font-size:10px;color:var(--muted);margin-left:auto}.tpl-desc{font-size:12px;color:var(--muted);line-height:1.5;margin-bottom:10px;flex:1}.tpl-footer{display:flex;align-items:center;gap:6px;flex-wrap:wrap}.tpl-dept{font-size:10px;padding:2px 6px;border-radius:4px;background:var(--panel2);color:var(--acc)}.tpl-est{font-size:10px;color:var(--muted);margin-left:auto}.tpl-go{font-size:11px;padding:5px 14px;border-radius:6px;background:var(--acc);color:#fff;border:none;cursor:pointer;font-weight:600;margin-left:8px;transition:opacity .12s}.tpl-go:hover{opacity:.85}.tpl-form{margin-top:18px}.tpl-field{margin-bottom:14px}.tpl-label{font-size:12px;font-weight:600;display:block;margin-bottom:6px}.tpl-input{width:100%;padding:10px 12px;background:var(--bg);border:1px solid var(--line);border-radius:8px;color:var(--text);font-size:13px;outline:none}.mb-img{width:72px;height:52px;border-radius:7px;-o-object-fit:cover;object-fit:cover;flex-shrink:0;background:var(--panel2);display:flex;align-items:center;justify-content:center;font-size:22px;overflow:hidden}.mb-img img{width:100%;height:100%;-o-object-fit:cover;object-fit:cover;border-radius:7px}.mb-info{flex:1;min-width:0}.mb-headline{font-size:13px;font-weight:700;line-height:1.4;margin-bottom:4px;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}.mb-summary{font-size:11px;color:var(--muted);line-height:1.5;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}.mb-meta{display:flex;align-items:center;gap:8px;margin-top:5px}.mb-source{font-size:10px;color:var(--acc)}.mb-time{font-size:10px;color:var(--muted)}.mb-cat-icon{font-size:20px}.mb-cat-name{font-size:14px;font-weight:800}.mb-cat-cnt{font-size:11px;color:var(--muted);margin-left:auto}.mb-empty{text-align:center;padding:30px;color:var(--muted);font-size:13px}.mb-loading{display:flex;align-items:center;justify-content:center;padding:60px;color:var(--muted);font-size:14px;gap:10px}.la-dot{display:inline-block;width:6px;height:6px;border-radius:50%;background:var(--ok);margin-right:4px;animation:pulse 1.5s infinite}.la-dot.idle{background:var(--muted);animation:none}.la-agent{font-size:11px;color:var(--muted)}.la-icon{flex-shrink:0;font-size:13px;margin-top:1px}.la-body{flex:1;min-width:0}.la-time{font-size:10px;color:var(--muted);flex-shrink:0;min-width:44px;text-align:right}.la-assistant{color:var(--text)}.la-thinking{color:#a07aff;font-style:italic;opacity:.75}.la-tool{color:#4af}.la-tool-result{color:var(--muted);font-size:11px}.la-tool-result.ok{color:var(--ok)}.la-tool-result.err{color:var(--danger)}.la-user{color:var(--warn)}.la-tool-name{font-weight:700;margin-right:4px}.la-trunc{color:var(--muted);font-size:10px;opacity:.6}.la-flow-wrap{display:flex;flex-direction:column;gap:6px}.la-groups{display:flex;flex-direction:column;gap:8px;margin-top:4px}.la-group{border:1px solid var(--line);border-radius:8px;background:var(--panel)}.la-group-hd{display:flex;align-items:center;justify-content:space-between;padding:6px 10px;border-bottom:1px solid var(--line);font-size:11px;color:var(--muted)}.la-group-hd .name{font-weight:700;color:var(--text)}.la-group-bd{display:flex;flex-direction:column;gap:4px;padding:6px}.sched-status{font-size:10px;color:var(--muted)}.sched-line{font-size:11px;color:var(--muted);display:flex;gap:12px;flex-wrap:wrap;margin-bottom:10px}.sched-actions{display:flex;gap:6px;flex-wrap:wrap}.sched-btn.warn:hover{border-color:#f5c842;color:#f5c842}.sched-btn.danger:hover{border-color:#ff5270;color:#ff5270}.btn-cancel{background:#8882;color:#888;border:1px solid #88888844}.btn-cancel:hover{background:#8884}.btn-action:disabled{opacity:.4;cursor:not-allowed}.todo-detail{display:none;padding:4px 10px 10px 36px;font-size:11px;line-height:1.6;color:var(--text);white-space:pre-wrap;word-break:break-word;border-top:1px solid var(--line);margin:0 6px;opacity:.85}.todo-item.expanded .todo-detail{display:block}.todo-item .t-expand{color:var(--muted);font-size:10px;transition:transform .2s;flex-shrink:0}.todo-item.expanded .t-expand{transform:rotate(90deg)}.todo-item .t-id{color:var(--muted);font-size:10px;min-width:20px}.todo-item.has-detail .t-row{cursor:pointer}.act-label{color:var(--muted);flex-shrink:0}.act-dot{display:inline-flex;align-items:center;gap:5px;padding:3px 8px;border-radius:999px;background:#0f1a38;border:1px solid #1e2e50;margin:2px}.act-dot.alive{border-color:#2ecc8a44;background:#0a2018;color:var(--ok)}.act-dot.warn{border-color:#f5c84244;background:#201a08;color:var(--warn)}.act-dot.idle{color:var(--muted)}.orl-medal{font-size:16px;min-width:20px;text-align:center}.orl-emoji{font-size:18px}.orl-name{flex:1}.orl-role{font-size:12px;font-weight:700}.orl-org{font-size:10px;color:var(--muted)}.orl-score{font-size:11px;font-weight:700;color:var(--acc)}.orl-hbdot{width:8px;height:8px;border-radius:50%;flex-shrink:0}.orl-hbdot.active{background:var(--ok)}.orl-hbdot.warn{background:var(--warn)}.orl-hbdot.stalled{background:var(--danger);animation:pulse 1.2s infinite}.orl-hbdot.idle{background:#2a3a5a}.od-empty{display:flex;align-items:center;justify-content:center;height:100%;color:var(--muted);font-size:13px;min-height:200px}.od-hero{display:flex;align-items:center;gap:16px;margin-bottom:20px;padding-bottom:16px;border-bottom:1px solid var(--line)}.od-emoji{font-size:40px}.od-name{font-size:22px;font-weight:800}.od-role{font-size:13px;color:var(--muted);margin-top:2px}.od-rank-badge{font-size:11px;padding:3px 9px;border-radius:999px;border:1px solid #f5c84244;color:#f5c842;background:#201a08;margin-top:4px;display:inline-block}.od-hb{margin-left:auto;text-align:right}.od-section{margin-bottom:18px}.od-sec-title{font-size:10px;font-weight:700;color:var(--muted);letter-spacing:.07em;text-transform:uppercase;margin-bottom:10px}.od-stats{display:grid;grid-template-columns:repeat(3,1fr);gap:8px}.ods{background:var(--panel2);border-radius:8px;padding:10px;text-align:center}.ods-v{font-size:20px;font-weight:800}.ods-l{font-size:10px;color:var(--muted);margin-top:2px}.tbar{margin-bottom:7px}.tbar-hdr{display:flex;justify-content:space-between;font-size:11px;margin-bottom:3px}.tbar-label{color:var(--muted)}.tbar-val{font-weight:600}.tbar-track{height:6px;background:#0e1320;border-radius:3px;overflow:hidden}.tbar-fill{height:100%;border-radius:3px}.od-cost-row{display:flex;gap:10px;flex-wrap:wrap}.cost-chip{font-size:12px;padding:5px 12px;border-radius:8px;border:1px solid var(--line);background:var(--panel2)}.cost-chip b{font-size:15px}.cost-chip.hi{border-color:#ff527044}.cost-chip.md{border-color:#f5c84244}.cost-chip.lo{border-color:#2ecc8a44}.od-edict-list{display:flex;flex-direction:column;gap:5px}.oe-item{display:flex;align-items:center;gap:8px;padding:7px 10px;background:var(--panel2);border-radius:7px;font-size:12px;cursor:pointer}.oe-item:hover{background:#141c30}.oe-id{font-size:10px;color:var(--acc);font-weight:700;min-width:110px}.oe-title{flex:1;color:var(--text)}.oe-state{font-size:10px}.kpi-v.gold{color:#f5c842}.kpi-v.green{color:var(--ok)}.kpi-v.blue{color:var(--acc)}.kpi-v.warn{color:var(--warn)}.sub-cats{display:flex;flex-wrap:wrap;gap:8px}.sub-cat{display:flex;align-items:center;gap:6px;padding:7px 12px;border-radius:8px;border:1px solid var(--line);background:var(--panel2);cursor:pointer;transition:all .15s;-webkit-user-select:none;-moz-user-select:none;user-select:none}.sub-cat:hover{border-color:var(--acc)}.sub-cat.active{border-color:var(--ok);background:#0a2018}.sub-cat .sc-check{width:16px;height:16px;border-radius:4px;border:1px solid var(--line);display:flex;align-items:center;justify-content:center;font-size:10px;transition:all .15s}.sub-cat.active .sc-check{background:var(--ok);border-color:var(--ok);color:#000}.sub-cat .sc-label{font-size:12px;font-weight:600}.sub-cat .sc-count{font-size:10px;color:var(--muted)}.sub-kw-list{display:flex;flex-wrap:wrap;gap:6px}.sub-kw{display:flex;align-items:center;gap:4px;padding:4px 8px 4px 10px;border-radius:999px;background:#0f1a38;border:1px solid #1e2e50;font-size:11px;color:var(--acc)}.sub-kw .kw-del{cursor:pointer;opacity:.5;font-size:13px;padding:0 2px}.sub-kw .kw-del:hover{opacity:1;color:var(--danger)}.sub-feed-list{display:flex;flex-direction:column;gap:4px}.sub-feed{display:flex;align-items:center;gap:8px;padding:6px 10px;background:var(--panel2);border-radius:7px;font-size:12px}.sub-feed .sf-name{font-weight:600;min-width:80px;color:var(--acc)}.sub-feed .sf-url{flex:1;color:var(--muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.sub-feed .sf-cat{font-size:10px;padding:2px 6px;border-radius:4px;border:1px solid var(--line)}.sub-feed .sf-del{cursor:pointer;color:var(--muted);font-size:14px}.sub-feed .sf-del:hover{color:var(--danger)}.as-card .as-emoji{font-size:22px;margin-bottom:3px}.as-card .as-label{font-size:12px;font-weight:700}.as-card .as-role{font-size:10px;color:var(--muted)}.as-card .as-status{font-size:10px;margin-top:4px}.as-card .as-time{font-size:9px;color:var(--muted);margin-top:2px}.as-wake-btn:disabled{opacity:.4;cursor:not-allowed}.as-refresh{font-size:11px;padding:4px 12px;border-radius:8px;border:1px solid var(--line);color:var(--muted);background:transparent;cursor:pointer;transition:background .15s}.as-refresh:hover{background:var(--panel2);color:var(--text)}.as-wake-all{font-size:11px;padding:4px 12px;border-radius:8px;border:1px solid var(--warn);color:var(--warn);background:transparent;cursor:pointer;transition:background .15s;margin-left:6px}.as-wake-all:hover{background:var(--warn);color:#fff}.as-summary span{display:flex;align-items:center;gap:4px}.archive-bar .ab-archive-all{font-size:11px;padding:4px 12px;border-radius:6px;border:1px solid #2ecc8a44;background:transparent;cursor:pointer;color:var(--ok);font-weight:600;transition:all .15s}.archive-bar .ab-archive-all:hover{background:#0a2018;border-color:var(--ok)}.archive-bar .ab-scan-detail{font-size:11px;padding:4px 10px;border-radius:6px;border:1px solid var(--line);background:transparent;cursor:pointer;color:var(--muted);font-weight:600;transition:all .15s}.archive-bar .ab-scan-detail:hover{border-color:var(--acc);color:var(--text)}.archive-bar .ab-scan-detail.active{border-color:var(--acc);color:var(--acc);background:#0f1a38}.archive-bar .ab-scan-copy{font-size:11px;padding:4px 10px;border-radius:6px;border:1px solid #2ecc8a44;background:transparent;cursor:pointer;color:var(--ok);font-weight:600;transition:all .15s}.archive-bar .ab-scan-copy:hover{background:#0a2018;border-color:var(--ok)}.global-scan-detail{display:none;margin-top:-4px;margin-bottom:12px;background:var(--panel2);border:1px solid var(--line);border-radius:10px;padding:10px 12px}.global-scan-detail.open{display:block}.global-scan-detail .gs-empty{font-size:11px;color:var(--muted)}.global-scan-detail .gs-list{display:flex;flex-direction:column;gap:6px}.global-scan-detail .gs-item{display:flex;align-items:center;gap:8px;padding:6px 8px;border-radius:8px;background:var(--panel);border:1px solid var(--line);font-size:11px}.global-scan-detail .gs-tag{font-size:10px;border-radius:10px;padding:2px 8px;font-weight:700;border:1px solid var(--line);color:var(--muted)}.global-scan-detail .gs-tag.retry{color:var(--acc);border-color:#6a9eff55}.global-scan-detail .gs-tag.escalate{color:#f5c842;border-color:#f5c84255}.global-scan-detail .gs-tag.rollback{color:#ff5270;border-color:#ff527055}.global-scan-detail .gs-task{font-weight:700;color:var(--text)}.global-scan-detail .gs-meta{color:var(--muted)}.global-scan-detail .gs-hint{margin-top:8px;font-size:10px;color:var(--muted)}.confirm-reason{width:100%;background:var(--panel2);border:1px solid var(--line);border-radius:7px;color:var(--text);padding:8px 10px;font-size:12px;outline:none;margin-bottom:14px;resize:vertical;min-height:60px}.confirm-reason:focus{border-color:var(--acc)}.empty{text-align:center;padding:40px 20px;color:var(--muted);font-size:13px}.sec-title{font-size:12px;font-weight:700;color:var(--muted);letter-spacing:.07em;text-transform:uppercase;margin-bottom:12px}code{font-size:11px;background:var(--panel2);padding:2px 6px;border-radius:4px;font-family:monospace}@keyframes fadeIn{0%{opacity:0;transform:translateY(6px)}to{opacity:1;transform:translateY(0)}}@keyframes fadeOut{0%{opacity:1}to{opacity:0}}@keyframes pulse{0%,to{opacity:.6}50%{opacity:1}}@keyframes bounceIn{0%{transform:scale(0)}60%{transform:scale(1.3)}to{transform:scale(1)}}.hover\:border-\[var\(--acc\)\]:hover{border-color:var(--acc)}.hover\:border-\[var\(--warn\)\]:hover{border-color:var(--warn)}.hover\:bg-\[var\(--acc\)\]:hover{background-color:var(--acc)}.hover\:bg-amber-900\/20:hover{background-color:#78350f33}.hover\:bg-purple-900\/20:hover{background-color:#581c8733}.hover\:text-\[var\(--acc\)\]:hover{color:var(--acc)}.hover\:text-\[var\(--text\)\]:hover{color:var(--text)}.hover\:text-\[var\(--warn\)\]:hover{color:var(--warn)}.hover\:text-red-400:hover{--tw-text-opacity: 1;color:rgb(248 113 113 / var(--tw-text-opacity, 1))}.focus\:border-\[var\(--acc\)\]:focus{border-color:var(--acc)}.focus\:border-amber-600:focus{--tw-border-opacity: 1;border-color:rgb(217 119 6 / var(--tw-border-opacity, 1))}.disabled\:opacity-40:disabled{opacity:.4}@media(min-width:640px){.sm\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}}@media(min-width:768px){.md\:grid-cols-5{grid-template-columns:repeat(5,minmax(0,1fr))}}@media(min-width:1024px){.lg\:grid-cols-\[280px_1fr\]{grid-template-columns:280px 1fr}} diff --git a/dashboard/dist/index.html b/dashboard/dist/index.html index 457c14d..5588b63 100644 --- a/dashboard/dist/index.html +++ b/dashboard/dist/index.html @@ -5,8 +5,8 @@ 三省六部 · Edict Dashboard - - + +
diff --git a/dashboard/server.py b/dashboard/server.py index 78b0692..66bd836 100644 --- a/dashboard/server.py +++ b/dashboard/server.py @@ -21,6 +21,12 @@ scripts_dir = str(pathlib.Path(__file__).parent.parent / 'scripts') sys.path.insert(0, scripts_dir) from file_lock import atomic_json_read, atomic_json_write, atomic_json_update from utils import validate_url, read_json, now_iso +from court_discuss import ( + create_session as cd_create, advance_discussion as cd_advance, + get_session as cd_get, conclude_session as cd_conclude, + list_sessions as cd_list, destroy_session as cd_destroy, + get_fate_event as cd_fate, OFFICIAL_PROFILES as CD_PROFILES, +) log = logging.getLogger('server') logging.basicConfig(level=logging.INFO, format='%(asctime)s [%(name)s] %(message)s', datefmt='%H:%M:%S') @@ -883,8 +889,8 @@ def _ensure_scheduler(task): sched = {} task['_scheduler'] = sched sched.setdefault('enabled', True) - sched.setdefault('stallThresholdSec', 180) - sched.setdefault('maxRetry', 1) + sched.setdefault('stallThresholdSec', 600) + sched.setdefault('maxRetry', 2) sched.setdefault('retryCount', 0) sched.setdefault('escalationLevel', 0) sched.setdefault('autoRollback', True) @@ -1055,8 +1061,8 @@ def handle_scheduler_rollback(task_id, reason=''): return {'ok': True, 'message': f'{task_id} 已回滚到 {snap_state}'} -def handle_scheduler_scan(threshold_sec=180): - threshold_sec = max(30, int(threshold_sec or 180)) +def handle_scheduler_scan(threshold_sec=600): + threshold_sec = max(60, int(threshold_sec or 600)) tasks = load_tasks() now_dt = datetime.datetime.now(datetime.timezone.utc) pending_retries = [] @@ -2177,6 +2183,17 @@ class Handler(BaseHTTPRequestHandler): self.send_json({'ok': False, 'error': 'invalid agent_id'}, 400) else: self.send_json({'ok': True, 'agentId': agent_id, 'activity': get_agent_activity(agent_id)}) + # ── 朝堂议政 ── + elif p == '/api/court-discuss/list': + self.send_json({'ok': True, 'sessions': cd_list()}) + elif p == '/api/court-discuss/officials': + self.send_json({'ok': True, 'officials': CD_PROFILES}) + elif p.startswith('/api/court-discuss/session/'): + sid = p.replace('/api/court-discuss/session/', '') + data = cd_get(sid) + self.send_json(data if data else {'ok': False, 'error': 'session not found'}, 200 if data else 404) + elif p == '/api/court-discuss/fate': + self.send_json({'ok': True, 'event': cd_fate()}) elif self._serve_static(p): pass # 已由 _serve_static 处理 (JS/CSS/图片等) else: @@ -2448,6 +2465,48 @@ class Handler(BaseHTTPRequestHandler): threading.Thread(target=apply_async, daemon=True).start() self.send_json({'ok': True, 'message': f'Queued: {agent_id} → {model}'}) + + # ── 朝堂议政 POST ── + elif p == '/api/court-discuss/start': + topic = body.get('topic', '').strip() + officials = body.get('officials', []) + task_id = body.get('taskId', '').strip() + if not topic: + self.send_json({'ok': False, 'error': 'topic required'}, 400) + return + if not officials or not isinstance(officials, list): + self.send_json({'ok': False, 'error': 'officials list required'}, 400) + return + # 校验官员 ID + valid_ids = set(CD_PROFILES.keys()) + officials = [o for o in officials if o in valid_ids] + if len(officials) < 2: + self.send_json({'ok': False, 'error': '至少选择2位官员'}, 400) + return + self.send_json(cd_create(topic, officials, task_id)) + + elif p == '/api/court-discuss/advance': + sid = body.get('sessionId', '').strip() + user_msg = body.get('userMessage', '').strip() or None + decree = body.get('decree', '').strip() or None + if not sid: + self.send_json({'ok': False, 'error': 'sessionId required'}, 400) + return + self.send_json(cd_advance(sid, user_msg, decree)) + + elif p == '/api/court-discuss/conclude': + sid = body.get('sessionId', '').strip() + if not sid: + self.send_json({'ok': False, 'error': 'sessionId required'}, 400) + return + self.send_json(cd_conclude(sid)) + + elif p == '/api/court-discuss/destroy': + sid = body.get('sessionId', '').strip() + if sid: + cd_destroy(sid) + self.send_json({'ok': True}) + else: self.send_error(404) diff --git a/docs/getting-started.md b/docs/getting-started.md index af8c9c4..196c0d1 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -134,6 +134,28 @@ open http://127.0.0.1:7891 python3 dashboard/server.py ``` +### Agent 报错 "No API key found for provider" + +这是最常见的问题。三省六部有 11 个 Agent,每个都需要 API Key。 + +```bash +# 方法一:为任意 Agent 配置后重新运行 install.sh(推荐) +openclaw agents add taizi # 按提示输入 Anthropic API Key +cd edict && ./install.sh # 自动同步到所有 Agent + +# 方法二:手动复制 auth 文件 +MAIN_AUTH=$(find ~/.openclaw/agents -name auth-profiles.json | head -1) +for agent in taizi zhongshu menxia shangshu hubu libu bingbu xingbu gongbu; do + mkdir -p ~/.openclaw/agents/$agent/agent + cp "$MAIN_AUTH" ~/.openclaw/agents/$agent/agent/auth-profiles.json +done + +# 方法三:逐个配置 +openclaw agents add taizi +openclaw agents add zhongshu +# ... 其他 Agent +``` + ### Agent 不响应 ```bash # 检查 Gateway 状态 diff --git a/edict/frontend/src/App.tsx b/edict/frontend/src/App.tsx index c06200d..f7dc90b 100644 --- a/edict/frontend/src/App.tsx +++ b/edict/frontend/src/App.tsx @@ -13,6 +13,7 @@ import TaskModal from './components/TaskModal'; // ConfirmDialog is used inside TaskModal as needed import Toaster from './components/Toaster'; import CourtCeremony from './components/CourtCeremony'; +import CourtDiscussion from './components/CourtDiscussion'; export default function App() { const activeTab = useStore((s) => s.activeTab); @@ -81,6 +82,7 @@ export default function App() { {/* ── Panels ── */} {activeTab === 'edicts' && } + {activeTab === 'court' && } {activeTab === 'monitor' && } {activeTab === 'officials' && } {activeTab === 'models' && } diff --git a/edict/frontend/src/api.ts b/edict/frontend/src/api.ts index 7e6c776..69559dc 100644 --- a/edict/frontend/src/api.ts +++ b/edict/frontend/src/api.ts @@ -93,6 +93,18 @@ export const api = { createTask: (data: CreateTaskPayload) => postJ(`${API_BASE}/api/create-task`, data), + + // ── 朝堂议政 ── + courtDiscussStart: (topic: string, officials: string[], taskId?: string) => + postJ(`${API_BASE}/api/court-discuss/start`, { topic, officials, taskId }), + courtDiscussAdvance: (sessionId: string, userMessage?: string, decree?: string) => + postJ(`${API_BASE}/api/court-discuss/advance`, { sessionId, userMessage, decree }), + courtDiscussConclude: (sessionId: string) => + postJ(`${API_BASE}/api/court-discuss/conclude`, { sessionId }), + courtDiscussDestroy: (sessionId: string) => + postJ(`${API_BASE}/api/court-discuss/destroy`, { sessionId }), + courtDiscussFate: () => + fetchJ<{ ok: boolean; event: string }>(`${API_BASE}/api/court-discuss/fate`), }; // ── Types ── @@ -396,3 +408,22 @@ export interface RemoteSkillsListResult { listedAt?: string; error?: string; } + +// ── 朝堂议政 ── + +export interface CourtDiscussResult { + ok: boolean; + session_id?: string; + topic?: string; + round?: number; + new_messages?: Array<{ + official_id: string; + name: string; + content: string; + emotion?: string; + action?: string; + }>; + scene_note?: string; + total_messages?: number; + error?: string; +} diff --git a/edict/frontend/src/components/CourtDiscussion.tsx b/edict/frontend/src/components/CourtDiscussion.tsx new file mode 100644 index 0000000..9aea715 --- /dev/null +++ b/edict/frontend/src/components/CourtDiscussion.tsx @@ -0,0 +1,774 @@ +/** + * 朝堂议政 — 多官员实时讨论可视化组件 + * + * 灵感来自 nvwa 项目的故事剧场 + 协作工坊 + 虚拟生活 + * 功能: + * - 可视化朝堂布局,官员站位 + * - 实时群聊讨论,官员各抒己见 + * - 皇帝(用户)随时发言参与 + * - 天命降临(上帝视角)改变讨论走向 + * - 命运骰子:随机事件增加趣味性 + * - 自动推进 / 手动推进 + */ + +import { useState, useRef, useEffect, useCallback } from 'react'; +import { useStore, DEPTS } from '../store'; +import { api } from '../api'; + +// ── 常量 ── + +const OFFICIAL_COLORS: Record = { + taizi: '#e8a040', zhongshu: '#a07aff', menxia: '#6a9eff', shangshu: '#2ecc8a', + libu: '#f5c842', hubu: '#ff9a6a', bingbu: '#ff5270', xingbu: '#cc4444', + gongbu: '#44aaff', libu_hr: '#9b59b6', +}; + +const EMOTION_EMOJI: Record = { + neutral: '', confident: '😏', worried: '😟', angry: '😤', + thinking: '🤔', amused: '😄', happy: '😊', +}; + +const COURT_POSITIONS: Record = { + // 左列 + zhongshu: { x: 15, y: 25 }, menxia: { x: 15, y: 45 }, shangshu: { x: 15, y: 65 }, + // 右列 + libu: { x: 85, y: 20 }, hubu: { x: 85, y: 35 }, bingbu: { x: 85, y: 50 }, + xingbu: { x: 85, y: 65 }, gongbu: { x: 85, y: 80 }, + // 中间 + taizi: { x: 50, y: 20 }, libu_hr: { x: 50, y: 80 }, +}; + +interface CourtMessage { + type: string; + content: string; + official_id?: string; + official_name?: string; + emotion?: string; + action?: string; + timestamp?: number; +} + +interface CourtSession { + session_id: string; + topic: string; + officials: Array<{ + id: string; + name: string; + emoji: string; + role: string; + personality: string; + speaking_style: string; + }>; + messages: CourtMessage[]; + round: number; + phase: string; +} + +export default function CourtDiscussion() { + // Phase: setup | session + const [phase, setPhase] = useState<'setup' | 'session'>('setup'); + const [selectedIds, setSelectedIds] = useState>(new Set()); + const [topic, setTopic] = useState(''); + const [session, setSession] = useState(null); + const [loading, setLoading] = useState(false); + const [autoPlay, setAutoPlay] = useState(false); + const autoPlayRef = useRef(false); + + // 皇帝发言 + const [userInput, setUserInput] = useState(''); + // 天命降临 + const [showDecree, setShowDecree] = useState(false); + const [decreeInput, setDecreeInput] = useState(''); + const [decreeFlash, setDecreeFlash] = useState(false); + // 命运骰子 + const [diceRolling, setDiceRolling] = useState(false); + const [diceResult, setDiceResult] = useState(null); + // 活跃说话官员 + const [speakingId, setSpeakingId] = useState(null); + // 官员情绪 + const [emotions, setEmotions] = useState>({}); + + const messagesEndRef = useRef(null); + const toast = useStore((s) => s.toast); + const liveStatus = useStore((s) => s.liveStatus); + + // 自动滚到底部 + useEffect(() => { + messagesEndRef.current?.scrollIntoView({ behavior: 'smooth' }); + }, [session?.messages?.length]); + + // 自动推进 + useEffect(() => { + autoPlayRef.current = autoPlay; + }, [autoPlay]); + + useEffect(() => { + if (!autoPlay || !session || loading) return; + const timer = setInterval(() => { + if (autoPlayRef.current && !loading) { + handleAdvance(); + } + }, 5000); + return () => clearInterval(timer); + }, [autoPlay, session, loading]); + + // ── 切换官员选中 ── + const toggleOfficial = (id: string) => { + setSelectedIds((prev) => { + const next = new Set(prev); + if (next.has(id)) next.delete(id); + else if (next.size < 8) next.add(id); + return next; + }); + }; + + // ── 开始议政 ── + const handleStart = async () => { + if (!topic.trim() || selectedIds.size < 2 || loading) return; + setLoading(true); + try { + const res = await api.courtDiscussStart(topic, Array.from(selectedIds)); + if (!res.ok) throw new Error(res.error || '启动失败'); + setSession(res as unknown as CourtSession); + setPhase('session'); + } catch (e: unknown) { + toast((e as Error).message || '启动失败', 'err'); + } finally { + setLoading(false); + } + }; + + // ── 推进讨论 ── + const handleAdvance = useCallback(async (userMsg?: string, decree?: string) => { + if (!session || loading) return; + setLoading(true); + + try { + const res = await api.courtDiscussAdvance(session.session_id, userMsg, decree); + if (!res.ok) throw new Error(res.error || '推进失败'); + + // 更新 session messages(追加新消息) + setSession((prev) => { + if (!prev) return prev; + const newMsgs: CourtMessage[] = []; + + if (userMsg) { + newMsgs.push({ type: 'emperor', content: userMsg, timestamp: Date.now() / 1000 }); + } + if (decree) { + newMsgs.push({ type: 'decree', content: decree, timestamp: Date.now() / 1000 }); + } + + const aiMsgs = (res.new_messages || []).map((m: Record) => ({ + type: 'official', + official_id: m.official_id, + official_name: m.name, + content: m.content, + emotion: m.emotion, + action: m.action, + timestamp: Date.now() / 1000, + })); + + if (res.scene_note) { + newMsgs.push({ type: 'scene_note', content: res.scene_note, timestamp: Date.now() / 1000 }); + } + + return { + ...prev, + round: res.round ?? prev.round + 1, + messages: [...prev.messages, ...newMsgs, ...aiMsgs], + }; + }); + + // 动画:依次高亮说话的官员 + const aiMsgs = res.new_messages || []; + if (aiMsgs.length > 0) { + const emotionMap: Record = {}; + let idx = 0; + const cycle = () => { + if (idx < aiMsgs.length) { + setSpeakingId(aiMsgs[idx].official_id); + emotionMap[aiMsgs[idx].official_id] = aiMsgs[idx].emotion || 'neutral'; + idx++; + setTimeout(cycle, 1200); + } else { + setSpeakingId(null); + } + }; + cycle(); + setEmotions((prev) => ({ ...prev, ...emotionMap })); + } + } catch { + // silently + } finally { + setLoading(false); + } + }, [session, loading]); + + // ── 皇帝发言 ── + const handleEmperor = () => { + const msg = userInput.trim(); + if (!msg) return; + setUserInput(''); + handleAdvance(msg); + }; + + // ── 天命降临 ── + const handleDecree = () => { + const msg = decreeInput.trim(); + if (!msg) return; + setDecreeInput(''); + setShowDecree(false); + setDecreeFlash(true); + setTimeout(() => setDecreeFlash(false), 800); + handleAdvance(undefined, msg); + }; + + // ── 命运骰子 ── + const handleDice = async () => { + if (loading || diceRolling) return; + setDiceRolling(true); + setDiceResult(null); + + // 滚动动画 + let count = 0; + const timer = setInterval(async () => { + count++; + setDiceResult('🎲 命运轮转中...'); + if (count >= 6) { + clearInterval(timer); + try { + const res = await api.courtDiscussFate(); + const event = res.event || '边疆急报传来'; + setDiceResult(event); + setDiceRolling(false); + // 自动作为天命降临注入 + handleAdvance(undefined, `【命运骰子】${event}`); + } catch { + setDiceResult('命运之力暂时无法触及'); + setDiceRolling(false); + } + } + }, 200); + }; + + // ── 结束议政 ── + const handleConclude = async () => { + if (!session) return; + setLoading(true); + try { + const res = await api.courtDiscussConclude(session.session_id); + if (res.summary) { + setSession((prev) => + prev + ? { + ...prev, + phase: 'concluded', + messages: [ + ...prev.messages, + { type: 'system', content: `📋 朝堂议政结束 — ${res.summary}`, timestamp: Date.now() / 1000 }, + ], + } + : prev, + ); + } + setAutoPlay(false); + } catch { + toast('结束失败', 'err'); + } finally { + setLoading(false); + } + }; + + // ── 重置 ── + const handleReset = () => { + if (session) { + api.courtDiscussDestroy(session.session_id).catch(() => {}); + } + setPhase('setup'); + setSession(null); + setAutoPlay(false); + setEmotions({}); + setSpeakingId(null); + setDiceResult(null); + }; + + // ── 预设议题(从当前旨意中提取)── + const activeEdicts = (liveStatus?.tasks || []).filter( + (t) => /^JJC-/i.test(t.id) && !['Done', 'Cancelled'].includes(t.state), + ); + + const presetTopics = [ + ...activeEdicts.slice(0, 3).map((t) => ({ + text: `讨论旨意 ${t.id}:${t.title}`, + taskId: t.id, + icon: '📜', + })), + { text: '讨论系统架构优化方案', taskId: '', icon: '🏗️' }, + { text: '评估当前项目进展和风险', taskId: '', icon: '📊' }, + { text: '制定下周工作计划', taskId: '', icon: '📋' }, + { text: '紧急问题:线上Bug排查方案', taskId: '', icon: '🚨' }, + ]; + + // ═══════════════════ + // 渲染:设置页 + // ═══════════════════ + + if (phase === 'setup') { + return ( +
+ {/* Header */} +
+

+ 🏛 朝堂议政 +

+

+ 择臣上殿,围绕议题展开讨论 · 陛下可随时发言或降下天意改变走向 +

+
+ + {/* 选择官员 */} +
+
+ 👔 选择参朝官员 + ({selectedIds.size}/8,至少2位) +
+
+ {DEPTS.map((d) => { + const active = selectedIds.has(d.id); + const color = OFFICIAL_COLORS[d.id] || '#6a9eff'; + return ( + + ); + })} +
+
+ + {/* 议题 */} +
+
📜 设定议题
+ {presetTopics.length > 0 && ( +
+ {presetTopics.map((p, i) => ( + + ))} +
+ )} +