lantern-harness 0.1.45 → 0.2.2

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.
Files changed (244) hide show
  1. package/CHANGELOG.md +215 -0
  2. package/README.md +25 -8
  3. package/builtin/session/lh-fs.mjs +93 -4
  4. package/builtin/session/lh-nav-groups.mjs +3 -0
  5. package/builtin/session/mcp-client.mjs +7 -3
  6. package/builtin/session/session-runs.mjs +5 -1
  7. package/builtin/session/skill-validation.mjs +72 -0
  8. package/builtin/session/space-skills.mjs +751 -0
  9. package/cli/data-root.mjs +21 -4
  10. package/cli/lantern.mjs +26 -1
  11. package/cli/mcp-server.mjs +2779 -0
  12. package/cli/server.mjs +8 -2
  13. package/config/app.defaults.json +4 -2
  14. package/dist/500.html +9 -6
  15. package/dist/_astro/Base.Du_-4L-4.css +1 -0
  16. package/dist/_astro/Base.astro_astro_type_script_index_0_lang.XUV2H6ea.js +2 -0
  17. package/dist/_astro/BusinessMapBoard.mRxl2G3D.js +5 -0
  18. package/dist/_astro/CaseExecBoard.Cqkxuf5c.js +1 -0
  19. package/dist/_astro/CaseExecutionBoard.CjX4CoKd.js +5 -0
  20. package/dist/_astro/CaseGenerateApp.acgnxl79.js +10 -0
  21. package/dist/_astro/CasesLibrary.zmzOQwdn.js +21 -0
  22. package/dist/_astro/ChatApp.Ben9LFra.js +1 -0
  23. package/dist/_astro/ChatApp.DBi6q7Qv.js +262 -0
  24. package/dist/_astro/{ConfirmDialog.DrrPf1MB.js → ConfirmDialog.DQFd6g2r.js} +1 -1
  25. package/dist/_astro/DashboardBoard.CAJVE2G4.js +5 -0
  26. package/dist/_astro/{DatePicker.Bkl71M49.js → DatePicker.BRO_CjVQ.js} +1 -1
  27. package/dist/_astro/DefectSubmitEntry.BzKXJ-zq.js +2 -0
  28. package/dist/_astro/DocsFileBrowser.apKMbGVf.js +1 -0
  29. package/dist/_astro/{DocsPager.Duf4I68E.js → DocsPager.DMN9-Tjg.js} +1 -1
  30. package/dist/_astro/{DrawerField.BH3p4Q4D.js → DrawerField.CLdvmHc6.js} +1 -1
  31. package/dist/_astro/KnowledgeLibrary.BcoMQeUd.js +1 -0
  32. package/dist/_astro/LifeKrTasksBoard.DJU0-QI-.js +1 -0
  33. package/dist/_astro/LifeKrTodosBoard.GK7KRAO3.js +1 -0
  34. package/dist/_astro/LifeObjectivesBoard.DuKa6Q3k.js +1 -0
  35. package/dist/_astro/LifePlanTypeSelect.Cm2lUmnH.js +1 -0
  36. package/dist/_astro/{LifeReviewsBoard.BPXeVpg1.js → LifeReviewsBoard.BWOOVMtz.js} +3 -3
  37. package/dist/_astro/{LifeShared.tnT7aQON.js → LifeShared.bY2l01Ha.js} +2 -2
  38. package/dist/_astro/LifeStagesBoard.CIzxPOJB.js +1 -0
  39. package/dist/_astro/LifeYearCycleSelect.BlsyPmmI.js +1 -0
  40. package/dist/_astro/LifeYearPlansBoard.DaA9O08j.js +1 -0
  41. package/dist/_astro/MultiSelectDropdown.D-rbpivp.js +1 -0
  42. package/dist/_astro/{NamePromptDialog.Csfnh5eM.js → NamePromptDialog.KPCeXmri.js} +1 -1
  43. package/dist/_astro/NavLibraries.DVR5Ua-S.js +1 -0
  44. package/dist/_astro/PluginsPage.B063QIlQ.js +18 -0
  45. package/dist/_astro/PmBugsBoard.Cu-v0Gfd.js +1 -0
  46. package/dist/_astro/PmIterationsBoard.CgRzkP-j.js +1 -0
  47. package/dist/_astro/{PmProjectDetail.DneFVBpy.js → PmProjectDetail.DVCEh0Lm.js} +1 -1
  48. package/dist/_astro/PmProjectsBoard.z-bQa98r.js +1 -0
  49. package/dist/_astro/PmRequirementsBoard.B0W6bsW2.js +1 -0
  50. package/dist/_astro/PmRequirementsBoard.CyfBI0u_.js +1 -0
  51. package/dist/_astro/PmShared.BQVzwsiz.js +1 -0
  52. package/dist/_astro/ReportsPage.najSzJeT.js +1 -0
  53. package/dist/_astro/ReqAnalysisBoard.BQb8dHFD.js +39 -0
  54. package/dist/_astro/RequirementBreakdownLibrary.Cn6OV6xt.js +2 -0
  55. package/dist/_astro/RequirementsLibrary.CqKNFVsP.js +1 -0
  56. package/dist/_astro/SearchableSelect.DXclLMJI.js +1 -0
  57. package/dist/_astro/SelectDropdown.D7IeyHDI.js +1 -0
  58. package/dist/_astro/SettingsDialog.db3BpFw0.js +1 -0
  59. package/dist/_astro/SlideOverDrawer.BMg2tce6.js +1 -0
  60. package/dist/_astro/SpaceSwitcher.DSUVAPOi.js +7 -0
  61. package/dist/_astro/{TableFieldConfig.C7O-mL-p.js → TableFieldConfig.72AL-8p-.js} +1 -1
  62. package/dist/_astro/{TagSelect.UUXgkMqJ.js → TagSelect.B_r2p0fp.js} +1 -1
  63. package/dist/_astro/TasksBoard.CCDhCSR7.js +1 -0
  64. package/dist/_astro/TemplatesLibrary.peYzrHZ2.js +1 -0
  65. package/dist/_astro/TestReportsLibrary.fWiEyCRx.js +1 -0
  66. package/dist/_astro/TestStatsBoard.BSUBsWSu.js +1 -0
  67. package/dist/_astro/Toast.BydY-X7T.js +1 -0
  68. package/dist/_astro/TodosBoard.By5YdlUe.js +1 -0
  69. package/dist/_astro/UiAutoBoard.BGdlp5Sr.js +3 -0
  70. package/dist/_astro/UiAutoEnvPanel.BUASgPLB.js +10 -0
  71. package/dist/_astro/UiAutoGenerationDialog.D1PyCgrD.js +12 -0
  72. package/dist/_astro/UiAutoProjectsPage.B6A9NlVK.js +3 -0
  73. package/dist/_astro/app-config.Dvfzl5_N.js +1 -0
  74. package/dist/_astro/app-version.CNpnKIb9.js +1 -0
  75. package/dist/_astro/{bash-tools.D9HCzC_7.js → bash-tools.CS2w8LOb.js} +1 -1
  76. package/dist/_astro/business-map.BiJ85oxm.js +1 -0
  77. package/dist/_astro/business-map.DKwdW1VL.css +1 -0
  78. package/dist/_astro/case-gen-run.Cvvdv_kv.js +26 -0
  79. package/dist/_astro/case-prompt.CZ3vWUju.js +2 -0
  80. package/dist/_astro/{case-review.TdDs1WFM.js → case-review.DFWZkoR9.js} +1 -1
  81. package/dist/_astro/{case-template.Cd2xNbgy.js → case-template.Clb7HrDB.js} +1 -1
  82. package/dist/_astro/defect-submit.Dc49lFjm.css +1 -0
  83. package/dist/_astro/defect-workbench.CjTb4FDv.js +6 -0
  84. package/dist/_astro/dialog.XgRGNF_Q.js +1 -0
  85. package/dist/_astro/doc-roots.C-20VD0x.js +1 -0
  86. package/dist/_astro/{hydrate-cache.B15Nrpq0.js → hydrate-cache.O4CIma9y.js} +1 -1
  87. package/dist/_astro/i18n.Cp4so7KR.js +7 -0
  88. package/dist/_astro/{llm.DN5S1KBK.js → llm.BCYNgppW.js} +1 -1
  89. package/dist/_astro/mcp-tools.Kf-lupGn.js +7 -0
  90. package/dist/_astro/{open-docs-in-session.CRiZT022.js → open-docs-in-session.BpcAcBSI.js} +1 -1
  91. package/dist/_astro/plugins.Db9xoFZb.js +1 -0
  92. package/dist/_astro/project-docs.bB9lQ1Ki.js +1 -0
  93. package/dist/_astro/prompts-meta.VAjE4OET.js +2 -0
  94. package/dist/_astro/report-prompt.CwHuOcRN.js +1 -0
  95. package/dist/_astro/req-analysis.C_gARMrB.js +31 -0
  96. package/dist/_astro/requirement-breakdown-library.l0rPd7b3.js +1 -0
  97. package/dist/_astro/{settings.38J2uD5M.js → settings.D02wZj3w.js} +2 -2
  98. package/dist/_astro/space-skills.CPucW8zt.js +1 -0
  99. package/dist/_astro/{spaces-client.DV04tRyD.js → spaces-client.BAtG6PkW.js} +1 -1
  100. package/dist/_astro/story-review.DTN91Vl9.js +7 -0
  101. package/dist/_astro/test-points.C7ZgggQT.js +8 -0
  102. package/dist/_astro/test-reports.0gr6-c_0.js +19 -0
  103. package/dist/_astro/ui-auto-prompt.BmO3ja2m.js +8 -0
  104. package/dist/_astro/{view-prefs.DhdLZjGh.js → view-prefs.COAKEQtZ.js} +1 -1
  105. package/dist/business-map/index.html +983 -0
  106. package/dist/case-exec/index.html +10 -7
  107. package/dist/{prompts → case-execution}/index.html +12 -9
  108. package/dist/cases/generate/index.html +9 -6
  109. package/dist/cases/library/index.html +10 -7
  110. package/dist/dashboard/index.html +10 -7
  111. package/dist/defect-rules/index.html +690 -0
  112. package/dist/defect-submit/index.html +690 -0
  113. package/dist/defect-submit/templates/index.html +690 -0
  114. package/dist/docs/changelog/index.html +259 -52
  115. package/dist/docs/install/index.html +44 -12
  116. package/dist/docs/manual/index.html +212 -75
  117. package/dist/knowledge/index.html +10 -7
  118. package/dist/life/kr-tasks/index.html +10 -7
  119. package/dist/life/kr-todos/index.html +10 -7
  120. package/dist/life/objectives/index.html +10 -7
  121. package/dist/life/reviews/index.html +10 -7
  122. package/dist/life/stages/index.html +10 -7
  123. package/dist/life/year-plans/index.html +10 -7
  124. package/dist/plugins/index.html +10 -7
  125. package/dist/pm/bugs/index.html +10 -7
  126. package/dist/pm/iterations/index.html +10 -7
  127. package/dist/pm/projects/detail/index.html +10 -7
  128. package/dist/pm/projects/index.html +10 -7
  129. package/dist/pm/requirements/index.html +10 -7
  130. package/dist/reports/index.html +10 -7
  131. package/dist/requirement-analysis/index.html +10 -7
  132. package/dist/requirement-breakdowns/index.html +983 -0
  133. package/dist/requirements/index.html +10 -7
  134. package/dist/tasks/index.html +10 -7
  135. package/dist/templates/index.html +10 -7
  136. package/dist/test-automation/index.html +10 -7
  137. package/dist/test-automation/projects/index.html +10 -7
  138. package/dist/test-reports/index.html +10 -7
  139. package/dist/test-stats/index.html +10 -7
  140. package/dist/todos/index.html +10 -7
  141. package/dist/workbench/index.html +9 -6
  142. package/docs/Codex-MCP/351/233/206/346/210/220.md +296 -0
  143. package/docs//344/270/232/345/212/241/345/234/260/345/233/276/350/257/204/344/274/260.md +39 -0
  144. package/docs//344/270/232/345/212/241/345/234/260/345/233/276/350/257/206/345/210/253/351/207/215/346/236/204/346/226/271/346/241/210.md +88 -0
  145. package/docs//344/274/232/350/257/235/346/217/222/344/273/266.md +22 -3
  146. package/docs//345/205/250/345/261/200/346/217/222/344/273/266.md +41 -1
  147. package/docs//345/256/211/350/243/205/346/211/213/345/206/214.md +63 -17
  148. package/docs//346/217/222/344/273/266/344/273/223/345/272/223/344/270/216/346/212/200/350/203/275/346/225/264/345/220/210/346/226/271/346/241/210.md +187 -0
  149. package/docs//346/223/215/344/275/234/346/211/213/345/206/214.md +207 -69
  150. package/lh-plugins/business-map/assistant.mjs +958 -0
  151. package/lh-plugins/business-map/auth-paths.mjs +61 -0
  152. package/lh-plugins/business-map/jobs.mjs +749 -0
  153. package/lh-plugins/business-map/login.mjs +295 -0
  154. package/lh-plugins/business-map/sources.mjs +1014 -0
  155. package/lh-plugins/case-execution/files.mjs +777 -0
  156. package/lh-plugins/case-execution/service.mjs +959 -0
  157. package/lh-plugins/case-execution-prompt.mjs +33 -0
  158. package/lh-plugins/lh-business-map.mjs +2431 -0
  159. package/lh-plugins/lh-case-execution.mjs +304 -0
  160. package/lh-plugins/lh-config.mjs +13 -0
  161. package/lh-plugins/lh-defect-submit.mjs +989 -0
  162. package/lh-plugins/lh-project-docs.mjs +31 -140
  163. package/lh-plugins/lh-reports.mjs +29 -57
  164. package/lh-plugins/lh-req-analysis.mjs +32 -3
  165. package/lh-plugins/lh-req-breakdown-library.mjs +1084 -0
  166. package/lh-plugins/lh-uiauto.mjs +514 -22
  167. package/lh-plugins/plugin-prompts.mjs +19 -15
  168. package/lh-plugins/req-analysis-revision.mjs +24 -0
  169. package/lh-plugins/test-points-prompt.mjs +2 -3
  170. package/lh-plugins/uiauto-auth-setup.mjs +218 -0
  171. package/lh-plugins/uiauto-explorer/apps.mjs +13 -2
  172. package/lh-plugins/uiauto-explorer/runner.mjs +15 -2
  173. package/lh-plugins/uiauto-explorer/sessions.mjs +305 -17
  174. package/lh-plugins/uiauto-node.mjs +102 -11
  175. package/lh-plugins/uiauto-prompt.mjs +20 -15
  176. package/lh-plugins/uiauto-sso.mjs +407 -0
  177. package/package.json +5 -2
  178. package/skills/case-execution/SKILL.md +30 -0
  179. package/skills/lantern-defect-submit/SKILL.md +15 -0
  180. package/skills/lantern-workflow/SKILL.md +57 -0
  181. package/skills/office/SKILL.md +26 -0
  182. package/dist/_astro/Base.Bkt1lrgu.css +0 -1
  183. package/dist/_astro/Base.astro_astro_type_script_index_0_lang.UKTVQqk7.js +0 -2
  184. package/dist/_astro/CaseExecBoard.DICluCbK.js +0 -1
  185. package/dist/_astro/CaseGenerateApp.Be3h5XPG.js +0 -10
  186. package/dist/_astro/CasesLibrary.Buys7Cy-.js +0 -21
  187. package/dist/_astro/ChatApp.D3BheKci.js +0 -227
  188. package/dist/_astro/DashboardBoard.Qvf8o4v1.js +0 -5
  189. package/dist/_astro/DocsFileBrowser.DwKBffbM.js +0 -1
  190. package/dist/_astro/KnowledgeLibrary.MDpMqeOd.js +0 -1
  191. package/dist/_astro/LifeKrTasksBoard.DsvW_S66.js +0 -1
  192. package/dist/_astro/LifeKrTodosBoard.D2KTqvg1.js +0 -1
  193. package/dist/_astro/LifeObjectivesBoard.B0cDK934.js +0 -1
  194. package/dist/_astro/LifePlanTypeSelect.BELDvMWU.js +0 -1
  195. package/dist/_astro/LifeStagesBoard.CZftLR9K.js +0 -1
  196. package/dist/_astro/LifeYearCycleSelect.Bw2eRbSm.js +0 -1
  197. package/dist/_astro/LifeYearPlansBoard.DB-RJFEl.js +0 -1
  198. package/dist/_astro/MultiSelectDropdown.CBC7aNOv.js +0 -1
  199. package/dist/_astro/NavLibraries.DdQYsZbe.js +0 -1
  200. package/dist/_astro/OverflowHint.CHZeFfUj.js +0 -1
  201. package/dist/_astro/PluginsPage.C1JnInH4.js +0 -17
  202. package/dist/_astro/PluginsPage.C3eEwy3K.js +0 -1
  203. package/dist/_astro/PmBugsBoard.CGpXUTPu.js +0 -1
  204. package/dist/_astro/PmIterationsBoard.BaKiFIam.js +0 -1
  205. package/dist/_astro/PmProjectsBoard.BxoMF9gK.js +0 -1
  206. package/dist/_astro/PmRequirementsBoard.-SI8VZXI.js +0 -1
  207. package/dist/_astro/PmRequirementsBoard.DsK6RF7Q.js +0 -1
  208. package/dist/_astro/PmShared.BK8kWRSV.js +0 -1
  209. package/dist/_astro/PromptMountDialog.mrTx3U5T.js +0 -1
  210. package/dist/_astro/PromptsLibrary.B_SUf47p.js +0 -1
  211. package/dist/_astro/ReportsPage.B9lGg1_s.js +0 -16
  212. package/dist/_astro/ReqAnalysisBoard.CIZKnCQH.js +0 -39
  213. package/dist/_astro/RequirementsLibrary.cJc-bnGQ.js +0 -1
  214. package/dist/_astro/SearchableSelect.SyLRS-Jj.js +0 -1
  215. package/dist/_astro/SelectDropdown.T3CKHaLt.js +0 -1
  216. package/dist/_astro/SettingsDialog.DYdtCvLc.js +0 -1
  217. package/dist/_astro/SpaceSwitcher.C47_S1g9.js +0 -7
  218. package/dist/_astro/TasksBoard.BUEg2BYk.js +0 -1
  219. package/dist/_astro/TemplatesLibrary.BLVIphXO.js +0 -1
  220. package/dist/_astro/TestReportsLibrary.DVq30Jae.js +0 -1
  221. package/dist/_astro/TestStatsBoard.-5BWQ6bI.js +0 -1
  222. package/dist/_astro/Toast.BO2NFckG.js +0 -1
  223. package/dist/_astro/TodosBoard.DI_lTp2e.js +0 -1
  224. package/dist/_astro/UiAutoBoard.ChFdgv7s.js +0 -2
  225. package/dist/_astro/UiAutoEnvPanel.B50q4kYb.js +0 -19
  226. package/dist/_astro/UiAutoGenerationDialog.CLkFAHrm.js +0 -1
  227. package/dist/_astro/UiAutoProjectsPage.DCsDeN5d.js +0 -3
  228. package/dist/_astro/app-config.DkyjuL-S.js +0 -1
  229. package/dist/_astro/app-version.Cy-5oZO2.js +0 -1
  230. package/dist/_astro/case-gen-run.BklG1H8k.js +0 -22
  231. package/dist/_astro/case-types.DlFkbZJN.js +0 -1
  232. package/dist/_astro/dialog.DZHZCe_T.js +0 -1
  233. package/dist/_astro/doc-roots.CO3IBiY6.js +0 -1
  234. package/dist/_astro/i18n.D_aOCHSN.js +0 -7
  235. package/dist/_astro/markdown-client.BS19nLL3.js +0 -62
  236. package/dist/_astro/plugins.BRvXWHLe.js +0 -1
  237. package/dist/_astro/project-docs.CCjtiFjB.js +0 -1
  238. package/dist/_astro/prompts-meta.BUGutlsk.js +0 -2
  239. package/dist/_astro/report-prompt.B9C4cv84.js +0 -1
  240. package/dist/_astro/req-analysis.B12_MGMQ.js +0 -31
  241. package/dist/_astro/story-review.D2W5tEOY.js +0 -14
  242. package/dist/_astro/test-reports.CuIjlEyK.js +0 -19
  243. package/dist/_astro/ui-auto-prompt.H9_yhau9.js +0 -9
  244. package/dist/_astro/ui-auto.DMv940x4.js +0 -1
@@ -1 +0,0 @@
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.DkyjuL-S.js";import{i as te,n as o,r as ne,t as s}from"./listbox.DNxAJmEo.js";import{a as re,o as c}from"./dialog.DZHZCe_T.js";import{t as l}from"./jsx-runtime.DUg_B_vD.js";import{t as ie}from"./ConfirmDialog.DrrPf1MB.js";import{showToast as ae}from"./Toast.BO2NFckG.js";import{t as u}from"./app-version.Cy-5oZO2.js";import{_ as oe,c as se,d as ce,f as le,g as d,i as ue,l as de,n as f,o as p,r as fe,s as pe,t as me,u as he,v as ge,y as _e}from"./settings.38J2uD5M.js";import{i as ve}from"./llm.DN5S1KBK.js";import{n as m}from"./i18n.D_aOCHSN.js";import{s as h}from"./fs-tools.3F9MFrLf.js";import{_ as g,c as _,l as ye}from"./bash-tools.D9HCzC_7.js";import{n as be,t as xe}from"./update.Fq2CGmCX.js";var v=e(t(),1);function y(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===`mcp-client`||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 b=[{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:`会话能力`}],x=[{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:`mcp-client`,packageName:`@deepseek-ai/dsh-mcp-client`,roleZh:`外接 MCP 真客户端(stdio/HTTP → 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 核心`}],S=l();function C(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 w({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,S.jsx)(`span`,{className:`shrink-0 rounded border px-1.5 py-0.5 text-[11px] ${t}`,children:e.label})}function Se({tone:e}){return(0,S.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 T({open:e}){return(0,S.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,S.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`})})}var E=`tw.builtin.showPlanned`;function Ce(){let[e,t]=(0,v.useState)(null),[n,r]=(0,v.useState)(null),[i,ee]=(0,v.useState)(null),[a,te]=(0,v.useState)(null),[o,ne]=(0,v.useState)(!0),[s,re]=(0,v.useState)(``),[c,l]=(0,v.useState)(()=>{try{return localStorage.getItem(E)===`1`}catch{return!1}}),[ie,ae]=(0,v.useState)({}),[u,oe]=(0,v.useState)({});function se(e){ae(t=>({...t,[e]:!t[e]}))}function ce(e){oe(t=>({...t,[e]:!t[e]}))}(0,v.useEffect)(()=>{let e=!0;return(async()=>{try{let[n,i,a,o]=await Promise.all([g(),h(),_(),ye()]);if(!e)return;t(n),r(i),ee(a),te(o)}finally{e&&ne(!1)}})(),()=>{e=!1}},[]);function le(t){let r=y(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 d=s.trim().toLowerCase(),ue=e=>!c&&y(e.id)===`none`&&!d?!1:!d||e.id.toLowerCase().includes(d)||C(e.roleZh).toLowerCase().includes(d),de=b.filter(e=>y(e.id)===`none`).length+x.filter(e=>y(e.id)===`none`).length,f=b.filter(ue),p=x.filter(ue),fe=[{id:`session`,title:`会话插件`,hint:`每个会话各自加载,随会话结束释放`,items:f,total:b.length},{id:`global`,title:`全局插件`,hint:`由系统与所有会话共享,常驻运行`,items:p,total:x.length}];return(0,S.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,S.jsx)(`div`,{className:`shrink-0 px-6 pt-5 pb-3`,children:(0,S.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,S.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,S.jsx)(`h3`,{className:`text-[15px] font-semibold text-stone-900`,children:`内置插件`}),(0,S.jsxs)(`p`,{className:`mt-1 text-xs leading-5 text-stone-500`,children:[`由平台按会话或全局提供,默认常开,不需要开关;状态取决于本机服务是否就绪。`,!c&&de>0?` 已隐藏 ${de} 项规划中能力。`:``]})]}),(0,S.jsxs)(`div`,{className:`flex shrink-0 flex-col items-end gap-2`,children:[(0,S.jsxs)(`label`,{className:`relative block w-44`,children:[(0,S.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,S.jsx)(`circle`,{cx:`11`,cy:`11`,r:`7`}),(0,S.jsx)(`path`,{d:`m20 20-3.5-3.5`})]}),(0,S.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,S.jsxs)(`label`,{className:`inline-flex cursor-pointer items-center gap-1.5 text-[11px] text-stone-500`,children:[(0,S.jsx)(`input`,{type:`checkbox`,className:`rounded border-stone-300 text-[#4176e6] focus:ring-[#4176e6]/30`,checked:c,onChange:e=>{let t=e.target.checked;l(t);try{localStorage.setItem(E,t?`1`:`0`)}catch{}}}),`显示规划中`]})]})]})}),(0,S.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 pb-6`,children:(0,S.jsx)(`div`,{className:`space-y-3`,children:fe.map(e=>{let t=!ie[e.id];return(0,S.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,S.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,S.jsx)(T,{open:t}),(0,S.jsx)(`h4`,{className:`text-[13px] font-medium text-stone-700`,children:e.title}),(0,S.jsx)(`span`,{className:`text-[11px] tabular-nums text-stone-400`,children:d?`${e.items.length}/${e.total}`:e.total}),(0,S.jsx)(`span`,{className:`ml-auto truncate text-[11px] text-stone-400`,children:e.hint})]}),t?e.items.length?(0,S.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=le(t),r=`${e.id}:${t.id}`,i=!!u[r];return(0,S.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,S.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,S.jsx)(`span`,{className:`mt-1.5`,children:(0,S.jsx)(Se,{tone:n.tone})}),(0,S.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,S.jsx)(`p`,{className:`truncate font-mono text-[12.5px] text-stone-800`,children:t.id}),(0,S.jsx)(`p`,{className:`mt-0.5 text-[11.5px] leading-5 text-stone-500 ${i?``:`line-clamp-2`}`,children:C(t.roleZh)})]}),(0,S.jsxs)(`div`,{className:`flex shrink-0 flex-col items-end gap-1.5`,children:[(0,S.jsx)(w,{status:n}),(0,S.jsx)(T,{open:i})]})]}),i?(0,S.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,S.jsx)(`dt`,{className:`shrink-0 text-stone-400`,children:`分类`}),(0,S.jsx)(`dd`,{className:`truncate text-stone-600`,children:t.category}),(0,S.jsx)(`dt`,{className:`shrink-0 text-stone-400`,children:`npm 包`}),(0,S.jsx)(`dd`,{className:`truncate font-mono text-stone-600`,children:t.packageName||`—`})]}):null]},r)})}):(0,S.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 we(e){try{return new URL(e).host}catch{return``}}var Te=[{value:`zh-CN`,label:`中文`},{value:`en`,label:`English`}],D=`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`,O=`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 Ee({className:e=`w-4 h-4`}){return(0,S.jsx)(`svg`,{className:e,viewBox:`0 0 20 20`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,children:(0,S.jsx)(`path`,{d:`M5 10.5l3.5 3.5L15 6.5`,strokeLinecap:`round`,strokeLinejoin:`round`})})}function De({className:e=`w-4 h-4`}){return(0,S.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:[(0,S.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`}),(0,S.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 Oe({className:e=`w-4 h-4`}){return(0,S.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:[(0,S.jsx)(`ellipse`,{cx:`12`,cy:`5`,rx:`8`,ry:`3`}),(0,S.jsx)(`path`,{d:`M4 5v6c0 1.7 3.6 3 8 3s8-1.3 8-3V5`}),(0,S.jsx)(`path`,{d:`M4 11v6c0 1.7 3.6 3 8 3s8-1.3 8-3v-6`})]})}function ke({className:e=`w-4 h-4`}){return(0,S.jsx)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:(0,S.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 Ae({kind:e}){let t=`w-5 h-5`;return e===`sun`?(0,S.jsxs)(`svg`,{className:t,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:[(0,S.jsx)(`circle`,{cx:`12`,cy:`12`,r:`4`}),(0,S.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,S.jsx)(`svg`,{className:t,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:(0,S.jsx)(`path`,{d:`M21 14.5A8.5 8.5 0 1 1 9.5 3a7 7 0 0 0 11.5 11.5z`})}):(0,S.jsxs)(`svg`,{className:t,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:[(0,S.jsx)(`rect`,{x:`3`,y:`4`,width:`18`,height:`12`,rx:`2`}),(0,S.jsx)(`path`,{d:`M8 20h8M12 16v4`})]})}function k({title:e,description:t,control:n}){return(0,S.jsxs)(`div`,{className:`flex items-center gap-4 py-4 border-b border-stone-100 last:border-b-0`,children:[(0,S.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,S.jsx)(`div`,{className:`text-sm font-medium text-stone-800`,children:e}),t?(0,S.jsx)(`div`,{className:`mt-0.5 text-xs text-stone-400 leading-5`,children:t}):null]}),(0,S.jsx)(`div`,{className:`shrink-0`,children:n})]})}function A({value:e,options:t,onChange:n}){let r=t.find(t=>t.value===e)?.label??e;return(0,S.jsxs)(ne,{value:e,onChange:n,children:[(0,S.jsx)(te,{className:O,children:(0,S.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left`,children:r})}),(0,S.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,S.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,S.jsx)(`span`,{children:e.label}),(0,S.jsx)(Ee,{className:`w-4 h-4 text-[#4176e6] opacity-0 group-data-[selected]:opacity-100 shrink-0`})]},e.value))})]})}function j(){let[e,t]=(0,v.useState)(!1),[l,h]=(0,v.useState)(`general`),[g,_]=(0,v.useState)(()=>ee().model.providers),[ye,y]=(0,v.useState)(()=>ee().model.activeId),[b,x]=(0,v.useState)(null),[C,w]=(0,v.useState)(``),[Se,T]=(0,v.useState)(`DeepSeek`),[E,O]=(0,v.useState)(``),[j,je]=(0,v.useState)(``),[M,N]=(0,v.useState)(``),[P,Me]=(0,v.useState)([]),[F,I]=(0,v.useState)(`idle`),[Ne,Pe]=(0,v.useState)(``),[Fe,Ie]=(0,v.useState)(!0),[Le,Re]=(0,v.useState)(!1),[ze,Be]=(0,v.useState)(!1),[Ve,He]=(0,v.useState)(`readonly`),[Ue,We]=(0,v.useState)(!1),[Ge,L]=(0,v.useState)(!1),[Ke,qe]=(0,v.useState)(null),[R,z]=(0,v.useState)({language:`zh-CN`,appearance:`system`,sessionFontSize:14,toolStepDetail:`standard`,busySendBehavior:`queue`,subagentModel:``,allowPrivateWebFetch:!1}),[Je,Ye]=(0,v.useState)(`14`),Xe=(0,v.useRef)(0),[B,Ze]=(0,v.useState)(null),[Qe,$e]=(0,v.useState)(!1),[et,tt]=(0,v.useState)(!1),[nt,V]=(0,v.useState)(!1),[rt,H]=(0,v.useState)(``),U=(0,v.useRef)(null),it=(0,v.useRef)(!1),W=b!==null,G=R.language,K=g.find(e=>e.id===ye),q=(K?.name||``).trim(),J=B?.status??null,at=J?.phase===`done`&&!!J.to&&J.to===B?.current&&u!==B?.current&&Date.now()-Date.parse(J.finishedAt||``)<864e5,ot=J?.phase===`failed`?J.error:``,Y=nt||J?.phase===`installing`||J?.phase===`restarting`,st=(J?.to||B?.latest||``).replace(/^v/,``),X=ot||rt,ct=B?.checkedAt&&!Y?new Date(B.checkedAt).toLocaleTimeString():``,lt=Qe?``:Y?J?.phase===`restarting`?m(`settings.updateRestarting`,void 0,G):m(`settings.updateInstalling`,{v:st},G):X?`${m(`settings.updateFailed`,void 0,G)}:${X}`:at?m(`settings.updateDone`,{v:J?.to||``},G):B?.mode===`dev`&&B?.hasUpdate?m(`settings.updateDevMode`,void 0,G):B?.error?`${m(`settings.updateUnavailable`,void 0,G)}:${B.error}`:B?.hasUpdate?B.mode===`npx`?m(`settings.updateNpxHint`,void 0,G):``:B?`${m(`settings.updateLatest`,void 0,G)}${ct?` · ${m(`settings.updateCheckedAt`,{time:ct},G)}`:``}`:et?m(`settings.updateUnavailable`,void 0,G):``,ut=q||(G===`en`?`No model`:`未配置`),dt=q?K?.model?.trim()?`${q} · ${K.model.trim()}`:q:G===`en`?`No model configured`:`未配置模型`;function ft(e=`general`){h(e),r().then(()=>{pt(),t(!0)})}function pt(){We(n()),_(de()),y(p()),L(!!he()),z(se()),fe(se()),He(pe()),x(null)}function Z(){U.current!==null&&(window.clearInterval(U.current),U.current=null)}async function mt(e=!0){$e(!0);try{let t=await xe(e);t&&(Ze(t),H(``))}finally{$e(!1),tt(!0)}}function ht(e){Z();let t=Date.now()+18e4;U.current=window.setInterval(async()=>{if(!it.current){it.current=!0;try{let n=await xe(!0);if(n){Ze(n);let t=n.status;if(t?.phase===`failed`){Z(),V(!1),H(t.error||m(`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(m(`settings.updateTimeout`,void 0,G)))}finally{it.current=!1}}},1500)}async function gt(){let e=B?.latest||``;H(``),V(!0);let t=B?.current||u,n=await be(e||void 0);n.ok?ht(t):(V(!1),H(n.error||m(`settings.updateFailed`,void 0,G)))}function _t(e){if(!e){let e=a();x(e),w(`DeepSeek`),T(`DeepSeek`),O(`https://api.deepseek.com/v1`),je(``),N(``),Me([]),I(`idle`),Pe(``),Ie(!0),Re(!1),Be(!1);return}x(e.id),w(e.name),O(e.baseURL);let t=e.apiKey?.trim()||(e.id===p()?i().trim():``)||``;je(t),N(e.model),Me(e.availableModels??[]),I(e.availableModels?.length?`ok`:`idle`),Pe(typeof e.contextWindow==`number`&&e.contextWindow>0?String(e.contextWindow):``),Ie(e.supportsTools!==!1),Re(e.supportsVision===!0),T(f.find(t=>t.baseURL===e.baseURL)?.label??`自定义`),Be(!1)}(0,v.useEffect)(()=>{r().then(()=>pt());let e=e=>{let n=e.detail;h(n?.tab===`model`?`model`:n?.tab===`builtin`?`builtin`:`general`),r().then(()=>{pt(),t(!0)})};window.addEventListener(me,e);let n=le(e=>z(e)),i=ce(e=>He(e));return()=>{window.removeEventListener(me,e),n(),i()}},[]),(0,v.useEffect)(()=>{if(e)return(async()=>{let e=await xe(!1);if(tt(!0),!e)return;Ze(e);let t=e.status;(t?.phase===`installing`||t?.phase===`restarting`)&&(V(!0),ht(t.from||e.current))})(),Z},[e]),(0,v.useEffect)(()=>{if(!e||l!==`model`||!W)return;let t=E.trim(),n=j.trim();if(!t||!n){I(e=>e===`ok`?`ok`:`idle`);return}I(`loading`);let r=++Xe.current,i=setTimeout(()=>{ve(t,n).then(e=>{r===Xe.current&&(Me(e),I(`ok`))}).catch(()=>{r===Xe.current&&I(`fail`)})},800);return()=>clearTimeout(i)},[e,l,W,E,j]);function vt(e){T(e);let t=f.find(t=>t.label===e);t&&(t.baseURL&&O(t.baseURL),(!C.trim()||f.some(e=>e.label===C))&&w(t.label)),N(``)}function Q(e){z(oe(e))}(0,v.useEffect)(()=>{Ye(String(R.sessionFontSize))},[R.sessionFontSize]);function yt(){let e=Number(Je);if(!Je.trim()||!Number.isFinite(e)){Ye(String(R.sessionFontSize));return}let t=oe({sessionFontSize:Math.round(e)});z(t),Ye(String(t.sessionFontSize))}let bt=!!(C.trim()&&E.trim()&&j.trim()&&M.trim()),$=P.length>0;function xt(){if(!bt||!b)return;let e=!g.some(e=>e.id===b),t=Number(Ne.trim()),n=Ne.trim()&&Number.isFinite(t)&&t>0?Math.floor(t):void 0,r=_e({id:b,name:C.trim(),baseURL:E.trim(),apiKey:j.trim(),model:M.trim(),availableModels:$?P:void 0,contextWindow:n,supportsTools:Fe,supportsVision:Le},{activate:!0});_(r),y(b),x(null),L(!!he()),ae(e?`已新增模型服务`:`已保存模型服务`,`success`)}function St(e){qe(e)}function Ct(){let e=Ke;if(!e)return;let t=g.find(t=>t.id===e)?.name??`该服务`;qe(null);let n=ue(e);_(n),y(p()),b===e&&x(null),L(!!he()),ae(`已删除模型服务「${t}」`,`success`)}function wt(e){ge(e),y(e),L(!!he())}let Tt=[{value:`readonly`,label:m(`settings.access.readonly`,void 0,G)},{value:`readwrite`,label:m(`settings.access.readwrite`,void 0,G)},{value:`full`,label:m(`settings.access.full`,void 0,G)}],Et=[{value:`concise`,label:m(`settings.step.concise`,void 0,G)},{value:`standard`,label:m(`settings.step.standard`,void 0,G)},{value:`detailed`,label:m(`settings.step.detailed`,void 0,G)},{value:`full`,label:m(`settings.step.full`,void 0,G)}],Dt=[{value:`queue`,label:m(`settings.busySend.queue`,void 0,G)},{value:`interrupt`,label:m(`settings.busySend.interrupt`,void 0,G)}],Ot=[{value:`light`,label:m(`settings.appear.light`,void 0,G),icon:`sun`},{value:`dark`,label:m(`settings.appear.dark`,void 0,G),icon:`moon`},{value:`system`,label:m(`settings.appear.system`,void 0,G),icon:`monitor`}],kt=[{id:`general`,label:m(`settings.general`,void 0,G),icon:(0,S.jsx)(De,{})},{id:`model`,label:m(`settings.model`,void 0,G),icon:(0,S.jsx)(Oe,{})},{id:`builtin`,label:m(`settings.builtin`,void 0,G),icon:(0,S.jsx)(ke,{})}],At=l===`general`||l===`builtin`?m(l===`general`?`settings.general`:`settings.builtin`,void 0,G):W?g.some(e=>e.id===b)?m(`settings.editProvider`,void 0,G):m(`settings.addProviderTitle`,void 0,G):m(`settings.model`,void 0,G);return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`div`,{className:`tw-nav-foot-row`,children:[(0,S.jsxs)(`button`,{type:`button`,onClick:()=>ft(`general`),className:`tw-nav-settings-btn`,"data-hint":Ge?`设置(已配置模型)`:`设置`,children:[(0,S.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,S.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`}),(0,S.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,S.jsx)(`span`,{"data-i18n":`nav.settings`,children:m(`nav.settings`,void 0,G)})]}),(0,S.jsxs)(`button`,{type:`button`,className:`tw-nav-provider-chip${q?``:` is-empty`}`,"data-hint":dt,onClick:()=>ft(`model`),children:[(0,S.jsx)(`span`,{className:`tw-nav-provider-dot`,"aria-hidden":`true`}),(0,S.jsx)(`span`,{className:`tw-nav-provider-name`,children:ut})]})]}),(0,S.jsx)(re,{show:e,children:(0,S.jsxs)(`div`,{className:`fixed inset-0 z-110 flex items-center justify-center p-4`,children:[(0,S.jsx)(c,{children:(0,S.jsx)(`div`,{className:`tw-dialog-backdrop-anim absolute inset-0 bg-stone-950/45`,onClick:()=>t(!1),"aria-hidden":`true`})}),(0,S.jsx)(c,{children:(0,S.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,S.jsxs)(`div`,{className:`shrink-0 h-12 px-4 flex items-center justify-between border-b border-stone-100 bg-white`,children:[(0,S.jsx)(`h2`,{className:`text-sm font-semibold text-stone-800 truncate pr-3`,children:At}),(0,S.jsx)(`button`,{type:`button`,"aria-label":m(`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,S.jsx)(`svg`,{className:`w-4 h-4`,viewBox:`0 0 20 20`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:(0,S.jsx)(`path`,{d:`M5 5l10 10M15 5L5 15`,strokeLinecap:`round`})})})]}),(0,S.jsxs)(`div`,{className:`flex-1 min-h-0 flex`,children:[(0,S.jsx)(`aside`,{className:`w-38 shrink-0 border-r border-stone-100 bg-[#f4f5f7] py-3 px-2 space-y-0.5`,children:kt.map(e=>{let t=l===e.id;return(0,S.jsxs)(`button`,{type:`button`,onClick:()=>{h(e.id),e.id===`model`&&x(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,S.jsx)(`span`,{className:t?`text-[#4176e6]`:`text-stone-400`,children:e.icon}),e.label]},e.id)})}),(0,S.jsx)(`div`,{className:`flex-1 min-w-0 flex flex-col min-h-0 bg-white`,children:l===`general`?(0,S.jsxs)(`div`,{className:`flex-1 min-h-0 flex flex-col`,children:[(0,S.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-6 py-1`,children:[(0,S.jsx)(k,{title:m(`settings.access`,void 0,G),description:m(`settings.accessDesc`,void 0,G),control:(0,S.jsx)(A,{value:Ve,options:Tt,onChange:e=>{He(e),d(e)}})}),(0,S.jsx)(k,{title:m(`settings.language`,void 0,G),control:(0,S.jsx)(A,{value:R.language,options:Te,onChange:e=>Q({language:e})})}),(0,S.jsxs)(`div`,{className:`py-4 border-b border-stone-100`,children:[(0,S.jsx)(`div`,{className:`text-sm font-medium text-stone-800 mb-3`,children:m(`settings.appearance`,void 0,G)}),(0,S.jsx)(`div`,{className:`grid grid-cols-3 gap-2.5`,children:Ot.map(e=>{let t=R.appearance===e.value;return(0,S.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,S.jsx)(Ae,{kind:e.icon}),(0,S.jsx)(`span`,{className:`text-xs font-medium`,children:e.label})]},e.value)})})]}),(0,S.jsx)(k,{title:m(`settings.fontSize`,void 0,G),description:m(`settings.fontSizeDesc`,void 0,G),control:(0,S.jsxs)(`div`,{className:`inline-flex items-center gap-1.5`,children:[(0,S.jsx)(`input`,{type:`number`,min:12,max:22,value:Je,onChange:e=>Ye(e.target.value),onBlur:yt,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,S.jsx)(`span`,{className:`text-sm text-stone-400`,children:`px`})]})}),(0,S.jsx)(k,{title:m(`settings.toolSteps`,void 0,G),description:m(`settings.toolStepsDesc`,void 0,G),control:(0,S.jsx)(A,{value:R.toolStepDetail,options:Et,onChange:e=>Q({toolStepDetail:e})})}),(0,S.jsx)(k,{title:m(`settings.busySend`,void 0,G),description:m(`settings.busySendDesc`,void 0,G),control:(0,S.jsx)(A,{value:R.busySendBehavior,options:Dt,onChange:e=>Q({busySendBehavior:e})})}),(0,S.jsx)(k,{title:m(`settings.allowPrivateWebFetch`,void 0,G),description:m(`settings.allowPrivateWebFetchDesc`,void 0,G),control:(0,S.jsx)(A,{value:R.allowPrivateWebFetch?`on`:`off`,options:[{value:`off`,label:m(`settings.allowPrivateWebFetch.off`,void 0,G)},{value:`on`,label:m(`settings.allowPrivateWebFetch.on`,void 0,G)}],onChange:e=>Q({allowPrivateWebFetch:e===`on`})})}),(0,S.jsx)(k,{title:m(`settings.subagentModel`,void 0,G),description:m(`settings.subagentModelDesc`,void 0,G),control:(0,S.jsx)(A,{value:R.subagentModel?.trim()?R.subagentModel:`inherit`,options:[{value:`inherit`,label:m(`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,S.jsxs)(`div`,{className:`shrink-0 px-6 py-3 border-t border-stone-100`,children:[(0,S.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,S.jsxs)(`div`,{className:`min-w-0 flex items-center gap-2`,children:[(0,S.jsx)(`span`,{className:`text-sm text-stone-700 whitespace-nowrap`,children:m(`settings.platformVersion`,void 0,G)}),(0,S.jsxs)(`span`,{className:`text-sm tabular-nums text-stone-500`,children:[`v`,u]}),B?.hasUpdate&&!Y&&!at?(0,S.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:`${m(`settings.updateAvailable`,void 0,G)} v${(B.latest||``).replace(/^v/,``)}`}):null]}),(0,S.jsx)(`div`,{className:`shrink-0 flex items-center gap-2`,children:Y?(0,S.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,S.jsx)(`span`,{className:`w-3 h-3 rounded-full border-2 border-stone-300 border-t-[#4176e6] animate-spin`}),m(`settings.updateWorking`,void 0,G)]}):at?(0,S.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:m(`settings.updateReload`,void 0,G)}):(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`button`,{type:`button`,disabled:Qe,onClick:()=>void mt(!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,S.jsxs)(S.Fragment,{children:[m(`settings.updateChecking`,void 0,G),(0,S.jsxs)(`span`,{className:`tw-dots`,"aria-hidden":`true`,children:[(0,S.jsx)(`i`,{}),(0,S.jsx)(`i`,{}),(0,S.jsx)(`i`,{})]})]}):m(`settings.updateCheck`,void 0,G)}),B?.hasUpdate?(0,S.jsx)(`button`,{type:`button`,disabled:B.mode===`dev`,onClick:()=>void gt(),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:m(`settings.updateNow`,void 0,G)}):null]})})]}),lt?(0,S.jsx)(`div`,{className:`mt-1 text-[11px] leading-relaxed ${X?`text-red-500`:`text-stone-400`}`,children:lt}):null,X&&B?.logPath?(0,S.jsx)(`div`,{className:`mt-0.5 text-[11px] leading-relaxed text-stone-400 break-all`,children:m(`settings.updateLog`,{path:B.logPath},G)}):null]})]}):W?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`div`,{className:`shrink-0 px-5 pt-3 pb-2 flex items-center gap-2 border-b border-stone-100`,children:(0,S.jsx)(`button`,{type:`button`,onClick:()=>x(null),className:`text-sm text-stone-500 hover:text-stone-800`,children:m(`settings.back`,void 0,G)})}),(0,S.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-5 py-4 space-y-4`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`label`,{className:`block text-xs font-medium text-stone-500 mb-1.5`,children:m(`settings.displayName`,void 0,G)}),(0,S.jsx)(`input`,{type:`text`,value:C,onChange:e=>w(e.target.value),placeholder:`DeepSeek`,className:D})]}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`label`,{className:`block text-xs font-medium text-stone-500 mb-1.5`,children:m(`settings.preset`,void 0,G)}),(0,S.jsx)(`div`,{className:`grid grid-cols-2 gap-2`,children:f.map(e=>{let t=Se===e.label;return(0,S.jsxs)(`button`,{type:`button`,onClick:()=>vt(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,S.jsx)(`div`,{className:`text-sm ${t?`text-[#3565c7] font-medium`:`text-stone-700`}`,children:e.label}),(0,S.jsx)(`div`,{className:`text-[11px] text-stone-400 truncate`,children:e.baseURL?we(e.baseURL):`OpenAI compatible`})]},e.label)})})]}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`label`,{className:`block text-xs font-medium text-stone-500 mb-1.5`,children:m(`settings.baseUrl`,void 0,G)}),(0,S.jsx)(`input`,{type:`text`,value:E,onChange:e=>O(e.target.value),placeholder:`https://api.deepseek.com/v1`,className:D})]}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`label`,{className:`block text-xs font-medium text-stone-500 mb-1.5`,children:m(`settings.apiKey`,void 0,G)}),(0,S.jsxs)(`div`,{className:`relative`,children:[(0,S.jsx)(`input`,{type:ze?`text`:`password`,value:j,onChange:e=>je(e.target.value),placeholder:`sk-...`,className:`${D} pr-14`}),(0,S.jsx)(`button`,{type:`button`,onClick:()=>Be(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:ze?G===`en`?`Hide`:`隐藏`:G===`en`?`Show`:`显示`})]}),Ue?(0,S.jsx)(`p`,{className:`mt-1.5 text-[11px] text-stone-400 leading-5`,children:m(`settings.keyHint`,void 0,G)}):null]}),(0,S.jsxs)(`div`,{children:[(0,S.jsxs)(`div`,{className:`flex items-center justify-between mb-1.5`,children:[(0,S.jsx)(`label`,{className:`text-xs font-medium text-stone-500`,children:m(`settings.modelField`,void 0,G)}),F===`loading`&&(0,S.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:m(`settings.recognizing`,void 0,G)}),$&&F===`ok`&&(0,S.jsx)(`span`,{className:`text-[11px] text-emerald-600`,children:m(`settings.recognized`,{n:P.length},G)}),F===`fail`&&!$&&(0,S.jsx)(`span`,{className:`text-[11px] text-amber-600`,children:m(`settings.recognizeFail`,void 0,G)}),F===`fail`&&$&&(0,S.jsx)(`span`,{className:`text-[11px] text-amber-600`,children:m(`settings.recognizeKeep`,void 0,G)})]}),$?(0,S.jsxs)(ne,{value:M,onChange:N,children:[(0,S.jsx)(te,{className:`${D} flex items-center justify-start text-left hover:border-stone-400 cursor-pointer`,children:(0,S.jsx)(`span`,{className:`min-w-0 truncate text-stone-800`,children:M||(G===`en`?`Select a model`:`请选择模型`)})}),(0,S.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:P.map(e=>(0,S.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,S.jsx)(`span`,{className:`truncate`,children:e}),(0,S.jsx)(Ee,{className:`w-4 h-4 text-[#4176e6] opacity-0 group-data-[selected]:opacity-100 shrink-0 ml-2`})]},e))})]}):(0,S.jsx)(`input`,{type:`text`,value:M,onChange:e=>N(e.target.value),placeholder:m(`settings.modelPlaceholder`,void 0,G),className:D})]}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`label`,{className:`block text-xs font-medium text-stone-500 mb-1.5`,children:m(`settings.contextWindow`,void 0,G)}),(0,S.jsx)(`input`,{type:`number`,min:1,value:Ne,onChange:e=>Pe(e.target.value),placeholder:m(`settings.contextWindowPlaceholder`,void 0,G),className:D}),(0,S.jsx)(`p`,{className:`mt-1.5 text-[11px] text-stone-400 leading-5`,children:m(`settings.contextWindowDesc`,void 0,G)})]}),(0,S.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`label`,{className:`block text-xs font-medium text-stone-500 mb-1.5`,children:m(`settings.supportsTools`,void 0,G)}),(0,S.jsx)(A,{value:Fe?`on`:`off`,options:[{value:`on`,label:m(`settings.cap.on`,void 0,G)},{value:`off`,label:m(`settings.cap.off`,void 0,G)}],onChange:e=>Ie(e===`on`)})]}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`label`,{className:`block text-xs font-medium text-stone-500 mb-1.5`,children:m(`settings.supportsVision`,void 0,G)}),(0,S.jsx)(A,{value:Le?`on`:`off`,options:[{value:`on`,label:m(`settings.cap.on`,void 0,G)},{value:`off`,label:m(`settings.cap.off`,void 0,G)}],onChange:e=>Re(e===`on`)})]})]})]}),(0,S.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,S.jsx)(`button`,{type:`button`,onClick:()=>x(null),className:`px-3.5 py-1.5 text-sm text-stone-600 hover:bg-stone-200/60 rounded-lg`,children:m(`settings.cancel`,void 0,G)}),(0,S.jsx)(`button`,{type:`button`,onClick:xt,disabled:!bt,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:m(`settings.save`,void 0,G)})]})]}):l===`builtin`?(0,S.jsx)(Ce,{}):(0,S.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-6 py-5 bg-[#f4f5f7]`,children:[(0,S.jsx)(`p`,{className:`text-sm text-stone-500`,children:m(`settings.modelIntro`,void 0,G)}),(0,S.jsxs)(`div`,{className:`mt-5 space-y-2.5`,children:[g.map(e=>{let t=!!(e.apiKey?.trim()&&e.baseURL.trim()&&e.model.trim()),n=e.id===ye;return(0,S.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,S.jsxs)(`button`,{type:`button`,"data-hint":n?G===`en`?`Active`:`当前使用`:G===`en`?`Set active`:`设为当前`,onClick:()=>wt(e.id),className:`flex-1 min-w-0 flex items-center gap-2 text-left`,children:[(0,S.jsx)(`span`,{className:`text-sm font-medium text-stone-800 truncate`,children:e.name}),t?(0,S.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full shrink-0 bg-emerald-500`}):null]}),(0,S.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0`,children:[(0,S.jsx)(`button`,{type:`button`,onClick:()=>_t(e),className:`h-8 px-3 text-sm text-stone-700 rounded-lg border border-stone-200 bg-white hover:bg-stone-50`,children:m(`settings.edit`,void 0,G)}),g.length>1?(0,S.jsx)(`button`,{type:`button`,onClick:()=>St(e.id),className:`h-8 px-3 text-sm text-red-600 rounded-lg hover:bg-red-50`,children:m(`settings.delete`,void 0,G)}):null]})]},e.id)}),(0,S.jsx)(`button`,{type:`button`,onClick:()=>_t(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:m(`settings.addProvider`,void 0,G)})]})]})})]})]})})]})}),(0,S.jsx)(ie,{open:Ke!=null,title:m(`settings.delete`,void 0,G),message:m(`settings.deleteConfirm`,void 0,G),confirmLabel:m(`settings.delete`,void 0,G),cancelLabel:G===`en`?`Cancel`:`取消`,danger:!0,onClose:()=>qe(null),onConfirm:Ct})]})}export{j as default};
@@ -1,7 +0,0 @@
1
- import{s as e,t}from"./react.Blvh0GOs.js";import{E as n,f as r,i}from"./app-config.DkyjuL-S.js";import{c as a}from"./plugins.BRvXWHLe.js";import{i as o,n as s,r as c,t as l}from"./dialog.DZHZCe_T.js";import{i as ee,n as u,r as d,t as f}from"./menu.Dnrpz489.js";import{t as p}from"./jsx-runtime.DUg_B_vD.js";import{t as m}from"./ConfirmDialog.DrrPf1MB.js";import{showToast as h}from"./Toast.BO2NFckG.js";import{p as te}from"./project-docs.CCjtiFjB.js";import{u as g}from"./settings.38J2uD5M.js";import{n as _}from"./llm.DN5S1KBK.js";import{t as ne}from"./prompts-meta.BUGutlsk.js";import{n as v}from"./i18n.D_aOCHSN.js";import{a as y,c as re,d as ie,f as b,i as ae,l as oe,m as se,n as ce,o as x,p as le,r as ue,s as de,t as fe,u as pe}from"./spaces-client.DV04tRyD.js";var S=e(t(),1),me=`你是提示词作者。根据用户对这个数据空间的要求,写一份「默认提示词」正文(Markdown 纯文本,不要用代码围栏)。
2
- 这份提示词将作为 Lantern Harness 该空间里 AI 助手的默认人设与回答原则。
3
- 要求:
4
- - 用「你是…」起头设定角色;
5
- - 紧扣用户描述的领域与工作方式;
6
- - 写几条简洁的回答原则(问什么答什么、先结论);
7
- - 只输出提示词正文,不要解释、不要标题。`;function he(e){let t=String(e??``).replace(/^\uFEFF/,``).trim(),n=/^```(?:markdown|md|text)?\s*\n([\s\S]*?)\n```$/i.exec(t);return n&&(t=n[1].trim()),t}var C=p();function ge(e){return e instanceof DOMException&&e.name===`AbortError`||e instanceof Error&&e.name===`AbortError`}function _e({hint:e,children:t}){return e?(0,C.jsx)(`span`,{className:`inline-flex cursor-help`,"data-hint":e,"data-hint-always":``,children:t}):t}function ve(e){let{value:t,onChange:n,onGenerate:r,onStop:i,generating:a,disabled:o}=e,s=(0,S.useRef)(null);(0,S.useLayoutEffect)(()=>{let e=s.current;e&&(e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,96)}px`)},[t]);let c=!!t.trim()&&!a&&!o;return(0,C.jsxs)(`div`,{className:`tw-space-prompt-composer pt-1 rounded-lg bg-white border border-stone-200 outline-none transition-colors focus-within:ring-2 focus-within:ring-[#4176e6]/30 focus-within:border-[#4176e6]`,children:[(0,C.jsx)(`textarea`,{ref:s,value:t,onChange:e=>n(e.target.value),onKeyDown:e=>{if(e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing){if(e.preventDefault(),a){i();return}c&&r()}},placeholder:v(`space.promptBriefPlaceholder`),rows:1,disabled:o,className:`block w-full min-h-6 pl-3.5 pr-2 pt-0.5 pb-0 text-sm leading-5 text-stone-800 bg-transparent resize-none focus:outline-none placeholder:text-stone-400 disabled:opacity-60`}),(0,C.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-1.5 gap-y-2 px-3 pb-2 pt-1`,children:[(0,C.jsx)(`span`,{className:`flex-1`}),(0,C.jsx)(`button`,{type:`button`,onClick:()=>a?i():r(),disabled:!a&&!c,"aria-label":v(a?`space.promptStop`:`space.promptGenerate`),className:`w-7 h-7 shrink-0 rounded-full flex items-center justify-center outline-none transition-colors ${a?`bg-stone-200 text-stone-700 hover:bg-stone-300`:`bg-[#4176e6] text-white hover:bg-[#3565c7] disabled:bg-[#a9c3ef] disabled:cursor-not-allowed`}`,children:a?(0,C.jsx)(`span`,{className:`w-2.5 h-2.5 bg-current rounded-xs`}):(0,C.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,className:`w-4 h-4`,"aria-hidden":!0,children:[(0,C.jsx)(`path`,{d:`m5 12 7-7 7 7`}),(0,C.jsx)(`path`,{d:`M12 19V5`})]})})]})]})}function ye(e){return(0,C.jsxs)(C.Fragment,{children:[(0,C.jsxs)(`div`,{className:`mt-3 flex items-center justify-between gap-2 mb-1.5`,children:[(0,C.jsx)(`label`,{className:`text-xs font-medium text-stone-500`,children:v(`space.promptBodyLabel`)}),(0,C.jsx)(`span`,{className:`text-[11px] text-stone-400 font-mono truncate`,children:ne})]}),(0,C.jsx)(`textarea`,{value:e.value,onChange:t=>e.onChange(t.target.value),placeholder:v(`space.promptBodyPlaceholder`),rows:8,disabled:e.disabled,className:`w-full min-h-36 px-3 py-2 text-sm leading-relaxed rounded-lg border border-stone-200 text-stone-800 outline-none focus:ring-2 focus:ring-[#4176e6]/30 focus:border-[#4176e6] transition-colors resize-y font-[inherit]`}),(0,C.jsx)(`p`,{className:`mt-1.5 text-[11px] text-stone-400 leading-snug`,children:e.hint??v(`space.promptHint`)})]})}function w({open:e,onClose:t,onListChanged:n}){let[a,ee]=(0,S.useState)(null),[u,d]=(0,S.useState)(null),[f,p]=(0,S.useState)(``),[b,w]=(0,S.useState)(``),[T,E]=(0,S.useState)(!1),[D,O]=(0,S.useState)(``),[k,A]=(0,S.useState)(``),[j,M]=(0,S.useState)(``),[N,P]=(0,S.useState)(null),[F,I]=(0,S.useState)(``),[L,R]=(0,S.useState)(``),[be,z]=(0,S.useState)(``),[B,xe]=(0,S.useState)(!1),[Se,Ce]=(0,S.useState)(!1),[V,H]=(0,S.useState)(null),[U,W]=(0,S.useState)(null),[we,Te]=(0,S.useState)(``),[G,K]=(0,S.useState)([]),[Ee,q]=(0,S.useState)({}),De=(0,S.useRef)(null),Oe=(0,S.useRef)(null),ke=(0,S.useRef)(null),J=(0,S.useRef)(null),[Ae,je]=(0,S.useState)(null),Y=(0,S.useCallback)(async(e=!1)=>{e&&d(`stats`);let t=await ie({stats:e});e&&d(null),t?(ee(t),n?.(t)):p(`无法读取数据空间列表(本地服务未运行?)`)},[n]),Me=(0,S.useRef)(Y);(0,S.useEffect)(()=>{Me.current=Y},[Y]);function X(){J.current?.abort()}(0,S.useEffect)(()=>{e?(p(``),w(``),E(!1),P(null),Me.current(!1)):(X(),E(!1),P(null),je(null))},[e]);async function Ne(e){if(Ae||u!==null)return;let t=(e===`create`?k:L).trim();if(!t){p(v(`space.promptNeedReq`));return}p(``);let n=new AbortController;J.current=n,je(e);try{await i();let r=g();if(!r?.apiKey?.trim()||!r.model?.trim()||!r.baseURL?.trim()){p(v(`space.promptNeedModel`));return}let a=(e===`create`?D:F).trim(),o=await _(r,[{role:`system`,content:me},{role:`user`,content:(a?`空间名称:${a}\n\n`:``)+`用户要求:\n${t}`}],n.signal);if(n.signal.aborted)return;let s=he(o);if(!s){p(v(`space.promptGenEmpty`));return}e===`create`?M(s):z(s)}catch(e){if(ge(e)||n.signal.aborted)return;p(e instanceof Error?e.message:String(e))}finally{J.current===n&&(J.current=null),je(null)}}function Pe(){X(),p(``),w(``),O(``),A(``),M(``),E(!0),requestAnimationFrame(()=>Oe.current?.scrollIntoView({block:`nearest`}))}async function Fe(){if(u!==null)return;let e=D.trim();if(!e){p(v(`space.needName`));return}X();let t=j.trim(),n=k.trim();d(`create`),p(``);let i=await ce(e,{switch:!0,...t?{systemPrompt:t}:{},...n?{promptBrief:n}:{}});if(d(null),!i.ok){p(i.error||v(`space.create`)+` 失败`);return}let a=i.space?.id;a&&r(a),window.location.reload()}async function Ie(e){X(),p(``),w(``),P(e),I(e.name),R(``),Ce(!1),z(``),xe(!0),requestAnimationFrame(()=>ke.current?.scrollIntoView({block:`nearest`}));let t=await re(e.id),n=``,r=``;if(t.ok)n=t.brief??``,r=t.systemPrompt??``;else if(e.isActive)try{r=(await te(`prompts`,ne)).content.trim()}catch{}if(xe(!1),!t.ok&&!r){P(null),p(t.error||v(`space.detailFailed`));return}t.space&&I(t.space.name),z(r);let i=!n.trim()&&!!r;R(i?r:n),Ce(i)}async function Le(){if(!N||u!==null)return;let e=F.trim();if(!e){p(v(`space.needName`));return}X(),d(`update`),p(``);let t=await se(N.id,{name:e,...Se?{}:{brief:L},systemPrompt:be});if(d(null),!t.ok){let e=t.error||v(`space.updateFailed`);p(e),h(`保存空间失败:${e}`,`error`);return}let n=!!(t.space&&t.space.name!==N.name),r=N.isActive;P(null);let i=t.space?.name??e;w(v(`space.updated`,{name:i})),h(`已保存数据空间「${i}」`,`success`),n&&r?window.location.reload():await Y(!1)}async function Re(e){if(e.isActive||u!==null)return;d(`update`),p(``);let t=await le(e.id);d(null),t.ok?window.location.reload():p(t.error||`切换失败`)}async function ze(){if(!U)return;let e=we.trim();if(!e)return;d(`copy`),p(``);let t=await fe(U.id,e);if(d(null),!t.ok){let e=t.error||`复制失败`;p(e),h(`复制空间失败:${e}`,`error`)}else W(null),w(`已复制为「${t.space?.name}」`),h(`已复制为「${t.space?.name}」`,`success`),await Y(!1)}async function Be(e,t){d(`delete`),p(``);let n=await ue(e.id,t);if(d(null),!n.ok){let e=n.error||`删除失败`;p(e),h(`删除空间失败:${e}`,`error`)}else H(null),h(`已删除数据空间「${e.name}」`,`success`),e.isActive?(r(`public`),window.location.reload()):(w(n.warning?n.warning:n.purged?`已删除「${e.name}」及其数据`:`已从列表移除「${e.name}」(数据保留在磁盘)`),await Y(!1))}async function Ve(){d(`discover`),p(``),w(``),K([]);let e=await ae();if(d(null),!e.ok){p(e.error||`扫描失败`);return}let t=e.added?.length??0,n=e.backfilled?.length??0,r=e.skipped?.length??0,i=e.candidates??[],a=[];t?a.push(v(`space.discoverAdded`,{n:t})):i.length||a.push(v(`space.discoverNone`)),n&&a.push(v(`space.discoverBackfilled`,{n})),r&&a.push(v(`space.discoverSkipped`,{n:r})),w(a.join(`;`)),K(i),q(Object.fromEntries(i.map(e=>[e.path,e.hasContent===!0]))),await Y(!1)}async function He(){let e=G.filter(e=>Ee[e.path]).map(e=>e.path);if(!e.length){K([]),w(v(`space.candidatesIgnored`));return}d(`discover`),p(``);let t=await ae(e);if(d(null),!t.ok){p(t.error||`纳入失败`);return}K([]);let n=t.added?.length??0,r=t.skipped??[],i=[n?v(`space.candidatesAdopted`,{n}):v(`space.candidatesIgnored`)];r.length&&i.push(v(`space.candidatesRejected`,{names:r.map(e=>e.reason).join(`、`)})),w(i.join(`;`)),await Y(!1)}async function Ue(e){let t=e.target.files?.[0];if(e.target.value=``,!t)return;d(`import`),p(``);let n=await pe(t);d(null),n.ok?(w(`已导入为「${n.space?.name}」`),await Y(!1)):p(n.error||`导入失败`)}let Z=a?.spaces??[],We=new Map(Z.map((e,t)=>[e.id,t])),Ge=e=>e.isPublic?0:e.isActive?1:2,Ke=[...Z].sort((e,t)=>Ge(e)-Ge(t)||(We.get(e.id)??0)-(We.get(t.id)??0)),Q=a?.baseRoot,$=u!==null,qe=Ae===`create`,Je=Ae===`edit`;return(0,C.jsxs)(C.Fragment,{children:[(0,C.jsxs)(c,{open:e,onClose:t,className:`relative z-95`,children:[(0,C.jsx)(l,{transition:!0,className:`tw-dialog-backdrop-anim fixed inset-0 bg-black/30`,"aria-hidden":`true`}),(0,C.jsx)(`div`,{className:`fixed inset-0 flex items-center justify-center p-4`,children:(0,C.jsxs)(o,{transition:!0,className:`tw-dialog-panel-anim tw-space-dialog w-full max-w-4xl rounded-xl shadow-xl border border-stone-200 bg-white flex flex-col h-[86vh]`,children:[(0,C.jsxs)(`div`,{className:`flex items-start justify-between gap-4 px-5 pt-4 pb-3 border-b border-stone-200`,children:[(0,C.jsxs)(`div`,{className:`min-w-0`,children:[(0,C.jsx)(s,{className:`tw-confirm-title text-base font-semibold text-stone-900`,children:v(`space.manageTitle`)}),(0,C.jsx)(`p`,{className:`mt-1 text-xs text-stone-500 leading-relaxed`,children:v(`space.manageDesc`)})]}),(0,C.jsx)(`div`,{className:`shrink-0 flex items-center gap-2`,children:(0,C.jsx)(`button`,{type:`button`,onClick:t,className:`tw-confirm-cancel w-7 h-7 flex items-center justify-center rounded-md text-stone-400 hover:bg-stone-100 hover:text-stone-700 transition-colors`,"aria-label":`关闭`,children:`✕`})})]}),(0,C.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-5 py-4`,children:[f?(0,C.jsxs)(`div`,{className:`mb-3 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700 flex items-start gap-2`,children:[(0,C.jsx)(`span`,{className:`flex-1 min-w-0`,children:f}),(0,C.jsx)(`button`,{type:`button`,onClick:()=>p(``),className:`shrink-0 w-5 h-5 -mr-0.5 flex items-center justify-center rounded text-red-700/70 hover:bg-red-100 hover:text-red-900`,"aria-label":`关闭`,children:`✕`})]}):null,b?(0,C.jsxs)(`div`,{className:`mb-3 rounded-lg border border-emerald-200 bg-emerald-50 px-3 py-2 text-xs text-emerald-700 flex items-start gap-2`,children:[(0,C.jsx)(`span`,{className:`flex-1 min-w-0`,children:b}),(0,C.jsx)(`button`,{type:`button`,onClick:()=>w(``),className:`shrink-0 w-5 h-5 -mr-0.5 flex items-center justify-center rounded text-emerald-700/70 hover:bg-emerald-100 hover:text-emerald-900`,"aria-label":`关闭`,children:`✕`})]}):null,G.length?(0,C.jsxs)(`div`,{className:`mb-3 rounded-lg border border-amber-200 bg-amber-50 px-3 py-2.5`,children:[(0,C.jsx)(`div`,{className:`text-xs font-medium text-amber-800`,children:v(`space.candidatesTitle`,{n:G.length})}),(0,C.jsx)(`p`,{className:`mt-1 text-[11px] leading-snug text-amber-700/90`,children:v(`space.candidatesHint`)}),(0,C.jsx)(`div`,{className:`mt-2 max-h-44 overflow-auto rounded-md border border-amber-200/70 bg-white divide-y divide-stone-100`,children:G.map(e=>(0,C.jsxs)(`label`,{className:`flex items-start gap-2 px-2.5 py-1.5 cursor-pointer hover:bg-stone-50`,children:[(0,C.jsx)(`input`,{type:`checkbox`,checked:Ee[e.path]===!0,onChange:t=>q(n=>({...n,[e.path]:t.target.checked})),className:`mt-0.5 accent-[#4176e6]`}),(0,C.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,C.jsx)(`span`,{className:`block text-xs text-stone-800 truncate`,children:e.name}),(0,C.jsx)(`span`,{className:`block text-[10px] text-stone-400 truncate font-mono`,children:Q?x(e.path,Q):e.path})]})]},e.path))}),(0,C.jsxs)(`div`,{className:`mt-2 flex items-center gap-3`,children:[(0,C.jsx)(`button`,{type:`button`,onClick:()=>q(Object.fromEntries(G.map(e=>[e.path,!0]))),className:`text-[11px] text-[#4176e6] hover:underline`,children:v(`space.candidatesSelectAll`)}),(0,C.jsx)(`button`,{type:`button`,onClick:()=>q({}),className:`text-[11px] text-stone-500 hover:underline`,children:v(`space.candidatesClear`)}),(0,C.jsx)(`span`,{className:`flex-1`}),(0,C.jsx)(`button`,{type:`button`,onClick:()=>{K([]),q({}),w(v(`space.candidatesIgnored`))},className:`px-2.5 py-1 text-[11px] rounded-md border border-stone-200 text-stone-600 hover:bg-stone-50`,children:v(`space.candidatesIgnore`)}),(0,C.jsx)(`button`,{type:`button`,disabled:$,onClick:()=>void He(),className:`px-2.5 py-1 text-[11px] rounded-md bg-[#4176e6] text-white hover:bg-[#3565c7] disabled:opacity-40`,children:v(`space.candidatesAdopt`)})]})]}):null,T?(0,C.jsxs)(`div`,{ref:Oe,children:[(0,C.jsxs)(`div`,{className:`mb-2`,children:[(0,C.jsx)(`div`,{className:`text-xs font-medium text-stone-500`,children:v(`space.newTitle`)}),(0,C.jsx)(`p`,{className:`mt-1 text-[11px] leading-relaxed text-stone-400`,children:v(`space.newDesc`)})]}),(0,C.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,C.jsx)(`input`,{autoFocus:!0,value:D,onChange:e=>O(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),Fe())},placeholder:v(`space.namePlaceholder`),className:`w-full h-9 px-3 text-sm rounded-lg border border-stone-200 text-stone-800 outline-none focus:ring-2 focus:ring-[#4176e6]/30 focus:border-[#4176e6] transition-colors`})}),a?(0,C.jsx)(`div`,{className:`mt-1.5 text-[11px] text-stone-400 truncate`,children:(0,C.jsx)(`code`,{children:x(a.dataRoot,a.baseRoot)})}):null,(0,C.jsxs)(`div`,{className:`mt-4 pt-3 border-t border-stone-200`,children:[(0,C.jsx)(`div`,{className:`text-xs font-medium text-stone-500 mb-1.5`,children:v(`space.promptBriefLabel`)}),(0,C.jsx)(ve,{value:k,onChange:A,onGenerate:()=>void Ne(`create`),onStop:X,generating:qe,disabled:$}),(0,C.jsxs)(`div`,{className:`mt-1.5 flex items-start gap-3`,children:[(0,C.jsx)(`p`,{className:`flex-1 min-w-0 text-[11px] text-stone-400 leading-snug`,children:v(`space.promptHint`)}),qe?(0,C.jsxs)(`p`,{className:`tw-busy-status shrink-0`,"aria-live":`polite`,children:[v(`space.promptGeneratingStatus`),(0,C.jsx)(`span`,{className:`tw-busy-ellipsis`,"aria-hidden":!0})]}):null]}),(0,C.jsx)(ye,{value:j,onChange:M,disabled:$})]})]}):N?(0,C.jsxs)(`div`,{ref:ke,children:[(0,C.jsxs)(`div`,{className:`mb-2`,children:[(0,C.jsx)(`div`,{className:`text-xs font-medium text-stone-500`,children:v(`space.editTitle`)}),(0,C.jsx)(`p`,{className:`mt-1 text-[11px] leading-relaxed text-stone-400 font-mono truncate`,children:Q?x(N.path,Q):N.path})]}),(0,C.jsxs)(`label`,{className:`block text-xs font-medium text-stone-500`,children:[v(`space.nameLabel`),(0,C.jsx)(`input`,{autoFocus:!0,value:F,disabled:B||N.isPublic===!0,onChange:e=>I(e.target.value),className:`mt-1.5 w-full h-9 px-3 text-sm rounded-lg border border-stone-200 text-stone-800 outline-none focus:ring-2 focus:ring-[#4176e6]/30 focus:border-[#4176e6] transition-colors disabled:bg-stone-50 disabled:text-stone-400`})]}),N.isPublic?(0,C.jsx)(`p`,{className:`mt-1 text-[11px] text-stone-400`,children:v(`space.publicNameLocked`)}):null,(0,C.jsxs)(`div`,{className:`mt-4 pt-3 border-t border-stone-200`,children:[(0,C.jsx)(`div`,{className:`text-xs font-medium text-stone-500 mb-1.5`,children:v(`space.promptBriefLabel`)}),(0,C.jsx)(ve,{value:L,onChange:e=>{R(e),Ce(!1)},onGenerate:()=>void Ne(`edit`),onStop:X,generating:Je,disabled:$||B}),(0,C.jsxs)(`div`,{className:`mt-1.5 flex items-start gap-3`,children:[(0,C.jsx)(`p`,{className:`flex-1 min-w-0 text-[11px] text-stone-400 leading-snug`,children:v(`space.promptBriefHint`)}),Je?(0,C.jsxs)(`p`,{className:`tw-busy-status shrink-0`,"aria-live":`polite`,children:[v(`space.promptGeneratingStatus`),(0,C.jsx)(`span`,{className:`tw-busy-ellipsis`,"aria-hidden":!0})]}):null]}),(0,C.jsx)(ye,{value:be,onChange:z,disabled:$||B,hint:v(`space.promptEditHint`)}),B?(0,C.jsx)(`p`,{className:`mt-2 text-[11px] text-stone-400`,children:v(`space.loading`)}):null]})]}):(0,C.jsxs)(C.Fragment,{children:[(0,C.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,C.jsxs)(`div`,{className:`text-xs font-medium text-stone-500`,children:[v(`space.listTitle`),Z.length?(0,C.jsx)(`span`,{className:`ml-1.5 text-[11px] text-stone-400 tabular-nums`,children:Z.length}):null]}),(0,C.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,C.jsx)(`button`,{type:`button`,disabled:$,onClick:()=>De.current?.click(),className:`text-xs text-[#4176e6] hover:underline disabled:opacity-40`,children:u===`import`?`…`:v(`space.import`)}),(0,C.jsx)(`input`,{ref:De,type:`file`,accept:`.zip,application/zip`,className:`hidden`,onChange:e=>void Ue(e)}),(0,C.jsx)(`button`,{type:`button`,disabled:$,onClick:()=>void Ve(),"data-hint":v(`space.discoverTitle`),"data-hint-always":``,className:`text-xs text-[#4176e6] hover:underline disabled:opacity-40`,children:v(u===`discover`?`space.discovering`:`space.discover`)}),(0,C.jsx)(`button`,{type:`button`,disabled:$,onClick:()=>void Y(!0),"data-hint":v(`space.sizeTitle`),"data-hint-always":``,className:`text-xs text-[#4176e6] hover:underline disabled:opacity-40`,children:v(u===`stats`?`space.sizing`:`space.size`)})]})]}),(0,C.jsx)(`div`,{className:`rounded-lg border border-stone-200 divide-y divide-stone-100 overflow-hidden`,children:Z.length===0?(0,C.jsx)(`div`,{className:`px-3 py-8 text-center text-xs text-stone-400`,children:v(`space.empty`)}):Ke.map(e=>(0,C.jsxs)(`div`,{className:`flex items-center gap-3 px-3 py-2.5`,children:[(0,C.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,C.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,C.jsx)(`span`,{className:`text-sm font-medium text-stone-800 truncate`,children:y(e)}),e.isPublic?(0,C.jsx)(`span`,{className:`shrink-0 rounded px-1.5 py-px text-[10px] bg-stone-100 text-stone-500`,children:v(`space.builtin`)}):null,e.isActive?(0,C.jsx)(`span`,{className:`shrink-0 rounded px-1.5 py-px text-[10px] bg-[#4176e6]/10 text-[#3565c7]`,children:v(`space.activeTag`)}):null,e.exists?null:(0,C.jsx)(`span`,{className:`shrink-0 rounded px-1.5 py-px text-[10px] bg-amber-50 text-amber-600`,children:v(`space.missing`)}),e.bytes==null?null:(0,C.jsx)(`span`,{className:`shrink-0 rounded px-1.5 py-px text-[10px] bg-stone-100 text-stone-500 tabular-nums`,children:oe(e.bytes)})]}),(0,C.jsx)(`div`,{className:`mt-0.5 text-[11px] text-stone-400 truncate cursor-help hover:text-stone-500`,"data-hint":Q?x(e.path,Q):e.path,"data-hint-always":``,children:Q?x(e.path,Q):e.path})]}),(0,C.jsxs)(`div`,{className:`shrink-0 flex flex-wrap justify-end items-center gap-1`,children:[!e.isActive&&e.exists?(0,C.jsx)(`button`,{type:`button`,disabled:$,onClick:()=>void Re(e),className:`h-7 px-2 text-xs rounded-md border border-stone-200 text-stone-600 hover:bg-stone-100 disabled:opacity-30 disabled:cursor-not-allowed transition-colors`,children:v(`space.switch`)}):null,(0,C.jsx)(`button`,{type:`button`,disabled:$||!e.exists,onClick:()=>void Ie(e),className:`h-7 px-2 text-xs rounded-md border border-stone-200 text-stone-600 hover:bg-stone-100 disabled:opacity-30 disabled:cursor-not-allowed transition-colors`,children:v(`space.edit`)}),(0,C.jsx)(`button`,{type:`button`,disabled:$,onClick:()=>{W(e),Te(`${e.name}-copy`)},className:`h-7 px-2 text-xs rounded-md border border-stone-200 text-stone-600 hover:bg-stone-100 disabled:opacity-30 disabled:cursor-not-allowed transition-colors`,children:v(`space.copy`)}),(0,C.jsx)(`a`,{href:de(e.id,`content`),"data-hint":v(`space.exportContentTitle`),"data-hint-always":``,className:`h-7 px-2 text-xs rounded-md border border-stone-200 text-stone-600 hover:bg-stone-100 inline-flex items-center transition-colors`,children:v(`space.exportContent`)}),(0,C.jsx)(`a`,{href:de(e.id,`full`),"data-hint":v(`space.exportFullTitle`),"data-hint-always":``,className:`h-7 px-2 text-xs rounded-md border border-stone-200 text-stone-600 hover:bg-stone-100 inline-flex items-center transition-colors`,children:v(`space.exportFull`)}),(0,C.jsx)(_e,{hint:e.removable?void 0:v(`space.publicLocked`),children:(0,C.jsx)(`button`,{type:`button`,disabled:!e.removable||$,onClick:()=>H({kind:`remove`,space:e}),className:`h-7 px-2 text-xs rounded-md border border-stone-200 text-stone-600 hover:bg-stone-100 disabled:opacity-30 disabled:cursor-not-allowed disabled:pointer-events-none transition-colors`,children:v(`space.removeList`)})}),(0,C.jsx)(_e,{hint:e.removable?void 0:v(`space.publicLocked`),children:(0,C.jsx)(`button`,{type:`button`,disabled:!e.removable||$,onClick:()=>H({kind:`delete`,space:e}),className:`h-7 px-2 text-xs rounded-md border border-red-200 text-red-600 hover:bg-red-50 disabled:opacity-30 disabled:cursor-not-allowed disabled:pointer-events-none transition-colors`,children:v(`space.deleteDisk`)})})]})]},e.id))})]})]}),(0,C.jsxs)(`div`,{className:`flex items-center gap-2 px-5 py-3 border-t border-stone-200`,children:[(0,C.jsx)(`button`,{type:`button`,disabled:$||T||N!==null,onClick:()=>{!T&&N===null&&Pe()},className:`h-8 px-3 text-xs font-medium text-white bg-[#4176e6] rounded-lg hover:bg-[#3565c7] disabled:opacity-40 disabled:cursor-not-allowed disabled:hover:bg-[#4176e6] transition-colors`,children:v(`space.addNew`)}),(0,C.jsx)(`span`,{className:`flex-1`}),T||N?(0,C.jsx)(`button`,{type:`button`,disabled:$,onClick:()=>{X(),E(!1),P(null)},className:`tw-confirm-cancel h-8 px-4 text-sm rounded-lg border border-stone-200 text-stone-600 hover:bg-stone-100 disabled:opacity-40 transition-colors`,children:v(`space.cancel`)}):null,T?(0,C.jsx)(`button`,{type:`button`,disabled:!D.trim()||$,onClick:()=>void Fe(),className:`h-8 px-4 text-sm font-medium text-white bg-[#4176e6] rounded-lg hover:bg-[#3565c7] disabled:opacity-40 transition-colors`,children:u===`create`?`…`:v(`space.create`)}):N?(0,C.jsx)(`button`,{type:`button`,disabled:!F.trim()||$||B,onClick:()=>void Le(),className:`h-8 px-4 text-sm font-medium text-white bg-[#4176e6] rounded-lg hover:bg-[#3565c7] disabled:opacity-40 transition-colors`,children:u===`update`?`…`:v(`space.save`)}):null]})]})})]}),(0,C.jsxs)(c,{open:U!==null,onClose:()=>W(null),className:`relative z-96`,children:[(0,C.jsx)(l,{transition:!0,className:`tw-dialog-backdrop-anim fixed inset-0 bg-black/30`,"aria-hidden":`true`}),(0,C.jsx)(`div`,{className:`fixed inset-0 flex items-center justify-center p-4`,children:(0,C.jsxs)(o,{transition:!0,className:`tw-confirm-dialog tw-dialog-panel-anim w-full max-w-sm rounded-xl shadow-xl border border-stone-200 p-5 bg-white`,children:[(0,C.jsx)(s,{className:`tw-confirm-title text-base font-semibold text-stone-900`,children:v(`space.confirmCopyTitle`)}),(0,C.jsx)(`p`,{className:`tw-confirm-msg mt-3 text-sm text-stone-600 leading-relaxed`,children:v(`space.confirmCopyMsg`,{name:U?.name??``})}),(0,C.jsxs)(`label`,{className:`mt-3 block text-xs font-medium text-stone-500`,children:[v(`space.copyName`),(0,C.jsx)(`input`,{autoFocus:!0,value:we,onChange:e=>Te(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),ze())},className:`mt-1.5 w-full h-9 px-3 text-sm rounded-lg border border-stone-200 text-stone-800 outline-none focus:ring-2 focus:ring-[#4176e6]/30 focus:border-[#4176e6] transition-colors`})]}),(0,C.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,C.jsx)(`button`,{type:`button`,onClick:()=>W(null),className:`tw-confirm-cancel h-8 px-3 text-sm rounded-lg border border-stone-200 text-stone-600 hover:bg-stone-100 transition-colors`,children:v(`space.cancel`)}),(0,C.jsx)(`button`,{type:`button`,disabled:!we.trim()||$,onClick:()=>void ze(),className:`h-8 px-4 text-sm font-medium text-white bg-[#4176e6] rounded-lg hover:bg-[#3565c7] disabled:opacity-40 transition-colors`,children:u===`copy`?`…`:v(`space.copy`)})]})]})})]}),(0,C.jsx)(m,{open:V?.kind===`remove`,title:v(`space.confirmRemoveTitle`),message:V?.kind===`remove`?v(`space.confirmRemoveMsg`,{name:V.space.name,path:V.space.path}):``,confirmLabel:v(`space.removeList`),onClose:()=>H(null),onConfirm:()=>{V?.kind===`remove`&&Be(V.space,!1)}}),(0,C.jsx)(m,{open:V?.kind===`delete`,title:v(`space.confirmDeleteTitle`),message:V?.kind===`delete`?v(`space.confirmDeleteMsg`,{name:V.space.name,path:V.space.path}):``,confirmLabel:v(`space.deleteDisk`),danger:`solid`,onClose:()=>H(null),onConfirm:()=>{V?.kind===`delete`&&Be(V.space,!0)}})]})}var T=`tw.spaces.list.v1`;async function E(){let e=n(window.location.pathname,`/`);if(!e?.plugin)return!0;try{let t=await fetch(`/__tb_config`,{signal:AbortSignal.timeout(1500)});if(!t.ok)return!0;let n=await t.json();return a(n.config?.plugins??{})[e.plugin]!==!1}catch{return!0}}function D(){try{let e=sessionStorage.getItem(T);if(!e)return null;let t=JSON.parse(e);return t&&Array.isArray(t.spaces)?t:null}catch{return null}}function O(e){try{sessionStorage.setItem(T,JSON.stringify(e))}catch{}}function k(e){try{e?document.documentElement.dataset.spaceService=`none`:delete document.documentElement.dataset.spaceService}catch{}}function A(){let e=D(),[t,n]=(0,S.useState)(e!==null),[r,i]=(0,S.useState)(e!==null),[a,o]=(0,S.useState)(e),[s,c]=(0,S.useState)(!1),[l,p]=(0,S.useState)(!1),[m,h]=(0,S.useState)(``);(0,S.useEffect)(()=>{let e=!0;return(async()=>{let t=await b();if(!e)return;if(i(!0),!t){n(!1),k(!0);return}k(!1),n(!0);let r=await ie();e&&r&&(o(r),O(r))})(),()=>{e=!1}},[]);async function te(e){if(e===a?.activeId)return;p(!0),h(``);let t=await le(e);t.ok?(a&&O({...a,activeId:e,spaces:a.spaces.map(t=>({...t,isActive:t.id===e}))}),await E()?window.location.reload():window.location.replace(`/workbench/`)):(p(!1),h(t.error||`切换失败`))}if(!r)return null;if(!t)return(0,C.jsx)(`div`,{className:`tw-nav-space`,children:(0,C.jsxs)(`div`,{className:`tw-nav-space-btn tw-nav-space-btn--off`,children:[(0,C.jsx)(`span`,{className:`tw-nav-space-ico`,"aria-hidden":`true`,children:(0,C.jsx)(j,{})}),(0,C.jsxs)(`span`,{className:`tw-nav-space-text`,children:[(0,C.jsx)(`span`,{className:`tw-nav-space-cap`,children:v(`space.offlineCap`)}),(0,C.jsx)(`span`,{className:`tw-nav-space-name`,children:v(`space.offline`)})]})]})});let g=a?.spaces.find(e=>e.isActive),_=(a?.spaces??[]).filter(e=>!e.isActive);return(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(`div`,{className:`tw-nav-space`,children:(0,C.jsxs)(d,{as:`div`,className:`tw-nav-space-menu`,children:[(0,C.jsxs)(f,{className:`tw-nav-space-btn`,"data-hint":v(`space.label`),children:[(0,C.jsx)(`span`,{className:`tw-nav-space-ico`,"aria-hidden":`true`,children:(0,C.jsx)(j,{})}),(0,C.jsxs)(`span`,{className:`tw-nav-space-text`,children:[(0,C.jsx)(`span`,{className:`tw-nav-space-cap`,children:v(`space.current`)}),(0,C.jsx)(`span`,{className:`tw-nav-space-name`,children:l?v(`space.switching`):g?y(g):`—`})]}),(0,C.jsx)(`svg`,{className:`tw-nav-space-caret`,viewBox:`0 0 24 24`,width:`13`,height:`13`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,C.jsx)(`path`,{d:`m6 9 6 6 6-6`})})]}),(0,C.jsxs)(ee,{transition:!0,anchor:{to:`bottom start`,gap:`0.375rem`},className:`tw-nav-space-pop tw-menu-anim`,children:[m?(0,C.jsx)(`div`,{className:`tw-nav-space-err`,role:`alert`,children:m}):null,(0,C.jsx)(`div`,{className:`tw-nav-space-group`,children:v(`space.others`)}),_.length===0?(0,C.jsx)(`p`,{className:`tw-nav-space-hint`,children:v(`space.othersEmpty`)}):_.map(e=>(0,C.jsx)(u,{children:(0,C.jsxs)(`button`,{type:`button`,className:`tw-nav-space-item`,disabled:l,onClick:()=>void te(e.id),children:[(0,C.jsx)(`span`,{className:`tw-nav-space-item-main`,children:(0,C.jsx)(`span`,{className:`tw-nav-space-item-name`,"data-hint":y(e),children:y(e)})}),(0,C.jsx)(`svg`,{className:`tw-nav-space-item-go`,viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,C.jsx)(`path`,{d:`m9 6 6 6-6 6`})})]})},e.id)),(0,C.jsx)(`div`,{className:`tw-nav-space-sep`}),(0,C.jsx)(u,{children:(0,C.jsxs)(`button`,{type:`button`,className:`tw-nav-space-item tw-nav-space-item--manage`,onClick:()=>c(!0),children:[(0,C.jsx)(`span`,{className:`tw-nav-space-item-ico`,"aria-hidden":`true`,children:(0,C.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:[(0,C.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`}),(0,C.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,C.jsx)(`span`,{className:`tw-nav-space-item-main`,children:(0,C.jsx)(`span`,{className:`tw-nav-space-item-name`,children:v(`space.manage`)})}),(0,C.jsx)(`svg`,{className:`tw-nav-space-item-go`,viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,C.jsx)(`path`,{d:`m9 6 6 6-6 6`})})]})})]})]})}),(0,C.jsx)(w,{open:s,onClose:()=>c(!1),onListChanged:e=>{o(e),O(e)}})]})}function j(){return(0,C.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`15`,height:`15`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,C.jsx)(`path`,{d:`M3 7.5 12 3l9 4.5-9 4.5-9-4.5Z`}),(0,C.jsx)(`path`,{d:`m3 12.5 9 4.5 9-4.5`}),(0,C.jsx)(`path`,{d:`m3 17 9 4.5 9-4.5`})]})}export{A as default};
@@ -1 +0,0 @@
1
- import{s as e,t}from"./react.Blvh0GOs.js";import{i as n}from"./app-config.DkyjuL-S.js";import{i as r,o as i,s as ee}from"./plugins.BRvXWHLe.js";import{n as a,o,r as s,s as c}from"./view-prefs.DhdLZjGh.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.DrrPf1MB.js";import{t as h}from"./DatePicker.Bkl71M49.js";import{t as g}from"./SelectDropdown.T3CKHaLt.js";import{E as _}from"./PmShared.BK8kWRSV.js";import{n as v,r as y,t as b}from"./TableFieldConfig.C7O-mL-p.js";import{showToast as x}from"./Toast.BO2NFckG.js";import{c as te,d as S,i as ne,l as re,n as ie,o as ae,t as C}from"./ColumnResize.CkE59sGq.js";import{C as w,F as oe,O as se,a as T,b as E,c as ce,f as le,g as ue,h as de,i as D,j as O,m as k,n as A,o as fe,p as pe,r as me,s as he,t as j,u as ge}from"./tasks.DEyD8pmq.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.BH3p4Q4D.js";var z=e(t(),1),B=p(),_e=8e3,ve=[{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:`createdAt`,width:140,min:110},{key:`updatedAt`,width:140,min:110},{key:`filler`,filler:!0},{key:`action`,width:76,min:64}],ye=new Set([`title`,`filler`,`action`]),be=[{key:`status`,label:`任务状态`},{key:`priority`,label:`紧急程度`},{key:`start`,label:`开始日期`},{key:`due`,label:`截止日期`},{key:`cycle`,label:`任务周期`},{key:`todos`,label:`待办数量`},{key:`progress`,label:`完成进度`},{key:`note`,label:`备注`},{key:`createdAt`,label:`创建日期`},{key:`updatedAt`,label:`修改日期`}],xe=`tasks.fields`,Se={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`},Ce={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`},V={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]`},H={pool:`bg-stone-400`,in_progress:`bg-[#3370ff]`,done:`bg-[#34c724]`,closed:`bg-stone-300`,cancelled:`bg-stone-300`},we={urgent_important:`bg-[#f54a45]`,important:`bg-[#ff8800]`,urgent:`bg-[#f7ba1e]`,normal:`bg-stone-300`,"":`border border-stone-300 bg-transparent`},Te=me.map(e=>({value:e,label:D[e]})),Ee=j.map(e=>({value:e,label:A[e]})),De=`h-8 w-full justify-start rounded-md border border-stone-200 bg-white px-2 text-left text-sm font-normal text-stone-400 hover:border-stone-300 focus:ring-2 focus:ring-[#3370ff]/30`,Oe=`h-8 w-auto max-w-full justify-start bg-transparent px-0 text-left focus:ring-0`,ke=`未选择`,Ae=[{value:`all`,label:`全部优先级`},...j.map(e=>({value:e,label:A[e]}))],je=[{value:`all`,label:`全部`},{value:`pool`,label:`任务池`},{value:`in_progress`,label:`进行中`},{value:`done`,label:`已完成`},{value:`closed`,label:`已关闭`},{value:`cancelled`,label:`已取消`}],Me=[`all`,`pool`,`in_progress`,`done`,`closed`,`cancelled`],Ne=`tasks.status-tab`,Pe=`tasks.priority-filter`,Fe=`tasks.search`,Ie=Ae.map(e=>e.value);function U(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 Le(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:O(),dueDate:O()}))},[t,n]);function g(e){o(t=>({...t,...e}))}let v=k({startDate:a.startDate??``,dueDate:a.dueDate??``}),y=n?r.filter(e=>e.taskId===n.id):[],b=y.filter(e=>e.status===`done`).length,te=y.length?Math.round(b/y.length*100):0;async function S(){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 ue(n.id,a):await T([{...a,title:e}],{mode:`manual`}),await ee(),x(n?`已保存任务`:`已新建任务`,`success`),i()}catch(e){let t=e instanceof Error?e.message:String(e);c(t),x(`保存任务失败:${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 overflow-hidden`,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 duration-[280ms]`,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=>g({title:e.target.value}),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),S())},placeholder:`请输入内容`,className:R})}),(0,B.jsx)(P,{icon:(0,B.jsx)(L,{}),label:`任务状态`,children:(0,B.jsx)(I,{ariaLabel:`任务状态`,menuMinWidth:140,options:Te,value:a.status??`pool`,onChange:e=>g({status:e}),label:D[a.status??`pool`],optionDotClassName:e=>H[e]})}),(0,B.jsx)(P,{icon:(0,B.jsx)(L,{}),label:`紧急程度`,children:(0,B.jsx)(I,{ariaLabel:`紧急程度`,menuMinWidth:140,options:Ee,value:a.priority??``,onChange:e=>g({priority:e}),label:a.priority?A[a.priority]:ke,optionDotClassName:e=>we[e]})}),(0,B.jsx)(P,{icon:(0,B.jsx)(M,{}),label:`开始日期`,children:(0,B.jsx)(h,{value:a.startDate??``,onChange:e=>g({startDate:e}),className:`${R} tabular-nums`})}),(0,B.jsx)(P,{icon:(0,B.jsx)(M,{}),label:`截止日期`,children:(0,B.jsx)(h,{value:a.dueDate??``,onChange:e=>g({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:v===null?`—`:`${v} 天`})}),(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:y.length?`${b}/${y.length} · ${te}%`:`还没有关联待办`})}),(0,B.jsx)(P,{icon:(0,B.jsx)(N,{}),label:`备注`,children:(0,B.jsx)(`textarea`,{value:a.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`})}),n?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(P,{icon:(0,B.jsx)(M,{}),label:`创建日期`,children:(0,B.jsx)(`div`,{className:`px-2 pt-1.5 text-sm text-stone-500`,children:_(n.createdAt)})}),(0,B.jsx)(P,{icon:(0,B.jsx)(M,{}),label:`修改日期`,children:(0,B.jsx)(`div`,{className:`px-2 pt-1.5 text-sm text-stone-500`,children:_(n.updatedAt)})})]}):null,n&&y.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:y.map(e=>{let t=w(e,O());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 ${V[t]}`,children:E[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 S(),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 Re(){let[e,t]=(0,z.useState)(!1),[l,u]=(0,z.useState)(!0),[d,f]=(0,z.useState)(!0),[p,w]=(0,z.useState)(null),[T,E]=(0,z.useState)([]),[O,me]=(0,z.useState)([]),[j,M]=(0,z.useState)(null),[N,P]=(0,z.useState)(!1),[F,I]=(0,z.useState)(()=>s(Fe)),[L,R]=(0,z.useState)(()=>a(Ne,Me,`all`)),[V,Re]=(0,z.useState)(()=>a(Pe,Ie,`all`)),[ze,W]=(0,z.useState)(null),[G,K]=(0,z.useState)(null);function Be(e){o(Ne,e),R(e)}function Ve(e){c(Fe,e),I(e)}function He(e){o(Pe,e),Re(e)}let q=(0,z.useRef)(!0),J=y(xe,be,ye),Ue=(0,z.useMemo)(()=>v(ve,J.isVisible),[J.isVisible]),Y=re(`lh:tasks:cols:v1`,Ue),We=S(`tasks`);(0,z.useEffect)(()=>(q.current=!0,()=>{q.current=!1}),[]);let X=(0,z.useCallback)(async()=>{try{let[e,t]=await Promise.all([ge(),d?se().catch(()=>[]):Promise.resolve([])]);if(!q.current)return;E(e),me(t),M(null)}catch(e){if(!q.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 he();q.current&&(e?(await X(),q.current&&w(!0)):w(!1))})()},[e,l,X]),(0,z.useEffect)(()=>{if(p!==!0)return;let e=window.setInterval(()=>void X(),_e),t=()=>void X();return window.addEventListener(`focus`,t),()=>{window.clearInterval(e),window.removeEventListener(`focus`,t)}},[p,X]);let Ge=(0,z.useMemo)(()=>de(O),[O]),Z=(0,z.useMemo)(()=>pe(T),[T]),Ke=(0,z.useMemo)(()=>ce(T,{status:L,priority:V,keyword:F}),[T,L,V,F]),Q=(0,z.useMemo)(()=>le(Ke),[Ke]);async function $(e,t){E(n=>n.map(n=>n.id===e?{...n,...t}:n));try{let n=await ue(e,t);if(!q.current)return;E(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 qe(){let e=G;if(e){K(null),P(!0);try{await fe([e.id]),await Promise.all(O.filter(t=>t.taskId===e.id).map(e=>oe(e.id,{taskId:``,linkedTask:``}).catch(()=>null))),await X(),x(`已删除任务「${e.title}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);M(t),x(`删除任务失败:${t}`,`error`)}finally{q.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)(U,{label:`全部任务`,value:Z.total}),(0,B.jsx)(U,{label:`任务池`,value:Z.pool}),(0,B.jsx)(U,{label:`进行中`,value:Z.in_progress}),(0,B.jsx)(U,{label:`已完成`,value:Z.done}),(0,B.jsx)(U,{label:`已关闭`,value:Z.closed}),(0,B.jsx)(U,{label:`已取消`,value:Z.cancelled}),(0,B.jsx)(U,{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=>Ve(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:je.map(e=>(0,B.jsx)(`button`,{type:`button`,onClick:()=>Be(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)(g,{flat:!0,className:`w-[136px]`,ariaLabel:`优先级筛选`,options:Ae,value:V,onChange:e=>He(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)(b,{fields:J.fields,isVisible:J.isVisible,onToggle:J.toggle}),(0,B.jsx)(`button`,{type:`button`,disabled:N,onClick:()=>W({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:We,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:Ue.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:ae,children:[`任务描述`,(0,B.jsx)(C,{...Y.resizeProps(`title`)})]}),J.isVisible(`status`)?(0,B.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`任务状态`,(0,B.jsx)(C,{...Y.resizeProps(`status`)})]}):null,J.isVisible(`priority`)?(0,B.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`紧急程度`,(0,B.jsx)(C,{...Y.resizeProps(`priority`)})]}):null,J.isVisible(`start`)?(0,B.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`开始日期`,(0,B.jsx)(C,{...Y.resizeProps(`start`)})]}):null,J.isVisible(`due`)?(0,B.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`截止日期`,(0,B.jsx)(C,{...Y.resizeProps(`due`)})]}):null,J.isVisible(`cycle`)?(0,B.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`任务周期`,(0,B.jsx)(C,{...Y.resizeProps(`cycle`)})]}):null,J.isVisible(`todos`)?(0,B.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`待办数量`,(0,B.jsx)(C,{...Y.resizeProps(`todos`)})]}):null,J.isVisible(`progress`)?(0,B.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`完成进度`,(0,B.jsx)(C,{...Y.resizeProps(`progress`)})]}):null,J.isVisible(`note`)?(0,B.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`备注`,(0,B.jsx)(C,{...Y.resizeProps(`note`)})]}):null,J.isVisible(`createdAt`)?(0,B.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`创建日期`,(0,B.jsx)(C,{...Y.resizeProps(`createdAt`)})]}):null,J.isVisible(`updatedAt`)?(0,B.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`修改日期`,(0,B.jsx)(C,{...Y.resizeProps(`updatedAt`)})]}):null,(0,B.jsx)(`th`,{"aria-hidden":`true`}),(0,B.jsx)(`th`,{className:te,children:`操作`})]})}),(0,B.jsxs)(`tbody`,{children:[Q.map(e=>{let t=k(e),n=Ge[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:ie,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:()=>W({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})]})}),J.isVisible(`status`)?(0,B.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,B.jsx)(g,{unstyled:!0,fitContent:!0,hideChevron:!0,centerContent:!0,ariaLabel:`任务状态`,menuMinWidth:120,options:Te,value:e.status,onChange:t=>void $(e.id,{status:t}),triggerClassName:`h-7 max-w-full rounded-md px-2 text-center text-xs font-medium focus:ring-2 focus:ring-[#3370ff]/30 ${Se[e.status]}`,renderTrigger:()=>(0,B.jsx)(`span`,{className:`truncate`,children:D[e.status]}),renderOptionPrefix:e=>(0,B.jsx)(`span`,{className:`h-2 w-2 rounded-full ${H[e.value]}`})})}):null,J.isVisible(`priority`)?(0,B.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,B.jsx)(g,{unstyled:!0,fitContent:!!e.priority,hideChevron:!0,ariaLabel:`紧急程度`,menuMinWidth:128,options:Ee,value:e.priority,onChange:t=>void $(e.id,{priority:t}),triggerClassName:e.priority?Oe:De,renderTrigger:()=>e.priority?(0,B.jsx)(`span`,{className:`inline-flex h-7 max-w-full items-center truncate rounded-md px-2 text-xs font-medium ${Ce[e.priority]}`,children:A[e.priority]}):(0,B.jsx)(`span`,{className:`truncate text-stone-400`,children:ke}),renderOptionPrefix:e=>(0,B.jsx)(`span`,{className:`h-2 w-2 rounded-full ${we[e.value]}`})})}):null,J.isVisible(`start`)?(0,B.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,B.jsx)(h,{value:e.startDate,onChange:t=>void $(e.id,{startDate:t}),placeholder:`选择日期`,className:`h-8 rounded-md px-1.5 text-sm tabular-nums`})}):null,J.isVisible(`due`)?(0,B.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,B.jsx)(h,{value:e.dueDate,onChange:t=>void $(e.id,{dueDate:t}),placeholder:`选择日期`,className:`h-8 rounded-md px-1.5 text-sm tabular-nums`})}):null,J.isVisible(`cycle`)?(0,B.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap text-stone-500 tabular-nums`,children:t===null?`—`:`${t} 天`}):null,J.isVisible(`todos`)?(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:`待办事项未启用`})}):null,J.isVisible(`progress`)?(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:`待办事项未启用`})}):null,J.isVisible(`note`)?(0,B.jsx)(`td`,{className:`truncate px-2 py-1 align-middle text-xs text-stone-500`,children:e.note||`—`}):null,J.isVisible(`createdAt`)?(0,B.jsx)(`td`,{className:`whitespace-nowrap px-2 py-1 align-middle text-xs text-stone-500`,children:_(e.createdAt)}):null,J.isVisible(`updatedAt`)?(0,B.jsx)(`td`,{className:`whitespace-nowrap px-2 py-1 align-middle text-xs text-stone-500`,children:_(e.updatedAt)}):null,(0,B.jsx)(`td`,{"aria-hidden":`true`}),(0,B.jsx)(`td`,{className:ne,children:(0,B.jsxs)(`div`,{className:`flex items-center justify-end gap-0.5`,children:[(0,B.jsx)(`button`,{type:`button`,onClick:()=>W({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:()=>K(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:T.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)(Le,{open:ze!==null,task:ze?.task??null,todos:O,onClose:()=>W(null),onSaved:X}),(0,B.jsx)(m,{open:G!=null,title:`删除任务`,message:`删除「${G?.title??``}」?已关联的待办会保留,但不再挂在该任务下。`,confirmLabel:`删除`,cancelLabel:`取消`,danger:!0,onClose:()=>K(null),onConfirm:()=>void qe()})]}):(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{Re as default};
@@ -1 +0,0 @@
1
- import{s as e,t}from"./react.Blvh0GOs.js";import{i as n}from"./app-config.DkyjuL-S.js";import{i as r,o as i,s as a}from"./plugins.BRvXWHLe.js";import{t as o}from"./jsx-runtime.DUg_B_vD.js";import{t as s}from"./ConfirmDialog.DrrPf1MB.js";import{n as c,t as ee}from"./DocsPager.Duf4I68E.js";import{showToast as l}from"./Toast.BO2NFckG.js";import{a as te,c as u,d as ne,f as d,g as re,h as ie,i as ae,l as oe,m as se,n as ce,p as f,r as le,s as ue,t as de,u as fe}from"./project-docs.CCjtiFjB.js";import{i as p,n as m,r as h}from"./case-template.Cd2xNbgy.js";import{n as pe}from"./doc-roots.CO3IBiY6.js";import{t as me}from"./ExcelFieldTags.CXif3Ilh.js";import{t as g}from"./NamePromptDialog.Csfnh5eM.js";import{t as he}from"./useListAnim.BoerpmsB.js";var _=e(t(),1),v=o(),ge=5;async function _e(e){let t=e.name.toLowerCase();try{if(t.endsWith(`.xlsx`)||t.endsWith(`.xls`)){let t=await d(`templates`,e.path);if(t.encoding===`base64`&&t.contentBase64)return p(t.contentBase64).headers}else if(t.endsWith(`.csv`)){let t=await f(`templates`,e.path);return m(t.content).headers}else if(t.endsWith(`.md`)||t.endsWith(`.txt`)){let t=await f(`templates`,e.path);return h(t.content).headers}}catch{}return[]}function y({className:e=`w-4 h-4`,open:t=!1}){return(0,v.jsx)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:t?(0,v.jsx)(`path`,{d:`M6 14l1.45-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.55 6a2 2 0 0 1-1.94 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2`}):(0,v.jsx)(`path`,{d:`M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7z`})})}function b({className:e=`w-3 h-3`}){return(0,v.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,v.jsx)(`path`,{d:`M21.17 6.81a1 1 0 0 0-3.99-3.99L3.84 16.17a2 2 0 0 0-.5.83l-1.32 4.35a.5.5 0 0 0 .62.62l4.35-1.32a2 2 0 0 0 .83-.5z`}),(0,v.jsx)(`path`,{d:`m15 5 4 4`})]})}function x({className:e=`w-3 h-3`}){return(0,v.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,v.jsx)(`path`,{d:`M3 6h18`}),(0,v.jsx)(`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`}),(0,v.jsx)(`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`}),(0,v.jsx)(`path`,{d:`M10 11v6`}),(0,v.jsx)(`path`,{d:`M14 11v6`})]})}function S({node:e,depth:t,activePath:n,expanded:r,globalOpen:i,onToggle:a,onSelect:o}){let s=r[e.path]??i,c=n===e.path;return(0,v.jsxs)(`div`,{children:[(0,v.jsx)(`div`,{className:`group flex items-center rounded-md ${c?`bg-[#e8f0fe]`:`hover:bg-stone-100`}`,style:{paddingLeft:8+t*12},children:(0,v.jsxs)(`button`,{type:`button`,onClick:()=>{o(e.path),e.children.length&&a(e.path)},"aria-expanded":e.children.length?s:void 0,className:`flex-1 min-w-0 flex items-center gap-1.5 py-1.5 pr-1 text-sm text-left ${c?`text-[#4176e6]`:`text-stone-600`}`,children:[(0,v.jsx)(`span`,{className:`w-3.5 shrink-0`,"aria-hidden":`true`}),(0,v.jsx)(y,{open:!!(e.children.length&&s),className:`w-3.5 h-3.5 shrink-0 text-[#4176e6]`}),(0,v.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,children:e.name}),(0,v.jsxs)(`span`,{className:`shrink-0 tabular-nums text-[11px] text-stone-400`,children:[`(`,e.fileCount??0,`)`]})]})}),(0,v.jsx)(`div`,{className:`tw-collapse ${s?`is-open`:``}`,children:(0,v.jsx)(`div`,{className:`tw-collapse-inner space-y-1`,children:e.children.map(e=>(0,v.jsx)(S,{node:e,depth:t+1,activePath:n,expanded:r,globalOpen:i,onToggle:a,onSelect:o},e.path))})})]})}function ve(e){return e==null?`—`:e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function C(){let[e,t]=(0,_.useState)(()=>r(`templates`)),[o,d]=(0,_.useState)(!1),[f,p]=(0,_.useState)(null),[m,h]=(0,_.useState)([]),[C,ye]=(0,_.useState)(0),[w,T]=(0,_.useState)(`.`),[E,D]=(0,_.useState)([]),[be,xe]=(0,_.useState)({}),[Se,O]=(0,_.useState)({}),[k,Ce]=(0,_.useState)(!0),[A,j]=(0,_.useState)(null),[M,N]=(0,_.useState)(!1),[we,P]=(0,_.useState)(!1),[F,I]=(0,_.useState)(null),[L,R]=(0,_.useState)(null),[Te,z]=(0,_.useState)(1),[B,Ee]=c(ge),[De,V]=(0,_.useState)(null),H=(0,_.useRef)(null),{cls:Oe,play:U}=he(),W=(0,_.useCallback)(async e=>{let t={};await Promise.all(e.map(async e=>{let n=await _e(e);n.length&&(t[e.path]=n)})),xe(t)},[]),G=(0,_.useCallback)(async()=>{let e=await ae(`templates`);h(e.tree),ye(e.totalFiles)},[]),K=(0,_.useCallback)(async(e=w)=>{j(null);try{let[t]=await Promise.all([u(`templates`,e),G()]);D(t.entries),T(t.path);let n=t.entries.filter(e=>e.type===`file`);await W(n)}catch(e){j(e instanceof Error?e.message:String(e))}},[w,W,G]);(0,_.useEffect)(()=>{let e=i(e=>t(!!e.templates));return n().then(()=>{t(r(`templates`)),d(!0)}),e},[]),(0,_.useEffect)(()=>{o&&e&&(async()=>{if(!await le(`templates`))p(!1);else try{let[e]=await Promise.all([u(`templates`,`.`),G()]);D(e.entries),T(e.path),await W(e.entries.filter(e=>e.type===`file`)),p(!0)}catch(e){j(e instanceof Error?e.message:String(e)),p(!0)}})()},[o,e,W,G]);function ke(){Ce(e=>!e),O({})}async function q(e){U(),T(e),z(1),V(null),j(null);try{let t=await u(`templates`,e);D(t.entries),await W(t.entries.filter(e=>e.type===`file`))}catch(e){j(e instanceof Error?e.message:String(e))}}async function Ae(e){P(!1),N(!0),j(null);try{await oe(`templates`,w,e),await K(w),l(`已新建文件夹「${e}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);j(t),l(`新建文件夹失败:${t}`,`error`)}finally{N(!1)}}async function je(e){if(e?.length){N(!0),j(null);try{for(let t of Array.from(e))await re(`templates`,w,t);await K(w),l(`已上传 ${e.length} 个文件`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);j(t),l(`上传失败:${t}`,`error`)}finally{N(!1),H.current&&(H.current.value=``)}}}async function Me(e){if(e.type===`file`){N(!0),j(null);try{await fe(`templates`,e.path)}catch(e){j(e instanceof Error?e.message:String(e))}finally{N(!1)}}}function Ne(e){let t=te(m,e.path),n=t?.fileCount??0,r=t?de(t):0;I({...e,isDir:!0,blocked:n>0||r>0,files:n,dirs:r})}function J(e){I({name:e.name,path:e.path,isDir:!1})}function Y(e,t){R({...e,isDir:t})}async function Pe(){let e=F;if(e&&(I(null),!e.blocked)){N(!0),j(null);try{await ce(`templates`,e.path);let t=ue(w,e.path)?ne(e.path):w;await K(t),l(`已删除「${e.name}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);j(t),l(`删除失败:${t}`,`error`)}finally{N(!1)}}}async function Fe(e){let t=L;if(t&&(R(null),e!==t.name)){N(!0),j(null);try{let n=await ie(`templates`,t.path,e);await K(se(w,t.path,n)),l(`已重命名为「${e}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);j(t),l(`重命名失败:${t}`,`error`)}finally{N(!1)}}}let Ie=(()=>{if(!F)return``;if(!F.isDir)return`删除文件「${F.name}」?将移入系统废纸篓,可随时找回。`;if(F.blocked){let e=[];return F.files&&e.push(`${F.files} 个文件`),F.dirs&&e.push(`${F.dirs} 个子文件夹`),`文件夹「${F.name}」中还有 ${e.join(`、`)},请先清空内部内容后再删除。`}return`删除文件夹「${F.name}」?将移入系统废纸篓。`})();if(!o)return(0,v.jsx)(`div`,{className:`tw-lib-probing`,"aria-busy":`true`,"aria-label":`正在读取插件开关`,children:(0,v.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})});if(!e)return(0,v.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(`templates`)});if(f===null)return(0,v.jsx)(`div`,{className:`tw-lib-probing`,"aria-busy":`true`,"aria-label":`正在连接本地文档服务`,children:(0,v.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})});if(!f)return(0,v.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:`模板库需要本地文档服务,当前未就绪。`});let X=E.filter(e=>e.type===`file`),Z=E.filter(e=>e.type===`dir`),Q=Math.max(1,Math.ceil(X.length/B)),$=Math.min(Te,Q),Le=X.slice(($-1)*B,$*B);function Re(e){U(),Ee(e),z(1)}return(0,v.jsxs)(`div`,{className:`flex gap-4 min-h-0`,children:[(0,v.jsxs)(`aside`,{className:`w-56 shrink-0 rounded-xl border border-stone-200 bg-white flex flex-col overflow-hidden`,children:[(0,v.jsxs)(`div`,{className:`px-3 py-2.5 border-b border-stone-100 flex items-center justify-between`,children:[(0,v.jsx)(`span`,{className:`text-xs font-semibold text-stone-500`,children:`文件夹`}),(0,v.jsx)(`button`,{type:`button`,disabled:M,onClick:()=>P(!0),className:`tw-mkdir-btn disabled:opacity-40`,children:`+ 新建`})]}),(0,v.jsxs)(`div`,{className:`flex-1 overflow-y-auto py-2 px-1 space-y-1`,children:[(0,v.jsx)(`div`,{className:`group flex items-center rounded-md ${w===`.`?`bg-[#e8f0fe]`:`hover:bg-stone-100`}`,style:{paddingLeft:8},children:(0,v.jsxs)(`button`,{type:`button`,onClick:()=>{q(`.`),ke()},"aria-expanded":k,className:`flex-1 min-w-0 flex items-center gap-1.5 py-1.5 pr-1 text-sm text-left ${w===`.`?`text-[#4176e6]`:`text-stone-600`}`,children:[(0,v.jsx)(y,{open:k,className:`w-3.5 h-3.5 shrink-0 text-[#4176e6]`}),(0,v.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,children:`全部模板`}),(0,v.jsxs)(`span`,{className:`shrink-0 tabular-nums text-[11px] text-stone-400`,children:[`(`,C,`)`]})]})}),(0,v.jsx)(`div`,{className:`tw-collapse ${k?`is-open`:``}`,children:(0,v.jsx)(`div`,{className:`tw-collapse-inner space-y-1`,children:m.map(e=>(0,v.jsx)(S,{node:e,depth:0,activePath:w,expanded:Se,globalOpen:k,onToggle:e=>O(t=>({...t,[e]:!(t[e]??k)})),onSelect:e=>void q(e)},e.path))})})]})]}),(0,v.jsxs)(`section`,{className:`flex-1 min-w-0 rounded-xl border border-stone-200 bg-white flex flex-col overflow-hidden`,children:[(0,v.jsxs)(`div`,{className:`px-4 py-3 border-b border-stone-100 flex items-center gap-2 flex-wrap`,children:[(0,v.jsxs)(`div`,{className:`text-sm text-stone-600 flex-1 min-w-0 truncate`,children:[(0,v.jsx)(`span`,{className:`text-stone-400`,children:pe(`templates`)}),w===`.`?``:w]}),(0,v.jsx)(`input`,{ref:H,type:`file`,multiple:!0,accept:`.md,.txt,.docx,.xlsx,.xls,.csv,text/plain,text/markdown,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`,className:`hidden`,onChange:e=>void je(e.target.files)}),(0,v.jsx)(`button`,{type:`button`,disabled:M,onClick:()=>H.current?.click(),className:`h-8 px-3 shrink-0 whitespace-nowrap text-sm font-medium text-white bg-[#4176e6] rounded-lg hover:bg-[#3565c7] disabled:opacity-40`,children:`上传文件`})]}),A?(0,v.jsx)(`div`,{className:`mx-4 mt-3 px-3 py-2 text-sm text-red-700 bg-red-50 border border-red-200 rounded-lg`,children:A}):null,(0,v.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-4 space-y-4`,children:[Z.length>0&&(0,v.jsxs)(`div`,{children:[(0,v.jsx)(`div`,{className:`text-xs font-medium text-stone-400 mb-2`,children:`子文件夹`}),(0,v.jsx)(`ul`,{className:`space-y-1`,children:Z.map(e=>(0,v.jsxs)(`li`,{className:`flex items-center gap-2 px-3 py-2 rounded-lg border border-stone-100 hover:bg-stone-50`,children:[(0,v.jsxs)(`button`,{type:`button`,className:`flex-1 min-w-0 flex items-center gap-2 text-left text-sm text-stone-700`,onClick:()=>void q(e.path),children:[(0,v.jsx)(y,{className:`w-4 h-4 text-[#4176e6] shrink-0`}),(0,v.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,children:e.name})]}),(0,v.jsx)(`button`,{type:`button`,disabled:M,"aria-label":`重命名 ${e.name}`,onClick:()=>Y({name:e.name,path:e.path},!0),className:`p-1.5 rounded text-stone-400 hover:text-[#4176e6] hover:bg-[#e8f0fe] disabled:opacity-40`,children:(0,v.jsx)(b,{className:`w-3.5 h-3.5`})}),(0,v.jsx)(`button`,{type:`button`,disabled:M,"aria-label":`删除 ${e.name}`,onClick:()=>Ne({name:e.name,path:e.path}),className:`tw-icon-danger p-1.5 rounded`,children:(0,v.jsx)(x,{className:`w-3.5 h-3.5`})})]},e.path))})]}),(0,v.jsxs)(`div`,{children:[(0,v.jsx)(`div`,{className:`text-xs font-medium text-stone-400 mb-2`,children:`文件`}),X.length===0?(0,v.jsx)(`p`,{className:`text-sm text-stone-400 py-6 text-center border border-dashed border-stone-200 rounded-lg`,children:`当前文件夹为空,点击「上传文件」添加模板(.md / .xlsx / .docx 等)`}):(0,v.jsx)(`ul`,{className:`${Oe}space-y-1`,children:Le.map(e=>{let t=be[e.path]??[],n=De===e.path;return(0,v.jsxs)(`li`,{className:`flex items-start gap-2 px-3 py-2 rounded-lg border transition-colors ${n?`border-[#c7dcff] bg-[#e8f0fe]`:`border-stone-100 hover:bg-stone-50`}`,children:[(0,v.jsxs)(`button`,{type:`button`,className:`flex-1 min-w-0 text-left`,disabled:M,onClick:()=>V(e.path),onDoubleClick:()=>void Me(e),children:[(0,v.jsx)(`div`,{className:`text-sm text-stone-800 truncate`,"data-hint":e.name,children:e.name}),(0,v.jsx)(`div`,{className:`text-[11px] text-stone-400`,children:ve(e.size)}),t.length>0?(0,v.jsx)(me,{fields:t}):null]}),(0,v.jsx)(`button`,{type:`button`,disabled:M,"aria-label":`重命名 ${e.name}`,onClick:()=>Y({name:e.name,path:e.path},!1),className:`p-1.5 rounded text-stone-400 hover:text-[#4176e6] hover:bg-[#e8f0fe] disabled:opacity-40 shrink-0 mt-0.5`,children:(0,v.jsx)(b,{className:`w-3.5 h-3.5`})}),(0,v.jsx)(`button`,{type:`button`,disabled:M,"aria-label":`删除 ${e.name}`,onClick:()=>J(e),className:`tw-icon-danger p-1.5 rounded shrink-0 mt-0.5`,children:(0,v.jsx)(x,{className:`w-3.5 h-3.5`})})]},e.path)})})]})]}),X.length>0?(0,v.jsx)(ee,{page:$,totalPages:Q,pageSize:B,busy:M,onPage:e=>{U(),z(e)},onPageSize:Re}):null]}),(0,v.jsx)(g,{open:we,title:`新建文件夹`,onClose:()=>P(!1),onConfirm:e=>void Ae(e)}),(0,v.jsx)(g,{open:L!=null,title:L?.isDir?`重命名文件夹`:`重命名文件`,label:L?.isDir?`文件夹名称`:`文件名称`,initialValue:L?.name??``,lockExtension:L!=null&&!L.isDir,confirmLabel:`保存`,onClose:()=>R(null),onConfirm:e=>void Fe(e)}),(0,v.jsx)(s,{open:F!=null,title:F?.blocked?`无法删除文件夹`:F?.isDir?`删除文件夹`:`删除模板`,message:Ie,confirmLabel:F?.blocked?`知道了`:`删除`,cancelLabel:`取消`,danger:!F?.blocked,hideCancel:!!F?.blocked,onClose:()=>I(null),onConfirm:()=>void Pe()})]})}export{C as default};
@@ -1 +0,0 @@
1
- import{s as e,t}from"./react.Blvh0GOs.js";import{i as n}from"./app-config.DkyjuL-S.js";import{i as r,o as i,s as a}from"./plugins.BRvXWHLe.js";import{t as o}from"./jsx-runtime.DUg_B_vD.js";import{t as s}from"./ConfirmDialog.DrrPf1MB.js";import{n as c,t as ee}from"./DocsPager.Duf4I68E.js";import{t as te}from"./OverflowHint.CHZeFfUj.js";import{showToast as l}from"./Toast.BO2NFckG.js";import{a as ne,c as u,d as re,f as ie,g as ae,h as oe,i as se,l as d,m as ce,n as le,p as f,r as ue,s as de,t as fe,u as pe,v as me}from"./project-docs.CCjtiFjB.js";import{i as p,n as m,r as he}from"./case-template.Cd2xNbgy.js";import{n as ge}from"./doc-roots.CO3IBiY6.js";import{t as _e}from"./ExcelFieldTags.CXif3Ilh.js";import{t as ve}from"./open-docs-in-session.CRiZT022.js";import{t as ye}from"./NamePromptDialog.Csfnh5eM.js";import{t as be}from"./useListAnim.BoerpmsB.js";import{t as xe}from"./PromptMountDialog.mrTx3U5T.js";import{a as Se,i as Ce,n as we,o as h,r as Te,s as Ee,t as g}from"./test-reports.CuIjlEyK.js";var _=e(t(),1),v=o(),De=5;async function Oe(e){let t=e.name.toLowerCase();try{if(t.endsWith(`.xlsx`)||t.endsWith(`.xls`)){let t=await ie(`testReports`,e.path);if(t.encoding===`base64`&&t.contentBase64)return p(t.contentBase64).headers}else if(t.endsWith(`.csv`)){let t=await f(`testReports`,e.path);return m(t.content).headers}else if(t.endsWith(`.md`)||t.endsWith(`.txt`)){let t=await f(`testReports`,e.path);return he(t.content).headers}}catch{}return[]}function y({className:e=`w-4 h-4`,open:t=!1}){return(0,v.jsx)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:t?(0,v.jsx)(`path`,{d:`M6 14l1.45-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.55 6a2 2 0 0 1-1.94 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2`}):(0,v.jsx)(`path`,{d:`M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7z`})})}function ke({className:e=`w-3 h-3`}){return(0,v.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,v.jsx)(`path`,{d:`M21.17 6.81a1 1 0 0 0-3.99-3.99L3.84 16.17a2 2 0 0 0-.5.83l-1.32 4.35a.5.5 0 0 0 .62.62l4.35-1.32a2 2 0 0 0 .83-.5z`}),(0,v.jsx)(`path`,{d:`m15 5 4 4`})]})}function b({className:e=`w-3 h-3`}){return(0,v.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,v.jsx)(`path`,{d:`M3 6h18`}),(0,v.jsx)(`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`}),(0,v.jsx)(`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`}),(0,v.jsx)(`path`,{d:`M10 11v6`}),(0,v.jsx)(`path`,{d:`M14 11v6`})]})}function x({node:e,depth:t,activePath:n,expanded:r,globalOpen:i,onToggle:a,onSelect:o}){let s=r[e.path]??i,c=n===e.path;return(0,v.jsxs)(`div`,{children:[(0,v.jsx)(`div`,{className:`group flex items-center rounded-md ${c?`bg-[#e8f0fe]`:`hover:bg-stone-100`}`,style:{paddingLeft:8+t*12},children:(0,v.jsxs)(`button`,{type:`button`,onClick:()=>{o(e.path),e.children.length&&a(e.path)},"aria-expanded":e.children.length?s:void 0,className:`flex-1 min-w-0 flex items-center gap-1.5 py-1.5 pr-1 text-sm text-left ${c?`text-[#4176e6]`:`text-stone-600`}`,children:[(0,v.jsx)(`span`,{className:`w-3.5 shrink-0`,"aria-hidden":`true`}),(0,v.jsx)(y,{open:!!(e.children.length&&s),className:`w-3.5 h-3.5 shrink-0 text-[#4176e6]`}),(0,v.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,children:e.name}),(0,v.jsxs)(`span`,{className:`shrink-0 tabular-nums text-[11px] text-stone-400`,children:[`(`,e.fileCount??0,`)`]})]})}),(0,v.jsx)(`div`,{className:`tw-collapse ${s?`is-open`:``}`,children:(0,v.jsx)(`div`,{className:`tw-collapse-inner space-y-1`,children:e.children.map(e=>(0,v.jsx)(x,{node:e,depth:t+1,activePath:n,expanded:r,globalOpen:i,onToggle:a,onSelect:o},e.path))})})]})}function Ae(e){return e==null?`—`:e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function S(){let[e,t]=(0,_.useState)(()=>r(`testReports`)),[o,ie]=(0,_.useState)(!1),[f,p]=(0,_.useState)(null),[m,he]=(0,_.useState)([]),[S,je]=(0,_.useState)(0),[C,w]=(0,_.useState)(`.`),[T,E]=(0,_.useState)([]),[Me,Ne]=(0,_.useState)({}),[Pe,D]=(0,_.useState)({}),[O,k]=(0,_.useState)(!0),[Fe,A]=(0,_.useState)(null),[j,M]=(0,_.useState)(!1),[Ie,N]=(0,_.useState)(!1),[P,F]=(0,_.useState)(null),[I,L]=(0,_.useState)(null),[Le,R]=(0,_.useState)(1),[z,Re]=c(De),[ze,Be]=(0,_.useState)(null),B=(0,_.useRef)(null),{cls:Ve,play:V}=be(),[He,H]=(0,_.useState)(()=>h()),[Ue,U]=(0,_.useState)(!1),[We,Ge]=(0,_.useState)([]),[Ke,qe]=(0,_.useState)(!1),W=(0,_.useMemo)(()=>C===`.`||!C.trim()?null:Se(C),[C]),G=W?Ce(W):null,K=W?He[W]?.trim()||Ee(W):``,q=!!W&&!K,J=(0,_.useCallback)(async e=>{let t={};await Promise.all(e.map(async e=>{let n=await Oe(e);n.length&&(t[e.path]=n)})),Ne(t)},[]),Y=(0,_.useCallback)(async()=>{let e=await se(`testReports`);he(e.tree),je(e.totalFiles)},[]),X=(0,_.useCallback)(async(e=C)=>{A(null);try{let[t]=await Promise.all([u(`testReports`,e),Y()]);E(t.entries),w(t.path);let n=t.entries.filter(e=>e.type===`file`);await J(n)}catch(e){A(e instanceof Error?e.message:String(e))}},[C,J,Y]);(0,_.useEffect)(()=>{let e=i(e=>t(!!e.testReports));return n().then(()=>{t(r(`testReports`)),ie(!0)}),e},[]);let Je=(0,_.useCallback)(async()=>{for(let e of g)try{await d(`testReports`,`.`,e.folder)}catch{}try{let{entries:e}=await u(`prompts`,`.`),t=new Set(e.filter(e=>e.type===`file`).map(e=>e.name));for(let e of g)t.has(e.defaultPrompt)||(await me(`prompts`,e.defaultPrompt,we),t.add(e.defaultPrompt));Ge([...t].filter(e=>/\.(md|markdown|txt)$/i.test(e)).sort((e,t)=>e.localeCompare(t)))}catch{}H(h())},[]);(0,_.useEffect)(()=>{o&&e&&(async()=>{if(!await ue(`testReports`))p(!1);else try{await Je();let e=h();for(let t of g)e[t.id]?.trim()||(e=Te(t.id,t.defaultPrompt));H(e);let[t]=await Promise.all([u(`testReports`,`.`),Y()]);E(t.entries),w(t.path),await J(t.entries.filter(e=>e.type===`file`)),p(!0)}catch(e){A(e instanceof Error?e.message:String(e)),p(!0)}})()},[o,e,Je,J,Y]);function Ye(){k(e=>!e),D({})}async function Z(e){V(),w(e),R(1),Be(null),A(null);try{let t=await u(`testReports`,e);E(t.entries),await J(t.entries.filter(e=>e.type===`file`))}catch(e){A(e instanceof Error?e.message:String(e))}}async function Xe(e){N(!1),M(!0),A(null);try{await d(`testReports`,C,e),await X(C),l(`已新建文件夹「${e}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);A(t),l(`新建文件夹失败:${t}`,`error`)}finally{M(!1)}}async function Ze(e){if(e?.length){M(!0),A(null);try{for(let t of Array.from(e))await ae(`testReports`,C,t);await X(C),l(`已上传 ${e.length} 个文件`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);A(t),l(`上传失败:${t}`,`error`)}finally{M(!1),B.current&&(B.current.value=``)}}}async function Qe(e){if(W&&G){qe(!0);try{let t=Te(W,e);H(t),U(!1),l(`已为「${G.label}」挂载「${e}」`,`success`)}finally{qe(!1)}}}async function $e(e){if(!W)throw Error(`请先选择功能 / 接口 / 性能测试报告目录`);let t=e.trim().replace(/[\\/]/g,``);if(!t)throw Error(`请填写提示词文件名`);/\.(md|markdown|txt)$/i.test(t)||(t=`${t}.md`),await me(`prompts`,t,we);let{entries:n}=await u(`prompts`,`.`);return Ge(n.filter(e=>e.type===`file`&&/\.(md|markdown|txt)$/i.test(e.name)).map(e=>e.name)),await Qe(t),t}async function et(e){let t=Se(e.path)??W,n=t?h()[t]||Ce(t).defaultPrompt:``;M(!0),A(null);try{await ve(`testReports`,e,{attachPrompt:n||void 0})}catch(e){A(e instanceof Error?e.message:String(e)),M(!1)}}async function tt(e){if(e.type===`file`){M(!0),A(null);try{await pe(`testReports`,e.path)}catch(e){A(e instanceof Error?e.message:String(e))}finally{M(!1)}}}function nt(e){let t=ne(m,e.path),n=t?.fileCount??0,r=t?fe(t):0;F({...e,isDir:!0,blocked:n>0||r>0,files:n,dirs:r})}function rt(e){F({name:e.name,path:e.path,isDir:!1})}function it(e,t){L({...e,isDir:t})}async function at(){let e=P;if(e&&(F(null),!e.blocked)){M(!0),A(null);try{await le(`testReports`,e.path);let t=de(C,e.path)?re(e.path):C;await X(t),l(`已删除「${e.name}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);A(t),l(`删除失败:${t}`,`error`)}finally{M(!1)}}}async function ot(e){let t=I;if(t&&(L(null),e!==t.name)){M(!0),A(null);try{let n=await oe(`testReports`,t.path,e);await X(ce(C,t.path,n)),l(`已重命名为「${e}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);A(t),l(`重命名失败:${t}`,`error`)}finally{M(!1)}}}let st=(()=>{if(!P)return``;if(!P.isDir)return`删除文件「${P.name}」?将移入系统废纸篓,可随时找回。`;if(P.blocked){let e=[];return P.files&&e.push(`${P.files} 个文件`),P.dirs&&e.push(`${P.dirs} 个子文件夹`),`文件夹「${P.name}」中还有 ${e.join(`、`)},请先清空内部内容后再删除。`}return`删除文件夹「${P.name}」?将移入系统废纸篓。`})();if(!o)return(0,v.jsx)(`div`,{className:`tw-lib-probing`,"aria-busy":`true`,"aria-label":`正在读取插件开关`,children:(0,v.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})});if(!e)return(0,v.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(`testReports`)});if(f===null)return(0,v.jsx)(`div`,{className:`tw-lib-probing`,"aria-busy":`true`,"aria-label":`正在连接本地文档服务`,children:(0,v.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})});if(!f)return(0,v.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:`报告管理需要本地文档服务,当前未就绪。`});let Q=T.filter(e=>e.type===`file`),ct=T.filter(e=>e.type===`dir`),lt=Math.max(1,Math.ceil(Q.length/z)),$=Math.min(Le,lt),ut=Q.slice(($-1)*z,$*z);function dt(e){V(),Re(e),R(1)}return(0,v.jsxs)(`div`,{className:`flex gap-4 min-h-0`,children:[(0,v.jsxs)(`aside`,{className:`w-56 shrink-0 rounded-xl border border-stone-200 bg-white flex flex-col overflow-hidden`,children:[(0,v.jsxs)(`div`,{className:`px-3 py-2.5 border-b border-stone-100 flex items-center justify-between`,children:[(0,v.jsx)(`span`,{className:`text-xs font-semibold text-stone-500`,children:`文件夹`}),(0,v.jsx)(`button`,{type:`button`,disabled:j,onClick:()=>N(!0),className:`tw-mkdir-btn disabled:opacity-40`,children:`+ 新建`})]}),(0,v.jsxs)(`div`,{className:`flex-1 overflow-y-auto py-2 px-1 space-y-1`,children:[(0,v.jsx)(`div`,{className:`group flex items-center rounded-md ${C===`.`?`bg-[#e8f0fe]`:`hover:bg-stone-100`}`,style:{paddingLeft:8},children:(0,v.jsxs)(`button`,{type:`button`,onClick:()=>{Z(`.`),C===`.`?Ye():(k(!0),D({}))},"aria-expanded":O,className:`flex-1 min-w-0 flex items-center gap-1.5 py-1.5 pr-1 text-sm text-left ${C===`.`?`text-[#4176e6]`:`text-stone-600`}`,children:[(0,v.jsx)(y,{open:O,className:`w-3.5 h-3.5 shrink-0 text-[#4176e6]`}),(0,v.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,children:`全部报告`}),(0,v.jsxs)(`span`,{className:`shrink-0 tabular-nums text-[11px] text-stone-400`,children:[`(`,S,`)`]})]})}),(0,v.jsx)(`div`,{className:`tw-collapse ${O?`is-open`:``}`,children:(0,v.jsx)(`div`,{className:`tw-collapse-inner space-y-1`,children:m.map(e=>(0,v.jsx)(x,{node:e,depth:0,activePath:C,expanded:Pe,globalOpen:O,onToggle:e=>D(t=>({...t,[e]:!(t[e]??O)})),onSelect:e=>void Z(e)},e.path))})})]})]}),(0,v.jsxs)(`section`,{className:`flex-1 min-w-0 rounded-xl border border-stone-200 bg-white flex flex-col overflow-hidden`,children:[(0,v.jsxs)(`div`,{className:`px-4 py-3 border-b border-stone-100 flex items-center gap-2 flex-wrap`,children:[(0,v.jsxs)(`div`,{className:`text-sm text-stone-600 flex-1 min-w-0 truncate`,children:[(0,v.jsx)(`span`,{className:`text-stone-400`,children:ge(`testReports`)}),C===`.`?``:C]}),W&&G?(0,v.jsx)(`button`,{type:`button`,disabled:Ke,onClick:()=>U(!0),"aria-label":`挂载提示词`,className:`flex h-8 w-44 min-w-0 items-center rounded-lg border bg-white px-2.5 text-left transition-colors hover:border-stone-300 focus:border-[#4176e6] focus:outline-none disabled:opacity-40 ${q?`border-amber-300 text-amber-700`:`border-stone-200`}`,children:(0,v.jsx)(te,{text:q?`未挂载提示词 · 点击挂载`:K.replace(/\.(md|markdown|txt)$/i,``),className:`min-w-0 flex-1 truncate text-sm ${q?`text-amber-700`:`text-stone-700`}`})}):null,(0,v.jsx)(`input`,{ref:B,type:`file`,multiple:!0,accept:`.md,.txt,.docx,.xlsx,.xls,.csv,text/plain,text/markdown,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`,className:`hidden`,onChange:e=>void Ze(e.target.files)}),(0,v.jsx)(`button`,{type:`button`,disabled:j,onClick:()=>B.current?.click(),className:`h-8 px-3 shrink-0 whitespace-nowrap text-sm font-medium text-white bg-[#4176e6] rounded-lg hover:bg-[#3565c7] disabled:opacity-40`,children:`上传文件`})]}),Fe?(0,v.jsx)(`div`,{className:`mx-4 mt-3 px-3 py-2 text-sm text-red-700 bg-red-50 border border-red-200 rounded-lg`,children:Fe}):null,(0,v.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-4 space-y-4`,children:[ct.length>0&&(0,v.jsxs)(`div`,{children:[(0,v.jsx)(`div`,{className:`text-xs font-medium text-stone-400 mb-2`,children:`子文件夹`}),(0,v.jsx)(`ul`,{className:`space-y-1`,children:ct.map(e=>(0,v.jsxs)(`li`,{className:`flex items-center gap-2 px-3 py-2 rounded-lg border border-stone-100 hover:bg-stone-50`,children:[(0,v.jsxs)(`button`,{type:`button`,className:`flex-1 min-w-0 flex items-center gap-2 text-left text-sm text-stone-700`,onClick:()=>void Z(e.path),children:[(0,v.jsx)(y,{className:`w-4 h-4 text-[#4176e6] shrink-0`}),(0,v.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,children:e.name})]}),(0,v.jsx)(`button`,{type:`button`,disabled:j,"aria-label":`重命名 ${e.name}`,onClick:()=>it({name:e.name,path:e.path},!0),className:`p-1.5 rounded text-stone-400 hover:text-[#4176e6] hover:bg-[#e8f0fe] disabled:opacity-40`,children:(0,v.jsx)(ke,{className:`w-3.5 h-3.5`})}),(0,v.jsx)(`button`,{type:`button`,disabled:j,"aria-label":`删除 ${e.name}`,onClick:()=>nt({name:e.name,path:e.path}),className:`tw-icon-danger p-1.5 rounded`,children:(0,v.jsx)(b,{className:`w-3.5 h-3.5`})})]},e.path))})]}),(0,v.jsxs)(`div`,{children:[(0,v.jsx)(`div`,{className:`text-xs font-medium text-stone-400 mb-2`,children:`文件`}),Q.length===0?(0,v.jsx)(`p`,{className:`text-sm text-stone-400 py-6 text-center border border-dashed border-stone-200 rounded-lg`,children:`当前文件夹为空,点击「上传文件」添加报告(.md / .xlsx / .docx 等)`}):(0,v.jsx)(`ul`,{className:`${Ve}space-y-1`,children:ut.map(e=>{let t=Me[e.path]??[],n=ze===e.path;return(0,v.jsxs)(`li`,{className:`flex items-start gap-2 px-3 py-2 rounded-lg border transition-colors ${n?`border-[#c7dcff] bg-[#e8f0fe]`:`border-stone-100 hover:bg-stone-50`}`,children:[(0,v.jsxs)(`button`,{type:`button`,className:`flex-1 min-w-0 text-left`,disabled:j,onClick:()=>Be(e.path),onDoubleClick:()=>void tt(e),children:[(0,v.jsx)(`div`,{className:`text-sm text-stone-800 truncate`,"data-hint":e.name,children:e.name}),(0,v.jsx)(`div`,{className:`text-[11px] text-stone-400`,children:Ae(e.size)}),t.length>0?(0,v.jsx)(_e,{fields:t}):null]}),(0,v.jsx)(`button`,{type:`button`,disabled:j,onClick:()=>void et(e),className:`mt-0.5 shrink-0 cursor-pointer whitespace-nowrap rounded bg-[#4176e6] px-2 py-1 text-xs text-white hover:bg-[#3565c7] disabled:opacity-40`,children:`在会话中打开`}),(0,v.jsx)(`button`,{type:`button`,disabled:j,"aria-label":`重命名 ${e.name}`,onClick:()=>it({name:e.name,path:e.path},!1),className:`p-1.5 rounded text-stone-400 hover:text-[#4176e6] hover:bg-[#e8f0fe] disabled:opacity-40 shrink-0 mt-0.5`,children:(0,v.jsx)(ke,{className:`w-3.5 h-3.5`})}),(0,v.jsx)(`button`,{type:`button`,disabled:j,"aria-label":`删除 ${e.name}`,onClick:()=>rt(e),className:`tw-icon-danger p-1.5 rounded shrink-0 mt-0.5`,children:(0,v.jsx)(b,{className:`w-3.5 h-3.5`})})]},e.path)})})]})]}),Q.length>0?(0,v.jsx)(ee,{page:$,totalPages:lt,pageSize:z,busy:j,onPage:e=>{V(),R(e)},onPageSize:dt}):null]}),(0,v.jsx)(ye,{open:Ie,title:`新建文件夹`,onClose:()=>N(!1),onConfirm:e=>void Xe(e)}),(0,v.jsx)(ye,{open:I!=null,title:I?.isDir?`重命名文件夹`:`重命名文件`,label:I?.isDir?`文件夹名称`:`文件名称`,initialValue:I?.name??``,lockExtension:I!=null&&!I.isDir,confirmLabel:`保存`,onClose:()=>L(null),onConfirm:e=>void ot(e)}),(0,v.jsx)(s,{open:P!=null,title:P?.blocked?`无法删除文件夹`:P?.isDir?`删除文件夹`:`删除报告`,message:st,confirmLabel:P?.blocked?`知道了`:`删除`,cancelLabel:`取消`,danger:!P?.blocked,hideCancel:!!P?.blocked,onClose:()=>F(null),onConfirm:()=>void at()}),(0,v.jsx)(xe,{open:Ue&&!!W,prompts:We,value:K,force:q,onClose:()=>U(!1),onMount:e=>void Qe(e),onCreate:$e,target:`报告类型`,createHint:`会按报告管理短种子生成一份,之后可在「提示词管理」里改。`})]})}export{S as default};
@@ -1 +0,0 @@
1
- import{s as e,t}from"./react.Blvh0GOs.js";import{i as n}from"./app-config.DkyjuL-S.js";import{i as r,o as i,s as a}from"./plugins.BRvXWHLe.js";import{r as ee,s as te}from"./view-prefs.DhdLZjGh.js";import{t as o}from"./jsx-runtime.DUg_B_vD.js";import{t as ne}from"./ConfirmDialog.DrrPf1MB.js";import{t as re}from"./DatePicker.Bkl71M49.js";import{n as ie,t as ae}from"./DocsPager.Duf4I68E.js";import{E as s}from"./PmShared.BK8kWRSV.js";import{n as oe,r as se,t as ce}from"./TableFieldConfig.C7O-mL-p.js";import{t as le}from"./TagSelect.UUXgkMqJ.js";import{showToast as c}from"./Toast.BO2NFckG.js";import{a as ue,c as de,d as fe,i as pe,l as me,n as l,o as he,r as ge,t as u}from"./ColumnResize.CkE59sGq.js";import{a as _e,c as ve,d,f as ye,i as be,l as xe,n as Se,o as Ce,p as we,r as Te,s as Ee,t as De,u as Oe}from"./test-stats.Cf3_L4wu.js";var f=e(t(),1),p=o(),ke=8e3,m=600,Ae=20,je=`tw.test-stats.page-size.v1`,h=`test-stats.search`,g=[{key:`select`,width:32,min:28},{key:`date`,width:140,min:120},{key:`dimensions`,width:320,min:200},{key:`count`,width:120,min:90},{key:`createdAt`,width:140,min:110},{key:`updatedAt`,width:140,min:110},{key:`filler`,filler:!0},{key:`action`,width:76,min:64}],_=new Set([`select`,`date`,`filler`,`action`]),v=[{key:`dimensions`,label:`测试统计维度`},{key:`count`,label:`统计数量`},{key:`createdAt`,label:`创建日期`},{key:`updatedAt`,label:`修改日期`}],y=`test-stats.fields`,b=`h-8 w-full min-w-0 rounded-md border border-transparent bg-transparent px-1.5 text-center text-sm text-stone-800 outline-none transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white placeholder:text-stone-300 tabular-nums`,x=(0,p.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,p.jsx)(`path`,{d:`M3 6h18`}),(0,p.jsx)(`path`,{d:`M8 6V4h8v2`}),(0,p.jsx)(`path`,{d:`M19 6l-1 14H6L5 6`}),(0,p.jsx)(`path`,{d:`M10 11v6M14 11v6`})]});function S(e){let[t,n]=(0,f.useState)(e.value?String(e.value):``),r=(0,f.useRef)(e.value),i=(0,f.useRef)(e.onCommit);i.current=e.onCommit,(0,f.useEffect)(()=>{e.value!==r.current&&(r.current=e.value,n(e.value?String(e.value):``))},[e.value]),(0,f.useEffect)(()=>{let e=t?d(t):0;if(e===r.current)return;let n=window.setTimeout(()=>{r.current=e,i.current(e)},m);return()=>window.clearTimeout(n)},[t]);function a(){let e=t?d(t):0;e!==r.current&&(r.current=e,i.current(e))}return(0,p.jsx)(`input`,{type:`text`,inputMode:`numeric`,"aria-label":e.ariaLabel,value:t,placeholder:e.placeholder??`0`,onChange:e=>n(e.target.value.replace(/[^\d]/g,``)),onBlur:a,onKeyDown:t=>{t.key===`Enter`?(t.preventDefault(),t.currentTarget.blur()):t.key===`Escape`&&(t.preventDefault(),r.current=e.value,n(e.value?String(e.value):``),t.currentTarget.blur())},className:b})}function C(){let[e,t]=(0,f.useState)(!1),[o,d]=(0,f.useState)(!0),[m,b]=(0,f.useState)(null),[C,w]=(0,f.useState)([]),[T,E]=(0,f.useState)([]),[D,O]=(0,f.useState)(null),[k,A]=(0,f.useState)(!1),[j,Me]=(0,f.useState)(()=>ee(h)),[M,N]=(0,f.useState)({}),[Ne,P]=(0,f.useState)(1),[F,Pe]=ie(Ae,je),[I,L]=(0,f.useState)(null),[R,z]=(0,f.useState)(null);function B(e){te(h,e),Me(e),P(1)}let V=(0,f.useRef)(!0),H=(0,f.useRef)(!1),U=se(y,v,_),W=(0,f.useMemo)(()=>oe(g,U.isVisible),[U.isVisible]),G=me(`lh:test-stats:cols:v1`,W),Fe=fe(`test-stats`);(0,f.useEffect)(()=>(V.current=!0,()=>{V.current=!1}),[]);let K=(0,f.useCallback)(async()=>{try{let e=await Ee();if(!V.current)return;w(e.items),E(e.dimensions),N(t=>{let n=new Set(e.items.map(e=>e.id)),r=!1,i={};for(let[e,a]of Object.entries(t))a&&(n.has(e)?i[e]=!0:r=!0);return r?i:t}),O(null)}catch(e){if(!V.current)return;O(e instanceof Error?e.message:String(e))}},[]);(0,f.useEffect)(()=>{let e=i(e=>d(!!e.testStats));return n().then(()=>{d(r(`testStats`)),t(!0)}),e},[]),(0,f.useEffect)(()=>{e&&o&&(async()=>{let e=await _e();V.current&&(e?(await K(),V.current&&b(!0)):b(!1))})()},[e,o,K]),(0,f.useEffect)(()=>{if(m!==!0)return;let e=window.setInterval(()=>{H.current||K()},ke),t=()=>{H.current||K()};return window.addEventListener(`focus`,t),()=>{window.clearInterval(e),window.removeEventListener(`focus`,t)}},[m,K]);let Ie=ye(),q=(0,f.useMemo)(()=>xe(Ce(C,{keyword:j})),[C,j]),J=(0,f.useMemo)(()=>Oe(C),[C]),Y=Math.max(1,Math.ceil(q.length/F)),X=Math.min(Ne,Y),Z=(0,f.useMemo)(()=>q.slice((X-1)*F,X*F),[q,X,F]),Q=(0,f.useMemo)(()=>C.filter(e=>M[e.id]),[C,M]),Le=Z.length>0&&Z.every(e=>M[e.id]);(0,f.useEffect)(()=>{if(!I)return;let e=q.findIndex(e=>e.id===I);if(e<0)return;P(Math.floor(e/F)+1);let t=window.setTimeout(()=>L(null),2e3);return()=>window.clearTimeout(t)},[I,q,F]);async function Re(){if(!k){A(!0),O(null),B(``);try{let e=await Se([{date:Ie,dimensions:[],count:0}],{mode:`manual`});if(!V.current)return;let t=e.items[0];if(e.dimensions.length&&E(e.dimensions),await K(),!V.current||!t)return;L(t.id)}catch(e){V.current&&O(e instanceof Error?e.message:String(e))}finally{V.current&&A(!1)}}}async function $(e,t){w(n=>n.map(n=>n.id===e?{...n,...t}:n));try{let{item:n,dimensions:r}=await we(e,t);if(!V.current)return;w(t=>t.map(t=>t.id===e?n:t)),r.length&&E(r),O(null)}catch(e){if(!V.current)return;O(e instanceof Error?e.message:String(e)),await K()}}async function ze(e,t){let n=t.trim();if(n&&n!==e)try{let t=await ve(e,n);if(!V.current)return;w(t.items),E(t.dimensions),O(null),c(t.replaced>0?`已重命名,同步了 ${t.replaced} 条记录`:`已重命名测试统计维度`,`success`)}catch(e){if(!V.current)return;c(`重命名失败:${e instanceof Error?e.message:String(e)}`,`error`)}}async function Be(e){let t=De(C,e);if(t>0)c(`还有 ${t} 条记录在用「${e}」,先改掉再删除`,`error`);else try{let t=await be(e);if(!V.current)return;w(t.items),E(t.dimensions),O(null),c(`已删除测试统计维度「${e}」`,`success`)}catch(e){if(!V.current)return;c(`删除失败:${e instanceof Error?e.message:String(e)}`,`error`)}}async function Ve(){let e=R;if(e&&e.length!==0){z(null),A(!0);try{if(await Te(e.map(e=>e.id)),!V.current)return;N({}),O(null),await K()}catch(e){V.current&&O(e instanceof Error?e.message:String(e))}finally{V.current&&A(!1)}}}return e?o?m===null?(0,p.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,p.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center`,children:(0,p.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})}):m?(0,p.jsxs)(`section`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,p.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-3 border-b border-stone-100 px-4 py-3`,children:[(0,p.jsxs)(`div`,{className:`text-sm text-stone-600`,children:[`共 `,(0,p.jsx)(`span`,{className:`font-medium text-stone-800`,children:J.records}),` 条`,(0,p.jsxs)(`span`,{className:`text-stone-400`,children:[` `,`· 覆盖 `,J.dimensions,` 个维度 · 数量合计 `,J.total,Q.length?` · 已选 ${Q.length} 条`:``]})]}),(0,p.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[(0,p.jsx)(`input`,{value:j,onChange:e=>B(e.target.value),placeholder:`搜索日期 / 维度…`,className:`h-9 w-44 rounded-lg border border-stone-200 px-3 text-sm text-stone-800 outline-none focus:border-[#3370ff]`}),(0,p.jsx)(`button`,{type:`button`,disabled:k||Q.length===0,onClick:()=>z(Q),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,p.jsx)(ce,{fields:U.fields,isVisible:U.isVisible,onToggle:U.toggle}),(0,p.jsx)(`button`,{type:`button`,disabled:k,onClick:()=>void Re(),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:`+ 添加记录`})]})]}),D?(0,p.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,p.jsx)(`span`,{className:`min-w-0 flex-1`,children:D}),(0,p.jsx)(`button`,{type:`button`,onClick:()=>O(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,p.jsx)(`div`,{ref:Fe,className:`tw-scroll-x min-h-0 flex-1 overflow-auto`,onFocusCapture:()=>{H.current=!0},onBlurCapture:()=>{window.setTimeout(()=>{H.current=!!document.activeElement?.closest(`.tw-data-table`)},0)},children:(0,p.jsxs)(`table`,{className:`tw-data-table tw-sticky-table w-full table-fixed text-sm`,style:G.tableStyle,children:[(0,p.jsx)(`colgroup`,{children:W.map(e=>(0,p.jsx)(`col`,{style:G.widthOf(e.key)?{width:G.widthOf(e.key)}:void 0},e.key))}),(0,p.jsx)(`thead`,{className:`tw-table-head sticky top-0 z-10 text-xs text-stone-500`,children:(0,p.jsxs)(`tr`,{children:[(0,p.jsx)(`th`,{className:ue,children:(0,p.jsx)(`input`,{type:`checkbox`,"aria-label":`全选本页记录`,checked:Le,disabled:Z.length===0,onChange:e=>{let t=e.target.checked;N(e=>{let n={...e};for(let e of Z)t?n[e.id]=!0:delete n[e.id];return n})}})}),(0,p.jsxs)(`th`,{className:he,style:{"--tw-sticky-left":`32px`},children:[`统计日期`,(0,p.jsx)(u,{...G.resizeProps(`date`)})]}),U.isVisible(`dimensions`)?(0,p.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`测试统计维度`,(0,p.jsx)(u,{...G.resizeProps(`dimensions`)})]}):null,U.isVisible(`count`)?(0,p.jsxs)(`th`,{className:`relative px-2 py-2 text-center font-medium whitespace-nowrap`,children:[`统计数量`,(0,p.jsx)(u,{...G.resizeProps(`count`)})]}):null,U.isVisible(`createdAt`)?(0,p.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`创建日期`,(0,p.jsx)(u,{...G.resizeProps(`createdAt`)})]}):null,U.isVisible(`updatedAt`)?(0,p.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`修改日期`,(0,p.jsx)(u,{...G.resizeProps(`updatedAt`)})]}):null,(0,p.jsx)(`th`,{"aria-hidden":`true`}),(0,p.jsx)(`th`,{className:de,children:`操作`})]})}),(0,p.jsxs)(`tbody`,{children:[q.length===0?(0,p.jsx)(`tr`,{children:(0,p.jsx)(`td`,{colSpan:W.length,className:`px-4 py-14 text-center text-sm text-stone-400`,children:`还没有测试统计记录,点右上角「+ 添加记录」开始。`})}):null,Z.map(e=>(0,p.jsxs)(`tr`,{className:`group/row ${e.id===I?`tw-new-row`:`hover:bg-[#f7f8fa]`}`,children:[(0,p.jsx)(`td`,{className:l,children:(0,p.jsx)(`input`,{type:`checkbox`,"aria-label":`选择 ${e.date} ${e.dimensions.join(`/`)}`,checked:!!M[e.id],onChange:t=>N(n=>{let r={...n};return t.target.checked?r[e.id]=!0:delete r[e.id],r})})}),(0,p.jsx)(`td`,{className:ge,style:{"--tw-sticky-left":`32px`},children:(0,p.jsx)(re,{value:e.date,onChange:t=>void $(e.id,{date:t}),placeholder:`选择日期`,className:`h-8 w-full 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`})}),U.isVisible(`dimensions`)?(0,p.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,p.jsx)(le,{compact:!0,ariaLabel:`测试统计维度`,options:T,value:e.dimensions[0]??``,onChange:t=>void $(e.id,{dimensions:t?[t]:[]}),onRenameOption:(e,t)=>void ze(e,t),onDeleteOption:e=>void Be(e),placeholder:`选择或创建维度`})}):null,U.isVisible(`count`)?(0,p.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,p.jsx)(S,{value:e.count,ariaLabel:`统计数量`,onCommit:t=>void $(e.id,{count:t})})}):null,U.isVisible(`createdAt`)?(0,p.jsx)(`td`,{className:`whitespace-nowrap px-2 py-1 align-middle text-xs text-stone-500`,children:s(e.createdAt)}):null,U.isVisible(`updatedAt`)?(0,p.jsx)(`td`,{className:`whitespace-nowrap px-2 py-1 align-middle text-xs text-stone-500`,children:s(e.updatedAt)}):null,(0,p.jsx)(`td`,{"aria-hidden":`true`}),(0,p.jsx)(`td`,{className:pe,children:(0,p.jsx)(`button`,{type:`button`,disabled:k,onClick:()=>z([e]),"aria-label":`删除 ${e.date} 的记录`,className:`tw-icon-danger rounded p-1`,children:x})})]},e.id))]})]})}),q.length>0?(0,p.jsx)(ae,{page:X,totalPages:Y,pageSize:F,busy:k,onPage:P,onPageSize:e=>{Pe(e),P(1)}}):(0,p.jsx)(`div`,{className:`pb-1`}),(0,p.jsx)(ne,{open:R!==null,title:`删除测试统计`,message:R&&R.length>1?`确定删除选中的 ${R.length} 条记录吗?删除后不可恢复。`:`确定删除 ${R?.[0]?.date??``} 的这条记录吗?删除后不可恢复。`,confirmLabel:`删除`,danger:!0,onClose:()=>z(null),onConfirm:()=>void Ve()})]}):(0,p.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,p.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(`testStats`)}):(0,p.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,p.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center`,children:(0,p.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})})}export{C as default};
@@ -1 +0,0 @@
1
- import{s as e,t}from"./react.Blvh0GOs.js";import{t as n}from"./jsx-runtime.DUg_B_vD.js";var r=e(t(),1),i=n(),a=`lantern:toast`,o={info:2600,success:2600,error:4200},s={info:{dot:`bg-stone-400`,box:`border-stone-200 bg-white tw-toast-info`,text:`text-stone-700`},success:{dot:`bg-emerald-500`,box:`border-emerald-200 bg-white tw-toast-success`,text:`text-emerald-700`},error:{dot:`bg-red-500`,box:`border-red-200 bg-white tw-toast-error`,text:`text-red-600`}};function c(e,t=`info`){let n=String(e??``).trim();n&&typeof window<`u`&&window.dispatchEvent(new CustomEvent(a,{detail:{message:n,tone:t}}))}function l(){let[e,t]=(0,r.useState)(null),n=(0,r.useRef)(0),i=(0,r.useRef)(null),a=(0,r.useCallback)(()=>{i.current!=null&&(window.clearTimeout(i.current),i.current=null),t(null)},[]),s=(0,r.useCallback)((e,r=`info`)=>{let a=String(e??``).trim();a&&(i.current!=null&&window.clearTimeout(i.current),n.current+=1,t({message:a,tone:r,seq:n.current}),i.current=window.setTimeout(()=>{i.current=null,t(null)},o[r]??2600))},[]);return(0,r.useEffect)(()=>()=>{i.current!=null&&window.clearTimeout(i.current)},[]),{state:e,show:s,hide:a}}function u({state:e,onClose:t,topClassName:n=`top-[68px]`}){if(!e)return null;let r=s[e.tone]??s.info;return(0,i.jsx)(`div`,{className:`tw-plugin-toast pointer-events-none fixed left-1/2 z-[200] -translate-x-1/2 ${n}`,role:e.tone===`error`?`alert`:`status`,"aria-live":e.tone===`error`?`assertive`:`polite`,children:(0,i.jsxs)(`div`,{className:`tw-toast-box pointer-events-auto flex max-w-[min(92vw,520px)] items-start gap-2 rounded-xl border px-3.5 py-2.5 shadow-lg ${r.box}`,children:[(0,i.jsx)(`span`,{className:`mt-1.5 h-1.5 w-1.5 shrink-0 rounded-full ${r.dot}`,"aria-hidden":`true`}),(0,i.jsx)(`p`,{className:`tw-toast-text text-[12px] leading-relaxed ${r.text}`,children:e.message}),(0,i.jsx)(`button`,{type:`button`,onClick:t,className:`tw-toast-close -mr-1 ml-1 flex h-5 w-5 shrink-0 items-center justify-center rounded text-stone-400 transition-colors hover:bg-stone-100 hover:text-stone-600`,"aria-label":`关闭提示`,children:(0,i.jsx)(`svg`,{viewBox:`0 0 24 24`,width:11,height:11,fill:`none`,"aria-hidden":`true`,children:(0,i.jsx)(`path`,{d:`M5 5l14 14M19 5 5 19`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`})})})]})},e.seq)}function d(){let[e,t]=(0,r.useState)(null),n=(0,r.useRef)(0),s=(0,r.useRef)(null),c=(0,r.useCallback)(()=>{s.current!=null&&(window.clearTimeout(s.current),s.current=null),t(null)},[]);return(0,r.useEffect)(()=>{let e=e=>{let r=e.detail??{},i=String(r.message??``).trim();if(!i)return;let a=r.tone??`info`;s.current!=null&&window.clearTimeout(s.current),n.current+=1,t({message:i,tone:a,seq:n.current}),s.current=window.setTimeout(()=>{s.current=null,t(null)},o[a]??2600)};return window.addEventListener(a,e),()=>{window.removeEventListener(a,e),s.current!=null&&window.clearTimeout(s.current)}},[]),(0,i.jsx)(u,{state:e,onClose:c})}export{d as GlobalToastHost,u as ToastHost,c as showToast,l as useToast};
@@ -1 +0,0 @@
1
- import{s as e,t}from"./react.Blvh0GOs.js";import{i as n}from"./app-config.DkyjuL-S.js";import{i as r,o as i,s as a}from"./plugins.BRvXWHLe.js";import{n as o,o as s,r as c,s as ee}from"./view-prefs.DhdLZjGh.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.DrrPf1MB.js";import{n as re,t as p}from"./DatePicker.Bkl71M49.js";import{t as ie}from"./OverflowHint.CHZeFfUj.js";import{t as m}from"./SelectDropdown.T3CKHaLt.js";import{E as ae}from"./PmShared.BK8kWRSV.js";import{n as oe,r as se,t as ce}from"./TableFieldConfig.C7O-mL-p.js";import{showToast as h}from"./Toast.BO2NFckG.js";import{a as le,c as ue,d as g,i as de,l as _,n as v,o as fe,r as pe,s as me,t as y}from"./ColumnResize.CkE59sGq.js";import{A as he,C as ge,D as b,E as x,F as S,M as _e,N as ve,O as ye,P as be,S as xe,T as Se,_ as Ce,b as C,f as we,g as Te,j as w,n as T,u as Ee,v as E,w as De,x as Oe,y as D}from"./tasks.DEyD8pmq.js";import{a as O,c as k,i as ke,l as Ae,n as A,o as j,r as je,s as M,t as N}from"./DrawerField.BH3p4Q4D.js";var P=e(t(),1),F=d(),Me=8e3,Ne=[{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:`createdAt`,width:140,min:110},{key:`updatedAt`,width:140,min:110},{key:`filler`,filler:!0},{key:`action`,width:88,min:72}],Pe=new Set([`select`,`index`,`title`,`filler`,`action`]),Fe=[{key:`status`,label:`待办状态`},{key:`task`,label:`所属任务`},{key:`priority`,label:`紧急程度`},{key:`start`,label:`开始日期`},{key:`due`,label:`截止日期`},{key:`end`,label:`结束日期`},{key:`cycle`,label:`周期`},{key:`remain`,label:`剩余`},{key:`note`,label:`备注`},{key:`createdAt`,label:`创建日期`},{key:`updatedAt`,label:`修改日期`}],Ie=`todos.fields`,Le=[`title`,`status`,`priority`,`linkedTask`,`startDate`,`dueDate`,`note`],Re={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`},ze={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]`},I={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`},Be={pending:`bg-stone-400`,in_progress:`bg-[#3370ff]`,done:`bg-[#34c724]`,overdue:`bg-[#f54a45]`,cancelled:`bg-stone-300`},Ve={urgent_important:`bg-[#f54a45]`,important:`bg-[#ff8800]`,urgent:`bg-[#f7ba1e]`,normal:`bg-stone-300`,"":`border border-stone-300 bg-transparent`},L={status:`按状态分组`,priority:`按紧急程度分组`,none:`不分组`},He=[`status`,`priority`,`none`],Ue=`todos.group-by`,We=[`in_progress`,`pending`,`overdue`,`done`,`cancelled`],Ge=D.map(e=>({value:e,label:C[e]})),Ke=Ce.map(e=>({value:e,label:E[e]})),qe=`h-8 w-full justify-start rounded-md border border-stone-200 bg-white px-2 text-left text-sm font-normal text-stone-400 hover:border-stone-300 focus:ring-2 focus:ring-[#3370ff]/30`,Je=`h-8 w-auto max-w-full justify-start bg-transparent px-0 text-left focus:ring-0`,R=`未选择`,Ye=Object.keys(L).map(e=>({value:e,label:L[e]})),Xe=[{value:`all`,label:`全部紧急程度`},...Ce.map(e=>({value:e,label:E[e]}))],Ze=Xe.map(e=>e.value),Qe=`todos.priority-filter`,$e=`todos.search`,et=`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 tt(e){let{value:t,placeholder:n,muted:r,autoFocus:i,onChange:a,onCommit:o,onCancel:s}=e;return(0,F.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:`${et} ${r&&!t?`text-stone-300`:``}`})}function nt(e){let{value:t,onChange:n,onCommit:r,onCancel:i}=e,[a,o]=(0,P.useState)(!1);return a?(0,F.jsx)(tt,{value:t,placeholder:`—`,autoFocus:!0,onChange:n,onCommit:()=>{o(!1),r()},onCancel:()=>{o(!1),i()}}):(0,F.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,F.jsx)(`span`,{className:`text-stone-300`,children:`—`})})}function rt(e){return(0,F.jsx)(p,{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 it(e){let{open:t,item:n,preset:r,tasks:i,tasksOn:a,onClose:o,onSaved:s}=e,[c,ee]=(0,P.useState)({title:``}),[d,f]=(0,P.useState)(``),[oe,se]=(0,P.useState)(!1),[ce,le]=(0,P.useState)(!0);(0,P.useEffect)(()=>{t&&(f(``),se(!1),le(!0),ee(n?{title:n.title,status:n.status,statusManual:n.statusManual,priority:n.priority,linkedTask:n.linkedTask,taskId:n.taskId,startDate:n.startDate,dueDate:n.dueDate,note:n.note}:(()=>{let e=w(),t=w(),n=x(e,t)??`in_progress`;return{title:``,status:r?.status??n,statusManual:!!r?.status,priority:r?.priority??``,startDate:e,dueDate:t}})()))},[t,n,r]);let ue=[{value:``,label:`不关联`},...we(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=>{let n={...t,...e};if(`status`in e&&!(`startDate`in e||`dueDate`in e))n.statusManual=!0;else if((`startDate`in e||`dueDate`in e)&&!n.statusManual&&!b(n.status??`pending`)){let e=x(n.startDate??``,n.dueDate??``);e&&(n.status=e)}let r=n.dueDate??``,i=n.status??`pending`;return r&&r<w()&&!b(i)&&(n.status=`overdue`,n.statusManual=!1),n})}let de=_e({startDate:c.startDate??``,dueDate:c.dueDate??``}),_=be({dueDate:c.dueDate??``}),v=b(c.status??`pending`),fe=v?re((n&&b(n.status)?n.taskEndDate:``)||w()):``,pe=_===null?``:c.status===`done`?`已完成`:c.status===`cancelled`?`已取消`:_<0?`逾期 ${Math.abs(_)} 天`:_===0?`今天截止`:`${_} 天`;async function me(){let e=(c.title??``).trim();if(!e)f(`请填写待办名称`);else if(c.startDate&&c.dueDate&&c.dueDate<c.startDate)f(`截止日期不能早于开始日期`);else{se(!0),f(``);try{let t={...c,title:e};n?await S(n.id,t):await Oe([t],{mode:`manual`}),await s(),h(n?`已保存待办`:`已新建待办`,`success`),o()}catch(e){let t=e instanceof Error?e.message:String(e);f(t),h(`保存待办失败:${t}`,`error`)}finally{se(!1)}}}return(0,F.jsxs)(u,{open:t,onClose:o,transition:!0,className:`relative z-100`,children:[(0,F.jsx)(ne,{transition:!0,className:`tw-dialog-backdrop-anim fixed inset-0 bg-black/25`,"aria-hidden":`true`}),(0,F.jsx)(`div`,{className:`fixed inset-0 flex justify-end overflow-hidden`,children:(0,F.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 duration-[280ms]`,children:[(0,F.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-3 border-b border-stone-100 px-6 py-4`,children:[(0,F.jsx)(te,{className:`text-base font-semibold text-stone-900`,children:n?`待办详情`:`新建待办`}),(0,F.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,F.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto py-3`,children:[(0,F.jsx)(A,{icon:(0,F.jsx)(Ae,{}),label:`待办名称`,children:(0,F.jsx)(`input`,{autoFocus:!0,value:c.title,onChange:e=>g({title:e.target.value}),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),me())},placeholder:`请输入内容`,className:N})}),(0,F.jsx)(A,{icon:(0,F.jsx)(M,{}),label:`待办状态`,children:(0,F.jsx)(je,{ariaLabel:`待办状态`,menuMinWidth:140,options:Ge,value:c.status??`pending`,onChange:e=>g({status:e}),label:C[c.status??`pending`],optionDotClassName:e=>Be[e]})}),(0,F.jsxs)(`button`,{type:`button`,onClick:()=>le(e=>!e),"aria-expanded":ce,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,F.jsx)(`span`,{className:`flex h-4 w-4 items-center justify-center text-stone-400`,children:(0,F.jsx)(k,{})}),(0,F.jsx)(`span`,{children:`任务详情`}),(0,F.jsx)(`span`,{className:`text-stone-400`,children:(0,F.jsx)(ke,{open:ce})})]}),ce?(0,F.jsxs)(`div`,{className:`ml-[42px] border-l border-stone-100 pl-1`,children:[(0,F.jsx)(A,{icon:(0,F.jsx)(k,{}),label:`所属任务`,children:a?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(m,{flat:!0,searchable:!0,searchPlaceholder:`搜索任务…`,ariaLabel:`所属任务`,menuMinWidth:220,options:ue,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,F.jsx)(ie,{text:c.taskId?i.find(e=>e.id===c.taskId)?.title??``:c.linkedTask||`请选择任务`,className:`min-w-0 truncate ${c.taskId||c.linkedTask?`text-stone-800`:`text-stone-400`}`})}),i.length===0?(0,F.jsx)(`p`,{className:`mt-1 px-2 text-xs text-stone-400`,children:`任务管理里还没有任务,可到「任务管理」新建后再关联。`}):null]}):(0,F.jsx)(`div`,{className:`flex h-9 items-center rounded-md bg-stone-50 px-2 text-sm text-stone-400`,children:(0,F.jsx)(`span`,{className:`truncate`,children:c.linkedTask?`${c.linkedTask}(任务管理插件未启用)`:`任务管理插件未启用,无法关联任务`})})}),(0,F.jsx)(A,{icon:(0,F.jsx)(M,{}),label:`重要紧急程度`,children:(()=>{let e=c.taskId?i.find(e=>e.id===c.taskId):void 0;return e?(0,F.jsxs)(`div`,{className:`flex h-9 items-center gap-2 px-2 text-sm`,children:[(0,F.jsx)(`span`,{className:e.priority?`text-stone-800`:`text-stone-400`,children:e.priority?T[e.priority]:`任务未设置`}),(0,F.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:`跟随所属任务`})]}):(0,F.jsx)(je,{ariaLabel:`重要紧急程度`,menuMinWidth:140,options:Ke,value:c.priority??``,onChange:e=>g({priority:e}),label:c.priority?E[c.priority]:R,optionDotClassName:e=>Ve[e]})})()}),(0,F.jsx)(A,{icon:(0,F.jsx)(O,{}),label:`结束日期`,children:(0,F.jsxs)(`div`,{className:`flex h-9 items-center px-2 text-sm tabular-nums`,"aria-readonly":`true`,children:[fe?(0,F.jsx)(`span`,{className:`text-stone-800`,children:fe}):(0,F.jsx)(`span`,{className:`text-stone-400`,children:`待办未完成`}),(0,F.jsx)(`span`,{className:`ml-2 text-[11px] text-stone-400`,children:v?`按完成日期自动记录`:`状态为已完成 / 已取消时自动记录`})]})})]}):null,(0,F.jsx)(A,{icon:(0,F.jsx)(O,{}),label:`开始日期`,children:(0,F.jsx)(p,{value:c.startDate??``,onChange:e=>g({startDate:e}),className:`${N} tabular-nums`})}),(0,F.jsx)(A,{icon:(0,F.jsx)(O,{}),label:`截止日期`,children:(0,F.jsx)(p,{value:c.dueDate??``,onChange:e=>g({dueDate:e}),className:`${N} tabular-nums`})}),(0,F.jsx)(A,{icon:(0,F.jsx)(j,{}),label:`待办周期`,children:(0,F.jsx)(`div`,{className:`px-2 pt-1.5 text-sm text-stone-500`,children:de===null?`—`:`${de} 天`})}),(0,F.jsx)(A,{icon:(0,F.jsx)(j,{}),label:`剩余天数`,children:(0,F.jsx)(`div`,{className:`px-2 pt-1.5 text-sm text-stone-500`,children:pe||`—`})}),(0,F.jsx)(A,{icon:(0,F.jsx)(Ae,{}),label:`备注`,children:(0,F.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`})}),n?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(A,{icon:(0,F.jsx)(O,{}),label:`创建日期`,children:(0,F.jsx)(`div`,{className:`px-2 pt-1.5 text-sm text-stone-500`,children:ae(n.createdAt)})}),(0,F.jsx)(A,{icon:(0,F.jsx)(O,{}),label:`修改日期`,children:(0,F.jsx)(`div`,{className:`px-2 pt-1.5 text-sm text-stone-500`,children:ae(n.updatedAt)})})]}):null,d?(0,F.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,F.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-stone-100 px-6 py-3`,children:[(0,F.jsx)(`button`,{type:`button`,onClick:o,disabled:oe,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,F.jsx)(`button`,{type:`button`,onClick:()=>void me(),disabled:oe,className:`h-8 rounded-lg bg-[#3370ff] px-4 text-sm font-medium text-white transition-colors hover:bg-[#2b5fd9] disabled:opacity-40`,children:oe?`保存中…`:n?`保存`:`新建`})]})]})})]})}function z(){let[e,t]=(0,P.useState)(!1),[l,te]=(0,P.useState)(!0),[u,ne]=(0,P.useState)(null),[d,T]=(0,P.useState)([]),[D,O]=(0,P.useState)([]),[k,ke]=(0,P.useState)(!1),[Ae,A]=(0,P.useState)(null),[j,je]=(0,P.useState)(!1),[M,N]=(0,P.useState)(()=>c($e)),[L,et]=(0,P.useState)(()=>o(Qe,Ze,`all`)),[z,at]=(0,P.useState)(()=>o(Ue,He,`status`)),[ot,st]=(0,P.useState)({}),[B,ct]=(0,P.useState)({});function lt(e){s(Ue,e),at(e)}function ut(e){s(Qe,e),et(e)}function dt(e){ee($e,e),N(e)}let[ft,pt]=(0,P.useState)({}),[V,H]=(0,P.useState)(null),[U,W]=(0,P.useState)(null),[mt,ht]=(0,P.useState)(!1),[gt,_t]=(0,P.useState)(null),G=(0,P.useRef)(!0),vt=(0,P.useRef)(!1),yt=(0,P.useRef)(!1),K=se(Ie,Fe,Pe),bt=(0,P.useMemo)(()=>oe(Ne,K.isVisible),[K.isVisible]),xt=bt.length,q=_(`lh:todos:cols:v1`,bt),St=g(`todos`),Ct=V!==null,wt=(0,P.useRef)(V);wt.current=V;let Tt=(0,P.useRef)(!1),Et=(0,P.useRef)(async()=>{});Et.current=Pt,(0,P.useEffect)(()=>(G.current=!0,()=>{G.current=!1}),[]),(0,P.useEffect)(()=>{if(!Ct)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=wt.current;if(!n)return;if(n.title.trim()){Et.current();return}let r=w();!n.note.trim()&&!n.taskId&&n.status===n.baseStatus&&n.priority===n.basePriority&&n.startDate===r&&n.dueDate===r&&H(null)};return document.addEventListener(`pointerdown`,e,!0),()=>document.removeEventListener(`pointerdown`,e,!0)},[Ct]);let J=(0,P.useCallback)(async()=>{try{let[e,t]=await Promise.all([ye(),k?Ee().catch(()=>[]):Promise.resolve([])]);if(!G.current)return;let n=t;if(!vt.current&&k){vt.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=>Te(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),A(null)}catch(e){if(!G.current)return;A(e instanceof Error?e.message:String(e))}},[k]);(0,P.useEffect)(()=>{let e=i(e=>{te(!!e.todos),ke(!!e.tasks)});return n().then(()=>{te(r(`todos`)),ke(r(`tasks`)),t(!0)}),e},[]),(0,P.useEffect)(()=>{e&&l&&(async()=>{let e=await De();G.current&&(e?(await J(),G.current&&ne(!0)):ne(!1))})()},[e,l,J]),(0,P.useEffect)(()=>{if(u!==!0)return;let e=window.setInterval(()=>{yt.current||J()},Me),t=()=>{yt.current||J()};return window.addEventListener(`focus`,t),()=>{window.clearInterval(e),window.removeEventListener(`focus`,t)}},[u,J]),(0,P.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 S(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 Dt(e,t,n){pt(r=>({...r,[e]:{...r[e],[t]:n}}))}function Y(e){pt(t=>{if(!(e in t))return t;let n={...t};return delete n[e],n})}let Ot=(0,P.useMemo)(()=>[{value:``,label:`不关联`},...we(D.filter(e=>e.status!==`closed`&&e.status!==`cancelled`)).map(e=>({value:e.id,label:e.title}))],[D]);function kt(e){return e.taskId?D.find(t=>t.id===e.taskId)?.title??e.linkedTask:e.linkedTask}function At(e){return e.taskId?D.find(t=>t.id===e.taskId):void 0}function jt(e){let t=At(e);return t?t.priority:e.priority}async function X(e,t){let n=d.find(t=>t.id===e),r={...t};if(t.status!==void 0&&t.startDate===void 0&&t.dueDate===void 0)r.statusManual=!0;else if(n&&!n.statusManual&&!b(n.status)&&(t.startDate!==void 0||t.dueDate!==void 0)&&t.status===void 0){let e=x(t.startDate??n.startDate,t.dueDate??n.dueDate);e&&(r.status=e)}if(n){let e=r.dueDate??n.dueDate,t=r.status??n.status;e&&e<w()&&!b(t)&&(r.status=`overdue`,r.statusManual=!1)}T(t=>t.map(t=>t.id===e?{...t,...r,updatedAt:new Date().toISOString()}:t));try{let t=await S(e,r);if(!G.current)return;T(n=>n.map(n=>n.id===e?t:n)),A(null),r.taskId&&await J()}catch(e){A(e instanceof Error?e.message:String(e)),await J()}}async function Mt(e){let t=ft[e],n=d.find(t=>t.id===e);if(!t||!n)return;let r={},i=n;for(let e of Le){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())A(`待办名称不能为空`),Y(e);else try{let t=await S(e,r);if(!G.current)return;T(n=>n.map(n=>n.id===e?t:n)),pt(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}}),A(null)}catch(t){A(t instanceof Error?t.message:String(t)),Y(e)}}function Nt(e){let t=w(),n=w(),r=!!e.newStatus,i=x(t,n)??`in_progress`,a=e.newStatus??i,o=e.newPriority??``;H({groupKey:e.key,title:``,status:a,statusManual:r,priority:o,taskId:``,startDate:t,dueDate:n,note:``,baseStatus:a,basePriority:o}),st(t=>({...t,[e.key]:!1}))}async function Pt(){let e=wt.current;if(!e||Tt.current)return;let t=e.title.trim();if(t){Tt.current=!0,ht(!0);try{let n=D.find(t=>t.id===e.taskId);await Oe([{title:t,status:e.status,statusManual:e.statusManual,priority:e.priority,taskId:e.taskId,linkedTask:n?.title??``,startDate:e.startDate,dueDate:e.dueDate,note:e.note}],{mode:`manual`}),wt.current===e&&H(null),A(null),await J()}catch(e){A(e instanceof Error?e.message:String(e))}finally{Tt.current=!1,G.current&&ht(!1)}}}async function Ft(){let e=U;if(e){W(null),je(!0),A(null);try{await xe(e.map(e=>e.id)),ct({}),await J(),h(e.length>1?`已删除 ${e.length} 条待办`:`已删除待办`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);A(t),h(`删除待办失败:${t}`,`error`)}finally{G.current&&je(!1)}}}let Z=w(),It=(0,P.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]),Lt=(0,P.useMemo)(()=>Se(It,{status:`all`,priority:L,keyword:M,today:Z}),[It,L,M,Z]),Q=(0,P.useMemo)(()=>he(Lt),[Lt]),Rt=(0,P.useMemo)(()=>z===`none`?[{key:`all`,label:`全部待办`,pill:`bg-stone-500 text-white`,items:Q}]:z===`priority`?[...Ce,``].map(e=>({key:`priority:${e||`none`}`,label:e?E[e]:R,pill:e?I[e]:`bg-stone-300 text-stone-600`,items:Q.filter(t=>t.priority===e),newPriority:e})):We.map(e=>({key:`status:${e}`,label:C[e],pill:Re[e],items:Q.filter(t=>ge(t,Z)===e),newStatus:e===`overdue`?`pending`:e})),[z,Q,Z]).filter(e=>e.items.length>0||V?.groupKey===e.key&&!!V),zt=Object.keys(B).filter(e=>B[e]),$=(0,P.useMemo)(()=>{let e={total:d.length,pending:0,in_progress:0,done:0,overdue:0};for(let t of d){let n=ge(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,F.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,F.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center`,children:(0,F.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})}):u?(0,F.jsxs)(`section`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,F.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-3 border-b border-stone-100 px-4 py-3`,children:[(0,F.jsxs)(`div`,{className:`text-sm text-stone-600`,children:[`共 `,(0,F.jsx)(`span`,{className:`font-medium text-stone-800`,children:$.total}),` 条`,(0,F.jsxs)(`span`,{className:`text-stone-400`,children:[` `,`· 待开始 `,$.pending,` · 进行中 `,$.in_progress,` · 已完成 `,$.done,$.overdue?` · 已延期 ${$.overdue}`:``]})]}),(0,F.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[(0,F.jsx)(`input`,{value:M,onChange:e=>dt(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,F.jsx)(m,{flat:!0,className:`w-[132px]`,ariaLabel:`分组方式`,options:Ye,value:z,onChange:e=>lt(e)}),(0,F.jsx)(m,{flat:!0,className:`w-[136px]`,ariaLabel:`紧急程度筛选`,options:Xe,value:L,onChange:e=>ut(e)}),(0,F.jsx)(`button`,{type:`button`,disabled:j||zt.length===0,onClick:()=>W(d.filter(e=>B[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,F.jsx)(ce,{fields:K.fields,isVisible:K.isVisible,onToggle:K.toggle}),(0,F.jsx)(`button`,{type:`button`,disabled:j,onClick:()=>_t({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:`+ 新建待办`})]})]}),Ae?(0,F.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,F.jsx)(`span`,{className:`min-w-0 flex-1`,children:Ae}),(0,F.jsx)(`button`,{type:`button`,onClick:()=>A(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,F.jsx)(`div`,{ref:St,className:`tw-scroll-x min-h-0 flex-1 overflow-auto`,onFocusCapture:()=>{yt.current=!0},onBlurCapture:()=>{window.setTimeout(()=>{yt.current=!!document.activeElement?.closest(`.tw-todo-table`)},0)},children:(0,F.jsxs)(`table`,{className:`tw-todo-table tw-sticky-table w-full table-fixed text-sm`,style:q.tableStyle,children:[(0,F.jsx)(`colgroup`,{children:bt.map(e=>(0,F.jsx)(`col`,{style:q.widthOf(e.key)?{width:q.widthOf(e.key)}:void 0},e.key))}),(0,F.jsx)(`thead`,{className:`tw-table-head sticky top-0 z-10 text-xs text-stone-500`,children:(0,F.jsxs)(`tr`,{children:[(0,F.jsx)(`th`,{className:le,children:(0,F.jsx)(`input`,{type:`checkbox`,"aria-label":`全选可见待办`,checked:Q.length>0&&Q.every(e=>B[e.id]),onChange:e=>{let t=e.target.checked;ct(e=>{let n={...e};for(let e of Q)t?n[e.id]=!0:delete n[e.id];return n})}})}),(0,F.jsx)(`th`,{className:me,style:{"--tw-sticky-left":`32px`},"aria-label":`行号`}),(0,F.jsxs)(`th`,{className:fe,style:{"--tw-sticky-left":`68px`},children:[`待办名称`,(0,F.jsx)(y,{...q.resizeProps(`title`)})]}),K.isVisible(`status`)?(0,F.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`待办状态`,(0,F.jsx)(y,{...q.resizeProps(`status`)})]}):null,K.isVisible(`task`)?(0,F.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`所属任务`,(0,F.jsx)(y,{...q.resizeProps(`task`)})]}):null,K.isVisible(`priority`)?(0,F.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`紧急程度`,(0,F.jsx)(y,{...q.resizeProps(`priority`)})]}):null,K.isVisible(`start`)?(0,F.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`开始日期`,(0,F.jsx)(y,{...q.resizeProps(`start`)})]}):null,K.isVisible(`due`)?(0,F.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`截止日期`,(0,F.jsx)(y,{...q.resizeProps(`due`)})]}):null,K.isVisible(`end`)?(0,F.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`结束日期`,(0,F.jsx)(y,{...q.resizeProps(`end`)})]}):null,K.isVisible(`cycle`)?(0,F.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`周期`,(0,F.jsx)(y,{...q.resizeProps(`cycle`)})]}):null,K.isVisible(`remain`)?(0,F.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`剩余`,(0,F.jsx)(y,{...q.resizeProps(`remain`)})]}):null,K.isVisible(`note`)?(0,F.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`备注`,(0,F.jsx)(y,{...q.resizeProps(`note`)})]}):null,K.isVisible(`createdAt`)?(0,F.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`创建日期`,(0,F.jsx)(y,{...q.resizeProps(`createdAt`)})]}):null,K.isVisible(`updatedAt`)?(0,F.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`修改日期`,(0,F.jsx)(y,{...q.resizeProps(`updatedAt`)})]}):null,(0,F.jsx)(`th`,{"aria-hidden":`true`}),(0,F.jsx)(`th`,{className:ue,children:`操作`})]})}),Rt.map(e=>{let t=ot[e.key]===!0,n=()=>st(n=>({...n,[e.key]:!t}));return(0,F.jsxs)(`tbody`,{children:[(0,F.jsxs)(`tr`,{role:`button`,tabIndex:0,"aria-expanded":!t,"aria-label":t?`展开分组`:`收起分组`,className:`tw-life-group-head cursor-pointer bg-white`,style:{"--tw-row-bg":`#ffffff`,"--life-select-w":`68px`},onClick:n,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),n())},children:[(0,F.jsx)(`td`,{colSpan:3,className:`tw-sticky-l tw-life-group-sticky-lead border-b border-stone-100 px-0 pb-1.5 pt-3 align-middle`,style:{left:0,"--tw-sticky-left":`0px`},children:(0,F.jsxs)(`div`,{className:`flex w-full items-center gap-2 py-1.5 pr-2 text-left`,children:[(0,F.jsx)(`span`,{className:`flex h-7 w-9 shrink-0 items-center justify-center`,children:(0,F.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.4`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,className:`shrink-0 text-stone-400 transition-transform duration-200 ease-out ${t?`-rotate-90`:`rotate-0`}`,children:(0,F.jsx)(`path`,{d:`m6 9 6 6 6-6`})})}),(0,F.jsx)(`span`,{className:`inline-flex max-w-[min(100%,16rem)] shrink-0 items-center truncate rounded-full px-2.5 py-0.5 text-xs font-medium whitespace-nowrap ${e.pill}`,children:e.label}),(0,F.jsxs)(`span`,{className:`shrink-0 text-xs text-stone-400 tabular-nums`,children:[e.items.length,` 条记录`]})]})}),(0,F.jsx)(`td`,{colSpan:Math.max(xt-3,1),className:`border-b border-stone-100 bg-white pb-1.5 pt-3`,"aria-hidden":`true`})]}),t?null:e.items.map((e,t)=>{let n=ft[e.id]??{},r={...e,...n},i=ge(r,Z),a=_e(r),o=be(r,Z),s=o===null?`—`:i===`done`?`已完成`:i===`cancelled`?`已取消`:o<0?`逾期 ${Math.abs(o)} 天`:o===0?`今天截止`:`${o} 天`;return(0,F.jsxs)(`tr`,{className:`group/row hover:bg-[#f7f8fa]`,children:[(0,F.jsx)(`td`,{className:v,children:(0,F.jsx)(`input`,{type:`checkbox`,"aria-label":`选择 ${e.title}`,checked:!!B[e.id],onChange:t=>ct(n=>{let r={...n};return t.target.checked?r[e.id]=!0:delete r[e.id],r})})}),(0,F.jsx)(`td`,{className:`${pe} text-xs text-stone-400 tabular-nums`,style:{"--tw-sticky-left":`32px`},children:t+1}),(0,F.jsx)(`td`,{className:v,style:{"--tw-sticky-left":`68px`},children:(0,F.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1`,children:[e.source===`ai`?(0,F.jsx)(`span`,{className:`shrink-0 rounded bg-[#e1eaff] px-1 py-px text-[10px] text-[#1f4ec2]`,title:`AI 记录`,children:`AI`}):null,(0,F.jsx)(tt,{value:r.title,placeholder:`输入待办名称`,onChange:t=>Dt(e.id,`title`,t),onCommit:()=>void Mt(e.id),onCancel:()=>Y(e.id)})]})}),K.isVisible(`status`)?(0,F.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,F.jsx)(m,{unstyled:!0,fitContent:!0,hideChevron:!0,centerContent:!0,ariaLabel:`待办状态`,menuMinWidth:120,options:Ge,value:i,onChange:t=>void X(e.id,{status:t}),triggerClassName:`h-7 max-w-full rounded-md px-2 text-center text-xs font-medium focus:ring-2 focus:ring-[#3370ff]/30 ${ze[i]}`,renderTrigger:()=>(0,F.jsx)(`span`,{className:`truncate`,children:C[i]}),renderOptionPrefix:e=>(0,F.jsx)(`span`,{className:`h-2 w-2 rounded-full ${Be[e.value]}`})})}):null,K.isVisible(`task`)?(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:k?(0,F.jsx)(m,{unstyled:!0,searchable:!0,searchPlaceholder:`搜索任务…`,ariaLabel:`所属任务`,menuMinWidth:220,options:Ot,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,F.jsx)(ie,{text:kt(r)||`未关联`,className:`min-w-0 truncate ${kt(r)?`text-stone-800`:`text-stone-300`}`})}):(0,F.jsx)(`span`,{className:`block truncate px-1.5 text-xs text-stone-400`,children:kt(r)?`${kt(r)} · 插件未启用`:`任务管理插件未启用`})}):null,K.isVisible(`priority`)?(0,F.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:At(r)?jt(r)?(0,F.jsx)(`span`,{className:`inline-flex h-7 max-w-full items-center truncate rounded-md px-2 text-xs font-medium ${I[jt(r)]}`,children:E[jt(r)]}):(0,F.jsx)(`span`,{className:`text-sm text-stone-400`,children:R}):(0,F.jsx)(m,{unstyled:!0,fitContent:!!e.priority,hideChevron:!0,ariaLabel:`紧急程度`,menuMinWidth:128,options:Ke,value:e.priority,onChange:t=>void X(e.id,{priority:t}),triggerClassName:e.priority?Je:qe,renderTrigger:()=>e.priority?(0,F.jsx)(`span`,{className:`inline-flex h-7 max-w-full items-center truncate rounded-md px-2 text-xs font-medium ${I[e.priority]}`,children:E[e.priority]}):(0,F.jsx)(`span`,{className:`truncate text-stone-400`,children:R}),renderOptionPrefix:e=>(0,F.jsx)(`span`,{className:`h-2 w-2 rounded-full ${Ve[e.value]}`})})}):null,K.isVisible(`start`)?(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,F.jsx)(rt,{value:r.startDate,onChange:t=>void X(e.id,{startDate:t})})}):null,K.isVisible(`due`)?(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,F.jsx)(rt,{value:r.dueDate,onChange:t=>void X(e.id,{dueDate:t})})}):null,K.isVisible(`end`)?(0,F.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap tabular-nums`,children:ve(r)?(0,F.jsx)(`span`,{className:`text-stone-500`,children:re(ve(r))}):(0,F.jsx)(`span`,{className:`text-stone-400`,children:`待办未完成`})}):null,K.isVisible(`cycle`)?(0,F.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap text-stone-500 tabular-nums`,children:a===null?`—`:`${a} 天`}):null,K.isVisible(`remain`)?(0,F.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}):null,K.isVisible(`note`)?(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,F.jsx)(nt,{value:r.note,onChange:t=>Dt(e.id,`note`,t),onCommit:()=>void Mt(e.id),onCancel:()=>Y(e.id)})}):null,K.isVisible(`createdAt`)?(0,F.jsx)(`td`,{className:`whitespace-nowrap px-2 py-1 align-middle text-xs text-stone-500`,children:ae(e.createdAt)}):null,K.isVisible(`updatedAt`)?(0,F.jsx)(`td`,{className:`whitespace-nowrap px-2 py-1 align-middle text-xs text-stone-500`,children:ae(e.updatedAt)}):null,(0,F.jsx)(`td`,{"aria-hidden":`true`}),(0,F.jsx)(`td`,{className:de,children:(0,F.jsxs)(`div`,{className:`flex items-center justify-end gap-0.5`,children:[(0,F.jsx)(`button`,{type:`button`,onClick:()=>_t({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,F.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,F.jsx)(`path`,{d:`M14 4h6v6`}),(0,F.jsx)(`path`,{d:`M20 4 13 11`}),(0,F.jsx)(`path`,{d:`M10 20H4v-6`}),(0,F.jsx)(`path`,{d:`M4 20l7-7`})]})}),(0,F.jsx)(`button`,{type:`button`,disabled:j,onClick:()=>W([e]),"aria-label":`删除 ${e.title}`,className:`tw-icon-danger rounded p-1`,children:(0,F.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,F.jsx)(`path`,{d:`M3 6h18`}),(0,F.jsx)(`path`,{d:`M8 6V4h8v2`}),(0,F.jsx)(`path`,{d:`M19 6l-1 14H6L5 6`}),(0,F.jsx)(`path`,{d:`M10 11v6M14 11v6`})]})})]})})]},e.id)}),t?null:V?.groupKey===e.key?(0,F.jsxs)(`tr`,{className:`tw-new-row`,children:[(0,F.jsx)(`td`,{className:`px-2 py-1 align-middle`}),(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle text-xs text-stone-400 tabular-nums`,children:e.items.length+1}),(0,F.jsx)(`td`,{className:pe,children:(0,F.jsx)(`input`,{autoFocus:!0,value:V.title,disabled:mt,placeholder:`输入待办名称,回车或点空白处保存`,onChange:e=>H(t=>t&&{...t,title:e.target.value}),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),Pt()):e.key===`Escape`&&(e.preventDefault(),H(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]`})}),K.isVisible(`status`)?(0,F.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,F.jsx)(m,{unstyled:!0,fitContent:!0,hideChevron:!0,centerContent:!0,ariaLabel:`待办状态`,menuMinWidth:120,options:Ge,value:V.status,onChange:e=>H(t=>t&&{...t,status:e,statusManual:!0}),triggerClassName:`h-7 max-w-full rounded-md px-2 text-center text-xs font-medium focus:ring-2 focus:ring-[#3370ff]/30 ${ze[V.status]}`,renderTrigger:()=>(0,F.jsx)(`span`,{className:`truncate`,children:C[V.status]})})}):null,K.isVisible(`task`)?(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:k?(0,F.jsx)(m,{unstyled:!0,searchable:!0,searchPlaceholder:`搜索任务…`,ariaLabel:`所属任务`,menuMinWidth:220,options:Ot,value:V.taskId,onChange:e=>H(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===V.taskId);return(0,F.jsx)(ie,{text:e?.title||`未关联`,className:`min-w-0 truncate ${e?`text-stone-800`:`text-stone-300`}`})}}):(0,F.jsx)(`span`,{className:`block truncate px-1.5 text-xs text-stone-400`,children:`任务管理插件未启用`})}):null,K.isVisible(`priority`)?(0,F.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(()=>{let e=D.find(e=>e.id===V.taskId);return e?(0,F.jsx)(`span`,{title:`跟随所属任务的紧急程度`,className:`inline-flex h-7 max-w-full items-center justify-center truncate rounded-md px-2 text-center text-xs font-medium ${I[e.priority]??`text-stone-300`}`,children:e.priority?E[e.priority]:R}):(0,F.jsx)(m,{unstyled:!0,fitContent:!!V.priority,hideChevron:!0,ariaLabel:`紧急程度`,menuMinWidth:128,options:Ke,value:V.priority,onChange:e=>H(t=>t&&{...t,priority:e}),triggerClassName:V.priority?Je:qe,renderTrigger:()=>V.priority?(0,F.jsx)(`span`,{className:`inline-flex h-7 max-w-full items-center truncate rounded-md px-2 text-xs font-medium ${I[V.priority]}`,children:E[V.priority]}):(0,F.jsx)(`span`,{className:`truncate text-stone-400`,children:R})})})()}):null,K.isVisible(`start`)?(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,F.jsx)(p,{value:V.startDate,onChange:e=>H(t=>{if(!t)return t;let n=e,r={...t,startDate:n};if(!t.statusManual&&!b(t.status)){let e=x(n,t.dueDate);e&&(r.status=e)}return r.dueDate&&r.dueDate<w()&&!b(r.status)&&(r.status=`overdue`,r.statusManual=!1),r}),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`})}):null,K.isVisible(`due`)?(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,F.jsx)(p,{value:V.dueDate,onChange:e=>H(t=>{if(!t)return t;let n=e,r={...t,dueDate:n};if(!t.statusManual&&!b(t.status)){let e=x(t.startDate,n);e&&(r.status=e)}return n&&n<w()&&!b(r.status)&&(r.status=`overdue`,r.statusManual=!1),r}),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`})}):null,K.isVisible(`end`)?(0,F.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap tabular-nums`,children:b(V.status)?(0,F.jsx)(`span`,{className:`text-stone-500`,children:re(w())}):(0,F.jsx)(`span`,{className:`text-stone-400`,children:`待办未完成`})}):null,K.isVisible(`cycle`)?(0,F.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap text-stone-400 tabular-nums`,children:`—`}):null,K.isVisible(`remain`)?(0,F.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap text-stone-400 tabular-nums`,children:`—`}):null,K.isVisible(`note`)?(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,F.jsx)(`input`,{value:V.note,disabled:mt,placeholder:`—`,onChange:e=>H(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`})}):null,K.isVisible(`createdAt`)?(0,F.jsx)(`td`,{className:`whitespace-nowrap px-2 py-1 align-middle text-xs text-stone-400`,children:`—`}):null,K.isVisible(`updatedAt`)?(0,F.jsx)(`td`,{className:`whitespace-nowrap px-2 py-1 align-middle text-xs text-stone-400`,children:`—`}):null,(0,F.jsx)(`td`,{"aria-hidden":`true`}),(0,F.jsx)(`td`,{className:`px-1 py-1 align-middle`})]}):(0,F.jsxs)(`tr`,{children:[(0,F.jsx)(`td`,{className:`px-2 py-0.5`}),(0,F.jsx)(`td`,{className:`px-1 py-0.5`}),(0,F.jsx)(`td`,{className:`px-1 py-0.5`,colSpan:Math.max(xt-2,1),children:(0,F.jsxs)(`button`,{type:`button`,disabled:mt,onClick:()=>Nt(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,F.jsx)(`span`,{className:`text-sm leading-none`,children:`+`}),`新增记录`]})})]})]},e.key)}),Rt.length===0?(0,F.jsx)(`tbody`,{children:(0,F.jsx)(`tr`,{children:(0,F.jsx)(`td`,{colSpan:xt,className:`px-3 py-16 text-center text-sm text-stone-400`,children:d.length===0?`还没有待办`:`没有匹配的待办,试试调整搜索或筛选`})})}):null]})}),(0,F.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,F.jsxs)(`span`,{children:[`共 `,Q.length,` 条`,zt.length?` · 已选 ${zt.length}`:``]}),(0,F.jsx)(`span`,{className:`ml-auto text-stone-400`,children:`点击单元格直接编辑,回车或点空白处保存`})]}),(0,F.jsx)(it,{open:gt!==null,item:gt?.item??null,preset:gt?.preset,tasks:D,tasksOn:k,onClose:()=>_t(null),onSaved:J}),(0,F.jsx)(f,{open:U!=null,title:U&&U.length>1?`批量删除`:`删除待办`,message:U&&U.length>1?`确认删除已选中的 ${U.length} 条待办?此操作不可恢复。`:`删除「${U?.[0]?.title??``}」?此操作不可恢复。`,confirmLabel:`删除`,cancelLabel:`取消`,danger:!0,onClose:()=>W(null),onConfirm:()=>void Ft()})]}):(0,F.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,F.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,F.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,F.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center`,children:(0,F.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})})}export{z as default};