lantern-harness 0.1.15 → 0.1.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/README.md +1 -1
- package/dist/500.html +3 -3
- package/dist/_astro/Base.astro_astro_type_script_index_0_lang.CaBtSEmL.js +1 -0
- package/dist/_astro/{ChatApp.7piDha-y.js → ChatApp.BoTr-jsm.js} +1 -1
- package/dist/_astro/{DashboardBoard.BIP9es-t.js → DashboardBoard.BNuKH_zX.js} +1 -1
- package/dist/_astro/{PluginsPage.DMTsFl_R.js → PluginsPage.DtMHumy8.js} +1 -1
- package/dist/_astro/PluginsPage.ev2imTDc.js +1 -0
- package/dist/_astro/{PromptsLibrary.B_qFbQGi.js → PromptsLibrary.D6uvqZFz.js} +1 -1
- package/dist/_astro/{ReqAnalysisBoard.hwNqRyim.js → ReqAnalysisBoard.BVi6hHme.js} +1 -1
- package/dist/_astro/RequirementsLibrary.CgzwlAXi.js +1 -0
- package/dist/_astro/{SettingsDialog.CnBZRaWE.js → SettingsDialog.OaLXsUUu.js} +1 -1
- package/dist/_astro/{TasksBoard.DvfyDL76.js → TasksBoard.Bz_JL_uQ.js} +1 -1
- package/dist/_astro/{TodosBoard.7IptYUFY.js → TodosBoard.DV1VzVDe.js} +1 -1
- package/dist/_astro/app-version.zuhxTsqO.js +1 -0
- package/dist/_astro/{story-review.CGcusNKf.js → story-review.DT3vpEfU.js} +1 -1
- package/dist/_astro/{tasks.otRBFydq.js → tasks.BNBkrFC3.js} +1 -1
- package/dist/case-exec/index.html +3 -3
- package/dist/cases/generate/index.html +3 -3
- package/dist/cases/library/index.html +3 -3
- package/dist/dashboard/index.html +4 -4
- package/dist/docs/changelog/index.html +13 -4
- package/dist/docs/install/index.html +3 -3
- package/dist/docs/manual/index.html +10 -6
- package/dist/knowledge/index.html +3 -3
- package/dist/knowledge//345/212/237/350/203/275/346/265/213/350/257/225/347/224/250/344/276/213/347/274/226/345/206/231/350/247/204/350/214/203/index.html +3 -3
- package/dist/plugins/index.html +4 -4
- package/dist/pm/bugs/index.html +3 -3
- package/dist/pm/iterations/index.html +3 -3
- package/dist/pm/projects/detail/index.html +3 -3
- package/dist/pm/projects/index.html +3 -3
- package/dist/pm/requirements/index.html +3 -3
- package/dist/prompts/index.html +4 -4
- package/dist/reports/index.html +3 -3
- package/dist/requirement-analysis/index.html +4 -4
- package/dist/requirements/index.html +4 -4
- package/dist/tasks/index.html +4 -4
- package/dist/templates/index.html +3 -3
- package/dist/templates//345/212/237/350/203/275/346/265/213/350/257/225/346/212/245/345/221/212//345/212/237/350/203/275/346/265/213/350/257/225/346/212/245/345/221/212/346/250/241/346/235/277/index.html +3 -3
- package/dist/templates//346/200/247/350/203/275/346/265/213/350/257/225/346/212/245/345/221/212//346/200/247/350/203/275/346/265/213/350/257/225/346/212/245/345/221/212/346/250/241/346/235/277/index.html +3 -3
- package/dist/templates//346/200/247/350/203/275/346/265/213/350/257/225/347/224/250/344/276/213//346/200/247/350/203/275/346/265/213/350/257/225/347/224/250/344/276/213/346/250/241/346/235/277/index.html +3 -3
- package/dist/templates//346/216/245/345/217/243/346/265/213/350/257/225/346/212/245/345/221/212//346/216/245/345/217/243/346/265/213/350/257/225/346/212/245/345/221/212/346/250/241/346/235/277/index.html +3 -3
- package/dist/templates//350/207/252/345/212/250/345/214/226/346/265/213/350/257/225/347/224/250/344/276/213//350/207/252/345/212/250/345/214/226/346/265/213/350/257/225/347/224/250/344/276/213/346/250/241/346/235/277/index.html +3 -3
- package/dist/test-automation/index.html +3 -3
- package/dist/test-stats/index.html +3 -3
- package/dist/todos/index.html +4 -4
- package/dist/workbench/index.html +4 -4
- package/docs//346/223/215/344/275/234/346/211/213/345/206/214.md +12 -9
- package/lh-plugins/lh-project-docs.mjs +4 -1
- package/package.json +1 -1
- package/dist/_astro/Base.astro_astro_type_script_index_0_lang.CpzwEBjx.js +0 -1
- package/dist/_astro/PluginsPage.DMxVKmiY.js +0 -1
- package/dist/_astro/RequirementsLibrary.CGCNnQQG.js +0 -1
- package/dist/_astro/app-version.YyNOCGCb.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as e,t}from"./react.Blvh0GOs.js";import{a as n,i as r,n as i,r as ee,s as a}from"./app-config.CF1xVPmo.js";import{i as te,n as o,r as ne,t as s}from"./listbox.DNxAJmEo.js";import{a as re,o as ie}from"./dialog.DZHZCe_T.js";import{t as c}from"./jsx-runtime.DUg_B_vD.js";import{t as ae}from"./ConfirmDialog.CsMwWevK.js";import{showToast as oe}from"./Toast.BO2NFckG.js";import{i as se}from"./llm.BZEzE0x2.js";import{_ as ce,a as l,c as u,d as le,g as ue,h as de,i as fe,l as d,n as f,o as pe,r as me,s as he,t as ge,u as _e,v as ve}from"./settings.BvxRxdqa.js";import{n as p}from"./i18n.B3BVhlok.js";import{s as m}from"./fs-tools.3F9MFrLf.js";import{_ as h,c as g,l as ye}from"./bash-tools.CPS0ZiKi.js";import{t as be}from"./app-version.YyNOCGCb.js";import{n as xe,t as Se}from"./update.DXCPfU4a.js";var _=e(t(),1);function v(e){return e===`time-context`||e===`tool-todo`||e===`tool-ask-user`||e===`user-questions`||e===`plan-mode`||e===`tool-result-pruner`||e===`compaction-basic`||e===`command-compact`||e===`tool-goal`||e===`command-goal`||e===`goal`||e===`tool-schedule`||e===`schedule`||e===`goal-round-driver`||e===`session-log-download`||e===`llm-retry`||e===`session-title-llm`||e===`session-stats`||e===`locale`||e===`config-editor`||e===`subagent`||e===`subagent-fork-in-process`||e===`spill-local`||e===`spill-policy`||e===`session-turn-outline`||e===`image-offload`||e===`session-persistence-jsonl`||e===`session-checkpoint-policy`||e===`session-query-sqlite`||e===`session-projection-cache`||e===`storage-domain`||e===`workspace-changes`||e===`workspace-dependencies`||e===`skill-office`||e===`fs-observation-policy`||e===`deepseek-llm-api-extensions`||e===`session-log-deepseek`||e===`subagent-model-selection-settings`||e===`authorization`||e===`modules`||e===`resources`||e===`mcp-resources`||e===`ptc-runtime`||e===`headless-runner`||e===`headless-startup`||e===`sdk-jsonrpc-server`||e===`sdk-app-startup`||e===`acp`||e===`acp-app-startup`||e===`subagent-spawn-in-process`||e===`llm-pi-ai`||e===`session-reference`||e===`tool-subagent`||e===`tool-subagent-control`||e===`tool-subagent-list-agents`||e===`tool-subagent-fork`||e===`tool-workflow`||e===`workflow-ptc`||e===`session-title`||e===`attachment-local`||e===`file-upload`||e===`file-reference-local`||e===`credentials`||e===`connection`||e===`token-meter`||e===`llm`||e===`llm-deepseek`||e===`agent-default-model`||e===`session`||e===`sessions`||e===`session-projection`||e===`storage`||e===`storage-json`||e===`settings`||e===`commands`||e===`shortcuts`||e===`timeout-policy`||e===`shell-env`||e===`approval`||e===`agent`||e===`system-prompt`||e===`tools`||e===`repeat-tool-reminder`?`ready`:e===`tool-web`||e===`web`||e===`web-fetch-http`||e===`web-search-deepseek`?`web`:e===`tool-bash`||e===`tool-jobs`||e===`jobs`||e===`sandbox-policy`||e===`bash-sandbox`||e===`sandbox`||e===`pty`||e===`terminal-bash`||e===`persistent-bash`||e===`subprocess`?`bash`:e===`tool-pwsh`||e===`persistent-pwsh`||e===`terminal-pwsh`||e===`pwsh-sandbox`?`pwsh`:e===`tool-fs`||e===`tool-fs-search`||e===`tool-skill`||e===`skill`||e===`agent-instructions`||e===`present`||e===`office-to-pdf`||e===`filesystem`||e===`fs-sandbox`||e===`permission`||e===`working-directory`||e===`tool-working-directory`||e===`workspace`?`fs`:`none`}var y=[{id:`agent-instructions`,packageName:`@deepseek-ai/dsh-agent-instructions`,roleZh:`加载 AGENTS.md/CLAUDE.md。`,category:`会话能力`},{id:`time-context`,packageName:`@deepseek-ai/dsh-time-context`,roleZh:`注入当前时间与耗时。`,category:`会话能力`},{id:`tool-bash`,packageName:`@deepseek-ai/dsh-tool-bash`,roleZh:`模型可调用 bash 在本机执行命令(可后台、可沙箱升级)。`,category:`会话能力`},{id:`tool-pwsh`,packageName:`@deepseek-ai/dsh-tool-pwsh`,roleZh:`模型可调用 PowerShell(主要面向 Windows)。`,category:`会话能力`},{id:`tool-fs`,packageName:`@deepseek-ai/dsh-tool-fs`,roleZh:`模型可读/写/编辑工作区文件。`,category:`会话能力`},{id:`tool-working-directory`,packageName:`@deepseek-ai/dsh-tool-working-directory`,roleZh:`模型可查看/切换会话工作目录。`,category:`会话能力`},{id:`tool-fs-search`,packageName:`@deepseek-ai/dsh-tool-fs-search`,roleZh:`模型可用 glob / grep 搜索工作区文件(内置 ripgrep)。`,category:`会话能力`},{id:`tool-skill`,packageName:`@deepseek-ai/dsh-tool-skill`,roleZh:`模型可按需加载工作区 SKILL.md。`,category:`会话能力`},{id:`tool-jobs`,packageName:`@deepseek-ai/dsh-tool-jobs`,roleZh:`模型可查看/读取输出/终止后台任务(job_list/output/kill)。`,category:`会话能力`},{id:`tool-schedule`,packageName:`@deepseek-ai/dsh-tool-schedule`,roleZh:`模型可创建/查询/更新/删除定时提醒,到点投递回原会话。`,category:`会话能力`},{id:`command-goal`,packageName:`@deepseek-ai/dsh-command-goal`,roleZh:`人类管理会话目标的 slash 命令。`,category:`会话能力`},{id:`tool-goal`,packageName:`@deepseek-ai/dsh-tool-goal`,roleZh:`模型可读写本会话目标,并在执行时做权限校验。`,category:`会话能力`},{id:`plan-mode`,packageName:`@deepseek-ai/dsh-plan-mode`,roleZh:`计划模式(探查→方案→批准→实施)。`,category:`planning`},{id:`compaction-basic`,packageName:`@deepseek-ai/dsh-compaction-basic`,roleZh:`上下文 token 过高时自动摘要压缩,腾出窗口。`,category:`compaction`},{id:`command-compact`,packageName:`@deepseek-ai/dsh-command-compact`,roleZh:`人类手动压缩会话的 slash 命令。`,category:`compaction`},{id:`tool-result-pruner`,packageName:`@deepseek-ai/dsh-compaction-tool-result-pruner`,roleZh:`裁剪过长的工具返回(头/中/尾保留),省 token。`,category:`compaction`},{id:`tool-subagent-control`,packageName:`@deepseek-ai/dsh-tool-subagent-control`,roleZh:`模型可给子代理发消息、中断、列出正在跑的子代理。`,category:`delegation`},{id:`tool-subagent-list-agents`,packageName:`@deepseek-ai/dsh-tool-subagent-control/list-agents`,roleZh:`单独暴露 list_agents,列出可用/运行中的子代理。`,category:`delegation`},{id:`tool-subagent`,packageName:`@deepseek-ai/dsh-tool-subagent`,roleZh:`模型可派生子代理去执行子任务(spawn)。`,category:`delegation`},{id:`tool-subagent-fork`,packageName:`@deepseek-ai/dsh-tool-subagent`,roleZh:`模型可 fork 当前上下文开子代理并行干活。`,category:`delegation`},{id:`workflow-ptc`,packageName:`@deepseek-ai/dsh-workflow-ptc`,roleZh:`在沙箱 Node 运行时里跑工作流编排脚本。`,category:`delegation`},{id:`tool-workflow`,packageName:`@deepseek-ai/dsh-tool-workflow`,roleZh:`模型可调用 workflow:跑一段编排脚本来协调多步。`,category:`delegation`},{id:`tool-ask-user`,packageName:`@deepseek-ai/dsh-tool-ask-user`,roleZh:`模型可向用户提出结构化问题并等待回答。`,category:`会话能力`},{id:`tool-todo`,packageName:`@deepseek-ai/dsh-tool-todo`,roleZh:`模型可维护本会话待办清单(todo_write)。`,category:`会话能力`},{id:`tool-web`,packageName:`@deepseek-ai/dsh-tool-web`,roleZh:`模型可网页搜索(web_search)与抓取页面(web_fetch)。`,category:`会话能力`},{id:`present`,packageName:`@deepseek-ai/dsh-tool-present`,roleZh:`模型可声明「交付了哪些工作区文件」,便于 UI 展示/打开。`,category:`会话能力`}],b=[{id:`attachment-local`,packageName:`@deepseek-ai/dsh-attachment-local`,roleZh:`本机附件存储与读取。`,category:`会话 / 存储`},{id:`session`,packageName:`@deepseek-ai/dsh-session`,roleZh:`事件溯源的会话存储(会话真相源)。`,category:`会话 / 存储`},{id:`session-checkpoint-policy`,packageName:`@deepseek-ai/dsh-session-checkpoint-policy`,roleZh:`会话检查点策略。`,category:`会话 / 存储`},{id:`session-log-deepseek`,packageName:`@deepseek-ai/dsh-session-log-deepseek`,roleZh:`DeepSeek 侧增量无损会话日志请求扩展。`,category:`会话 / 存储`},{id:`session-log-download`,packageName:`@deepseek-ai/dsh-session-log-export`,roleZh:`导出会话日志。`,category:`会话 / 存储`},{id:`session-persistence-jsonl`,packageName:`@deepseek-ai/dsh-session-persistence-jsonl`,roleZh:`会话以 JSONL 持久化。`,category:`会话 / 存储`},{id:`session-projection`,packageName:`@deepseek-ai/dsh-session-projection`,roleZh:`会话投影视图(给 UI/查询用)。`,category:`会话 / 存储`},{id:`session-projection-cache`,packageName:`@deepseek-ai/dsh-session-projection-cache`,roleZh:`会话投影缓存。`,category:`会话 / 存储`},{id:`session-query-sqlite`,packageName:`@deepseek-ai/dsh-session-query-sqlite`,roleZh:`会话全文/结构化查询(sqlite)。`,category:`会话 / 存储`},{id:`session-reference`,packageName:`@deepseek-ai/dsh-session-reference`,roleZh:`会话内引用(消息/文件等)。`,category:`会话 / 存储`},{id:`session-stats`,packageName:`@deepseek-ai/dsh-session-stats`,roleZh:`会话统计信息。`,category:`会话 / 存储`},{id:`session-title`,packageName:`@deepseek-ai/dsh-session-title`,roleZh:`会话标题能力。`,category:`会话 / 存储`},{id:`session-turn-outline`,packageName:`@deepseek-ai/dsh-session-turn-outline`,roleZh:`对话回合摘要。`,category:`会话 / 存储`},{id:`sessions`,packageName:`@deepseek-ai/dsh-session-persistence-jsonl`,roleZh:`会话 JSONL 持久化后端(与 session-persistence 同类)。`,category:`会话 / 存储`},{id:`storage`,packageName:`@deepseek-ai/dsh-storage`,roleZh:`通用存储服务。`,category:`会话 / 存储`},{id:`storage-domain`,packageName:`@deepseek-ai/dsh-storage-domain`,roleZh:`按域划分的存储。`,category:`会话 / 存储`},{id:`storage-json`,packageName:`@deepseek-ai/dsh-storage-json`,roleZh:`JSON 文件存储后端。`,category:`会话 / 存储`},{id:`command-compact`,packageName:`@deepseek-ai/dsh-command-compact`,roleZh:`人类手动压缩会话的 slash 命令。`,category:`模型面工具/命令`},{id:`command-goal`,packageName:`@deepseek-ai/dsh-command-goal`,roleZh:`人类管理会话目标的 slash 命令。`,category:`模型面工具/命令`},{id:`skill-office`,packageName:`@deepseek-ai/dsh-skill-office`,roleZh:`Office(Word/PPT/Excel)相关工作流 Skill。`,category:`模型面工具/命令`},{id:`tool-bash`,packageName:`@deepseek-ai/dsh-tool-bash`,roleZh:`模型可调用 bash 在本机执行命令(可后台、可沙箱升级)。`,category:`模型面工具/命令`},{id:`tool-fs`,packageName:`@deepseek-ai/dsh-tool-fs`,roleZh:`模型可读/写/编辑工作区文件。`,category:`模型面工具/命令`},{id:`tool-fs-search`,packageName:`@deepseek-ai/dsh-tool-fs-search`,roleZh:`模型可用 glob / grep 搜索工作区文件(内置 ripgrep)。`,category:`模型面工具/命令`},{id:`tool-goal`,packageName:`@deepseek-ai/dsh-tool-goal`,roleZh:`模型可读写本会话目标,并在执行时做权限校验。`,category:`模型面工具/命令`},{id:`tool-jobs`,packageName:`@deepseek-ai/dsh-tool-jobs`,roleZh:`模型可查看/读取输出/终止后台任务(job_list/output/kill)。`,category:`模型面工具/命令`},{id:`tool-pwsh`,packageName:`@deepseek-ai/dsh-tool-pwsh`,roleZh:`模型可调用 PowerShell(主要面向 Windows)。`,category:`模型面工具/命令`},{id:`tool-result-pruner`,packageName:`@deepseek-ai/dsh-compaction-tool-result-pruner`,roleZh:`裁剪过长的工具返回(头/中/尾保留),省 token。`,category:`模型面工具/命令`},{id:`tool-skill`,packageName:`@deepseek-ai/dsh-tool-skill`,roleZh:`模型可按需加载某个 Skill,把技能说明拉进上下文。`,category:`模型面工具/命令`},{id:`tool-subagent`,packageName:`@deepseek-ai/dsh-tool-subagent`,roleZh:`模型可派生子代理去执行子任务(spawn)。`,category:`模型面工具/命令`},{id:`tool-subagent-control`,packageName:`@deepseek-ai/dsh-tool-subagent-control`,roleZh:`模型可给子代理发消息、中断、列出正在跑的子代理。`,category:`模型面工具/命令`},{id:`tool-subagent-fork`,packageName:`@deepseek-ai/dsh-tool-subagent`,roleZh:`模型可 fork 当前上下文开子代理并行干活。`,category:`模型面工具/命令`},{id:`tool-subagent-list-agents`,packageName:`@deepseek-ai/dsh-tool-subagent-control/list-agents`,roleZh:`单独暴露 list_agents,列出可用/运行中的子代理。`,category:`模型面工具/命令`},{id:`tool-todo`,packageName:`@deepseek-ai/dsh-tool-todo`,roleZh:`模型可维护本会话待办清单(todo_write)。`,category:`模型面工具/命令`},{id:`tool-web`,packageName:`@deepseek-ai/dsh-tool-web`,roleZh:`模型可网页搜索(web_search)与抓取页面(web_fetch)。`,category:`模型面工具/命令`},{id:`tool-workflow`,packageName:`@deepseek-ai/dsh-tool-workflow`,roleZh:`模型可调用 workflow:跑一段编排脚本来协调多步。`,category:`模型面工具/命令`},{id:`tool-working-directory`,packageName:`@deepseek-ai/dsh-tool-working-directory`,roleZh:`模型可查看/切换会话工作目录。`,category:`模型面工具/命令`},{id:`acp`,packageName:`@deepseek-ai/dsh-acp`,roleZh:`通过 JSON-RPC stdio 驱动 Harness Agent 的自动化协议服务(给外部编排用)。`,category:`其它`},{id:`acp-app-startup`,packageName:`@deepseek-ai/dsh-acp-app`,roleZh:`ACP 配置包启动:在 base 之上挂 JSON-RPC stdio 与进程生命周期。`,category:`其它`},{id:`authorization`,packageName:`@deepseek-ai/dsh-authorization`,roleZh:`授权/鉴权服务。`,category:`其它`},{id:`commands`,packageName:`@deepseek-ai/dsh-commands`,roleZh:`人类 slash 命令注册底座。`,category:`其它`},{id:`config-editor`,packageName:`@deepseek-ai/dsh-config-editor`,roleZh:`配置编辑能力。`,category:`其它`},{id:`connection`,packageName:`@deepseek-ai/dsh-client-connection`,roleZh:`客户端与 Host 连接。`,category:`其它`},{id:`credentials`,packageName:`@deepseek-ai/dsh-credentials-local`,roleZh:`本机凭证存储。`,category:`其它`},{id:`file-reference-local`,packageName:`@deepseek-ai/dsh-file-reference-local`,roleZh:`本机文件引用解析。`,category:`其它`},{id:`file-upload`,packageName:`@deepseek-ai/dsh-client-file-upload`,roleZh:`客户端上传文件。`,category:`其它`},{id:`filesystem`,packageName:`@deepseek-ai/dsh-fs-local`,roleZh:`本机文件系统实现(ctx.fs),供 tool-fs 等读写。`,category:`其它`},{id:`fs-observation-policy`,packageName:`@deepseek-ai/dsh-fs-observation-policy`,roleZh:`文件系统观察/上报策略。`,category:`其它`},{id:`headless-runner`,packageName:`@deepseek-ai/dsh-headless`,roleZh:`无 Host/HTTP/浏览器的一键 Agent/Session 运行器(纯 headless)。`,category:`其它`},{id:`headless-startup`,packageName:`@deepseek-ai/dsh-headless/startup`,roleZh:`Headless 配置包的启动插件。`,category:`其它`},{id:`image-offload`,packageName:`@deepseek-ai/dsh-compaction-image-offload`,roleZh:`超预算图片卸载为占位符并重试。`,category:`其它`},{id:`locale`,packageName:`@deepseek-ai/dsh-client-locale`,roleZh:`界面语言。`,category:`其它`},{id:`mcp-resources`,packageName:`@deepseek-ai/dsh-mcp-resources`,roleZh:`MCP 资源对接。`,category:`其它`},{id:`modules`,packageName:`@deepseek-ai/dsh-client-modules`,roleZh:`客户端模块加载。`,category:`其它`},{id:`office-to-pdf`,packageName:`@deepseek-ai/dsh-office-to-pdf`,roleZh:`Office 转 PDF。`,category:`其它`},{id:`pty`,packageName:`@deepseek-ai/dsh-terminal`,roleZh:`持久 PTY 会话能力缝:会话 id、后端注册、交互读写与信号。`,category:`其它`},{id:`repeat-tool-reminder`,packageName:`@deepseek-ai/dsh-repeat-tool-reminder`,roleZh:`重复工具调用时提醒模型。`,category:`其它`},{id:`resources`,packageName:`@deepseek-ai/dsh-client-resources`,roleZh:`客户端资源。`,category:`其它`},{id:`sdk-app-startup`,packageName:`@deepseek-ai/dsh-sdk-app`,roleZh:`SDK 配置包启动:stdio JSON-RPC 服务与进程生命周期。`,category:`其它`},{id:`sdk-jsonrpc-server`,packageName:`@deepseek-ai/dsh-sdk-jsonrpc-server`,roleZh:`给进程外 SDK 客户端用的 stdio JSON-RPC 服务端。`,category:`其它`},{id:`settings`,packageName:`@deepseek-ai/dsh-settings`,roleZh:`设置读写与校验。`,category:`其它`},{id:`shell-env`,packageName:`@deepseek-ai/dsh-shell-env`,roleZh:`注入/管理 shell 环境变量。`,category:`其它`},{id:`shortcuts`,packageName:`@deepseek-ai/dsh-client-shortcuts`,roleZh:`快捷键注册。`,category:`其它`},{id:`timeout-policy`,packageName:`@deepseek-ai/dsh-tool-call-timeout-policy`,roleZh:`单次工具调用超时策略。`,category:`其它`},{id:`user-questions`,packageName:`@deepseek-ai/dsh-user-questions`,roleZh:`用户提问通道(供 ask_user 等使用)。`,category:`其它`},{id:`working-directory`,packageName:`@deepseek-ai/dsh-working-directory`,roleZh:`会话工作目录状态。`,category:`其它`},{id:`workspace`,packageName:`@deepseek-ai/dsh-workspace`,roleZh:`工作区抽象(根目录、切换等)。`,category:`其它`},{id:`workspace-changes`,packageName:`@deepseek-ai/dsh-workspace-changes`,roleZh:`工作区变更追踪。`,category:`其它`},{id:`workspace-dependencies`,packageName:`@deepseek-ai/dsh-tool-workspace-dependencies`,roleZh:`向模型提供捆绑的 Python/Node/pnpm 依赖绝对路径(load_workspace_dependencies)。`,category:`其它`},{id:`compaction-basic`,packageName:`@deepseek-ai/dsh-compaction-basic`,roleZh:`上下文 token 过高时自动摘要压缩,腾出窗口。`,category:`上下文压缩`},{id:`spill-local`,packageName:`@deepseek-ai/dsh-spill-local`,roleZh:`过大内容溢出到本机文件。`,category:`上下文压缩`},{id:`spill-policy`,packageName:`@deepseek-ai/dsh-spill-policy`,roleZh:`何时溢出、溢出策略。`,category:`上下文压缩`},{id:`token-meter`,packageName:`@deepseek-ai/dsh-token-meter`,roleZh:`统计上下文 token 用量。`,category:`上下文压缩`},{id:`web`,packageName:`@deepseek-ai/dsh-web`,roleZh:`网页能力缝(ctx.web):注册 search/fetch provider。`,category:`网页能力`},{id:`web-fetch-http`,packageName:`@deepseek-ai/dsh-web-fetch-http`,roleZh:`通用 HTTP 抓取网页正文 provider。`,category:`网页能力`},{id:`goal`,packageName:`@deepseek-ai/dsh-goal`,roleZh:`本会话目标状态机服务。`,category:`预设 / 能力服务`},{id:`goal-round-driver`,packageName:`@deepseek-ai/dsh-goal-round-driver`,roleZh:`按目标驱动多轮执行。`,category:`预设 / 能力服务`},{id:`plan-mode`,packageName:`@deepseek-ai/dsh-plan-mode`,roleZh:`计划模式(探查→方案→批准→实施)。`,category:`预设 / 能力服务`},{id:`schedule`,packageName:`@deepseek-ai/dsh-schedule`,roleZh:`主机级持久提醒,到点投递原会话。`,category:`预设 / 能力服务`},{id:`skill`,packageName:`@deepseek-ai/dsh-skill`,roleZh:`Skill 能力注册底座。`,category:`预设 / 能力服务`},{id:`approval`,packageName:`@deepseek-ai/dsh-user-approval`,roleZh:`敏感操作需用户批准。`,category:`执行 / 权限`},{id:`bash-sandbox`,packageName:`@deepseek-ai/dsh-bash-sandbox`,roleZh:`bash 专用沙箱绑定。`,category:`执行 / 权限`},{id:`fs-sandbox`,packageName:`@deepseek-ai/dsh-fs-sandbox`,roleZh:`文件系统沙箱。`,category:`执行 / 权限`},{id:`jobs`,packageName:`@deepseek-ai/dsh-jobs-local`,roleZh:`后台任务注册表(id、归属、轮询、取消)。`,category:`执行 / 权限`},{id:`permission`,packageName:`@deepseek-ai/dsh-permission-presets`,roleZh:`权限预设(只读/读写等档位)。`,category:`执行 / 权限`},{id:`persistent-bash`,packageName:`@deepseek-ai/dsh-tool-bash-persistent`,roleZh:`带 PTY 的持久 Bash 工具(跨调用保持 shell 状态)。`,category:`执行 / 权限`},{id:`persistent-pwsh`,packageName:`@deepseek-ai/dsh-tool-pwsh-persistent`,roleZh:`带 PTY 的持久 PowerShell 工具。`,category:`执行 / 权限`},{id:`pwsh-sandbox`,packageName:`@deepseek-ai/dsh-pwsh-sandbox`,roleZh:`pwsh 专用沙箱绑定。`,category:`执行 / 权限`},{id:`sandbox`,packageName:`@deepseek-ai/dsh-sandbox-local`,roleZh:`本机沙箱执行环境。`,category:`执行 / 权限`},{id:`sandbox-policy`,packageName:`@deepseek-ai/dsh-sandbox-policy`,roleZh:`沙箱策略(能跑什么、不能跑什么)。`,category:`执行 / 权限`},{id:`subprocess`,packageName:`@deepseek-ai/dsh-subprocess-local`,roleZh:`本机子进程执行器。`,category:`执行 / 权限`},{id:`terminal-bash`,packageName:`@deepseek-ai/dsh-terminal-bash`,roleZh:`基于子进程终端原语的持久 bash PTY 后端。`,category:`执行 / 权限`},{id:`terminal-pwsh`,packageName:`@deepseek-ai/dsh-terminal-bash`,roleZh:`基于子进程终端原语的持久 pwsh PTY 后端。`,category:`执行 / 权限`},{id:`ptc-runtime`,packageName:`@deepseek-ai/dsh-ptc-runtime-node`,roleZh:`PTC(工具调用呈现)Node 运行时。`,category:`子代理 / 工作流`},{id:`subagent`,packageName:`@deepseek-ai/dsh-subagent`,roleZh:`子代理能力底座。`,category:`子代理 / 工作流`},{id:`workflow-ptc`,packageName:`@deepseek-ai/dsh-workflow-ptc`,roleZh:`在沙箱 Node 运行时里跑工作流编排脚本。`,category:`子代理 / 工作流`},{id:`agent`,packageName:`@deepseek-ai/dsh-agent`,roleZh:`Agent 主体:把会话、工具、模型串起来。`,category:`LLM / Agent 核心`},{id:`agent-default-model`,packageName:`@deepseek-ai/dsh-agent-default-model`,roleZh:`解析/提供默认模型配置。`,category:`LLM / Agent 核心`},{id:`agent-instructions`,packageName:`@deepseek-ai/dsh-agent-instructions`,roleZh:`加载 AGENTS.md/CLAUDE.md。`,category:`LLM / Agent 核心`},{id:`deepseek-llm-api-extensions`,packageName:`@deepseek-ai/dsh-deepseek-llm-api-extensions`,roleZh:`给官方 DeepSeek API 适配器登记额外请求字段。`,category:`LLM / Agent 核心`},{id:`llm`,packageName:`@deepseek-ai/dsh-llm`,roleZh:`厂商无关的 LLM 服务接口(发请求、流式、工具调用等)。`,category:`LLM / Agent 核心`},{id:`llm-deepseek`,packageName:`@deepseek-ai/dsh-llm-deepseek-api-key`,roleZh:`DeepSeek API Key 模型适配。`,category:`LLM / Agent 核心`},{id:`llm-pi-ai`,packageName:`@deepseek-ai/dsh-llm-pi-ai`,roleZh:`Pi AI 等 LLM 适配。`,category:`LLM / Agent 核心`},{id:`llm-retry`,packageName:`@deepseek-ai/dsh-llm-retry`,roleZh:`LLM 调用失败重试策略。`,category:`LLM / Agent 核心`},{id:`session-title-llm`,packageName:`@deepseek-ai/dsh-session-title-first-prompt-llm`,roleZh:`用首条用户消息经 LLM 自动起会话标题。`,category:`LLM / Agent 核心`},{id:`subagent-fork-in-process`,packageName:`@deepseek-ai/dsh-subagent-fork-in-process`,roleZh:`进程内 fork 子代理实现。`,category:`LLM / Agent 核心`},{id:`subagent-model-selection-settings`,packageName:`@deepseek-ai/dsh-tool-subagent/model-selection-settings`,roleZh:`子代理可选模型的设置项。`,category:`LLM / Agent 核心`},{id:`subagent-spawn-in-process`,packageName:`@deepseek-ai/dsh-subagent-spawn-in-process`,roleZh:`进程内 spawn 子代理实现。`,category:`LLM / Agent 核心`},{id:`system-prompt`,packageName:`@deepseek-ai/dsh-system-prompt`,roleZh:`系统提示词拼装服务。`,category:`LLM / Agent 核心`},{id:`tools`,packageName:`@deepseek-ai/dsh-tools`,roleZh:`工具注册与执行总闸。`,category:`LLM / Agent 核心`}],x=c();function S(e){return String(e??``).replace(/(\s*dsh[^)]*)/gi,``).replace(/\(\s*dsh[^)]*\)/gi,``).replace(/\bdsh\b/gi,``).replace(/\s{2,}/g,` `).replace(/(\s*)/g,``).trim()}function C({status:e}){let t=e.tone===`ready`?`bg-emerald-50 text-emerald-700 border-emerald-100`:e.tone===`warn`?`bg-amber-50 text-amber-800 border-amber-100`:`bg-stone-100 text-stone-500 border-stone-200`;return(0,x.jsx)(`span`,{className:`shrink-0 rounded border px-1.5 py-0.5 text-[11px] ${t}`,children:e.label})}function Ce({tone:e}){return(0,x.jsx)(`span`,{"aria-hidden":`true`,className:`h-1.5 w-1.5 shrink-0 rounded-full ${e===`ready`?`bg-emerald-500`:e===`warn`?`bg-amber-500`:`bg-stone-300`}`})}function w({open:e}){return(0,x.jsx)(`svg`,{"aria-hidden":`true`,className:`h-3.5 w-3.5 shrink-0 text-stone-400 transition-transform duration-150 ${e?`rotate-90`:``}`,viewBox:`0 0 20 20`,fill:`currentColor`,children:(0,x.jsx)(`path`,{fillRule:`evenodd`,d:`M7.21 14.77a.75.75 0 01.02-1.06L11.17 10 7.23 6.29a.75.75 0 111.04-1.08l4.5 4.25a.75.75 0 010 1.08l-4.5 4.25a.75.75 0 01-1.06-.02z`,clipRule:`evenodd`})})}function we(){let[e,t]=(0,_.useState)(null),[n,r]=(0,_.useState)(null),[i,ee]=(0,_.useState)(null),[a,te]=(0,_.useState)(null),[o,ne]=(0,_.useState)(!0),[s,re]=(0,_.useState)(``),[ie,c]=(0,_.useState)({}),[ae,oe]=(0,_.useState)({});function se(e){c(t=>({...t,[e]:!t[e]}))}function ce(e){oe(t=>({...t,[e]:!t[e]}))}(0,_.useEffect)(()=>{let e=!0;return(async()=>{try{let[n,i,a,o]=await Promise.all([h(),m(),g(),ye()]);if(!e)return;t(n),r(i),ee(a),te(o)}finally{e&&ne(!1)}})(),()=>{e=!1}},[]);function l(t){let r=v(t.id);return r===`none`?{label:`规划中`,tone:`plan`}:r===`ready`?{label:`已就绪`,tone:`ready`}:o?{label:`探测中…`,tone:`plan`}:r===`web`?e?.ok?{label:`已就绪`,tone:`ready`}:{label:`需本地服务`,tone:`warn`}:r===`fs`?n?.ok?{label:`已就绪`,tone:`ready`}:{label:`需本地服务`,tone:`warn`}:r===`bash`?i?.ok?{label:`已就绪`,tone:`ready`}:{label:`需本地服务`,tone:`warn`}:r===`pwsh`?a?.ok&&a.available?{label:`已就绪`,tone:`ready`}:a?.ok?{label:`未装 PowerShell`,tone:`warn`}:{label:`需本地服务`,tone:`warn`}:{label:`规划中`,tone:`plan`}}let u=s.trim().toLowerCase(),le=e=>!u||e.id.toLowerCase().includes(u)||S(e.roleZh).toLowerCase().includes(u),ue=y.filter(le),de=b.filter(le),fe=[{id:`session`,title:`会话插件`,hint:`每个会话各自加载,随会话结束释放`,items:ue,total:y.length},{id:`global`,title:`全局插件`,hint:`由系统与所有会话共享,常驻运行`,items:de,total:b.length}];return(0,x.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,x.jsx)(`div`,{className:`shrink-0 px-6 pt-5 pb-3`,children:(0,x.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,x.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,x.jsx)(`h3`,{className:`text-[15px] font-semibold text-stone-900`,children:`内置插件`}),(0,x.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-stone-500`,children:`由平台按会话或全局提供,默认常开,不需要开关;状态取决于本机服务是否就绪。`})]}),(0,x.jsxs)(`label`,{className:`relative block w-44 shrink-0`,children:[(0,x.jsxs)(`svg`,{"aria-hidden":`true`,className:`pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-stone-400`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,children:[(0,x.jsx)(`circle`,{cx:`11`,cy:`11`,r:`7`}),(0,x.jsx)(`path`,{d:`m20 20-3.5-3.5`})]}),(0,x.jsx)(`input`,{value:s,onChange:e=>re(e.target.value),placeholder:`搜索插件名 / 作用`,className:`h-8 w-full rounded-lg border border-stone-200 bg-white pl-8 pr-2.5 text-xs text-stone-800 outline-none transition-colors placeholder:text-stone-400 focus:border-[#4176e6]`})]})]})}),(0,x.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 pb-6`,children:(0,x.jsx)(`div`,{className:`space-y-3`,children:fe.map(e=>{let t=!ie[e.id];return(0,x.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,x.jsxs)(`button`,{type:`button`,onClick:()=>se(e.id),"aria-expanded":t,className:`flex w-full items-center gap-2 px-3.5 py-2.5 text-left transition-colors hover:bg-stone-50/70`,children:[(0,x.jsx)(w,{open:t}),(0,x.jsx)(`h4`,{className:`text-[13px] font-medium text-stone-700`,children:e.title}),(0,x.jsx)(`span`,{className:`text-[11px] tabular-nums text-stone-400`,children:u?`${e.items.length}/${e.total}`:e.total}),(0,x.jsx)(`span`,{className:`ml-auto truncate text-[11px] text-stone-400`,children:e.hint})]}),t?e.items.length?(0,x.jsx)(`div`,{className:`grid grid-cols-2 items-start gap-2 border-t border-stone-100 p-2.5`,children:e.items.map(t=>{let n=l(t),r=`${e.id}:${t.id}`,i=!!ae[r];return(0,x.jsxs)(`div`,{role:`button`,tabIndex:0,"aria-expanded":i,onClick:()=>ce(r),onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),ce(r))},className:`flex cursor-pointer flex-col rounded-lg border p-2.5 text-left transition-colors ${i?`border-[#4176e6]/40 bg-[#f6f9ff]`:`border-stone-200 bg-white hover:border-stone-300 hover:bg-stone-50/60`}`,children:[(0,x.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,x.jsx)(`span`,{className:`mt-1.5`,children:(0,x.jsx)(Ce,{tone:n.tone})}),(0,x.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,x.jsx)(`p`,{className:`truncate font-mono text-[12.5px] text-stone-800`,children:t.id}),(0,x.jsx)(`p`,{className:`mt-0.5 text-[11.5px] leading-5 text-stone-500 ${i?``:`line-clamp-2`}`,children:S(t.roleZh)})]}),(0,x.jsxs)(`div`,{className:`flex shrink-0 flex-col items-end gap-1.5`,children:[(0,x.jsx)(C,{status:n}),(0,x.jsx)(w,{open:i})]})]}),i?(0,x.jsxs)(`dl`,{className:`mt-2 grid w-full grid-cols-[auto_1fr] gap-x-2 gap-y-1 border-t border-stone-200/70 pt-2 text-[11px]`,children:[(0,x.jsx)(`dt`,{className:`shrink-0 text-stone-400`,children:`分类`}),(0,x.jsx)(`dd`,{className:`truncate text-stone-600`,children:t.category}),(0,x.jsx)(`dt`,{className:`shrink-0 text-stone-400`,children:`npm 包`}),(0,x.jsx)(`dd`,{className:`truncate font-mono text-stone-600`,children:t.packageName||`—`})]}):null]},r)})}):(0,x.jsx)(`p`,{className:`border-t border-stone-100 px-3.5 py-4 text-center text-xs text-stone-400`,children:`没有匹配的内置插件`}):null]},e.id)})})})]})}function Te(e){try{return new URL(e).host}catch{return``}}var Ee=[{value:`zh-CN`,label:`中文`},{value:`en`,label:`English`}],T=`w-full px-3 py-2 text-sm border border-stone-300 rounded-lg bg-white focus:outline-none focus:ring-2 focus:ring-[#4176e6]/35 focus:border-[#4176e6] transition-colors`,E=`inline-flex items-center gap-1.5 h-9 min-w-30 px-3 rounded-lg bg-stone-100 text-sm text-stone-700 hover:bg-stone-200/80 transition-colors outline-none focus:outline-none`;function De({className:e=`w-3.5 h-3.5`}){return(0,x.jsx)(`svg`,{className:e,viewBox:`0 0 20 20`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,children:(0,x.jsx)(`path`,{d:`M6 8l4 4 4-4`,strokeLinecap:`round`,strokeLinejoin:`round`})})}function Oe({className:e=`w-4 h-4`}){return(0,x.jsx)(`svg`,{className:e,viewBox:`0 0 20 20`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,children:(0,x.jsx)(`path`,{d:`M5 10.5l3.5 3.5L15 6.5`,strokeLinecap:`round`,strokeLinejoin:`round`})})}function ke({className:e=`w-4 h-4`}){return(0,x.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:[(0,x.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`}),(0,x.jsx)(`path`,{d:`M12 1v2M12 21v2M4.2 4.2l1.4 1.4M18.4 18.4l1.4 1.4M1 12h2M21 12h2M4.2 19.8l1.4-1.4M18.4 5.6l1.4-1.4`})]})}function Ae({className:e=`w-4 h-4`}){return(0,x.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:[(0,x.jsx)(`ellipse`,{cx:`12`,cy:`5`,rx:`8`,ry:`3`}),(0,x.jsx)(`path`,{d:`M4 5v6c0 1.7 3.6 3 8 3s8-1.3 8-3V5`}),(0,x.jsx)(`path`,{d:`M4 11v6c0 1.7 3.6 3 8 3s8-1.3 8-3v-6`})]})}function je({className:e=`w-4 h-4`}){return(0,x.jsx)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:(0,x.jsx)(`path`,{d:`M10 4a2 2 0 0 1 4 0v1h3a1 1 0 0 1 1 1v3h1a2 2 0 0 1 0 4h-1v3a1 1 0 0 1-1 1h-3v1a2 2 0 0 1-4 0v-1H7a1 1 0 0 1-1-1v-3H5a2 2 0 0 1 0-4h1V6a1 1 0 0 1 1-1h3V4z`})})}function Me({kind:e}){let t=`w-5 h-5`;return e===`sun`?(0,x.jsxs)(`svg`,{className:t,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:[(0,x.jsx)(`circle`,{cx:`12`,cy:`12`,r:`4`}),(0,x.jsx)(`path`,{d:`M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4`})]}):e===`moon`?(0,x.jsx)(`svg`,{className:t,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:(0,x.jsx)(`path`,{d:`M21 14.5A8.5 8.5 0 1 1 9.5 3a7 7 0 0 0 11.5 11.5z`})}):(0,x.jsxs)(`svg`,{className:t,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:[(0,x.jsx)(`rect`,{x:`3`,y:`4`,width:`18`,height:`12`,rx:`2`}),(0,x.jsx)(`path`,{d:`M8 20h8M12 16v4`})]})}function D({title:e,description:t,control:n}){return(0,x.jsxs)(`div`,{className:`flex items-center gap-4 py-4 border-b border-stone-100 last:border-b-0`,children:[(0,x.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,x.jsx)(`div`,{className:`text-sm font-medium text-stone-800`,children:e}),t?(0,x.jsx)(`div`,{className:`mt-0.5 text-xs text-stone-400 leading-5`,children:t}):null]}),(0,x.jsx)(`div`,{className:`shrink-0`,children:n})]})}function O({value:e,options:t,onChange:n}){let r=t.find(t=>t.value===e)?.label??e;return(0,x.jsxs)(ne,{value:e,onChange:n,children:[(0,x.jsxs)(te,{className:E,children:[(0,x.jsx)(`span`,{className:`flex-1 text-left truncate`,children:r}),(0,x.jsx)(De,{className:`w-3.5 h-3.5 text-stone-400 shrink-0`})]}),(0,x.jsx)(s,{transition:!0,anchor:{to:`bottom end`,gap:6},className:`tw-select-menu tw-menu-anim z-60 min-w-40 rounded-xl py-1 shadow-lg ring-1 ring-stone-200 focus:outline-none`,children:t.map(e=>(0,x.jsxs)(o,{value:e.value,className:`group cursor-pointer select-none flex items-center justify-between gap-3 px-3 py-2 text-sm text-stone-700 data-[focus]:bg-stone-50 data-[selected]:text-stone-900`,children:[(0,x.jsx)(`span`,{children:e.label}),(0,x.jsx)(Oe,{className:`w-4 h-4 text-[#4176e6] opacity-0 group-data-[selected]:opacity-100 shrink-0`})]},e.value))})]})}function k(){let[e,t]=(0,_.useState)(!1),[c,m]=(0,_.useState)(`general`),[h,g]=(0,_.useState)(()=>ee().model.providers),[ye,v]=(0,_.useState)(()=>ee().model.activeId),[y,b]=(0,_.useState)(null),[S,C]=(0,_.useState)(``),[Ce,w]=(0,_.useState)(`DeepSeek`),[E,k]=(0,_.useState)(``),[A,Ne]=(0,_.useState)(``),[j,M]=(0,_.useState)(``),[N,Pe]=(0,_.useState)([]),[P,F]=(0,_.useState)(`idle`),[Fe,Ie]=(0,_.useState)(!1),[Le,Re]=(0,_.useState)(`readonly`),[ze,Be]=(0,_.useState)(!1),[Ve,I]=(0,_.useState)(!1),[He,Ue]=(0,_.useState)(null),[L,R]=(0,_.useState)({language:`zh-CN`,appearance:`system`,sessionFontSize:14,toolStepDetail:`standard`,busySendBehavior:`queue`,subagentModel:``}),[We,z]=(0,_.useState)(`14`),Ge=(0,_.useRef)(0),[B,Ke]=(0,_.useState)(null),[qe,Je]=(0,_.useState)(!1),[Ye,Xe]=(0,_.useState)(!1),[Ze,V]=(0,_.useState)(!1),[Qe,H]=(0,_.useState)(``),U=(0,_.useRef)(null),$e=(0,_.useRef)(!1),W=y!==null,G=L.language,K=h.find(e=>e.id===ye),q=(K?.name||``).trim(),J=B?.status??null,et=J?.phase===`done`&&!!J.to&&J.to===B?.current&&be!==B?.current&&Date.now()-Date.parse(J.finishedAt||``)<864e5,tt=J?.phase===`failed`?J.error:``,Y=Ze||J?.phase===`installing`||J?.phase===`restarting`,nt=(J?.to||B?.latest||``).replace(/^v/,``),X=tt||Qe,rt=B?.checkedAt&&!Y?new Date(B.checkedAt).toLocaleTimeString():``,it=qe?``:Y?J?.phase===`restarting`?p(`settings.updateRestarting`,void 0,G):p(`settings.updateInstalling`,{v:nt},G):X?`${p(`settings.updateFailed`,void 0,G)}:${X}`:et?p(`settings.updateDone`,{v:J?.to||``},G):B?.mode===`dev`&&B?.hasUpdate?p(`settings.updateDevMode`,void 0,G):B?.error?`${p(`settings.updateUnavailable`,void 0,G)}:${B.error}`:B?.hasUpdate?B.mode===`npx`?p(`settings.updateNpxHint`,void 0,G):``:B?`${p(`settings.updateLatest`,void 0,G)}${rt?` · ${p(`settings.updateCheckedAt`,{time:rt},G)}`:``}`:Ye?p(`settings.updateUnavailable`,void 0,G):``,at=q||(G===`en`?`No model`:`未配置`),ot=q?K?.model?.trim()?`${q} · ${K.model.trim()}`:q:G===`en`?`No model configured`:`未配置模型`;function st(e=`general`){m(e),r().then(()=>{ct(),t(!0)})}function ct(){Be(n()),g(u()),v(l()),I(!!d()),R(he()),me(he()),Re(pe()),b(null)}function Z(){U.current!==null&&(window.clearInterval(U.current),U.current=null)}async function lt(e=!0){Je(!0);try{let t=await Se(e);t&&(Ke(t),H(``))}finally{Je(!1),Xe(!0)}}function ut(e){Z();let t=Date.now()+18e4;U.current=window.setInterval(async()=>{if(!$e.current){$e.current=!0;try{let n=await Se(!0);if(n){Ke(n);let t=n.status;if(t?.phase===`failed`){Z(),V(!1),H(t.error||p(`settings.updateFailed`,void 0,G));return}if(t?.phase===`done`||e&&n.current!==e){Z(),V(!1);return}}Date.now()>t&&(Z(),V(!1),H(p(`settings.updateTimeout`,void 0,G)))}finally{$e.current=!1}}},1500)}async function dt(){let e=B?.latest||``;H(``),V(!0);let t=B?.current||be,n=await xe(e||void 0);n.ok?ut(t):(V(!1),H(n.error||p(`settings.updateFailed`,void 0,G)))}function ft(e){if(!e){let e=a();b(e),C(`DeepSeek`),w(`DeepSeek`),k(`https://api.deepseek.com/v1`),Ne(``),M(``),Pe([]),F(`idle`),Ie(!1);return}b(e.id),C(e.name),k(e.baseURL);let t=e.apiKey?.trim()||(e.id===l()?i().trim():``)||``;Ne(t),M(e.model),Pe(e.availableModels??[]),F(e.availableModels?.length?`ok`:`idle`),w(f.find(t=>t.baseURL===e.baseURL)?.label??`自定义`),Ie(!1)}(0,_.useEffect)(()=>{r().then(()=>ct());let e=e=>{let n=e.detail;m(n?.tab===`model`?`model`:n?.tab===`builtin`?`builtin`:`general`),r().then(()=>{ct(),t(!0)})};window.addEventListener(ge,e);let n=le(e=>R(e)),i=_e(e=>Re(e));return()=>{window.removeEventListener(ge,e),n(),i()}},[]),(0,_.useEffect)(()=>{if(e)return(async()=>{let e=await Se(!1);if(Xe(!0),!e)return;Ke(e);let t=e.status;(t?.phase===`installing`||t?.phase===`restarting`)&&(V(!0),ut(t.from||e.current))})(),Z},[e]),(0,_.useEffect)(()=>{if(!e||c!==`model`||!W)return;let t=E.trim(),n=A.trim();if(!t||!n){F(e=>e===`ok`?`ok`:`idle`);return}F(`loading`);let r=++Ge.current,i=setTimeout(()=>{se(t,n).then(e=>{r===Ge.current&&(Pe(e),F(`ok`))}).catch(()=>{r===Ge.current&&F(`fail`)})},800);return()=>clearTimeout(i)},[e,c,W,E,A]);function pt(e){w(e);let t=f.find(t=>t.label===e);t&&(t.baseURL&&k(t.baseURL),(!S.trim()||f.some(e=>e.label===S))&&C(t.label)),M(``)}function Q(e){R(ue(e))}(0,_.useEffect)(()=>{z(String(L.sessionFontSize))},[L.sessionFontSize]);function mt(){let e=Number(We);if(!We.trim()||!Number.isFinite(e)){z(String(L.sessionFontSize));return}let t=ue({sessionFontSize:Math.round(e)});R(t),z(String(t.sessionFontSize))}let ht=!!(S.trim()&&E.trim()&&A.trim()&&j.trim()),$=N.length>0;function gt(){if(!ht||!y)return;let e=!h.some(e=>e.id===y),t=ve({id:y,name:S.trim(),baseURL:E.trim(),apiKey:A.trim(),model:j.trim(),availableModels:$?N:void 0},{activate:!0});g(t),v(y),b(null),I(!!d()),oe(e?`已新增模型服务`:`已保存模型服务`,`success`)}function _t(e){Ue(e)}function vt(){let e=He;if(!e)return;let t=h.find(t=>t.id===e)?.name??`该服务`;Ue(null);let n=fe(e);g(n),v(l()),y===e&&b(null),I(!!d()),oe(`已删除模型服务「${t}」`,`success`)}function yt(e){ce(e),v(e),I(!!d())}let bt=[{value:`readonly`,label:p(`settings.access.readonly`,void 0,G)},{value:`readwrite`,label:p(`settings.access.readwrite`,void 0,G)},{value:`full`,label:p(`settings.access.full`,void 0,G)}],xt=[{value:`concise`,label:p(`settings.step.concise`,void 0,G)},{value:`standard`,label:p(`settings.step.standard`,void 0,G)},{value:`detailed`,label:p(`settings.step.detailed`,void 0,G)},{value:`full`,label:p(`settings.step.full`,void 0,G)}],St=[{value:`queue`,label:p(`settings.busySend.queue`,void 0,G)},{value:`interrupt`,label:p(`settings.busySend.interrupt`,void 0,G)}],Ct=[{value:`light`,label:p(`settings.appear.light`,void 0,G),icon:`sun`},{value:`dark`,label:p(`settings.appear.dark`,void 0,G),icon:`moon`},{value:`system`,label:p(`settings.appear.system`,void 0,G),icon:`monitor`}],wt=[{id:`general`,label:p(`settings.general`,void 0,G),icon:(0,x.jsx)(ke,{})},{id:`model`,label:p(`settings.model`,void 0,G),icon:(0,x.jsx)(Ae,{})},{id:`builtin`,label:p(`settings.builtin`,void 0,G),icon:(0,x.jsx)(je,{})}],Tt=c===`general`||c===`builtin`?p(c===`general`?`settings.general`:`settings.builtin`,void 0,G):W?h.some(e=>e.id===y)?p(`settings.editProvider`,void 0,G):p(`settings.addProviderTitle`,void 0,G):p(`settings.model`,void 0,G);return(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(`div`,{className:`tw-nav-foot-row`,children:[(0,x.jsxs)(`button`,{type:`button`,onClick:()=>st(`general`),className:`tw-nav-settings-btn`,"data-hint":Ve?`设置(已配置模型)`:`设置`,children:[(0,x.jsxs)(`svg`,{className:`tw-nav-ico w-4.5 h-4.5 shrink-0`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,"aria-hidden":`true`,children:[(0,x.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`}),(0,x.jsx)(`path`,{d:`M19.4 15a1.7 1.7 0 0 0 .3 1.8l.1.1a2 2 0 1 1-2.8 2.8l-.1-.1a1.7 1.7 0 0 0-1.8-.3 1.7 1.7 0 0 0-1 1.5V21a2 2 0 1 1-4 0v-.1a1.7 1.7 0 0 0-1-1.5 1.7 1.7 0 0 0-1.8.3l-.1.1a2 2 0 1 1-2.8-2.8l.1-.1a1.7 1.7 0 0 0 .3-1.8 1.7 1.7 0 0 0-1.5-1H3a2 2 0 1 1 0-4h.1a1.7 1.7 0 0 0 1.5-1 1.7 1.7 0 0 0-.3-1.8l-.1-.1a2 2 0 1 1 2.8-2.8l.1.1a1.7 1.7 0 0 0 1.8.3H9a1.7 1.7 0 0 0 1-1.5V3a2 2 0 1 1 4 0v.1a1.7 1.7 0 0 0 1 1.5 1.7 1.7 0 0 0 1.8-.3l.1-.1a2 2 0 1 1 2.8 2.8l-.1.1a1.7 1.7 0 0 0-.3 1.8V9c.2.6.7 1 1.5 1H21a2 2 0 1 1 0 4h-.1a1.7 1.7 0 0 0-1.5 1z`})]}),(0,x.jsx)(`span`,{"data-i18n":`nav.settings`,children:p(`nav.settings`,void 0,G)})]}),(0,x.jsxs)(`button`,{type:`button`,className:`tw-nav-provider-chip${q?``:` is-empty`}`,"data-hint":ot,onClick:()=>st(`model`),children:[(0,x.jsx)(`span`,{className:`tw-nav-provider-dot`,"aria-hidden":`true`}),(0,x.jsx)(`span`,{className:`tw-nav-provider-name`,children:at})]})]}),(0,x.jsx)(re,{show:e,children:(0,x.jsxs)(`div`,{className:`fixed inset-0 z-110 flex items-center justify-center p-4`,children:[(0,x.jsx)(ie,{children:(0,x.jsx)(`div`,{className:`tw-dialog-backdrop-anim absolute inset-0 bg-stone-950/45`,onClick:()=>t(!1),"aria-hidden":`true`})}),(0,x.jsx)(ie,{children:(0,x.jsxs)(`div`,{className:`tw-settings-dialog tw-dialog-panel-anim relative bg-white rounded-2xl shadow-2xl w-full max-w-3xl h-[min(92vh,720px)] overflow-hidden flex flex-col`,children:[(0,x.jsxs)(`div`,{className:`shrink-0 h-12 px-4 flex items-center justify-between border-b border-stone-100 bg-white`,children:[(0,x.jsx)(`h2`,{className:`text-sm font-semibold text-stone-800 truncate pr-3`,children:Tt}),(0,x.jsx)(`button`,{type:`button`,"aria-label":p(`settings.close`,void 0,G),onClick:()=>t(!1),className:`w-8 h-8 inline-flex items-center justify-center rounded-lg text-stone-400 hover:text-stone-700 hover:bg-stone-100 transition-colors`,children:(0,x.jsx)(`svg`,{className:`w-4 h-4`,viewBox:`0 0 20 20`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:(0,x.jsx)(`path`,{d:`M5 5l10 10M15 5L5 15`,strokeLinecap:`round`})})})]}),(0,x.jsxs)(`div`,{className:`flex-1 min-h-0 flex`,children:[(0,x.jsx)(`aside`,{className:`w-38 shrink-0 border-r border-stone-100 bg-[#f4f5f7] py-3 px-2 space-y-0.5`,children:wt.map(e=>{let t=c===e.id;return(0,x.jsxs)(`button`,{type:`button`,onClick:()=>{m(e.id),e.id===`model`&&b(null)},className:`w-full flex items-center gap-2 px-3 py-2.5 rounded-lg text-sm transition-colors ${t?`bg-[#e8f0fe] text-[#4176e6] font-medium`:`text-stone-600 hover:bg-white/70 hover:text-stone-800`}`,children:[(0,x.jsx)(`span`,{className:t?`text-[#4176e6]`:`text-stone-400`,children:e.icon}),e.label]},e.id)})}),(0,x.jsx)(`div`,{className:`flex-1 min-w-0 flex flex-col min-h-0 bg-white`,children:c===`general`?(0,x.jsxs)(`div`,{className:`flex-1 min-h-0 flex flex-col`,children:[(0,x.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-6 py-1`,children:[(0,x.jsx)(D,{title:p(`settings.access`,void 0,G),description:p(`settings.accessDesc`,void 0,G),control:(0,x.jsx)(O,{value:Le,options:bt,onChange:e=>{Re(e),de(e)}})}),(0,x.jsx)(D,{title:p(`settings.language`,void 0,G),control:(0,x.jsx)(O,{value:L.language,options:Ee,onChange:e=>Q({language:e})})}),(0,x.jsxs)(`div`,{className:`py-4 border-b border-stone-100`,children:[(0,x.jsx)(`div`,{className:`text-sm font-medium text-stone-800 mb-3`,children:p(`settings.appearance`,void 0,G)}),(0,x.jsx)(`div`,{className:`grid grid-cols-3 gap-2.5`,children:Ct.map(e=>{let t=L.appearance===e.value;return(0,x.jsxs)(`button`,{type:`button`,onClick:()=>Q({appearance:e.value}),className:`flex flex-col items-center justify-center gap-2 h-19 rounded-xl border transition-colors ${t?`border-[#4176e6] bg-[#edf3fe] text-[#4176e6] ring-1 ring-[#4176e6]/30`:`border-stone-200 text-stone-500 hover:border-stone-300 hover:bg-stone-50`}`,children:[(0,x.jsx)(Me,{kind:e.icon}),(0,x.jsx)(`span`,{className:`text-xs font-medium`,children:e.label})]},e.value)})})]}),(0,x.jsx)(D,{title:p(`settings.fontSize`,void 0,G),description:p(`settings.fontSizeDesc`,void 0,G),control:(0,x.jsxs)(`div`,{className:`inline-flex items-center gap-1.5`,children:[(0,x.jsx)(`input`,{type:`number`,min:12,max:22,value:We,onChange:e=>z(e.target.value),onBlur:mt,onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur()},className:`w-14 h-9 px-2 text-sm text-center rounded-lg bg-stone-100 border-0 outline-none focus:ring-2 focus:ring-[#4176e6]/30`}),(0,x.jsx)(`span`,{className:`text-sm text-stone-400`,children:`px`})]})}),(0,x.jsx)(D,{title:p(`settings.toolSteps`,void 0,G),description:p(`settings.toolStepsDesc`,void 0,G),control:(0,x.jsx)(O,{value:L.toolStepDetail,options:xt,onChange:e=>Q({toolStepDetail:e})})}),(0,x.jsx)(D,{title:p(`settings.busySend`,void 0,G),description:p(`settings.busySendDesc`,void 0,G),control:(0,x.jsx)(O,{value:L.busySendBehavior,options:St,onChange:e=>Q({busySendBehavior:e})})}),(0,x.jsx)(D,{title:p(`settings.subagentModel`,void 0,G),description:p(`settings.subagentModelDesc`,void 0,G),control:(0,x.jsx)(O,{value:L.subagentModel?.trim()?L.subagentModel:`inherit`,options:[{value:`inherit`,label:p(`settings.subagentModel.inherit`,void 0,G)},...Array.from(new Set([...K?.availableModels??[],...K?.model?[K.model]:[]])).filter(Boolean).map(e=>({value:e,label:e}))],onChange:e=>Q({subagentModel:e===`inherit`?``:e})})})]}),(0,x.jsxs)(`div`,{className:`shrink-0 px-6 py-3 border-t border-stone-100`,children:[(0,x.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,x.jsxs)(`div`,{className:`min-w-0 flex items-center gap-2`,children:[(0,x.jsx)(`span`,{className:`text-sm text-stone-700 whitespace-nowrap`,children:p(`settings.platformVersion`,void 0,G)}),(0,x.jsxs)(`span`,{className:`text-sm tabular-nums text-stone-500`,children:[`v`,be]}),B?.hasUpdate&&!Y&&!et?(0,x.jsx)(`span`,{className:`inline-flex items-center h-[18px] px-1.5 rounded-full bg-[#edf3fe] text-[11px] font-medium text-[#4176e6] tabular-nums whitespace-nowrap`,children:`${p(`settings.updateAvailable`,void 0,G)} v${(B.latest||``).replace(/^v/,``)}`}):null]}),(0,x.jsx)(`div`,{className:`shrink-0 flex items-center gap-2`,children:Y?(0,x.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 h-8 px-3 rounded-lg text-xs text-stone-500 bg-stone-100 whitespace-nowrap`,children:[(0,x.jsx)(`span`,{className:`w-3 h-3 rounded-full border-2 border-stone-300 border-t-[#4176e6] animate-spin`}),p(`settings.updateWorking`,void 0,G)]}):et?(0,x.jsx)(`button`,{type:`button`,onClick:()=>window.location.reload(),className:`h-8 px-3 rounded-lg text-xs font-medium text-[#4176e6] bg-[#edf3fe] hover:bg-[#e2ecfd] whitespace-nowrap`,children:p(`settings.updateReload`,void 0,G)}):(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(`button`,{type:`button`,disabled:qe,onClick:()=>void lt(!0),className:`inline-flex items-center justify-center min-w-[76px] h-8 px-3 rounded-lg text-xs font-medium text-stone-600 bg-stone-100 hover:bg-stone-200 disabled:opacity-70 disabled:cursor-default whitespace-nowrap`,children:qe?(0,x.jsxs)(x.Fragment,{children:[p(`settings.updateChecking`,void 0,G),(0,x.jsxs)(`span`,{className:`tw-dots`,"aria-hidden":`true`,children:[(0,x.jsx)(`i`,{}),(0,x.jsx)(`i`,{}),(0,x.jsx)(`i`,{})]})]}):p(`settings.updateCheck`,void 0,G)}),B?.hasUpdate?(0,x.jsx)(`button`,{type:`button`,disabled:B.mode===`dev`,onClick:()=>void dt(),className:`h-8 px-3 rounded-lg text-xs font-semibold text-white bg-[#4176e6] hover:bg-[#3566d6] disabled:opacity-50 disabled:cursor-not-allowed whitespace-nowrap`,children:p(`settings.updateNow`,void 0,G)}):null]})})]}),it?(0,x.jsx)(`div`,{className:`mt-1 text-[11px] leading-relaxed ${X?`text-red-500`:`text-stone-400`}`,children:it}):null,X&&B?.logPath?(0,x.jsx)(`div`,{className:`mt-0.5 text-[11px] leading-relaxed text-stone-400 break-all`,children:p(`settings.updateLog`,{path:B.logPath},G)}):null]})]}):W?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(`div`,{className:`shrink-0 px-5 pt-3 pb-2 flex items-center gap-2 border-b border-stone-100`,children:(0,x.jsx)(`button`,{type:`button`,onClick:()=>b(null),className:`text-sm text-stone-500 hover:text-stone-800`,children:p(`settings.back`,void 0,G)})}),(0,x.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-5 py-4 space-y-4`,children:[(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`label`,{className:`block text-xs font-medium text-stone-500 mb-1.5`,children:p(`settings.displayName`,void 0,G)}),(0,x.jsx)(`input`,{type:`text`,value:S,onChange:e=>C(e.target.value),placeholder:`DeepSeek`,className:T})]}),(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`label`,{className:`block text-xs font-medium text-stone-500 mb-1.5`,children:p(`settings.preset`,void 0,G)}),(0,x.jsx)(`div`,{className:`grid grid-cols-2 gap-2`,children:f.map(e=>{let t=Ce===e.label;return(0,x.jsxs)(`button`,{type:`button`,onClick:()=>pt(e.label),className:`text-left px-3 py-2 rounded-lg border transition-colors ${t?`border-[#4176e6] bg-[#edf3fe] ring-1 ring-[#4176e6]/30`:`border-stone-200 hover:border-stone-300 hover:bg-stone-50`}`,children:[(0,x.jsx)(`div`,{className:`text-sm ${t?`text-[#3565c7] font-medium`:`text-stone-700`}`,children:e.label}),(0,x.jsx)(`div`,{className:`text-[11px] text-stone-400 truncate`,children:e.baseURL?Te(e.baseURL):`OpenAI compatible`})]},e.label)})})]}),(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`label`,{className:`block text-xs font-medium text-stone-500 mb-1.5`,children:p(`settings.baseUrl`,void 0,G)}),(0,x.jsx)(`input`,{type:`text`,value:E,onChange:e=>k(e.target.value),placeholder:`https://api.deepseek.com/v1`,className:T})]}),(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`label`,{className:`block text-xs font-medium text-stone-500 mb-1.5`,children:p(`settings.apiKey`,void 0,G)}),(0,x.jsxs)(`div`,{className:`relative`,children:[(0,x.jsx)(`input`,{type:Fe?`text`:`password`,value:A,onChange:e=>Ne(e.target.value),placeholder:`sk-...`,className:`${T} pr-14`}),(0,x.jsx)(`button`,{type:`button`,onClick:()=>Ie(e=>!e),className:`absolute right-2 top-1/2 -translate-y-1/2 text-[11px] text-stone-400 hover:text-stone-600 px-1.5 py-1`,children:Fe?G===`en`?`Hide`:`隐藏`:G===`en`?`Show`:`显示`})]}),ze?(0,x.jsx)(`p`,{className:`mt-1.5 text-[11px] text-stone-400 leading-5`,children:p(`settings.keyHint`,void 0,G)}):null]}),(0,x.jsxs)(`div`,{children:[(0,x.jsxs)(`div`,{className:`flex items-center justify-between mb-1.5`,children:[(0,x.jsx)(`label`,{className:`text-xs font-medium text-stone-500`,children:p(`settings.modelField`,void 0,G)}),P===`loading`&&(0,x.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:p(`settings.recognizing`,void 0,G)}),$&&P===`ok`&&(0,x.jsx)(`span`,{className:`text-[11px] text-emerald-600`,children:p(`settings.recognized`,{n:N.length},G)}),P===`fail`&&!$&&(0,x.jsx)(`span`,{className:`text-[11px] text-amber-600`,children:p(`settings.recognizeFail`,void 0,G)}),P===`fail`&&$&&(0,x.jsx)(`span`,{className:`text-[11px] text-amber-600`,children:p(`settings.recognizeKeep`,void 0,G)})]}),$?(0,x.jsxs)(ne,{value:j,onChange:M,children:[(0,x.jsxs)(te,{className:`${T} flex items-center justify-between text-left hover:border-stone-400 cursor-pointer`,children:[(0,x.jsx)(`span`,{className:`truncate text-stone-800`,children:j||(G===`en`?`Select a model`:`请选择模型`)}),(0,x.jsx)(De,{className:`w-4 h-4 shrink-0 ml-2 text-stone-400`})]}),(0,x.jsx)(s,{transition:!0,anchor:{to:`bottom start`,gap:6},className:`tw-select-menu tw-menu-anim z-60 w-(--button-width) max-h-60 overflow-auto rounded-lg py-1 shadow-lg ring-1 ring-stone-200 focus:outline-none`,children:N.map(e=>(0,x.jsxs)(o,{value:e,className:`group cursor-pointer select-none flex items-center justify-between px-3 py-2 text-sm text-stone-700 data-[focus]:bg-[#edf3fe] data-[selected]:text-[#3565c7] data-[selected]:font-medium`,children:[(0,x.jsx)(`span`,{className:`truncate`,children:e}),(0,x.jsx)(Oe,{className:`w-4 h-4 text-[#4176e6] opacity-0 group-data-[selected]:opacity-100 shrink-0 ml-2`})]},e))})]}):(0,x.jsx)(`input`,{type:`text`,value:j,onChange:e=>M(e.target.value),placeholder:p(`settings.modelPlaceholder`,void 0,G),className:T})]})]}),(0,x.jsxs)(`div`,{className:`shrink-0 px-5 py-3.5 bg-stone-50 border-t border-stone-100 flex justify-end gap-2`,children:[(0,x.jsx)(`button`,{type:`button`,onClick:()=>b(null),className:`px-3.5 py-1.5 text-sm text-stone-600 hover:bg-stone-200/60 rounded-lg`,children:p(`settings.cancel`,void 0,G)}),(0,x.jsx)(`button`,{type:`button`,onClick:gt,disabled:!ht,className:`px-3.5 py-1.5 text-sm font-medium text-white bg-[#4176e6] hover:bg-[#3565c7] rounded-lg disabled:opacity-40 disabled:cursor-not-allowed`,children:p(`settings.save`,void 0,G)})]})]}):c===`builtin`?(0,x.jsx)(we,{}):(0,x.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-6 py-5 bg-[#f4f5f7]`,children:[(0,x.jsx)(`p`,{className:`text-sm text-stone-500`,children:p(`settings.modelIntro`,void 0,G)}),(0,x.jsxs)(`div`,{className:`mt-5 space-y-2.5`,children:[h.map(e=>{let t=!!(e.apiKey?.trim()&&e.baseURL.trim()&&e.model.trim()),n=e.id===ye;return(0,x.jsxs)(`div`,{className:`flex items-center gap-3 rounded-xl border border-stone-200/90 bg-white px-4 py-3.5 shadow-[0_1px_0_rgba(15,23,42,0.02)]`,children:[(0,x.jsxs)(`button`,{type:`button`,"data-hint":n?G===`en`?`Active`:`当前使用`:G===`en`?`Set active`:`设为当前`,onClick:()=>yt(e.id),className:`flex-1 min-w-0 flex items-center gap-2 text-left`,children:[(0,x.jsx)(`span`,{className:`text-sm font-medium text-stone-800 truncate`,children:e.name}),t?(0,x.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full shrink-0 bg-emerald-500`}):null]}),(0,x.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0`,children:[(0,x.jsx)(`button`,{type:`button`,onClick:()=>ft(e),className:`h-8 px-3 text-sm text-stone-700 rounded-lg border border-stone-200 bg-white hover:bg-stone-50`,children:p(`settings.edit`,void 0,G)}),h.length>1?(0,x.jsx)(`button`,{type:`button`,onClick:()=>_t(e.id),className:`h-8 px-3 text-sm text-red-600 rounded-lg hover:bg-red-50`,children:p(`settings.delete`,void 0,G)}):null]})]},e.id)}),(0,x.jsx)(`button`,{type:`button`,onClick:()=>ft(null),className:`w-full h-12 rounded-xl border border-dashed border-stone-300 bg-white/60 text-sm text-stone-600 hover:border-[#4176e6] hover:text-[#4176e6] hover:bg-[#edf3fe]/50 transition-colors`,children:p(`settings.addProvider`,void 0,G)})]})]})})]})]})})]})}),(0,x.jsx)(ae,{open:He!=null,title:p(`settings.delete`,void 0,G),message:p(`settings.deleteConfirm`,void 0,G),confirmLabel:p(`settings.delete`,void 0,G),cancelLabel:G===`en`?`Cancel`:`取消`,danger:!0,onClose:()=>Ue(null),onConfirm:vt})]})}export{k as default};
|
|
1
|
+
import{s as e,t}from"./react.Blvh0GOs.js";import{a as n,i as r,n as i,r as ee,s as a}from"./app-config.CF1xVPmo.js";import{i as te,n as o,r as ne,t as s}from"./listbox.DNxAJmEo.js";import{a as re,o as ie}from"./dialog.DZHZCe_T.js";import{t as c}from"./jsx-runtime.DUg_B_vD.js";import{t as ae}from"./ConfirmDialog.CsMwWevK.js";import{showToast as oe}from"./Toast.BO2NFckG.js";import{i as se}from"./llm.BZEzE0x2.js";import{_ as ce,a as l,c as u,d as le,g as ue,h as de,i as fe,l as d,n as f,o as pe,r as me,s as he,t as ge,u as _e,v as ve}from"./settings.BvxRxdqa.js";import{n as p}from"./i18n.B3BVhlok.js";import{s as m}from"./fs-tools.3F9MFrLf.js";import{_ as h,c as g,l as ye}from"./bash-tools.CPS0ZiKi.js";import{t as be}from"./app-version.zuhxTsqO.js";import{n as xe,t as Se}from"./update.DXCPfU4a.js";var _=e(t(),1);function v(e){return e===`time-context`||e===`tool-todo`||e===`tool-ask-user`||e===`user-questions`||e===`plan-mode`||e===`tool-result-pruner`||e===`compaction-basic`||e===`command-compact`||e===`tool-goal`||e===`command-goal`||e===`goal`||e===`tool-schedule`||e===`schedule`||e===`goal-round-driver`||e===`session-log-download`||e===`llm-retry`||e===`session-title-llm`||e===`session-stats`||e===`locale`||e===`config-editor`||e===`subagent`||e===`subagent-fork-in-process`||e===`spill-local`||e===`spill-policy`||e===`session-turn-outline`||e===`image-offload`||e===`session-persistence-jsonl`||e===`session-checkpoint-policy`||e===`session-query-sqlite`||e===`session-projection-cache`||e===`storage-domain`||e===`workspace-changes`||e===`workspace-dependencies`||e===`skill-office`||e===`fs-observation-policy`||e===`deepseek-llm-api-extensions`||e===`session-log-deepseek`||e===`subagent-model-selection-settings`||e===`authorization`||e===`modules`||e===`resources`||e===`mcp-resources`||e===`ptc-runtime`||e===`headless-runner`||e===`headless-startup`||e===`sdk-jsonrpc-server`||e===`sdk-app-startup`||e===`acp`||e===`acp-app-startup`||e===`subagent-spawn-in-process`||e===`llm-pi-ai`||e===`session-reference`||e===`tool-subagent`||e===`tool-subagent-control`||e===`tool-subagent-list-agents`||e===`tool-subagent-fork`||e===`tool-workflow`||e===`workflow-ptc`||e===`session-title`||e===`attachment-local`||e===`file-upload`||e===`file-reference-local`||e===`credentials`||e===`connection`||e===`token-meter`||e===`llm`||e===`llm-deepseek`||e===`agent-default-model`||e===`session`||e===`sessions`||e===`session-projection`||e===`storage`||e===`storage-json`||e===`settings`||e===`commands`||e===`shortcuts`||e===`timeout-policy`||e===`shell-env`||e===`approval`||e===`agent`||e===`system-prompt`||e===`tools`||e===`repeat-tool-reminder`?`ready`:e===`tool-web`||e===`web`||e===`web-fetch-http`||e===`web-search-deepseek`?`web`:e===`tool-bash`||e===`tool-jobs`||e===`jobs`||e===`sandbox-policy`||e===`bash-sandbox`||e===`sandbox`||e===`pty`||e===`terminal-bash`||e===`persistent-bash`||e===`subprocess`?`bash`:e===`tool-pwsh`||e===`persistent-pwsh`||e===`terminal-pwsh`||e===`pwsh-sandbox`?`pwsh`:e===`tool-fs`||e===`tool-fs-search`||e===`tool-skill`||e===`skill`||e===`agent-instructions`||e===`present`||e===`office-to-pdf`||e===`filesystem`||e===`fs-sandbox`||e===`permission`||e===`working-directory`||e===`tool-working-directory`||e===`workspace`?`fs`:`none`}var y=[{id:`agent-instructions`,packageName:`@deepseek-ai/dsh-agent-instructions`,roleZh:`加载 AGENTS.md/CLAUDE.md。`,category:`会话能力`},{id:`time-context`,packageName:`@deepseek-ai/dsh-time-context`,roleZh:`注入当前时间与耗时。`,category:`会话能力`},{id:`tool-bash`,packageName:`@deepseek-ai/dsh-tool-bash`,roleZh:`模型可调用 bash 在本机执行命令(可后台、可沙箱升级)。`,category:`会话能力`},{id:`tool-pwsh`,packageName:`@deepseek-ai/dsh-tool-pwsh`,roleZh:`模型可调用 PowerShell(主要面向 Windows)。`,category:`会话能力`},{id:`tool-fs`,packageName:`@deepseek-ai/dsh-tool-fs`,roleZh:`模型可读/写/编辑工作区文件。`,category:`会话能力`},{id:`tool-working-directory`,packageName:`@deepseek-ai/dsh-tool-working-directory`,roleZh:`模型可查看/切换会话工作目录。`,category:`会话能力`},{id:`tool-fs-search`,packageName:`@deepseek-ai/dsh-tool-fs-search`,roleZh:`模型可用 glob / grep 搜索工作区文件(内置 ripgrep)。`,category:`会话能力`},{id:`tool-skill`,packageName:`@deepseek-ai/dsh-tool-skill`,roleZh:`模型可按需加载工作区 SKILL.md。`,category:`会话能力`},{id:`tool-jobs`,packageName:`@deepseek-ai/dsh-tool-jobs`,roleZh:`模型可查看/读取输出/终止后台任务(job_list/output/kill)。`,category:`会话能力`},{id:`tool-schedule`,packageName:`@deepseek-ai/dsh-tool-schedule`,roleZh:`模型可创建/查询/更新/删除定时提醒,到点投递回原会话。`,category:`会话能力`},{id:`command-goal`,packageName:`@deepseek-ai/dsh-command-goal`,roleZh:`人类管理会话目标的 slash 命令。`,category:`会话能力`},{id:`tool-goal`,packageName:`@deepseek-ai/dsh-tool-goal`,roleZh:`模型可读写本会话目标,并在执行时做权限校验。`,category:`会话能力`},{id:`plan-mode`,packageName:`@deepseek-ai/dsh-plan-mode`,roleZh:`计划模式(探查→方案→批准→实施)。`,category:`planning`},{id:`compaction-basic`,packageName:`@deepseek-ai/dsh-compaction-basic`,roleZh:`上下文 token 过高时自动摘要压缩,腾出窗口。`,category:`compaction`},{id:`command-compact`,packageName:`@deepseek-ai/dsh-command-compact`,roleZh:`人类手动压缩会话的 slash 命令。`,category:`compaction`},{id:`tool-result-pruner`,packageName:`@deepseek-ai/dsh-compaction-tool-result-pruner`,roleZh:`裁剪过长的工具返回(头/中/尾保留),省 token。`,category:`compaction`},{id:`tool-subagent-control`,packageName:`@deepseek-ai/dsh-tool-subagent-control`,roleZh:`模型可给子代理发消息、中断、列出正在跑的子代理。`,category:`delegation`},{id:`tool-subagent-list-agents`,packageName:`@deepseek-ai/dsh-tool-subagent-control/list-agents`,roleZh:`单独暴露 list_agents,列出可用/运行中的子代理。`,category:`delegation`},{id:`tool-subagent`,packageName:`@deepseek-ai/dsh-tool-subagent`,roleZh:`模型可派生子代理去执行子任务(spawn)。`,category:`delegation`},{id:`tool-subagent-fork`,packageName:`@deepseek-ai/dsh-tool-subagent`,roleZh:`模型可 fork 当前上下文开子代理并行干活。`,category:`delegation`},{id:`workflow-ptc`,packageName:`@deepseek-ai/dsh-workflow-ptc`,roleZh:`在沙箱 Node 运行时里跑工作流编排脚本。`,category:`delegation`},{id:`tool-workflow`,packageName:`@deepseek-ai/dsh-tool-workflow`,roleZh:`模型可调用 workflow:跑一段编排脚本来协调多步。`,category:`delegation`},{id:`tool-ask-user`,packageName:`@deepseek-ai/dsh-tool-ask-user`,roleZh:`模型可向用户提出结构化问题并等待回答。`,category:`会话能力`},{id:`tool-todo`,packageName:`@deepseek-ai/dsh-tool-todo`,roleZh:`模型可维护本会话待办清单(todo_write)。`,category:`会话能力`},{id:`tool-web`,packageName:`@deepseek-ai/dsh-tool-web`,roleZh:`模型可网页搜索(web_search)与抓取页面(web_fetch)。`,category:`会话能力`},{id:`present`,packageName:`@deepseek-ai/dsh-tool-present`,roleZh:`模型可声明「交付了哪些工作区文件」,便于 UI 展示/打开。`,category:`会话能力`}],b=[{id:`attachment-local`,packageName:`@deepseek-ai/dsh-attachment-local`,roleZh:`本机附件存储与读取。`,category:`会话 / 存储`},{id:`session`,packageName:`@deepseek-ai/dsh-session`,roleZh:`事件溯源的会话存储(会话真相源)。`,category:`会话 / 存储`},{id:`session-checkpoint-policy`,packageName:`@deepseek-ai/dsh-session-checkpoint-policy`,roleZh:`会话检查点策略。`,category:`会话 / 存储`},{id:`session-log-deepseek`,packageName:`@deepseek-ai/dsh-session-log-deepseek`,roleZh:`DeepSeek 侧增量无损会话日志请求扩展。`,category:`会话 / 存储`},{id:`session-log-download`,packageName:`@deepseek-ai/dsh-session-log-export`,roleZh:`导出会话日志。`,category:`会话 / 存储`},{id:`session-persistence-jsonl`,packageName:`@deepseek-ai/dsh-session-persistence-jsonl`,roleZh:`会话以 JSONL 持久化。`,category:`会话 / 存储`},{id:`session-projection`,packageName:`@deepseek-ai/dsh-session-projection`,roleZh:`会话投影视图(给 UI/查询用)。`,category:`会话 / 存储`},{id:`session-projection-cache`,packageName:`@deepseek-ai/dsh-session-projection-cache`,roleZh:`会话投影缓存。`,category:`会话 / 存储`},{id:`session-query-sqlite`,packageName:`@deepseek-ai/dsh-session-query-sqlite`,roleZh:`会话全文/结构化查询(sqlite)。`,category:`会话 / 存储`},{id:`session-reference`,packageName:`@deepseek-ai/dsh-session-reference`,roleZh:`会话内引用(消息/文件等)。`,category:`会话 / 存储`},{id:`session-stats`,packageName:`@deepseek-ai/dsh-session-stats`,roleZh:`会话统计信息。`,category:`会话 / 存储`},{id:`session-title`,packageName:`@deepseek-ai/dsh-session-title`,roleZh:`会话标题能力。`,category:`会话 / 存储`},{id:`session-turn-outline`,packageName:`@deepseek-ai/dsh-session-turn-outline`,roleZh:`对话回合摘要。`,category:`会话 / 存储`},{id:`sessions`,packageName:`@deepseek-ai/dsh-session-persistence-jsonl`,roleZh:`会话 JSONL 持久化后端(与 session-persistence 同类)。`,category:`会话 / 存储`},{id:`storage`,packageName:`@deepseek-ai/dsh-storage`,roleZh:`通用存储服务。`,category:`会话 / 存储`},{id:`storage-domain`,packageName:`@deepseek-ai/dsh-storage-domain`,roleZh:`按域划分的存储。`,category:`会话 / 存储`},{id:`storage-json`,packageName:`@deepseek-ai/dsh-storage-json`,roleZh:`JSON 文件存储后端。`,category:`会话 / 存储`},{id:`command-compact`,packageName:`@deepseek-ai/dsh-command-compact`,roleZh:`人类手动压缩会话的 slash 命令。`,category:`模型面工具/命令`},{id:`command-goal`,packageName:`@deepseek-ai/dsh-command-goal`,roleZh:`人类管理会话目标的 slash 命令。`,category:`模型面工具/命令`},{id:`skill-office`,packageName:`@deepseek-ai/dsh-skill-office`,roleZh:`Office(Word/PPT/Excel)相关工作流 Skill。`,category:`模型面工具/命令`},{id:`tool-bash`,packageName:`@deepseek-ai/dsh-tool-bash`,roleZh:`模型可调用 bash 在本机执行命令(可后台、可沙箱升级)。`,category:`模型面工具/命令`},{id:`tool-fs`,packageName:`@deepseek-ai/dsh-tool-fs`,roleZh:`模型可读/写/编辑工作区文件。`,category:`模型面工具/命令`},{id:`tool-fs-search`,packageName:`@deepseek-ai/dsh-tool-fs-search`,roleZh:`模型可用 glob / grep 搜索工作区文件(内置 ripgrep)。`,category:`模型面工具/命令`},{id:`tool-goal`,packageName:`@deepseek-ai/dsh-tool-goal`,roleZh:`模型可读写本会话目标,并在执行时做权限校验。`,category:`模型面工具/命令`},{id:`tool-jobs`,packageName:`@deepseek-ai/dsh-tool-jobs`,roleZh:`模型可查看/读取输出/终止后台任务(job_list/output/kill)。`,category:`模型面工具/命令`},{id:`tool-pwsh`,packageName:`@deepseek-ai/dsh-tool-pwsh`,roleZh:`模型可调用 PowerShell(主要面向 Windows)。`,category:`模型面工具/命令`},{id:`tool-result-pruner`,packageName:`@deepseek-ai/dsh-compaction-tool-result-pruner`,roleZh:`裁剪过长的工具返回(头/中/尾保留),省 token。`,category:`模型面工具/命令`},{id:`tool-skill`,packageName:`@deepseek-ai/dsh-tool-skill`,roleZh:`模型可按需加载某个 Skill,把技能说明拉进上下文。`,category:`模型面工具/命令`},{id:`tool-subagent`,packageName:`@deepseek-ai/dsh-tool-subagent`,roleZh:`模型可派生子代理去执行子任务(spawn)。`,category:`模型面工具/命令`},{id:`tool-subagent-control`,packageName:`@deepseek-ai/dsh-tool-subagent-control`,roleZh:`模型可给子代理发消息、中断、列出正在跑的子代理。`,category:`模型面工具/命令`},{id:`tool-subagent-fork`,packageName:`@deepseek-ai/dsh-tool-subagent`,roleZh:`模型可 fork 当前上下文开子代理并行干活。`,category:`模型面工具/命令`},{id:`tool-subagent-list-agents`,packageName:`@deepseek-ai/dsh-tool-subagent-control/list-agents`,roleZh:`单独暴露 list_agents,列出可用/运行中的子代理。`,category:`模型面工具/命令`},{id:`tool-todo`,packageName:`@deepseek-ai/dsh-tool-todo`,roleZh:`模型可维护本会话待办清单(todo_write)。`,category:`模型面工具/命令`},{id:`tool-web`,packageName:`@deepseek-ai/dsh-tool-web`,roleZh:`模型可网页搜索(web_search)与抓取页面(web_fetch)。`,category:`模型面工具/命令`},{id:`tool-workflow`,packageName:`@deepseek-ai/dsh-tool-workflow`,roleZh:`模型可调用 workflow:跑一段编排脚本来协调多步。`,category:`模型面工具/命令`},{id:`tool-working-directory`,packageName:`@deepseek-ai/dsh-tool-working-directory`,roleZh:`模型可查看/切换会话工作目录。`,category:`模型面工具/命令`},{id:`acp`,packageName:`@deepseek-ai/dsh-acp`,roleZh:`通过 JSON-RPC stdio 驱动 Harness Agent 的自动化协议服务(给外部编排用)。`,category:`其它`},{id:`acp-app-startup`,packageName:`@deepseek-ai/dsh-acp-app`,roleZh:`ACP 配置包启动:在 base 之上挂 JSON-RPC stdio 与进程生命周期。`,category:`其它`},{id:`authorization`,packageName:`@deepseek-ai/dsh-authorization`,roleZh:`授权/鉴权服务。`,category:`其它`},{id:`commands`,packageName:`@deepseek-ai/dsh-commands`,roleZh:`人类 slash 命令注册底座。`,category:`其它`},{id:`config-editor`,packageName:`@deepseek-ai/dsh-config-editor`,roleZh:`配置编辑能力。`,category:`其它`},{id:`connection`,packageName:`@deepseek-ai/dsh-client-connection`,roleZh:`客户端与 Host 连接。`,category:`其它`},{id:`credentials`,packageName:`@deepseek-ai/dsh-credentials-local`,roleZh:`本机凭证存储。`,category:`其它`},{id:`file-reference-local`,packageName:`@deepseek-ai/dsh-file-reference-local`,roleZh:`本机文件引用解析。`,category:`其它`},{id:`file-upload`,packageName:`@deepseek-ai/dsh-client-file-upload`,roleZh:`客户端上传文件。`,category:`其它`},{id:`filesystem`,packageName:`@deepseek-ai/dsh-fs-local`,roleZh:`本机文件系统实现(ctx.fs),供 tool-fs 等读写。`,category:`其它`},{id:`fs-observation-policy`,packageName:`@deepseek-ai/dsh-fs-observation-policy`,roleZh:`文件系统观察/上报策略。`,category:`其它`},{id:`headless-runner`,packageName:`@deepseek-ai/dsh-headless`,roleZh:`无 Host/HTTP/浏览器的一键 Agent/Session 运行器(纯 headless)。`,category:`其它`},{id:`headless-startup`,packageName:`@deepseek-ai/dsh-headless/startup`,roleZh:`Headless 配置包的启动插件。`,category:`其它`},{id:`image-offload`,packageName:`@deepseek-ai/dsh-compaction-image-offload`,roleZh:`超预算图片卸载为占位符并重试。`,category:`其它`},{id:`locale`,packageName:`@deepseek-ai/dsh-client-locale`,roleZh:`界面语言。`,category:`其它`},{id:`mcp-resources`,packageName:`@deepseek-ai/dsh-mcp-resources`,roleZh:`MCP 资源对接。`,category:`其它`},{id:`modules`,packageName:`@deepseek-ai/dsh-client-modules`,roleZh:`客户端模块加载。`,category:`其它`},{id:`office-to-pdf`,packageName:`@deepseek-ai/dsh-office-to-pdf`,roleZh:`Office 转 PDF。`,category:`其它`},{id:`pty`,packageName:`@deepseek-ai/dsh-terminal`,roleZh:`持久 PTY 会话能力缝:会话 id、后端注册、交互读写与信号。`,category:`其它`},{id:`repeat-tool-reminder`,packageName:`@deepseek-ai/dsh-repeat-tool-reminder`,roleZh:`重复工具调用时提醒模型。`,category:`其它`},{id:`resources`,packageName:`@deepseek-ai/dsh-client-resources`,roleZh:`客户端资源。`,category:`其它`},{id:`sdk-app-startup`,packageName:`@deepseek-ai/dsh-sdk-app`,roleZh:`SDK 配置包启动:stdio JSON-RPC 服务与进程生命周期。`,category:`其它`},{id:`sdk-jsonrpc-server`,packageName:`@deepseek-ai/dsh-sdk-jsonrpc-server`,roleZh:`给进程外 SDK 客户端用的 stdio JSON-RPC 服务端。`,category:`其它`},{id:`settings`,packageName:`@deepseek-ai/dsh-settings`,roleZh:`设置读写与校验。`,category:`其它`},{id:`shell-env`,packageName:`@deepseek-ai/dsh-shell-env`,roleZh:`注入/管理 shell 环境变量。`,category:`其它`},{id:`shortcuts`,packageName:`@deepseek-ai/dsh-client-shortcuts`,roleZh:`快捷键注册。`,category:`其它`},{id:`timeout-policy`,packageName:`@deepseek-ai/dsh-tool-call-timeout-policy`,roleZh:`单次工具调用超时策略。`,category:`其它`},{id:`user-questions`,packageName:`@deepseek-ai/dsh-user-questions`,roleZh:`用户提问通道(供 ask_user 等使用)。`,category:`其它`},{id:`working-directory`,packageName:`@deepseek-ai/dsh-working-directory`,roleZh:`会话工作目录状态。`,category:`其它`},{id:`workspace`,packageName:`@deepseek-ai/dsh-workspace`,roleZh:`工作区抽象(根目录、切换等)。`,category:`其它`},{id:`workspace-changes`,packageName:`@deepseek-ai/dsh-workspace-changes`,roleZh:`工作区变更追踪。`,category:`其它`},{id:`workspace-dependencies`,packageName:`@deepseek-ai/dsh-tool-workspace-dependencies`,roleZh:`向模型提供捆绑的 Python/Node/pnpm 依赖绝对路径(load_workspace_dependencies)。`,category:`其它`},{id:`compaction-basic`,packageName:`@deepseek-ai/dsh-compaction-basic`,roleZh:`上下文 token 过高时自动摘要压缩,腾出窗口。`,category:`上下文压缩`},{id:`spill-local`,packageName:`@deepseek-ai/dsh-spill-local`,roleZh:`过大内容溢出到本机文件。`,category:`上下文压缩`},{id:`spill-policy`,packageName:`@deepseek-ai/dsh-spill-policy`,roleZh:`何时溢出、溢出策略。`,category:`上下文压缩`},{id:`token-meter`,packageName:`@deepseek-ai/dsh-token-meter`,roleZh:`统计上下文 token 用量。`,category:`上下文压缩`},{id:`web`,packageName:`@deepseek-ai/dsh-web`,roleZh:`网页能力缝(ctx.web):注册 search/fetch provider。`,category:`网页能力`},{id:`web-fetch-http`,packageName:`@deepseek-ai/dsh-web-fetch-http`,roleZh:`通用 HTTP 抓取网页正文 provider。`,category:`网页能力`},{id:`goal`,packageName:`@deepseek-ai/dsh-goal`,roleZh:`本会话目标状态机服务。`,category:`预设 / 能力服务`},{id:`goal-round-driver`,packageName:`@deepseek-ai/dsh-goal-round-driver`,roleZh:`按目标驱动多轮执行。`,category:`预设 / 能力服务`},{id:`plan-mode`,packageName:`@deepseek-ai/dsh-plan-mode`,roleZh:`计划模式(探查→方案→批准→实施)。`,category:`预设 / 能力服务`},{id:`schedule`,packageName:`@deepseek-ai/dsh-schedule`,roleZh:`主机级持久提醒,到点投递原会话。`,category:`预设 / 能力服务`},{id:`skill`,packageName:`@deepseek-ai/dsh-skill`,roleZh:`Skill 能力注册底座。`,category:`预设 / 能力服务`},{id:`approval`,packageName:`@deepseek-ai/dsh-user-approval`,roleZh:`敏感操作需用户批准。`,category:`执行 / 权限`},{id:`bash-sandbox`,packageName:`@deepseek-ai/dsh-bash-sandbox`,roleZh:`bash 专用沙箱绑定。`,category:`执行 / 权限`},{id:`fs-sandbox`,packageName:`@deepseek-ai/dsh-fs-sandbox`,roleZh:`文件系统沙箱。`,category:`执行 / 权限`},{id:`jobs`,packageName:`@deepseek-ai/dsh-jobs-local`,roleZh:`后台任务注册表(id、归属、轮询、取消)。`,category:`执行 / 权限`},{id:`permission`,packageName:`@deepseek-ai/dsh-permission-presets`,roleZh:`权限预设(只读/读写等档位)。`,category:`执行 / 权限`},{id:`persistent-bash`,packageName:`@deepseek-ai/dsh-tool-bash-persistent`,roleZh:`带 PTY 的持久 Bash 工具(跨调用保持 shell 状态)。`,category:`执行 / 权限`},{id:`persistent-pwsh`,packageName:`@deepseek-ai/dsh-tool-pwsh-persistent`,roleZh:`带 PTY 的持久 PowerShell 工具。`,category:`执行 / 权限`},{id:`pwsh-sandbox`,packageName:`@deepseek-ai/dsh-pwsh-sandbox`,roleZh:`pwsh 专用沙箱绑定。`,category:`执行 / 权限`},{id:`sandbox`,packageName:`@deepseek-ai/dsh-sandbox-local`,roleZh:`本机沙箱执行环境。`,category:`执行 / 权限`},{id:`sandbox-policy`,packageName:`@deepseek-ai/dsh-sandbox-policy`,roleZh:`沙箱策略(能跑什么、不能跑什么)。`,category:`执行 / 权限`},{id:`subprocess`,packageName:`@deepseek-ai/dsh-subprocess-local`,roleZh:`本机子进程执行器。`,category:`执行 / 权限`},{id:`terminal-bash`,packageName:`@deepseek-ai/dsh-terminal-bash`,roleZh:`基于子进程终端原语的持久 bash PTY 后端。`,category:`执行 / 权限`},{id:`terminal-pwsh`,packageName:`@deepseek-ai/dsh-terminal-bash`,roleZh:`基于子进程终端原语的持久 pwsh PTY 后端。`,category:`执行 / 权限`},{id:`ptc-runtime`,packageName:`@deepseek-ai/dsh-ptc-runtime-node`,roleZh:`PTC(工具调用呈现)Node 运行时。`,category:`子代理 / 工作流`},{id:`subagent`,packageName:`@deepseek-ai/dsh-subagent`,roleZh:`子代理能力底座。`,category:`子代理 / 工作流`},{id:`workflow-ptc`,packageName:`@deepseek-ai/dsh-workflow-ptc`,roleZh:`在沙箱 Node 运行时里跑工作流编排脚本。`,category:`子代理 / 工作流`},{id:`agent`,packageName:`@deepseek-ai/dsh-agent`,roleZh:`Agent 主体:把会话、工具、模型串起来。`,category:`LLM / Agent 核心`},{id:`agent-default-model`,packageName:`@deepseek-ai/dsh-agent-default-model`,roleZh:`解析/提供默认模型配置。`,category:`LLM / Agent 核心`},{id:`agent-instructions`,packageName:`@deepseek-ai/dsh-agent-instructions`,roleZh:`加载 AGENTS.md/CLAUDE.md。`,category:`LLM / Agent 核心`},{id:`deepseek-llm-api-extensions`,packageName:`@deepseek-ai/dsh-deepseek-llm-api-extensions`,roleZh:`给官方 DeepSeek API 适配器登记额外请求字段。`,category:`LLM / Agent 核心`},{id:`llm`,packageName:`@deepseek-ai/dsh-llm`,roleZh:`厂商无关的 LLM 服务接口(发请求、流式、工具调用等)。`,category:`LLM / Agent 核心`},{id:`llm-deepseek`,packageName:`@deepseek-ai/dsh-llm-deepseek-api-key`,roleZh:`DeepSeek API Key 模型适配。`,category:`LLM / Agent 核心`},{id:`llm-pi-ai`,packageName:`@deepseek-ai/dsh-llm-pi-ai`,roleZh:`Pi AI 等 LLM 适配。`,category:`LLM / Agent 核心`},{id:`llm-retry`,packageName:`@deepseek-ai/dsh-llm-retry`,roleZh:`LLM 调用失败重试策略。`,category:`LLM / Agent 核心`},{id:`session-title-llm`,packageName:`@deepseek-ai/dsh-session-title-first-prompt-llm`,roleZh:`用首条用户消息经 LLM 自动起会话标题。`,category:`LLM / Agent 核心`},{id:`subagent-fork-in-process`,packageName:`@deepseek-ai/dsh-subagent-fork-in-process`,roleZh:`进程内 fork 子代理实现。`,category:`LLM / Agent 核心`},{id:`subagent-model-selection-settings`,packageName:`@deepseek-ai/dsh-tool-subagent/model-selection-settings`,roleZh:`子代理可选模型的设置项。`,category:`LLM / Agent 核心`},{id:`subagent-spawn-in-process`,packageName:`@deepseek-ai/dsh-subagent-spawn-in-process`,roleZh:`进程内 spawn 子代理实现。`,category:`LLM / Agent 核心`},{id:`system-prompt`,packageName:`@deepseek-ai/dsh-system-prompt`,roleZh:`系统提示词拼装服务。`,category:`LLM / Agent 核心`},{id:`tools`,packageName:`@deepseek-ai/dsh-tools`,roleZh:`工具注册与执行总闸。`,category:`LLM / Agent 核心`}],x=c();function S(e){return String(e??``).replace(/(\s*dsh[^)]*)/gi,``).replace(/\(\s*dsh[^)]*\)/gi,``).replace(/\bdsh\b/gi,``).replace(/\s{2,}/g,` `).replace(/(\s*)/g,``).trim()}function C({status:e}){let t=e.tone===`ready`?`bg-emerald-50 text-emerald-700 border-emerald-100`:e.tone===`warn`?`bg-amber-50 text-amber-800 border-amber-100`:`bg-stone-100 text-stone-500 border-stone-200`;return(0,x.jsx)(`span`,{className:`shrink-0 rounded border px-1.5 py-0.5 text-[11px] ${t}`,children:e.label})}function Ce({tone:e}){return(0,x.jsx)(`span`,{"aria-hidden":`true`,className:`h-1.5 w-1.5 shrink-0 rounded-full ${e===`ready`?`bg-emerald-500`:e===`warn`?`bg-amber-500`:`bg-stone-300`}`})}function w({open:e}){return(0,x.jsx)(`svg`,{"aria-hidden":`true`,className:`h-3.5 w-3.5 shrink-0 text-stone-400 transition-transform duration-150 ${e?`rotate-90`:``}`,viewBox:`0 0 20 20`,fill:`currentColor`,children:(0,x.jsx)(`path`,{fillRule:`evenodd`,d:`M7.21 14.77a.75.75 0 01.02-1.06L11.17 10 7.23 6.29a.75.75 0 111.04-1.08l4.5 4.25a.75.75 0 010 1.08l-4.5 4.25a.75.75 0 01-1.06-.02z`,clipRule:`evenodd`})})}function we(){let[e,t]=(0,_.useState)(null),[n,r]=(0,_.useState)(null),[i,ee]=(0,_.useState)(null),[a,te]=(0,_.useState)(null),[o,ne]=(0,_.useState)(!0),[s,re]=(0,_.useState)(``),[ie,c]=(0,_.useState)({}),[ae,oe]=(0,_.useState)({});function se(e){c(t=>({...t,[e]:!t[e]}))}function ce(e){oe(t=>({...t,[e]:!t[e]}))}(0,_.useEffect)(()=>{let e=!0;return(async()=>{try{let[n,i,a,o]=await Promise.all([h(),m(),g(),ye()]);if(!e)return;t(n),r(i),ee(a),te(o)}finally{e&&ne(!1)}})(),()=>{e=!1}},[]);function l(t){let r=v(t.id);return r===`none`?{label:`规划中`,tone:`plan`}:r===`ready`?{label:`已就绪`,tone:`ready`}:o?{label:`探测中…`,tone:`plan`}:r===`web`?e?.ok?{label:`已就绪`,tone:`ready`}:{label:`需本地服务`,tone:`warn`}:r===`fs`?n?.ok?{label:`已就绪`,tone:`ready`}:{label:`需本地服务`,tone:`warn`}:r===`bash`?i?.ok?{label:`已就绪`,tone:`ready`}:{label:`需本地服务`,tone:`warn`}:r===`pwsh`?a?.ok&&a.available?{label:`已就绪`,tone:`ready`}:a?.ok?{label:`未装 PowerShell`,tone:`warn`}:{label:`需本地服务`,tone:`warn`}:{label:`规划中`,tone:`plan`}}let u=s.trim().toLowerCase(),le=e=>!u||e.id.toLowerCase().includes(u)||S(e.roleZh).toLowerCase().includes(u),ue=y.filter(le),de=b.filter(le),fe=[{id:`session`,title:`会话插件`,hint:`每个会话各自加载,随会话结束释放`,items:ue,total:y.length},{id:`global`,title:`全局插件`,hint:`由系统与所有会话共享,常驻运行`,items:de,total:b.length}];return(0,x.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,x.jsx)(`div`,{className:`shrink-0 px-6 pt-5 pb-3`,children:(0,x.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,x.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,x.jsx)(`h3`,{className:`text-[15px] font-semibold text-stone-900`,children:`内置插件`}),(0,x.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-stone-500`,children:`由平台按会话或全局提供,默认常开,不需要开关;状态取决于本机服务是否就绪。`})]}),(0,x.jsxs)(`label`,{className:`relative block w-44 shrink-0`,children:[(0,x.jsxs)(`svg`,{"aria-hidden":`true`,className:`pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-stone-400`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,children:[(0,x.jsx)(`circle`,{cx:`11`,cy:`11`,r:`7`}),(0,x.jsx)(`path`,{d:`m20 20-3.5-3.5`})]}),(0,x.jsx)(`input`,{value:s,onChange:e=>re(e.target.value),placeholder:`搜索插件名 / 作用`,className:`h-8 w-full rounded-lg border border-stone-200 bg-white pl-8 pr-2.5 text-xs text-stone-800 outline-none transition-colors placeholder:text-stone-400 focus:border-[#4176e6]`})]})]})}),(0,x.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 pb-6`,children:(0,x.jsx)(`div`,{className:`space-y-3`,children:fe.map(e=>{let t=!ie[e.id];return(0,x.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,x.jsxs)(`button`,{type:`button`,onClick:()=>se(e.id),"aria-expanded":t,className:`flex w-full items-center gap-2 px-3.5 py-2.5 text-left transition-colors hover:bg-stone-50/70`,children:[(0,x.jsx)(w,{open:t}),(0,x.jsx)(`h4`,{className:`text-[13px] font-medium text-stone-700`,children:e.title}),(0,x.jsx)(`span`,{className:`text-[11px] tabular-nums text-stone-400`,children:u?`${e.items.length}/${e.total}`:e.total}),(0,x.jsx)(`span`,{className:`ml-auto truncate text-[11px] text-stone-400`,children:e.hint})]}),t?e.items.length?(0,x.jsx)(`div`,{className:`grid grid-cols-2 items-start gap-2 border-t border-stone-100 p-2.5`,children:e.items.map(t=>{let n=l(t),r=`${e.id}:${t.id}`,i=!!ae[r];return(0,x.jsxs)(`div`,{role:`button`,tabIndex:0,"aria-expanded":i,onClick:()=>ce(r),onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),ce(r))},className:`flex cursor-pointer flex-col rounded-lg border p-2.5 text-left transition-colors ${i?`border-[#4176e6]/40 bg-[#f6f9ff]`:`border-stone-200 bg-white hover:border-stone-300 hover:bg-stone-50/60`}`,children:[(0,x.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,x.jsx)(`span`,{className:`mt-1.5`,children:(0,x.jsx)(Ce,{tone:n.tone})}),(0,x.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,x.jsx)(`p`,{className:`truncate font-mono text-[12.5px] text-stone-800`,children:t.id}),(0,x.jsx)(`p`,{className:`mt-0.5 text-[11.5px] leading-5 text-stone-500 ${i?``:`line-clamp-2`}`,children:S(t.roleZh)})]}),(0,x.jsxs)(`div`,{className:`flex shrink-0 flex-col items-end gap-1.5`,children:[(0,x.jsx)(C,{status:n}),(0,x.jsx)(w,{open:i})]})]}),i?(0,x.jsxs)(`dl`,{className:`mt-2 grid w-full grid-cols-[auto_1fr] gap-x-2 gap-y-1 border-t border-stone-200/70 pt-2 text-[11px]`,children:[(0,x.jsx)(`dt`,{className:`shrink-0 text-stone-400`,children:`分类`}),(0,x.jsx)(`dd`,{className:`truncate text-stone-600`,children:t.category}),(0,x.jsx)(`dt`,{className:`shrink-0 text-stone-400`,children:`npm 包`}),(0,x.jsx)(`dd`,{className:`truncate font-mono text-stone-600`,children:t.packageName||`—`})]}):null]},r)})}):(0,x.jsx)(`p`,{className:`border-t border-stone-100 px-3.5 py-4 text-center text-xs text-stone-400`,children:`没有匹配的内置插件`}):null]},e.id)})})})]})}function Te(e){try{return new URL(e).host}catch{return``}}var Ee=[{value:`zh-CN`,label:`中文`},{value:`en`,label:`English`}],T=`w-full px-3 py-2 text-sm border border-stone-300 rounded-lg bg-white focus:outline-none focus:ring-2 focus:ring-[#4176e6]/35 focus:border-[#4176e6] transition-colors`,E=`inline-flex items-center gap-1.5 h-9 min-w-30 px-3 rounded-lg bg-stone-100 text-sm text-stone-700 hover:bg-stone-200/80 transition-colors outline-none focus:outline-none`;function De({className:e=`w-3.5 h-3.5`}){return(0,x.jsx)(`svg`,{className:e,viewBox:`0 0 20 20`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,children:(0,x.jsx)(`path`,{d:`M6 8l4 4 4-4`,strokeLinecap:`round`,strokeLinejoin:`round`})})}function Oe({className:e=`w-4 h-4`}){return(0,x.jsx)(`svg`,{className:e,viewBox:`0 0 20 20`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,children:(0,x.jsx)(`path`,{d:`M5 10.5l3.5 3.5L15 6.5`,strokeLinecap:`round`,strokeLinejoin:`round`})})}function ke({className:e=`w-4 h-4`}){return(0,x.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:[(0,x.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`}),(0,x.jsx)(`path`,{d:`M12 1v2M12 21v2M4.2 4.2l1.4 1.4M18.4 18.4l1.4 1.4M1 12h2M21 12h2M4.2 19.8l1.4-1.4M18.4 5.6l1.4-1.4`})]})}function Ae({className:e=`w-4 h-4`}){return(0,x.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:[(0,x.jsx)(`ellipse`,{cx:`12`,cy:`5`,rx:`8`,ry:`3`}),(0,x.jsx)(`path`,{d:`M4 5v6c0 1.7 3.6 3 8 3s8-1.3 8-3V5`}),(0,x.jsx)(`path`,{d:`M4 11v6c0 1.7 3.6 3 8 3s8-1.3 8-3v-6`})]})}function je({className:e=`w-4 h-4`}){return(0,x.jsx)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:(0,x.jsx)(`path`,{d:`M10 4a2 2 0 0 1 4 0v1h3a1 1 0 0 1 1 1v3h1a2 2 0 0 1 0 4h-1v3a1 1 0 0 1-1 1h-3v1a2 2 0 0 1-4 0v-1H7a1 1 0 0 1-1-1v-3H5a2 2 0 0 1 0-4h1V6a1 1 0 0 1 1-1h3V4z`})})}function Me({kind:e}){let t=`w-5 h-5`;return e===`sun`?(0,x.jsxs)(`svg`,{className:t,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:[(0,x.jsx)(`circle`,{cx:`12`,cy:`12`,r:`4`}),(0,x.jsx)(`path`,{d:`M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4`})]}):e===`moon`?(0,x.jsx)(`svg`,{className:t,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:(0,x.jsx)(`path`,{d:`M21 14.5A8.5 8.5 0 1 1 9.5 3a7 7 0 0 0 11.5 11.5z`})}):(0,x.jsxs)(`svg`,{className:t,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:[(0,x.jsx)(`rect`,{x:`3`,y:`4`,width:`18`,height:`12`,rx:`2`}),(0,x.jsx)(`path`,{d:`M8 20h8M12 16v4`})]})}function D({title:e,description:t,control:n}){return(0,x.jsxs)(`div`,{className:`flex items-center gap-4 py-4 border-b border-stone-100 last:border-b-0`,children:[(0,x.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,x.jsx)(`div`,{className:`text-sm font-medium text-stone-800`,children:e}),t?(0,x.jsx)(`div`,{className:`mt-0.5 text-xs text-stone-400 leading-5`,children:t}):null]}),(0,x.jsx)(`div`,{className:`shrink-0`,children:n})]})}function O({value:e,options:t,onChange:n}){let r=t.find(t=>t.value===e)?.label??e;return(0,x.jsxs)(ne,{value:e,onChange:n,children:[(0,x.jsxs)(te,{className:E,children:[(0,x.jsx)(`span`,{className:`flex-1 text-left truncate`,children:r}),(0,x.jsx)(De,{className:`w-3.5 h-3.5 text-stone-400 shrink-0`})]}),(0,x.jsx)(s,{transition:!0,anchor:{to:`bottom end`,gap:6},className:`tw-select-menu tw-menu-anim z-60 min-w-40 rounded-xl py-1 shadow-lg ring-1 ring-stone-200 focus:outline-none`,children:t.map(e=>(0,x.jsxs)(o,{value:e.value,className:`group cursor-pointer select-none flex items-center justify-between gap-3 px-3 py-2 text-sm text-stone-700 data-[focus]:bg-stone-50 data-[selected]:text-stone-900`,children:[(0,x.jsx)(`span`,{children:e.label}),(0,x.jsx)(Oe,{className:`w-4 h-4 text-[#4176e6] opacity-0 group-data-[selected]:opacity-100 shrink-0`})]},e.value))})]})}function k(){let[e,t]=(0,_.useState)(!1),[c,m]=(0,_.useState)(`general`),[h,g]=(0,_.useState)(()=>ee().model.providers),[ye,v]=(0,_.useState)(()=>ee().model.activeId),[y,b]=(0,_.useState)(null),[S,C]=(0,_.useState)(``),[Ce,w]=(0,_.useState)(`DeepSeek`),[E,k]=(0,_.useState)(``),[A,Ne]=(0,_.useState)(``),[j,M]=(0,_.useState)(``),[N,Pe]=(0,_.useState)([]),[P,F]=(0,_.useState)(`idle`),[Fe,Ie]=(0,_.useState)(!1),[Le,Re]=(0,_.useState)(`readonly`),[ze,Be]=(0,_.useState)(!1),[Ve,I]=(0,_.useState)(!1),[He,Ue]=(0,_.useState)(null),[L,R]=(0,_.useState)({language:`zh-CN`,appearance:`system`,sessionFontSize:14,toolStepDetail:`standard`,busySendBehavior:`queue`,subagentModel:``}),[We,z]=(0,_.useState)(`14`),Ge=(0,_.useRef)(0),[B,Ke]=(0,_.useState)(null),[qe,Je]=(0,_.useState)(!1),[Ye,Xe]=(0,_.useState)(!1),[Ze,V]=(0,_.useState)(!1),[Qe,H]=(0,_.useState)(``),U=(0,_.useRef)(null),$e=(0,_.useRef)(!1),W=y!==null,G=L.language,K=h.find(e=>e.id===ye),q=(K?.name||``).trim(),J=B?.status??null,et=J?.phase===`done`&&!!J.to&&J.to===B?.current&&be!==B?.current&&Date.now()-Date.parse(J.finishedAt||``)<864e5,tt=J?.phase===`failed`?J.error:``,Y=Ze||J?.phase===`installing`||J?.phase===`restarting`,nt=(J?.to||B?.latest||``).replace(/^v/,``),X=tt||Qe,rt=B?.checkedAt&&!Y?new Date(B.checkedAt).toLocaleTimeString():``,it=qe?``:Y?J?.phase===`restarting`?p(`settings.updateRestarting`,void 0,G):p(`settings.updateInstalling`,{v:nt},G):X?`${p(`settings.updateFailed`,void 0,G)}:${X}`:et?p(`settings.updateDone`,{v:J?.to||``},G):B?.mode===`dev`&&B?.hasUpdate?p(`settings.updateDevMode`,void 0,G):B?.error?`${p(`settings.updateUnavailable`,void 0,G)}:${B.error}`:B?.hasUpdate?B.mode===`npx`?p(`settings.updateNpxHint`,void 0,G):``:B?`${p(`settings.updateLatest`,void 0,G)}${rt?` · ${p(`settings.updateCheckedAt`,{time:rt},G)}`:``}`:Ye?p(`settings.updateUnavailable`,void 0,G):``,at=q||(G===`en`?`No model`:`未配置`),ot=q?K?.model?.trim()?`${q} · ${K.model.trim()}`:q:G===`en`?`No model configured`:`未配置模型`;function st(e=`general`){m(e),r().then(()=>{ct(),t(!0)})}function ct(){Be(n()),g(u()),v(l()),I(!!d()),R(he()),me(he()),Re(pe()),b(null)}function Z(){U.current!==null&&(window.clearInterval(U.current),U.current=null)}async function lt(e=!0){Je(!0);try{let t=await Se(e);t&&(Ke(t),H(``))}finally{Je(!1),Xe(!0)}}function ut(e){Z();let t=Date.now()+18e4;U.current=window.setInterval(async()=>{if(!$e.current){$e.current=!0;try{let n=await Se(!0);if(n){Ke(n);let t=n.status;if(t?.phase===`failed`){Z(),V(!1),H(t.error||p(`settings.updateFailed`,void 0,G));return}if(t?.phase===`done`||e&&n.current!==e){Z(),V(!1);return}}Date.now()>t&&(Z(),V(!1),H(p(`settings.updateTimeout`,void 0,G)))}finally{$e.current=!1}}},1500)}async function dt(){let e=B?.latest||``;H(``),V(!0);let t=B?.current||be,n=await xe(e||void 0);n.ok?ut(t):(V(!1),H(n.error||p(`settings.updateFailed`,void 0,G)))}function ft(e){if(!e){let e=a();b(e),C(`DeepSeek`),w(`DeepSeek`),k(`https://api.deepseek.com/v1`),Ne(``),M(``),Pe([]),F(`idle`),Ie(!1);return}b(e.id),C(e.name),k(e.baseURL);let t=e.apiKey?.trim()||(e.id===l()?i().trim():``)||``;Ne(t),M(e.model),Pe(e.availableModels??[]),F(e.availableModels?.length?`ok`:`idle`),w(f.find(t=>t.baseURL===e.baseURL)?.label??`自定义`),Ie(!1)}(0,_.useEffect)(()=>{r().then(()=>ct());let e=e=>{let n=e.detail;m(n?.tab===`model`?`model`:n?.tab===`builtin`?`builtin`:`general`),r().then(()=>{ct(),t(!0)})};window.addEventListener(ge,e);let n=le(e=>R(e)),i=_e(e=>Re(e));return()=>{window.removeEventListener(ge,e),n(),i()}},[]),(0,_.useEffect)(()=>{if(e)return(async()=>{let e=await Se(!1);if(Xe(!0),!e)return;Ke(e);let t=e.status;(t?.phase===`installing`||t?.phase===`restarting`)&&(V(!0),ut(t.from||e.current))})(),Z},[e]),(0,_.useEffect)(()=>{if(!e||c!==`model`||!W)return;let t=E.trim(),n=A.trim();if(!t||!n){F(e=>e===`ok`?`ok`:`idle`);return}F(`loading`);let r=++Ge.current,i=setTimeout(()=>{se(t,n).then(e=>{r===Ge.current&&(Pe(e),F(`ok`))}).catch(()=>{r===Ge.current&&F(`fail`)})},800);return()=>clearTimeout(i)},[e,c,W,E,A]);function pt(e){w(e);let t=f.find(t=>t.label===e);t&&(t.baseURL&&k(t.baseURL),(!S.trim()||f.some(e=>e.label===S))&&C(t.label)),M(``)}function Q(e){R(ue(e))}(0,_.useEffect)(()=>{z(String(L.sessionFontSize))},[L.sessionFontSize]);function mt(){let e=Number(We);if(!We.trim()||!Number.isFinite(e)){z(String(L.sessionFontSize));return}let t=ue({sessionFontSize:Math.round(e)});R(t),z(String(t.sessionFontSize))}let ht=!!(S.trim()&&E.trim()&&A.trim()&&j.trim()),$=N.length>0;function gt(){if(!ht||!y)return;let e=!h.some(e=>e.id===y),t=ve({id:y,name:S.trim(),baseURL:E.trim(),apiKey:A.trim(),model:j.trim(),availableModels:$?N:void 0},{activate:!0});g(t),v(y),b(null),I(!!d()),oe(e?`已新增模型服务`:`已保存模型服务`,`success`)}function _t(e){Ue(e)}function vt(){let e=He;if(!e)return;let t=h.find(t=>t.id===e)?.name??`该服务`;Ue(null);let n=fe(e);g(n),v(l()),y===e&&b(null),I(!!d()),oe(`已删除模型服务「${t}」`,`success`)}function yt(e){ce(e),v(e),I(!!d())}let bt=[{value:`readonly`,label:p(`settings.access.readonly`,void 0,G)},{value:`readwrite`,label:p(`settings.access.readwrite`,void 0,G)},{value:`full`,label:p(`settings.access.full`,void 0,G)}],xt=[{value:`concise`,label:p(`settings.step.concise`,void 0,G)},{value:`standard`,label:p(`settings.step.standard`,void 0,G)},{value:`detailed`,label:p(`settings.step.detailed`,void 0,G)},{value:`full`,label:p(`settings.step.full`,void 0,G)}],St=[{value:`queue`,label:p(`settings.busySend.queue`,void 0,G)},{value:`interrupt`,label:p(`settings.busySend.interrupt`,void 0,G)}],Ct=[{value:`light`,label:p(`settings.appear.light`,void 0,G),icon:`sun`},{value:`dark`,label:p(`settings.appear.dark`,void 0,G),icon:`moon`},{value:`system`,label:p(`settings.appear.system`,void 0,G),icon:`monitor`}],wt=[{id:`general`,label:p(`settings.general`,void 0,G),icon:(0,x.jsx)(ke,{})},{id:`model`,label:p(`settings.model`,void 0,G),icon:(0,x.jsx)(Ae,{})},{id:`builtin`,label:p(`settings.builtin`,void 0,G),icon:(0,x.jsx)(je,{})}],Tt=c===`general`||c===`builtin`?p(c===`general`?`settings.general`:`settings.builtin`,void 0,G):W?h.some(e=>e.id===y)?p(`settings.editProvider`,void 0,G):p(`settings.addProviderTitle`,void 0,G):p(`settings.model`,void 0,G);return(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(`div`,{className:`tw-nav-foot-row`,children:[(0,x.jsxs)(`button`,{type:`button`,onClick:()=>st(`general`),className:`tw-nav-settings-btn`,"data-hint":Ve?`设置(已配置模型)`:`设置`,children:[(0,x.jsxs)(`svg`,{className:`tw-nav-ico w-4.5 h-4.5 shrink-0`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,"aria-hidden":`true`,children:[(0,x.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`}),(0,x.jsx)(`path`,{d:`M19.4 15a1.7 1.7 0 0 0 .3 1.8l.1.1a2 2 0 1 1-2.8 2.8l-.1-.1a1.7 1.7 0 0 0-1.8-.3 1.7 1.7 0 0 0-1 1.5V21a2 2 0 1 1-4 0v-.1a1.7 1.7 0 0 0-1-1.5 1.7 1.7 0 0 0-1.8.3l-.1.1a2 2 0 1 1-2.8-2.8l.1-.1a1.7 1.7 0 0 0 .3-1.8 1.7 1.7 0 0 0-1.5-1H3a2 2 0 1 1 0-4h.1a1.7 1.7 0 0 0 1.5-1 1.7 1.7 0 0 0-.3-1.8l-.1-.1a2 2 0 1 1 2.8-2.8l.1.1a1.7 1.7 0 0 0 1.8.3H9a1.7 1.7 0 0 0 1-1.5V3a2 2 0 1 1 4 0v.1a1.7 1.7 0 0 0 1 1.5 1.7 1.7 0 0 0 1.8-.3l.1-.1a2 2 0 1 1 2.8 2.8l-.1.1a1.7 1.7 0 0 0-.3 1.8V9c.2.6.7 1 1.5 1H21a2 2 0 1 1 0 4h-.1a1.7 1.7 0 0 0-1.5 1z`})]}),(0,x.jsx)(`span`,{"data-i18n":`nav.settings`,children:p(`nav.settings`,void 0,G)})]}),(0,x.jsxs)(`button`,{type:`button`,className:`tw-nav-provider-chip${q?``:` is-empty`}`,"data-hint":ot,onClick:()=>st(`model`),children:[(0,x.jsx)(`span`,{className:`tw-nav-provider-dot`,"aria-hidden":`true`}),(0,x.jsx)(`span`,{className:`tw-nav-provider-name`,children:at})]})]}),(0,x.jsx)(re,{show:e,children:(0,x.jsxs)(`div`,{className:`fixed inset-0 z-110 flex items-center justify-center p-4`,children:[(0,x.jsx)(ie,{children:(0,x.jsx)(`div`,{className:`tw-dialog-backdrop-anim absolute inset-0 bg-stone-950/45`,onClick:()=>t(!1),"aria-hidden":`true`})}),(0,x.jsx)(ie,{children:(0,x.jsxs)(`div`,{className:`tw-settings-dialog tw-dialog-panel-anim relative bg-white rounded-2xl shadow-2xl w-full max-w-3xl h-[min(92vh,720px)] overflow-hidden flex flex-col`,children:[(0,x.jsxs)(`div`,{className:`shrink-0 h-12 px-4 flex items-center justify-between border-b border-stone-100 bg-white`,children:[(0,x.jsx)(`h2`,{className:`text-sm font-semibold text-stone-800 truncate pr-3`,children:Tt}),(0,x.jsx)(`button`,{type:`button`,"aria-label":p(`settings.close`,void 0,G),onClick:()=>t(!1),className:`w-8 h-8 inline-flex items-center justify-center rounded-lg text-stone-400 hover:text-stone-700 hover:bg-stone-100 transition-colors`,children:(0,x.jsx)(`svg`,{className:`w-4 h-4`,viewBox:`0 0 20 20`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:(0,x.jsx)(`path`,{d:`M5 5l10 10M15 5L5 15`,strokeLinecap:`round`})})})]}),(0,x.jsxs)(`div`,{className:`flex-1 min-h-0 flex`,children:[(0,x.jsx)(`aside`,{className:`w-38 shrink-0 border-r border-stone-100 bg-[#f4f5f7] py-3 px-2 space-y-0.5`,children:wt.map(e=>{let t=c===e.id;return(0,x.jsxs)(`button`,{type:`button`,onClick:()=>{m(e.id),e.id===`model`&&b(null)},className:`w-full flex items-center gap-2 px-3 py-2.5 rounded-lg text-sm transition-colors ${t?`bg-[#e8f0fe] text-[#4176e6] font-medium`:`text-stone-600 hover:bg-white/70 hover:text-stone-800`}`,children:[(0,x.jsx)(`span`,{className:t?`text-[#4176e6]`:`text-stone-400`,children:e.icon}),e.label]},e.id)})}),(0,x.jsx)(`div`,{className:`flex-1 min-w-0 flex flex-col min-h-0 bg-white`,children:c===`general`?(0,x.jsxs)(`div`,{className:`flex-1 min-h-0 flex flex-col`,children:[(0,x.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-6 py-1`,children:[(0,x.jsx)(D,{title:p(`settings.access`,void 0,G),description:p(`settings.accessDesc`,void 0,G),control:(0,x.jsx)(O,{value:Le,options:bt,onChange:e=>{Re(e),de(e)}})}),(0,x.jsx)(D,{title:p(`settings.language`,void 0,G),control:(0,x.jsx)(O,{value:L.language,options:Ee,onChange:e=>Q({language:e})})}),(0,x.jsxs)(`div`,{className:`py-4 border-b border-stone-100`,children:[(0,x.jsx)(`div`,{className:`text-sm font-medium text-stone-800 mb-3`,children:p(`settings.appearance`,void 0,G)}),(0,x.jsx)(`div`,{className:`grid grid-cols-3 gap-2.5`,children:Ct.map(e=>{let t=L.appearance===e.value;return(0,x.jsxs)(`button`,{type:`button`,onClick:()=>Q({appearance:e.value}),className:`flex flex-col items-center justify-center gap-2 h-19 rounded-xl border transition-colors ${t?`border-[#4176e6] bg-[#edf3fe] text-[#4176e6] ring-1 ring-[#4176e6]/30`:`border-stone-200 text-stone-500 hover:border-stone-300 hover:bg-stone-50`}`,children:[(0,x.jsx)(Me,{kind:e.icon}),(0,x.jsx)(`span`,{className:`text-xs font-medium`,children:e.label})]},e.value)})})]}),(0,x.jsx)(D,{title:p(`settings.fontSize`,void 0,G),description:p(`settings.fontSizeDesc`,void 0,G),control:(0,x.jsxs)(`div`,{className:`inline-flex items-center gap-1.5`,children:[(0,x.jsx)(`input`,{type:`number`,min:12,max:22,value:We,onChange:e=>z(e.target.value),onBlur:mt,onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur()},className:`w-14 h-9 px-2 text-sm text-center rounded-lg bg-stone-100 border-0 outline-none focus:ring-2 focus:ring-[#4176e6]/30`}),(0,x.jsx)(`span`,{className:`text-sm text-stone-400`,children:`px`})]})}),(0,x.jsx)(D,{title:p(`settings.toolSteps`,void 0,G),description:p(`settings.toolStepsDesc`,void 0,G),control:(0,x.jsx)(O,{value:L.toolStepDetail,options:xt,onChange:e=>Q({toolStepDetail:e})})}),(0,x.jsx)(D,{title:p(`settings.busySend`,void 0,G),description:p(`settings.busySendDesc`,void 0,G),control:(0,x.jsx)(O,{value:L.busySendBehavior,options:St,onChange:e=>Q({busySendBehavior:e})})}),(0,x.jsx)(D,{title:p(`settings.subagentModel`,void 0,G),description:p(`settings.subagentModelDesc`,void 0,G),control:(0,x.jsx)(O,{value:L.subagentModel?.trim()?L.subagentModel:`inherit`,options:[{value:`inherit`,label:p(`settings.subagentModel.inherit`,void 0,G)},...Array.from(new Set([...K?.availableModels??[],...K?.model?[K.model]:[]])).filter(Boolean).map(e=>({value:e,label:e}))],onChange:e=>Q({subagentModel:e===`inherit`?``:e})})})]}),(0,x.jsxs)(`div`,{className:`shrink-0 px-6 py-3 border-t border-stone-100`,children:[(0,x.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,x.jsxs)(`div`,{className:`min-w-0 flex items-center gap-2`,children:[(0,x.jsx)(`span`,{className:`text-sm text-stone-700 whitespace-nowrap`,children:p(`settings.platformVersion`,void 0,G)}),(0,x.jsxs)(`span`,{className:`text-sm tabular-nums text-stone-500`,children:[`v`,be]}),B?.hasUpdate&&!Y&&!et?(0,x.jsx)(`span`,{className:`inline-flex items-center h-[18px] px-1.5 rounded-full bg-[#edf3fe] text-[11px] font-medium text-[#4176e6] tabular-nums whitespace-nowrap`,children:`${p(`settings.updateAvailable`,void 0,G)} v${(B.latest||``).replace(/^v/,``)}`}):null]}),(0,x.jsx)(`div`,{className:`shrink-0 flex items-center gap-2`,children:Y?(0,x.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 h-8 px-3 rounded-lg text-xs text-stone-500 bg-stone-100 whitespace-nowrap`,children:[(0,x.jsx)(`span`,{className:`w-3 h-3 rounded-full border-2 border-stone-300 border-t-[#4176e6] animate-spin`}),p(`settings.updateWorking`,void 0,G)]}):et?(0,x.jsx)(`button`,{type:`button`,onClick:()=>window.location.reload(),className:`h-8 px-3 rounded-lg text-xs font-medium text-[#4176e6] bg-[#edf3fe] hover:bg-[#e2ecfd] whitespace-nowrap`,children:p(`settings.updateReload`,void 0,G)}):(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(`button`,{type:`button`,disabled:qe,onClick:()=>void lt(!0),className:`inline-flex items-center justify-center min-w-[76px] h-8 px-3 rounded-lg text-xs font-medium text-stone-600 bg-stone-100 hover:bg-stone-200 disabled:opacity-70 disabled:cursor-default whitespace-nowrap`,children:qe?(0,x.jsxs)(x.Fragment,{children:[p(`settings.updateChecking`,void 0,G),(0,x.jsxs)(`span`,{className:`tw-dots`,"aria-hidden":`true`,children:[(0,x.jsx)(`i`,{}),(0,x.jsx)(`i`,{}),(0,x.jsx)(`i`,{})]})]}):p(`settings.updateCheck`,void 0,G)}),B?.hasUpdate?(0,x.jsx)(`button`,{type:`button`,disabled:B.mode===`dev`,onClick:()=>void dt(),className:`h-8 px-3 rounded-lg text-xs font-semibold text-white bg-[#4176e6] hover:bg-[#3566d6] disabled:opacity-50 disabled:cursor-not-allowed whitespace-nowrap`,children:p(`settings.updateNow`,void 0,G)}):null]})})]}),it?(0,x.jsx)(`div`,{className:`mt-1 text-[11px] leading-relaxed ${X?`text-red-500`:`text-stone-400`}`,children:it}):null,X&&B?.logPath?(0,x.jsx)(`div`,{className:`mt-0.5 text-[11px] leading-relaxed text-stone-400 break-all`,children:p(`settings.updateLog`,{path:B.logPath},G)}):null]})]}):W?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(`div`,{className:`shrink-0 px-5 pt-3 pb-2 flex items-center gap-2 border-b border-stone-100`,children:(0,x.jsx)(`button`,{type:`button`,onClick:()=>b(null),className:`text-sm text-stone-500 hover:text-stone-800`,children:p(`settings.back`,void 0,G)})}),(0,x.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-5 py-4 space-y-4`,children:[(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`label`,{className:`block text-xs font-medium text-stone-500 mb-1.5`,children:p(`settings.displayName`,void 0,G)}),(0,x.jsx)(`input`,{type:`text`,value:S,onChange:e=>C(e.target.value),placeholder:`DeepSeek`,className:T})]}),(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`label`,{className:`block text-xs font-medium text-stone-500 mb-1.5`,children:p(`settings.preset`,void 0,G)}),(0,x.jsx)(`div`,{className:`grid grid-cols-2 gap-2`,children:f.map(e=>{let t=Ce===e.label;return(0,x.jsxs)(`button`,{type:`button`,onClick:()=>pt(e.label),className:`text-left px-3 py-2 rounded-lg border transition-colors ${t?`border-[#4176e6] bg-[#edf3fe] ring-1 ring-[#4176e6]/30`:`border-stone-200 hover:border-stone-300 hover:bg-stone-50`}`,children:[(0,x.jsx)(`div`,{className:`text-sm ${t?`text-[#3565c7] font-medium`:`text-stone-700`}`,children:e.label}),(0,x.jsx)(`div`,{className:`text-[11px] text-stone-400 truncate`,children:e.baseURL?Te(e.baseURL):`OpenAI compatible`})]},e.label)})})]}),(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`label`,{className:`block text-xs font-medium text-stone-500 mb-1.5`,children:p(`settings.baseUrl`,void 0,G)}),(0,x.jsx)(`input`,{type:`text`,value:E,onChange:e=>k(e.target.value),placeholder:`https://api.deepseek.com/v1`,className:T})]}),(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`label`,{className:`block text-xs font-medium text-stone-500 mb-1.5`,children:p(`settings.apiKey`,void 0,G)}),(0,x.jsxs)(`div`,{className:`relative`,children:[(0,x.jsx)(`input`,{type:Fe?`text`:`password`,value:A,onChange:e=>Ne(e.target.value),placeholder:`sk-...`,className:`${T} pr-14`}),(0,x.jsx)(`button`,{type:`button`,onClick:()=>Ie(e=>!e),className:`absolute right-2 top-1/2 -translate-y-1/2 text-[11px] text-stone-400 hover:text-stone-600 px-1.5 py-1`,children:Fe?G===`en`?`Hide`:`隐藏`:G===`en`?`Show`:`显示`})]}),ze?(0,x.jsx)(`p`,{className:`mt-1.5 text-[11px] text-stone-400 leading-5`,children:p(`settings.keyHint`,void 0,G)}):null]}),(0,x.jsxs)(`div`,{children:[(0,x.jsxs)(`div`,{className:`flex items-center justify-between mb-1.5`,children:[(0,x.jsx)(`label`,{className:`text-xs font-medium text-stone-500`,children:p(`settings.modelField`,void 0,G)}),P===`loading`&&(0,x.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:p(`settings.recognizing`,void 0,G)}),$&&P===`ok`&&(0,x.jsx)(`span`,{className:`text-[11px] text-emerald-600`,children:p(`settings.recognized`,{n:N.length},G)}),P===`fail`&&!$&&(0,x.jsx)(`span`,{className:`text-[11px] text-amber-600`,children:p(`settings.recognizeFail`,void 0,G)}),P===`fail`&&$&&(0,x.jsx)(`span`,{className:`text-[11px] text-amber-600`,children:p(`settings.recognizeKeep`,void 0,G)})]}),$?(0,x.jsxs)(ne,{value:j,onChange:M,children:[(0,x.jsxs)(te,{className:`${T} flex items-center justify-between text-left hover:border-stone-400 cursor-pointer`,children:[(0,x.jsx)(`span`,{className:`truncate text-stone-800`,children:j||(G===`en`?`Select a model`:`请选择模型`)}),(0,x.jsx)(De,{className:`w-4 h-4 shrink-0 ml-2 text-stone-400`})]}),(0,x.jsx)(s,{transition:!0,anchor:{to:`bottom start`,gap:6},className:`tw-select-menu tw-menu-anim z-60 w-(--button-width) max-h-60 overflow-auto rounded-lg py-1 shadow-lg ring-1 ring-stone-200 focus:outline-none`,children:N.map(e=>(0,x.jsxs)(o,{value:e,className:`group cursor-pointer select-none flex items-center justify-between px-3 py-2 text-sm text-stone-700 data-[focus]:bg-[#edf3fe] data-[selected]:text-[#3565c7] data-[selected]:font-medium`,children:[(0,x.jsx)(`span`,{className:`truncate`,children:e}),(0,x.jsx)(Oe,{className:`w-4 h-4 text-[#4176e6] opacity-0 group-data-[selected]:opacity-100 shrink-0 ml-2`})]},e))})]}):(0,x.jsx)(`input`,{type:`text`,value:j,onChange:e=>M(e.target.value),placeholder:p(`settings.modelPlaceholder`,void 0,G),className:T})]})]}),(0,x.jsxs)(`div`,{className:`shrink-0 px-5 py-3.5 bg-stone-50 border-t border-stone-100 flex justify-end gap-2`,children:[(0,x.jsx)(`button`,{type:`button`,onClick:()=>b(null),className:`px-3.5 py-1.5 text-sm text-stone-600 hover:bg-stone-200/60 rounded-lg`,children:p(`settings.cancel`,void 0,G)}),(0,x.jsx)(`button`,{type:`button`,onClick:gt,disabled:!ht,className:`px-3.5 py-1.5 text-sm font-medium text-white bg-[#4176e6] hover:bg-[#3565c7] rounded-lg disabled:opacity-40 disabled:cursor-not-allowed`,children:p(`settings.save`,void 0,G)})]})]}):c===`builtin`?(0,x.jsx)(we,{}):(0,x.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-6 py-5 bg-[#f4f5f7]`,children:[(0,x.jsx)(`p`,{className:`text-sm text-stone-500`,children:p(`settings.modelIntro`,void 0,G)}),(0,x.jsxs)(`div`,{className:`mt-5 space-y-2.5`,children:[h.map(e=>{let t=!!(e.apiKey?.trim()&&e.baseURL.trim()&&e.model.trim()),n=e.id===ye;return(0,x.jsxs)(`div`,{className:`flex items-center gap-3 rounded-xl border border-stone-200/90 bg-white px-4 py-3.5 shadow-[0_1px_0_rgba(15,23,42,0.02)]`,children:[(0,x.jsxs)(`button`,{type:`button`,"data-hint":n?G===`en`?`Active`:`当前使用`:G===`en`?`Set active`:`设为当前`,onClick:()=>yt(e.id),className:`flex-1 min-w-0 flex items-center gap-2 text-left`,children:[(0,x.jsx)(`span`,{className:`text-sm font-medium text-stone-800 truncate`,children:e.name}),t?(0,x.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full shrink-0 bg-emerald-500`}):null]}),(0,x.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0`,children:[(0,x.jsx)(`button`,{type:`button`,onClick:()=>ft(e),className:`h-8 px-3 text-sm text-stone-700 rounded-lg border border-stone-200 bg-white hover:bg-stone-50`,children:p(`settings.edit`,void 0,G)}),h.length>1?(0,x.jsx)(`button`,{type:`button`,onClick:()=>_t(e.id),className:`h-8 px-3 text-sm text-red-600 rounded-lg hover:bg-red-50`,children:p(`settings.delete`,void 0,G)}):null]})]},e.id)}),(0,x.jsx)(`button`,{type:`button`,onClick:()=>ft(null),className:`w-full h-12 rounded-xl border border-dashed border-stone-300 bg-white/60 text-sm text-stone-600 hover:border-[#4176e6] hover:text-[#4176e6] hover:bg-[#edf3fe]/50 transition-colors`,children:p(`settings.addProvider`,void 0,G)})]})]})})]})]})})]})}),(0,x.jsx)(ae,{open:He!=null,title:p(`settings.delete`,void 0,G),message:p(`settings.deleteConfirm`,void 0,G),confirmLabel:p(`settings.delete`,void 0,G),cancelLabel:G===`en`?`Cancel`:`取消`,danger:!0,onClose:()=>Ue(null),onConfirm:vt})]})}export{k as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as e,t}from"./react.Blvh0GOs.js";import{i as n}from"./app-config.CF1xVPmo.js";import{i as r,o as i,s as ee}from"./plugins.DYyAjBXb.js";import{a,n as o,o as s,r as c}from"./view-prefs.D1snIG5o.js";import{i as l,n as u,r as d,t as f}from"./dialog.DZHZCe_T.js";import{t as p}from"./jsx-runtime.DUg_B_vD.js";import{t as m}from"./ConfirmDialog.CsMwWevK.js";import{c as h,d as g,i as _,l as v,n as y,o as b,t as x}from"./ColumnResize.BgYkV9Iy.js";import{t as S}from"./DatePicker.Bkl71M49.js";import{t as C}from"./SelectDropdown.Cb-QtC-D.js";import{showToast as w}from"./Toast.BO2NFckG.js";import{A as T,C as E,D as te,P as ne,a as D,b as O,c as re,f as ie,g as ae,h as oe,i as k,m as se,n as A,o as ce,p as le,r as ue,s as de,t as j,u as fe}from"./tasks.otRBFydq.js";import{a as M,l as N,n as P,o as F,r as I,s as L,t as R}from"./DrawerField.C0ehOlDt.js";var z=e(t(),1),B=p(),pe=8e3,V=[{key:`title`,width:280,min:200},{key:`status`,width:104,min:80},{key:`priority`,width:104,min:88},{key:`start`,width:108,min:88},{key:`due`,width:108,min:88},{key:`cycle`,width:76,min:60},{key:`todos`,width:84,min:68},{key:`progress`,width:132,min:104},{key:`note`,width:140,min:88},{key:`filler`,filler:!0},{key:`action`,width:76,min:64}],me={pool:`bg-stone-100 text-stone-600`,in_progress:`bg-[#e1eaff] text-[#1f4ec2]`,done:`bg-[#d9f5d2] text-[#1d7a12]`,closed:`bg-stone-100 text-stone-400`,cancelled:`bg-stone-100 text-stone-400 line-through`},he={urgent_important:`bg-[#f54a45] text-white`,important:`bg-[#ff8800] text-white`,urgent:`bg-[#f7ba1e] text-stone-800`,normal:`bg-stone-200 text-stone-600`,"":`bg-transparent text-stone-400`},H={pending:`bg-stone-100 text-stone-600`,in_progress:`bg-[#e1eaff] text-[#1f4ec2]`,done:`bg-[#d9f5d2] text-[#1d7a12]`,cancelled:`bg-stone-100 text-stone-400`,overdue:`bg-[#fee4e3] text-[#c02a26]`},ge={pool:`bg-stone-400`,in_progress:`bg-[#3370ff]`,done:`bg-[#34c724]`,closed:`bg-stone-300`,cancelled:`bg-stone-300`},_e={urgent_important:`bg-[#f54a45]`,important:`bg-[#ff8800]`,urgent:`bg-[#f7ba1e]`,normal:`bg-stone-300`,"":`border border-stone-300 bg-transparent`},ve=ue.map(e=>({value:e,label:k[e]})),U=[{value:``,label:`未设置`},...j.map(e=>({value:e,label:A[e]}))],ye=[{value:`all`,label:`全部优先级`},...j.map(e=>({value:e,label:A[e]}))],be=[{value:`all`,label:`全部`},{value:`pool`,label:`任务池`},{value:`in_progress`,label:`进行中`},{value:`done`,label:`已完成`},{value:`closed`,label:`已关闭`},{value:`cancelled`,label:`已取消`}],xe=[`all`,`pool`,`in_progress`,`done`,`closed`,`cancelled`],Se=`tasks.status-tab`,Ce=`tasks.priority-filter`,we=`tasks.search`,Te=ye.map(e=>e.value);function W(e){return(0,B.jsxs)(`div`,{"data-tone":e.tone,className:`tw-stat-card flex min-w-0 flex-col gap-1 rounded-xl border px-4 py-3 ${e.tone===`urgent`?`border-red-100 bg-red-50/60`:`border-stone-200 bg-white`}`,children:[(0,B.jsx)(`span`,{className:`text-2xl font-semibold tabular-nums ${e.tone===`urgent`?`text-[#c02a26]`:`text-stone-900`}`,children:e.value}),(0,B.jsx)(`span`,{className:`truncate text-xs text-stone-500`,children:e.label})]})}function Ee(e){let{open:t,task:n,todos:r,onClose:i,onSaved:ee}=e,[a,o]=(0,z.useState)({title:``}),[s,c]=(0,z.useState)(``),[p,m]=(0,z.useState)(!1);(0,z.useEffect)(()=>{t&&(c(``),m(!1),o(n?{title:n.title,status:n.status,priority:n.priority,startDate:n.startDate,dueDate:n.dueDate,note:n.note}:{title:``,status:`pool`,priority:``,startDate:T(),dueDate:T()}))},[t,n]);function h(e){o(t=>({...t,...e}))}let g=se({startDate:a.startDate??``,dueDate:a.dueDate??``}),_=n?r.filter(e=>e.taskId===n.id):[],v=_.filter(e=>e.status===`done`).length,y=_.length?Math.round(v/_.length*100):0;async function b(){let e=(a.title??``).trim();if(!e)c(`请填写任务名称`);else if(a.startDate&&a.dueDate&&a.dueDate<a.startDate)c(`截止日期不能早于开始日期`);else{m(!0),c(``);try{n?await ae(n.id,a):await D([{...a,title:e}],{mode:`manual`}),await ee(),w(n?`已保存任务`:`已新建任务`,`success`),i()}catch(e){let t=e instanceof Error?e.message:String(e);c(t),w(`保存任务失败:${t}`,`error`)}finally{m(!1)}}}return(0,B.jsxs)(d,{open:t,onClose:i,transition:!0,className:`relative z-100`,children:[(0,B.jsx)(f,{transition:!0,className:`tw-dialog-backdrop-anim fixed inset-0 bg-black/25`,"aria-hidden":`true`}),(0,B.jsx)(`div`,{className:`fixed inset-0 flex justify-end`,children:(0,B.jsxs)(l,{transition:!0,className:`tw-drawer-panel-anim flex h-full w-full max-w-[520px] flex-col border-l border-stone-200 bg-white shadow-2xl`,children:[(0,B.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-3 border-b border-stone-100 px-6 py-4`,children:[(0,B.jsx)(u,{className:`text-base font-semibold text-stone-900`,children:n?`任务详情`:`新建任务`}),(0,B.jsx)(`button`,{type:`button`,onClick:i,"aria-label":`关闭`,className:`flex h-7 w-7 items-center justify-center rounded-md text-stone-400 transition-colors hover:bg-stone-100 hover:text-stone-700`,children:`✕`})]}),(0,B.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto py-3`,children:[(0,B.jsx)(P,{icon:(0,B.jsx)(N,{}),label:`任务名称`,children:(0,B.jsx)(`input`,{autoFocus:!0,value:a.title,onChange:e=>h({title:e.target.value}),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),b())},placeholder:`请输入内容`,className:R})}),(0,B.jsx)(P,{icon:(0,B.jsx)(L,{}),label:`任务状态`,children:(0,B.jsx)(I,{ariaLabel:`任务状态`,menuMinWidth:140,options:ve,value:a.status??`pool`,onChange:e=>h({status:e}),label:k[a.status??`pool`],optionDotClassName:e=>ge[e]})}),(0,B.jsx)(P,{icon:(0,B.jsx)(L,{}),label:`紧急程度`,children:(0,B.jsx)(I,{ariaLabel:`紧急程度`,menuMinWidth:140,options:U,value:a.priority??``,onChange:e=>h({priority:e}),label:a.priority?A[a.priority]:`未设置`,optionDotClassName:e=>_e[e]})}),(0,B.jsx)(P,{icon:(0,B.jsx)(M,{}),label:`开始日期`,children:(0,B.jsx)(S,{value:a.startDate??``,onChange:e=>h({startDate:e}),className:`${R} tabular-nums`})}),(0,B.jsx)(P,{icon:(0,B.jsx)(M,{}),label:`截止日期`,children:(0,B.jsx)(S,{value:a.dueDate??``,onChange:e=>h({dueDate:e}),className:`${R} tabular-nums`})}),(0,B.jsx)(P,{icon:(0,B.jsx)(F,{}),label:`任务周期`,children:(0,B.jsx)(`div`,{className:`px-2 pt-1.5 text-sm text-stone-500`,children:g===null?`—`:`${g} 天`})}),(0,B.jsx)(P,{icon:(0,B.jsx)(F,{}),label:`待办进度`,children:(0,B.jsx)(`div`,{className:`px-2 pt-1.5 text-sm text-stone-500`,children:_.length?`${v}/${_.length} · ${y}%`:`还没有关联待办`})}),(0,B.jsx)(P,{icon:(0,B.jsx)(N,{}),label:`备注`,children:(0,B.jsx)(`textarea`,{value:a.note??``,onChange:e=>h({note:e.target.value}),rows:4,placeholder:`请输入内容`,className:`w-full resize-y rounded-md border border-transparent bg-transparent px-2 py-1.5 text-sm text-stone-800 outline-none transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white placeholder:text-stone-400`})}),n&&_.length?(0,B.jsxs)(`div`,{className:`mx-6 mt-2 rounded-lg border border-stone-100 bg-stone-50/60 px-3 py-2`,children:[(0,B.jsx)(`div`,{className:`mb-1.5 text-xs font-medium text-stone-500`,children:`关联待办`}),(0,B.jsx)(`ul`,{className:`space-y-1.5`,children:_.map(e=>{let t=E(e,T());return(0,B.jsxs)(`li`,{className:`flex items-center gap-2 text-sm text-stone-700`,children:[(0,B.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.title}),(0,B.jsx)(`span`,{className:`shrink-0 rounded-full px-2 py-0.5 text-[11px] font-medium ${H[t]}`,children:O[t]})]},e.id)})})]}):null,s?(0,B.jsx)(`div`,{className:`mx-6 mt-2 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700`,children:s}):null]}),(0,B.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-stone-100 px-6 py-3`,children:[(0,B.jsx)(`button`,{type:`button`,onClick:i,disabled:p,className:`h-8 rounded-lg border border-stone-200 px-4 text-sm text-stone-600 transition-colors hover:bg-stone-100 disabled:opacity-40`,children:`取消`}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>void b(),disabled:p,className:`h-8 rounded-lg bg-[#3370ff] px-4 text-sm font-medium text-white transition-colors hover:bg-[#2b5fd9] disabled:opacity-40`,children:p?`保存中…`:n?`保存`:`新建`})]})]})})]})}function De(){let[e,t]=(0,z.useState)(!1),[l,u]=(0,z.useState)(!0),[d,f]=(0,z.useState)(!0),[p,T]=(0,z.useState)(null),[E,D]=(0,z.useState)([]),[O,ue]=(0,z.useState)([]),[j,M]=(0,z.useState)(null),[N,P]=(0,z.useState)(!1),[F,I]=(0,z.useState)(()=>c(we)),[L,R]=(0,z.useState)(()=>o(Se,xe,`all`)),[H,De]=(0,z.useState)(()=>o(Ce,Te,`all`)),[Oe,G]=(0,z.useState)(null),[K,q]=(0,z.useState)(null);function ke(e){a(Se,e),R(e)}function Ae(e){s(we,e),I(e)}function je(e){a(Ce,e),De(e)}let J=(0,z.useRef)(!0),Y=v(`lh:tasks:cols:v1`,V),Me=g(`tasks`);(0,z.useEffect)(()=>(J.current=!0,()=>{J.current=!1}),[]);let X=(0,z.useCallback)(async()=>{try{let[e,t]=await Promise.all([fe(),d?te().catch(()=>[]):Promise.resolve([])]);if(!J.current)return;D(e),ue(t),M(null)}catch(e){if(!J.current)return;M(e instanceof Error?e.message:String(e))}},[d]);(0,z.useEffect)(()=>{let e=i(e=>{u(!!e.tasks),f(!!e.todos)});return n().then(()=>{u(r(`tasks`)),f(r(`todos`)),t(!0)}),e},[]),(0,z.useEffect)(()=>{e&&l&&(async()=>{let e=await de();J.current&&(e?(await X(),J.current&&T(!0)):T(!1))})()},[e,l,X]),(0,z.useEffect)(()=>{if(p!==!0)return;let e=window.setInterval(()=>void X(),pe),t=()=>void X();return window.addEventListener(`focus`,t),()=>{window.clearInterval(e),window.removeEventListener(`focus`,t)}},[p,X]);let Ne=(0,z.useMemo)(()=>oe(O),[O]),Z=(0,z.useMemo)(()=>le(E),[E]),Pe=(0,z.useMemo)(()=>re(E,{status:L,priority:H,keyword:F}),[E,L,H,F]),Q=(0,z.useMemo)(()=>ie(Pe),[Pe]);async function $(e,t){D(n=>n.map(n=>n.id===e?{...n,...t}:n));try{let n=await ae(e,t);if(!J.current)return;D(t=>t.map(t=>t.id===e?n:t)),M(null)}catch(e){M(e instanceof Error?e.message:String(e)),await X()}}async function Fe(){let e=K;if(e){q(null),P(!0);try{await ce([e.id]),await Promise.all(O.filter(t=>t.taskId===e.id).map(e=>ne(e.id,{taskId:``,linkedTask:``}).catch(()=>null))),await X(),w(`已删除任务「${e.title}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);M(t),w(`删除任务失败:${t}`,`error`)}finally{J.current&&P(!1)}}}return e?l?p===null?(0,B.jsx)(`div`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,"aria-busy":`true`,"aria-label":`正在连接任务服务`,children:(0,B.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center`,children:(0,B.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})}):p?(0,B.jsxs)(`section`,{className:`flex min-h-0 flex-col gap-4`,children:[(0,B.jsxs)(`div`,{className:`grid shrink-0 grid-cols-2 gap-3 sm:grid-cols-3 xl:grid-cols-7`,children:[(0,B.jsx)(W,{label:`全部任务`,value:Z.total}),(0,B.jsx)(W,{label:`任务池`,value:Z.pool}),(0,B.jsx)(W,{label:`进行中`,value:Z.in_progress}),(0,B.jsx)(W,{label:`已完成`,value:Z.done}),(0,B.jsx)(W,{label:`已关闭`,value:Z.closed}),(0,B.jsx)(W,{label:`已取消`,value:Z.cancelled}),(0,B.jsx)(W,{label:`需要紧急`,value:Z.urgent,tone:`urgent`})]}),(0,B.jsxs)(`div`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,B.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2 border-b border-stone-100 px-4 py-3`,children:[(0,B.jsx)(`input`,{value:F,onChange:e=>Ae(e.target.value),placeholder:`搜索任务…`,className:`h-9 w-52 rounded-lg border border-stone-200 px-3 text-sm text-stone-800 outline-none focus:border-[#3370ff]`}),(0,B.jsx)(`div`,{className:`flex items-center gap-0.5 rounded-lg bg-stone-100/80 p-0.5`,children:be.map(e=>(0,B.jsx)(`button`,{type:`button`,onClick:()=>ke(e.value),className:`h-8 rounded-md px-3 text-sm transition-colors ${L===e.value?`bg-white font-medium text-stone-900 shadow-sm`:`text-stone-600 hover:text-stone-900`}`,children:e.label},e.value))}),(0,B.jsx)(C,{flat:!0,className:`w-[136px]`,ariaLabel:`优先级筛选`,options:ye,value:H,onChange:e=>je(e)}),(0,B.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,B.jsx)(`button`,{type:`button`,onClick:()=>void X(),"aria-label":`刷新`,className:`flex h-9 w-9 items-center justify-center rounded-lg border border-stone-200 text-stone-500 transition-colors hover:bg-stone-50 hover:text-stone-800`,children:(0,B.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`16`,height:`16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,B.jsx)(`path`,{d:`M21 12a9 9 0 1 1-3-6.7`}),(0,B.jsx)(`path`,{d:`M21 4v5h-5`})]})}),(0,B.jsx)(`button`,{type:`button`,disabled:N,onClick:()=>G({task:null}),className:`h-9 shrink-0 rounded-lg bg-[#3370ff] px-3 text-sm font-medium whitespace-nowrap text-white transition-colors hover:bg-[#2b5fd9] disabled:opacity-40`,children:`+ 新建任务`})]})]}),j?(0,B.jsxs)(`div`,{className:`mx-4 mt-3 flex shrink-0 items-start gap-2 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700`,children:[(0,B.jsx)(`span`,{className:`min-w-0 flex-1`,children:j}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>M(null),"aria-label":`关闭`,className:`-mr-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded text-red-700/70 hover:bg-red-100 hover:text-red-900`,children:`✕`})]}):null,(0,B.jsx)(`div`,{ref:Me,className:`tw-scroll-x min-h-0 flex-1 overflow-auto`,children:(0,B.jsxs)(`table`,{className:`tw-task-table tw-sticky-table w-full table-fixed text-sm`,style:Y.tableStyle,children:[(0,B.jsx)(`colgroup`,{children:V.map(e=>(0,B.jsx)(`col`,{style:Y.widthOf(e.key)?{width:Y.widthOf(e.key)}:void 0},e.key))}),(0,B.jsx)(`thead`,{className:`tw-table-head sticky top-0 z-10 text-xs text-stone-500`,children:(0,B.jsxs)(`tr`,{children:[(0,B.jsxs)(`th`,{className:b,children:[`任务描述`,(0,B.jsx)(x,{...Y.resizeProps(`title`)})]}),(0,B.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`任务状态`,(0,B.jsx)(x,{...Y.resizeProps(`status`)})]}),(0,B.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`紧急程度`,(0,B.jsx)(x,{...Y.resizeProps(`priority`)})]}),(0,B.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`开始日期`,(0,B.jsx)(x,{...Y.resizeProps(`start`)})]}),(0,B.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`截止日期`,(0,B.jsx)(x,{...Y.resizeProps(`due`)})]}),(0,B.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`任务周期`,(0,B.jsx)(x,{...Y.resizeProps(`cycle`)})]}),(0,B.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`待办数量`,(0,B.jsx)(x,{...Y.resizeProps(`todos`)})]}),(0,B.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`完成进度`,(0,B.jsx)(x,{...Y.resizeProps(`progress`)})]}),(0,B.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`备注`,(0,B.jsx)(x,{...Y.resizeProps(`note`)})]}),(0,B.jsx)(`th`,{"aria-hidden":`true`}),(0,B.jsx)(`th`,{className:h,children:`操作`})]})}),(0,B.jsxs)(`tbody`,{children:[Q.map(e=>{let t=se(e),n=Ne[e.id]??{total:0,done:0,percent:0};return(0,B.jsxs)(`tr`,{className:`group/row hover:bg-[#f7f8fa]`,children:[(0,B.jsx)(`td`,{className:y,children:(0,B.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[e.source===`ai`?(0,B.jsx)(`span`,{className:`shrink-0 rounded bg-[#e1eaff] px-1 py-px text-[10px] text-[#1f4ec2]`,children:`AI`}):null,(0,B.jsx)(`button`,{type:`button`,onClick:()=>G({task:e}),className:`min-w-0 truncate rounded-md px-1.5 py-1 text-left text-sm text-stone-800 hover:bg-stone-100`,children:e.title})]})}),(0,B.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,B.jsx)(C,{unstyled:!0,hideChevron:!0,centerContent:!0,ariaLabel:`任务状态`,menuMinWidth:120,options:ve,value:e.status,onChange:t=>void $(e.id,{status:t}),triggerClassName:`h-7 w-full rounded-md px-2 text-center text-xs font-medium focus:ring-2 focus:ring-[#3370ff]/30 ${me[e.status]}`,renderTrigger:()=>(0,B.jsx)(`span`,{className:`w-full truncate text-center`,children:k[e.status]}),renderOptionPrefix:e=>(0,B.jsx)(`span`,{className:`h-2 w-2 rounded-full ${ge[e.value]}`})})}),(0,B.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,B.jsx)(C,{unstyled:!0,hideChevron:!0,centerContent:!0,ariaLabel:`紧急程度`,menuMinWidth:128,options:U,value:e.priority,onChange:t=>void $(e.id,{priority:t}),triggerClassName:`h-7 w-full rounded-md px-2 text-center text-xs font-medium focus:ring-2 focus:ring-[#3370ff]/30 ${he[e.priority]}`,renderTrigger:()=>(0,B.jsx)(`span`,{className:`w-full truncate text-center`,children:e.priority?A[e.priority]:`未设置`}),renderOptionPrefix:e=>(0,B.jsx)(`span`,{className:`h-2 w-2 rounded-full ${_e[e.value]}`})})}),(0,B.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,B.jsx)(S,{value:e.startDate,onChange:t=>void $(e.id,{startDate:t}),placeholder:`选择日期`,className:`h-8 rounded-md px-1.5 text-sm tabular-nums`})}),(0,B.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,B.jsx)(S,{value:e.dueDate,onChange:t=>void $(e.id,{dueDate:t}),placeholder:`选择日期`,className:`h-8 rounded-md px-1.5 text-sm tabular-nums`})}),(0,B.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap text-stone-500 tabular-nums`,children:t===null?`—`:`${t} 天`}),(0,B.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs text-stone-500 tabular-nums`,children:d?n.total?`${n.total} 条`:`0`:(0,B.jsx)(`span`,{className:`whitespace-nowrap text-stone-400`,children:`待办事项未启用`})}),(0,B.jsx)(`td`,{className:`px-2 py-1 align-middle`,children:d?(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(`span`,{className:`h-1.5 min-w-0 flex-1 overflow-hidden rounded-full bg-stone-100`,children:(0,B.jsx)(`span`,{className:`block h-full rounded-full bg-[#3370ff] transition-[width]`,style:{width:`${n.percent}%`}})}),(0,B.jsxs)(`span`,{className:`w-9 shrink-0 text-right text-xs text-stone-500 tabular-nums`,children:[n.percent,`%`]})]}):(0,B.jsx)(`span`,{className:`whitespace-nowrap text-xs text-stone-400`,children:`待办事项未启用`})}),(0,B.jsx)(`td`,{className:`truncate px-2 py-1 align-middle text-xs text-stone-500`,children:e.note||`—`}),(0,B.jsx)(`td`,{"aria-hidden":`true`}),(0,B.jsx)(`td`,{className:_,children:(0,B.jsxs)(`div`,{className:`flex items-center justify-end gap-0.5`,children:[(0,B.jsx)(`button`,{type:`button`,onClick:()=>G({task:e}),"aria-label":`展开 ${e.title}`,className:`rounded p-1 text-stone-300 transition-colors hover:bg-stone-100 hover:text-stone-600 focus:text-stone-600`,children:(0,B.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,B.jsx)(`path`,{d:`M14 4h6v6`}),(0,B.jsx)(`path`,{d:`M20 4 13 11`}),(0,B.jsx)(`path`,{d:`M10 20H4v-6`}),(0,B.jsx)(`path`,{d:`M4 20l7-7`})]})}),(0,B.jsx)(`button`,{type:`button`,disabled:N,onClick:()=>q(e),"aria-label":`删除 ${e.title}`,className:`tw-icon-danger rounded p-1`,children:(0,B.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,B.jsx)(`path`,{d:`M3 6h18`}),(0,B.jsx)(`path`,{d:`M8 6V4h8v2`}),(0,B.jsx)(`path`,{d:`M19 6l-1 14H6L5 6`}),(0,B.jsx)(`path`,{d:`M10 11v6M14 11v6`})]})})]})})]},e.id)}),Q.length===0?(0,B.jsx)(`tr`,{children:(0,B.jsx)(`td`,{colSpan:11,className:`px-3 py-16 text-center text-sm text-stone-400`,children:E.length===0?`还没有任务`:`没有匹配的任务,试试调整搜索或筛选`})}):null]})]})}),(0,B.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-t border-stone-100 px-4 py-2.5 text-xs text-stone-500`,children:[(0,B.jsxs)(`span`,{children:[`共 `,Q.length,` 条`]}),(0,B.jsx)(`span`,{className:`ml-auto text-stone-400`,children:`任务下关联的待办可直接在「待办事项」里维护`})]})]}),(0,B.jsx)(Ee,{open:Oe!==null,task:Oe?.task??null,todos:O,onClose:()=>G(null),onSaved:X}),(0,B.jsx)(m,{open:K!=null,title:`删除任务`,message:`删除「${K?.title??``}」?已关联的待办会保留,但不再挂在该任务下。`,confirmLabel:`删除`,cancelLabel:`取消`,danger:!0,onClose:()=>q(null),onConfirm:()=>void Fe()})]}):(0,B.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:`任务管理需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`}):(0,B.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:ee(`tasks`)}):(0,B.jsx)(`div`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,"aria-busy":`true`,"aria-label":`正在读取插件开关`,children:(0,B.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center`,children:(0,B.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})})}export{De as default};
|
|
1
|
+
import{s as e,t}from"./react.Blvh0GOs.js";import{i as n}from"./app-config.CF1xVPmo.js";import{i as r,o as i,s as ee}from"./plugins.DYyAjBXb.js";import{a,n as o,o as s,r as c}from"./view-prefs.D1snIG5o.js";import{i as l,n as u,r as d,t as f}from"./dialog.DZHZCe_T.js";import{t as p}from"./jsx-runtime.DUg_B_vD.js";import{t as m}from"./ConfirmDialog.CsMwWevK.js";import{c as h,d as g,i as _,l as v,n as y,o as b,t as x}from"./ColumnResize.BgYkV9Iy.js";import{t as S}from"./DatePicker.Bkl71M49.js";import{t as C}from"./SelectDropdown.Cb-QtC-D.js";import{showToast as w}from"./Toast.BO2NFckG.js";import{A as T,C as E,D as te,P as ne,a as D,b as O,c as re,f as ie,g as ae,h as oe,i as k,m as se,n as A,o as ce,p as le,r as ue,s as de,t as j,u as fe}from"./tasks.BNBkrFC3.js";import{a as M,l as N,n as P,o as F,r as I,s as L,t as R}from"./DrawerField.C0ehOlDt.js";var z=e(t(),1),B=p(),pe=8e3,V=[{key:`title`,width:280,min:200},{key:`status`,width:104,min:80},{key:`priority`,width:104,min:88},{key:`start`,width:108,min:88},{key:`due`,width:108,min:88},{key:`cycle`,width:76,min:60},{key:`todos`,width:84,min:68},{key:`progress`,width:132,min:104},{key:`note`,width:140,min:88},{key:`filler`,filler:!0},{key:`action`,width:76,min:64}],me={pool:`bg-stone-100 text-stone-600`,in_progress:`bg-[#e1eaff] text-[#1f4ec2]`,done:`bg-[#d9f5d2] text-[#1d7a12]`,closed:`bg-stone-100 text-stone-400`,cancelled:`bg-stone-100 text-stone-400 line-through`},he={urgent_important:`bg-[#f54a45] text-white`,important:`bg-[#ff8800] text-white`,urgent:`bg-[#f7ba1e] text-stone-800`,normal:`bg-stone-200 text-stone-600`,"":`bg-transparent text-stone-400`},H={pending:`bg-stone-100 text-stone-600`,in_progress:`bg-[#e1eaff] text-[#1f4ec2]`,done:`bg-[#d9f5d2] text-[#1d7a12]`,cancelled:`bg-stone-100 text-stone-400`,overdue:`bg-[#fee4e3] text-[#c02a26]`},ge={pool:`bg-stone-400`,in_progress:`bg-[#3370ff]`,done:`bg-[#34c724]`,closed:`bg-stone-300`,cancelled:`bg-stone-300`},_e={urgent_important:`bg-[#f54a45]`,important:`bg-[#ff8800]`,urgent:`bg-[#f7ba1e]`,normal:`bg-stone-300`,"":`border border-stone-300 bg-transparent`},ve=ue.map(e=>({value:e,label:k[e]})),U=[{value:``,label:`未设置`},...j.map(e=>({value:e,label:A[e]}))],ye=[{value:`all`,label:`全部优先级`},...j.map(e=>({value:e,label:A[e]}))],be=[{value:`all`,label:`全部`},{value:`pool`,label:`任务池`},{value:`in_progress`,label:`进行中`},{value:`done`,label:`已完成`},{value:`closed`,label:`已关闭`},{value:`cancelled`,label:`已取消`}],xe=[`all`,`pool`,`in_progress`,`done`,`closed`,`cancelled`],Se=`tasks.status-tab`,Ce=`tasks.priority-filter`,we=`tasks.search`,Te=ye.map(e=>e.value);function W(e){return(0,B.jsxs)(`div`,{"data-tone":e.tone,className:`tw-stat-card flex min-w-0 flex-col gap-1 rounded-xl border px-4 py-3 ${e.tone===`urgent`?`border-red-100 bg-red-50/60`:`border-stone-200 bg-white`}`,children:[(0,B.jsx)(`span`,{className:`text-2xl font-semibold tabular-nums ${e.tone===`urgent`?`text-[#c02a26]`:`text-stone-900`}`,children:e.value}),(0,B.jsx)(`span`,{className:`truncate text-xs text-stone-500`,children:e.label})]})}function Ee(e){let{open:t,task:n,todos:r,onClose:i,onSaved:ee}=e,[a,o]=(0,z.useState)({title:``}),[s,c]=(0,z.useState)(``),[p,m]=(0,z.useState)(!1);(0,z.useEffect)(()=>{t&&(c(``),m(!1),o(n?{title:n.title,status:n.status,priority:n.priority,startDate:n.startDate,dueDate:n.dueDate,note:n.note}:{title:``,status:`pool`,priority:``,startDate:T(),dueDate:T()}))},[t,n]);function h(e){o(t=>({...t,...e}))}let g=se({startDate:a.startDate??``,dueDate:a.dueDate??``}),_=n?r.filter(e=>e.taskId===n.id):[],v=_.filter(e=>e.status===`done`).length,y=_.length?Math.round(v/_.length*100):0;async function b(){let e=(a.title??``).trim();if(!e)c(`请填写任务名称`);else if(a.startDate&&a.dueDate&&a.dueDate<a.startDate)c(`截止日期不能早于开始日期`);else{m(!0),c(``);try{n?await ae(n.id,a):await D([{...a,title:e}],{mode:`manual`}),await ee(),w(n?`已保存任务`:`已新建任务`,`success`),i()}catch(e){let t=e instanceof Error?e.message:String(e);c(t),w(`保存任务失败:${t}`,`error`)}finally{m(!1)}}}return(0,B.jsxs)(d,{open:t,onClose:i,transition:!0,className:`relative z-100`,children:[(0,B.jsx)(f,{transition:!0,className:`tw-dialog-backdrop-anim fixed inset-0 bg-black/25`,"aria-hidden":`true`}),(0,B.jsx)(`div`,{className:`fixed inset-0 flex justify-end`,children:(0,B.jsxs)(l,{transition:!0,className:`tw-drawer-panel-anim flex h-full w-full max-w-[520px] flex-col border-l border-stone-200 bg-white shadow-2xl`,children:[(0,B.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-3 border-b border-stone-100 px-6 py-4`,children:[(0,B.jsx)(u,{className:`text-base font-semibold text-stone-900`,children:n?`任务详情`:`新建任务`}),(0,B.jsx)(`button`,{type:`button`,onClick:i,"aria-label":`关闭`,className:`flex h-7 w-7 items-center justify-center rounded-md text-stone-400 transition-colors hover:bg-stone-100 hover:text-stone-700`,children:`✕`})]}),(0,B.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto py-3`,children:[(0,B.jsx)(P,{icon:(0,B.jsx)(N,{}),label:`任务名称`,children:(0,B.jsx)(`input`,{autoFocus:!0,value:a.title,onChange:e=>h({title:e.target.value}),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),b())},placeholder:`请输入内容`,className:R})}),(0,B.jsx)(P,{icon:(0,B.jsx)(L,{}),label:`任务状态`,children:(0,B.jsx)(I,{ariaLabel:`任务状态`,menuMinWidth:140,options:ve,value:a.status??`pool`,onChange:e=>h({status:e}),label:k[a.status??`pool`],optionDotClassName:e=>ge[e]})}),(0,B.jsx)(P,{icon:(0,B.jsx)(L,{}),label:`紧急程度`,children:(0,B.jsx)(I,{ariaLabel:`紧急程度`,menuMinWidth:140,options:U,value:a.priority??``,onChange:e=>h({priority:e}),label:a.priority?A[a.priority]:`未设置`,optionDotClassName:e=>_e[e]})}),(0,B.jsx)(P,{icon:(0,B.jsx)(M,{}),label:`开始日期`,children:(0,B.jsx)(S,{value:a.startDate??``,onChange:e=>h({startDate:e}),className:`${R} tabular-nums`})}),(0,B.jsx)(P,{icon:(0,B.jsx)(M,{}),label:`截止日期`,children:(0,B.jsx)(S,{value:a.dueDate??``,onChange:e=>h({dueDate:e}),className:`${R} tabular-nums`})}),(0,B.jsx)(P,{icon:(0,B.jsx)(F,{}),label:`任务周期`,children:(0,B.jsx)(`div`,{className:`px-2 pt-1.5 text-sm text-stone-500`,children:g===null?`—`:`${g} 天`})}),(0,B.jsx)(P,{icon:(0,B.jsx)(F,{}),label:`待办进度`,children:(0,B.jsx)(`div`,{className:`px-2 pt-1.5 text-sm text-stone-500`,children:_.length?`${v}/${_.length} · ${y}%`:`还没有关联待办`})}),(0,B.jsx)(P,{icon:(0,B.jsx)(N,{}),label:`备注`,children:(0,B.jsx)(`textarea`,{value:a.note??``,onChange:e=>h({note:e.target.value}),rows:4,placeholder:`请输入内容`,className:`w-full resize-y rounded-md border border-transparent bg-transparent px-2 py-1.5 text-sm text-stone-800 outline-none transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white placeholder:text-stone-400`})}),n&&_.length?(0,B.jsxs)(`div`,{className:`mx-6 mt-2 rounded-lg border border-stone-100 bg-stone-50/60 px-3 py-2`,children:[(0,B.jsx)(`div`,{className:`mb-1.5 text-xs font-medium text-stone-500`,children:`关联待办`}),(0,B.jsx)(`ul`,{className:`space-y-1.5`,children:_.map(e=>{let t=E(e,T());return(0,B.jsxs)(`li`,{className:`flex items-center gap-2 text-sm text-stone-700`,children:[(0,B.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.title}),(0,B.jsx)(`span`,{className:`shrink-0 rounded-full px-2 py-0.5 text-[11px] font-medium ${H[t]}`,children:O[t]})]},e.id)})})]}):null,s?(0,B.jsx)(`div`,{className:`mx-6 mt-2 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700`,children:s}):null]}),(0,B.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-stone-100 px-6 py-3`,children:[(0,B.jsx)(`button`,{type:`button`,onClick:i,disabled:p,className:`h-8 rounded-lg border border-stone-200 px-4 text-sm text-stone-600 transition-colors hover:bg-stone-100 disabled:opacity-40`,children:`取消`}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>void b(),disabled:p,className:`h-8 rounded-lg bg-[#3370ff] px-4 text-sm font-medium text-white transition-colors hover:bg-[#2b5fd9] disabled:opacity-40`,children:p?`保存中…`:n?`保存`:`新建`})]})]})})]})}function De(){let[e,t]=(0,z.useState)(!1),[l,u]=(0,z.useState)(!0),[d,f]=(0,z.useState)(!0),[p,T]=(0,z.useState)(null),[E,D]=(0,z.useState)([]),[O,ue]=(0,z.useState)([]),[j,M]=(0,z.useState)(null),[N,P]=(0,z.useState)(!1),[F,I]=(0,z.useState)(()=>c(we)),[L,R]=(0,z.useState)(()=>o(Se,xe,`all`)),[H,De]=(0,z.useState)(()=>o(Ce,Te,`all`)),[Oe,G]=(0,z.useState)(null),[K,q]=(0,z.useState)(null);function ke(e){a(Se,e),R(e)}function Ae(e){s(we,e),I(e)}function je(e){a(Ce,e),De(e)}let J=(0,z.useRef)(!0),Y=v(`lh:tasks:cols:v1`,V),Me=g(`tasks`);(0,z.useEffect)(()=>(J.current=!0,()=>{J.current=!1}),[]);let X=(0,z.useCallback)(async()=>{try{let[e,t]=await Promise.all([fe(),d?te().catch(()=>[]):Promise.resolve([])]);if(!J.current)return;D(e),ue(t),M(null)}catch(e){if(!J.current)return;M(e instanceof Error?e.message:String(e))}},[d]);(0,z.useEffect)(()=>{let e=i(e=>{u(!!e.tasks),f(!!e.todos)});return n().then(()=>{u(r(`tasks`)),f(r(`todos`)),t(!0)}),e},[]),(0,z.useEffect)(()=>{e&&l&&(async()=>{let e=await de();J.current&&(e?(await X(),J.current&&T(!0)):T(!1))})()},[e,l,X]),(0,z.useEffect)(()=>{if(p!==!0)return;let e=window.setInterval(()=>void X(),pe),t=()=>void X();return window.addEventListener(`focus`,t),()=>{window.clearInterval(e),window.removeEventListener(`focus`,t)}},[p,X]);let Ne=(0,z.useMemo)(()=>oe(O),[O]),Z=(0,z.useMemo)(()=>le(E),[E]),Pe=(0,z.useMemo)(()=>re(E,{status:L,priority:H,keyword:F}),[E,L,H,F]),Q=(0,z.useMemo)(()=>ie(Pe),[Pe]);async function $(e,t){D(n=>n.map(n=>n.id===e?{...n,...t}:n));try{let n=await ae(e,t);if(!J.current)return;D(t=>t.map(t=>t.id===e?n:t)),M(null)}catch(e){M(e instanceof Error?e.message:String(e)),await X()}}async function Fe(){let e=K;if(e){q(null),P(!0);try{await ce([e.id]),await Promise.all(O.filter(t=>t.taskId===e.id).map(e=>ne(e.id,{taskId:``,linkedTask:``}).catch(()=>null))),await X(),w(`已删除任务「${e.title}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);M(t),w(`删除任务失败:${t}`,`error`)}finally{J.current&&P(!1)}}}return e?l?p===null?(0,B.jsx)(`div`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,"aria-busy":`true`,"aria-label":`正在连接任务服务`,children:(0,B.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center`,children:(0,B.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})}):p?(0,B.jsxs)(`section`,{className:`flex min-h-0 flex-col gap-4`,children:[(0,B.jsxs)(`div`,{className:`grid shrink-0 grid-cols-2 gap-3 sm:grid-cols-3 xl:grid-cols-7`,children:[(0,B.jsx)(W,{label:`全部任务`,value:Z.total}),(0,B.jsx)(W,{label:`任务池`,value:Z.pool}),(0,B.jsx)(W,{label:`进行中`,value:Z.in_progress}),(0,B.jsx)(W,{label:`已完成`,value:Z.done}),(0,B.jsx)(W,{label:`已关闭`,value:Z.closed}),(0,B.jsx)(W,{label:`已取消`,value:Z.cancelled}),(0,B.jsx)(W,{label:`需要紧急`,value:Z.urgent,tone:`urgent`})]}),(0,B.jsxs)(`div`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,B.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2 border-b border-stone-100 px-4 py-3`,children:[(0,B.jsx)(`input`,{value:F,onChange:e=>Ae(e.target.value),placeholder:`搜索任务…`,className:`h-9 w-52 rounded-lg border border-stone-200 px-3 text-sm text-stone-800 outline-none focus:border-[#3370ff]`}),(0,B.jsx)(`div`,{className:`flex items-center gap-0.5 rounded-lg bg-stone-100/80 p-0.5`,children:be.map(e=>(0,B.jsx)(`button`,{type:`button`,onClick:()=>ke(e.value),className:`h-8 rounded-md px-3 text-sm transition-colors ${L===e.value?`bg-white font-medium text-stone-900 shadow-sm`:`text-stone-600 hover:text-stone-900`}`,children:e.label},e.value))}),(0,B.jsx)(C,{flat:!0,className:`w-[136px]`,ariaLabel:`优先级筛选`,options:ye,value:H,onChange:e=>je(e)}),(0,B.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,B.jsx)(`button`,{type:`button`,onClick:()=>void X(),"aria-label":`刷新`,className:`flex h-9 w-9 items-center justify-center rounded-lg border border-stone-200 text-stone-500 transition-colors hover:bg-stone-50 hover:text-stone-800`,children:(0,B.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`16`,height:`16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,B.jsx)(`path`,{d:`M21 12a9 9 0 1 1-3-6.7`}),(0,B.jsx)(`path`,{d:`M21 4v5h-5`})]})}),(0,B.jsx)(`button`,{type:`button`,disabled:N,onClick:()=>G({task:null}),className:`h-9 shrink-0 rounded-lg bg-[#3370ff] px-3 text-sm font-medium whitespace-nowrap text-white transition-colors hover:bg-[#2b5fd9] disabled:opacity-40`,children:`+ 新建任务`})]})]}),j?(0,B.jsxs)(`div`,{className:`mx-4 mt-3 flex shrink-0 items-start gap-2 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700`,children:[(0,B.jsx)(`span`,{className:`min-w-0 flex-1`,children:j}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>M(null),"aria-label":`关闭`,className:`-mr-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded text-red-700/70 hover:bg-red-100 hover:text-red-900`,children:`✕`})]}):null,(0,B.jsx)(`div`,{ref:Me,className:`tw-scroll-x min-h-0 flex-1 overflow-auto`,children:(0,B.jsxs)(`table`,{className:`tw-task-table tw-sticky-table w-full table-fixed text-sm`,style:Y.tableStyle,children:[(0,B.jsx)(`colgroup`,{children:V.map(e=>(0,B.jsx)(`col`,{style:Y.widthOf(e.key)?{width:Y.widthOf(e.key)}:void 0},e.key))}),(0,B.jsx)(`thead`,{className:`tw-table-head sticky top-0 z-10 text-xs text-stone-500`,children:(0,B.jsxs)(`tr`,{children:[(0,B.jsxs)(`th`,{className:b,children:[`任务描述`,(0,B.jsx)(x,{...Y.resizeProps(`title`)})]}),(0,B.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`任务状态`,(0,B.jsx)(x,{...Y.resizeProps(`status`)})]}),(0,B.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`紧急程度`,(0,B.jsx)(x,{...Y.resizeProps(`priority`)})]}),(0,B.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`开始日期`,(0,B.jsx)(x,{...Y.resizeProps(`start`)})]}),(0,B.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`截止日期`,(0,B.jsx)(x,{...Y.resizeProps(`due`)})]}),(0,B.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`任务周期`,(0,B.jsx)(x,{...Y.resizeProps(`cycle`)})]}),(0,B.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`待办数量`,(0,B.jsx)(x,{...Y.resizeProps(`todos`)})]}),(0,B.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`完成进度`,(0,B.jsx)(x,{...Y.resizeProps(`progress`)})]}),(0,B.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`备注`,(0,B.jsx)(x,{...Y.resizeProps(`note`)})]}),(0,B.jsx)(`th`,{"aria-hidden":`true`}),(0,B.jsx)(`th`,{className:h,children:`操作`})]})}),(0,B.jsxs)(`tbody`,{children:[Q.map(e=>{let t=se(e),n=Ne[e.id]??{total:0,done:0,percent:0};return(0,B.jsxs)(`tr`,{className:`group/row hover:bg-[#f7f8fa]`,children:[(0,B.jsx)(`td`,{className:y,children:(0,B.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[e.source===`ai`?(0,B.jsx)(`span`,{className:`shrink-0 rounded bg-[#e1eaff] px-1 py-px text-[10px] text-[#1f4ec2]`,children:`AI`}):null,(0,B.jsx)(`button`,{type:`button`,onClick:()=>G({task:e}),className:`min-w-0 truncate rounded-md px-1.5 py-1 text-left text-sm text-stone-800 hover:bg-stone-100`,children:e.title})]})}),(0,B.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,B.jsx)(C,{unstyled:!0,hideChevron:!0,centerContent:!0,ariaLabel:`任务状态`,menuMinWidth:120,options:ve,value:e.status,onChange:t=>void $(e.id,{status:t}),triggerClassName:`h-7 w-full rounded-md px-2 text-center text-xs font-medium focus:ring-2 focus:ring-[#3370ff]/30 ${me[e.status]}`,renderTrigger:()=>(0,B.jsx)(`span`,{className:`w-full truncate text-center`,children:k[e.status]}),renderOptionPrefix:e=>(0,B.jsx)(`span`,{className:`h-2 w-2 rounded-full ${ge[e.value]}`})})}),(0,B.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,B.jsx)(C,{unstyled:!0,hideChevron:!0,centerContent:!0,ariaLabel:`紧急程度`,menuMinWidth:128,options:U,value:e.priority,onChange:t=>void $(e.id,{priority:t}),triggerClassName:`h-7 w-full rounded-md px-2 text-center text-xs font-medium focus:ring-2 focus:ring-[#3370ff]/30 ${he[e.priority]}`,renderTrigger:()=>(0,B.jsx)(`span`,{className:`w-full truncate text-center`,children:e.priority?A[e.priority]:`未设置`}),renderOptionPrefix:e=>(0,B.jsx)(`span`,{className:`h-2 w-2 rounded-full ${_e[e.value]}`})})}),(0,B.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,B.jsx)(S,{value:e.startDate,onChange:t=>void $(e.id,{startDate:t}),placeholder:`选择日期`,className:`h-8 rounded-md px-1.5 text-sm tabular-nums`})}),(0,B.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,B.jsx)(S,{value:e.dueDate,onChange:t=>void $(e.id,{dueDate:t}),placeholder:`选择日期`,className:`h-8 rounded-md px-1.5 text-sm tabular-nums`})}),(0,B.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap text-stone-500 tabular-nums`,children:t===null?`—`:`${t} 天`}),(0,B.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs text-stone-500 tabular-nums`,children:d?n.total?`${n.total} 条`:`0`:(0,B.jsx)(`span`,{className:`whitespace-nowrap text-stone-400`,children:`待办事项未启用`})}),(0,B.jsx)(`td`,{className:`px-2 py-1 align-middle`,children:d?(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(`span`,{className:`h-1.5 min-w-0 flex-1 overflow-hidden rounded-full bg-stone-100`,children:(0,B.jsx)(`span`,{className:`block h-full rounded-full bg-[#3370ff] transition-[width]`,style:{width:`${n.percent}%`}})}),(0,B.jsxs)(`span`,{className:`w-9 shrink-0 text-right text-xs text-stone-500 tabular-nums`,children:[n.percent,`%`]})]}):(0,B.jsx)(`span`,{className:`whitespace-nowrap text-xs text-stone-400`,children:`待办事项未启用`})}),(0,B.jsx)(`td`,{className:`truncate px-2 py-1 align-middle text-xs text-stone-500`,children:e.note||`—`}),(0,B.jsx)(`td`,{"aria-hidden":`true`}),(0,B.jsx)(`td`,{className:_,children:(0,B.jsxs)(`div`,{className:`flex items-center justify-end gap-0.5`,children:[(0,B.jsx)(`button`,{type:`button`,onClick:()=>G({task:e}),"aria-label":`展开 ${e.title}`,className:`rounded p-1 text-stone-300 transition-colors hover:bg-stone-100 hover:text-stone-600 focus:text-stone-600`,children:(0,B.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,B.jsx)(`path`,{d:`M14 4h6v6`}),(0,B.jsx)(`path`,{d:`M20 4 13 11`}),(0,B.jsx)(`path`,{d:`M10 20H4v-6`}),(0,B.jsx)(`path`,{d:`M4 20l7-7`})]})}),(0,B.jsx)(`button`,{type:`button`,disabled:N,onClick:()=>q(e),"aria-label":`删除 ${e.title}`,className:`tw-icon-danger rounded p-1`,children:(0,B.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,B.jsx)(`path`,{d:`M3 6h18`}),(0,B.jsx)(`path`,{d:`M8 6V4h8v2`}),(0,B.jsx)(`path`,{d:`M19 6l-1 14H6L5 6`}),(0,B.jsx)(`path`,{d:`M10 11v6M14 11v6`})]})})]})})]},e.id)}),Q.length===0?(0,B.jsx)(`tr`,{children:(0,B.jsx)(`td`,{colSpan:11,className:`px-3 py-16 text-center text-sm text-stone-400`,children:E.length===0?`还没有任务`:`没有匹配的任务,试试调整搜索或筛选`})}):null]})]})}),(0,B.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-t border-stone-100 px-4 py-2.5 text-xs text-stone-500`,children:[(0,B.jsxs)(`span`,{children:[`共 `,Q.length,` 条`]}),(0,B.jsx)(`span`,{className:`ml-auto text-stone-400`,children:`任务下关联的待办可直接在「待办事项」里维护`})]})]}),(0,B.jsx)(Ee,{open:Oe!==null,task:Oe?.task??null,todos:O,onClose:()=>G(null),onSaved:X}),(0,B.jsx)(m,{open:K!=null,title:`删除任务`,message:`删除「${K?.title??``}」?已关联的待办会保留,但不再挂在该任务下。`,confirmLabel:`删除`,cancelLabel:`取消`,danger:!0,onClose:()=>q(null),onConfirm:()=>void Fe()})]}):(0,B.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:`任务管理需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`}):(0,B.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:ee(`tasks`)}):(0,B.jsx)(`div`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,"aria-busy":`true`,"aria-label":`正在读取插件开关`,children:(0,B.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center`,children:(0,B.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})})}export{De as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as e,t}from"./react.Blvh0GOs.js";import{i as n}from"./app-config.CF1xVPmo.js";import{i as r,o as i,s as a}from"./plugins.DYyAjBXb.js";import{a as o,n as s,o as c,r as ee}from"./view-prefs.D1snIG5o.js";import{i as l,n as te,r as u,t as ne}from"./dialog.DZHZCe_T.js";import{t as d}from"./jsx-runtime.DUg_B_vD.js";import{t as f}from"./ConfirmDialog.CsMwWevK.js";import{a as p,c as m,d as h,i as re,l as ie,n as g,o as ae,r as _,s as oe,t as v}from"./ColumnResize.BgYkV9Iy.js";import{n as se,t as y}from"./DatePicker.Bkl71M49.js";import{t as ce}from"./OverflowHint.pvo2Xc8R.js";import{t as b}from"./SelectDropdown.Cb-QtC-D.js";import{showToast as x}from"./Toast.BO2NFckG.js";import{A as S,C as le,D as ue,E as de,M as fe,N as pe,P as C,S as me,T as he,_ as ge,b as w,f as _e,g as ve,j as ye,k as be,n as T,u as xe,v as E,w as Se,x as Ce,y as D}from"./tasks.otRBFydq.js";import{a as O,c as k,i as we,l as A,n as j,o as M,r as N,s as P,t as F}from"./DrawerField.C0ehOlDt.js";var I=e(t(),1),L=d(),Te=8e3,Ee=[{key:`select`,width:32,min:28},{key:`index`,width:36,min:28},{key:`title`,width:300,min:160},{key:`status`,width:104,min:76},{key:`task`,width:156,min:96},{key:`priority`,width:104,min:84},{key:`start`,width:108,min:88},{key:`due`,width:108,min:88},{key:`end`,width:108,min:88},{key:`cycle`,width:64,min:52},{key:`remain`,width:86,min:64},{key:`note`,width:160,min:100},{key:`filler`,filler:!0},{key:`action`,width:88,min:72}],De=[`title`,`status`,`priority`,`linkedTask`,`startDate`,`dueDate`,`note`],Oe={in_progress:`bg-[#3370ff] text-white`,pending:`bg-stone-400 text-white`,done:`bg-[#34c724] text-white`,cancelled:`bg-stone-300 text-stone-600`,overdue:`bg-[#f54a45] text-white`},ke={in_progress:`bg-[#e1eaff] text-[#1f4ec2]`,pending:`bg-stone-100 text-stone-600`,done:`bg-[#d9f5d2] text-[#1d7a12]`,cancelled:`bg-stone-100 text-stone-400`,overdue:`bg-[#fee4e3] text-[#c02a26]`},R={urgent_important:`bg-[#f54a45] text-white`,important:`bg-[#ff8800] text-white`,urgent:`bg-[#f7ba1e] text-stone-800`,normal:`bg-stone-200 text-stone-600`,"":`bg-transparent text-stone-400`},Ae={pending:`bg-stone-400`,in_progress:`bg-[#3370ff]`,done:`bg-[#34c724]`,overdue:`bg-[#f54a45]`,cancelled:`bg-stone-300`},je={urgent_important:`bg-[#f54a45]`,important:`bg-[#ff8800]`,urgent:`bg-[#f7ba1e]`,normal:`bg-stone-300`,"":`border border-stone-300 bg-transparent`},z={status:`按状态分组`,priority:`按紧急程度分组`,none:`不分组`},Me=[`status`,`priority`,`none`],Ne=`todos.group-by`,Pe=[`in_progress`,`pending`,`done`,`overdue`,`cancelled`],Fe=D.map(e=>({value:e,label:w[e]})),Ie=[{value:``,label:`未设置`},...ge.map(e=>({value:e,label:E[e]}))],Le=Object.keys(z).map(e=>({value:e,label:z[e]})),Re=[{value:`all`,label:`全部紧急程度`},...ge.map(e=>({value:e,label:E[e]}))],ze=Re.map(e=>e.value),Be=`todos.priority-filter`,Ve=`todos.search`,He=`h-8 w-full min-w-0 truncate rounded-md border border-transparent bg-transparent px-1.5 text-sm text-stone-800 outline-none transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white placeholder:text-stone-300`;function Ue(e){let{value:t,placeholder:n,muted:r,autoFocus:i,onChange:a,onCommit:o,onCancel:s}=e;return(0,L.jsx)(`input`,{type:`text`,value:t,placeholder:n,autoFocus:i,onChange:e=>a(e.target.value),onBlur:o,onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),e.currentTarget.blur()):e.key===`Escape`&&(e.preventDefault(),s(),e.currentTarget.blur())},className:`${He} ${r&&!t?`text-stone-300`:``}`})}function We(e){let{value:t,onChange:n,onCommit:r,onCancel:i}=e,[a,o]=(0,I.useState)(!1);return a?(0,L.jsx)(Ue,{value:t,placeholder:`—`,autoFocus:!0,onChange:n,onCommit:()=>{o(!1),r()},onCancel:()=>{o(!1),i()}}):(0,L.jsx)(`button`,{type:`button`,onClick:()=>o(!0),className:`block h-8 w-full min-w-0 truncate rounded-md border border-transparent px-1.5 text-left text-sm leading-8 text-stone-700 transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:outline-none`,children:t||(0,L.jsx)(`span`,{className:`text-stone-300`,children:`—`})})}function Ge(e){return(0,L.jsx)(y,{value:e.value,onChange:e.onChange,placeholder:`选择日期`,className:`h-8 rounded-md border border-transparent px-1.5 text-sm text-stone-800 tabular-nums transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white`})}function Ke(e){let{open:t,item:n,preset:r,tasks:i,tasksOn:a,onClose:o,onSaved:s}=e,[c,ee]=(0,I.useState)({title:``}),[d,f]=(0,I.useState)(``),[p,m]=(0,I.useState)(!1),[h,re]=(0,I.useState)(!0);(0,I.useEffect)(()=>{t&&(f(``),m(!1),re(!0),ee(n?{title:n.title,status:n.status,priority:n.priority,linkedTask:n.linkedTask,taskId:n.taskId,startDate:n.startDate,dueDate:n.dueDate,note:n.note}:{title:``,status:`pending`,priority:``,startDate:S(),dueDate:S(),...r}))},[t,n,r]);let ie=[{value:``,label:`不关联`},..._e(i.filter(e=>e.status!==`closed`&&e.status!==`cancelled`||e.id===n?.taskId)).map(e=>({value:e.id,label:e.title}))];function g(e){ee(t=>({...t,...e}))}let ae=ye({startDate:c.startDate??``,dueDate:c.dueDate??``}),_=pe({dueDate:c.dueDate??``}),oe=de(c.status??`pending`),v=oe?se((n&&de(n.status)?n.taskEndDate:``)||S()):``,le=_===null?``:c.status===`done`?`已完成`:c.status===`cancelled`?`已取消`:_<0?`逾期 ${Math.abs(_)} 天`:_===0?`今天截止`:`${_} 天`;async function ue(){let e=(c.title??``).trim();if(!e)f(`请填写待办名称`);else if(c.startDate&&c.dueDate&&c.dueDate<c.startDate)f(`截止日期不能早于开始日期`);else{m(!0),f(``);try{let t={...c,title:e};n?await C(n.id,t):await Ce([t],{mode:`manual`}),await s(),x(n?`已保存待办`:`已新建待办`,`success`),o()}catch(e){let t=e instanceof Error?e.message:String(e);f(t),x(`保存待办失败:${t}`,`error`)}finally{m(!1)}}}return(0,L.jsxs)(u,{open:t,onClose:o,transition:!0,className:`relative z-100`,children:[(0,L.jsx)(ne,{transition:!0,className:`tw-dialog-backdrop-anim fixed inset-0 bg-black/25`,"aria-hidden":`true`}),(0,L.jsx)(`div`,{className:`fixed inset-0 flex justify-end`,children:(0,L.jsxs)(l,{transition:!0,className:`tw-drawer-panel-anim flex h-full w-full max-w-[520px] flex-col border-l border-stone-200 bg-white shadow-2xl`,children:[(0,L.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-3 border-b border-stone-100 px-6 py-4`,children:[(0,L.jsx)(te,{className:`text-base font-semibold text-stone-900`,children:n?`待办详情`:`新建待办`}),(0,L.jsx)(`button`,{type:`button`,onClick:o,"aria-label":`关闭`,className:`flex h-7 w-7 items-center justify-center rounded-md text-stone-400 transition-colors hover:bg-stone-100 hover:text-stone-700`,children:`✕`})]}),(0,L.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto py-3`,children:[(0,L.jsx)(j,{icon:(0,L.jsx)(A,{}),label:`待办名称`,children:(0,L.jsx)(`input`,{autoFocus:!0,value:c.title,onChange:e=>g({title:e.target.value}),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),ue())},placeholder:`请输入内容`,className:F})}),(0,L.jsx)(j,{icon:(0,L.jsx)(P,{}),label:`待办状态`,children:(0,L.jsx)(N,{ariaLabel:`待办状态`,menuMinWidth:140,options:Fe,value:c.status??`pending`,onChange:e=>g({status:e}),label:w[c.status??`pending`],optionDotClassName:e=>Ae[e]})}),(0,L.jsxs)(`button`,{type:`button`,onClick:()=>re(e=>!e),"aria-expanded":h,className:`flex w-full items-center gap-2 px-6 py-2 text-left text-sm text-stone-600 hover:bg-stone-50`,children:[(0,L.jsx)(`span`,{className:`flex h-4 w-4 items-center justify-center text-stone-400`,children:(0,L.jsx)(k,{})}),(0,L.jsx)(`span`,{children:`任务详情`}),(0,L.jsx)(`span`,{className:`text-stone-400`,children:(0,L.jsx)(we,{open:h})})]}),h?(0,L.jsxs)(`div`,{className:`ml-[42px] border-l border-stone-100 pl-1`,children:[(0,L.jsx)(j,{icon:(0,L.jsx)(k,{}),label:`所属任务`,children:a?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(b,{flat:!0,searchable:!0,searchPlaceholder:`搜索任务…`,ariaLabel:`所属任务`,menuMinWidth:220,options:ie,value:c.taskId??``,onChange:e=>{let t=i.find(t=>t.id===e);g({taskId:e,linkedTask:t?.title??``,...t?{priority:t.priority}:{}})},renderTrigger:()=>(0,L.jsx)(ce,{text:c.taskId?i.find(e=>e.id===c.taskId)?.title??``:c.linkedTask||`请选择任务`,className:`min-w-0 flex-1 truncate ${c.taskId||c.linkedTask?`text-stone-800`:`text-stone-400`}`})}),i.length===0?(0,L.jsx)(`p`,{className:`mt-1 px-2 text-xs text-stone-400`,children:`任务管理里还没有任务,可到「任务管理」新建后再关联。`}):null]}):(0,L.jsx)(`div`,{className:`flex h-9 items-center rounded-md bg-stone-50 px-2 text-sm text-stone-400`,children:(0,L.jsx)(`span`,{className:`truncate`,children:c.linkedTask?`${c.linkedTask}(任务管理插件未启用)`:`任务管理插件未启用,无法关联任务`})})}),(0,L.jsx)(j,{icon:(0,L.jsx)(P,{}),label:`重要紧急程度`,children:(()=>{let e=c.taskId?i.find(e=>e.id===c.taskId):void 0;return e?(0,L.jsxs)(`div`,{className:`flex h-9 items-center gap-2 px-2 text-sm`,children:[(0,L.jsx)(`span`,{className:e.priority?`text-stone-800`:`text-stone-400`,children:e.priority?T[e.priority]:`任务未设置`}),(0,L.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:`跟随所属任务`})]}):(0,L.jsx)(N,{ariaLabel:`重要紧急程度`,menuMinWidth:140,options:Ie,value:c.priority??``,onChange:e=>g({priority:e}),label:c.priority?E[c.priority]:`未设置`,optionDotClassName:e=>je[e]})})()}),(0,L.jsx)(j,{icon:(0,L.jsx)(O,{}),label:`结束日期`,children:(0,L.jsxs)(`div`,{className:`flex h-9 items-center px-2 text-sm tabular-nums`,"aria-readonly":`true`,children:[v?(0,L.jsx)(`span`,{className:`text-stone-800`,children:v}):(0,L.jsx)(`span`,{className:`text-stone-400`,children:`待办未完成`}),(0,L.jsx)(`span`,{className:`ml-2 text-[11px] text-stone-400`,children:oe?`按完成日期自动记录`:`状态为已完成 / 已取消时自动记录`})]})})]}):null,(0,L.jsx)(j,{icon:(0,L.jsx)(O,{}),label:`开始日期`,children:(0,L.jsx)(y,{value:c.startDate??``,onChange:e=>g({startDate:e}),className:`${F} tabular-nums`})}),(0,L.jsx)(j,{icon:(0,L.jsx)(O,{}),label:`截止日期`,children:(0,L.jsx)(y,{value:c.dueDate??``,onChange:e=>g({dueDate:e}),className:`${F} tabular-nums`})}),(0,L.jsx)(j,{icon:(0,L.jsx)(M,{}),label:`待办周期`,children:(0,L.jsx)(`div`,{className:`px-2 pt-1.5 text-sm text-stone-500`,children:ae===null?`—`:`${ae} 天`})}),(0,L.jsx)(j,{icon:(0,L.jsx)(M,{}),label:`剩余天数`,children:(0,L.jsx)(`div`,{className:`px-2 pt-1.5 text-sm text-stone-500`,children:le||`—`})}),(0,L.jsx)(j,{icon:(0,L.jsx)(A,{}),label:`备注`,children:(0,L.jsx)(`textarea`,{value:c.note??``,onChange:e=>g({note:e.target.value}),rows:4,placeholder:`请输入内容`,className:`w-full resize-y rounded-md border border-transparent bg-transparent px-2 py-1.5 text-sm text-stone-800 outline-none transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white placeholder:text-stone-400`})}),d?(0,L.jsx)(`div`,{className:`mx-6 mt-2 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700`,children:d}):null]}),(0,L.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-stone-100 px-6 py-3`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:o,disabled:p,className:`h-8 rounded-lg border border-stone-200 px-4 text-sm text-stone-600 transition-colors hover:bg-stone-100 disabled:opacity-40`,children:`取消`}),(0,L.jsx)(`button`,{type:`button`,onClick:()=>void ue(),disabled:p,className:`h-8 rounded-lg bg-[#3370ff] px-4 text-sm font-medium text-white transition-colors hover:bg-[#2b5fd9] disabled:opacity-40`,children:p?`保存中…`:n?`保存`:`新建`})]})]})})]})}function B(){let[e,t]=(0,I.useState)(!1),[l,te]=(0,I.useState)(!0),[u,ne]=(0,I.useState)(null),[d,T]=(0,I.useState)([]),[D,O]=(0,I.useState)([]),[k,we]=(0,I.useState)(!1),[A,j]=(0,I.useState)(null),[M,N]=(0,I.useState)(!1),[P,F]=(0,I.useState)(()=>ee(Ve)),[z,He]=(0,I.useState)(()=>s(Be,ze,`all`)),[B,qe]=(0,I.useState)(()=>s(Ne,Me,`status`)),[Je,Ye]=(0,I.useState)({}),[V,Xe]=(0,I.useState)({});function Ze(e){o(Ne,e),qe(e)}function Qe(e){o(Be,e),He(e)}function $e(e){c(Ve,e),F(e)}let[et,tt]=(0,I.useState)({}),[H,U]=(0,I.useState)(null),[W,G]=(0,I.useState)(null),[nt,rt]=(0,I.useState)(!1),[it,at]=(0,I.useState)(null),K=(0,I.useRef)(!0),ot=(0,I.useRef)(!1),st=(0,I.useRef)(!1),q=ie(`lh:todos:cols:v1`,Ee),ct=h(`todos`),lt=H!==null,ut=(0,I.useRef)(H);ut.current=H;let dt=(0,I.useRef)(!1),ft=(0,I.useRef)(async()=>{});ft.current=bt,(0,I.useEffect)(()=>(K.current=!0,()=>{K.current=!1}),[]),(0,I.useEffect)(()=>{if(!lt)return;let e=e=>{let t=e.target;if(!(t instanceof Element)||t.closest(`.tw-new-row`)||t.closest(`.tw-date-panel`)||t.closest(`.tw-select-menu`))return;let n=ut.current;if(!n)return;if(n.title.trim()){ft.current();return}let r=S();!n.note.trim()&&!n.taskId&&n.status===n.baseStatus&&n.priority===n.basePriority&&n.startDate===r&&n.dueDate===r&&U(null)};return document.addEventListener(`pointerdown`,e,!0),()=>document.removeEventListener(`pointerdown`,e,!0)},[lt]);let J=(0,I.useCallback)(async()=>{try{let[e,t]=await Promise.all([ue(),k?xe().catch(()=>[]):Promise.resolve([])]);if(!K.current)return;let n=t;if(!ot.current&&k){ot.current=!0;let r=new Set(e.filter(e=>e.status===`pending`||e.status===`in_progress`).map(e=>e.taskId).filter(Boolean)),i=t.filter(e=>r.has(e.id)&&(e.status===`pool`||e.status===`done`));if(i.length){let e=await Promise.all(i.map(e=>ve(e.id,{status:`in_progress`}).catch(()=>null))),r=new Map(e.filter(e=>!!e).map(e=>[e.id,e]));n=t.map(e=>r.get(e.id)??e)}}T(e),O(n),j(null)}catch(e){if(!K.current)return;j(e instanceof Error?e.message:String(e))}},[k]);(0,I.useEffect)(()=>{let e=i(e=>{te(!!e.todos),we(!!e.tasks)});return n().then(()=>{te(r(`todos`)),we(r(`tasks`)),t(!0)}),e},[]),(0,I.useEffect)(()=>{e&&l&&(async()=>{let e=await Se();K.current&&(e?(await J(),K.current&&ne(!0)):ne(!1))})()},[e,l,J]),(0,I.useEffect)(()=>{if(u!==!0)return;let e=window.setInterval(()=>{st.current||J()},Te),t=()=>{st.current||J()};return window.addEventListener(`focus`,t),()=>{window.clearInterval(e),window.removeEventListener(`focus`,t)}},[u,J]),(0,I.useEffect)(()=>{if(!k||u!==!0||D.length===0)return;let e=d.filter(e=>!e.taskId&&e.linkedTask.trim());if(!e.length)return;let t=!1;return(async()=>{let n=[];for(let t of e){let e=D.find(e=>e.title.trim()===t.linkedTask.trim());if(e)try{n.push(await C(t.id,{taskId:e.id}))}catch{}}!t&&n.length&&T(e=>e.map(e=>n.find(t=>t.id===e.id)??e))})(),()=>{t=!0}},[k,u,d,D]);function pt(e,t,n){tt(r=>({...r,[e]:{...r[e],[t]:n}}))}function Y(e){tt(t=>{if(!(e in t))return t;let n={...t};return delete n[e],n})}let mt=(0,I.useMemo)(()=>[{value:``,label:`不关联`},..._e(D.filter(e=>e.status!==`closed`&&e.status!==`cancelled`)).map(e=>({value:e.id,label:e.title}))],[D]);function ht(e){return e.taskId?D.find(t=>t.id===e.taskId)?.title??e.linkedTask:e.linkedTask}function gt(e){return e.taskId?D.find(t=>t.id===e.taskId):void 0}function _t(e){let t=gt(e);return t?t.priority:e.priority}async function X(e,t){T(n=>n.map(n=>n.id===e?{...n,...t}:n));try{let n=await C(e,t);if(!K.current)return;T(t=>t.map(t=>t.id===e?n:t)),j(null),t.taskId&&await J()}catch(e){j(e instanceof Error?e.message:String(e)),await J()}}async function vt(e){let t=et[e],n=d.find(t=>t.id===e);if(!t||!n)return;let r={},i=n;for(let e of De){let n=t[e];n!==void 0&&String(i[e]??``)!==String(n)&&(r[e]=n)}if(!Object.keys(r).length)Y(e);else if(typeof r.title==`string`&&!r.title.trim())j(`待办名称不能为空`),Y(e);else try{let t=await C(e,r);if(!K.current)return;T(n=>n.map(n=>n.id===e?t:n)),tt(t=>{let n=t[e];if(!n)return t;let i={...n};for(let e of Object.keys(r))String(i[e]??``)===String(r[e]??``)&&delete i[e];if(!Object.keys(i).length){let n={...t};return delete n[e],n}return{...t,[e]:i}}),j(null)}catch(t){j(t instanceof Error?t.message:String(t)),Y(e)}}function yt(e){let t=e.newStatus??`pending`,n=e.newPriority??``;U({groupKey:e.key,title:``,status:t,priority:n,taskId:``,startDate:S(),dueDate:S(),note:``,baseStatus:t,basePriority:n}),Ye(t=>({...t,[e.key]:!1}))}async function bt(){let e=ut.current;if(!e||dt.current)return;let t=e.title.trim();if(t){dt.current=!0,rt(!0);try{let n=D.find(t=>t.id===e.taskId);await Ce([{title:t,status:e.status,priority:e.priority,taskId:e.taskId,linkedTask:n?.title??``,startDate:e.startDate,dueDate:e.dueDate,note:e.note}],{mode:`manual`}),ut.current===e&&U(null),j(null),await J()}catch(e){j(e instanceof Error?e.message:String(e))}finally{dt.current=!1,K.current&&rt(!1)}}}async function xt(){let e=W;if(e){G(null),N(!0),j(null);try{await me(e.map(e=>e.id)),Xe({}),await J(),x(e.length>1?`已删除 ${e.length} 条待办`:`已删除待办`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);j(t),x(`删除待办失败:${t}`,`error`)}finally{K.current&&N(!1)}}}let Z=S(),St=(0,I.useMemo)(()=>d.map(e=>{let t=e.taskId?D.find(t=>t.id===e.taskId):void 0;return t?{...e,priority:t.priority}:e}),[d,D]),Ct=(0,I.useMemo)(()=>he(St,{status:`all`,priority:z,keyword:P,today:Z}),[St,z,P,Z]),Q=(0,I.useMemo)(()=>be(Ct),[Ct]),wt=(0,I.useMemo)(()=>B===`none`?[{key:`all`,label:`全部待办`,pill:`bg-stone-500 text-white`,items:Q}]:B===`priority`?[...ge,``].map(e=>({key:`priority:${e||`none`}`,label:e?E[e]:`未设置`,pill:e?R[e]:`bg-stone-300 text-stone-600`,items:Q.filter(t=>t.priority===e),newPriority:e})):Pe.map(e=>({key:`status:${e}`,label:w[e],pill:Oe[e],items:Q.filter(t=>le(t,Z)===e),newStatus:e===`overdue`?`pending`:e})),[B,Q,Z]).filter(e=>e.items.length>0||H?.groupKey===e.key&&!!H),Tt=Object.keys(V).filter(e=>V[e]),$=(0,I.useMemo)(()=>{let e={total:d.length,pending:0,in_progress:0,done:0,overdue:0};for(let t of d){let n=le(t,Z);n===`overdue`?e.overdue+=1:n===`pending`?e.pending+=1:n===`in_progress`?e.in_progress+=1:n===`done`&&(e.done+=1)}return e},[d,Z]);return e?l?u===null?(0,L.jsx)(`div`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,"aria-busy":`true`,"aria-label":`正在连接待办服务`,children:(0,L.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center`,children:(0,L.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})}):u?(0,L.jsxs)(`section`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,L.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-3 border-b border-stone-100 px-4 py-3`,children:[(0,L.jsxs)(`div`,{className:`text-sm text-stone-600`,children:[`共 `,(0,L.jsx)(`span`,{className:`font-medium text-stone-800`,children:$.total}),` 条`,(0,L.jsxs)(`span`,{className:`text-stone-400`,children:[` `,`· 待开始 `,$.pending,` · 进行中 `,$.in_progress,` · 已完成 `,$.done,$.overdue?` · 已延期 ${$.overdue}`:``]})]}),(0,L.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[(0,L.jsx)(`input`,{value:P,onChange:e=>$e(e.target.value),placeholder:`搜索待办…`,className:`h-9 w-52 rounded-lg border border-stone-200 px-3 text-sm text-stone-800 outline-none focus:border-[#3370ff]`}),(0,L.jsx)(b,{flat:!0,className:`w-[132px]`,ariaLabel:`分组方式`,options:Le,value:B,onChange:e=>Ze(e)}),(0,L.jsx)(b,{flat:!0,className:`w-[136px]`,ariaLabel:`紧急程度筛选`,options:Re,value:z,onChange:e=>Qe(e)}),(0,L.jsx)(`button`,{type:`button`,disabled:M||Tt.length===0,onClick:()=>G(d.filter(e=>V[e.id])),className:`h-9 shrink-0 rounded-lg border border-red-200 px-3 text-sm font-medium whitespace-nowrap text-red-600 hover:bg-red-50 disabled:opacity-40`,children:`批量删除`}),(0,L.jsx)(`button`,{type:`button`,disabled:M,onClick:()=>at({item:null}),className:`h-9 shrink-0 rounded-lg bg-[#3370ff] px-3 text-sm font-medium whitespace-nowrap text-white hover:bg-[#2b5fd9] disabled:opacity-40`,children:`+ 新建待办`})]})]}),A?(0,L.jsxs)(`div`,{className:`mx-4 mt-3 flex shrink-0 items-start gap-2 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700`,children:[(0,L.jsx)(`span`,{className:`min-w-0 flex-1`,children:A}),(0,L.jsx)(`button`,{type:`button`,onClick:()=>j(null),"aria-label":`关闭`,className:`-mr-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded text-red-700/70 hover:bg-red-100 hover:text-red-900`,children:`✕`})]}):null,(0,L.jsx)(`div`,{ref:ct,className:`tw-scroll-x min-h-0 flex-1 overflow-auto`,onFocusCapture:()=>{st.current=!0},onBlurCapture:()=>{window.setTimeout(()=>{st.current=!!document.activeElement?.closest(`.tw-todo-table`)},0)},children:(0,L.jsxs)(`table`,{className:`tw-todo-table tw-sticky-table w-full table-fixed text-sm`,style:q.tableStyle,children:[(0,L.jsx)(`colgroup`,{children:Ee.map(e=>(0,L.jsx)(`col`,{style:q.widthOf(e.key)?{width:q.widthOf(e.key)}:void 0},e.key))}),(0,L.jsx)(`thead`,{className:`tw-table-head sticky top-0 z-10 text-xs text-stone-500`,children:(0,L.jsxs)(`tr`,{children:[(0,L.jsx)(`th`,{className:p,children:(0,L.jsx)(`input`,{type:`checkbox`,"aria-label":`全选可见待办`,checked:Q.length>0&&Q.every(e=>V[e.id]),onChange:e=>{let t=e.target.checked;Xe(e=>{let n={...e};for(let e of Q)t?n[e.id]=!0:delete n[e.id];return n})}})}),(0,L.jsx)(`th`,{className:oe,style:{"--tw-sticky-left":`32px`},"aria-label":`行号`}),(0,L.jsxs)(`th`,{className:ae,style:{"--tw-sticky-left":`68px`},children:[`待办名称`,(0,L.jsx)(v,{...q.resizeProps(`title`)})]}),(0,L.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`待办状态`,(0,L.jsx)(v,{...q.resizeProps(`status`)})]}),(0,L.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`所属任务`,(0,L.jsx)(v,{...q.resizeProps(`task`)})]}),(0,L.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`紧急程度`,(0,L.jsx)(v,{...q.resizeProps(`priority`)})]}),(0,L.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`开始日期`,(0,L.jsx)(v,{...q.resizeProps(`start`)})]}),(0,L.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`截止日期`,(0,L.jsx)(v,{...q.resizeProps(`due`)})]}),(0,L.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`结束日期`,(0,L.jsx)(v,{...q.resizeProps(`end`)})]}),(0,L.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`周期`,(0,L.jsx)(v,{...q.resizeProps(`cycle`)})]}),(0,L.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`剩余`,(0,L.jsx)(v,{...q.resizeProps(`remain`)})]}),(0,L.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`备注`,(0,L.jsx)(v,{...q.resizeProps(`note`)})]}),(0,L.jsx)(`th`,{"aria-hidden":`true`}),(0,L.jsx)(`th`,{className:m,children:`操作`})]})}),wt.map(e=>{let t=Je[e.key]===!0;return(0,L.jsxs)(`tbody`,{children:[(0,L.jsx)(`tr`,{className:`bg-white`,children:(0,L.jsx)(`td`,{colSpan:14,className:`px-2 py-0 pt-3 pb-1.5`,children:(0,L.jsxs)(`button`,{type:`button`,onClick:()=>Ye(n=>({...n,[e.key]:!t})),className:`flex items-center gap-2 rounded-md px-1 py-0.5 text-left hover:bg-stone-50`,"aria-expanded":!t,children:[(0,L.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`12`,height:`12`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.4`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,className:`text-stone-400 transition-transform ${t?`-rotate-90`:``}`,children:(0,L.jsx)(`path`,{d:`m6 9 6 6 6-6`})}),(0,L.jsx)(`span`,{className:`rounded-md px-2 py-0.5 text-xs font-medium ${e.pill}`,children:e.label}),(0,L.jsxs)(`span`,{className:`text-xs text-stone-400 tabular-nums`,children:[e.items.length,` 条记录`]})]})})}),t?null:e.items.map((e,t)=>{let n=et[e.id]??{},r={...e,...n},i=le(r,Z),a=ye(r),o=pe(r,Z),s=o===null?`—`:r.status===`done`?`已完成`:r.status===`cancelled`?`已取消`:o<0?`逾期 ${Math.abs(o)} 天`:o===0?`今天截止`:`${o} 天`;return(0,L.jsxs)(`tr`,{className:`group/row hover:bg-[#f7f8fa]`,children:[(0,L.jsx)(`td`,{className:g,children:(0,L.jsx)(`input`,{type:`checkbox`,"aria-label":`选择 ${e.title}`,checked:!!V[e.id],onChange:t=>Xe(n=>{let r={...n};return t.target.checked?r[e.id]=!0:delete r[e.id],r})})}),(0,L.jsx)(`td`,{className:`${_} text-xs text-stone-400 tabular-nums`,style:{"--tw-sticky-left":`32px`},children:t+1}),(0,L.jsx)(`td`,{className:g,style:{"--tw-sticky-left":`68px`},children:(0,L.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1`,children:[e.source===`ai`?(0,L.jsx)(`span`,{className:`shrink-0 rounded bg-[#e1eaff] px-1 py-px text-[10px] text-[#1f4ec2]`,title:`AI 记录`,children:`AI`}):null,(0,L.jsx)(Ue,{value:r.title,placeholder:`输入待办名称`,onChange:t=>pt(e.id,`title`,t),onCommit:()=>void vt(e.id),onCancel:()=>Y(e.id)})]})}),(0,L.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,L.jsx)(b,{unstyled:!0,hideChevron:!0,centerContent:!0,ariaLabel:`待办状态`,menuMinWidth:120,options:Fe,value:e.status,onChange:t=>void X(e.id,{status:t}),triggerClassName:`h-7 w-full rounded-md px-2 text-center text-xs font-medium focus:ring-2 focus:ring-[#3370ff]/30 ${ke[i]}`,renderTrigger:()=>(0,L.jsx)(`span`,{className:`w-full truncate text-center`,children:w[i]}),renderOptionPrefix:e=>(0,L.jsx)(`span`,{className:`h-2 w-2 rounded-full ${Ae[e.value]}`})})}),(0,L.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:k?(0,L.jsx)(b,{unstyled:!0,searchable:!0,searchPlaceholder:`搜索任务…`,ariaLabel:`所属任务`,menuMinWidth:220,options:mt,value:r.taskId,onChange:t=>{let n=D.find(e=>e.id===t);X(e.id,{taskId:t,linkedTask:n?.title??``,...n?{priority:n.priority}:{}})},triggerClassName:`h-8 w-full rounded-md px-1.5 text-sm hover:border-stone-200`,renderTrigger:()=>(0,L.jsx)(ce,{text:ht(r)||`未关联`,className:`min-w-0 flex-1 truncate ${ht(r)?`text-stone-800`:`text-stone-300`}`})}):(0,L.jsx)(`span`,{className:`block truncate px-1.5 text-xs text-stone-400`,children:ht(r)?`${ht(r)} · 插件未启用`:`任务管理插件未启用`})}),(0,L.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:gt(r)?(0,L.jsx)(`span`,{title:`跟随所属任务的紧急程度`,className:`flex h-7 w-full items-center justify-center truncate rounded-md px-2 text-center text-xs font-medium ${R[_t(r)]??`text-stone-300`}`,children:_t(r)?E[_t(r)]:`未设置`}):(0,L.jsx)(b,{unstyled:!0,hideChevron:!0,centerContent:!0,ariaLabel:`紧急程度`,menuMinWidth:128,options:Ie,value:e.priority,onChange:t=>void X(e.id,{priority:t}),triggerClassName:`h-7 w-full rounded-md px-2 text-center text-xs font-medium focus:ring-2 focus:ring-[#3370ff]/30 ${R[e.priority]}`,renderTrigger:()=>(0,L.jsx)(`span`,{className:`w-full truncate text-center`,children:e.priority?E[e.priority]:`未设置`}),renderOptionPrefix:e=>(0,L.jsx)(`span`,{className:`h-2 w-2 rounded-full ${je[e.value]}`})})}),(0,L.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,L.jsx)(Ge,{value:r.startDate,onChange:t=>void X(e.id,{startDate:t})})}),(0,L.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,L.jsx)(Ge,{value:r.dueDate,onChange:t=>void X(e.id,{dueDate:t})})}),(0,L.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap tabular-nums`,children:fe(r)?(0,L.jsx)(`span`,{className:`text-stone-500`,children:se(fe(r))}):(0,L.jsx)(`span`,{className:`text-stone-400`,children:`待办未完成`})}),(0,L.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap text-stone-500 tabular-nums`,children:a===null?`—`:`${a} 天`}),(0,L.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap tabular-nums ${o!==null&&o<0&&i!==`done`&&i!==`cancelled`?`font-medium text-[#c02a26]`:`text-stone-500`}`,children:s}),(0,L.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,L.jsx)(We,{value:r.note,onChange:t=>pt(e.id,`note`,t),onCommit:()=>void vt(e.id),onCancel:()=>Y(e.id)})}),(0,L.jsx)(`td`,{"aria-hidden":`true`}),(0,L.jsx)(`td`,{className:re,children:(0,L.jsxs)(`div`,{className:`flex items-center justify-end gap-0.5`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:()=>at({item:e}),"aria-label":`展开 ${e.title}`,className:`rounded p-1 text-stone-300 transition-colors hover:bg-stone-100 hover:text-stone-600 focus:text-stone-600`,children:(0,L.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,L.jsx)(`path`,{d:`M14 4h6v6`}),(0,L.jsx)(`path`,{d:`M20 4 13 11`}),(0,L.jsx)(`path`,{d:`M10 20H4v-6`}),(0,L.jsx)(`path`,{d:`M4 20l7-7`})]})}),(0,L.jsx)(`button`,{type:`button`,disabled:M,onClick:()=>G([e]),"aria-label":`删除 ${e.title}`,className:`tw-icon-danger rounded p-1`,children:(0,L.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,L.jsx)(`path`,{d:`M3 6h18`}),(0,L.jsx)(`path`,{d:`M8 6V4h8v2`}),(0,L.jsx)(`path`,{d:`M19 6l-1 14H6L5 6`}),(0,L.jsx)(`path`,{d:`M10 11v6M14 11v6`})]})})]})})]},e.id)}),t?null:H?.groupKey===e.key?(0,L.jsxs)(`tr`,{className:`tw-new-row`,children:[(0,L.jsx)(`td`,{className:`px-2 py-1 align-middle`}),(0,L.jsx)(`td`,{className:`px-1 py-1 align-middle text-xs text-stone-400 tabular-nums`,children:e.items.length+1}),(0,L.jsx)(`td`,{className:_,children:(0,L.jsx)(`input`,{autoFocus:!0,value:H.title,disabled:nt,placeholder:`输入待办名称,回车或点空白处保存`,onChange:e=>U(t=>t&&{...t,title:e.target.value}),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),bt()):e.key===`Escape`&&(e.preventDefault(),U(null))},className:`h-8 w-full truncate rounded-md border border-[#3370ff]/40 bg-white px-2 text-sm text-stone-800 outline-none focus:border-[#3370ff]`})}),(0,L.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,L.jsx)(b,{unstyled:!0,hideChevron:!0,centerContent:!0,ariaLabel:`待办状态`,menuMinWidth:120,options:Fe,value:H.status,onChange:e=>U(t=>t&&{...t,status:e}),triggerClassName:`h-7 w-full rounded-md px-2 text-center text-xs font-medium focus:ring-2 focus:ring-[#3370ff]/30 ${ke[H.status]}`,renderTrigger:()=>(0,L.jsx)(`span`,{className:`w-full truncate text-center`,children:w[H.status]})})}),(0,L.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:k?(0,L.jsx)(b,{unstyled:!0,searchable:!0,searchPlaceholder:`搜索任务…`,ariaLabel:`所属任务`,menuMinWidth:220,options:mt,value:H.taskId,onChange:e=>U(t=>{if(!t)return t;let n=D.find(t=>t.id===e);return{...t,taskId:e,...n?{priority:n.priority}:{}}}),triggerClassName:`h-8 w-full rounded-md px-1.5 text-sm hover:border-stone-200`,renderTrigger:()=>{let e=D.find(e=>e.id===H.taskId);return(0,L.jsx)(ce,{text:e?.title||`未关联`,className:`min-w-0 flex-1 truncate ${e?`text-stone-800`:`text-stone-300`}`})}}):(0,L.jsx)(`span`,{className:`block truncate px-1.5 text-xs text-stone-400`,children:`任务管理插件未启用`})}),(0,L.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(()=>{let e=D.find(e=>e.id===H.taskId);return e?(0,L.jsx)(`span`,{title:`跟随所属任务的紧急程度`,className:`flex h-7 w-full items-center justify-center truncate rounded-md px-2 text-center text-xs font-medium ${R[e.priority]??`text-stone-300`}`,children:e.priority?E[e.priority]:`未设置`}):(0,L.jsx)(b,{unstyled:!0,hideChevron:!0,centerContent:!0,ariaLabel:`紧急程度`,menuMinWidth:128,options:Ie,value:H.priority,onChange:e=>U(t=>t&&{...t,priority:e}),triggerClassName:`h-7 w-full rounded-md px-2 text-center text-xs font-medium focus:ring-2 focus:ring-[#3370ff]/30 ${R[H.priority]}`,renderTrigger:()=>(0,L.jsx)(`span`,{className:`w-full truncate text-center`,children:H.priority?E[H.priority]:`未设置`})})})()}),(0,L.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,L.jsx)(y,{value:H.startDate,onChange:e=>U(t=>t&&{...t,startDate:e}),placeholder:`选择日期`,className:`h-8 rounded-md border border-transparent px-1.5 text-sm text-stone-800 tabular-nums transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white`})}),(0,L.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,L.jsx)(y,{value:H.dueDate,onChange:e=>U(t=>t&&{...t,dueDate:e}),placeholder:`选择日期`,className:`h-8 rounded-md border border-transparent px-1.5 text-sm text-stone-800 tabular-nums transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white`})}),(0,L.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap tabular-nums`,children:de(H.status)?(0,L.jsx)(`span`,{className:`text-stone-500`,children:se(S())}):(0,L.jsx)(`span`,{className:`text-stone-400`,children:`待办未完成`})}),(0,L.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap text-stone-400 tabular-nums`,children:`—`}),(0,L.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap text-stone-400 tabular-nums`,children:`—`}),(0,L.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,L.jsx)(`input`,{value:H.note,disabled:nt,placeholder:`—`,onChange:e=>U(t=>t&&{...t,note:e.target.value}),className:`h-8 w-full truncate rounded-md border border-transparent bg-transparent px-1.5 text-sm text-stone-800 outline-none transition-colors placeholder:text-stone-300 hover:border-stone-200 focus:border-[#3370ff] focus:bg-white`})}),(0,L.jsx)(`td`,{"aria-hidden":`true`}),(0,L.jsx)(`td`,{className:`px-1 py-1 align-middle`})]}):(0,L.jsxs)(`tr`,{children:[(0,L.jsx)(`td`,{className:`px-2 py-0.5`}),(0,L.jsx)(`td`,{className:`px-1 py-0.5`}),(0,L.jsx)(`td`,{className:`px-1 py-0.5`,colSpan:12,children:(0,L.jsxs)(`button`,{type:`button`,disabled:nt,onClick:()=>yt(e),className:`flex items-center gap-1 rounded px-1 py-0.5 text-xs text-stone-400 transition-colors hover:bg-stone-100 hover:text-stone-600 disabled:opacity-40`,children:[(0,L.jsx)(`span`,{className:`text-sm leading-none`,children:`+`}),`新增记录`]})})]})]},e.key)}),wt.length===0?(0,L.jsx)(`tbody`,{children:(0,L.jsx)(`tr`,{children:(0,L.jsx)(`td`,{colSpan:14,className:`px-3 py-16 text-center text-sm text-stone-400`,children:d.length===0?`还没有待办`:`没有匹配的待办,试试调整搜索或筛选`})})}):null]})}),(0,L.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2 border-t border-stone-100 px-4 py-2.5 text-xs text-stone-500`,children:[(0,L.jsxs)(`span`,{children:[`共 `,Q.length,` 条`,Tt.length?` · 已选 ${Tt.length}`:``]}),(0,L.jsx)(`span`,{className:`ml-auto text-stone-400`,children:`点击单元格直接编辑,回车或点空白处保存`})]}),(0,L.jsx)(Ke,{open:it!==null,item:it?.item??null,preset:it?.preset,tasks:D,tasksOn:k,onClose:()=>at(null),onSaved:J}),(0,L.jsx)(f,{open:W!=null,title:W&&W.length>1?`批量删除`:`删除待办`,message:W&&W.length>1?`确认删除已选中的 ${W.length} 条待办?此操作不可恢复。`:`删除「${W?.[0]?.title??``}」?此操作不可恢复。`,confirmLabel:`删除`,cancelLabel:`取消`,danger:!0,onClose:()=>G(null),onConfirm:()=>void xt()})]}):(0,L.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:`待办事项需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`}):(0,L.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:a(`todos`)}):(0,L.jsx)(`div`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,"aria-busy":`true`,"aria-label":`正在读取插件开关`,children:(0,L.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center`,children:(0,L.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})})}export{B as default};
|
|
1
|
+
import{s as e,t}from"./react.Blvh0GOs.js";import{i as n}from"./app-config.CF1xVPmo.js";import{i as r,o as i,s as a}from"./plugins.DYyAjBXb.js";import{a as o,n as s,o as c,r as ee}from"./view-prefs.D1snIG5o.js";import{i as l,n as te,r as u,t as ne}from"./dialog.DZHZCe_T.js";import{t as d}from"./jsx-runtime.DUg_B_vD.js";import{t as f}from"./ConfirmDialog.CsMwWevK.js";import{a as p,c as m,d as h,i as re,l as ie,n as g,o as ae,r as _,s as oe,t as v}from"./ColumnResize.BgYkV9Iy.js";import{n as se,t as y}from"./DatePicker.Bkl71M49.js";import{t as ce}from"./OverflowHint.pvo2Xc8R.js";import{t as b}from"./SelectDropdown.Cb-QtC-D.js";import{showToast as x}from"./Toast.BO2NFckG.js";import{A as S,C as le,D as ue,E as de,M as fe,N as pe,P as C,S as me,T as he,_ as ge,b as w,f as _e,g as ve,j as ye,k as be,n as T,u as xe,v as E,w as Se,x as Ce,y as D}from"./tasks.BNBkrFC3.js";import{a as O,c as k,i as we,l as A,n as j,o as M,r as N,s as P,t as F}from"./DrawerField.C0ehOlDt.js";var I=e(t(),1),L=d(),Te=8e3,Ee=[{key:`select`,width:32,min:28},{key:`index`,width:36,min:28},{key:`title`,width:300,min:160},{key:`status`,width:104,min:76},{key:`task`,width:156,min:96},{key:`priority`,width:104,min:84},{key:`start`,width:108,min:88},{key:`due`,width:108,min:88},{key:`end`,width:108,min:88},{key:`cycle`,width:64,min:52},{key:`remain`,width:86,min:64},{key:`note`,width:160,min:100},{key:`filler`,filler:!0},{key:`action`,width:88,min:72}],De=[`title`,`status`,`priority`,`linkedTask`,`startDate`,`dueDate`,`note`],Oe={in_progress:`bg-[#3370ff] text-white`,pending:`bg-stone-400 text-white`,done:`bg-[#34c724] text-white`,cancelled:`bg-stone-300 text-stone-600`,overdue:`bg-[#f54a45] text-white`},ke={in_progress:`bg-[#e1eaff] text-[#1f4ec2]`,pending:`bg-stone-100 text-stone-600`,done:`bg-[#d9f5d2] text-[#1d7a12]`,cancelled:`bg-stone-100 text-stone-400`,overdue:`bg-[#fee4e3] text-[#c02a26]`},R={urgent_important:`bg-[#f54a45] text-white`,important:`bg-[#ff8800] text-white`,urgent:`bg-[#f7ba1e] text-stone-800`,normal:`bg-stone-200 text-stone-600`,"":`bg-transparent text-stone-400`},Ae={pending:`bg-stone-400`,in_progress:`bg-[#3370ff]`,done:`bg-[#34c724]`,overdue:`bg-[#f54a45]`,cancelled:`bg-stone-300`},je={urgent_important:`bg-[#f54a45]`,important:`bg-[#ff8800]`,urgent:`bg-[#f7ba1e]`,normal:`bg-stone-300`,"":`border border-stone-300 bg-transparent`},z={status:`按状态分组`,priority:`按紧急程度分组`,none:`不分组`},Me=[`status`,`priority`,`none`],Ne=`todos.group-by`,Pe=[`in_progress`,`pending`,`overdue`,`done`,`cancelled`],Fe=D.map(e=>({value:e,label:w[e]})),Ie=[{value:``,label:`未设置`},...ge.map(e=>({value:e,label:E[e]}))],Le=Object.keys(z).map(e=>({value:e,label:z[e]})),Re=[{value:`all`,label:`全部紧急程度`},...ge.map(e=>({value:e,label:E[e]}))],ze=Re.map(e=>e.value),Be=`todos.priority-filter`,Ve=`todos.search`,He=`h-8 w-full min-w-0 truncate rounded-md border border-transparent bg-transparent px-1.5 text-sm text-stone-800 outline-none transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white placeholder:text-stone-300`;function Ue(e){let{value:t,placeholder:n,muted:r,autoFocus:i,onChange:a,onCommit:o,onCancel:s}=e;return(0,L.jsx)(`input`,{type:`text`,value:t,placeholder:n,autoFocus:i,onChange:e=>a(e.target.value),onBlur:o,onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),e.currentTarget.blur()):e.key===`Escape`&&(e.preventDefault(),s(),e.currentTarget.blur())},className:`${He} ${r&&!t?`text-stone-300`:``}`})}function We(e){let{value:t,onChange:n,onCommit:r,onCancel:i}=e,[a,o]=(0,I.useState)(!1);return a?(0,L.jsx)(Ue,{value:t,placeholder:`—`,autoFocus:!0,onChange:n,onCommit:()=>{o(!1),r()},onCancel:()=>{o(!1),i()}}):(0,L.jsx)(`button`,{type:`button`,onClick:()=>o(!0),className:`block h-8 w-full min-w-0 truncate rounded-md border border-transparent px-1.5 text-left text-sm leading-8 text-stone-700 transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:outline-none`,children:t||(0,L.jsx)(`span`,{className:`text-stone-300`,children:`—`})})}function Ge(e){return(0,L.jsx)(y,{value:e.value,onChange:e.onChange,placeholder:`选择日期`,className:`h-8 rounded-md border border-transparent px-1.5 text-sm text-stone-800 tabular-nums transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white`})}function Ke(e){let{open:t,item:n,preset:r,tasks:i,tasksOn:a,onClose:o,onSaved:s}=e,[c,ee]=(0,I.useState)({title:``}),[d,f]=(0,I.useState)(``),[p,m]=(0,I.useState)(!1),[h,re]=(0,I.useState)(!0);(0,I.useEffect)(()=>{t&&(f(``),m(!1),re(!0),ee(n?{title:n.title,status:n.status,priority:n.priority,linkedTask:n.linkedTask,taskId:n.taskId,startDate:n.startDate,dueDate:n.dueDate,note:n.note}:{title:``,status:`pending`,priority:``,startDate:S(),dueDate:S(),...r}))},[t,n,r]);let ie=[{value:``,label:`不关联`},..._e(i.filter(e=>e.status!==`closed`&&e.status!==`cancelled`||e.id===n?.taskId)).map(e=>({value:e.id,label:e.title}))];function g(e){ee(t=>({...t,...e}))}let ae=ye({startDate:c.startDate??``,dueDate:c.dueDate??``}),_=pe({dueDate:c.dueDate??``}),oe=de(c.status??`pending`),v=oe?se((n&&de(n.status)?n.taskEndDate:``)||S()):``,le=_===null?``:c.status===`done`?`已完成`:c.status===`cancelled`?`已取消`:_<0?`逾期 ${Math.abs(_)} 天`:_===0?`今天截止`:`${_} 天`;async function ue(){let e=(c.title??``).trim();if(!e)f(`请填写待办名称`);else if(c.startDate&&c.dueDate&&c.dueDate<c.startDate)f(`截止日期不能早于开始日期`);else{m(!0),f(``);try{let t={...c,title:e};n?await C(n.id,t):await Ce([t],{mode:`manual`}),await s(),x(n?`已保存待办`:`已新建待办`,`success`),o()}catch(e){let t=e instanceof Error?e.message:String(e);f(t),x(`保存待办失败:${t}`,`error`)}finally{m(!1)}}}return(0,L.jsxs)(u,{open:t,onClose:o,transition:!0,className:`relative z-100`,children:[(0,L.jsx)(ne,{transition:!0,className:`tw-dialog-backdrop-anim fixed inset-0 bg-black/25`,"aria-hidden":`true`}),(0,L.jsx)(`div`,{className:`fixed inset-0 flex justify-end`,children:(0,L.jsxs)(l,{transition:!0,className:`tw-drawer-panel-anim flex h-full w-full max-w-[520px] flex-col border-l border-stone-200 bg-white shadow-2xl`,children:[(0,L.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-3 border-b border-stone-100 px-6 py-4`,children:[(0,L.jsx)(te,{className:`text-base font-semibold text-stone-900`,children:n?`待办详情`:`新建待办`}),(0,L.jsx)(`button`,{type:`button`,onClick:o,"aria-label":`关闭`,className:`flex h-7 w-7 items-center justify-center rounded-md text-stone-400 transition-colors hover:bg-stone-100 hover:text-stone-700`,children:`✕`})]}),(0,L.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto py-3`,children:[(0,L.jsx)(j,{icon:(0,L.jsx)(A,{}),label:`待办名称`,children:(0,L.jsx)(`input`,{autoFocus:!0,value:c.title,onChange:e=>g({title:e.target.value}),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),ue())},placeholder:`请输入内容`,className:F})}),(0,L.jsx)(j,{icon:(0,L.jsx)(P,{}),label:`待办状态`,children:(0,L.jsx)(N,{ariaLabel:`待办状态`,menuMinWidth:140,options:Fe,value:c.status??`pending`,onChange:e=>g({status:e}),label:w[c.status??`pending`],optionDotClassName:e=>Ae[e]})}),(0,L.jsxs)(`button`,{type:`button`,onClick:()=>re(e=>!e),"aria-expanded":h,className:`flex w-full items-center gap-2 px-6 py-2 text-left text-sm text-stone-600 hover:bg-stone-50`,children:[(0,L.jsx)(`span`,{className:`flex h-4 w-4 items-center justify-center text-stone-400`,children:(0,L.jsx)(k,{})}),(0,L.jsx)(`span`,{children:`任务详情`}),(0,L.jsx)(`span`,{className:`text-stone-400`,children:(0,L.jsx)(we,{open:h})})]}),h?(0,L.jsxs)(`div`,{className:`ml-[42px] border-l border-stone-100 pl-1`,children:[(0,L.jsx)(j,{icon:(0,L.jsx)(k,{}),label:`所属任务`,children:a?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(b,{flat:!0,searchable:!0,searchPlaceholder:`搜索任务…`,ariaLabel:`所属任务`,menuMinWidth:220,options:ie,value:c.taskId??``,onChange:e=>{let t=i.find(t=>t.id===e);g({taskId:e,linkedTask:t?.title??``,...t?{priority:t.priority}:{}})},renderTrigger:()=>(0,L.jsx)(ce,{text:c.taskId?i.find(e=>e.id===c.taskId)?.title??``:c.linkedTask||`请选择任务`,className:`min-w-0 flex-1 truncate ${c.taskId||c.linkedTask?`text-stone-800`:`text-stone-400`}`})}),i.length===0?(0,L.jsx)(`p`,{className:`mt-1 px-2 text-xs text-stone-400`,children:`任务管理里还没有任务,可到「任务管理」新建后再关联。`}):null]}):(0,L.jsx)(`div`,{className:`flex h-9 items-center rounded-md bg-stone-50 px-2 text-sm text-stone-400`,children:(0,L.jsx)(`span`,{className:`truncate`,children:c.linkedTask?`${c.linkedTask}(任务管理插件未启用)`:`任务管理插件未启用,无法关联任务`})})}),(0,L.jsx)(j,{icon:(0,L.jsx)(P,{}),label:`重要紧急程度`,children:(()=>{let e=c.taskId?i.find(e=>e.id===c.taskId):void 0;return e?(0,L.jsxs)(`div`,{className:`flex h-9 items-center gap-2 px-2 text-sm`,children:[(0,L.jsx)(`span`,{className:e.priority?`text-stone-800`:`text-stone-400`,children:e.priority?T[e.priority]:`任务未设置`}),(0,L.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:`跟随所属任务`})]}):(0,L.jsx)(N,{ariaLabel:`重要紧急程度`,menuMinWidth:140,options:Ie,value:c.priority??``,onChange:e=>g({priority:e}),label:c.priority?E[c.priority]:`未设置`,optionDotClassName:e=>je[e]})})()}),(0,L.jsx)(j,{icon:(0,L.jsx)(O,{}),label:`结束日期`,children:(0,L.jsxs)(`div`,{className:`flex h-9 items-center px-2 text-sm tabular-nums`,"aria-readonly":`true`,children:[v?(0,L.jsx)(`span`,{className:`text-stone-800`,children:v}):(0,L.jsx)(`span`,{className:`text-stone-400`,children:`待办未完成`}),(0,L.jsx)(`span`,{className:`ml-2 text-[11px] text-stone-400`,children:oe?`按完成日期自动记录`:`状态为已完成 / 已取消时自动记录`})]})})]}):null,(0,L.jsx)(j,{icon:(0,L.jsx)(O,{}),label:`开始日期`,children:(0,L.jsx)(y,{value:c.startDate??``,onChange:e=>g({startDate:e}),className:`${F} tabular-nums`})}),(0,L.jsx)(j,{icon:(0,L.jsx)(O,{}),label:`截止日期`,children:(0,L.jsx)(y,{value:c.dueDate??``,onChange:e=>g({dueDate:e}),className:`${F} tabular-nums`})}),(0,L.jsx)(j,{icon:(0,L.jsx)(M,{}),label:`待办周期`,children:(0,L.jsx)(`div`,{className:`px-2 pt-1.5 text-sm text-stone-500`,children:ae===null?`—`:`${ae} 天`})}),(0,L.jsx)(j,{icon:(0,L.jsx)(M,{}),label:`剩余天数`,children:(0,L.jsx)(`div`,{className:`px-2 pt-1.5 text-sm text-stone-500`,children:le||`—`})}),(0,L.jsx)(j,{icon:(0,L.jsx)(A,{}),label:`备注`,children:(0,L.jsx)(`textarea`,{value:c.note??``,onChange:e=>g({note:e.target.value}),rows:4,placeholder:`请输入内容`,className:`w-full resize-y rounded-md border border-transparent bg-transparent px-2 py-1.5 text-sm text-stone-800 outline-none transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white placeholder:text-stone-400`})}),d?(0,L.jsx)(`div`,{className:`mx-6 mt-2 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700`,children:d}):null]}),(0,L.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-stone-100 px-6 py-3`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:o,disabled:p,className:`h-8 rounded-lg border border-stone-200 px-4 text-sm text-stone-600 transition-colors hover:bg-stone-100 disabled:opacity-40`,children:`取消`}),(0,L.jsx)(`button`,{type:`button`,onClick:()=>void ue(),disabled:p,className:`h-8 rounded-lg bg-[#3370ff] px-4 text-sm font-medium text-white transition-colors hover:bg-[#2b5fd9] disabled:opacity-40`,children:p?`保存中…`:n?`保存`:`新建`})]})]})})]})}function B(){let[e,t]=(0,I.useState)(!1),[l,te]=(0,I.useState)(!0),[u,ne]=(0,I.useState)(null),[d,T]=(0,I.useState)([]),[D,O]=(0,I.useState)([]),[k,we]=(0,I.useState)(!1),[A,j]=(0,I.useState)(null),[M,N]=(0,I.useState)(!1),[P,F]=(0,I.useState)(()=>ee(Ve)),[z,He]=(0,I.useState)(()=>s(Be,ze,`all`)),[B,qe]=(0,I.useState)(()=>s(Ne,Me,`status`)),[Je,Ye]=(0,I.useState)({}),[V,Xe]=(0,I.useState)({});function Ze(e){o(Ne,e),qe(e)}function Qe(e){o(Be,e),He(e)}function $e(e){c(Ve,e),F(e)}let[et,tt]=(0,I.useState)({}),[H,U]=(0,I.useState)(null),[W,G]=(0,I.useState)(null),[nt,rt]=(0,I.useState)(!1),[it,at]=(0,I.useState)(null),K=(0,I.useRef)(!0),ot=(0,I.useRef)(!1),st=(0,I.useRef)(!1),q=ie(`lh:todos:cols:v1`,Ee),ct=h(`todos`),lt=H!==null,ut=(0,I.useRef)(H);ut.current=H;let dt=(0,I.useRef)(!1),ft=(0,I.useRef)(async()=>{});ft.current=bt,(0,I.useEffect)(()=>(K.current=!0,()=>{K.current=!1}),[]),(0,I.useEffect)(()=>{if(!lt)return;let e=e=>{let t=e.target;if(!(t instanceof Element)||t.closest(`.tw-new-row`)||t.closest(`.tw-date-panel`)||t.closest(`.tw-select-menu`))return;let n=ut.current;if(!n)return;if(n.title.trim()){ft.current();return}let r=S();!n.note.trim()&&!n.taskId&&n.status===n.baseStatus&&n.priority===n.basePriority&&n.startDate===r&&n.dueDate===r&&U(null)};return document.addEventListener(`pointerdown`,e,!0),()=>document.removeEventListener(`pointerdown`,e,!0)},[lt]);let J=(0,I.useCallback)(async()=>{try{let[e,t]=await Promise.all([ue(),k?xe().catch(()=>[]):Promise.resolve([])]);if(!K.current)return;let n=t;if(!ot.current&&k){ot.current=!0;let r=new Set(e.filter(e=>e.status===`pending`||e.status===`in_progress`).map(e=>e.taskId).filter(Boolean)),i=t.filter(e=>r.has(e.id)&&(e.status===`pool`||e.status===`done`));if(i.length){let e=await Promise.all(i.map(e=>ve(e.id,{status:`in_progress`}).catch(()=>null))),r=new Map(e.filter(e=>!!e).map(e=>[e.id,e]));n=t.map(e=>r.get(e.id)??e)}}T(e),O(n),j(null)}catch(e){if(!K.current)return;j(e instanceof Error?e.message:String(e))}},[k]);(0,I.useEffect)(()=>{let e=i(e=>{te(!!e.todos),we(!!e.tasks)});return n().then(()=>{te(r(`todos`)),we(r(`tasks`)),t(!0)}),e},[]),(0,I.useEffect)(()=>{e&&l&&(async()=>{let e=await Se();K.current&&(e?(await J(),K.current&&ne(!0)):ne(!1))})()},[e,l,J]),(0,I.useEffect)(()=>{if(u!==!0)return;let e=window.setInterval(()=>{st.current||J()},Te),t=()=>{st.current||J()};return window.addEventListener(`focus`,t),()=>{window.clearInterval(e),window.removeEventListener(`focus`,t)}},[u,J]),(0,I.useEffect)(()=>{if(!k||u!==!0||D.length===0)return;let e=d.filter(e=>!e.taskId&&e.linkedTask.trim());if(!e.length)return;let t=!1;return(async()=>{let n=[];for(let t of e){let e=D.find(e=>e.title.trim()===t.linkedTask.trim());if(e)try{n.push(await C(t.id,{taskId:e.id}))}catch{}}!t&&n.length&&T(e=>e.map(e=>n.find(t=>t.id===e.id)??e))})(),()=>{t=!0}},[k,u,d,D]);function pt(e,t,n){tt(r=>({...r,[e]:{...r[e],[t]:n}}))}function Y(e){tt(t=>{if(!(e in t))return t;let n={...t};return delete n[e],n})}let mt=(0,I.useMemo)(()=>[{value:``,label:`不关联`},..._e(D.filter(e=>e.status!==`closed`&&e.status!==`cancelled`)).map(e=>({value:e.id,label:e.title}))],[D]);function ht(e){return e.taskId?D.find(t=>t.id===e.taskId)?.title??e.linkedTask:e.linkedTask}function gt(e){return e.taskId?D.find(t=>t.id===e.taskId):void 0}function _t(e){let t=gt(e);return t?t.priority:e.priority}async function X(e,t){T(n=>n.map(n=>n.id===e?{...n,...t}:n));try{let n=await C(e,t);if(!K.current)return;T(t=>t.map(t=>t.id===e?n:t)),j(null),t.taskId&&await J()}catch(e){j(e instanceof Error?e.message:String(e)),await J()}}async function vt(e){let t=et[e],n=d.find(t=>t.id===e);if(!t||!n)return;let r={},i=n;for(let e of De){let n=t[e];n!==void 0&&String(i[e]??``)!==String(n)&&(r[e]=n)}if(!Object.keys(r).length)Y(e);else if(typeof r.title==`string`&&!r.title.trim())j(`待办名称不能为空`),Y(e);else try{let t=await C(e,r);if(!K.current)return;T(n=>n.map(n=>n.id===e?t:n)),tt(t=>{let n=t[e];if(!n)return t;let i={...n};for(let e of Object.keys(r))String(i[e]??``)===String(r[e]??``)&&delete i[e];if(!Object.keys(i).length){let n={...t};return delete n[e],n}return{...t,[e]:i}}),j(null)}catch(t){j(t instanceof Error?t.message:String(t)),Y(e)}}function yt(e){let t=e.newStatus??`pending`,n=e.newPriority??``;U({groupKey:e.key,title:``,status:t,priority:n,taskId:``,startDate:S(),dueDate:S(),note:``,baseStatus:t,basePriority:n}),Ye(t=>({...t,[e.key]:!1}))}async function bt(){let e=ut.current;if(!e||dt.current)return;let t=e.title.trim();if(t){dt.current=!0,rt(!0);try{let n=D.find(t=>t.id===e.taskId);await Ce([{title:t,status:e.status,priority:e.priority,taskId:e.taskId,linkedTask:n?.title??``,startDate:e.startDate,dueDate:e.dueDate,note:e.note}],{mode:`manual`}),ut.current===e&&U(null),j(null),await J()}catch(e){j(e instanceof Error?e.message:String(e))}finally{dt.current=!1,K.current&&rt(!1)}}}async function xt(){let e=W;if(e){G(null),N(!0),j(null);try{await me(e.map(e=>e.id)),Xe({}),await J(),x(e.length>1?`已删除 ${e.length} 条待办`:`已删除待办`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);j(t),x(`删除待办失败:${t}`,`error`)}finally{K.current&&N(!1)}}}let Z=S(),St=(0,I.useMemo)(()=>d.map(e=>{let t=e.taskId?D.find(t=>t.id===e.taskId):void 0;return t?{...e,priority:t.priority}:e}),[d,D]),Ct=(0,I.useMemo)(()=>he(St,{status:`all`,priority:z,keyword:P,today:Z}),[St,z,P,Z]),Q=(0,I.useMemo)(()=>be(Ct),[Ct]),wt=(0,I.useMemo)(()=>B===`none`?[{key:`all`,label:`全部待办`,pill:`bg-stone-500 text-white`,items:Q}]:B===`priority`?[...ge,``].map(e=>({key:`priority:${e||`none`}`,label:e?E[e]:`未设置`,pill:e?R[e]:`bg-stone-300 text-stone-600`,items:Q.filter(t=>t.priority===e),newPriority:e})):Pe.map(e=>({key:`status:${e}`,label:w[e],pill:Oe[e],items:Q.filter(t=>le(t,Z)===e),newStatus:e===`overdue`?`pending`:e})),[B,Q,Z]).filter(e=>e.items.length>0||H?.groupKey===e.key&&!!H),Tt=Object.keys(V).filter(e=>V[e]),$=(0,I.useMemo)(()=>{let e={total:d.length,pending:0,in_progress:0,done:0,overdue:0};for(let t of d){let n=le(t,Z);n===`overdue`?e.overdue+=1:n===`pending`?e.pending+=1:n===`in_progress`?e.in_progress+=1:n===`done`&&(e.done+=1)}return e},[d,Z]);return e?l?u===null?(0,L.jsx)(`div`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,"aria-busy":`true`,"aria-label":`正在连接待办服务`,children:(0,L.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center`,children:(0,L.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})}):u?(0,L.jsxs)(`section`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,L.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-3 border-b border-stone-100 px-4 py-3`,children:[(0,L.jsxs)(`div`,{className:`text-sm text-stone-600`,children:[`共 `,(0,L.jsx)(`span`,{className:`font-medium text-stone-800`,children:$.total}),` 条`,(0,L.jsxs)(`span`,{className:`text-stone-400`,children:[` `,`· 待开始 `,$.pending,` · 进行中 `,$.in_progress,` · 已完成 `,$.done,$.overdue?` · 已延期 ${$.overdue}`:``]})]}),(0,L.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[(0,L.jsx)(`input`,{value:P,onChange:e=>$e(e.target.value),placeholder:`搜索待办…`,className:`h-9 w-52 rounded-lg border border-stone-200 px-3 text-sm text-stone-800 outline-none focus:border-[#3370ff]`}),(0,L.jsx)(b,{flat:!0,className:`w-[132px]`,ariaLabel:`分组方式`,options:Le,value:B,onChange:e=>Ze(e)}),(0,L.jsx)(b,{flat:!0,className:`w-[136px]`,ariaLabel:`紧急程度筛选`,options:Re,value:z,onChange:e=>Qe(e)}),(0,L.jsx)(`button`,{type:`button`,disabled:M||Tt.length===0,onClick:()=>G(d.filter(e=>V[e.id])),className:`h-9 shrink-0 rounded-lg border border-red-200 px-3 text-sm font-medium whitespace-nowrap text-red-600 hover:bg-red-50 disabled:opacity-40`,children:`批量删除`}),(0,L.jsx)(`button`,{type:`button`,disabled:M,onClick:()=>at({item:null}),className:`h-9 shrink-0 rounded-lg bg-[#3370ff] px-3 text-sm font-medium whitespace-nowrap text-white hover:bg-[#2b5fd9] disabled:opacity-40`,children:`+ 新建待办`})]})]}),A?(0,L.jsxs)(`div`,{className:`mx-4 mt-3 flex shrink-0 items-start gap-2 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700`,children:[(0,L.jsx)(`span`,{className:`min-w-0 flex-1`,children:A}),(0,L.jsx)(`button`,{type:`button`,onClick:()=>j(null),"aria-label":`关闭`,className:`-mr-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded text-red-700/70 hover:bg-red-100 hover:text-red-900`,children:`✕`})]}):null,(0,L.jsx)(`div`,{ref:ct,className:`tw-scroll-x min-h-0 flex-1 overflow-auto`,onFocusCapture:()=>{st.current=!0},onBlurCapture:()=>{window.setTimeout(()=>{st.current=!!document.activeElement?.closest(`.tw-todo-table`)},0)},children:(0,L.jsxs)(`table`,{className:`tw-todo-table tw-sticky-table w-full table-fixed text-sm`,style:q.tableStyle,children:[(0,L.jsx)(`colgroup`,{children:Ee.map(e=>(0,L.jsx)(`col`,{style:q.widthOf(e.key)?{width:q.widthOf(e.key)}:void 0},e.key))}),(0,L.jsx)(`thead`,{className:`tw-table-head sticky top-0 z-10 text-xs text-stone-500`,children:(0,L.jsxs)(`tr`,{children:[(0,L.jsx)(`th`,{className:p,children:(0,L.jsx)(`input`,{type:`checkbox`,"aria-label":`全选可见待办`,checked:Q.length>0&&Q.every(e=>V[e.id]),onChange:e=>{let t=e.target.checked;Xe(e=>{let n={...e};for(let e of Q)t?n[e.id]=!0:delete n[e.id];return n})}})}),(0,L.jsx)(`th`,{className:oe,style:{"--tw-sticky-left":`32px`},"aria-label":`行号`}),(0,L.jsxs)(`th`,{className:ae,style:{"--tw-sticky-left":`68px`},children:[`待办名称`,(0,L.jsx)(v,{...q.resizeProps(`title`)})]}),(0,L.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`待办状态`,(0,L.jsx)(v,{...q.resizeProps(`status`)})]}),(0,L.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`所属任务`,(0,L.jsx)(v,{...q.resizeProps(`task`)})]}),(0,L.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`紧急程度`,(0,L.jsx)(v,{...q.resizeProps(`priority`)})]}),(0,L.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`开始日期`,(0,L.jsx)(v,{...q.resizeProps(`start`)})]}),(0,L.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`截止日期`,(0,L.jsx)(v,{...q.resizeProps(`due`)})]}),(0,L.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`结束日期`,(0,L.jsx)(v,{...q.resizeProps(`end`)})]}),(0,L.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`周期`,(0,L.jsx)(v,{...q.resizeProps(`cycle`)})]}),(0,L.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`剩余`,(0,L.jsx)(v,{...q.resizeProps(`remain`)})]}),(0,L.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`备注`,(0,L.jsx)(v,{...q.resizeProps(`note`)})]}),(0,L.jsx)(`th`,{"aria-hidden":`true`}),(0,L.jsx)(`th`,{className:m,children:`操作`})]})}),wt.map(e=>{let t=Je[e.key]===!0;return(0,L.jsxs)(`tbody`,{children:[(0,L.jsx)(`tr`,{className:`bg-white`,children:(0,L.jsx)(`td`,{colSpan:14,className:`px-2 py-0 pt-3 pb-1.5`,children:(0,L.jsxs)(`button`,{type:`button`,onClick:()=>Ye(n=>({...n,[e.key]:!t})),className:`flex items-center gap-2 rounded-md px-1 py-0.5 text-left hover:bg-stone-50`,"aria-expanded":!t,children:[(0,L.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`12`,height:`12`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.4`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,className:`text-stone-400 transition-transform ${t?`-rotate-90`:``}`,children:(0,L.jsx)(`path`,{d:`m6 9 6 6 6-6`})}),(0,L.jsx)(`span`,{className:`rounded-md px-2 py-0.5 text-xs font-medium ${e.pill}`,children:e.label}),(0,L.jsxs)(`span`,{className:`text-xs text-stone-400 tabular-nums`,children:[e.items.length,` 条记录`]})]})})}),t?null:e.items.map((e,t)=>{let n=et[e.id]??{},r={...e,...n},i=le(r,Z),a=ye(r),o=pe(r,Z),s=o===null?`—`:r.status===`done`?`已完成`:r.status===`cancelled`?`已取消`:o<0?`逾期 ${Math.abs(o)} 天`:o===0?`今天截止`:`${o} 天`;return(0,L.jsxs)(`tr`,{className:`group/row hover:bg-[#f7f8fa]`,children:[(0,L.jsx)(`td`,{className:g,children:(0,L.jsx)(`input`,{type:`checkbox`,"aria-label":`选择 ${e.title}`,checked:!!V[e.id],onChange:t=>Xe(n=>{let r={...n};return t.target.checked?r[e.id]=!0:delete r[e.id],r})})}),(0,L.jsx)(`td`,{className:`${_} text-xs text-stone-400 tabular-nums`,style:{"--tw-sticky-left":`32px`},children:t+1}),(0,L.jsx)(`td`,{className:g,style:{"--tw-sticky-left":`68px`},children:(0,L.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1`,children:[e.source===`ai`?(0,L.jsx)(`span`,{className:`shrink-0 rounded bg-[#e1eaff] px-1 py-px text-[10px] text-[#1f4ec2]`,title:`AI 记录`,children:`AI`}):null,(0,L.jsx)(Ue,{value:r.title,placeholder:`输入待办名称`,onChange:t=>pt(e.id,`title`,t),onCommit:()=>void vt(e.id),onCancel:()=>Y(e.id)})]})}),(0,L.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,L.jsx)(b,{unstyled:!0,hideChevron:!0,centerContent:!0,ariaLabel:`待办状态`,menuMinWidth:120,options:Fe,value:e.status,onChange:t=>void X(e.id,{status:t}),triggerClassName:`h-7 w-full rounded-md px-2 text-center text-xs font-medium focus:ring-2 focus:ring-[#3370ff]/30 ${ke[i]}`,renderTrigger:()=>(0,L.jsx)(`span`,{className:`w-full truncate text-center`,children:w[i]}),renderOptionPrefix:e=>(0,L.jsx)(`span`,{className:`h-2 w-2 rounded-full ${Ae[e.value]}`})})}),(0,L.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:k?(0,L.jsx)(b,{unstyled:!0,searchable:!0,searchPlaceholder:`搜索任务…`,ariaLabel:`所属任务`,menuMinWidth:220,options:mt,value:r.taskId,onChange:t=>{let n=D.find(e=>e.id===t);X(e.id,{taskId:t,linkedTask:n?.title??``,...n?{priority:n.priority}:{}})},triggerClassName:`h-8 w-full rounded-md px-1.5 text-sm hover:border-stone-200`,renderTrigger:()=>(0,L.jsx)(ce,{text:ht(r)||`未关联`,className:`min-w-0 flex-1 truncate ${ht(r)?`text-stone-800`:`text-stone-300`}`})}):(0,L.jsx)(`span`,{className:`block truncate px-1.5 text-xs text-stone-400`,children:ht(r)?`${ht(r)} · 插件未启用`:`任务管理插件未启用`})}),(0,L.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:gt(r)?(0,L.jsx)(`span`,{title:`跟随所属任务的紧急程度`,className:`flex h-7 w-full items-center justify-center truncate rounded-md px-2 text-center text-xs font-medium ${R[_t(r)]??`text-stone-300`}`,children:_t(r)?E[_t(r)]:`未设置`}):(0,L.jsx)(b,{unstyled:!0,hideChevron:!0,centerContent:!0,ariaLabel:`紧急程度`,menuMinWidth:128,options:Ie,value:e.priority,onChange:t=>void X(e.id,{priority:t}),triggerClassName:`h-7 w-full rounded-md px-2 text-center text-xs font-medium focus:ring-2 focus:ring-[#3370ff]/30 ${R[e.priority]}`,renderTrigger:()=>(0,L.jsx)(`span`,{className:`w-full truncate text-center`,children:e.priority?E[e.priority]:`未设置`}),renderOptionPrefix:e=>(0,L.jsx)(`span`,{className:`h-2 w-2 rounded-full ${je[e.value]}`})})}),(0,L.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,L.jsx)(Ge,{value:r.startDate,onChange:t=>void X(e.id,{startDate:t})})}),(0,L.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,L.jsx)(Ge,{value:r.dueDate,onChange:t=>void X(e.id,{dueDate:t})})}),(0,L.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap tabular-nums`,children:fe(r)?(0,L.jsx)(`span`,{className:`text-stone-500`,children:se(fe(r))}):(0,L.jsx)(`span`,{className:`text-stone-400`,children:`待办未完成`})}),(0,L.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap text-stone-500 tabular-nums`,children:a===null?`—`:`${a} 天`}),(0,L.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap tabular-nums ${o!==null&&o<0&&i!==`done`&&i!==`cancelled`?`font-medium text-[#c02a26]`:`text-stone-500`}`,children:s}),(0,L.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,L.jsx)(We,{value:r.note,onChange:t=>pt(e.id,`note`,t),onCommit:()=>void vt(e.id),onCancel:()=>Y(e.id)})}),(0,L.jsx)(`td`,{"aria-hidden":`true`}),(0,L.jsx)(`td`,{className:re,children:(0,L.jsxs)(`div`,{className:`flex items-center justify-end gap-0.5`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:()=>at({item:e}),"aria-label":`展开 ${e.title}`,className:`rounded p-1 text-stone-300 transition-colors hover:bg-stone-100 hover:text-stone-600 focus:text-stone-600`,children:(0,L.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,L.jsx)(`path`,{d:`M14 4h6v6`}),(0,L.jsx)(`path`,{d:`M20 4 13 11`}),(0,L.jsx)(`path`,{d:`M10 20H4v-6`}),(0,L.jsx)(`path`,{d:`M4 20l7-7`})]})}),(0,L.jsx)(`button`,{type:`button`,disabled:M,onClick:()=>G([e]),"aria-label":`删除 ${e.title}`,className:`tw-icon-danger rounded p-1`,children:(0,L.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,L.jsx)(`path`,{d:`M3 6h18`}),(0,L.jsx)(`path`,{d:`M8 6V4h8v2`}),(0,L.jsx)(`path`,{d:`M19 6l-1 14H6L5 6`}),(0,L.jsx)(`path`,{d:`M10 11v6M14 11v6`})]})})]})})]},e.id)}),t?null:H?.groupKey===e.key?(0,L.jsxs)(`tr`,{className:`tw-new-row`,children:[(0,L.jsx)(`td`,{className:`px-2 py-1 align-middle`}),(0,L.jsx)(`td`,{className:`px-1 py-1 align-middle text-xs text-stone-400 tabular-nums`,children:e.items.length+1}),(0,L.jsx)(`td`,{className:_,children:(0,L.jsx)(`input`,{autoFocus:!0,value:H.title,disabled:nt,placeholder:`输入待办名称,回车或点空白处保存`,onChange:e=>U(t=>t&&{...t,title:e.target.value}),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),bt()):e.key===`Escape`&&(e.preventDefault(),U(null))},className:`h-8 w-full truncate rounded-md border border-[#3370ff]/40 bg-white px-2 text-sm text-stone-800 outline-none focus:border-[#3370ff]`})}),(0,L.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,L.jsx)(b,{unstyled:!0,hideChevron:!0,centerContent:!0,ariaLabel:`待办状态`,menuMinWidth:120,options:Fe,value:H.status,onChange:e=>U(t=>t&&{...t,status:e}),triggerClassName:`h-7 w-full rounded-md px-2 text-center text-xs font-medium focus:ring-2 focus:ring-[#3370ff]/30 ${ke[H.status]}`,renderTrigger:()=>(0,L.jsx)(`span`,{className:`w-full truncate text-center`,children:w[H.status]})})}),(0,L.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:k?(0,L.jsx)(b,{unstyled:!0,searchable:!0,searchPlaceholder:`搜索任务…`,ariaLabel:`所属任务`,menuMinWidth:220,options:mt,value:H.taskId,onChange:e=>U(t=>{if(!t)return t;let n=D.find(t=>t.id===e);return{...t,taskId:e,...n?{priority:n.priority}:{}}}),triggerClassName:`h-8 w-full rounded-md px-1.5 text-sm hover:border-stone-200`,renderTrigger:()=>{let e=D.find(e=>e.id===H.taskId);return(0,L.jsx)(ce,{text:e?.title||`未关联`,className:`min-w-0 flex-1 truncate ${e?`text-stone-800`:`text-stone-300`}`})}}):(0,L.jsx)(`span`,{className:`block truncate px-1.5 text-xs text-stone-400`,children:`任务管理插件未启用`})}),(0,L.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(()=>{let e=D.find(e=>e.id===H.taskId);return e?(0,L.jsx)(`span`,{title:`跟随所属任务的紧急程度`,className:`flex h-7 w-full items-center justify-center truncate rounded-md px-2 text-center text-xs font-medium ${R[e.priority]??`text-stone-300`}`,children:e.priority?E[e.priority]:`未设置`}):(0,L.jsx)(b,{unstyled:!0,hideChevron:!0,centerContent:!0,ariaLabel:`紧急程度`,menuMinWidth:128,options:Ie,value:H.priority,onChange:e=>U(t=>t&&{...t,priority:e}),triggerClassName:`h-7 w-full rounded-md px-2 text-center text-xs font-medium focus:ring-2 focus:ring-[#3370ff]/30 ${R[H.priority]}`,renderTrigger:()=>(0,L.jsx)(`span`,{className:`w-full truncate text-center`,children:H.priority?E[H.priority]:`未设置`})})})()}),(0,L.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,L.jsx)(y,{value:H.startDate,onChange:e=>U(t=>t&&{...t,startDate:e}),placeholder:`选择日期`,className:`h-8 rounded-md border border-transparent px-1.5 text-sm text-stone-800 tabular-nums transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white`})}),(0,L.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,L.jsx)(y,{value:H.dueDate,onChange:e=>U(t=>t&&{...t,dueDate:e}),placeholder:`选择日期`,className:`h-8 rounded-md border border-transparent px-1.5 text-sm text-stone-800 tabular-nums transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white`})}),(0,L.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap tabular-nums`,children:de(H.status)?(0,L.jsx)(`span`,{className:`text-stone-500`,children:se(S())}):(0,L.jsx)(`span`,{className:`text-stone-400`,children:`待办未完成`})}),(0,L.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap text-stone-400 tabular-nums`,children:`—`}),(0,L.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap text-stone-400 tabular-nums`,children:`—`}),(0,L.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,L.jsx)(`input`,{value:H.note,disabled:nt,placeholder:`—`,onChange:e=>U(t=>t&&{...t,note:e.target.value}),className:`h-8 w-full truncate rounded-md border border-transparent bg-transparent px-1.5 text-sm text-stone-800 outline-none transition-colors placeholder:text-stone-300 hover:border-stone-200 focus:border-[#3370ff] focus:bg-white`})}),(0,L.jsx)(`td`,{"aria-hidden":`true`}),(0,L.jsx)(`td`,{className:`px-1 py-1 align-middle`})]}):(0,L.jsxs)(`tr`,{children:[(0,L.jsx)(`td`,{className:`px-2 py-0.5`}),(0,L.jsx)(`td`,{className:`px-1 py-0.5`}),(0,L.jsx)(`td`,{className:`px-1 py-0.5`,colSpan:12,children:(0,L.jsxs)(`button`,{type:`button`,disabled:nt,onClick:()=>yt(e),className:`flex items-center gap-1 rounded px-1 py-0.5 text-xs text-stone-400 transition-colors hover:bg-stone-100 hover:text-stone-600 disabled:opacity-40`,children:[(0,L.jsx)(`span`,{className:`text-sm leading-none`,children:`+`}),`新增记录`]})})]})]},e.key)}),wt.length===0?(0,L.jsx)(`tbody`,{children:(0,L.jsx)(`tr`,{children:(0,L.jsx)(`td`,{colSpan:14,className:`px-3 py-16 text-center text-sm text-stone-400`,children:d.length===0?`还没有待办`:`没有匹配的待办,试试调整搜索或筛选`})})}):null]})}),(0,L.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2 border-t border-stone-100 px-4 py-2.5 text-xs text-stone-500`,children:[(0,L.jsxs)(`span`,{children:[`共 `,Q.length,` 条`,Tt.length?` · 已选 ${Tt.length}`:``]}),(0,L.jsx)(`span`,{className:`ml-auto text-stone-400`,children:`点击单元格直接编辑,回车或点空白处保存`})]}),(0,L.jsx)(Ke,{open:it!==null,item:it?.item??null,preset:it?.preset,tasks:D,tasksOn:k,onClose:()=>at(null),onSaved:J}),(0,L.jsx)(f,{open:W!=null,title:W&&W.length>1?`批量删除`:`删除待办`,message:W&&W.length>1?`确认删除已选中的 ${W.length} 条待办?此操作不可恢复。`:`删除「${W?.[0]?.title??``}」?此操作不可恢复。`,confirmLabel:`删除`,cancelLabel:`取消`,danger:!0,onClose:()=>G(null),onConfirm:()=>void xt()})]}):(0,L.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:`待办事项需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`}):(0,L.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:a(`todos`)}):(0,L.jsx)(`div`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,"aria-busy":`true`,"aria-label":`正在读取插件开关`,children:(0,L.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center`,children:(0,L.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})})}export{B as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=`0.1.17`;export{e as t};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["_astro/jszip.min.Bh2Mgo40.js","_astro/react.Blvh0GOs.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{s as e}from"./react.Blvh0GOs.js";import{y as t}from"./settings.BvxRxdqa.js";import{r as n,s as r,t as i}from"./req-analysis.CkLx8c9E.js";import{t as a}from"./app-version.
|
|
2
|
+
import{s as e}from"./react.Blvh0GOs.js";import{y as t}from"./settings.BvxRxdqa.js";import{r as n,s as r,t as i}from"./req-analysis.CkLx8c9E.js";import{t as a}from"./app-version.zuhxTsqO.js";var o=`/__tb_testpoints`,s=`测试点生成提示词.md`,c=[`functional`,`boundary`,`exception`,`business`,`nonfunctional`],l=[`P0`,`P1`,`P2`,`P3`],u={functional:{label:`功能`,hint:`主流程 / 替代流程 / 每个功能点`,tone:`blue`,accent:`bg-[#3370ff]`},boundary:{label:`边界值`,hint:`为空 / 上下限 / 刚好越界`,tone:`purple`,accent:`bg-[#7b5bd6]`},exception:{label:`异常`,hint:`失败路径 / 非法输入 / 并发`,tone:`red`,accent:`bg-[#e5484d]`},business:{label:`业务规则`,hint:`状态流转 / 权限 / 唯一性`,tone:`amber`,accent:`bg-[#d9820b]`},nonfunctional:{label:`非功能`,hint:`性能 / 安全 / 兼容 / 时区`,tone:`green`,accent:`bg-[#2f9e44]`}},d={P0:{label:`P0`,tone:`red`,markerId:`priority-1`},P1:{label:`P1`,tone:`amber`,markerId:`priority-2`},P2:{label:`P2`,tone:`blue`,markerId:`priority-3`},P3:{label:`P3`,tone:`gray`,markerId:`priority-4`}},f=Object.fromEntries(c.map(e=>[e,u[e].label]));async function p(e,t){let n=await fetch(`${o}${e}`,{...t,headers:t?.body===void 0?void 0:{"Content-Type":`application/json`,...t?.headers}}),r=await n.json().catch(()=>({}));if(!n.ok||r.ok===!1)throw Error(r.error||`HTTP ${n.status}`);return r}async function m(){try{let e=await p(`/prompt`);return{file:s,exists:e.exists===!0,generate:e.generate??``}}catch(e){return{file:s,exists:!1,generate:``,error:e instanceof Error?e.message:String(e)}}}async function h(e){return p(`/prompt/sync`,{method:`POST`,body:JSON.stringify({enabled:e})})}var g={P0:0,P1:1,P2:2,P3:3};function _(e){let t=e?.points??[];return c.map(e=>({key:e,label:u[e].label,hint:u[e].hint,points:t.filter(t=>t.dimension===e).sort((e,t)=>g[e.priority]-g[t.priority]||e.title.localeCompare(t.title,`zh`))}))}function v(e){let t=e?.points??[],n={P0:0,P1:0,P2:0,P3:0};for(let e of t)e.priority in n&&(n[e.priority]+=1);return{total:t.length,byPriority:n,coveredDimensions:c.filter(e=>t.some(t=>t.dimension===e)).length}}function y(e){return[...e].sort((e,t)=>c.indexOf(e.dimension)-c.indexOf(t.dimension)||g[e.priority]-g[t.priority]||e.title.localeCompare(t.title,`zh`))}function b(e){let t=y(e);if(!t.length)return``;let n=[];for(let e of c){let r=t.filter(t=>t.dimension===e);if(r.length){n.push(`#### ${u[e].label}`);for(let e of r)n.push(`- **[${e.priority}]** ${e.title}(${e.id})`),e.storyId&&n.push(` - 来源故事:${e.storyId}`),e.precondition&&n.push(` - 前置:${e.precondition}`),e.steps.length&&n.push(` - 步骤:${e.steps.join(`;`)}`),e.expected&&n.push(` - 预期:${e.expected}`)}}return n.join(`
|
|
3
3
|
`)}function x(e){return(e||`需求分析`).replace(/[\\/:*?"<>|]/g,`_`).slice(0,60)}function S(e){let t=[];return e.precondition&&t.push(`前置条件:${e.precondition}`),e.steps.length&&(t.push(`步骤:`),e.steps.forEach((e,n)=>t.push(`${n+1}. ${e}`))),e.expected&&t.push(`预期:${e.expected}`),t.join(`
|
|
4
4
|
`)}function C(e,t){let n=t.replace(/[^A-Za-z0-9_-]/g,``);return n?`${e}-${n}`:`${e}-${Math.random().toString(36).slice(2,8)}`}function w(e){return{id:C(`tp`,e.id),title:`[${e.priority}] ${e.title}`,labels:[u[e.dimension].label,e.priority],markers:[{markerId:d[e.priority].markerId}],notes:{plain:{content:S(e)}}}}function T(e){let t=e.testPoints?.points??[],n=e.stories.map(e=>e.id),r=new Map(e.stories.map(e=>[e.id,e.title])),i=new Map;for(let e of t){let t=e.storyId||``,n=i.get(t);n?n.push(e):i.set(t,[e])}let a=[...n,...[...i.keys()].filter(e=>e&&!n.includes(e)).sort(),``],o=[];for(let e of a){let t=i.get(e);if(!t?.length)continue;let n=e?r.get(e):``;o.push({key:e||`global`,label:e?`${e} ${n??``}`.trim():`全局测试点`,points:[...t].sort((e,t)=>g[e.priority]-g[t.priority]||c.indexOf(e.dimension)-c.indexOf(t.dimension)||e.title.localeCompare(t.title,`zh`))})}return o}function E(e){let t=e.testPoints,n=T(e).map(e=>{let t=c.map(t=>e.points.filter(e=>e.dimension===t).length),n=t.filter(e=>e>0).length;return{id:C(`fn`,e.key),title:`${e.label}(${e.points.length})`,notes:{plain:{content:`测试点 ${e.points.length} 条 · 维度覆盖 ${n}/5\n${c.map((e,n)=>`${u[e].label} ${t[n]}`).join(` · `)}`}},children:{attached:e.points.map(w)}}}),r={id:`root-topic`,title:`测试点 · ${e.title||`未命名分析`}`,structureClass:`org.xmind.ui.logic.right`,notes:{plain:{content:t?.summary?t.summary:`按功能 / 用户故事归组的测试点,叶子标注优先级与所属维度。`}},children:{attached:n}};return[{id:`sheet-1`,class:`sheet`,title:e.title||`测试点`,rootTopic:r}]}async function D(n){let r=E(n),{default:i}=await t(async()=>{let{default:t}=await import(`./jszip.min.Bh2Mgo40.js`).then(t=>e(t.t(),1));return{default:t}},__vite__mapDeps([0,1])),o=new i;return o.file(`content.json`,JSON.stringify(r)),o.file(`metadata.json`,JSON.stringify({creator:{name:`Lantern Harness`,version:a},activeSheetId:`sheet-1`})),o.file(`manifest.json`,JSON.stringify({"file-entries":{"content.json":{},"metadata.json":{}}})),o.generateAsync({type:`blob`,compression:`DEFLATE`})}async function O(e){let t=new Date().toISOString().slice(0,10),n=`${x(e.title)}-测试点-${t}.xmind`,r=await D(e),i=URL.createObjectURL(r),a=document.createElement(`a`);return a.href=i,a.download=n,a.click(),URL.revokeObjectURL(i),n}function k(e){let t=e.testPoints,n=[];if(n.push(`# 测试点 · ${e.title||`未命名分析`}`),n.push(``),n.push(`> 来源:\`${e.sourcePath||`(未指定)`}\` · 故事 ${e.stories.length} 条`),n.push(``),!t)return n.push(`- 还没有生成测试点。`),`${n.join(`
|
|
5
5
|
`)}\n`;let r=v(t);n.push(`- 生成时间:${t.at}`),n.push(`- 共 ${r.total} 条(P0 ${r.byPriority.P0} / P1 ${r.byPriority.P1} / P2 ${r.byPriority.P2} / P3 ${r.byPriority.P3})`),n.push(`- 维度覆盖:${r.coveredDimensions}/5`),t.summary&&(n.push(``),n.push(t.summary)),n.push(``);let i=T(e);if(!i.length)return n.push(`- 还没有生成测试点。`),`${n.join(`
|