lantern-harness 0.1.21 → 0.1.23

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 (106) hide show
  1. package/CHANGELOG.md +40 -0
  2. package/builtin/session/session-runs.mjs +34 -1
  3. package/dist/500.html +4 -4
  4. package/dist/_astro/Base.GThhapKd.css +1 -0
  5. package/dist/_astro/Base.astro_astro_type_script_index_0_lang.CWRCetQl.js +2 -0
  6. package/dist/_astro/{CaseExecBoard.CwH1rd8R.js → CaseExecBoard.Dnb8oP5i.js} +1 -1
  7. package/dist/_astro/CaseGenerateApp.ci_JowEk.js +10 -0
  8. package/dist/_astro/CasesLibrary.CDjuLV_E.js +21 -0
  9. package/dist/_astro/ChatApp.Td2xCiQG.js +216 -0
  10. package/dist/_astro/{DashboardBoard.BDURPamv.js → DashboardBoard.D-zHXRds.js} +2 -2
  11. package/dist/_astro/DocsFileBrowser.BM3nH4VD.js +1 -0
  12. package/dist/_astro/{DocsPager.v4kQH163.js → DocsPager.B9VhI6E3.js} +1 -1
  13. package/dist/_astro/{DrawerField.C0ehOlDt.js → DrawerField.C0MkN-LW.js} +1 -1
  14. package/dist/_astro/{KnowledgeLibrary.B_99kzox.js → KnowledgeLibrary.D9KnqXzr.js} +1 -1
  15. package/dist/_astro/{PluginsPage.aQKIWMKz.js → PluginsPage.DBRfSxtq.js} +2 -2
  16. package/dist/_astro/PluginsPage.DMDyUktn.js +1 -0
  17. package/dist/_astro/PmBugsBoard.BnnaNP1y.js +1 -0
  18. package/dist/_astro/PmIterationsBoard.phiyhQVA.js +1 -0
  19. package/dist/_astro/{PmProjectDetail.BYVt43oh.js → PmProjectDetail.C8kRX5lu.js} +1 -1
  20. package/dist/_astro/{PmProjectsBoard.D06_aCFK.js → PmProjectsBoard.CFApEGPo.js} +1 -1
  21. package/dist/_astro/PmRequirementsBoard.B-AI9iZX.js +1 -0
  22. package/dist/_astro/PmRequirementsBoard.DR9egcgA.js +1 -0
  23. package/dist/_astro/PmShared.BrBicDMN.js +1 -0
  24. package/dist/_astro/PromptMountDialog.CpTT6L0a.js +62 -0
  25. package/dist/_astro/PromptsLibrary.sz6MivVn.js +1 -0
  26. package/dist/_astro/{ReportsPage.DOW1fswe.js → ReportsPage.CYZtpeiv.js} +1 -1
  27. package/dist/_astro/ReqAnalysisBoard.CazI9SU-.js +29 -0
  28. package/dist/_astro/RequirementsLibrary.R4dNZa9y.js +1 -0
  29. package/dist/_astro/SearchableSelect.Cbb8jMnP.js +1 -0
  30. package/dist/_astro/SelectDropdown.apWlFGbA.js +1 -0
  31. package/dist/_astro/{SettingsDialog.BBYaIU0N.js → SettingsDialog.Bs1I8b27.js} +1 -1
  32. package/dist/_astro/{SpaceSwitcher.DyzMNGfy.js → SpaceSwitcher.Dw9LjKiJ.js} +1 -1
  33. package/dist/_astro/{TagSelect.CuN5RdF4.js → TagSelect.B9W63KWq.js} +1 -1
  34. package/dist/_astro/{TasksBoard.BODqpiYV.js → TasksBoard.D0HwS5hd.js} +1 -1
  35. package/dist/_astro/{TemplatesLibrary.DDJLVEZk.js → TemplatesLibrary.CVv5Ef30.js} +1 -1
  36. package/dist/_astro/{TestStatsBoard.diX5s3sH.js → TestStatsBoard._qNcNorG.js} +1 -1
  37. package/dist/_astro/TodosBoard.CF5wbJy7.js +1 -0
  38. package/dist/_astro/UiAutoBoard.B-7mL3ez.js +9 -0
  39. package/dist/_astro/app-version.yT2l6J8H.js +1 -0
  40. package/dist/_astro/case-fields.h0roo2br.js +1 -0
  41. package/dist/_astro/case-gen-run.D8DGX0mr.js +19 -0
  42. package/dist/_astro/{case-review._K-6xl4v.js → case-review.C1hQRbQ2.js} +3 -3
  43. package/dist/_astro/case-template.F1Nv08GV.js +5 -0
  44. package/dist/_astro/docs-format.BlGh-XA_.js +1 -0
  45. package/dist/_astro/{llm.BZEzE0x2.js → llm.BuR7z55C.js} +1 -1
  46. package/dist/_astro/pm.pMOkNqqK.js +4 -0
  47. package/dist/_astro/req-analysis.dhgy4p2f.js +14 -0
  48. package/dist/_astro/{story-review.DvCTzGfr.js → story-review.BbdIf5zg.js} +5 -5
  49. package/dist/case-exec/index.html +5 -5
  50. package/dist/cases/generate/index.html +5 -5
  51. package/dist/cases/library/index.html +5 -5
  52. package/dist/dashboard/index.html +5 -5
  53. package/dist/docs/changelog/index.html +41 -5
  54. package/dist/docs/install/index.html +4 -4
  55. package/dist/docs/manual/index.html +17 -16
  56. package/dist/index.html +2 -2
  57. package/dist/knowledge/index.html +5 -5
  58. package/dist/plugins/index.html +5 -5
  59. package/dist/pm/bugs/index.html +5 -5
  60. package/dist/pm/iterations/index.html +5 -5
  61. package/dist/pm/projects/detail/index.html +5 -5
  62. package/dist/pm/projects/index.html +5 -5
  63. package/dist/pm/requirements/index.html +5 -5
  64. package/dist/prompts/index.html +5 -5
  65. package/dist/reports/index.html +5 -5
  66. package/dist/requirement-analysis/index.html +5 -5
  67. package/dist/requirements/index.html +5 -5
  68. package/dist/tasks/index.html +5 -5
  69. package/dist/templates/index.html +5 -5
  70. package/dist/test-automation/index.html +5 -5
  71. package/dist/test-stats/index.html +5 -5
  72. package/dist/todos/index.html +5 -5
  73. package/dist/workbench/index.html +5 -5
  74. package/docs//346/223/215/344/275/234/346/211/213/345/206/214.md +13 -12
  75. package/lh-plugins/case-backup-ttl.mjs +34 -0
  76. package/lh-plugins/lh-case-review.mjs +74 -2
  77. package/lh-plugins/lh-reports.mjs +6 -5
  78. package/lh-plugins/lh-req-analysis.mjs +41 -5
  79. package/package.json +1 -1
  80. package/dist/_astro/Base.NUwtco4a.css +0 -1
  81. package/dist/_astro/Base.astro_astro_type_script_index_0_lang.2J3Qrd4B.js +0 -1
  82. package/dist/_astro/CaseGenerateApp.CpL1po9n.js +0 -9
  83. package/dist/_astro/CasesLibrary.DAZMRzzt.js +0 -19
  84. package/dist/_astro/ChatApp.iDy6-iVA.js +0 -212
  85. package/dist/_astro/DocsFileBrowser.-dkkxR4X.js +0 -1
  86. package/dist/_astro/PluginsPage.B349vNQ7.js +0 -1
  87. package/dist/_astro/PmBugsBoard.Catlw5fm.js +0 -1
  88. package/dist/_astro/PmIterationsBoard.D4Bg969F.js +0 -1
  89. package/dist/_astro/PmRequirementsBoard.CyW9CfFH.js +0 -1
  90. package/dist/_astro/PmRequirementsBoard.DuXUq0HB.js +0 -1
  91. package/dist/_astro/PmShared.CwcLNMW2.js +0 -1
  92. package/dist/_astro/PromptMountDialog.YH2odDZx.js +0 -58
  93. package/dist/_astro/PromptsLibrary.dMO4dOAT.js +0 -1
  94. package/dist/_astro/ReqAnalysisBoard.DQpPjNNr.js +0 -29
  95. package/dist/_astro/RequirementsLibrary.Dd2DRKxL.js +0 -1
  96. package/dist/_astro/SearchableSelect.DZb-mxqw.js +0 -1
  97. package/dist/_astro/SelectDropdown.Cb-QtC-D.js +0 -1
  98. package/dist/_astro/TodosBoard.DQBEeiWU.js +0 -1
  99. package/dist/_astro/UiAutoBoard.3Xs5RjDq.js +0 -9
  100. package/dist/_astro/app-version.BqfBCSsN.js +0 -1
  101. package/dist/_astro/case-fields.CtFiDM_d.js +0 -1
  102. package/dist/_astro/case-gen-run.BI_ld4oo.js +0 -16
  103. package/dist/_astro/case-template.BGCVpSKI.js +0 -5
  104. package/dist/_astro/index.astro_astro_type_script_index_0_lang.DMnFoepS.js +0 -1
  105. package/dist/_astro/pm.CagBA-ht.js +0 -4
  106. package/dist/_astro/req-analysis.Dkbi-5A_.js +0 -9
@@ -1,29 +0,0 @@
1
- import{s as e,t}from"./react.Blvh0GOs.js";import{i as n}from"./app-config.CF1xVPmo.js";import{s as r}from"./plugins.CVM1IaoC.js";import{a as i,i as a,n as o,o as s,r as c,t as l}from"./view-prefs.D1snIG5o.js";import{t as u}from"./jsx-runtime.DUg_B_vD.js";import{t as d}from"./ConfirmDialog.CsMwWevK.js";import{t as f}from"./OverflowHint.pvo2Xc8R.js";import{t as p}from"./SelectDropdown.Cb-QtC-D.js";import{showToast as m}from"./Toast.BO2NFckG.js";import{o as h}from"./project-docs.DAw9bzgk.js";import{s as ee}from"./llm.BZEzE0x2.js";import{f as te,l as ne,p as g}from"./settings.B1yetppp.js";import{C as _,D as re,O as ie,S as ae,T as oe,_ as se,a as ce,b as le,c as ue,d as de,f as fe,g as pe,h as v,i as me,k as y,l as he,m as ge,n as _e,o as b,p as ve,r as ye,s as be,t as x,u as xe,v as Se,w as Ce,x as we,y as Te}from"./req-analysis.Dkbi-5A_.js";import{a as S,c as Ee,d as De,f as Oe,g as ke,h as Ae,i as je,l as Me,m as Ne,n as Pe,o as Fe,p as Ie,r as Le,s as Re,u as ze,v as Be}from"./story-review.DvCTzGfr.js";import{t as Ve}from"./hydrate-cache.CmC22o_H.js";import{O as He,S as C,_ as Ue,g as We,m as w,u as Ge}from"./PmShared.CwcLNMW2.js";var T=e(t(),1),Ke=`可用工具(只调用这些,不要自己编工具名):
2
- - req_set_outline:提交本批「需求条目」,返回每个条目的 id。
3
- - req_set_stories:提交「用户故事」;补写时提交合并后的完整故事集(带原 id 原地更新)。
4
- - req_save_check:提交体检结果(缺口清单 + 结论)。
5
- - req_save_test_points:提交测试点(功能 / 边界值 / 异常 / 业务规则 / 非功能五维,P0–P3)。
6
-
7
- 提交后不要重复提交同样的内容;工具返回 ok 之后再写最终回答。`,E=[`missing-scenario`,`missing-dimension`,`untestable-acceptance`,`conflict`,`over-split`,`other`];function qe(e){try{let t=JSON.parse(e||`{}`);return t&&typeof t==`object`?t:{}}catch{return{}}}function D(e,t=500){return typeof e==`string`?e.trim().slice(0,t):``}function Je(e){return String(e??``).toLowerCase().replace(/[\s\p{P}\p{S}]+/gu,``)}function O(e){let t=D(e,10);return t===`high`||t===`medium`||t===`low`?t:`medium`}function Ye(e){let t=D(e,40);return E.includes(t)?t:`other`}var k=[`functional`,`boundary`,`exception`,`business`,`nonfunctional`];function Xe(e){let t=D(e,40);if(k.includes(t))return t;let n=D(e,20);return k.find(e=>Re[e]===n)??`functional`}function A(e){let t=D(e,4).toUpperCase();return ze.includes(t)?t:`P1`}function Ze(e,t){if(!e||typeof e!=`object`)return null;let n=e,r=D(n.title,200);if(!r)return null;let i=D(n.storyId,20);return{id:``,storyId:t.has(i)?i:``,dimension:Xe(n.dimension),priority:A(n.priority),title:r,precondition:D(n.precondition,1e3),steps:Array.isArray(n.steps)?n.steps.map(e=>D(e,500)).filter(Boolean).slice(0,20):[],expected:D(n.expected,1e3)}}var Qe=[{type:`function`,function:{name:`req_set_outline`,description:`提交本批从原始需求里抽出的需求条目(一条 = 一个可独立验收的能力点)。返回每个条目的 id,供 sourceRefs 引用。`,parameters:{type:`object`,properties:{items:{type:`array`,items:{type:`object`,properties:{title:{type:`string`,description:`一句话概括`},quote:{type:`string`,description:`原文关键句,不超过 80 字`}},required:[`title`]}}},required:[`items`]}}},{type:`function`,function:{name:`req_set_stories`,description:`提交用户故事。拆解时只提交这一批新故事;补写时提交合并后的完整故事集(带原 id 的原地更新,新故事不带 id)。`,parameters:{type:`object`,properties:{stories:{type:`array`,items:{type:`object`,properties:{id:{type:`string`,description:`已有故事才带(US-001 这种)`},title:{type:`string`,description:`一句话说明这条故事做什么`},role:{type:`string`,description:`角色(来自原文;推断的要在 value 里注明)`},goal:{type:`string`,description:`用户想达成的目标`},value:{type:`string`,description:`业务价值 / 补充说明(角色为推断时写在这里)`},sourceRefs:{type:`array`,items:{type:`string`},description:`对应的需求条目 id(req_set_outline 返回的真实 id)`},priority:{type:`string`,enum:[`P0`,`P1`,`P2`]},preconditions:{type:`array`,items:{type:`string`}},mainFlow:{type:`array`,items:{type:`object`,properties:{actor:{type:`string`},action:{type:`string`,description:`动词开头的一步`},result:{type:`string`,description:`用户能看到的变化`}},required:[`action`]}},altFlows:{type:`array`,items:{type:`object`,properties:{name:{type:`string`},trigger:{type:`string`,description:`什么情况下走这条替代路径`},steps:{type:`array`,items:{type:`string`}}},required:[`name`,`trigger`]}},exceptions:{type:`array`,items:{type:`object`,properties:{scenario:{type:`string`,description:`异常场景`},expected:{type:`string`,description:`系统应有的表现`}},required:[`scenario`,`expected`]}},postconditions:{type:`array`,items:{type:`string`}},acceptance:{type:`array`,items:{type:`object`,properties:{given:{type:`string`},when:{type:`string`},then:{type:`string`,description:`必须可判定`}},required:[`given`,`when`,`then`]}},dimensions:{type:`array`,items:{type:`string`},description:`权限 / 边界值 / 并发与幂等 / 空数据 / 超时与失败 / 国际化与时区`}},required:[`title`,`role`,`mainFlow`,`acceptance`]}}},required:[`stories`]}}},{type:`function`,function:{name:`req_save_check`,description:`提交需求体检结果:语义类缺口清单 + 两三句话结论。只出问题,不改写故事。`,parameters:{type:`object`,properties:{summary:{type:`string`,description:`整体结论,两三句话`},gaps:{type:`array`,items:{type:`object`,properties:{storyTitle:{type:`string`,description:`相关故事标题;全局问题填空串`},type:{type:`string`,enum:E},severity:{type:`string`,enum:[`high`,`medium`,`low`]},title:{type:`string`},detail:{type:`string`,description:`位置 + 原因`},suggestion:{type:`string`,description:`建议补写什么`}},required:[`title`,`detail`]}}},required:[`gaps`]}}},{type:`function`,function:{name:`req_save_test_points`,description:`提交基于用户故事拆出的测试点:功能 / 边界值 / 异常 / 业务规则 / 非功能五个维度全覆盖,每条标 P0–P3。一次提交全部,不要分多次。`,parameters:{type:`object`,properties:{summary:{type:`string`,description:`整体结论:几条、五维覆盖情况、最该先测什么`},points:{type:`array`,items:{type:`object`,properties:{storyId:{type:`string`,description:`对应故事 id(US-001 这种);全局测试点填空串`},dimension:{type:`string`,enum:k,description:`functional 功能 / boundary 边界值 / exception 异常 / business 业务规则 / nonfunctional 非功能`},priority:{type:`string`,enum:ze},title:{type:`string`,description:`一句话说清测什么(动词开头,带条件)`},precondition:{type:`string`,description:`执行前需要的数据 / 角色 / 状态`},steps:{type:`array`,items:{type:`string`},description:`可执行步骤,一步一个动作`},expected:{type:`string`,description:`可判定的预期结果,有阈值写具体数值`}},required:[`dimension`,`priority`,`title`]}}},required:[`points`]}}}];async function $e(e,t,n){let r=qe(t),i=n.getDoc();if(!i)return JSON.stringify({ok:!1,error:`当前还没有打开分析文档`});if(e===`req_set_outline`){let e=Array.isArray(r.items)?r.items:[];if(!e.length)return JSON.stringify({ok:!0,added:0,total:i.outline.length,items:i.outline.map(({id:e,title:t})=>({id:e,title:t})),note:`没有提交新条目,需求条目保持不变。`});let t=i.outline,a=new Set(t.map(e=>Je(e.title))),o=new Set(t.map(e=>e.id)),s=[];for(let t of e){let e=t&&typeof t==`object`?t:{},r=D(e.title,200)||D(e.quote,200);if(!r||a.has(Je(r)))continue;a.add(Je(r));let i=`RO-${n.batch+1}-${s.length+1}`,c=i,l=1;for(;o.has(c);)c=`${i}-${l++}`;o.add(c),s.push({id:c,title:r,quote:D(e.quote,500)})}let c=[...t,...s],l=await n.saveOutline(c);return JSON.stringify({ok:!0,added:s.length,total:l.length,items:l.map(({id:e,title:t})=>({id:e,title:t})),note:s.length>0?`条目已保存。接下来用 req_set_stories 提交故事,sourceRefs 只能引用上面返回的 id。`:`这些条目已经存在,没有重复写入;继续提交故事即可。`})}if(e===`req_set_stories`){let e=Array.isArray(r.stories)?r.stories:[];if(!e.length)return JSON.stringify({ok:!0,added:0,total:i.stories.length,note:`没有提交故事,故事集保持不变。`});let t=i.stories.length,a=Te(i.stories,e),o=await n.saveStories(a),s=new Set(i.outline.map(e=>e.id)),c=o.stories.flatMap(e=>e.sourceRefs).filter(e=>!s.has(e));return JSON.stringify({ok:!0,added:Math.max(0,o.stories.length-t),total:o.stories.length,stories:o.stories.map(({id:e,title:t,priority:n})=>({id:e,title:t,priority:n})),danglingSourceRefs:Array.from(new Set(c)).slice(0,10),note:c.length>0?`有些 sourceRefs 不在需求条目里,覆盖率会算不到;需要的话用真实条目 id 修正。`:`故事已保存。`})}if(e===`req_save_check`){let e=ue(i),t=new Map(i.stories.filter(e=>e.title).map(e=>[Je(e.title),e.id])),a=new Set(i.stories.map(e=>e.id)),o=Array.isArray(r.gaps)?r.gaps:[],s=[];for(let e of o){let n=e&&typeof e==`object`?e:{},r=D(n.title,200);if(!r)continue;let i=D(n.storyId,20),o=a.has(i)&&i||t.get(Je(D(n.storyTitle,200)))||``,c=Ye(n.type);s.push({id:v(c,o,r),storyId:o,type:c,severity:O(n.severity),title:r,detail:D(n.detail,1e3),suggestion:D(n.suggestion,1e3),origin:`model`,selected:!1})}let c=Se(e.gaps,s),l=D(r.summary,1500)||e.summary;return await n.saveCheck({...e,summary:l,gaps:c}),JSON.stringify({ok:!0,gaps:c.length,high:c.filter(e=>e.severity===`high`).length,coverage:e.coverage,dimensions:e.dimensions.map(e=>({label:e.label,covered:e.covered})),note:`体检报告已保存:整体 ${c.length} 个缺口(高 ${c.filter(e=>e.severity===`high`).length} 个),覆盖率 ${Math.round(e.coverage.rate*100)}%。用户可以在页面上勾选缺口补写。`})}if(e===`req_save_test_points`){let e=Array.isArray(r.points)?r.points:[];if(!e.length)return JSON.stringify({ok:!0,total:i.testPoints?.points.length??0,note:`没有提交测试点,原结果保持不变。`});if(typeof n.saveTestPoints!=`function`)return JSON.stringify({ok:!1,error:`当前上下文不支持保存测试点`});let t=new Set(i.stories.map(e=>e.id)),a=e.slice(0,500).map(e=>Ze(e,t)).filter(e=>e!==null);if(!a.length)return JSON.stringify({ok:!1,error:`测试点都缺少标题,没有保存`});let o=(await n.saveTestPoints({at:new Date().toISOString(),summary:D(r.summary,2e3),points:a})).testPoints?.points??a,s=k.map(e=>({dimension:Re[e],count:o.filter(t=>t.dimension===e).length})),c=ze.map(e=>({priority:e,count:o.filter(t=>t.priority===e).length})),l=s.filter(e=>e.count===0).map(e=>e.dimension);return JSON.stringify({ok:!0,total:o.length,byDimension:s,byPriority:c,uncoveredDimensions:l,note:l.length>0?`测试点已保存:整体 ${o.length} 条。${l.join(`、`)}还没有测试点,如确实不适用请在回答里说明。`:`测试点已保存:整体 ${o.length} 条,五个维度都有覆盖。`})}return JSON.stringify({ok:!1,error:`未知工具:${e}`})}function j(e){let t=[],n=/```json\s*([\s\S]*?)```/gi,r;for(;(r=n.exec(e))!==null;)r[1]?.trim()&&t.push(r[1].trim());return t}function et(e){let t=j(String(e??``));for(let e of t)try{let t=JSON.parse(e),n=Array.isArray(t)?t:t&&typeof t==`object`&&Array.isArray(t.stories)?t.stories:null;if(!n?.length)continue;let r=n.filter(e=>!!(e&&typeof e==`object`&&typeof e.title==`string`));if(r.length)return r}catch{}return[]}function tt(e,t=[]){let n=new Set(t),r=j(String(e??``));for(let e of r)try{let t=JSON.parse(e),r=Array.isArray(t)?t:t&&typeof t==`object`&&Array.isArray(t.points)?t.points:null;if(!r?.length)continue;let i=r.map(e=>Ze(e,n)).filter(e=>e!==null);if(!i.length)continue;let a=t&&typeof t==`object`&&!Array.isArray(t)?D(t.summary,2e3):``;return{at:new Date().toISOString(),summary:a,points:i}}catch{}return null}var M=u(),N=`text-xs font-semibold tracking-wide text-stone-500`,nt=`inline-flex h-7 items-center justify-center rounded-md bg-[#3370ff] px-2.5 text-xs font-medium text-white transition-opacity hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-50`,P=`inline-flex h-7 items-center justify-center rounded-md border border-stone-200 bg-white px-2 text-xs text-stone-600 transition-colors hover:bg-stone-50 disabled:cursor-not-allowed disabled:opacity-50`;function rt({check:e,stories:t,busy:n,onToggleGap:r,onToggleAll:i,onFix:a,onReview:o,onExport:s}){if(!e)return(0,M.jsxs)(`div`,{className:`flex flex-col items-center justify-center rounded-xl border border-dashed border-stone-200 px-4 py-16 text-center`,children:[(0,M.jsx)(`p`,{className:`text-sm font-medium text-stone-600`,children:`还没有审查结果`}),(0,M.jsx)(`p`,{className:`mt-1 max-w-md text-xs leading-relaxed text-stone-400`,children:`审查会先用固定规则核对覆盖率与字段完整性,再让模型专查场景遗漏与维度缺失(替代流程不成立、验收不可测也会一并报)。`}),(0,M.jsx)(`button`,{type:`button`,className:`mt-4 h-9 rounded-md bg-[#3370ff] px-4 text-sm font-medium text-white transition-opacity hover:opacity-90 disabled:opacity-50`,disabled:n||!t.length,onClick:o,children:`开始审查`})]});let c=S(e.gaps),l=e.gaps.filter(e=>e.selected).length,u=e.coverage.total?Math.round(e.coverage.rate*100):0,d=Pe(e.gaps),p=new Map(t.map(e=>[e.id,e.title]));return(0,M.jsxs)(`div`,{className:`space-y-4`,children:[(0,M.jsxs)(`div`,{className:`rounded-xl border border-stone-200 bg-white px-4 py-3`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-6 gap-y-2`,children:[(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`p`,{className:N,children:`需求条目覆盖率`}),(0,M.jsxs)(`p`,{className:`mt-0.5 text-lg font-semibold text-stone-800`,children:[e.coverage.covered,(0,M.jsxs)(`span`,{className:`text-sm font-normal text-stone-400`,children:[` / `,e.coverage.total]}),(0,M.jsxs)(`span`,{className:`ml-2 text-sm font-normal text-stone-500`,children:[u,`%`]})]})]}),(0,M.jsxs)(`div`,{className:`min-w-[160px] flex-1`,children:[(0,M.jsx)(`div`,{className:`h-2 overflow-hidden rounded-full bg-stone-100`,children:(0,M.jsx)(`div`,{className:`h-full rounded-full transition-all ${u>=90?`bg-emerald-500`:u>=60?`bg-amber-500`:`bg-red-500`}`,style:{width:`${Math.max(u,e.coverage.total?2:0)}%`}})}),(0,M.jsx)(`p`,{className:`mt-1 text-[11px] text-stone-400`,children:e.coverage.total?`有故事引用的条目算覆盖;sourceRefs 为空的故事不会计入`:`还没有需求条目,先回「需求分析」做一次拆解`})]}),(0,M.jsxs)(`div`,{className:`text-right`,children:[(0,M.jsx)(`p`,{className:N,children:`缺口`}),(0,M.jsxs)(`p`,{className:`mt-0.5 text-lg font-semibold text-stone-800`,children:[e.gaps.length,(0,M.jsxs)(`span`,{className:`ml-1.5 text-xs font-normal text-stone-400`,children:[`高 `,d.high,` · 中 `,d.medium,` · 低 `,d.low]})]})]})]}),e.summary?(0,M.jsx)(`p`,{className:`mt-3 border-t border-stone-100 pt-2 text-xs leading-relaxed text-stone-500`,children:e.summary}):null]}),(0,M.jsxs)(`div`,{className:`rounded-xl border border-stone-200 bg-white px-4 py-3`,children:[(0,M.jsx)(`p`,{className:N,children:`维度覆盖`}),(0,M.jsx)(`div`,{className:`mt-2 grid gap-1.5 sm:grid-cols-2 lg:grid-cols-3`,children:e.dimensions.map(e=>{let t=e.stories.join(`, `);return(0,M.jsxs)(`div`,{"data-hint-width":!0,className:`min-w-0 rounded-lg border px-2.5 py-1.5 text-xs ${e.covered?`border-emerald-200 bg-emerald-50/60`:`border-stone-200 bg-stone-50`}`,children:[(0,M.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,M.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0 ${e.covered?`text-emerald-600`:`text-stone-400`}`,children:e.covered?`✓`:`—`}),(0,M.jsx)(`span`,{className:`shrink-0 whitespace-nowrap font-medium ${e.covered?`text-emerald-800`:`text-stone-500`}`,children:e.label}),(0,M.jsx)(`span`,{className:`ml-auto shrink-0 text-[11px] tabular-nums text-stone-400`,children:e.stories.length?`${e.stories.length} 条`:`未覆盖`})]}),(0,M.jsx)(`div`,{className:`mt-0.5 min-w-0 pl-[18px]`,children:t?(0,M.jsx)(f,{text:t,matchAnchorWidth:!0,className:`block truncate text-[11px] text-stone-400`}):(0,M.jsx)(`span`,{className:`text-[11px] text-stone-300`,children:`没有故事覆盖`})})]},e.key)})})]}),(0,M.jsxs)(`div`,{className:`rounded-xl border border-stone-200 bg-white`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 border-b border-stone-100 px-4 py-2.5`,children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,M.jsx)(`p`,{className:`text-sm font-medium text-stone-700`,children:`缺口清单`}),(0,M.jsxs)(`span`,{className:`text-xs text-stone-400`,children:[`已选 `,l,` 条`]})]}),(0,M.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,M.jsx)(`button`,{type:`button`,className:P,onClick:s,children:`导出 Markdown`}),(0,M.jsx)(`button`,{type:`button`,className:P,onClick:()=>i(l!==e.gaps.length),children:l===e.gaps.length&&e.gaps.length?`清空选择`:`全选`}),(0,M.jsx)(`button`,{type:`button`,className:nt,disabled:n||!l,onClick:a,children:`补写选中缺口`})]})]}),c.length?(0,M.jsx)(`div`,{className:`divide-y divide-stone-100`,children:c.map(e=>(0,M.jsxs)(`section`,{children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-2 bg-stone-50/60 px-4 py-1.5`,children:[(0,M.jsx)(`p`,{className:`text-xs font-semibold text-stone-600`,children:e.label}),(0,M.jsx)(`span`,{className:`rounded bg-white px-1.5 py-0.5 text-[11px] text-stone-500`,children:e.gaps.length}),(0,M.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:e.hint})]}),(0,M.jsx)(`ul`,{className:`divide-y divide-stone-100`,children:e.gaps.map(e=>(0,M.jsx)(it,{gap:e,storyTitle:p.get(e.storyId)??``,onToggle:r},e.id))})]},e.key))}):(0,M.jsx)(`p`,{className:`px-4 py-10 text-center text-sm text-stone-400`,children:`没有发现缺口。覆盖率与维度都过了,可以再人工过一遍验收标准。`})]})]})}function it({gap:e,storyTitle:t,onToggle:n}){return(0,M.jsxs)(`li`,{className:`flex items-start gap-2.5 px-4 py-2.5`,children:[(0,M.jsx)(`input`,{type:`checkbox`,className:`mt-1 h-3.5 w-3.5 shrink-0 accent-[#3370ff]`,checked:e.selected,onChange:t=>n(e.id,t.target.checked)}),(0,M.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,M.jsx)(C,{tone:_e[e.severity],children:x[e.severity]}),(0,M.jsx)(`span`,{className:`rounded bg-stone-100 px-1.5 py-0.5 text-[11px] text-stone-500`,children:ye[e.type]}),e.storyId?(0,M.jsxs)(`span`,{className:`font-mono text-[11px] text-stone-400`,children:[e.storyId,t?` · ${t}`:``]}):(0,M.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:`全局`}),(0,M.jsx)(`span`,{className:`text-[11px] text-stone-300`,children:e.origin===`model`?`模型`:`规则`})]}),(0,M.jsx)(`p`,{className:`mt-0.5 text-sm text-stone-800`,children:e.title}),e.detail?(0,M.jsx)(`p`,{className:`mt-0.5 text-xs leading-relaxed text-stone-500`,children:e.detail}):null,e.suggestion?(0,M.jsxs)(`p`,{className:`mt-0.5 text-xs leading-relaxed text-amber-700`,children:[`建议:`,e.suggestion]}):null]})]})}var at=`reqanalysis.testPointsView`,ot=[`map`,`list`],F=`inline-flex h-7 items-center justify-center rounded-md border border-stone-200 bg-white px-2 text-xs text-stone-600 transition-colors hover:bg-stone-50 disabled:cursor-not-allowed disabled:opacity-50`;function st({point:e}){return(0,M.jsxs)(`div`,{className:`space-y-1 text-[11px] leading-relaxed text-stone-500`,children:[e.precondition?(0,M.jsxs)(`p`,{children:[(0,M.jsx)(`span`,{className:`text-stone-400`,children:`前置:`}),e.precondition]}):null,e.steps.length?(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`p`,{className:`text-stone-400`,children:`步骤:`}),(0,M.jsx)(`ol`,{className:`mt-0.5 list-decimal space-y-0.5 pl-4`,children:e.steps.map((e,t)=>(0,M.jsx)(`li`,{children:e},t))})]}):null,e.expected?(0,M.jsxs)(`p`,{children:[(0,M.jsx)(`span`,{className:`text-stone-400`,children:`预期:`}),e.expected]}):null]})}function I({req:e}){return(0,M.jsxs)(`div`,{className:`flex items-stretch gap-0`,children:[(0,M.jsxs)(`div`,{className:`flex w-36 shrink-0 flex-col justify-center rounded-l-xl border border-r-0 border-[#c9d8ff] bg-[#f5f8ff] px-3 py-3`,children:[(0,M.jsx)(`p`,{className:`text-[11px] text-[#5b7fd6]`,children:`需求`}),(0,M.jsx)(`p`,{className:`text-sm font-semibold leading-snug text-stone-800`,children:e.title}),(0,M.jsxs)(`p`,{className:`mt-1 text-[11px] tabular-nums text-stone-400`,children:[e.points.length,` 条`]})]}),(0,M.jsx)(`div`,{className:`flex min-w-0 flex-1 overflow-hidden rounded-r-xl border border-stone-200 bg-white`,children:e.dimensions.map((e,t)=>{let n=Ee[e.key];return(0,M.jsxs)(`div`,{className:`flex w-[9.5rem] shrink-0 flex-col ${t>0?`border-l border-stone-100`:``}`,children:[(0,M.jsxs)(`div`,{className:`flex items-center justify-between gap-1 border-b border-stone-100 px-2 py-1.5`,children:[(0,M.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,M.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full ${n.accent}`,"aria-hidden":`true`}),(0,M.jsx)(`span`,{className:`truncate text-[11px] font-medium text-stone-700`,children:n.label})]}),(0,M.jsx)(`span`,{className:`shrink-0 text-[10px] tabular-nums text-stone-400`,children:e.points.length})]}),(0,M.jsx)(`div`,{className:`max-h-52 space-y-1.5 overflow-y-auto px-1.5 py-1.5`,children:e.points.length?e.points.map(e=>(0,M.jsx)(`div`,{className:`rounded-lg border border-stone-100 bg-stone-50/70 px-1.5 py-1`,children:(0,M.jsxs)(`div`,{className:`flex items-start gap-1`,children:[(0,M.jsx)(C,{tone:Me[e.priority].tone,children:e.priority}),(0,M.jsx)(`p`,{className:`min-w-0 flex-1 break-words text-[11px] leading-snug text-stone-700`,children:e.title})]})},e.id)):(0,M.jsx)(`p`,{className:`py-3 text-center text-[11px] text-stone-300`,children:`无`})})]},e.key)})})]})}function L({doc:e,idealTitles:t}){let n=(0,T.useMemo)(()=>ke(e,t),[e,t]);return(0,M.jsxs)(`div`,{className:`space-y-3`,children:[(0,M.jsx)(`div`,{className:`overflow-x-auto pb-1`,children:(0,M.jsx)(`div`,{className:`min-w-[62rem] space-y-3`,children:n.length?n.map(e=>(0,M.jsx)(I,{req:e},e.key)):(0,M.jsx)(`p`,{className:`py-8 text-center text-xs text-stone-400`,children:`还没有测试点。`})})}),(0,M.jsx)(`p`,{className:`text-center text-[11px] text-stone-400`,children:`每条需求横向展开五个维度;列过窄时整行左右滑动。导出 XMind 为同结构的向右逻辑图。`})]})}function R({doc:e,idealTitles:t}){let n=(0,T.useMemo)(()=>ke(e,t),[e,t]);return(0,M.jsx)(`div`,{className:`space-y-3`,children:n.map(e=>(0,M.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,M.jsxs)(`div`,{className:`border-b border-stone-100 bg-[#f8fafc] px-3.5 py-2.5`,children:[(0,M.jsx)(`p`,{className:`text-[11px] text-stone-400`,children:`需求`}),(0,M.jsx)(`p`,{className:`text-sm font-semibold text-stone-800`,children:e.title}),(0,M.jsxs)(`p`,{className:`mt-0.5 text-[11px] text-stone-400`,children:[e.points.length,` 条`]})]}),(0,M.jsx)(`div`,{className:`divide-y divide-stone-100`,children:e.dimensions.map(e=>(0,M.jsxs)(`div`,{children:[(0,M.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3.5 py-2`,children:[(0,M.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,M.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full ${Ee[e.key].accent}`,"aria-hidden":`true`}),(0,M.jsx)(`span`,{className:`text-xs font-medium text-stone-700`,children:e.label}),(0,M.jsx)(`span`,{className:`min-w-0 truncate text-[11px] text-stone-400`,children:e.hint})]}),(0,M.jsx)(`span`,{className:`shrink-0 text-[11px] tabular-nums text-stone-400`,children:e.points.length})]}),e.points.length?(0,M.jsx)(`ul`,{className:`border-t border-stone-50`,children:e.points.map(e=>(0,M.jsx)(`li`,{className:`border-t border-stone-50 first:border-t-0`,children:(0,M.jsxs)(`details`,{className:`group px-3.5 py-2 pl-8`,children:[(0,M.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-start gap-2`,children:[(0,M.jsx)(`span`,{className:`mt-0.5 shrink-0`,children:(0,M.jsx)(C,{tone:Me[e.priority].tone,children:e.priority})}),(0,M.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,M.jsx)(`span`,{className:`block text-sm text-stone-800`,children:e.title}),(0,M.jsxs)(`span`,{className:`mt-0.5 flex items-center gap-1.5 text-[11px] text-stone-400`,children:[(0,M.jsxs)(`span`,{children:[e.steps.length,` 步`]}),e.expected?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`span`,{className:`text-stone-300`,children:`·`}),(0,M.jsx)(f,{text:e.expected,className:`min-w-0 flex-1 truncate`})]}):null]})]}),(0,M.jsx)(`span`,{className:`mt-0.5 shrink-0 text-[11px] text-stone-300 group-open:hidden`,children:`展开`}),(0,M.jsx)(`span`,{className:`mt-0.5 hidden shrink-0 text-[11px] text-stone-300 group-open:inline`,children:`收起`})]}),(0,M.jsx)(`div`,{className:`mt-1.5 border-l-2 border-stone-100 pl-2.5`,children:(0,M.jsx)(st,{point:e})})]})},e.id))}):(0,M.jsx)(`p`,{className:`px-3.5 py-2 pl-8 text-[11px] text-stone-300`,children:`本维度没有测试点。`})]},e.key))})]},e.key))})}function ct({doc:e,idealTitles:t=[],generating:n,busy:r,promptReady:a,onExportXmind:s,onExportMarkdown:c}){let[l,u]=(0,T.useState)(()=>o(at,ot,`map`)),d=e.testPoints,f=Oe(d),p=!!e.sourcePath&&t.length===0,m=(0,T.useMemo)(()=>p?0:ke(e,t).length,[e,t,p]),h=e=>{u(e),i(at,e)};if(!d){let t=e.stories.length?a?``:`「测试点生成提示词.md」还没就绪,重新打开插件会自动补齐`:`还没有用户故事,先做一次拆解`;return(0,M.jsxs)(`div`,{className:`flex flex-col items-center justify-center rounded-xl border border-dashed border-stone-200 px-4 py-16 text-center`,children:[(0,M.jsx)(`p`,{className:`text-sm font-medium text-stone-600`,children:`还没有测试点`}),(0,M.jsx)(`p`,{className:`mt-1 max-w-md text-xs leading-relaxed text-stone-400`,children:`按需求文档每一行整理标题,再按功能 / 边界值 / 异常 / 业务规则 / 非功能拆测试点;导图左右展开,可导出 XMind(向右逻辑图)与 Markdown。`}),t?(0,M.jsx)(`p`,{className:`mt-2 text-xs text-amber-700`,children:t}):null,(0,M.jsx)(`p`,{className:`mt-3 text-xs text-stone-400`,children:n?`正在生成测试点,完成后会自动出现在这里。`:`用左栏的「生成测试点」开始拆。`})]})}return(0,M.jsxs)(`div`,{className:`space-y-3`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2 rounded-xl border border-stone-200 bg-white px-3.5 py-2`,children:[(0,M.jsxs)(`span`,{className:`text-xs text-stone-500`,children:[`需求 `,(0,M.jsx)(`span`,{className:`font-medium text-stone-700`,children:m}),` · 测试点`,` `,(0,M.jsx)(`span`,{className:`font-medium text-stone-700`,children:f.total})]}),(0,M.jsx)(`span`,{className:`flex items-center gap-1`,children:ze.map(e=>(0,M.jsxs)(C,{tone:Me[e].tone,children:[e,` `,f.byPriority[e]]},e))}),(0,M.jsxs)(`span`,{className:`text-xs text-stone-400`,children:[`维度覆盖 `,f.coveredDimensions,`/5`]}),(0,M.jsxs)(`span`,{className:`ml-auto flex items-center gap-1.5`,children:[(0,M.jsx)(`span`,{className:`flex overflow-hidden rounded-md border border-stone-200`,children:[{id:`map`,label:`导图`},{id:`list`,label:`列表`}].map(e=>(0,M.jsx)(`button`,{type:`button`,className:`h-7 px-2.5 text-xs transition-colors ${l===e.id?`bg-[#eef3ff] font-medium text-[#1f4fd8]`:`bg-white text-stone-500 hover:bg-stone-50`}`,onClick:()=>h(e.id),children:e.label},e.id))}),(0,M.jsx)(`button`,{type:`button`,className:F,disabled:r,onClick:s,children:`导出 XMind`}),(0,M.jsx)(`button`,{type:`button`,className:F,disabled:r,onClick:c,children:`导出 Markdown`})]})]}),p?(0,M.jsxs)(`div`,{className:`flex items-center justify-center gap-2 rounded-xl border border-dashed border-stone-200 py-16 text-xs text-stone-400`,"aria-busy":`true`,children:[(0,M.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`}),`正在按需求文档行整理…`]}):l===`map`?(0,M.jsx)(L,{doc:e,idealTitles:t}):(0,M.jsx)(R,{doc:e,idealTitles:t}),d.summary?(0,M.jsxs)(`details`,{className:`rounded-xl border border-stone-200 bg-white px-3.5 py-2`,children:[(0,M.jsx)(`summary`,{className:`cursor-pointer text-xs font-medium text-stone-600`,children:`生成说明`}),(0,M.jsx)(`p`,{className:`mt-1.5 text-xs leading-relaxed whitespace-pre-wrap text-stone-500`,children:d.summary})]}):null]})}var lt=[{value:`P0`,label:`P0 · 必须做`},{value:`P1`,label:`P1 · 应该做`},{value:`P2`,label:`P2 · 可以做`}],ut=`h-9 w-full rounded-md border border-stone-200 bg-white px-2 text-sm text-stone-800 outline-none transition-colors focus:border-[#3370ff] placeholder:text-stone-400`,dt=`w-full resize-y rounded-md border border-stone-200 bg-white px-2 py-1.5 text-sm text-stone-800 outline-none transition-colors focus:border-[#3370ff] placeholder:text-stone-400`,z=`text-xs font-semibold tracking-wide text-stone-500`,ft=`text-[11px] font-medium tracking-wide text-stone-400`,pt={P0:`bg-red-400`,P1:`bg-amber-400`,P2:`bg-stone-300`};function B({label:e,children:t}){return(0,M.jsxs)(`div`,{className:`grid gap-1 sm:grid-cols-[88px_minmax(0,1fr)] sm:gap-3`,children:[(0,M.jsx)(`p`,{className:`${ft} pt-0.5`,children:e}),(0,M.jsx)(`div`,{className:`min-w-0 text-[13px] leading-relaxed text-stone-700`,children:t})]})}function V(e){return e.split(`
8
- `).map(e=>e.trim()).filter(Boolean)}function mt({label:e,value:t,placeholder:n,onChange:r}){return(0,M.jsxs)(`label`,{className:`block`,children:[(0,M.jsxs)(`span`,{className:z,children:[e,`(一行一条)`]}),(0,M.jsx)(`textarea`,{className:`${dt} mt-1 min-h-[64px]`,value:t.join(`
9
- `),placeholder:n,onChange:e=>r(V(e.target.value))})]})}function H({value:e,onChange:t}){return(0,M.jsxs)(`label`,{className:`block`,children:[(0,M.jsx)(`span`,{className:z,children:`主流程(一行一步:动作 -> 结果)`}),(0,M.jsx)(`textarea`,{className:`${dt} mt-1 min-h-[80px]`,value:e.map(e=>e.result?`${e.action} -> ${e.result}`:e.action).join(`
10
- `),placeholder:`填写申请单 -> 进入待审批`,onChange:e=>t(V(e.target.value).map(e=>{let t=e.indexOf(`->`)>=0?e.indexOf(`->`):e.indexOf(`→`);return t<0?{action:e}:{action:e.slice(0,t).trim(),result:e.slice(t+(e.startsWith(`->`,t)?2:1)).trim()}}))})]})}function ht({value:e,onChange:t}){let n=e.map(e=>[`${e.name} | ${e.trigger}`,...e.steps.map((e,t)=>`${t+1}. ${e}`)].join(`
11
- `)).join(`
12
-
13
- `);return(0,M.jsxs)(`label`,{className:`block`,children:[(0,M.jsx)(`span`,{className:z,children:`替代流程(空行分段:名称 | 触发条件,下面写步骤)`}),(0,M.jsx)(`textarea`,{className:`${dt} mt-1 min-h-[80px]`,value:n,placeholder:`转人工审批 | 金额超过 5 万
14
- 1. 提交后进入人工队列
15
- 2. 审批通过再继续`,onChange:e=>t(e.target.value.split(/\n{2,}/).map(e=>{let t=e.split(`
16
- `).map(e=>e.trim()).filter(Boolean),[n,r]=(t.shift()??``).split(`|`);return{name:(n??``).trim()||`替代流程`,trigger:(r??``).trim(),steps:t.map(e=>e.replace(/^\d+[.、)]\s*/,``))}}).filter(e=>e.name!==`替代流程`||e.steps.length||e.trigger))})]})}function gt({value:e,onChange:t}){return(0,M.jsxs)(`label`,{className:`block`,children:[(0,M.jsx)(`span`,{className:z,children:`异常场景(一行一条:场景 -> 预期)`}),(0,M.jsx)(`textarea`,{className:`${dt} mt-1 min-h-[80px]`,value:e.map(e=>e.expected?`${e.scenario} -> ${e.expected}`:e.scenario).join(`
17
- `),placeholder:`提交时网络中断 -> 提示重试并保留草稿`,onChange:e=>t(V(e.target.value).map(e=>{let t=e.indexOf(`->`)>=0?e.indexOf(`->`):e.indexOf(`→`);return t<0?{scenario:e,expected:``}:{scenario:e.slice(0,t).trim(),expected:e.slice(t+(e.startsWith(`->`,t)?2:1)).trim()}}))})]})}function _t({value:e,onChange:t}){return(0,M.jsxs)(`label`,{className:`block`,children:[(0,M.jsx)(`span`,{className:z,children:`验收标准(一行一条:Given | When | Then)`}),(0,M.jsx)(`textarea`,{className:`${dt} mt-1 min-h-[80px]`,value:e.map(e=>`${e.given} | ${e.when} | ${e.then}`).join(`
18
- `),placeholder:`已登录且有权限 | 提交申请单 | 列表里出现一条待审批记录`,onChange:e=>t(V(e.target.value).map(e=>{let[t=``,n=``,r=``]=e.split(`|`).map(e=>e.trim());return{given:t,when:n,then:r}}))})]})}function vt({story:e,index:t,total:n,gaps:r,busy:i,onSave:a,onDelete:o,onMove:s,domId:c}){let[l,u]=(0,T.useState)(!1),[d,f]=(0,T.useState)(!1),[m,h]=(0,T.useState)(e),[ee,te]=(0,T.useState)(!1);(0,T.useEffect)(()=>{if(l||d){te(!0);return}let e=window.setTimeout(()=>te(!1),200);return()=>window.clearTimeout(e)},[l,d]);let ne=()=>{h({...e}),f(!0),u(!0)},g=e=>h(t=>({...t,...e})),_=r.filter(e=>e.severity===`high`).length;return(0,M.jsxs)(`li`,{id:c,className:`overflow-hidden rounded-xl border bg-white transition-colors ${l||d?`border-stone-200 shadow-sm`:`border-stone-200 hover:border-stone-300`}`,children:[(0,M.jsxs)(`div`,{role:`button`,tabIndex:0,"aria-expanded":l,"aria-label":l?`收起 ${e.id}`:`展开 ${e.id}`,className:`flex cursor-pointer items-start gap-3 px-3.5 py-3 outline-none transition-colors hover:bg-stone-50/70 focus-visible:bg-stone-50/70`,onClick:()=>u(e=>!e),onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),u(e=>!e))},children:[(0,M.jsx)(`span`,{className:`mt-1 h-9 w-[3px] shrink-0 rounded-full ${pt[e.priority]}`,"aria-hidden":`true`}),(0,M.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,M.jsx)(`span`,{className:`rounded bg-stone-100 px-1.5 py-0.5 font-mono text-[11px] text-stone-500`,children:e.id||`待编号`}),(0,M.jsx)(C,{tone:b[e.priority],children:e.priority}),(0,M.jsx)(`span`,{className:`truncate text-sm font-medium text-stone-800`,children:e.title}),r.length>0?(0,M.jsxs)(C,{tone:_?`red`:`amber`,children:[r.length,` 个缺口`,_?` · 高 ${_}`:``]}):null]}),(0,M.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs text-stone-500`,children:[e.role&&`角色:${e.role}`,e.goal&&`目标:${e.goal}`].filter(Boolean).join(` · `)||`还没有写角色与目标`}),l?null:(0,M.jsxs)(`p`,{className:`mt-1 text-[11px] text-stone-400`,children:[`验收 `,e.acceptance.length,` · 异常 `,e.exceptions.length,` · 维度`,` `,e.dimensions.length]})]}),(0,M.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),children:[(0,M.jsx)(`button`,{type:`button`,className:`rounded p-1 text-stone-400 transition-colors hover:bg-stone-100 hover:text-stone-600 disabled:opacity-30`,"aria-label":`上移`,disabled:i||t===0,onClick:()=>s(-1),children:(0,M.jsx)(w,{name:`chevronRight`,size:14,className:`-rotate-90`})}),(0,M.jsx)(`button`,{type:`button`,className:`rounded p-1 text-stone-400 transition-colors hover:bg-stone-100 hover:text-stone-600 disabled:opacity-30`,"aria-label":`下移`,disabled:i||t>=n-1,onClick:()=>s(1),children:(0,M.jsx)(w,{name:`chevronRight`,size:14,className:`rotate-90`})}),(0,M.jsx)(`button`,{type:`button`,className:`rounded p-1 text-stone-400 transition-colors hover:bg-stone-100 hover:text-stone-600`,"aria-label":d?`取消编辑`:`编辑`,onClick:()=>d?f(!1):ne(),children:(0,M.jsx)(w,{name:`pencil`,size:14})}),(0,M.jsx)(`button`,{type:`button`,className:`tw-icon-danger rounded p-1`,"aria-label":`删除`,disabled:i,onClick:o,children:(0,M.jsx)(w,{name:`trash`,size:14})}),(0,M.jsx)(w,{name:`chevronRight`,size:14,className:`ml-1 text-stone-300 transition-transform duration-150 ${l||d?`rotate-90`:``}`})]})]}),(0,M.jsx)(`div`,{className:`grid transition-[grid-template-rows] duration-200 ease-out motion-reduce:transition-none ${l||d?`grid-rows-[1fr]`:`grid-rows-[0fr]`}`,children:(0,M.jsxs)(`div`,{className:`min-h-0 overflow-hidden`,children:[ee&&d?(0,M.jsxs)(`div`,{className:`space-y-3 border-t border-stone-100 px-4 py-3`,children:[(0,M.jsxs)(`label`,{className:`block`,children:[(0,M.jsx)(`span`,{className:z,children:`标题`}),(0,M.jsx)(`input`,{className:`${ut} mt-1`,value:m.title,onChange:e=>g({title:e.target.value})})]}),(0,M.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,M.jsxs)(`label`,{className:`block`,children:[(0,M.jsx)(`span`,{className:z,children:`角色`}),(0,M.jsx)(`input`,{className:`${ut} mt-1`,value:m.role,onChange:e=>g({role:e.target.value})})]}),(0,M.jsxs)(`label`,{className:`block`,children:[(0,M.jsx)(`span`,{className:z,children:`优先级`}),(0,M.jsx)(`div`,{className:`mt-1`,children:(0,M.jsx)(p,{options:lt,value:m.priority,onChange:e=>g({priority:e}),ariaLabel:`优先级`,flat:!0})})]})]}),(0,M.jsxs)(`label`,{className:`block`,children:[(0,M.jsx)(`span`,{className:z,children:`目标`}),(0,M.jsx)(`input`,{className:`${ut} mt-1`,value:m.goal,onChange:e=>g({goal:e.target.value})})]}),(0,M.jsxs)(`label`,{className:`block`,children:[(0,M.jsx)(`span`,{className:z,children:`价值 / 备注`}),(0,M.jsx)(`input`,{className:`${ut} mt-1`,value:m.value,onChange:e=>g({value:e.target.value})})]}),(0,M.jsx)(mt,{label:`前置条件`,value:m.preconditions,placeholder:`已登录且拥有申请权限`,onChange:e=>g({preconditions:e})}),(0,M.jsx)(H,{value:m.mainFlow,onChange:e=>g({mainFlow:e})}),(0,M.jsx)(ht,{value:m.altFlows,onChange:e=>g({altFlows:e})}),(0,M.jsx)(gt,{value:m.exceptions,onChange:e=>g({exceptions:e})}),(0,M.jsx)(mt,{label:`后置条件`,value:m.postconditions,placeholder:`申请单状态变为待审批`,onChange:e=>g({postconditions:e})}),(0,M.jsx)(_t,{value:m.acceptance,onChange:e=>g({acceptance:e})}),(0,M.jsx)(mt,{label:`覆盖维度`,value:m.dimensions,placeholder:`权限、边界值、超时与失败`,onChange:e=>g({dimensions:e})}),(0,M.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,M.jsxs)(`span`,{className:`text-xs text-stone-400`,children:[`来源条目:`,e.sourceRefs.join(`、`)||`(未关联)`]}),(0,M.jsxs)(`div`,{className:`flex gap-2`,children:[(0,M.jsx)(`button`,{type:`button`,className:`h-8 rounded-md border border-stone-200 px-3 text-xs text-stone-600 transition-colors hover:bg-stone-50`,onClick:()=>f(!1),children:`取消`}),(0,M.jsx)(`button`,{type:`button`,className:`h-8 rounded-md bg-[#3370ff] px-3 text-xs font-medium text-white transition-opacity hover:opacity-90 disabled:opacity-50`,disabled:i||!m.title.trim(),onClick:()=>{a(m),f(!1)},children:`保存`})]})]})]}):null,ee&&!d?(0,M.jsxs)(`div`,{className:`border-t border-stone-100 bg-stone-50/50 px-3.5 py-3.5`,children:[(0,M.jsxs)(`div`,{className:`space-y-3.5`,children:[e.value?(0,M.jsx)(B,{label:`价值`,children:e.value}):null,e.preconditions.length?(0,M.jsx)(B,{label:`前置条件`,children:(0,M.jsx)(`ul`,{className:`list-disc space-y-0.5 pl-4`,children:e.preconditions.map((e,t)=>(0,M.jsx)(`li`,{children:e},t))})}):null,e.mainFlow.length?(0,M.jsx)(B,{label:`主流程`,children:(0,M.jsx)(`ol`,{className:`list-decimal space-y-0.5 pl-4`,children:e.mainFlow.map((e,t)=>(0,M.jsxs)(`li`,{children:[e.actor?(0,M.jsxs)(`span`,{className:`text-stone-500`,children:[e.actor,`:`]}):null,e.action,e.result?(0,M.jsxs)(`span`,{className:`text-stone-500`,children:[` → `,e.result]}):null]},t))})}):null,e.altFlows.length?(0,M.jsx)(B,{label:`替代流程`,children:(0,M.jsx)(`ul`,{className:`space-y-1.5`,children:e.altFlows.map((e,t)=>(0,M.jsxs)(`li`,{children:[(0,M.jsxs)(`p`,{className:`font-medium text-stone-700`,children:[e.name,e.trigger?(0,M.jsxs)(`span`,{className:`font-normal text-stone-500`,children:[`(触发:`,e.trigger,`)`]}):null]}),(0,M.jsx)(`ol`,{className:`mt-0.5 list-decimal space-y-0.5 pl-4 text-stone-600`,children:e.steps.map((e,t)=>(0,M.jsx)(`li`,{children:e},t))})]},t))})}):null,e.exceptions.length?(0,M.jsx)(B,{label:`异常场景`,children:(0,M.jsx)(`ul`,{className:`space-y-0.5`,children:e.exceptions.map((e,t)=>(0,M.jsxs)(`li`,{children:[e.scenario,e.expected?(0,M.jsxs)(`span`,{className:`text-stone-500`,children:[` → `,e.expected]}):null]},t))})}):null,e.postconditions.length?(0,M.jsx)(B,{label:`后置条件`,children:(0,M.jsx)(`ul`,{className:`list-disc space-y-0.5 pl-4`,children:e.postconditions.map((e,t)=>(0,M.jsx)(`li`,{children:e},t))})}):null,e.acceptance.length?(0,M.jsx)(B,{label:`验收标准`,children:(0,M.jsx)(`ul`,{className:`space-y-1`,children:e.acceptance.map((e,t)=>(0,M.jsxs)(`li`,{className:`flex flex-wrap items-baseline gap-x-2 gap-y-0.5 rounded-md bg-white px-2 py-1 ring-1 ring-stone-100`,children:[(0,M.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:`Given`}),(0,M.jsx)(`span`,{children:e.given||`—`}),(0,M.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:`When`}),(0,M.jsx)(`span`,{children:e.when||`—`}),(0,M.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:`Then`}),(0,M.jsx)(`span`,{className:e.then?`text-stone-800`:`text-red-500`,children:e.then||`(未写)`})]},t))})}):null,e.dimensions.length?(0,M.jsx)(B,{label:`覆盖维度`,children:(0,M.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:e.dimensions.map(e=>(0,M.jsx)(`span`,{className:`rounded bg-white px-1.5 py-0.5 text-[11px] text-stone-500 ring-1 ring-stone-100`,children:e},e))})}):null,(0,M.jsx)(B,{label:`来源条目`,children:(0,M.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:e.sourceRefs.length?e.sourceRefs.map(e=>(0,M.jsx)(`span`,{className:`rounded bg-white px-1.5 py-0.5 font-mono text-[11px] text-stone-500 ring-1 ring-stone-100`,children:e},e)):(0,M.jsx)(`span`,{className:`text-amber-600`,children:`未关联(覆盖率会算不到)`})})})]}),r.length?(0,M.jsxs)(`div`,{className:`mt-3 rounded-lg border border-amber-200 bg-amber-50/70 px-3 py-2`,children:[(0,M.jsx)(`p`,{className:`text-xs font-medium text-amber-900`,children:`审查发现的问题`}),(0,M.jsx)(`ul`,{className:`mt-1 space-y-1`,children:r.map(e=>(0,M.jsxs)(`li`,{className:`flex flex-wrap items-center gap-1.5 text-xs`,children:[(0,M.jsx)(C,{tone:_e[e.severity],children:x[e.severity]}),(0,M.jsx)(`span`,{className:`text-stone-500`,children:ye[e.type]}),(0,M.jsx)(`span`,{className:`text-stone-700`,children:e.title})]},e.id))})]}):null]}):null]})})]})}var yt=`reqanalysis.doc`,bt=`reqanalysis.listmode`,xt=`reqanalysis.view`,St=`reqanalysis.tab`,Ct=`reqanalysis.storykeyword`,wt=[`list`,`work`],Tt=[`stories`,`check`,`outline`,`points`],Et=`reqanalysis.activity`,Dt=[`info`,`tool`,`done`,`error`,`stage`];function Ot(e){return`${Et}.${e}`}function kt(e){if(!e)return[];let t=l(Ot(e),[]);return Array.isArray(t)?t.filter(e=>{if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.id==`number`&&typeof t.text==`string`&&typeof t.at==`string`&&typeof(t.detail??``)==`string`&&Dt.includes(t.kind)}).slice(-200):[]}var At=`reqanalysis.run`,jt=[`decompose`,`audit`,`fix`,`testpoints`],U=null,Mt={current:null},Nt=new Set;function Pt(e){return`${At}.${e}`}function Ft(e){let t=e?.docId??U?.docId;U=e,t&&a(Pt(t),e);for(let t of Nt)t(e)}function It(e){return Nt.add(e),()=>{Nt.delete(e)}}function W(e,t){if(!U||U.status!==`running`)return;let n=Math.max(0,Math.min(100,Math.round(e)));(n!==U.done||t!==void 0&&t!==U.message)&&Ft({...U,total:100,done:n,...t===void 0?{}:{message:t}})}var G=96;function Lt(e,t=1){if(!U||U.status!==`running`)return;let n=Math.max(1,Math.min(G,Math.round(e))),r=U.done;if(r>=n)return;let i=n-r,a=i>28?Math.min(Math.max(1,t),i):1;Ft({...U,total:100,done:Math.min(n,r+a)})}function Rt(e,t=1200){let n=0,r=window.setInterval(()=>{if(!U||U.status!==`running`)return;let t=Math.max(1,Math.min(G,Math.round(e)))-U.done;t<=0||(n+=1,n%(t>40?1:t>24?2:t>12?3:t>5?5:8)==0&&Lt(e,1))},t);return()=>window.clearInterval(r)}function zt(e){if(!e)return null;let t=l(Pt(e),null);if(!t||typeof t!=`object`)return null;let n=t;if(typeof n.label!=`string`||typeof n.message!=`string`||!jt.includes(n.kind))return null;let r=n.status===`done`||n.status===`error`?n.status:`stopped`;return{docId:e,kind:n.kind,label:n.label,done:Math.max(0,Number(n.done)||0),total:Math.max(0,Number(n.total)||0),message:n.message,startedAt:Number(n.startedAt)||0,status:r,finishedAt:Number(n.finishedAt)||void 0}}var Bt={md:`Markdown`,markdown:`Markdown`,txt:`文本`,csv:`CSV`,docx:`Word`,xlsx:`Excel`,xls:`Excel`,doc:`Word(旧版)`,pdf:`PDF`,ppt:`PPT`,pptx:`PPT`},Vt=`inline-flex h-9 items-center justify-center gap-1.5 rounded-md bg-[#3370ff] px-3.5 text-sm font-medium text-white transition-opacity hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-50`,Ht=`inline-flex h-9 items-center justify-center gap-1.5 rounded-md border border-stone-200 bg-white px-3 text-sm text-stone-700 transition-colors hover:bg-stone-50 disabled:cursor-not-allowed disabled:opacity-50`,Ut=`text-xs font-semibold tracking-wide text-stone-500`;function Wt(e){return e.split(`/`).pop()||e}function Gt(e){return(e.format||Wt(e.path).split(`.`).pop()||``).toLowerCase()}function Kt(e){let t=new Date(e);if(Number.isNaN(t.getTime()))return`—`;let n=e=>String(e).padStart(2,`0`),r=`${n(t.getMonth()+1)}/${n(t.getDate())} ${n(t.getHours())}:${n(t.getMinutes())}`;return t.getFullYear()===new Date().getFullYear()?r:`${t.getFullYear()}/${r}`}function qt(e){let t=new Date(e);if(Number.isNaN(t.getTime()))return``;let n=e=>String(e).padStart(2,`0`);return`${n(t.getHours())}:${n(t.getMinutes())}:${n(t.getSeconds())}`}function K(e,t=160){if(e==null)return``;let n=``;try{n=typeof e==`string`?e:JSON.stringify(e)}catch{return``}return n?n.length>t?`${n.slice(0,t)}…`:n:``}function Jt(e){let t=Math.max(0,(Date.now()-e)/1e3);return t<10?`${t.toFixed(1)}s`:`${Math.round(t)}s`}function Yt(e){return[...e].sort((e,t)=>t.updatedAt.localeCompare(e.updatedAt))}function Xt({name:e,ready:t}){return(0,M.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,M.jsx)(f,{text:e,className:`min-w-0 flex-1 truncate text-xs text-stone-500`}),(0,M.jsx)(`span`,{className:`shrink-0 text-[11px] ${t?`text-emerald-600`:`text-stone-400`}`,children:t?`已就绪`:`未就绪`})]})}function Zt(){let e=He(`reqAnalysis`),t=He(`storyReview`),u=He(`testPoints`),[v,_e]=(0,T.useState)(null),[b,ye]=(0,T.useState)([]),[x,Se]=(0,T.useState)(``),[S,Ee]=(0,T.useState)(null),[Oe,ke]=(0,T.useState)([]),[Me,Pe]=(0,T.useState)(``),[Re,ze]=(0,T.useState)(``),[E,qe]=(0,T.useState)(null),[D,Je]=(0,T.useState)(null),[O,Ye]=(0,T.useState)(null),[k,Xe]=(0,T.useState)(null),[A,Ze]=(0,T.useState)(()=>U);(0,T.useEffect)(()=>(Ze(U),It(Ze)),[]);let j=A?.status===`running`?A.kind:null,N=A?.status===`running`&&A.docId===x?{label:A.label,done:A.done,total:A.total,message:A.message}:null,nt=(0,T.useRef)(Date.now()),P=A&&A.docId===x&&A.status!==`running`&&(A.finishedAt??0)<nt.current?A:null,[it,at]=(0,T.useState)([]),[ot,F]=(0,T.useState)(``),[st,I]=(0,T.useState)(``),[L,R]=(0,T.useState)(()=>o(St,Tt,`stories`));(0,T.useEffect)(()=>{i(St,L)},[L]);let[lt,ut]=(0,T.useState)(`list`),dt=(0,T.useRef)(o(xt,wt,`list`)),[z,ft]=(0,T.useState)(!0),[pt,B]=(0,T.useState)(()=>o(bt,[`doc`,`story`],`doc`)),[V,mt]=(0,T.useState)(()=>c(Ct,``));(0,T.useEffect)(()=>{s(Ct,V)},[V]);let[H,ht]=(0,T.useState)(null),[gt,_t]=(0,T.useState)([]),Et=(0,T.useRef)(``),[Dt,At]=(0,T.useState)(``),[jt,Nt]=(0,T.useState)([]),G=(0,T.useRef)([]),[Zt,Qt]=(0,T.useState)(!1),[$t,en]=(0,T.useState)(!1),q=(0,T.useRef)(null),tn=(0,T.useRef)(0),nn=(0,T.useRef)(null),rn=(0,T.useRef)(null),an=(0,T.useCallback)(e=>t.on||e!==`checked`&&e!==`accepted`?be[e]:be.decomposed,[t.on]),on=(0,T.useMemo)(()=>{let e=e=>+!e.supported;return[...Oe].filter(e=>!h(e.name)).sort((t,n)=>e(t)-e(n)||t.path.localeCompare(n.path,`zh`)).map(e=>{let t=Gt(e),n=Bt[t]??t.toUpperCase();return{value:e.path,label:e.path,secondary:e.supported?t:`${n} · 暂不支持,请另存为 .docx / .xlsx / .md`,disabled:!e.supported}})},[Oe]),J=(0,T.useCallback)(e=>{q.current=e,Ee(e),ye(t=>Yt(t.map(t=>t.id===e.id?e:t)))},[]),Y=(0,T.useCallback)((e,t=`info`,n)=>{tn.current+=1,at(r=>[...r,{id:tn.current,kind:t,text:e,detail:n?.trim()||void 0,at:new Date().toISOString()}])},[]),X=(0,T.useCallback)((e,t,n,r)=>{Ft({docId:q.current?.id??``,kind:e,label:t,done:0,total:100,message:r,startedAt:Date.now(),status:`running`})},[]),sn=(0,T.useCallback)(e=>{if(!U||U.status!==`running`)return;let t=e.done==null?U.done:Math.max(0,Math.min(100,Math.round(e.done)));Ft({...U,...e,total:100,done:t})},[]),Z=(0,T.useCallback)((e,t,n)=>{U?.kind===e&&(Mt.current=null,Ft({...U,status:t,done:t===`done`?100:U.done,total:100,message:n??U.message,finishedAt:Date.now()}))},[]);(0,T.useEffect)(()=>{x&&Ze(U??zt(x))},[x]);let cn=(0,T.useCallback)(()=>{x&&a(Pt(x),null),Ft(null)},[x]),ln=(0,T.useRef)(!1);(0,T.useEffect)(()=>{if(!x){ln.current=!0,at([]);return}let e=kt(x);tn.current=e.reduce((e,t)=>Math.max(e,t.id),0),ln.current=!0,at(e)},[x]),(0,T.useEffect)(()=>{ln.current?ln.current=!1:x&&a(Ot(x),it.slice(-200))},[it,x]);let un=(0,T.useCallback)((e,t)=>{let n=G.current,r=n.length===t.length&&n.every((e,n)=>e===t[n]);G.current=t,r||Nt(t),e&&a(`reqanalysis.idealTitles.${e}`,t)},[]),Q=(0,T.useCallback)(e=>{if(q.current=e,Ee(e),Se(e?.id??``),s(yt,e?.id??``),e?.sourcePath&&Pe(e.sourcePath),e?.id){let t=l(`reqanalysis.idealTitles.${e.id}`,[]),n=Array.isArray(t)?t.filter(e=>typeof e==`string`):[];G.current=n,Nt(n)}else G.current=[],Nt([])},[]),dn=(0,T.useCallback)(e=>{ut(e),i(xt,e)},[]),fn=(0,T.useCallback)(async e=>{if(!e?.sourcePath)return un(``,[]),[];try{let t=await we(e.sourcePath),n=fe(t);return un(e.id,n),n}catch{return un(e.id,G.current),G.current}},[un]),pn=(0,T.useCallback)(async e=>{try{let t=await we(e.sourcePath),n=fe(t);return un(e.id,n),e}catch{return e}},[un]),mn=(0,T.useCallback)((e,t=`stories`)=>{Q(e),R(t),dn(`work`),Ve(`req-analysis`),pn(e)},[dn,Q,pn]),hn=(0,T.useCallback)((e,t)=>{Et.current=t,mn(e,`stories`)},[mn]);(0,T.useEffect)(()=>{if(lt!==`work`||!Et.current)return;let e=Et.current;Et.current=``;let t=0,n=requestAnimationFrame(()=>{let n=document.getElementById(`req-story-${e}`);n&&(n.scrollIntoView({block:`center`,behavior:`smooth`}),n.classList.add(`tw-req-story-focus`),t=window.setTimeout(()=>n.classList.remove(`tw-req-story-focus`),1600))});return()=>{cancelAnimationFrame(n),t&&window.clearTimeout(t)}},[lt,S?.id]);let gn=(0,T.useMemo)(()=>b.flatMap(e=>e.stories.map(t=>({doc:e,story:t}))),[b]),_n=gn.length,vn=(0,T.useMemo)(()=>{let e=V.trim().toLowerCase(),t=t=>String(t??``).toLowerCase().includes(e),n=e?gn.filter(({doc:e,story:n})=>t(n.id)||t(n.title)||t(n.role)||t(n.goal)||t(_(e))||t(e.title)):gn,r=[],i=new Map;for(let e of n){let t=i.get(e.doc.id);t===void 0?(i.set(e.doc.id,r.length),r.push({doc:e.doc,rows:[e]})):r[t].rows.push(e)}return r.sort((e,t)=>t.doc.updatedAt.localeCompare(e.doc.updatedAt))},[gn,V]),yn=(0,T.useMemo)(()=>new Set(H?.ids??[]),[H]),bn=(0,T.useCallback)((e,t)=>{ht(n=>{if(!n||n.docId!==e)return{docId:e,ids:[t]};let r=n.ids.includes(t)?n.ids.filter(e=>e!==t):[...n.ids,t];return r.length?{docId:e,ids:r}:null})},[]),xn=(0,T.useCallback)((e,t)=>{ht(n=>n?.docId===e&&t.every(e=>n.ids.includes(e))?null:t.length?{docId:e,ids:t}:null)},[]),Sn=(0,T.useCallback)(e=>{B(e),i(bt,e)},[]);(0,T.useEffect)(()=>{let e=!0;(async()=>{if(await n(),!e)return;qe(ne());let t=await ve();if(e){if(_e(t),!t)ft(!1);else try{let[t,n,r,i]=await Promise.all([pe(),ge(),je(),Ae()]);if(!e)return;let a=n;if((!n.exists||!n.decompose.trim())&&(await re(!0).catch(()=>void 0),a=await ge()),!e)return;Je(a);let o=r;if((!r.exists||!r.review.trim())&&(await Fe(!0).catch(()=>void 0),o=await je()),!e)return;o.exists&&Ye(o),i.exists&&Xe(i);let s=Yt(t);ye(s);let l=c(yt,``),u=s.find(e=>e.id===l)??s[0]??null;Q(u);let d=dt.current;if(dt.current=`list`,d===`work`&&u&&l&&u.id===l&&(dn(`work`),Ve(`req-analysis`)),u&&await pn(u),!e)return;ft(!1)}catch(t){e&&(ft(!1),I(t instanceof Error?t.message:String(t)))}}})();let t=te(()=>qe(ne()));return()=>{e=!1,t()}},[dn,Q,pn]),(0,T.useEffect)(()=>{if(!t.ready)return;if(!t.on){Ye(null),R(e=>e===`check`?`stories`:e);return}if(!v||O!==null)return;let e=!0;return(async()=>{let t=await je();(!t.exists||!t.review.trim())&&(await Fe(!0).catch(()=>void 0),t=await je()),e&&Ye(t)})(),()=>{e=!1}},[t.ready,t.on,v,O]),(0,T.useEffect)(()=>{L===`points`&&S?.sourcePath&&(G.current.length||fn(S))},[L,S,fn]),(0,T.useEffect)(()=>{if(!u.ready)return;if(!u.on){Xe(null),R(e=>e===`points`?`stories`:e);return}if(!v||k!==null)return;let e=!0;return(async()=>{let t=await Ae();(!t.exists||!t.generate.trim())&&(await Be(!0).catch(()=>void 0),t=await Ae()),e&&Xe(t)})(),()=>{e=!1}},[u.ready,u.on,v,k]),(0,T.useEffect)(()=>{if(!v)return;let e=!0;return se().then(t=>{e&&ke(t)}).catch(t=>{e&&ze(t instanceof Error?t.message:String(t))}),()=>{e=!1}},[v]),(0,T.useEffect)(()=>{let e=S?.sourcePath;if(!e){At(``);return}let t=!0;return we(e).then(e=>{t&&At(Ce(e))}).catch(()=>{t&&At(``)}),()=>{t=!1}},[S?.sourcePath,S?.sourceHash]),(0,T.useEffect)(()=>{let e=nn.current;e&&(e.scrollTop=e.scrollHeight)},[it]);let Cn=!!(S?.sourceHash&&Dt&&S.sourceHash!==Dt),wn=(0,T.useMemo)(()=>new Set((S?.stories??[]).flatMap(e=>e.sourceRefs)),[S?.stories]),Tn=D??null,En=!!Tn?.decompose.trim(),Dn=(0,T.useMemo)(()=>(S?.check?.gaps??[]).filter(e=>e.selected).length,[S?.check]),$=(0,T.useCallback)(async(e,t)=>{let n=t??q.current;if(!n)throw Error(`还没有分析文档`);let r=await y(n.id,e);return J(r),r},[J]),On=(0,T.useCallback)(()=>{rn.current&&window.clearTimeout(rn.current),rn.current=window.setTimeout(()=>{let e=q.current;e?.check&&y(e.id,{check:e.check}).catch(()=>void 0)},600)},[]),kn=(0,T.useCallback)(async e=>{if(!e)return null;let t=b.find(t=>t.sourcePath===e);if(t)return mn(t,`stories`),t;try{let t=await we(e),n=Wt(e),r=await he({sourcePath:e,sourceTitle:n,sourceHash:Ce(t),title:n});return ye(e=>Yt([r,...e])),mn(r,`stories`),Y(`新建分析:${_(r)}`),r}catch(e){let t=e instanceof Error?e.message:String(e);return I(t),m(t,`error`),Pe(q.current?.sourcePath??``),null}},[b,mn,Y]),An=!!(E?.baseURL&&E.apiKey&&E.model),jn=(0,T.useCallback)(()=>!An||!E?(m(`请先在设置里配置模型`,`error`),g(`model`),null):E,[An,E]),Mn=(0,T.useCallback)((e,t)=>({getDoc:()=>q.current,batch:t,saveOutline:async t=>{let n=await y(e.id,{outline:t});return J(n),n.outline},saveStories:async t=>{let n=await y(e.id,{stories:t});return J(n),Y(`已写入 ${n.stories.length} 个用户故事`),n},saveCheck:async t=>{let n=q.current?.check,r={...t,gaps:le(n?.gaps??[],t.gaps)},i=await y(e.id,{check:r});return J(i),i},saveTestPoints:async t=>{let n=await y(e.id,{testPoints:t});return J(n),n}}),[J,Y]),Nn=(0,T.useCallback)(async()=>{let e=q.current,n=jn();if(!e||!n)return;let r=Tn?.decompose.trim()??``;if(!r){m(`没有读到「${ce}」的「## 拆解」段落`,`error`);return}I(``),F(``),Y(`开始拆解`,`stage`),X(`decompose`,`拆解`,100,`正在读取来源文档`);let i=new AbortController;Mt.current=i;let a=`done`;try{let a=await y(e.id,{status:`draft`,progress:{stage:`stories`,done:0,total:100,message:`正在读取来源文档`,at:new Date().toISOString()}});J(a);let o=await we(e.sourcePath);if(!o.trim())throw Error(`来源文档是空的`);let s=oe(o);if(!s.length)throw Error(`来源文档没有可拆解的内容`);W(5,`共 ${s.length} 批,准备拆第 1 批`),Y(s.length>1?`来源 ${o.length} 字,已分 ${s.length} 批拆解`:`来源 ${o.length} 字,单批拆解`);let c=await y(e.id,{replaceStories:!0,stories:[],outline:[],check:null,status:`draft`,sourceHash:Ce(o)});J(c);for(let t of s){if(i.signal.aborted)break;let a=q.current?.stories.length??0,o=[r,``,Ke,``,`## 已抽取的需求条目(sourceRefs 只能引用这些 id)`,(q.current?.outline??[]).map(e=>`- ${e.id} ${e.title}${e.quote?`(原文:${e.quote})`:``}`).join(`
19
- `)||`(本批还没有条目,先调用 req_set_outline)`].join(`
20
- `),c=[`这一批是原始需求的第 ${t.index+1}/${s.length} 段${t.title?`(章节:${t.title})`:``}。只处理这一段的条目与故事,已完成的部分不要重写。`,``,`## 原始需求`,``,t.text].join(`
21
- `),l=5+Math.floor(t.index/s.length*85),u=5+Math.floor((t.index+1)/s.length*85),d=t.index===s.length-1,f=Math.max(l+1,d?Math.min(90,u):Math.min(u-2,88));await $({progress:{stage:`stories`,done:l,total:100,message:`正在拆第 ${t.index+1}/${s.length} 批`,at:new Date().toISOString()}},q.current).catch(()=>void 0);let p=Date.now();Y(`第 ${t.index+1}/${s.length} 批开始`,`info`,[t.title?`章节:${t.title}`:``,`${t.text.length} 字`].filter(Boolean).join(` · `)),W(l,`正在拆第 ${t.index+1}/${s.length} 批`);let m=Rt(f),h=``;try{for await(let r of ee(n,[{role:`system`,content:o},{role:`user`,content:c}],i.signal,{tools:Qe.filter(e=>[`req_set_outline`,`req_set_stories`].includes(e.function.name)),maxToolRounds:20,runTool:(n,r)=>$e(n,r,Mn(e,t.index))}))r.type===`content`?(h+=r.delta,F(e=>e+r.delta),Lt(f,1)):r.type===`tool`&&r.status===`running`?(Y(`调用 ${r.name}`,`tool`,K(r.args)),Lt(f,1)):r.type===`tool`&&r.status===`done`&&(Y(`${r.name} 返回`,`tool`,K(r.result,120)),Lt(f,2))}finally{m()}if(W(Math.min(90,Math.max(f+2,u-2)),`第 ${t.index+1}/${s.length} 批返回,正在写入`),(q.current?.stories.length??0)===a){let n=et(h);if(n.length){let t=Te(q.current?.stories??[],n),r=await y(e.id,{stories:t});J(r),Y(`模型没调工具,已从回答里兜底解析 ${n.length} 个故事`,`info`)}else Y(`第 ${t.index+1} 批没有拿到结构化故事`,`error`)}let te=Math.max(0,(q.current?.stories.length??0)-a);Y(`第 ${t.index+1}/${s.length} 批完成`,`done`,`新增 ${te} 个故事 · 耗时 ${Jt(p)}`),W(u,`第 ${t.index+1}/${s.length} 批已写入`)}if(i.signal.aborted){Y(`已中断:已经写入的故事保留`,`info`);return}W(92,`正在保存拆解结果`);let l=await y(e.id,{status:`decomposed`,progress:{stage:`done`,done:100,total:100,message:`拆解完成`,at:new Date().toISOString()}});J(l),Y(`拆解完成:${l.outline.length} 条需求条目、${l.stories.length} 个用户故事`,`done`),R(`stories`),t.on&&!i.signal.aborted?(W(96,`拆解完成,接着审查`),m(`拆解完成,接着做用户故事审查`,`success`),await Fn.current?.(!0)):(W(100,`拆解完成`),m(`拆解完成`,`success`))}catch(e){let t=e instanceof Error?e.message:String(e);i.signal.aborted?(a=`stopped`,Y(`已中断:已经写入的故事保留`,`info`)):(a=`error`,I(t),Y(`拆解失败:${t}`,`error`))}finally{i.signal.aborted&&(a=`stopped`),Z(`decompose`,a,a===`done`?`拆解完成`:a===`stopped`?`已中断:已经写入的故事保留`:`拆解失败,详见活动日志`)}},[X,Z,Mn,J,Y,Tn,jn,sn,t.on,$]),Pn=(0,T.useCallback)(async(e=!1)=>{let t=q.current;if(!t)return;if(!t.stories.length){e||m(`还没有用户故事,先做一次拆解`,`info`);return}I(``),e||F(``),Y(e?`继续审查用户故事`:`开始审查用户故事`,`stage`,e?`拆解完成后自动接续`:void 0),X(`audit`,`审查用户故事`,100,`正在跑规则体检`);let n=new AbortController;Mt.current=n;let r={status:`done`,message:`审查完成`};try{let e=Date.now();W(8,`正在跑规则体检`);let i=ue(t),a=await y(t.id,{check:{...i,gaps:le(t.check?.gaps??[],i.gaps)},progress:{stage:`audit`,done:18,total:100,message:`规则体检完成,等待模型评审`,at:new Date().toISOString()}});J(a),Y(`规则体检:覆盖率 ${Math.round(i.coverage.rate*100)}%,${i.gaps.length} 个缺口`,`info`,`${t.outline.length} 条需求条目 · ${t.stories.length} 个故事 · 耗时 ${Jt(e)}`),W(18,`规则体检完成,等待模型评审`);let o=O?.review.trim()??``,s=An?E:null;if(!s||!o){Y(s?`「用户故事审查提示词.md」缺少「## 审查」段落,只保留规则结果`:`没有配置模型,只保留规则结果`,`info`),r.message=`没有配置模型,只保留规则结果`,await y(t.id,{status:`checked`,progress:{stage:`done`,done:100,total:100,message:r.message,at:new Date().toISOString()}}).then(J).catch(()=>void 0),R(`check`);return}let c=!1,l=Mn(t,90),u=l.saveCheck;l.saveCheck=async e=>{c=!0,W(96,`正在写入审查结果`);let t=await u(e);return Y(`模型体检:整体 ${t.check?.gaps.length??0} 个缺口`,`done`),t};let d=q.current??a,f=await ae(d.sourcePath);f.text||Y(`没有读到原始需求,只能依据需求条目摘句审查`,`info`),Y(`提交模型审查`,`tool`,`模型 ${s.model} · ${d.stories.length} 个故事 · 原文 ${f.text.length} 字`),W(22,`正在提交模型审查`);let p=[`## 原始需求`,f.text?f.truncated?`${f.text}\n\n(原文共 ${f.total} 字,以上为前 ${f.text.length} 字,没看到的部分不要猜)`:f.text:`(未读到原始需求,只能依据下面的需求条目摘句判断)`,``,`## 需求条目`,d.outline.length?d.outline.map(e=>`- ${e.id} ${e.title}${e.quote?`(原文:${e.quote})`:``}`).join(`
22
- `):`(无)`,``,`## 用户故事(${d.stories.length} 条)`,"```json",JSON.stringify(d.stories,null,2),"```"].join(`
23
- `),h=Rt(90);try{for await(let e of ee(s,[{role:`system`,content:`${o}\n\n${Ke}`},{role:`user`,content:p}],n.signal,{tools:Qe.filter(e=>e.function.name===`req_save_check`),maxToolRounds:8,runTool:(e,t)=>$e(e,t,l)}))e.type===`content`?(F(t=>t+e.delta),Lt(90,1)):e.type===`tool`&&e.status===`running`?(Y(`调用 ${e.name}`,`tool`,K(e.args)),W(94,`模型正在提交审查结果`)):e.type===`tool`&&e.status===`done`&&(Y(`${e.name} 返回`,`tool`,K(e.result,120)),W(97,`审查结果已返回`))}finally{h()}c||(Y(`模型没有提交体检结果,当前只保留规则结果`,`error`),m(`模型没有提交体检结果,只保留了规则检查`,`error`)),W(100,c?`模型评审完成`:`已保留规则结果`),r.message=c?`审查完成`:`模型没提交结果,已保留规则结果`,await y(t.id,{status:`checked`,progress:{stage:`done`,done:100,total:100,message:r.message,at:new Date().toISOString()}}).then(J).catch(()=>void 0),R(`check`)}catch(e){let t=e instanceof Error?e.message:String(e);n.signal.aborted?(r.status=`stopped`,Y(`已中断:规则体检结果已保留`,`info`)):(r.status=`error`,I(t),Y(`体检失败:${t}`,`error`))}finally{n.signal.aborted&&(r.status=`stopped`),Z(`audit`,r.status,r.status===`error`?`审查失败,详见活动日志`:r.message)}},[X,Z,Mn,An,J,Y,sn,O,E]),Fn=(0,T.useRef)(null);Fn.current=Pn;let In=(0,T.useCallback)(async()=>{let e=q.current,t=jn();if(!e||!t)return;let n=(e.check?.gaps??[]).filter(e=>e.selected);if(!n.length){m(`先在缺口清单里勾选要补写的条目`,`info`);return}let r=O?.fix.trim()??``;if(!r){m(`「用户故事审查提示词.md」缺少「## 补写」段落`,`error`);return}I(``),F(``),Y(`开始补写选中条目`,`stage`,`勾选 ${n.length} 个缺口`),X(`fix`,`补写选中条目`,100,`正在按 ${n.length} 个勾选缺口补写`);let i=Date.now(),a=new AbortController;Mt.current=a;let o={status:`done`,message:`补写完成`};try{W(5,`正在按 ${n.length} 个勾选缺口补写`),Y(`按 ${n.length} 个勾选缺口补写`,`info`,n.map(e=>`[${e.severity}] ${e.storyId||`全局`}|${e.title}`).join(`;`));let s=new Map(e.stories.map(e=>[e.id,e.title])),c=await ae(e.sourcePath),l=[`## 原始需求`,c.text?c.truncated?`${c.text}\n\n(原文共 ${c.total} 字,以上为前 ${c.text.length} 字,没看到的部分不要猜)`:c.text:`(未读到原始需求,只能依据需求条目与当前故事集判断)`,``,`## 需求条目(新增故事的 sourceRefs 只能引用这里的 id)`,e.outline.length?e.outline.map(e=>`- ${e.id} ${e.title}${e.quote?`(原文:${e.quote})`:``}`).join(`
24
- `):`(无)`,``,`## 当前故事集(${e.stories.length} 条,没被点名的必须原样保留)`,"```json",JSON.stringify(e.stories,null,2),"```",``,`## 勾选待补写的缺口`,n.map(e=>{let t=e.storyId?`${e.storyId} ${s.get(e.storyId)??``}`:`全局问题`;return[`- [${e.severity}] ${t}|${e.title}`,e.detail?` 原因:${e.detail}`:``,e.suggestion?` 建议:${e.suggestion}`:``].filter(Boolean).join(`
25
- `)}).join(`
26
- `)].join(`
27
- `),u=Mn(e,90),d=!1,f=u.saveStories;u.saveStories=async e=>(d=!0,W(90,`正在写入补写结果`),f(e)),W(12,`正在提交模型补写`);let p=Rt(88);try{for await(let e of ee(t,[{role:`system`,content:`${r}\n\n${Ke}`},{role:`user`,content:l}],a.signal,{tools:Qe.filter(e=>e.function.name===`req_set_stories`),maxToolRounds:10,runTool:(e,t)=>$e(e,t,u)}))e.type===`content`?(F(t=>t+e.delta),Lt(88,1)):e.type===`tool`&&e.status===`running`?(Y(`调用 ${e.name}`,`tool`,K(e.args)),W(90,`模型正在提交补写`)):e.type===`tool`&&e.status===`done`&&(Y(`${e.name} 返回`,`tool`,K(e.result,120)),W(94,`补写结果已返回`))}finally{p()}if(!d){o.status=`error`,o.message=`模型没有提交补写结果,故事集保持不变`,Y(`模型没有提交补写结果,故事集保持不变`,`error`),m(`模型没有提交补写结果`,`error`);return}W(94,`已写入补写结果,正在重算覆盖率`);let h=q.current;if(h){let e=ue(h),t=await y(h.id,{check:e,status:`decomposed`});J(t)}let te=Math.round((q.current?.check?.coverage.rate??0)*100);Y(`补写完成,已按规则重算覆盖率;建议再跑一次体检`,`done`,`覆盖率 ${te}% · 耗时 ${Jt(i)}`),await $({progress:{stage:`done`,done:100,total:100,message:`补写完成`,at:new Date().toISOString()}},q.current).catch(()=>void 0),R(`check`),m(`补写完成,建议再跑一次体检`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);a.signal.aborted?(o.status=`stopped`,Y(`已中断:已经写入的改动保留`,`info`)):(o.status=`error`,o.message=t,I(t),Y(`补写失败:${t}`,`error`))}finally{a.signal.aborted&&(o.status=`stopped`),Z(`fix`,o.status,o.status===`error`?`补写失败:${o.message}`:o.message)}},[X,Z,Mn,J,Y,sn,jn,O,$]),Ln=(0,T.useCallback)(async()=>{let e=q.current,t=jn();if(!e||!t)return;if(!e.stories.length){m(`还没有用户故事,先做一次拆解`,`info`);return}let n=k?.generate.trim()??``;if(!n){m(`没有读到「${De}」的「## 生成」段落`,`error`);return}I(``),F(``),Y(`开始生成测试点`,`stage`,`基于 ${e.stories.length} 个用户故事,五维覆盖 P0–P3`),X(`testpoints`,`生成测试点`,100,`正在整理用户故事,等待模型生成`),R(`points`),await $({progress:{stage:`points`,done:5,total:100,message:`正在生成测试点`,at:new Date().toISOString()}},e).catch(()=>void 0);let r=Date.now();W(8,`正在整理用户故事`),Y(`整理用户故事,提交模型生成`,`info`,`${e.outline.length} 条需求条目 · ${e.stories.length} 个故事 · 模型 ${t.model}`);let i=new AbortController;Mt.current=i;let a={status:`done`,message:`测试点已生成`};try{let o=Mn(e,90),s=!1,c=o.saveTestPoints;o.saveTestPoints=async e=>{s=!0,W(90,`正在写入测试点`);let t=await c(e);return Y(`测试点已写入:${t.testPoints?.points.length??0} 条`,`done`),t};let l=[`## 分析标题\n${e.title||`未命名分析`}`,``,`## 需求条目`,e.outline.length?e.outline.map(e=>`- ${e.id} ${e.title}${e.quote?`(原文:${e.quote})`:``}`).join(`
28
- `):`(无)`,``,`## 用户故事(${e.stories.length} 条)`,"```json",JSON.stringify(e.stories,null,2),"```"].join(`
29
- `);W(15,`正在提交模型生成`);let u=``,d=Rt(88);try{for await(let e of ee(t,[{role:`system`,content:`${n}\n\n${Ke}`},{role:`user`,content:l}],i.signal,{tools:Qe.filter(e=>e.function.name===`req_save_test_points`),maxToolRounds:8,runTool:(e,t)=>$e(e,t,o)}))e.type===`content`?(u+=e.delta,F(t=>t+e.delta),Lt(88,1)):e.type===`tool`&&e.status===`running`?(Y(`调用 ${e.name}`,`tool`,K(e.args)),W(90,`模型正在提交测试点`)):e.type===`tool`&&e.status===`done`&&(Y(`${e.name} 返回`,`tool`,K(e.result,120)),W(94,`测试点已返回`))}finally{d()}if(!s){let t=tt(u,e.stories.map(e=>e.id));t&&(await o.saveTestPoints(t),s=!0,Y(`模型没调工具,已从回答里兜底解析 ${t.points.length} 条`,`info`))}if(!s)a.status=`error`,a.message=`模型没有提交测试点,原结果保持不变`,Y(`模型没有提交测试点,原结果保持不变`,`error`),m(`模型没有提交测试点,原结果保持不变`,`error`);else{let e=q.current?.testPoints?.points??[],t=t=>e.filter(e=>e.priority===t).length;Y(`测试点完成:${e.length} 条`,`done`,`P0 ${t(`P0`)} / P1 ${t(`P1`)} / P2 ${t(`P2`)} / P3 ${t(`P3`)} · 耗时 ${Jt(r)}`),W(100,`已生成 ${e.length} 条`),a.message=`测试点已生成 ${e.length} 条`,await $({progress:{stage:`done`,done:100,total:100,message:`测试点已生成 ${e.length} 条`,at:new Date().toISOString()}},q.current).catch(()=>void 0),m(`测试点已生成`,`success`)}}catch(e){let t=e instanceof Error?e.message:String(e);i.signal.aborted?(a.status=`stopped`,Y(`已中断:已经生成的测试点保留`,`info`)):(a.status=`error`,a.message=t,I(t),Y(`生成测试点失败:${t}`,`error`))}finally{i.signal.aborted&&(a.status=`stopped`),Z(`testpoints`,a.status,a.status===`error`?`生成测试点失败:${a.message}`:a.message)}},[X,Z,Mn,Y,sn,jn,$,k]),Rn=(0,T.useCallback)(async()=>{let e=q.current;if(!e?.testPoints)m(`还没有测试点可导出`,`info`);else try{let t=G.current;t.length||(t=await fn(e));let n=await Ne(e,t);Y(`已导出 ${n}`,`done`)}catch(e){m(`导出失败:${e instanceof Error?e.message:String(e)}`,`error`)}},[Y,fn]),zn=(0,T.useCallback)(async()=>{let e=q.current;if(!e?.testPoints){m(`还没有测试点可导出`,`info`);return}let t=G.current;t.length||(t=await fn(e));let n=Ie(e,t);Y(`已导出 ${n}`,`done`)},[Y,fn]),Bn=(0,T.useCallback)(async e=>{let t=q.current;if(t)try{await $({stories:e},t)}catch(e){m(`保存失败:${e instanceof Error?e.message:String(e)}`,`error`)}},[$]),Vn=(0,T.useCallback)((e,t)=>{let n=q.current;if(!n)return;let r=n.stories.map((n,r)=>r===e?{...t,id:n.id}:n);Bn(r)},[Bn]),Hn=(0,T.useCallback)(e=>{let t=q.current;t&&Bn(t.stories.filter((t,n)=>n!==e))},[Bn]),Un=(0,T.useCallback)((e,t)=>{let n=q.current;if(!n)return;let r=e+t;if(r<0||r>=n.stories.length)return;let i=[...n.stories],a=i[e],o=i[r];a&&o&&(i[e]=o,i[r]=a,Bn(i))},[Bn]),Wn=(0,T.useCallback)((e,t)=>{let n=q.current;if(!n?.check)return;let r={...n,check:{...n.check,gaps:n.check.gaps.map(n=>n.id===e?{...n,selected:t}:n)}};J(r),On()},[J,On]),Gn=(0,T.useCallback)(e=>{let t=q.current;if(!t?.check)return;let n={...t,check:{...t.check,gaps:t.check.gaps.map(t=>({...t,selected:e}))}};J(n),On()},[J,On]),Kn=(0,T.useCallback)(async()=>{let e=q.current;if(e)try{await xe(e.id);let t=b.filter(t=>t.id!==e.id);ye(t),Q(t[0]??null),dn(`list`),m(`已删除分析记录`,`success`)}catch(e){m(`删除失败:${e instanceof Error?e.message:String(e)}`,`error`)}finally{Qt(!1)}},[dn,b,Q]),qn=(0,T.useCallback)(()=>{let e=q.current;if(!e)return;let t=new Blob([ie(e)],{type:`text/markdown;charset=utf-8`}),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=de(e),document.body.appendChild(r),r.click(),r.remove(),window.setTimeout(()=>URL.revokeObjectURL(n),1e3),m(`已导出 Markdown`,`success`)},[]),Jn=(0,T.useCallback)(()=>{let e=q.current;if(!e?.check)return;let t=Le(e,e.check);m(`已导出 ${t}`,`success`)},[]),Yn=(0,T.useCallback)(()=>{Mt.current?.abort()},[]);if(!e.ready)return(0,M.jsx)(We,{label:`正在读取插件开关`});if(!e.on)return(0,M.jsx)(Ue,{children:r(`reqAnalysis`)});if(v===null)return(0,M.jsx)(We,{label:`正在连接需求分析服务`});if(!v)return(0,M.jsx)(Ue,{children:"需求分析需要本地服务,当前未就绪:确认服务已升级到最新版本并重启(`lantern` 一体服务或 `npm run dev`),静态部署的页面用不了。"});if(z)return(0,M.jsx)(We,{label:`正在回到上次的分析`});let Xn=S?.outline.filter(e=>wn.has(e.id)).length??0,Zn=S?.check?.gaps??[],Qn=(0,M.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3`,children:[(0,M.jsxs)(`section`,{className:`shrink-0 rounded-xl border border-stone-200 bg-white px-4 py-3`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[(0,M.jsxs)(`div`,{className:`min-w-[240px] flex-1`,children:[(0,M.jsx)(`p`,{className:Ut,children:`新建分析`}),(0,M.jsx)(`div`,{className:`mt-1.5 max-w-[440px]`,children:(0,M.jsx)(p,{options:on,value:Me,onChange:e=>{Pe(e),e&&kn(e)},triggerTitle:Me||`选择来源需求文档…`,ariaLabel:`选择来源需求文档`,searchable:!0,searchPlaceholder:`搜索文件名或路径…`,flat:!0})})]}),(0,M.jsxs)(`span`,{className:`pb-1 text-[11px] text-stone-400`,children:[`共 `,b.length,` 份分析`]})]}),Re?(0,M.jsxs)(`p`,{className:`mt-2 text-xs leading-relaxed text-amber-700`,children:[`读不到需求文档库:`,Re,(0,M.jsx)(`br`,{}),`请先启用「需求文档库」插件,或确认 `,me,` 之外的内容目录没有被移动。`]}):null]}),st?(0,M.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-2 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700`,children:[(0,M.jsx)(`span`,{className:`break-all`,children:st}),(0,M.jsx)(`button`,{type:`button`,className:`shrink-0 text-red-400`,onClick:()=>I(``),children:`✕`})]}):null,(0,M.jsxs)(`section`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,M.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2 border-b border-stone-100 px-3 py-2`,children:[(0,M.jsxs)(`div`,{className:`inline-flex rounded-lg border border-stone-200 bg-stone-50 p-0.5`,children:[(0,M.jsx)(`button`,{type:`button`,onClick:()=>Sn(`doc`),className:`h-7 rounded-md px-2.5 text-xs transition-colors ${pt===`doc`?`bg-white text-stone-900 shadow-sm`:`text-stone-500 hover:text-stone-700`}`,children:`按需求说明书`}),(0,M.jsx)(`button`,{type:`button`,onClick:()=>Sn(`story`),className:`h-7 rounded-md px-2.5 text-xs transition-colors ${pt===`story`?`bg-white text-stone-900 shadow-sm`:`text-stone-500 hover:text-stone-700`}`,children:`按用户故事`})]}),pt===`story`?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(`label`,{className:`relative block`,children:[(0,M.jsx)(w,{name:`search`,size:14,className:`pointer-events-none absolute left-2.5 top-1/2 -translate-y-1/2 text-stone-400`}),(0,M.jsx)(`input`,{value:V,onChange:e=>mt(e.target.value),placeholder:`搜索编号 / 标题 / 角色…`,className:`h-8 w-52 rounded-lg border border-stone-200 bg-white pl-8 pr-3 text-xs text-stone-800 outline-none transition-colors focus:border-[#3370ff]`})]}),(0,M.jsxs)(`span`,{className:`text-[11px] text-stone-400`,children:[_n,` 个故事`,H?` · 已选 ${H.ids.length}`:``]}),(0,M.jsx)(`button`,{type:`button`,disabled:!H,onClick:()=>{if(!H)return;let e=new URLSearchParams({plugin:`caseGen`,reqDoc:H.docId,stories:H.ids.join(`,`)});window.location.href=`/workbench/?${e.toString()}`},className:`${Vt} ml-auto h-8 text-xs`,children:`用选中故事生成用例`})]}):(0,M.jsxs)(`span`,{className:`ml-auto text-[11px] text-stone-400`,children:[b.length,` 份分析 · `,_n,` 个故事`]})]}),(0,M.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:pt===`doc`?b.length?(0,M.jsx)(`ul`,{className:`divide-y divide-stone-100`,children:b.map(e=>{let t=an(e.status);return(0,M.jsxs)(`li`,{className:`flex items-center gap-3 px-4 py-3 transition-colors hover:bg-stone-50`,children:[(0,M.jsx)(`button`,{type:`button`,className:`flex min-w-0 flex-1 items-center text-left`,onClick:()=>mn(e,`stories`),children:(0,M.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,M.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,M.jsx)(`span`,{className:`truncate text-sm font-medium text-stone-800`,children:_(e)}),(0,M.jsx)(C,{tone:t.tone,children:t.label})]}),(0,M.jsxs)(`span`,{className:`mt-1 flex flex-wrap items-center gap-x-3 gap-y-0.5 text-[11px] text-stone-400`,children:[(0,M.jsx)(`span`,{className:`truncate`,children:e.sourcePath||`(未指定来源)`}),(0,M.jsxs)(`span`,{children:[`用户故事 `,e.stories.length]}),(0,M.jsxs)(`span`,{children:[`需求条目 `,e.outline.length]}),(0,M.jsx)(`span`,{children:Kt(e.updatedAt)})]})]})}),(0,M.jsxs)(`button`,{type:`button`,className:`inline-flex h-8 shrink-0 items-center gap-1 rounded-md border border-stone-200 bg-white px-2.5 text-xs text-stone-700 transition-colors hover:border-[#3370ff] hover:text-[#3370ff]`,onClick:()=>mn(e,`stories`),children:[`用户故事`,(0,M.jsx)(w,{name:`chevronRight`,size:13})]}),(0,M.jsx)(`button`,{type:`button`,"aria-label":`删除 ${_(e)}`,className:`tw-icon-danger flex h-8 w-8 shrink-0 items-center justify-center rounded-md`,onClick:()=>{Q(e),Qt(!0)},children:(0,M.jsx)(w,{name:`trash`,size:14})})]},e.id)})}):(0,M.jsx)(Ge,{icon:`file`,title:`还没有分析记录`,hint:`上面选一份需求文档,系统会新建一份分析并进入用户故事拆解。`}):vn.length?(0,M.jsx)(`div`,{className:`divide-y divide-stone-100`,children:vn.map(({doc:e,rows:t})=>{let n=gt.includes(e.id),r=t.map(e=>e.story.id),i=H?.docId===e.id&&r.length>0&&r.every(e=>yn.has(e));return(0,M.jsxs)(`section`,{children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-2 bg-stone-50/70 px-3 py-1.5`,children:[(0,M.jsx)(`input`,{type:`checkbox`,"aria-label":`选中 ${_(e)} 的全部故事`,checked:i,onChange:()=>xn(e.id,r)}),(0,M.jsxs)(`button`,{type:`button`,className:`flex min-w-0 flex-1 items-center gap-1.5 text-left`,onClick:()=>_t(t=>t.includes(e.id)?t.filter(t=>t!==e.id):[...t,e.id]),children:[(0,M.jsx)(w,{name:n?`chevronRight`:`chevronDown`,size:13,className:`shrink-0 text-stone-400`}),(0,M.jsx)(`span`,{className:`truncate text-xs font-medium text-stone-700`,children:_(e)}),(0,M.jsxs)(`span`,{className:`shrink-0 text-[11px] text-stone-400`,children:[t.length,` 个故事 · `,Kt(e.updatedAt)]})]}),(0,M.jsx)(`button`,{type:`button`,className:`shrink-0 text-[11px] text-[#3370ff] hover:underline`,onClick:()=>mn(e,`stories`),children:`打开拆解`})]}),n?null:(0,M.jsx)(`ul`,{className:`divide-y divide-stone-50`,children:t.map(({story:t})=>(0,M.jsxs)(`li`,{className:`flex items-start gap-2 px-4 py-2 transition-colors hover:bg-stone-50`,children:[(0,M.jsx)(`input`,{type:`checkbox`,className:`mt-1`,"aria-label":`选中 ${t.id}`,checked:yn.has(t.id)&&H?.docId===e.id,onChange:()=>bn(e.id,t.id)}),(0,M.jsxs)(`button`,{type:`button`,className:`min-w-0 flex-1 text-left`,onClick:()=>hn(e,t.id),children:[(0,M.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,M.jsx)(`span`,{className:`shrink-0 font-mono text-[11px] text-stone-400`,children:t.id}),(0,M.jsx)(`span`,{className:`truncate text-sm text-stone-800`,children:t.title})]}),(0,M.jsxs)(`span`,{className:`mt-0.5 flex flex-wrap items-center gap-x-2.5 gap-y-0.5 text-[11px] text-stone-400`,children:[t.role?(0,M.jsxs)(`span`,{children:[`角色:`,t.role]}):null,(0,M.jsxs)(`span`,{children:[`优先级 `,t.priority]}),(0,M.jsxs)(`span`,{children:[`验收 `,t.acceptance.length]}),(0,M.jsxs)(`span`,{children:[`异常 `,t.exceptions.length]}),(0,M.jsxs)(`span`,{children:[`维度 `,t.dimensions.length]})]})]})]},`${e.id}-${t.id}`))})]},e.id)})}):(0,M.jsx)(Ge,{icon:`file`,title:V?`没有匹配的用户故事`:`还没有用户故事`,hint:V?`换个编号、标题或角色再试。`:`先按「需求说明书」选中一份文档拆解,故事会自动出现在这里。`})})]})]});return(0,M.jsxs)(`div`,{className:`flex h-full min-h-0 flex-1 flex-col p-3`,children:[lt===`list`?Qn:(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(`div`,{className:`mb-2 flex shrink-0 items-center gap-2`,children:[(0,M.jsxs)(`button`,{type:`button`,className:`inline-flex h-8 items-center gap-1 rounded-md border border-stone-200 bg-white px-2.5 text-xs text-stone-600 transition-colors hover:border-stone-300 hover:text-stone-800`,onClick:()=>{Pe(``),I(``),dn(`list`)},children:[(0,M.jsx)(w,{name:`arrowLeft`,size:14}),`返回列表`]}),(0,M.jsx)(`span`,{className:`min-w-0 truncate text-xs text-stone-400`,children:S?`用户故事 · ${_(S)}`:`用户故事`})]}),(0,M.jsxs)(`div`,{className:`flex min-h-0 flex-1 gap-4`,children:[(0,M.jsxs)(`aside`,{className:`flex w-[280px] shrink-0 flex-col gap-3 overflow-y-auto pb-1`,children:[(0,M.jsxs)(`section`,{"data-hint-width":!0,className:`rounded-xl border border-stone-200 bg-white`,children:[(0,M.jsxs)(`div`,{className:`flex items-center justify-between border-b border-stone-100 px-3.5 py-2.5`,children:[(0,M.jsx)(`p`,{className:Ut,children:`分析记录`}),(0,M.jsx)(`span`,{className:`text-[11px] tabular-nums text-stone-400`,children:b.length})]}),(0,M.jsx)(`div`,{className:`px-2 py-2`,children:b.length?(0,M.jsx)(`ul`,{className:`space-y-0.5`,children:b.map(e=>{let t=e.id===x,n=an(e.status);return(0,M.jsx)(`li`,{children:(0,M.jsx)(`button`,{type:`button`,className:`flex w-full items-start gap-2 rounded-lg px-2 py-1.5 text-left transition-colors ${t?`bg-[#eef3ff]`:`hover:bg-stone-50`}`,onClick:()=>Q(e),children:(0,M.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,M.jsx)(f,{text:_(e),matchAnchorWidth:!0,className:`block truncate text-xs ${t?`font-medium text-[#1f4fd8]`:`text-stone-700`}`}),(0,M.jsxs)(`span`,{className:`mt-0.5 flex items-center gap-1 text-[11px] text-stone-400`,children:[(0,M.jsx)(C,{tone:n.tone,children:n.label}),(0,M.jsxs)(`span`,{children:[e.stories.length,` 个故事`]})]})]})})},e.id)})}):(0,M.jsx)(`p`,{className:`px-1.5 py-1 text-xs text-stone-400`,children:`还没有分析记录,选一份来源文档开始。`})})]}),(0,M.jsxs)(`section`,{className:`rounded-xl border border-stone-200 bg-white`,children:[(0,M.jsx)(`div`,{className:`border-b border-stone-100 px-3.5 py-2.5`,children:(0,M.jsx)(`p`,{className:Ut,children:`提示词`})}),(0,M.jsxs)(`div`,{className:`px-3.5 py-3`,children:[(0,M.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,M.jsx)(Xt,{name:ce,ready:En}),(0,M.jsx)(Xt,{name:O?.file??`用户故事审查提示词.md`,ready:t.on&&!!O?.review.trim()&&!!O?.fix.trim()}),(0,M.jsx)(Xt,{name:De,ready:u.on&&!!k?.generate.trim()})]}),(0,M.jsx)(`p`,{className:`mt-2 text-[11px] ${An?`text-stone-400`:`text-amber-700`}`,children:An?`模型:${E?.model}`:`还没配置模型`})]})]}),(0,M.jsxs)(`section`,{className:`rounded-xl border border-stone-200 bg-white`,children:[(0,M.jsx)(`div`,{className:`border-b border-stone-100 px-3.5 py-2.5`,children:(0,M.jsx)(`p`,{className:Ut,children:`动作`})}),(0,M.jsxs)(`div`,{className:`space-y-2 px-3.5 py-3`,children:[(0,M.jsx)(`button`,{type:`button`,className:`${Vt} w-full`,disabled:!S||!!j||!S.sourcePath,onClick:()=>{S?.stories.length?en(!0):Nn()},children:j===`decompose`?`拆解中…`:S?.stories.length?`重新拆解`:`开始拆解`}),t.on?(0,M.jsx)(`button`,{type:`button`,className:`${Ht} w-full`,disabled:!S||!!j||!S.stories.length,onClick:()=>void Pn(),children:j===`audit`?`审查中…`:S?.check?`重新审查用户故事`:`用户故事审查`}):null,u.on?(0,M.jsx)(`button`,{type:`button`,className:`${Ht} w-full`,disabled:!S||!!j||!S.stories.length,onClick:()=>void Ln(),children:j===`testpoints`?`生成中…`:S?.testPoints?`重新生成测试点`:`生成测试点`}):null,j?(0,M.jsx)(`button`,{type:`button`,className:`${Ht} w-full`,onClick:Yn,children:`中断`}):(0,M.jsx)(`button`,{type:`button`,className:`${Ht} w-full`,disabled:!S,onClick:qn,children:`导出 Markdown`}),S&&!j?(0,M.jsx)(`button`,{type:`button`,className:`h-8 w-full rounded-md text-xs text-stone-400 transition-colors hover:bg-red-50 hover:text-red-500`,onClick:()=>Qt(!0),children:`删除这份分析`}):null]})]}),(0,M.jsxs)(`section`,{className:`flex min-h-[140px] flex-1 flex-col rounded-xl border border-stone-200 bg-white`,children:[(0,M.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between border-b border-stone-100 px-3.5 py-2.5`,children:[(0,M.jsx)(`p`,{className:Ut,children:`活动日志`}),it.length?(0,M.jsx)(`button`,{type:`button`,className:`text-[11px] text-stone-400 transition-colors hover:text-stone-600`,onClick:()=>at([]),children:`清空`}):null]}),(0,M.jsx)(`div`,{ref:nn,className:`min-h-0 flex-1 space-y-1 overflow-y-auto px-3.5 py-2.5`,children:it.length?it.map(e=>e.kind===`stage`?(0,M.jsxs)(`div`,{className:`flex items-center gap-2 pt-1.5 first:pt-0`,children:[(0,M.jsx)(`span`,{className:`h-px flex-1 bg-stone-200`,"aria-hidden":`true`}),(0,M.jsx)(`span`,{className:`shrink-0 text-[10px] font-medium text-stone-500`,children:e.text}),(0,M.jsx)(`span`,{className:`shrink-0 text-[10px] tabular-nums text-stone-300`,children:qt(e.at)}),(0,M.jsx)(`span`,{className:`h-px flex-1 bg-stone-200`,"aria-hidden":`true`})]},e.id):(0,M.jsxs)(`div`,{className:`flex gap-1.5 text-[11px] leading-relaxed`,children:[(0,M.jsx)(`span`,{className:`mt-px shrink-0 text-[10px] tabular-nums text-stone-300`,children:qt(e.at)}),(0,M.jsx)(`span`,{className:`mt-1.5 h-1.5 w-1.5 shrink-0 rounded-full ${e.kind===`error`?`bg-red-500`:e.kind===`done`?`bg-emerald-500`:e.kind===`tool`?`bg-[#3370ff]`:`bg-stone-300`}`,"aria-hidden":`true`}),(0,M.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,M.jsx)(`span`,{className:e.kind===`error`?`text-red-600`:e.kind===`done`?`text-stone-700`:`text-stone-500`,children:e.text}),e.detail?(0,M.jsx)(`span`,{className:`mt-0.5 block break-all text-[10px] leading-relaxed text-stone-400`,children:e.detail}):null]})]},e.id)):(0,M.jsx)(`p`,{className:`text-[11px] leading-relaxed text-stone-400`,children:`拆解 / 审查的过程会记在这里:抽取需求条目、写故事、跑审查与补写。`})})]})]}),(0,M.jsxs)(`section`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[st?(0,M.jsxs)(`div`,{className:`mb-2 flex items-start justify-between gap-2 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700`,children:[(0,M.jsx)(`span`,{className:`break-all`,children:st}),(0,M.jsx)(`button`,{type:`button`,className:`shrink-0 text-red-400`,onClick:()=>I(``),children:`✕`})]}):null,P&&!j?(0,M.jsxs)(`div`,{className:`mb-2 flex items-start justify-between gap-2 rounded-lg border px-3 py-2 text-xs ${P.status===`done`?`border-emerald-200 bg-emerald-50 text-emerald-700`:P.status===`error`?`border-red-200 bg-red-50 text-red-700`:`border-amber-200 bg-amber-50 text-amber-700`}`,children:[(0,M.jsxs)(`span`,{className:`break-all`,children:[(0,M.jsxs)(`span`,{className:`font-medium`,children:[P.label,P.status===`done`?`已完成`:P.status===`error`?`失败`:`已中断`]}),(0,M.jsx)(`span`,{className:`ml-1.5 opacity-80`,children:P.message}),P.finishedAt?(0,M.jsxs)(`span`,{className:`ml-1.5 opacity-60`,children:[`· `,Kt(new Date(P.finishedAt).toISOString())]}):null]}),(0,M.jsx)(`button`,{type:`button`,className:`shrink-0 opacity-60 transition-opacity hover:opacity-100`,"aria-label":`关闭上次任务提示`,onClick:cn,children:`✕`})]}):null,S?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(`header`,{className:`shrink-0 rounded-xl border border-stone-200 bg-white`,children:[(0,M.jsxs)(`div`,{className:`px-4 pt-3`,children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,M.jsx)(f,{text:_(S),matchAnchorWidth:!0,className:`min-w-0 flex-1 truncate px-1 py-0.5 text-[15px] font-semibold text-stone-800`}),j?(0,M.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1.5 text-xs text-stone-500`,children:[(0,M.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`}),N?N.message:j===`decompose`?`拆解中`:j===`audit`?`审查中`:j===`testpoints`?`生成测试点中`:j===`fix`?`补写中`:`处理中`,N&&N.total>0?(0,M.jsxs)(`span`,{className:`tabular-nums text-stone-400`,children:[Math.round(Math.min(N.done,N.total)/N.total*100),`%`]}):null]}):null,(0,M.jsx)(C,{tone:an(S.status).tone,children:an(S.status).label})]}),j?(0,M.jsx)(`div`,{className:`mt-2`,children:(0,M.jsx)(`div`,{className:`tw-run-track`,role:`progressbar`,"aria-label":`${N?.label??`任务`}进度`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":N&&N.total>0?Math.round(Math.min(N.done,N.total)/N.total*100):void 0,children:(0,M.jsx)(`div`,{className:N&&N.total>0?`tw-run-fill`:`tw-run-fill tw-run-fill--indeterminate`,style:N&&N.total>0?{width:`${Math.round(Math.min(N.done,N.total)/N.total*100)}%`}:void 0})})}):null,(0,M.jsxs)(`div`,{className:`mt-2 flex min-w-0 items-center gap-2.5 text-[11px] text-stone-400`,children:[(0,M.jsxs)(`span`,{className:`shrink-0`,children:[`故事`,` `,(0,M.jsx)(`span`,{className:`font-medium text-stone-600`,children:S.stories.length})]}),(0,M.jsx)(`span`,{className:`h-3 w-px shrink-0 bg-stone-200`,"aria-hidden":`true`}),(0,M.jsxs)(`span`,{className:`shrink-0`,children:[`条目`,` `,(0,M.jsxs)(`span`,{className:`font-medium text-stone-600`,children:[Xn,`/`,S.outline.length]}),` `,`覆盖`]}),t.on?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`span`,{className:`h-3 w-px shrink-0 bg-stone-200`,"aria-hidden":`true`}),(0,M.jsxs)(`span`,{className:`shrink-0`,children:[`缺口`,` `,(0,M.jsx)(`span`,{className:`font-medium text-stone-600`,children:Zn.length}),Dn?` · 已选 ${Dn}`:``]}),S.check?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`span`,{className:`h-3 w-px shrink-0 bg-stone-200`,"aria-hidden":`true`}),(0,M.jsxs)(`span`,{className:`shrink-0`,children:[`覆盖率`,` `,(0,M.jsx)(`span`,{className:`font-medium text-stone-600`,children:S.check.coverage.total?`${Math.round(S.check.coverage.rate*100)}%`:`—`})]})]}):null]}):null,u.on?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`span`,{className:`h-3 w-px shrink-0 bg-stone-200`,"aria-hidden":`true`}),(0,M.jsxs)(`span`,{className:`shrink-0`,children:[`测试点`,` `,(0,M.jsx)(`span`,{className:`font-medium text-stone-600`,children:S.testPoints?.points.length??0})]})]}):null,(0,M.jsxs)(`span`,{className:`ml-auto min-w-0 truncate pl-2`,children:[`来源:`,S.sourcePath]}),Cn?(0,M.jsx)(`span`,{className:`shrink-0 rounded bg-amber-50 px-1.5 py-0.5 text-[10px] text-amber-700`,children:`源文档已更新`}):null]})]}),(0,M.jsx)(`div`,{role:`tablist`,"aria-label":`需求分析视图`,className:`mt-2.5 flex items-center gap-1 border-b border-stone-100 px-2`,children:[{id:`stories`,label:`用户故事`,count:S.stories.length},{id:`check`,label:`审查结果`,count:Zn.length},{id:`outline`,label:`需求条目`,count:S.outline.length},{id:`points`,label:`测试点`,count:S.testPoints?.points.length??0}].filter(e=>(e.id!==`check`||t.on)&&(e.id!==`points`||u.on)).map(e=>{let t=L===e.id;return(0,M.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":t,className:`-mb-px flex items-center gap-1.5 border-b-2 px-3 py-2 text-xs transition-colors ${t?`border-[#3370ff] font-medium text-[#3370ff]`:`border-transparent text-stone-500 hover:text-stone-800`}`,onClick:()=>R(e.id),children:[e.label,(0,M.jsx)(`span`,{className:`rounded-full px-1.5 text-[10px] leading-4 tabular-nums ${t?`bg-[#eaf1ff] text-[#3370ff]`:`bg-stone-100 text-stone-400`}`,children:e.count})]},e.id)})})]}),(0,M.jsxs)(`div`,{className:`mt-3 min-h-0 flex-1 overflow-y-auto pr-1`,children:[L===`stories`?S.stories.length?(0,M.jsx)(`ul`,{className:`space-y-2`,children:S.stories.map((e,t)=>(0,M.jsx)(vt,{story:e,index:t,total:S.stories.length,gaps:Zn.filter(t=>t.storyId===e.id),busy:!!j,onSave:e=>Vn(t,e),onDelete:()=>Hn(t),onMove:e=>Un(t,e),domId:e.id?`req-story-${e.id}`:void 0},`${e.id}-${t}`))}):(0,M.jsx)(`div`,{className:`flex items-center justify-center rounded-xl border border-stone-200 bg-white`,children:(0,M.jsx)(Ge,{icon:`file`,title:`还没有用户故事`,hint:`点左侧「开始拆解」,会先抽需求条目再拆故事。`})}):null,L===`check`&&t.on?(0,M.jsx)(rt,{check:S.check,stories:S.stories,busy:!!j,onToggleGap:Wn,onToggleAll:Gn,onFix:()=>void In(),onReview:()=>void Pn(),onExport:Jn}):null,L===`points`&&u.on?(0,M.jsx)(ct,{doc:S,idealTitles:jt,generating:j===`testpoints`,busy:!!j,promptReady:!!k?.generate.trim(),onExportXmind:()=>void Rn(),onExportMarkdown:()=>void zn()}):null,L===`outline`?S.outline.length?(0,M.jsx)(`ul`,{className:`space-y-2`,children:S.outline.map(e=>{let t=wn.has(e.id);return(0,M.jsx)(`li`,{className:`rounded-xl border border-stone-200 bg-white px-4 py-2.5`,children:(0,M.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,M.jsx)(`span`,{className:`mt-1.5 h-1.5 w-1.5 shrink-0 rounded-full ${t?`bg-emerald-500`:`bg-amber-400`}`,"aria-hidden":`true`}),(0,M.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,M.jsxs)(`p`,{className:`text-sm text-stone-800`,children:[(0,M.jsx)(`span`,{className:`mr-1.5 rounded bg-stone-100 px-1.5 py-0.5 font-mono text-[11px] text-stone-500`,children:e.id}),e.title]}),e.quote?(0,M.jsx)(`p`,{className:`mt-1 border-l-2 border-stone-200 pl-2 text-xs leading-relaxed text-stone-400`,children:e.quote}):null]}),(0,M.jsx)(`span`,{className:`shrink-0 text-[11px] ${t?`text-emerald-600`:`text-amber-600`}`,children:t?`已覆盖`:`未覆盖`})]})},e.id)})}):(0,M.jsx)(`div`,{className:`flex items-center justify-center rounded-xl border border-stone-200 bg-white`,children:(0,M.jsx)(Ge,{icon:`file`,title:`还没有需求条目`,hint:`拆解时模型会先抽条目,覆盖率按条目统计。`})}):null]}),ot?(0,M.jsxs)(`details`,{className:`mt-2 shrink-0 rounded-xl border border-stone-200 bg-white px-3 py-2`,children:[(0,M.jsx)(`summary`,{className:`cursor-pointer text-xs text-stone-500`,children:`模型说明(本轮)`}),(0,M.jsx)(`pre`,{className:`mt-1 max-h-[180px] overflow-y-auto whitespace-pre-wrap break-words text-[11px] leading-relaxed text-stone-600`,children:ot})]}):null]}):(0,M.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center rounded-xl border border-stone-200 bg-white`,children:(0,M.jsx)(Ge,{icon:`file`,title:`还没有选来源`,hint:`左侧选一份「需求文档库」里的 Word / Excel / Markdown / txt,系统会新建一份分析。`})})]})]})]}),(0,M.jsx)(d,{open:Zt,title:`删除分析记录`,message:`确认删除「${S?_(S):``}」?故事、需求条目、体检报告与测试点都会一起清掉,来源需求文档不受影响。`,confirmLabel:`删除`,danger:`solid`,onClose:()=>Qt(!1),onConfirm:()=>void Kn()}),(0,M.jsx)(d,{open:$t,title:`重新拆解`,message:`重新拆解会用模型结果替换当前 ${S?.stories.length??0} 个用户故事,旧体检报告、测试点与需求条目也会一起清掉,编号从 US-001 重新开始。`,confirmLabel:`重新拆解`,onClose:()=>en(!1),onConfirm:()=>{en(!1),Nn()}})]})}export{Zt as default};
@@ -1 +0,0 @@
1
- import{s as e,t}from"./react.Blvh0GOs.js";import{i as n}from"./app-config.CF1xVPmo.js";import{i as r,o as i,s as a}from"./plugins.CVM1IaoC.js";import{t as o}from"./jsx-runtime.DUg_B_vD.js";import{t as s}from"./ConfirmDialog.CsMwWevK.js";import{n as c,t as ee}from"./DocsPager.v4kQH163.js";import{showToast as l}from"./Toast.BO2NFckG.js";import{a as te,c as u,d as ne,g as re,h as ie,i as ae,l as d,m as oe,n as se,p as ce,r as le,s as f,t as ue,u as de}from"./project-docs.DAw9bzgk.js";import{n as fe}from"./doc-roots.DAJP9Svr.js";import{t as pe}from"./useListAnim.BoerpmsB.js";import{t as p}from"./NamePromptDialog.CS1pTTVl.js";var m=e(t(),1),h=o(),me=5;function g({className:e=`w-4 h-4`,open:t=!1}){return(0,h.jsx)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:t?(0,h.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,h.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 _({className:e=`w-3 h-3`}){return(0,h.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,h.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,h.jsx)(`path`,{d:`m15 5 4 4`})]})}function v({className:e=`w-3 h-3`}){return(0,h.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,h.jsx)(`path`,{d:`M3 6h18`}),(0,h.jsx)(`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`}),(0,h.jsx)(`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`}),(0,h.jsx)(`path`,{d:`M10 11v6`}),(0,h.jsx)(`path`,{d:`M14 11v6`})]})}function y({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,h.jsxs)(`div`,{children:[(0,h.jsx)(`div`,{className:`group flex items-center rounded-md ${c?`bg-[#e8f0fe]`:`hover:bg-stone-100`}`,style:{paddingLeft:8+t*12},children:(0,h.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,h.jsx)(`span`,{className:`w-3.5 shrink-0`,"aria-hidden":`true`}),(0,h.jsx)(g,{open:!!(e.children.length&&s),className:`w-3.5 h-3.5 shrink-0 text-[#4176e6]`}),(0,h.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,children:e.name}),(0,h.jsxs)(`span`,{className:`shrink-0 tabular-nums text-[11px] text-stone-400`,children:[`(`,e.fileCount??0,`)`]})]})}),(0,h.jsx)(`div`,{className:`tw-collapse ${s?`is-open`:``}`,children:(0,h.jsx)(`div`,{className:`tw-collapse-inner space-y-1`,children:e.children.map(e=>(0,h.jsx)(y,{node:e,depth:t+1,activePath:n,expanded:r,globalOpen:i,onToggle:a,onSelect:o},e.path))})})]})}function he(e){return e==null?`—`:e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function b(){let[e,t]=(0,m.useState)(()=>r(`requirements`)),[o,b]=(0,m.useState)(!1),[x,S]=(0,m.useState)(null),[C,ge]=(0,m.useState)([]),[_e,ve]=(0,m.useState)(0),[w,T]=(0,m.useState)(`.`),[E,D]=(0,m.useState)([]),[ye,O]=(0,m.useState)({}),[k,be]=(0,m.useState)(!0),[A,j]=(0,m.useState)(null),[M,N]=(0,m.useState)(!1),[P,F]=(0,m.useState)(null),[xe,I]=(0,m.useState)(!1),[L,R]=(0,m.useState)(null),[z,B]=(0,m.useState)(null),[Se,V]=(0,m.useState)(1),[H,Ce]=c(me),[we,U]=(0,m.useState)(null),W=(0,m.useRef)(null),{cls:Te,play:G}=pe(),K=(0,m.useCallback)(async()=>{let e=await ae(`requirements`);ge(e.tree),ve(e.totalFiles)},[]),q=(0,m.useCallback)(async(e=w)=>{j(null);try{let[t]=await Promise.all([u(`requirements`,e),K()]);D(t.entries),T(t.path)}catch(e){j(e instanceof Error?e.message:String(e))}},[w,K]);(0,m.useEffect)(()=>{let e=i(e=>t(!!e.requirements));return n().then(()=>{t(r(`requirements`)),b(!0)}),e},[]),(0,m.useEffect)(()=>{o&&e&&(async()=>{if(!await le(`requirements`))S(!1);else try{let[e]=await Promise.all([u(`requirements`,`.`),K()]);D(e.entries),T(e.path),S(!0)}catch(e){j(e instanceof Error?e.message:String(e)),S(!0)}})()},[o,e,K]);function Ee(){be(e=>!e),O({})}async function J(e){G(),T(e),V(1),F(null),U(null),j(null);try{let t=await u(`requirements`,e);D(t.entries)}catch(e){j(e instanceof Error?e.message:String(e))}}async function De(e){I(!1),N(!0),j(null);try{await d(`requirements`,w,e),await q(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 Oe(e){if(e.type===`file`){N(!0),j(null);try{await de(`requirements`,e.path)}catch(e){j(e instanceof Error?e.message:String(e))}finally{N(!1)}}}async function ke(e){if(e?.length){N(!0),j(null);try{for(let t of Array.from(e))await re(`requirements`,w,t);await q(w),l(`已上传 ${e.length} 个文件`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);j(t),l(`上传失败:${t}`,`error`)}finally{N(!1),W.current&&(W.current.value=``)}}}function Ae(e){let t=te(C,e.path),n=t?.fileCount??0,r=t?ue(t):0;R({...e,isDir:!0,blocked:n>0||r>0,files:n,dirs:r})}function je(e){R({name:e.name,path:e.path,isDir:!1})}function Y(e,t){B({...e,isDir:t})}async function Me(){let e=L;if(e&&(R(null),!e.blocked)){N(!0),j(null);try{await se(`requirements`,e.path),P&&f(P.path,e.path)&&F(null);let t=f(w,e.path)?ne(e.path):w;await q(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 Ne(e){let t=z;if(t&&(B(null),e!==t.name)){N(!0),j(null);try{let n=await ie(`requirements`,t.path,e);await q(oe(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 Pe=(()=>{if(!L)return``;if(!L.isDir)return`删除文件「${L.name}」?将移入系统废纸篓,可随时找回。`;if(L.blocked){let e=[];return L.files&&e.push(`${L.files} 个文件`),L.dirs&&e.push(`${L.dirs} 个子文件夹`),`文件夹「${L.name}」中还有 ${e.join(`、`)},请先清空内部内容后再删除。`}return`删除文件夹「${L.name}」?将移入系统废纸篓。`})();async function Fe(e){if(e.type!==`file`)return;let t=e.name.toLowerCase();if(t.endsWith(`.md`)||t.endsWith(`.txt`)){N(!0),j(null);try{let t=await ce(`requirements`,e.path);F({path:t.path,content:t.content})}catch(e){j(e instanceof Error?e.message:String(e))}finally{N(!1)}}}if(!o)return(0,h.jsx)(`div`,{className:`tw-lib-probing`,"aria-busy":`true`,"aria-label":`正在读取插件开关`,children:(0,h.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})});if(!e)return(0,h.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(`requirements`)});if(x===null)return(0,h.jsx)(`div`,{className:`tw-lib-probing`,"aria-busy":`true`,"aria-label":`正在连接本地文档服务`,children:(0,h.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})});if(!x)return(0,h.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/H)),$=Math.min(Se,Q),Ie=X.slice(($-1)*H,$*H);function Le(e){G(),Ce(e),V(1)}return(0,h.jsxs)(`div`,{className:`flex gap-4 min-h-0`,children:[(0,h.jsxs)(`aside`,{className:`w-56 shrink-0 rounded-xl border border-stone-200 bg-white flex flex-col overflow-hidden`,children:[(0,h.jsxs)(`div`,{className:`px-3 py-2.5 border-b border-stone-100 flex items-center justify-between`,children:[(0,h.jsx)(`span`,{className:`text-xs font-semibold text-stone-500`,children:`文件夹`}),(0,h.jsx)(`button`,{type:`button`,disabled:M,onClick:()=>I(!0),className:`tw-mkdir-btn disabled:opacity-40`,children:`+ 新建`})]}),(0,h.jsxs)(`div`,{className:`flex-1 overflow-y-auto py-2 px-1 space-y-1`,children:[(0,h.jsx)(`div`,{className:`group flex items-center rounded-md ${w===`.`?`bg-[#e8f0fe]`:`hover:bg-stone-100`}`,style:{paddingLeft:8},children:(0,h.jsxs)(`button`,{type:`button`,onClick:()=>{J(`.`),Ee()},"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,h.jsx)(g,{open:k,className:`w-3.5 h-3.5 shrink-0 text-[#4176e6]`}),(0,h.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,children:`全部需求`}),(0,h.jsxs)(`span`,{className:`shrink-0 tabular-nums text-[11px] text-stone-400`,children:[`(`,_e,`)`]})]})}),(0,h.jsx)(`div`,{className:`tw-collapse ${k?`is-open`:``}`,children:(0,h.jsx)(`div`,{className:`tw-collapse-inner space-y-1`,children:C.map(e=>(0,h.jsx)(y,{node:e,depth:0,activePath:w,expanded:ye,globalOpen:k,onToggle:e=>O(t=>({...t,[e]:!(t[e]??k)})),onSelect:e=>void J(e)},e.path))})})]})]}),(0,h.jsxs)(`section`,{className:`flex-1 min-w-0 rounded-xl border border-stone-200 bg-white flex flex-col overflow-hidden`,children:[(0,h.jsxs)(`div`,{className:`px-4 py-3 border-b border-stone-100 flex items-center gap-2 flex-wrap`,children:[(0,h.jsxs)(`div`,{className:`text-sm text-stone-600 flex-1 min-w-0 truncate`,children:[(0,h.jsx)(`span`,{className:`text-stone-400`,children:fe(`requirements`)}),w===`.`?``:w]}),(0,h.jsx)(`input`,{ref:W,type:`file`,multiple:!0,accept:`.md,.txt,.docx,.xlsx,.xls,.csv,text/plain,text/markdown,text/csv,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel`,className:`hidden`,onChange:e=>void ke(e.target.files)}),(0,h.jsx)(`button`,{type:`button`,disabled:M,onClick:()=>W.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,h.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,h.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-4 space-y-4`,children:[Z.length>0&&(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`div`,{className:`text-xs font-medium text-stone-400 mb-2`,children:`子文件夹`}),(0,h.jsx)(`ul`,{className:`space-y-1`,children:Z.map(e=>(0,h.jsxs)(`li`,{className:`flex items-center gap-2 px-3 py-2 rounded-lg border border-stone-100 hover:bg-stone-50`,children:[(0,h.jsxs)(`button`,{type:`button`,className:`flex-1 min-w-0 flex items-center gap-2 text-left text-sm text-stone-700`,onClick:()=>void J(e.path),children:[(0,h.jsx)(g,{className:`w-4 h-4 text-[#4176e6] shrink-0`}),(0,h.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,children:e.name})]}),(0,h.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,h.jsx)(_,{className:`w-3.5 h-3.5`})}),(0,h.jsx)(`button`,{type:`button`,disabled:M,"aria-label":`删除 ${e.name}`,onClick:()=>Ae({name:e.name,path:e.path}),className:`tw-icon-danger p-1.5 rounded`,children:(0,h.jsx)(v,{className:`w-3.5 h-3.5`})})]},e.path))})]}),(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`div`,{className:`text-xs font-medium text-stone-400 mb-2`,children:`文件`}),X.length===0?(0,h.jsx)(`p`,{className:`text-sm text-stone-400 py-6 text-center border border-dashed border-stone-200 rounded-lg`,children:`当前文件夹为空,点击「上传文件」添加需求文档(.md / .txt / .docx / .xlsx / .csv)`}):(0,h.jsx)(`ul`,{className:`${Te}space-y-1`,children:Ie.map(e=>{let t=we===e.path;return(0,h.jsxs)(`li`,{className:`flex items-center gap-2 px-3 py-2 rounded-lg border transition-colors ${t?`border-[#c7dcff] bg-[#e8f0fe]`:`border-stone-100 hover:bg-stone-50`}`,children:[(0,h.jsxs)(`button`,{type:`button`,className:`flex-1 min-w-0 text-left`,onClick:()=>{U(e.path),Fe(e)},onDoubleClick:t=>{t.preventDefault(),Oe(e)},children:[(0,h.jsx)(`div`,{className:`text-sm text-stone-800 truncate`,"data-hint":e.name,children:e.name}),(0,h.jsx)(`div`,{className:`text-[11px] text-stone-400`,children:he(e.size)})]}),(0,h.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`,children:(0,h.jsx)(_,{className:`w-3.5 h-3.5`})}),(0,h.jsx)(`button`,{type:`button`,disabled:M,"aria-label":`删除 ${e.name}`,onClick:()=>je(e),className:`tw-icon-danger p-1.5 rounded`,children:(0,h.jsx)(v,{className:`w-3.5 h-3.5`})})]},e.path)})})]}),P?(0,h.jsxs)(`div`,{className:`rounded-lg border border-stone-200 overflow-hidden`,children:[(0,h.jsxs)(`div`,{className:`px-3 py-2 bg-stone-50 border-b border-stone-200 flex items-center justify-between`,children:[(0,h.jsx)(`span`,{className:`text-xs text-stone-500 truncate`,children:P.path}),(0,h.jsx)(`button`,{type:`button`,className:`text-xs text-stone-500 hover:text-stone-800`,onClick:()=>F(null),children:`关闭预览`})]}),(0,h.jsx)(`pre`,{className:`max-h-80 overflow-auto p-4 text-xs leading-5 text-stone-700 whitespace-pre-wrap bg-white`,children:P.content})]}):null]}),X.length>0?(0,h.jsx)(ee,{page:$,totalPages:Q,pageSize:H,busy:M,onPage:e=>{G(),V(e)},onPageSize:Le}):null]}),(0,h.jsx)(p,{open:xe,title:`新建文件夹`,onClose:()=>I(!1),onConfirm:e=>void De(e)}),(0,h.jsx)(p,{open:z!=null,title:z?.isDir?`重命名文件夹`:`重命名文件`,label:z?.isDir?`文件夹名称`:`文件名称`,initialValue:z?.name??``,lockExtension:z!=null&&!z.isDir,confirmLabel:`保存`,onClose:()=>B(null),onConfirm:e=>void Ne(e)}),(0,h.jsx)(s,{open:L!=null,title:L?.blocked?`无法删除文件夹`:L?.isDir?`删除文件夹`:`删除需求文件`,message:Pe,confirmLabel:L?.blocked?`知道了`:`删除`,cancelLabel:`取消`,danger:!L?.blocked,hideCancel:!!L?.blocked,onClose:()=>R(null),onConfirm:()=>void Me()})]})}export{b 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";import{t as r}from"./OverflowHint.pvo2Xc8R.js";import{t as i}from"./SelectDropdown.Cb-QtC-D.js";var a=e(t(),1),o=n();function s({options:e,values:t,onChange:n,placeholder:i=`选择…`,disabled:s=!1}){let[c,l]=(0,a.useState)(!1),u=(0,a.useRef)(null);(0,a.useEffect)(()=>{if(!c)return;function e(e){u.current?.contains(e.target)||l(!1)}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[c]);let d=e.filter(e=>t.includes(e.value)).map(e=>e.label),f=s||d.length===0?i:d.length<=2?d.join(`、`):`已选 ${d.length} 项`;function p(e){t.includes(e)?n(t.filter(t=>t!==e)):n([...t,e])}return(0,o.jsxs)(`div`,{className:`relative mt-1`,ref:u,children:[(0,o.jsxs)(`button`,{type:`button`,disabled:s,onClick:()=>l(e=>!e),className:s?`w-full h-9 flex items-center justify-between gap-2 rounded-lg border border-stone-200 bg-stone-50 px-3 text-sm text-left text-stone-400 cursor-not-allowed`:`tw-field-trigger w-full h-9 flex items-center justify-between gap-2 rounded-lg border border-stone-200 bg-white px-3 text-sm text-left text-stone-800 outline-none hover:border-stone-300 focus:ring-2 focus:ring-[#4176e6]/30`,children:[(0,o.jsx)(r,{text:f,className:`min-w-0 flex-1 truncate ${s||d.length?``:`text-stone-400`}`}),(0,o.jsx)(`svg`,{className:`w-4 h-4 text-stone-400 shrink-0`,viewBox:`0 0 20 20`,fill:`currentColor`,children:(0,o.jsx)(`path`,{fillRule:`evenodd`,d:`M5.23 7.21a.75.75 0 011.06.02L10 11.17l3.71-3.94a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z`,clipRule:`evenodd`})})]}),c?(0,o.jsx)(`div`,{className:`tw-select-menu tw-dsh-scroll tw-popover-anim absolute z-80 mt-1 max-h-72 w-full overflow-auto rounded-lg p-1 shadow-lg ring-1 ring-stone-200`,children:e.length===0?(0,o.jsx)(`div`,{className:`px-3 py-2 text-sm text-stone-400`,children:`暂无可选项`}):e.map(e=>{let n=t.includes(e.value);return(0,o.jsxs)(`label`,{className:`flex items-center gap-2 rounded-md px-3 py-2 text-sm text-stone-700 cursor-pointer hover:bg-stone-50`,children:[(0,o.jsx)(`input`,{type:`checkbox`,checked:n,onChange:()=>p(e.value),className:`rounded border-stone-300 text-[#4176e6] focus:ring-[#4176e6]/40`}),(0,o.jsx)(r,{text:e.label,className:`min-w-0 flex-1 truncate`})]},e.value)})}):null]})}function c({options:e,value:t,onChange:n,placeholder:s=`搜索并选择…`,disabled:c=!1,allowEmpty:l=!0,emptyLabel:u=`不选择`}){let d=(0,a.useMemo)(()=>{let t=e.map(e=>({value:e.value,label:e.label}));return l?[{value:``,label:u,muted:!0},...t]:t},[e,l,u]),f=t?d.find(e=>e.value===t):void 0;return(0,o.jsx)(i,{options:d,value:t,onChange:n,disabled:c,searchable:!0,searchPlaceholder:s,dimWhenOpen:!0,renderTrigger:(e,{open:t})=>f?(0,o.jsx)(`span`,{className:`min-w-0 flex-1 ${t?`text-stone-400`:``}`,children:(0,o.jsx)(r,{text:f.label,className:`block truncate`})}):(0,o.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-stone-400`,children:s})})}export{s as n,c as t};
@@ -1 +0,0 @@
1
- import{s as e,t}from"./react.Blvh0GOs.js";import{i as n,n as r,r as i,t as a}from"./listbox.DNxAJmEo.js";import{t as o}from"./jsx-runtime.DUg_B_vD.js";import{t as s}from"./OverflowHint.pvo2Xc8R.js";var c=e(t(),1),l=o();function u({className:e=`w-4 h-4 text-stone-400 shrink-0`}){return(0,l.jsx)(`svg`,{className:e,viewBox:`0 0 20 20`,fill:`currentColor`,children:(0,l.jsx)(`path`,{fillRule:`evenodd`,d:`M5.23 7.21a.75.75 0 011.06.02L10 11.17l3.71-3.94a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z`,clipRule:`evenodd`})})}function d({value:e,onChange:t,placeholder:n,ariaLabel:r}){let i=(0,c.useRef)(null);return(0,c.useEffect)(()=>{let e=i.current;if(!e)return;e.focus();let t=requestAnimationFrame(()=>e.focus());return()=>cancelAnimationFrame(t)},[]),(0,l.jsx)(`div`,{className:`shrink-0 border-b border-stone-100 bg-white px-1.5 py-1.5`,children:(0,l.jsxs)(`div`,{className:`relative`,children:[(0,l.jsxs)(`svg`,{className:`pointer-events-none absolute left-2 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`,strokeLinecap:`round`,"aria-hidden":`true`,children:[(0,l.jsx)(`circle`,{cx:`11`,cy:`11`,r:`7`}),(0,l.jsx)(`path`,{d:`m16.5 16.5 4 4`})]}),(0,l.jsx)(`input`,{ref:i,value:e,onChange:e=>t(e.target.value),onKeyDown:e=>{[`Escape`,`Enter`,`ArrowDown`,`ArrowUp`].includes(e.key)||e.stopPropagation()},placeholder:n,"aria-label":r,spellCheck:!1,className:`h-8 w-full rounded-md border border-stone-200 bg-stone-50 pl-7 pr-2 text-sm text-stone-700 outline-none transition-colors placeholder:text-stone-400 focus:border-[#4176e6]`})]})})}function f(){return(0,l.jsx)(`svg`,{className:`w-4 h-4 shrink-0`,viewBox:`0 0 20 20`,fill:`currentColor`,"aria-hidden":!0,children:(0,l.jsx)(`path`,{fillRule:`evenodd`,d:`M16.704 4.153a.75.75 0 01.143 1.052l-8 10.5a.75.75 0 01-1.127.075l-4.5-4.5a.75.75 0 011.06-1.06l3.894 3.893 7.48-9.817a.75.75 0 011.05-.143z`,clipRule:`evenodd`})})}function p({options:e,value:t,onChange:o,disabled:p=!1,className:m=``,compact:h=!1,ariaLabel:g,showCheck:_=!1,centerContent:v=!1,unstyled:y=!1,triggerClassName:b=``,hideChevron:x=!1,flat:S=!1,menuMinWidth:C,menuMatchTrigger:w=!0,renderTrigger:T,renderOptionPrefix:E,renderOptionAction:D,searchable:O=!1,searchPlaceholder:k=`搜索…`,triggerTitle:A,hideTriggerHint:j=!1,dimWhenOpen:M=!1}){let N=e.find(e=>e.value===t),[P,F]=(0,c.useState)(``),I=(0,c.useMemo)(()=>{let t=P.trim().toLowerCase();return t?e.filter(e=>e.label.toLowerCase().includes(t)||e.value.toLowerCase().includes(t)):e},[e,P]),L=v?`relative justify-center`:`justify-between`,R=v?`w-4 h-4 text-stone-400 shrink-0 absolute right-2.5`:void 0,z=y?`w-full flex items-center cursor-pointer outline-none disabled:cursor-not-allowed`:h?`tw-field-trigger w-full h-8 flex items-center gap-1.5 rounded-lg border border-stone-300 bg-white px-2.5 text-sm text-left text-stone-700 outline-none cursor-pointer hover:border-stone-400 focus:ring-2 focus:ring-[#4176e6]/30 focus:border-[#4176e6] disabled:bg-stone-50 disabled:text-stone-400 disabled:cursor-not-allowed`:S?`tw-field-trigger w-full h-9 flex items-center gap-2 rounded-lg border border-stone-200 bg-white px-2.5 text-sm text-left text-stone-700 outline-none cursor-pointer hover:border-stone-300 focus:ring-2 focus:ring-[#4176e6]/30 focus:border-[#4176e6] disabled:bg-stone-50 disabled:text-stone-400 disabled:cursor-not-allowed`:`tw-field-trigger w-full h-9 flex items-center gap-2 rounded-lg border border-stone-200 bg-white px-3 text-sm text-left text-stone-800 outline-none cursor-pointer hover:border-stone-300 focus:ring-2 focus:ring-[#4176e6]/30 focus:border-[#4176e6] disabled:bg-stone-50 disabled:text-stone-400 disabled:cursor-not-allowed`;return(0,l.jsx)(i,{value:t,onChange:e=>{F(``),o(e)},disabled:p,children:({open:e})=>(0,l.jsxs)(`div`,{className:`relative ${y?``:h?`inline-block`:S?``:`mt-1`} ${m}`,children:[(0,l.jsxs)(n,{"aria-label":g,onClick:()=>{O&&F(``)},className:`${z} ${L} ${b} ${M&&e?`text-stone-400`:``}`,children:[T?T(N,{open:e}):(0,l.jsx)(s,{text:A??N?.label??t,className:`min-w-0 flex-1 truncate`,disabled:j}),x?null:(0,l.jsx)(u,{className:R})]}),(0,l.jsxs)(a,{transition:!0,anchor:{to:`bottom start`,gap:4,padding:12},style:!w&&C?{minWidth:C}:void 0,className:`tw-select-menu tw-menu-anim z-80 flex max-h-64 flex-col overflow-hidden rounded-lg shadow-lg ring-1 ring-stone-200 [--anchor-max-height:16rem] focus:outline-none ${w?`w-max min-w-(--button-width) max-w-[360px]`:`w-max min-w-[150px] max-w-[360px]`}`,children:[O?(0,l.jsx)(d,{value:P,onChange:F,placeholder:k,ariaLabel:g?`${g}搜索`:`搜索选项`}):null,(0,l.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-1 overflow-auto p-1 pb-2`,children:[O&&I.length===0?(0,l.jsx)(`div`,{className:`px-3 py-2 text-sm text-stone-400`,children:`无匹配项`}):null,I.map(e=>(0,l.jsxs)(r,{value:e.value,disabled:e.disabled,className:`group flex select-none items-center gap-2 rounded-md px-3 py-2 text-sm leading-5 data-[focus]:bg-stone-50 data-[selected]:bg-(--tw-accent-soft) ${e.disabled?`cursor-not-allowed text-stone-300 data-[focus]:bg-transparent data-[selected]:bg-transparent data-[selected]:font-normal`:`cursor-pointer`} ${_?`text-stone-700 data-[selected]:text-stone-900`:`data-[selected]:text-(--tw-accent) data-[selected]:font-medium`} ${e.muted?`text-stone-400 data-[selected]:text-stone-500`:``} ${v&&!_&&!E?`justify-center px-2`:``}`,children:[_?(0,l.jsx)(`span`,{className:`w-4 shrink-0 text-[#4176e6] opacity-0 group-data-[selected]:opacity-100`,children:(0,l.jsx)(f,{})}):E?(0,l.jsx)(`span`,{className:`flex w-3.5 shrink-0 items-center justify-center`,children:E(e)}):null,(0,l.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,l.jsx)(s,{text:e.label,className:`min-w-0 w-full truncate`}),e.secondary?(0,l.jsx)(s,{text:e.secondary,className:`min-w-0 w-full truncate font-mono text-[10px] font-normal leading-4 text-stone-400`}):null]}),D?(0,l.jsx)(`span`,{className:`ml-0.5 flex shrink-0 items-center`,onPointerDown:e=>e.stopPropagation(),onClick:e=>{e.stopPropagation(),e.preventDefault()},children:D(e)}):null]},e.value))]})]})]})})}export{p as t};
@@ -1 +0,0 @@
1
- import{s as e,t}from"./react.Blvh0GOs.js";import{i as n}from"./app-config.CF1xVPmo.js";import{i as r,o as i,s as a}from"./plugins.CVM1IaoC.js";import{a as o,n as s,o as c,r as ee}from"./view-prefs.D1snIG5o.js";import{i as l,n as te,r as u,t as ne}from"./dialog.DZHZCe_T.js";import{t as d}from"./jsx-runtime.DUg_B_vD.js";import{t as f}from"./ConfirmDialog.CsMwWevK.js";import{a as p,c as m,d as h,i as re,l as ie,n as g,o as ae,r as _,s as oe,t as v}from"./ColumnResize.BgYkV9Iy.js";import{n as se,t as y}from"./DatePicker.Bkl71M49.js";import{t as ce}from"./OverflowHint.pvo2Xc8R.js";import{t as b}from"./SelectDropdown.Cb-QtC-D.js";import{showToast as x}from"./Toast.BO2NFckG.js";import{A as S,C as le,D as ue,E as de,M as fe,N as pe,P as C,S as me,T as he,_ as ge,b as w,f as _e,g as ve,j as ye,k as be,n as T,u as xe,v as E,w as Se,x as Ce,y as D}from"./tasks.BNBkrFC3.js";import{a as O,c as k,i as we,l as A,n as j,o as M,r as N,s as P,t as F}from"./DrawerField.C0ehOlDt.js";var I=e(t(),1),L=d(),Te=8e3,Ee=[{key:`select`,width:32,min:28},{key:`index`,width:36,min:28},{key:`title`,width:300,min:160},{key:`status`,width:104,min:76},{key:`task`,width:156,min:96},{key:`priority`,width:104,min:84},{key:`start`,width:108,min:88},{key:`due`,width:108,min:88},{key:`end`,width:108,min:88},{key:`cycle`,width:64,min:52},{key:`remain`,width:86,min:64},{key:`note`,width:160,min:100},{key:`filler`,filler:!0},{key:`action`,width:88,min:72}],De=[`title`,`status`,`priority`,`linkedTask`,`startDate`,`dueDate`,`note`],Oe={in_progress:`bg-[#3370ff] text-white`,pending:`bg-stone-400 text-white`,done:`bg-[#34c724] text-white`,cancelled:`bg-stone-300 text-stone-600`,overdue:`bg-[#f54a45] text-white`},ke={in_progress:`bg-[#e1eaff] text-[#1f4ec2]`,pending:`bg-stone-100 text-stone-600`,done:`bg-[#d9f5d2] text-[#1d7a12]`,cancelled:`bg-stone-100 text-stone-400`,overdue:`bg-[#fee4e3] text-[#c02a26]`},R={urgent_important:`bg-[#f54a45] text-white`,important:`bg-[#ff8800] text-white`,urgent:`bg-[#f7ba1e] text-stone-800`,normal:`bg-stone-200 text-stone-600`,"":`bg-transparent text-stone-400`},Ae={pending:`bg-stone-400`,in_progress:`bg-[#3370ff]`,done:`bg-[#34c724]`,overdue:`bg-[#f54a45]`,cancelled:`bg-stone-300`},je={urgent_important:`bg-[#f54a45]`,important:`bg-[#ff8800]`,urgent:`bg-[#f7ba1e]`,normal:`bg-stone-300`,"":`border border-stone-300 bg-transparent`},z={status:`按状态分组`,priority:`按紧急程度分组`,none:`不分组`},Me=[`status`,`priority`,`none`],Ne=`todos.group-by`,Pe=[`in_progress`,`pending`,`overdue`,`done`,`cancelled`],Fe=D.map(e=>({value:e,label:w[e]})),Ie=[{value:``,label:`未设置`},...ge.map(e=>({value:e,label:E[e]}))],Le=Object.keys(z).map(e=>({value:e,label:z[e]})),Re=[{value:`all`,label:`全部紧急程度`},...ge.map(e=>({value:e,label:E[e]}))],ze=Re.map(e=>e.value),Be=`todos.priority-filter`,Ve=`todos.search`,He=`h-8 w-full min-w-0 truncate rounded-md border border-transparent bg-transparent px-1.5 text-sm text-stone-800 outline-none transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white placeholder:text-stone-300`;function Ue(e){let{value:t,placeholder:n,muted:r,autoFocus:i,onChange:a,onCommit:o,onCancel:s}=e;return(0,L.jsx)(`input`,{type:`text`,value:t,placeholder:n,autoFocus:i,onChange:e=>a(e.target.value),onBlur:o,onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),e.currentTarget.blur()):e.key===`Escape`&&(e.preventDefault(),s(),e.currentTarget.blur())},className:`${He} ${r&&!t?`text-stone-300`:``}`})}function We(e){let{value:t,onChange:n,onCommit:r,onCancel:i}=e,[a,o]=(0,I.useState)(!1);return a?(0,L.jsx)(Ue,{value:t,placeholder:`—`,autoFocus:!0,onChange:n,onCommit:()=>{o(!1),r()},onCancel:()=>{o(!1),i()}}):(0,L.jsx)(`button`,{type:`button`,onClick:()=>o(!0),className:`block h-8 w-full min-w-0 truncate rounded-md border border-transparent px-1.5 text-left text-sm leading-8 text-stone-700 transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:outline-none`,children:t||(0,L.jsx)(`span`,{className:`text-stone-300`,children:`—`})})}function Ge(e){return(0,L.jsx)(y,{value:e.value,onChange:e.onChange,placeholder:`选择日期`,className:`h-8 rounded-md border border-transparent px-1.5 text-sm text-stone-800 tabular-nums transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white`})}function Ke(e){let{open:t,item:n,preset:r,tasks:i,tasksOn:a,onClose:o,onSaved:s}=e,[c,ee]=(0,I.useState)({title:``}),[d,f]=(0,I.useState)(``),[p,m]=(0,I.useState)(!1),[h,re]=(0,I.useState)(!0);(0,I.useEffect)(()=>{t&&(f(``),m(!1),re(!0),ee(n?{title:n.title,status:n.status,priority:n.priority,linkedTask:n.linkedTask,taskId:n.taskId,startDate:n.startDate,dueDate:n.dueDate,note:n.note}:{title:``,status:`pending`,priority:``,startDate:S(),dueDate:S(),...r}))},[t,n,r]);let ie=[{value:``,label:`不关联`},..._e(i.filter(e=>e.status!==`closed`&&e.status!==`cancelled`||e.id===n?.taskId)).map(e=>({value:e.id,label:e.title}))];function g(e){ee(t=>({...t,...e}))}let ae=ye({startDate:c.startDate??``,dueDate:c.dueDate??``}),_=pe({dueDate:c.dueDate??``}),oe=de(c.status??`pending`),v=oe?se((n&&de(n.status)?n.taskEndDate:``)||S()):``,le=_===null?``:c.status===`done`?`已完成`:c.status===`cancelled`?`已取消`:_<0?`逾期 ${Math.abs(_)} 天`:_===0?`今天截止`:`${_} 天`;async function ue(){let e=(c.title??``).trim();if(!e)f(`请填写待办名称`);else if(c.startDate&&c.dueDate&&c.dueDate<c.startDate)f(`截止日期不能早于开始日期`);else{m(!0),f(``);try{let t={...c,title:e};n?await C(n.id,t):await Ce([t],{mode:`manual`}),await s(),x(n?`已保存待办`:`已新建待办`,`success`),o()}catch(e){let t=e instanceof Error?e.message:String(e);f(t),x(`保存待办失败:${t}`,`error`)}finally{m(!1)}}}return(0,L.jsxs)(u,{open:t,onClose:o,transition:!0,className:`relative z-100`,children:[(0,L.jsx)(ne,{transition:!0,className:`tw-dialog-backdrop-anim fixed inset-0 bg-black/25`,"aria-hidden":`true`}),(0,L.jsx)(`div`,{className:`fixed inset-0 flex justify-end`,children:(0,L.jsxs)(l,{transition:!0,className:`tw-drawer-panel-anim flex h-full w-full max-w-[520px] flex-col border-l border-stone-200 bg-white shadow-2xl`,children:[(0,L.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-3 border-b border-stone-100 px-6 py-4`,children:[(0,L.jsx)(te,{className:`text-base font-semibold text-stone-900`,children:n?`待办详情`:`新建待办`}),(0,L.jsx)(`button`,{type:`button`,onClick:o,"aria-label":`关闭`,className:`flex h-7 w-7 items-center justify-center rounded-md text-stone-400 transition-colors hover:bg-stone-100 hover:text-stone-700`,children:`✕`})]}),(0,L.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto py-3`,children:[(0,L.jsx)(j,{icon:(0,L.jsx)(A,{}),label:`待办名称`,children:(0,L.jsx)(`input`,{autoFocus:!0,value:c.title,onChange:e=>g({title:e.target.value}),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),ue())},placeholder:`请输入内容`,className:F})}),(0,L.jsx)(j,{icon:(0,L.jsx)(P,{}),label:`待办状态`,children:(0,L.jsx)(N,{ariaLabel:`待办状态`,menuMinWidth:140,options:Fe,value:c.status??`pending`,onChange:e=>g({status:e}),label:w[c.status??`pending`],optionDotClassName:e=>Ae[e]})}),(0,L.jsxs)(`button`,{type:`button`,onClick:()=>re(e=>!e),"aria-expanded":h,className:`flex w-full items-center gap-2 px-6 py-2 text-left text-sm text-stone-600 hover:bg-stone-50`,children:[(0,L.jsx)(`span`,{className:`flex h-4 w-4 items-center justify-center text-stone-400`,children:(0,L.jsx)(k,{})}),(0,L.jsx)(`span`,{children:`任务详情`}),(0,L.jsx)(`span`,{className:`text-stone-400`,children:(0,L.jsx)(we,{open:h})})]}),h?(0,L.jsxs)(`div`,{className:`ml-[42px] border-l border-stone-100 pl-1`,children:[(0,L.jsx)(j,{icon:(0,L.jsx)(k,{}),label:`所属任务`,children:a?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(b,{flat:!0,searchable:!0,searchPlaceholder:`搜索任务…`,ariaLabel:`所属任务`,menuMinWidth:220,options:ie,value:c.taskId??``,onChange:e=>{let t=i.find(t=>t.id===e);g({taskId:e,linkedTask:t?.title??``,...t?{priority:t.priority}:{}})},renderTrigger:()=>(0,L.jsx)(ce,{text:c.taskId?i.find(e=>e.id===c.taskId)?.title??``:c.linkedTask||`请选择任务`,className:`min-w-0 flex-1 truncate ${c.taskId||c.linkedTask?`text-stone-800`:`text-stone-400`}`})}),i.length===0?(0,L.jsx)(`p`,{className:`mt-1 px-2 text-xs text-stone-400`,children:`任务管理里还没有任务,可到「任务管理」新建后再关联。`}):null]}):(0,L.jsx)(`div`,{className:`flex h-9 items-center rounded-md bg-stone-50 px-2 text-sm text-stone-400`,children:(0,L.jsx)(`span`,{className:`truncate`,children:c.linkedTask?`${c.linkedTask}(任务管理插件未启用)`:`任务管理插件未启用,无法关联任务`})})}),(0,L.jsx)(j,{icon:(0,L.jsx)(P,{}),label:`重要紧急程度`,children:(()=>{let e=c.taskId?i.find(e=>e.id===c.taskId):void 0;return e?(0,L.jsxs)(`div`,{className:`flex h-9 items-center gap-2 px-2 text-sm`,children:[(0,L.jsx)(`span`,{className:e.priority?`text-stone-800`:`text-stone-400`,children:e.priority?T[e.priority]:`任务未设置`}),(0,L.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:`跟随所属任务`})]}):(0,L.jsx)(N,{ariaLabel:`重要紧急程度`,menuMinWidth:140,options:Ie,value:c.priority??``,onChange:e=>g({priority:e}),label:c.priority?E[c.priority]:`未设置`,optionDotClassName:e=>je[e]})})()}),(0,L.jsx)(j,{icon:(0,L.jsx)(O,{}),label:`结束日期`,children:(0,L.jsxs)(`div`,{className:`flex h-9 items-center px-2 text-sm tabular-nums`,"aria-readonly":`true`,children:[v?(0,L.jsx)(`span`,{className:`text-stone-800`,children:v}):(0,L.jsx)(`span`,{className:`text-stone-400`,children:`待办未完成`}),(0,L.jsx)(`span`,{className:`ml-2 text-[11px] text-stone-400`,children:oe?`按完成日期自动记录`:`状态为已完成 / 已取消时自动记录`})]})})]}):null,(0,L.jsx)(j,{icon:(0,L.jsx)(O,{}),label:`开始日期`,children:(0,L.jsx)(y,{value:c.startDate??``,onChange:e=>g({startDate:e}),className:`${F} tabular-nums`})}),(0,L.jsx)(j,{icon:(0,L.jsx)(O,{}),label:`截止日期`,children:(0,L.jsx)(y,{value:c.dueDate??``,onChange:e=>g({dueDate:e}),className:`${F} tabular-nums`})}),(0,L.jsx)(j,{icon:(0,L.jsx)(M,{}),label:`待办周期`,children:(0,L.jsx)(`div`,{className:`px-2 pt-1.5 text-sm text-stone-500`,children:ae===null?`—`:`${ae} 天`})}),(0,L.jsx)(j,{icon:(0,L.jsx)(M,{}),label:`剩余天数`,children:(0,L.jsx)(`div`,{className:`px-2 pt-1.5 text-sm text-stone-500`,children:le||`—`})}),(0,L.jsx)(j,{icon:(0,L.jsx)(A,{}),label:`备注`,children:(0,L.jsx)(`textarea`,{value:c.note??``,onChange:e=>g({note:e.target.value}),rows:4,placeholder:`请输入内容`,className:`w-full resize-y rounded-md border border-transparent bg-transparent px-2 py-1.5 text-sm text-stone-800 outline-none transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white placeholder:text-stone-400`})}),d?(0,L.jsx)(`div`,{className:`mx-6 mt-2 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700`,children:d}):null]}),(0,L.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-stone-100 px-6 py-3`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:o,disabled:p,className:`h-8 rounded-lg border border-stone-200 px-4 text-sm text-stone-600 transition-colors hover:bg-stone-100 disabled:opacity-40`,children:`取消`}),(0,L.jsx)(`button`,{type:`button`,onClick:()=>void ue(),disabled:p,className:`h-8 rounded-lg bg-[#3370ff] px-4 text-sm font-medium text-white transition-colors hover:bg-[#2b5fd9] disabled:opacity-40`,children:p?`保存中…`:n?`保存`:`新建`})]})]})})]})}function B(){let[e,t]=(0,I.useState)(!1),[l,te]=(0,I.useState)(!0),[u,ne]=(0,I.useState)(null),[d,T]=(0,I.useState)([]),[D,O]=(0,I.useState)([]),[k,we]=(0,I.useState)(!1),[A,j]=(0,I.useState)(null),[M,N]=(0,I.useState)(!1),[P,F]=(0,I.useState)(()=>ee(Ve)),[z,He]=(0,I.useState)(()=>s(Be,ze,`all`)),[B,qe]=(0,I.useState)(()=>s(Ne,Me,`status`)),[Je,Ye]=(0,I.useState)({}),[V,Xe]=(0,I.useState)({});function Ze(e){o(Ne,e),qe(e)}function Qe(e){o(Be,e),He(e)}function $e(e){c(Ve,e),F(e)}let[et,tt]=(0,I.useState)({}),[H,U]=(0,I.useState)(null),[W,G]=(0,I.useState)(null),[nt,rt]=(0,I.useState)(!1),[it,at]=(0,I.useState)(null),K=(0,I.useRef)(!0),ot=(0,I.useRef)(!1),st=(0,I.useRef)(!1),q=ie(`lh:todos:cols:v1`,Ee),ct=h(`todos`),lt=H!==null,ut=(0,I.useRef)(H);ut.current=H;let dt=(0,I.useRef)(!1),ft=(0,I.useRef)(async()=>{});ft.current=bt,(0,I.useEffect)(()=>(K.current=!0,()=>{K.current=!1}),[]),(0,I.useEffect)(()=>{if(!lt)return;let e=e=>{let t=e.target;if(!(t instanceof Element)||t.closest(`.tw-new-row`)||t.closest(`.tw-date-panel`)||t.closest(`.tw-select-menu`))return;let n=ut.current;if(!n)return;if(n.title.trim()){ft.current();return}let r=S();!n.note.trim()&&!n.taskId&&n.status===n.baseStatus&&n.priority===n.basePriority&&n.startDate===r&&n.dueDate===r&&U(null)};return document.addEventListener(`pointerdown`,e,!0),()=>document.removeEventListener(`pointerdown`,e,!0)},[lt]);let J=(0,I.useCallback)(async()=>{try{let[e,t]=await Promise.all([ue(),k?xe().catch(()=>[]):Promise.resolve([])]);if(!K.current)return;let n=t;if(!ot.current&&k){ot.current=!0;let r=new Set(e.filter(e=>e.status===`pending`||e.status===`in_progress`).map(e=>e.taskId).filter(Boolean)),i=t.filter(e=>r.has(e.id)&&(e.status===`pool`||e.status===`done`));if(i.length){let e=await Promise.all(i.map(e=>ve(e.id,{status:`in_progress`}).catch(()=>null))),r=new Map(e.filter(e=>!!e).map(e=>[e.id,e]));n=t.map(e=>r.get(e.id)??e)}}T(e),O(n),j(null)}catch(e){if(!K.current)return;j(e instanceof Error?e.message:String(e))}},[k]);(0,I.useEffect)(()=>{let e=i(e=>{te(!!e.todos),we(!!e.tasks)});return n().then(()=>{te(r(`todos`)),we(r(`tasks`)),t(!0)}),e},[]),(0,I.useEffect)(()=>{e&&l&&(async()=>{let e=await Se();K.current&&(e?(await J(),K.current&&ne(!0)):ne(!1))})()},[e,l,J]),(0,I.useEffect)(()=>{if(u!==!0)return;let e=window.setInterval(()=>{st.current||J()},Te),t=()=>{st.current||J()};return window.addEventListener(`focus`,t),()=>{window.clearInterval(e),window.removeEventListener(`focus`,t)}},[u,J]),(0,I.useEffect)(()=>{if(!k||u!==!0||D.length===0)return;let e=d.filter(e=>!e.taskId&&e.linkedTask.trim());if(!e.length)return;let t=!1;return(async()=>{let n=[];for(let t of e){let e=D.find(e=>e.title.trim()===t.linkedTask.trim());if(e)try{n.push(await C(t.id,{taskId:e.id}))}catch{}}!t&&n.length&&T(e=>e.map(e=>n.find(t=>t.id===e.id)??e))})(),()=>{t=!0}},[k,u,d,D]);function pt(e,t,n){tt(r=>({...r,[e]:{...r[e],[t]:n}}))}function Y(e){tt(t=>{if(!(e in t))return t;let n={...t};return delete n[e],n})}let mt=(0,I.useMemo)(()=>[{value:``,label:`不关联`},..._e(D.filter(e=>e.status!==`closed`&&e.status!==`cancelled`)).map(e=>({value:e.id,label:e.title}))],[D]);function ht(e){return e.taskId?D.find(t=>t.id===e.taskId)?.title??e.linkedTask:e.linkedTask}function gt(e){return e.taskId?D.find(t=>t.id===e.taskId):void 0}function _t(e){let t=gt(e);return t?t.priority:e.priority}async function X(e,t){T(n=>n.map(n=>n.id===e?{...n,...t}:n));try{let n=await C(e,t);if(!K.current)return;T(t=>t.map(t=>t.id===e?n:t)),j(null),t.taskId&&await J()}catch(e){j(e instanceof Error?e.message:String(e)),await J()}}async function vt(e){let t=et[e],n=d.find(t=>t.id===e);if(!t||!n)return;let r={},i=n;for(let e of De){let n=t[e];n!==void 0&&String(i[e]??``)!==String(n)&&(r[e]=n)}if(!Object.keys(r).length)Y(e);else if(typeof r.title==`string`&&!r.title.trim())j(`待办名称不能为空`),Y(e);else try{let t=await C(e,r);if(!K.current)return;T(n=>n.map(n=>n.id===e?t:n)),tt(t=>{let n=t[e];if(!n)return t;let i={...n};for(let e of Object.keys(r))String(i[e]??``)===String(r[e]??``)&&delete i[e];if(!Object.keys(i).length){let n={...t};return delete n[e],n}return{...t,[e]:i}}),j(null)}catch(t){j(t instanceof Error?t.message:String(t)),Y(e)}}function yt(e){let t=e.newStatus??`pending`,n=e.newPriority??``;U({groupKey:e.key,title:``,status:t,priority:n,taskId:``,startDate:S(),dueDate:S(),note:``,baseStatus:t,basePriority:n}),Ye(t=>({...t,[e.key]:!1}))}async function bt(){let e=ut.current;if(!e||dt.current)return;let t=e.title.trim();if(t){dt.current=!0,rt(!0);try{let n=D.find(t=>t.id===e.taskId);await Ce([{title:t,status:e.status,priority:e.priority,taskId:e.taskId,linkedTask:n?.title??``,startDate:e.startDate,dueDate:e.dueDate,note:e.note}],{mode:`manual`}),ut.current===e&&U(null),j(null),await J()}catch(e){j(e instanceof Error?e.message:String(e))}finally{dt.current=!1,K.current&&rt(!1)}}}async function xt(){let e=W;if(e){G(null),N(!0),j(null);try{await me(e.map(e=>e.id)),Xe({}),await J(),x(e.length>1?`已删除 ${e.length} 条待办`:`已删除待办`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);j(t),x(`删除待办失败:${t}`,`error`)}finally{K.current&&N(!1)}}}let Z=S(),St=(0,I.useMemo)(()=>d.map(e=>{let t=e.taskId?D.find(t=>t.id===e.taskId):void 0;return t?{...e,priority:t.priority}:e}),[d,D]),Ct=(0,I.useMemo)(()=>he(St,{status:`all`,priority:z,keyword:P,today:Z}),[St,z,P,Z]),Q=(0,I.useMemo)(()=>be(Ct),[Ct]),wt=(0,I.useMemo)(()=>B===`none`?[{key:`all`,label:`全部待办`,pill:`bg-stone-500 text-white`,items:Q}]:B===`priority`?[...ge,``].map(e=>({key:`priority:${e||`none`}`,label:e?E[e]:`未设置`,pill:e?R[e]:`bg-stone-300 text-stone-600`,items:Q.filter(t=>t.priority===e),newPriority:e})):Pe.map(e=>({key:`status:${e}`,label:w[e],pill:Oe[e],items:Q.filter(t=>le(t,Z)===e),newStatus:e===`overdue`?`pending`:e})),[B,Q,Z]).filter(e=>e.items.length>0||H?.groupKey===e.key&&!!H),Tt=Object.keys(V).filter(e=>V[e]),$=(0,I.useMemo)(()=>{let e={total:d.length,pending:0,in_progress:0,done:0,overdue:0};for(let t of d){let n=le(t,Z);n===`overdue`?e.overdue+=1:n===`pending`?e.pending+=1:n===`in_progress`?e.in_progress+=1:n===`done`&&(e.done+=1)}return e},[d,Z]);return e?l?u===null?(0,L.jsx)(`div`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,"aria-busy":`true`,"aria-label":`正在连接待办服务`,children:(0,L.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center`,children:(0,L.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})}):u?(0,L.jsxs)(`section`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,L.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-3 border-b border-stone-100 px-4 py-3`,children:[(0,L.jsxs)(`div`,{className:`text-sm text-stone-600`,children:[`共 `,(0,L.jsx)(`span`,{className:`font-medium text-stone-800`,children:$.total}),` 条`,(0,L.jsxs)(`span`,{className:`text-stone-400`,children:[` `,`· 待开始 `,$.pending,` · 进行中 `,$.in_progress,` · 已完成 `,$.done,$.overdue?` · 已延期 ${$.overdue}`:``]})]}),(0,L.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[(0,L.jsx)(`input`,{value:P,onChange:e=>$e(e.target.value),placeholder:`搜索待办…`,className:`h-9 w-52 rounded-lg border border-stone-200 px-3 text-sm text-stone-800 outline-none focus:border-[#3370ff]`}),(0,L.jsx)(b,{flat:!0,className:`w-[132px]`,ariaLabel:`分组方式`,options:Le,value:B,onChange:e=>Ze(e)}),(0,L.jsx)(b,{flat:!0,className:`w-[136px]`,ariaLabel:`紧急程度筛选`,options:Re,value:z,onChange:e=>Qe(e)}),(0,L.jsx)(`button`,{type:`button`,disabled:M||Tt.length===0,onClick:()=>G(d.filter(e=>V[e.id])),className:`h-9 shrink-0 rounded-lg border border-red-200 px-3 text-sm font-medium whitespace-nowrap text-red-600 hover:bg-red-50 disabled:opacity-40`,children:`批量删除`}),(0,L.jsx)(`button`,{type:`button`,disabled:M,onClick:()=>at({item:null}),className:`h-9 shrink-0 rounded-lg bg-[#3370ff] px-3 text-sm font-medium whitespace-nowrap text-white hover:bg-[#2b5fd9] disabled:opacity-40`,children:`+ 新建待办`})]})]}),A?(0,L.jsxs)(`div`,{className:`mx-4 mt-3 flex shrink-0 items-start gap-2 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700`,children:[(0,L.jsx)(`span`,{className:`min-w-0 flex-1`,children:A}),(0,L.jsx)(`button`,{type:`button`,onClick:()=>j(null),"aria-label":`关闭`,className:`-mr-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded text-red-700/70 hover:bg-red-100 hover:text-red-900`,children:`✕`})]}):null,(0,L.jsx)(`div`,{ref:ct,className:`tw-scroll-x min-h-0 flex-1 overflow-auto`,onFocusCapture:()=>{st.current=!0},onBlurCapture:()=>{window.setTimeout(()=>{st.current=!!document.activeElement?.closest(`.tw-todo-table`)},0)},children:(0,L.jsxs)(`table`,{className:`tw-todo-table tw-sticky-table w-full table-fixed text-sm`,style:q.tableStyle,children:[(0,L.jsx)(`colgroup`,{children:Ee.map(e=>(0,L.jsx)(`col`,{style:q.widthOf(e.key)?{width:q.widthOf(e.key)}:void 0},e.key))}),(0,L.jsx)(`thead`,{className:`tw-table-head sticky top-0 z-10 text-xs text-stone-500`,children:(0,L.jsxs)(`tr`,{children:[(0,L.jsx)(`th`,{className:p,children:(0,L.jsx)(`input`,{type:`checkbox`,"aria-label":`全选可见待办`,checked:Q.length>0&&Q.every(e=>V[e.id]),onChange:e=>{let t=e.target.checked;Xe(e=>{let n={...e};for(let e of Q)t?n[e.id]=!0:delete n[e.id];return n})}})}),(0,L.jsx)(`th`,{className:oe,style:{"--tw-sticky-left":`32px`},"aria-label":`行号`}),(0,L.jsxs)(`th`,{className:ae,style:{"--tw-sticky-left":`68px`},children:[`待办名称`,(0,L.jsx)(v,{...q.resizeProps(`title`)})]}),(0,L.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`待办状态`,(0,L.jsx)(v,{...q.resizeProps(`status`)})]}),(0,L.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`所属任务`,(0,L.jsx)(v,{...q.resizeProps(`task`)})]}),(0,L.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`紧急程度`,(0,L.jsx)(v,{...q.resizeProps(`priority`)})]}),(0,L.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`开始日期`,(0,L.jsx)(v,{...q.resizeProps(`start`)})]}),(0,L.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`截止日期`,(0,L.jsx)(v,{...q.resizeProps(`due`)})]}),(0,L.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`结束日期`,(0,L.jsx)(v,{...q.resizeProps(`end`)})]}),(0,L.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`周期`,(0,L.jsx)(v,{...q.resizeProps(`cycle`)})]}),(0,L.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`剩余`,(0,L.jsx)(v,{...q.resizeProps(`remain`)})]}),(0,L.jsxs)(`th`,{className:`relative px-2 py-2 text-left font-medium whitespace-nowrap`,children:[`备注`,(0,L.jsx)(v,{...q.resizeProps(`note`)})]}),(0,L.jsx)(`th`,{"aria-hidden":`true`}),(0,L.jsx)(`th`,{className:m,children:`操作`})]})}),wt.map(e=>{let t=Je[e.key]===!0;return(0,L.jsxs)(`tbody`,{children:[(0,L.jsx)(`tr`,{className:`bg-white`,children:(0,L.jsx)(`td`,{colSpan:14,className:`px-2 py-0 pt-3 pb-1.5`,children:(0,L.jsxs)(`button`,{type:`button`,onClick:()=>Ye(n=>({...n,[e.key]:!t})),className:`flex items-center gap-2 rounded-md px-1 py-0.5 text-left hover:bg-stone-50`,"aria-expanded":!t,children:[(0,L.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`12`,height:`12`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.4`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,className:`text-stone-400 transition-transform ${t?`-rotate-90`:``}`,children:(0,L.jsx)(`path`,{d:`m6 9 6 6 6-6`})}),(0,L.jsx)(`span`,{className:`rounded-md px-2 py-0.5 text-xs font-medium ${e.pill}`,children:e.label}),(0,L.jsxs)(`span`,{className:`text-xs text-stone-400 tabular-nums`,children:[e.items.length,` 条记录`]})]})})}),t?null:e.items.map((e,t)=>{let n=et[e.id]??{},r={...e,...n},i=le(r,Z),a=ye(r),o=pe(r,Z),s=o===null?`—`:r.status===`done`?`已完成`:r.status===`cancelled`?`已取消`:o<0?`逾期 ${Math.abs(o)} 天`:o===0?`今天截止`:`${o} 天`;return(0,L.jsxs)(`tr`,{className:`group/row hover:bg-[#f7f8fa]`,children:[(0,L.jsx)(`td`,{className:g,children:(0,L.jsx)(`input`,{type:`checkbox`,"aria-label":`选择 ${e.title}`,checked:!!V[e.id],onChange:t=>Xe(n=>{let r={...n};return t.target.checked?r[e.id]=!0:delete r[e.id],r})})}),(0,L.jsx)(`td`,{className:`${_} text-xs text-stone-400 tabular-nums`,style:{"--tw-sticky-left":`32px`},children:t+1}),(0,L.jsx)(`td`,{className:g,style:{"--tw-sticky-left":`68px`},children:(0,L.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1`,children:[e.source===`ai`?(0,L.jsx)(`span`,{className:`shrink-0 rounded bg-[#e1eaff] px-1 py-px text-[10px] text-[#1f4ec2]`,title:`AI 记录`,children:`AI`}):null,(0,L.jsx)(Ue,{value:r.title,placeholder:`输入待办名称`,onChange:t=>pt(e.id,`title`,t),onCommit:()=>void vt(e.id),onCancel:()=>Y(e.id)})]})}),(0,L.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,L.jsx)(b,{unstyled:!0,hideChevron:!0,centerContent:!0,ariaLabel:`待办状态`,menuMinWidth:120,options:Fe,value:e.status,onChange:t=>void X(e.id,{status:t}),triggerClassName:`h-7 w-full rounded-md px-2 text-center text-xs font-medium focus:ring-2 focus:ring-[#3370ff]/30 ${ke[i]}`,renderTrigger:()=>(0,L.jsx)(`span`,{className:`w-full truncate text-center`,children:w[i]}),renderOptionPrefix:e=>(0,L.jsx)(`span`,{className:`h-2 w-2 rounded-full ${Ae[e.value]}`})})}),(0,L.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:k?(0,L.jsx)(b,{unstyled:!0,searchable:!0,searchPlaceholder:`搜索任务…`,ariaLabel:`所属任务`,menuMinWidth:220,options:mt,value:r.taskId,onChange:t=>{let n=D.find(e=>e.id===t);X(e.id,{taskId:t,linkedTask:n?.title??``,...n?{priority:n.priority}:{}})},triggerClassName:`h-8 w-full rounded-md px-1.5 text-sm hover:border-stone-200`,renderTrigger:()=>(0,L.jsx)(ce,{text:ht(r)||`未关联`,className:`min-w-0 flex-1 truncate ${ht(r)?`text-stone-800`:`text-stone-300`}`})}):(0,L.jsx)(`span`,{className:`block truncate px-1.5 text-xs text-stone-400`,children:ht(r)?`${ht(r)} · 插件未启用`:`任务管理插件未启用`})}),(0,L.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:gt(r)?(0,L.jsx)(`span`,{title:`跟随所属任务的紧急程度`,className:`flex h-7 w-full items-center justify-center truncate rounded-md px-2 text-center text-xs font-medium ${R[_t(r)]??`text-stone-300`}`,children:_t(r)?E[_t(r)]:`未设置`}):(0,L.jsx)(b,{unstyled:!0,hideChevron:!0,centerContent:!0,ariaLabel:`紧急程度`,menuMinWidth:128,options:Ie,value:e.priority,onChange:t=>void X(e.id,{priority:t}),triggerClassName:`h-7 w-full rounded-md px-2 text-center text-xs font-medium focus:ring-2 focus:ring-[#3370ff]/30 ${R[e.priority]}`,renderTrigger:()=>(0,L.jsx)(`span`,{className:`w-full truncate text-center`,children:e.priority?E[e.priority]:`未设置`}),renderOptionPrefix:e=>(0,L.jsx)(`span`,{className:`h-2 w-2 rounded-full ${je[e.value]}`})})}),(0,L.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,L.jsx)(Ge,{value:r.startDate,onChange:t=>void X(e.id,{startDate:t})})}),(0,L.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,L.jsx)(Ge,{value:r.dueDate,onChange:t=>void X(e.id,{dueDate:t})})}),(0,L.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap tabular-nums`,children:fe(r)?(0,L.jsx)(`span`,{className:`text-stone-500`,children:se(fe(r))}):(0,L.jsx)(`span`,{className:`text-stone-400`,children:`待办未完成`})}),(0,L.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap text-stone-500 tabular-nums`,children:a===null?`—`:`${a} 天`}),(0,L.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap tabular-nums ${o!==null&&o<0&&i!==`done`&&i!==`cancelled`?`font-medium text-[#c02a26]`:`text-stone-500`}`,children:s}),(0,L.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,L.jsx)(We,{value:r.note,onChange:t=>pt(e.id,`note`,t),onCommit:()=>void vt(e.id),onCancel:()=>Y(e.id)})}),(0,L.jsx)(`td`,{"aria-hidden":`true`}),(0,L.jsx)(`td`,{className:re,children:(0,L.jsxs)(`div`,{className:`flex items-center justify-end gap-0.5`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:()=>at({item:e}),"aria-label":`展开 ${e.title}`,className:`rounded p-1 text-stone-300 transition-colors hover:bg-stone-100 hover:text-stone-600 focus:text-stone-600`,children:(0,L.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,L.jsx)(`path`,{d:`M14 4h6v6`}),(0,L.jsx)(`path`,{d:`M20 4 13 11`}),(0,L.jsx)(`path`,{d:`M10 20H4v-6`}),(0,L.jsx)(`path`,{d:`M4 20l7-7`})]})}),(0,L.jsx)(`button`,{type:`button`,disabled:M,onClick:()=>G([e]),"aria-label":`删除 ${e.title}`,className:`tw-icon-danger rounded p-1`,children:(0,L.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,L.jsx)(`path`,{d:`M3 6h18`}),(0,L.jsx)(`path`,{d:`M8 6V4h8v2`}),(0,L.jsx)(`path`,{d:`M19 6l-1 14H6L5 6`}),(0,L.jsx)(`path`,{d:`M10 11v6M14 11v6`})]})})]})})]},e.id)}),t?null:H?.groupKey===e.key?(0,L.jsxs)(`tr`,{className:`tw-new-row`,children:[(0,L.jsx)(`td`,{className:`px-2 py-1 align-middle`}),(0,L.jsx)(`td`,{className:`px-1 py-1 align-middle text-xs text-stone-400 tabular-nums`,children:e.items.length+1}),(0,L.jsx)(`td`,{className:_,children:(0,L.jsx)(`input`,{autoFocus:!0,value:H.title,disabled:nt,placeholder:`输入待办名称,回车或点空白处保存`,onChange:e=>U(t=>t&&{...t,title:e.target.value}),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),bt()):e.key===`Escape`&&(e.preventDefault(),U(null))},className:`h-8 w-full truncate rounded-md border border-[#3370ff]/40 bg-white px-2 text-sm text-stone-800 outline-none focus:border-[#3370ff]`})}),(0,L.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(0,L.jsx)(b,{unstyled:!0,hideChevron:!0,centerContent:!0,ariaLabel:`待办状态`,menuMinWidth:120,options:Fe,value:H.status,onChange:e=>U(t=>t&&{...t,status:e}),triggerClassName:`h-7 w-full rounded-md px-2 text-center text-xs font-medium focus:ring-2 focus:ring-[#3370ff]/30 ${ke[H.status]}`,renderTrigger:()=>(0,L.jsx)(`span`,{className:`w-full truncate text-center`,children:w[H.status]})})}),(0,L.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:k?(0,L.jsx)(b,{unstyled:!0,searchable:!0,searchPlaceholder:`搜索任务…`,ariaLabel:`所属任务`,menuMinWidth:220,options:mt,value:H.taskId,onChange:e=>U(t=>{if(!t)return t;let n=D.find(t=>t.id===e);return{...t,taskId:e,...n?{priority:n.priority}:{}}}),triggerClassName:`h-8 w-full rounded-md px-1.5 text-sm hover:border-stone-200`,renderTrigger:()=>{let e=D.find(e=>e.id===H.taskId);return(0,L.jsx)(ce,{text:e?.title||`未关联`,className:`min-w-0 flex-1 truncate ${e?`text-stone-800`:`text-stone-300`}`})}}):(0,L.jsx)(`span`,{className:`block truncate px-1.5 text-xs text-stone-400`,children:`任务管理插件未启用`})}),(0,L.jsx)(`td`,{className:`px-1.5 py-1 align-middle`,children:(()=>{let e=D.find(e=>e.id===H.taskId);return e?(0,L.jsx)(`span`,{title:`跟随所属任务的紧急程度`,className:`flex h-7 w-full items-center justify-center truncate rounded-md px-2 text-center text-xs font-medium ${R[e.priority]??`text-stone-300`}`,children:e.priority?E[e.priority]:`未设置`}):(0,L.jsx)(b,{unstyled:!0,hideChevron:!0,centerContent:!0,ariaLabel:`紧急程度`,menuMinWidth:128,options:Ie,value:H.priority,onChange:e=>U(t=>t&&{...t,priority:e}),triggerClassName:`h-7 w-full rounded-md px-2 text-center text-xs font-medium focus:ring-2 focus:ring-[#3370ff]/30 ${R[H.priority]}`,renderTrigger:()=>(0,L.jsx)(`span`,{className:`w-full truncate text-center`,children:H.priority?E[H.priority]:`未设置`})})})()}),(0,L.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,L.jsx)(y,{value:H.startDate,onChange:e=>U(t=>t&&{...t,startDate:e}),placeholder:`选择日期`,className:`h-8 rounded-md border border-transparent px-1.5 text-sm text-stone-800 tabular-nums transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white`})}),(0,L.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,L.jsx)(y,{value:H.dueDate,onChange:e=>U(t=>t&&{...t,dueDate:e}),placeholder:`选择日期`,className:`h-8 rounded-md border border-transparent px-1.5 text-sm text-stone-800 tabular-nums transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white`})}),(0,L.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap tabular-nums`,children:de(H.status)?(0,L.jsx)(`span`,{className:`text-stone-500`,children:se(S())}):(0,L.jsx)(`span`,{className:`text-stone-400`,children:`待办未完成`})}),(0,L.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap text-stone-400 tabular-nums`,children:`—`}),(0,L.jsx)(`td`,{className:`px-2 py-1 align-middle text-xs whitespace-nowrap text-stone-400 tabular-nums`,children:`—`}),(0,L.jsx)(`td`,{className:`px-1 py-1 align-middle`,children:(0,L.jsx)(`input`,{value:H.note,disabled:nt,placeholder:`—`,onChange:e=>U(t=>t&&{...t,note:e.target.value}),className:`h-8 w-full truncate rounded-md border border-transparent bg-transparent px-1.5 text-sm text-stone-800 outline-none transition-colors placeholder:text-stone-300 hover:border-stone-200 focus:border-[#3370ff] focus:bg-white`})}),(0,L.jsx)(`td`,{"aria-hidden":`true`}),(0,L.jsx)(`td`,{className:`px-1 py-1 align-middle`})]}):(0,L.jsxs)(`tr`,{children:[(0,L.jsx)(`td`,{className:`px-2 py-0.5`}),(0,L.jsx)(`td`,{className:`px-1 py-0.5`}),(0,L.jsx)(`td`,{className:`px-1 py-0.5`,colSpan:12,children:(0,L.jsxs)(`button`,{type:`button`,disabled:nt,onClick:()=>yt(e),className:`flex items-center gap-1 rounded px-1 py-0.5 text-xs text-stone-400 transition-colors hover:bg-stone-100 hover:text-stone-600 disabled:opacity-40`,children:[(0,L.jsx)(`span`,{className:`text-sm leading-none`,children:`+`}),`新增记录`]})})]})]},e.key)}),wt.length===0?(0,L.jsx)(`tbody`,{children:(0,L.jsx)(`tr`,{children:(0,L.jsx)(`td`,{colSpan:14,className:`px-3 py-16 text-center text-sm text-stone-400`,children:d.length===0?`还没有待办`:`没有匹配的待办,试试调整搜索或筛选`})})}):null]})}),(0,L.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2 border-t border-stone-100 px-4 py-2.5 text-xs text-stone-500`,children:[(0,L.jsxs)(`span`,{children:[`共 `,Q.length,` 条`,Tt.length?` · 已选 ${Tt.length}`:``]}),(0,L.jsx)(`span`,{className:`ml-auto text-stone-400`,children:`点击单元格直接编辑,回车或点空白处保存`})]}),(0,L.jsx)(Ke,{open:it!==null,item:it?.item??null,preset:it?.preset,tasks:D,tasksOn:k,onClose:()=>at(null),onSaved:J}),(0,L.jsx)(f,{open:W!=null,title:W&&W.length>1?`批量删除`:`删除待办`,message:W&&W.length>1?`确认删除已选中的 ${W.length} 条待办?此操作不可恢复。`:`删除「${W?.[0]?.title??``}」?此操作不可恢复。`,confirmLabel:`删除`,cancelLabel:`取消`,danger:!0,onClose:()=>G(null),onConfirm:()=>void xt()})]}):(0,L.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:`待办事项需要本地服务,当前未就绪(仅 npm run dev / 本地一体服务可用)。`}):(0,L.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:a(`todos`)}):(0,L.jsx)(`div`,{className:`flex min-h-0 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,"aria-busy":`true`,"aria-label":`正在读取插件开关`,children:(0,L.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center`,children:(0,L.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})})})}export{B as default};